Does Scheme/Racket have an enumeration notation equivalent to the [a..b] notation in Haskell?
In Haskell, [1..5] evaluates to a list [1,2,3,4,5].
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
(for/list ([i (in-range 1 6)]) i)
(sequence->list (in-range 1 6))
(require srfi/1) (iota 5 1)
回答2:
(for/list ([i 5]) (+ 1 i))
(build-list 5 add1)
Also, (in-range 1 6)
(which is a sequence) by itself is useful in many contexts.