Clojure

range function has missing documentation

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Trivial Trivial
  • Resolution: Unresolved
  • Affects Version/s: Release 1.2
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    All

Description

The range function's documentation does indicate the following usage:

(range 10 0 -1) -> (10, 9, 8, 7, 6, 5, 4, 3, 2, 1)

Current doc:

Returns a lazy seq of nums from start (inclusive) to end
(exclusive), by step, where start defaults to 0, step to 1, and end
to infinity.

Suggestion:

Returns a lazy seq of nums from start (inclusive) to end
(exclusive), by step, where start defaults to 0, step to 1, and end
to infinity.

Its also possible to step down rather than up, for example counting
backwards from 10 by -1: (range 10 0 -1).

Activity

Hide
Rasmus Svensson added a comment -

The current doc actually mentions the 'step' parameter briefly:

"[...] to end (exclusive), by step, where start [...]"

But as this might be easy to miss, an addition to the doc is still a good idea, I think.

My suggestion:

Returns a lazy seq of nums from start (inclusive) to end
(exclusive), by step, where start defaults to 0, step to 1, and end
to infinity. Step may be negative to count backwards.

Show
Rasmus Svensson added a comment - The current doc actually mentions the 'step' parameter briefly: "[...] to end (exclusive), by step, where start [...]" But as this might be easy to miss, an addition to the doc is still a good idea, I think. My suggestion: Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0, step to 1, and end to infinity. Step may be negative to count backwards.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated: