Basic library functions Flashcards
What does the library function head do?
Returns the first element of a list
What does the library function tail do?
Removes the first element and returns the list
What does !! do?
Selects the nth element of a list
What does take do?
Select the first n elements of a list
What does the function drop do?
Removes the first n elements from a list and returns list
What does function length do?
Returns the length of the list
What does the function sum do?
Add the elements in the list together and return the result
What does the function product do?
Multiplies each element in the list together and returns the result
what does the operation ++ do?
Appends two lists together
What does the function reverse do?
Reverses a list
Name as many library functions as you can!!
head
tail
take
drop
reverse
!!
++
length
sum
product
What is the principle of Haskell?
Write clear concise and correct code
What is some of Haskells syntax?
- No capital letters for function names
- Back quotes for strings/characters
- Brackets around functions in functions