At the edge of infinity

I couldn’t resist a catchy title for this one, as CIS 194 is all about lazy evaluation, which in turn can be used to create (virtually) infinite data structures.

Hy and Boolean algebra

Recently I started wondering how Boolean algebra actually worked in Hy. I knew that we followed usual Python conventions and was sort of aware of them, but decided to dig into deeper and see how things actually are.

Granted, Boolean algebra maybe doesn’t sound the most exciting subject, but I found the results interesting. This post looks into things if Python 3.4 and 0.12.1 development version of Hy are used.

Type classes

Next topic to learn in CIS 194 was type classes. They’re quite similar to interfaces in some other languages and used for similar purpose: polymorphism.

Ironman mode and sudden death

Many games feature iron man mode where saving is limited in a way or another in order to make the game more exciting or real. You can’t go back in your decisions in the real life either, or can you?

Higher order functions

4th week of CIS 194 got into meat of functional programming: higher order functions. These are functions that either take other functions as parameters or return functions when called. While I was very familiar with them before, Haskell has neat trick in the sleeve for them. Topics covered included anonymous functions, function composition, partial application and folds (again).

Getting familiar with Prelude

Week 3 of CIS 194 was about how to abstract different kinds of recursion patterns with help of map, folds and filter. As a side note, polymorphism was touched upon to show how to define functions that work on several different kinds of data types. Prelude (one of the standard modules of Haskell) was mentioned and encouraged to be explored a bit. Finally total and partial functions were discussed and their differences outlined.

Algebraic data types and some new control structures

Second lecture of CIS 194 introduced algebraic data types and some new control structures to deal with them.While this was familiar to me from the last time, I made sure to do each and every exercise, just in case as I haven’t been programming in Haskell for much at all.