ClojureScript

Range issues

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test

Description

Problem
There are a number of bugs with Range which occur when the step size is 0 or where negative.

Examples

cljs.user=> (count (range 10 0 0))
-Infinity  ;Expect Infinity

cljs.user=> (nth (range 10 0 -1) -1)
11 ; Expected IndexOutOfBounds

cljs.user=> (take 5 (sequence identity (range 0 10 0)))
() ; Expected (0 0 0 0 0)

cljs.user=> (into [] (take 5) (range 0 10 0))
[] ; Expected [0 0 0 0 0]
  1. CLJS-1846.2.patch
    15/Nov/16 8:24 AM
    12 kB
    Thomas Mulvaney
  2. CLJS-1846.patch
    10/Nov/16 8:02 AM
    12 kB
    Thomas Mulvaney

Activity

Hide
David Nolen added a comment - - edited

This patch is headed in the right direction but it needs to be more vigilant about performance. I'm more than happy to talk it over via IRC or Slack. Thanks!

Show
David Nolen added a comment - - edited This patch is headed in the right direction but it needs to be more vigilant about performance. I'm more than happy to talk it over via IRC or Slack. Thanks!
Hide
Thomas Mulvaney added a comment -

Updated patch with performance tweaks.

  • Added the ^boolean annotation to the `some-range?` helper.
  • Removed calls to methods of Range where possible.
  • Improved 2-arity reduces performance over master significantly by replacing the call to ci-reduce.
Show
Thomas Mulvaney added a comment - Updated patch with performance tweaks.
  • Added the ^boolean annotation to the `some-range?` helper.
  • Removed calls to methods of Range where possible.
  • Improved 2-arity reduces performance over master significantly by replacing the call to ci-reduce.
Hide
Mike Fikes added a comment -

Patch no longer applies; needs re-baseline.

Show
Mike Fikes added a comment - Patch no longer applies; needs re-baseline.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated: