week 1 Flashcards
Briefly describe the imperative programming paradigm
memory + assignment + control structures
how
Briefly describe the functional programming paradigm
function application (How)
Give the definition of add 1, using lambda calculus
add_one(x) = \x.(x+1) add_one(3) = (\x.(x+1))(3)
what does pure mean in programming paradigms?
no side effects
how do side effects occur?
via assignments (state changes) and many imperative structures
Define polymorphic types
functions with a generic type
describe type inference
no type annotation, the computer can work out the type statically at compile time
write the quicksort algorithm in Haskell
qsort[] = []
qsort(x : xs) =qsort smaller ++ [x] ++ qsort larger
where
smaller = [ a | a x]
describe functional programming in a restricted sense
programming without mutable variables, assignments, loops and other imperative control structures
what is a function in functional programming?
values that are produced, consumed, and composed
when we say imperative programming focuses on WHAT, what is the WHAT?
describing inputs, outputs, and the I/O relationships