2

In Clojure, I can have a sequence a..b with (range a b). But this is a lazy sequence as I understand. Can I just generate a list and/or vector of numbers a..b?

Note: I am new to Clojure.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
demi
  • 5,384
  • 6
  • 37
  • 57
  • 1
    Possible duplicate: http://stackoverflow.com/questions/1641626/. Do you want a *non-lazy* vector? – Robert Harvey Jun 18 '13 at 18:05
  • @RobertHarvey I don't think that is a duplicate of this. This question seems broader in scope because it references converting between types as well. – Arthur Ulfeldt Jun 18 '13 at 18:12

1 Answers1

8

do you mean something like

user>  (vec (range 2 7))
[2 3 4 5 6]
user> (apply list (range 2 7))
(2 3 4 5 6)
user> (into [] (range 2 7))
[2 3 4 5 6]
user> (into '() (range 2 7))
(6 5 4 3 2) ; <-- note the order
user> (into #{} (range 2 7))
#{2 3 4 5 6}
Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284