1/4
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Define a “recip” function which takes the reciprocal of a fractional type value.
recip :: Fractional a => a → a
recip n = 1/n
How would you write the guarded equation version of the function abs, which finds the absolute value of an Int, Integer, Float or Double?
abs n | n >= 0 = n
| otherwise = -n
What does the ‘otherwise’ keyword imply?
It is defined in the prelude as otherwise = True.
What is the “:” symbol?
Called “cons”, it constructs a list by prepending a new element to teh start of an existing list.
What does the “\” symbol indicate?
A lambda expression!