Haskell Flashcards
Instead of the + symbol, Haskell uses the symbol ANSWER for a string concatenation operator
.
++
The type of a string constant in Haskell by default is written ANSWER.
[Char]
In Haskell, you use the keyword ANSWER to collect related code into a similar scope.
module
In Haskell, if I define a function double x = x + x its type signature would be ANSWER.
(Num a ) => a -> a
In Haskell, instead of writing something like if x ==0 then 1 else fact (x-1)*x, you can write a series of lines starting with factorial 0 = 1. This second style is called ANSWER.
pattern matching
In Haskell, instead of writing something like if x==0 then 1 else fact (x-1) x, you can write a series of lines starting with | x > 1 = x factorial (x-a). This second style is called ANSWER.
using guards
In Haskell, instead of writing something like second x = head(tail(x)), you can write this without introducing the parameter x by using function composition. Doing that, you would define second by ANSWER.
second = head . tail
In Haskell, if I write (h:t) = [3 , 5 ,7], ANSWER is the value of h.
3
In Haskell, if I write (h:t) = [3, 5, 7], ANSWER is the value of t.
[5,7]
In Haskell, ANSWER is the output of zip [17…20] [10 , 8 ….4].
[(17,10),(18,8),(19,6), (20,4)]
In Haskell, ANSWER is the output of zip [20….17] [10,8…4]
[]
Default increment is 1 and zip only goes as far as shortest argument list
In Haskell, the anonymous function ANSWER causes the expression ‘map ANSWER [1,2,3]’ to produce [-4, -5, -6].
(\x-> - (x+3))
In Haskell, if we want to define a local named function inside a function definition, we use the keyword ANSWER.
where
In Haskell, the type signature of the function sum x y = x + y is ANSWER.
(Num a ) => a -> a -> a
In Haskell, given the definition sum x y = x + y, ANSWER is the value of that is produced by the expression (sum 3).
(\x -> 3 + x)