-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Hello reader!
This is my first attempt at a full program in Clojure.
It’s a simple boggle solver (that doesn’t take into account the letter Qu from the real game)
After so many years of programming in c++ it took me some time to get my head around approaching the problem in a functional way like this but I found it an excellent exercise to help me learn Clojure.
Most surprising was how easily data structures such as tries can be represented in Clojure.
I would love to hear comments regarding how to make it more idiomatic.
I’m sure it could be greatly improved and it might make an interesting example for others learning the language to see different versions.
I’d also like to hear comments on how to improve the speed.
James
I found a nice public one here which should give better results than the usual unix ones which are for spell checking and therefore contain ancronyms etc.
Note that in the performance tests below I didn’t use this word list.
2.4 GHz Core 2 Duo running OSX 10.6.1
Clojure 1.1.0-alpha-SNAPSHOT
Java™ SE Runtime Environment (build 1.6.0_15-b03-219)
Java HotSpot™ 64-Bit Server VM (build 14.1-b02-90, mixed mode)
java -server
Profiled with a modified version of the standard time macro
100 shakes…
It’s quite clear to see the effects of JIT optimising the code and it getting cached by the cpu.
Here’s for 1000 shakes…
Now the average of about 50ms is clear and zooming in on the tail shows…
The differences are because some boards will have lots more words on them than others leading to a big difference in the number of function calls.