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 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, Ord

Continue Reading