Learn You Scala for Great Good! Part 4

Tags: , , , , ,

Learn You Scala for Great Good! Part 4

It’s my fourth post of the series where I told how I started studying Haskell in order to get knowledge in functional programming in Scala. You may see previous posts on this theme: Learn You Scala for Great Good! Learn You Scala for Great Good! Part 2 Learn You Scala for Great Good! Part 3 Today I want to take the three last examples from the Recursion Chapter. zip function It takes two lists and zips them together. zip [1,2,3] [2,3] returns [(1,2),(2,3)], because it truncates the longer list to match the length of the shorter one. Haskell zip ::

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