On Mon, Sep 19, 2011 at 2:20 PM, qhfgva <qhf...@gmail.com> wrote:
> 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 can't reproduce your results:

user=> (filter #(not-seen-already? path %) next-steps)
()

What does your REPL say if you: (= (first next-steps) (first path))
What version of Clojure are you using?

--Chouser

-- 
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

Reply via email to