I'm working through some puzzle problems to help get up to speed on
clojure. Generally I've been able to pound on something for a while
and get the moment of enlightenment but for some reason this seemingly
simple item is stumping me. (FWIW, the puzzle in question is the
crossing a bridge at night in pairs with one lantern problem).
Here is The output that is confusing me:
Using:
(defn not-seen-already? [states state]
(not (some #{state} states)))
user=> path
[{:left [1 2 3], :lamp :left, :right []} {:lamp :right, :left (2
3), :right (1)}]
user=> next-steps
({:lamp :left, :right (), :left (1 2 3)})
user=> next-steps2
[{:lamp :left, :right [], :left [1 2 3]}]
user=> (filter #(not-seen-already? path %) next-steps)
({:lamp :left, :right (), :left (1 2 3)})
user=> (filter #(not-seen-already? path %) next-steps2)
()
user=> (filter #(not-seen-already? path %) '({:lamp :left, :right
(), :left (1 2 3)}))
()
user=> (filter #(not-seen-already? path %) [{:lamp :left, :right
[], :left [1 2 3]}])
()
As you can see above, passing in the variable next-steps and next-
steps2 above into my expression I get two different results (I was
expecting the second result). When I pass the data structures in
explicitly I get the same result for each.
I'm assuming there is some obvious thing going on but after a few days
of staring at this off and on, I'm not making any progress (though I'm
half expecting a face palm when I understand the problem.)
Thanks in advance for any help.
dustin
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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