Learning Koka 2022-07-30

By Max Woerner Chase

Hey, guess what I remembered I could do!

Anyway, I messed around with some advice on "first programs to write in any language". The second thing it had me do was code up a subtraction game and an AI for it. It took me a long time to get it to compile, but once it compiled, everything worked perfectly and it beat me.

My impressions from getting it working were that using var and while together isn't worth it, and I ended up avoiding both by just rewriting everything as tail calls. I think I'm going to need to experiment with var, and later while, and try to get a handle on when to use them. Lastly, it seems to be better to write small functions, so they rack up fewer effects and it's easier to see where they're coming from.

I bet I could also make the code a bit nicer by cutting down on the mutual tail recursion, and coordinating stuff at a higher level, but I'm not going to try to figure that out right now.

One thing I'm interesting in figuring out is "the right" way to handle mapping objects. My gut feeling is that, if I try this, I should see how far I can get with association lists, unless I missed something that already does mapping.

Anyway, I'm wiped out and I'm going to try to get to bed earlier.

Good night.