Posts

Hi I'm Kyle CS @ UofE, interested in Computer & Network Security.

Functions

Functions, functions, functions; Haskell is all about functions. When writing Haskell code we create, compose and apply functions to achieve our goal. What is a function In Haskell a function takes one or more things (referred to as arguments), and will give you back something else (referred to as the output or return value). So to recap, a Haskell function takes something and gives something else back. This is all a ‘normal’ function can do in Haskell, I will discuss the ‘non-normal’ functions, ones that can effect the program state later, they are more advanced.

Lists and Comprehensions

Welcome back to the next post now we will be learning about List and comprehensions, they form a large part of a typical Haskell program, so lets find out more about them now. The List 1 2 3 4 5 6 7 8 9 10 11 12 13 14 nums :: [Int] nums = [1,2,3] chars :: [Char] chars = ['h', 'a', 's', 'k', 'e', 'l', 'l'] str :: String str = "haskell" funcs :: [[Int] -> Int] funcs = [product, sum] evenList :: [Int] evenList = [0,2.

Recursion

Our research into Haskell Lists continues. Before we can look into using recursive functions with lists, I think first we need to cover what recursion is. In my opinion recursion is one of the most important concepts for any Functional Programmer. Recursion: Where a function calls its self from within its definition. Case: A condition that could happen, eg the number could be zero or it may not be.