On 8 Oct 2015, at 09:15, r/ Wobben <wobbe...@gmail.com> wrote: > I have now this : > > (ns fourclojure.core > (:gen-class)) > > > (defn checker [x] > ( = x (if (string? x) > (clojure.string/reverse x) > (into (empty x) (reverse x))))) > > > (checker '(1 2 3 4 5)) true > > > ( = '( 1 2 3 4 5) '( 5 4 3 2 1) ) false > > So something is wrong about my code > > it works fine with string but not with a set
First, ‘(1 2 3 4 5) is a list, not a set. Second, (reverse ‘(1 2 3 4 5)) is ‘(5 4 3 2 1) and according to the docs for into https://clojuredocs.org/clojure.core/into that function conjoins items from (reverse ‘(1 2 3 4 5)) onto (empty ‘(1 2 3 4 5)). The docs for conj tell you what will happen https://clojuredocs.org/clojure.core/conj (empty ‘(1 2 3 4 5)) is a list and conjoining to a list puts items at the front of the list not the back, so it puts 5 in at the from, then puts 4 in front of the 5 and so on. So you are doing ( = '( 1 2 3 4 5) ‘(1 2 3 4 5)). Alan -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.