There is a pretty wide range of ways to solve problems in Clojure,
arguably more so than Python.  This isn't exactly how I'd code it, but
there's nothing so egregious in it that I'd call it un-idiomatic.  I'd
probably use keywords rather than strings.  I'd probably use lists
rather than some of these more specialized data structures (based on
an untested hunch that for these really small collections, it would
actually be more efficient to just use straight lists).  And I'd
probably avoid using so many nested map/filter/some/partial
higher-order functions in one-line, just because it can get rather
complicated to read and understand.  I'd maintain a list of cells to
still be analyzed, rather than recursing on the entire grid state so
that the stuff to be processed shrinks as the solution progresses.

But really, Sudoku solvers are so fast, it's way more important to
write it in a way that you consider easy-to-read and elegant.  I read
Norvig's approach just now, and since he comes from a Lisp background,
his Python code is fairly "functional" in style already.  So if you
like that algorithm, I agree with your conclusion that a port of that
to Clojure should be fairly straightforward and be equally or more
clean (no need to copy values).

When someone says that Clojure code is un-idiomatic, I usually assume
that's because it relies too heavily on state, or an algorithm that
feels "loopy" when a recursive formulation would be more natural, or a
misuse of Clojure's built-in data structures, or a misunderstanding of
laziness.  But I don't see any of that here, so I would say that the
code is basically fine.

Now if you really want a challenge, try to make the solver distribute
the propagation and search across multiple processors :) .

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