functions Flashcards
min
min x y
if x ≤ y
then x
else y
x, y ∈ ℝ
succ
succ x = x + 1
x ∈ ℝ
max
max x y
if x ≥ y
then x
else y
x, y ∈ ℝ
&&
boolean „and”
||
boolean „or”
:
x:[]
adds x to list []
x ∈ ℝ
let
defines right in ghci
!!
!! n
gets the n-th element of the list (indices begin with ‘0’)
head
takes a list and returns its first element
tail
takes a list and returns it without the head as element
last
takes a list and return its last element
init
takes a list and returns it without the last element
length
takes a list and returns the amount of elements
null
checks if a list is empty
reverse
reverse [a,b,c]
→[c,b,a]
take
take 3 [a,b,c,d,e]
→[a,b,c]
drop
drop 3 [a,b,c,d,e]
→[c,d,e]
maximum
takes a list of stuff, that can be put in some kind of order and returns the biggest element
minimum
like maximum, but returns the smallest element
not
boolean „not“
sum
takes a list of numbers and returns their sum
product
takes a list of numbers and returns their product
elem
takes a thing and a list of things and tells us if that thing is element of the list
mod
mod a b
returns the remainder of a when divided with b
odd
odd a
returns True on an odd number and False on an even one