Yes, seq? works. Thanks for the help! On Sun, Jan 8, 2012 at 9:03 PM, Cedric Greevey <cgree...@gmail.com> wrote:
> On Sun, Jan 8, 2012 at 10:30 AM, Samuel Lê <samuel...@gmail.com> wrote: > > Hi and Happy New Year to all the Clojure mailing list, > > > > I am am having some trouble with the two classes Cons and PersistentList: > > > > user> (class (conj (map #(+ % 1) '(1 2 3)) 4)) > > clojure.lang.Cons > > user> (class '(1 2 3 4)) > > clojure.lang.PersistentList > > > > My problem is that list? returns false for a Cons and true for a > > PersistentList. > > What can I do to make my Cons a PersistentList, or is there a way to use > > another function instead of list? that will return true for both classes? > > If any (...) structure will do, test with seq? instead. If you really > need a PersistentList, you'll probably have to call that class's > constructor or resort to icky hacks like > > user=> (class (apply list (cons 4 '(1 2 3)))) > clojure.lang.PersistentList > > (though much more evil would be > > user=> (class (eval `(quote ~(cons 4 '(1 2 3))))) > clojure.lang.PersistentList > > instead), because for some odd reason and despite its name (list* 4 > '(1 2 3)) returns a clojure.lang.Cons. > > -- > 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 -- 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