I wanted to write a prime generator, but all the popular languages already have optimised ones I can't compete with.
commented version: https://gist.github.com/olligobber/0445a1721eb22b1d5b65bb4d4becdbf6
I'm just surprised, as I'm pretty sure without recursive types or values it is impossible to define fix, but I didn't know recursive types could help.
The usual definition of fix is `fix f = f (fix f)', which is not a combinator as it uses itself in its definition, but since my definition only uses abstraction and application it might count. The only small cheat is the newtype constructor and destructor, but after compiling those are just the identity function, so I think this counts.
all language is made up and anyone saying "the rules say you can't" doesn't actually care what's correct, they just prefer the old version because it's more bigoted
"Looking at millions of cat pictures would be a nice way to spend a lifetime" - https://blog.cy.md/2021/03/24/solving-xkcd-1683/
To be clear, I haven't actually proven they aren't equivalent, I'm just pretty sure they are.
Oh, I guess it doesn't always output the virus. For example, (\xy.yx)(Virus) = \y.y(Virus), which isn't equivalent to the "virus", but is somewhat infected.
Well, it doesn't output exactly the virus, but something equivalent to the virus.
@olligobber every application, whether it knows it or not, draws a line of trust somewhere. With user input the line tends to be quite close to the concept of 'security' but there's no rule that says you can't choose to eat the distrust line like a piece of delicious abstract spaghetti and let everyone do whatever they like
Mathematician and design enthusiast. Computing, music, science, video games and art.
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!