by nemo1618 · 3y ago · 0 comments
I did: 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_zDbInYOpQAoC solutions here: https://github.com/lukechampine/advent/tree/master/2022
(The language has builtin commands for fetching inputs and submitting solutions)
: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.
The lambda formation is something that will have to be gnawed at though.