4 ms·
AoC is often used to learn a new programming language, but it can also be used to improve them—especially less established ones. Theres a small community [0] o
by reikonomusha 5y ago
AoC is often used to learn a new programming language, but it can also be used to improve them—especially less established ones.
Theres a small community [0] of people who decided to try out Coalton [1], which is a Common Lisp DSL that has a strict, Haskell-like type system, and has strict evaluation (not lazy) semantics. Pattern matching, algebraic data types, all that jazz are supported directly in a Common Lisp environment.
For example, here is a function to read in the first problem's data, which makes use of the usual high order functions (map and filter), as well as currying (only one argument provided to /=, making it curried):
(declare read-aoc-data (Unit -> (List Integer)))
(define (read-aoc-data _)
"Read the data for problem 1."
(let ((data (fromSome "Couldn't read AOC1 data."
(read-file-into-string aoc1-input-file))))
(map parse-int-or-fail
(filter (/= "") (split-string #\Newline data)))))
Type annotations, as in any good ML, are optional (except when there are polymorphism bugs, like one found during AoC!). Unlike Haskell, purity isn't demanded.
There's a small contest [2] with all sorts of prizes for doing AoC in Coalton and contributing back to the project through tutorials, PRs, and bug reports.
[0] They hang out on Discord https://discord.gg/cPb6Bc4xAH https://discord.gg/cPb6Bc4xAH
[1] https://github.com/coalton-lang/coalton https://github.com/coalton-lang/coalton
[2] https://coalton-lang.github.io/20211129-aoc-contest/ https://coalton-lang.github.io/20211129-aoc-contest/
- dunefox 5y agoOh man, I'm using CL for aoc this year and just figured out how to install Coalton. Maybe I'll do couple of days in it as well!
- mynameisash 5y agoI didn't know anything about AoC until just recently when I took a very brief look at the 2020 problems (but didn't deep-dive). I'm trying to find good problems that can help me learn SAT/SMT solvers, but there doesn't seem to be much out there. Anyone know how well-suited these are for AoC?