Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tommay/sudoku-in-erlang
Thrashing in Erlang and learning a lot.
https://github.com/tommay/sudoku-in-erlang
Last synced: about 6 hours ago
JSON representation
Thrashing in Erlang and learning a lot.
- Host: GitHub
- URL: https://github.com/tommay/sudoku-in-erlang
- Owner: tommay
- License: mit
- Created: 2015-02-14T05:09:59.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-15T00:54:10.000Z (about 8 years ago)
- Last Synced: 2023-04-19T16:52:49.960Z (over 1 year ago)
- Language: Erlang
- Size: 86.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
sudoku
======A little sudoku solver in Erlang. This is sort of a port of my
[sudoku solver](https://github.com/tommay/sudoku) done in various
other languages (Ruby, JavaScript, CoffeeScript) but Erlang is a
different beast entirely even for a Lisp hacker. I've been learning a
lot about how to do functional programming somewhat cleanly in Erlang
with a module per "object", tagged values, etc. Functional
programming seems to demand a "tell, don't ask" style and violating
the law of Demeter is right out. So it should be a good influence on
my designs in other languages. At least I've been a fan of
immutability for decadesThis finally works! I made an escript executable that takes a filename
and prints any solutions.I've gotten quite comfortable with the pattern matching and like it a
lot. If we get this, do that. If we get something else, do the other
thing. Give this piece of the arguments a name so we can use it
later.It's not clear whether I'll be sticking with some of my design
approaches. It's also strictly functional with no actors or
concurrency. I'll play with those later, probably when I add
statistics of the various techniques.Update: I wanted multiple processes when solving puzzles with multiple
solutions so I could use all available cores. But that made an
overwhelming number of processes for Erlang to deal with and it would
run out of memory and crash. So now there is a limiter process which
tracks the number of spawned processes and doesn't allow more than N
to run at once. There is also a stats server process.Somtimes it still feels weird to be writing functions that "don't do
anything"; they just look at their arguments and return some new junk,
often a slightly modified copy of itself. It's like telling a dog to
walk across the room, but instead of actually walking across the room
it creates a new dog that's on the other side of the room and you use
that dog instead. And you still have the old dog on your side of the
room, until you ignore it long enough and the garbage collector cleans
it up.