Learn You Scala for Great Good! Part 3

Learn You Scala for Great Good! Part 3

In my previous posts Learn You Scala for Great Good! and Learn You Scala for Great Good! Part 2 I told how I started studying Haskell in order to get knowledge in functional programming in Scala. While I was reading Learn You a Haskell for Great Good! I started to “translate” some examples from Haskell into Scala. Today I shall take some interesting examples from the Recursion chapter of this book. replicate function The replicate function takes an Int and some element and returns a list that has several repetitions of the same element.   Haskell replicate :: (Num i,

Continue Reading

Learn You Scala for Great Good! Part 2

Last time I wrote about my experience in learning of functional programming basics using Learn You a Haskell for Great Good! with accent on Scala. Today I’m going to use an example from the Recursion chapter. Maximum awesome In Haskell example the maximum function takes a list of things that can be ordered (e.g. instances of the Ord typeclass) and returns the biggest of them. maximum :: (Ord a) => [a] -> a maximum [] = error “maximum of empty list” maximum [x] = x maximum (x:xs) | x > maxTail = x | otherwise = maxTail where maxTail =

Continue Reading

Learn You Scala for Great Good!

I came to Scala from Java. So when I wanted to learn Scalaz, I didn’t know what to start with. I decided that the best way would be to start with functional programming. It’s strange but the best manual was Learn You a Haskell for Great Good! Yes, I chose my way: I started learning Haskell in order to know Scala better! For better understanding I started to “translate” Haskell examples into Scala. Now I have decided to publish these examples. Guards, guards! We’re going to make a simple function that berates you differently depending on your BMI (body mass

Continue Reading