Haskell Keywords

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/4

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

5 Terms

1
New cards

Define a “recip” function which takes the reciprocal of a fractional type value.

recip :: Fractional a => a → a
recip n = 1/n

2
New cards

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

3
New cards

What does the ‘otherwise’ keyword imply?

It is defined in the prelude as otherwise = True.

4
New cards

What is the “:” symbol?

Called “cons”, it constructs a list by prepending a new element to teh start of an existing list.

5
New cards

What does the “\” symbol indicate?

A lambda expression!