Generate character sequence from 'a' to 'z' in clojure

后端 未结 4 1457
夕颜
夕颜 2021-01-01 20:28

I want to generate character sequence from \'a\' to \'z\'. In scala, I can generate character sequence very simply:

(\'a\' to \'z\')

But in

4条回答
  •  遥遥无期
    2021-01-01 21:05

    If you're interested in a library that gives you a convenient char-range function, my library djy has one: see djy.char/char-range.

    boot.user=> (char-range \a \z)
    (\a \b \c \d \e \f \g \h \i \j \k \l \m \n \o \p \q \r \s \t \u \v \w \x \y \z)
    

    It even handles supplemental Unicode characters that are large enough that they require 2 characters, representing them as strings:

    boot.user=> (char-range (char' 0x1f910) (char' 0x1f917))
    ("

提交回复
热议问题