Arc Forumnew | comments | leaders | submitlogin
6 points by fallintothis 6171 days ago | link | parent

Incorporating the step parameter as in Python's indexing notation could also be interesting:

  "abcdefghijklmnopqrstuvwxyz"[10:2:-1] #=> "kjihgfed"
  "abcdefghijklmnopqrstuvwxyz"[2:20:2] #=> "cegikmoqs"
The one way that it might not work so hot in an s-expression is Python's blanking-out of indexes to indicate the default, e.g.,

  "abcdefghi"[::-2] #=> "igeca"
I'd like to see as much of this sort of range functionality as possible -- it's quite convenient -- but in an s-expression the above would be something like

  ("abcdefghi" -2) ;no distinction!
Perhaps use _ or some other symbol for the default? The cleanest would probably be to stick to the one-plus-optional-second-or-third format and just have a function that collects every nth element (then negative steps with default begins / ends would also be a chain of rev and firstn / nthcdr). Just my two cents.


9 points by simonb 6171 days ago | link

To me blanking is expressed most naturally as nil.

-----