On Fri, Aug 29, 2008 at 2:29 PM, noahr <[EMAIL PROTECTED]> wrote: > > 1) What's a good way to add to the end of a list? > > You could reverse it then cons then reverse it again > You could convert to vector and use (conj.. or some such > > Both of the above seem very kludgey
Hi, Appending to a list is kludgey in general. Clojure's PersistentLists are singly-linked lists (like Lisp's cons cells), and appending onto their tails is O(n) because the entire list must be traversed to find the tail (and IIRC because the source list is Persistent, the entire structure must be reconstructed. This isn't the case for prepending to a list, though). If you need to append, or want append/prepend/insert functions, pick a better data structure (like vectors). Best, Graham --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---