Clojure

A range function for characters, char-range

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code

Description

I've seen a lot of cases where people would do stuff like this:

(def alphabet "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

Or other equally meh things in order to get a range of characters. Haskell's range supports creating ranges of characters, so that was inspiration for this addition.

I've created a function that is the analogue of range for characters. I've called it char-range. It works almost precisely the same as range (and uses range under the hood), only the upper bound isn't exclusive. It made more sense to me for it to be inclusive, so that things like (char-range \a \z) work and make sense.

It takes the same argument combinations as range. For no arguments, it produces a lazy sequence of characters from Character/MIN_VALUE to Character/MAX_VALUE. For two arguments, it produces a lazy sequence from Character/MIN_VALUE to end. It allows for the same stepping that range allows for as well.

Activity

Stuart Halloway made changes -
Field Original Value New Value
Approval Test
Stuart Halloway made changes -
Status Open [ 1 ] Closed [ 6 ]
Resolution Declined [ 2 ]

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: