5 ms·
> The title is clickbait. I did not design and implement a programming language for the sole or even primary purpose of leaderboarding on Advent of Code. I did
by nemo1618 3y ago
> The title is clickbait. I did not design and implement a programming language for the sole or even primary purpose of leaderboarding on Advent of Code.
I did: https://github.com/lukechampine/slouch https://github.com/lukechampine/slouch
"Find all ten-letter words that contain each of the letters A, B, and C exactly once and that have the ninth letter K"
:load wordlist wordlist.txt
words wordlist | filter -:(len == 10 and .8 == "k")
A more interesting example: https://www.youtube.com/watch?v=i_zDbInYOpQ https://www.youtube.com/watch?v=i_zDbInYOpQ
AoC solutions here: https://github.com/lukechampine/advent/tree/master/2022 https://github.com/lukechampine/advent/tree/master/2022
(The language has builtin commands for fetching inputs and submitting solutions)
- brandly 3y agoYou should write a longer post about it!
- jodrellblank 3y agoHow does that do the fiddly bit "contain each of the letters A, B, and C exactly once" ?
- nemo1618 3y agoShoot, I totally overlooked that part. Here's the proper version: :load wordlist wordlist.txt =hasABC { all (count _ x == 1) "abc" } words wordlist | filter -:(len == 10 and hasABC and .8 == "k") Notes: { } defines a lambda with parameters named x,y,z,a,b,c... _ is the same as in noulith -- it turns any expression into a lambda. Values can also be omitted from most expressions (e.g. len == 10) for the same effect. -: takes a lambda with n parameters and turns it into a lambda that takes 1 parameter and replicates it n times.
- jodrellblank 3y agoThat is neat!
- bear8642 3y ago> words wordlist | filter -:(len == 10 and .8 == "k") This feels very similar to an APL or K solution. Are those languages you're aware of?
- nemo1618 3y agoOh yes -- I've never developed serious competency in them, but Arthur Whitney and Aaron Hsu are among my programming heroes :)
- x-complexity 3y agoIt definitely has a kind of "I have something I want to do, let me hack at it" feel. Love anything that helps with that. :) The lambda formation is something that will have to be gnawed at though.