Re: turn a seq into a list
But in this particular case (calling (apply list seq)) since we want to create a data structure that will hold the whole seq at once, then apply will not prevent seq from being of a great length, it's the memory heap that will. (I think the question was more : does apply have some "hard coded" limitation on the size of the arg list passed) Regards, -- Laurent 2009/7/16 Drew Raines > > jvt wrote: > > > Doesn't apply have a limit on the length of the arguments passed, > > too? > > Yes. > > http://groups.google.com/group/clojure/msg/34b9a170d36c5ab5 > > -Drew > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: turn a seq into a list
jvt wrote: > Doesn't apply have a limit on the length of the arguments passed, > too? Yes. http://groups.google.com/group/clojure/msg/34b9a170d36c5ab5 -Drew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: turn a seq into a list
Hi, On Jul 16, 1:43 pm, jvt wrote: > Doesn't apply have a limit on the length of the arguments passed, too? apply is lazy. user=> (defn foo [& args] (take 5 args)) #'user/foo user=> (apply foo (iterate inc 0)) (0 1 2 3 4) Sincerely Meikel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: turn a seq into a list
Doesn't apply have a limit on the length of the arguments passed, too? On Jul 16, 7:22 am, Jan Rychter wrote: > Jarkko Oranen writes: > > On Jul 15, 1:54 pm, Jan Rychter wrote: > >> I've been looking for a function that would take a seq and create a list > >> (a real clojure.lang.PersistentList), but haven't found one. The closest > >> I got was: > > >> (apply list my-seq) > > >> Essentially, I'm looking for something similar to (vec) that returns > >> lists. > > >> --J. > > > Why would you want to do this? Seqs are nearly identical to lists (The > > only difference I can think being that lists are Counted, while seqs > > are not). If it's about forcing strictness, You can use 'doall. > > I rely heavily on count being O(1). I have stacks implemented on top of > lists and if those lists turn into seqs, the performance impact is huge. > > > However, if you really do need a PersistentList, then (apply list the- > > seq) is what you need. The vec function is a shortcut for (apply > > vector the-seq), provided in the standard library because vectorising > > a seq is rather common. > > Based on my (admittedly limited) experiments with a profiler, apply > seems to be a rather heavyweight tool. And vec doesn't seem to be a > shortcut for apply, it seems it creates the structure directly: > > (defn vec > "Creates a new vector containing the contents of coll." > ([coll] > (. clojure.lang.LazilyPersistentVector (createOwning (to-array coll) > > --J. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: turn a seq into a list
Jarkko Oranen writes: > On Jul 15, 1:54 pm, Jan Rychter wrote: >> I've been looking for a function that would take a seq and create a list >> (a real clojure.lang.PersistentList), but haven't found one. The closest >> I got was: >> >> (apply list my-seq) >> >> Essentially, I'm looking for something similar to (vec) that returns >> lists. >> >> --J. > > Why would you want to do this? Seqs are nearly identical to lists (The > only difference I can think being that lists are Counted, while seqs > are not). If it's about forcing strictness, You can use 'doall. I rely heavily on count being O(1). I have stacks implemented on top of lists and if those lists turn into seqs, the performance impact is huge. > However, if you really do need a PersistentList, then (apply list the- > seq) is what you need. The vec function is a shortcut for (apply > vector the-seq), provided in the standard library because vectorising > a seq is rather common. Based on my (admittedly limited) experiments with a profiler, apply seems to be a rather heavyweight tool. And vec doesn't seem to be a shortcut for apply, it seems it creates the structure directly: (defn vec "Creates a new vector containing the contents of coll." ([coll] (. clojure.lang.LazilyPersistentVector (createOwning (to-array coll) --J. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: turn a seq into a list
Hi, On Jul 15, 1:41 pm, Jarkko Oranen wrote: > Essentially, I'm looking for something similar to (vec) that returns > lists. There is also list*. But that returns Cons's not a PersistentList's. Cons is not Counted... Sincerely Meikel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: turn a seq into a list
On Jul 15, 1:54 pm, Jan Rychter wrote: > I've been looking for a function that would take a seq and create a list > (a real clojure.lang.PersistentList), but haven't found one. The closest > I got was: > > (apply list my-seq) > > Essentially, I'm looking for something similar to (vec) that returns > lists. > > --J. Why would you want to do this? Seqs are nearly identical to lists (The only difference I can think being that lists are Counted, while seqs are not). If it's about forcing strictness, You can use 'doall. However, if you really do need a PersistentList, then (apply list the- seq) is what you need. The vec function is a shortcut for (apply vector the-seq), provided in the standard library because vectorising a seq is rather common. -- Jarkko --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
turn a seq into a list
I've been looking for a function that would take a seq and create a list (a real clojure.lang.PersistentList), but haven't found one. The closest I got was: (apply list my-seq) Essentially, I'm looking for something similar to (vec) that returns lists. --J. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---