


















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Haskell functional programming
Typology: Essays (university)
1 / 58
This page cannot be seen from the preview
Don't miss anything!



















































Steve Zhang
@CiaD team in Scotiabank
I am Passionate about:
TDD, XP, Clean Code
Software craftsmanship
Learning, deliberate
practice
Pure
Elegant
Powerful
Anything that is
āeffectively computableā
can be computed by a
Universal Turing
Machine.
Alan Turing
Anything that is
āeffectively computableā
can be computed by
via Ī» Calculus.
Alonzo Church
Head
Body
(Expression)
Argument
Turing machine Lambda Calculus
Imperative Programming
ļ¼ Assembly
ļ¼ C / C++
ļ¼ Java
ļ¼ JavaScript
ļ¼ OO ā¦
Functional Programming
ļ¼ Lisp
ļ¼ Erlang
ļ¼ Haskell
ļ¼ Scala
ļ¼ F# ā¦.
A Programming paradigm based on
functions
Function is a first class citizen
can be a variable
passed as argument
return as a value
Roots in Lambda calculus
Same input always get the same result
Every subexpression can be substituted
by any other thatās equal to it in value
Easier to reason
RT functions will NOT
print on screen
output logs
Data canāt be changed after itās been
created
No assignment
No shared state
void quicksort (int *A, int len ) {
if ( len < 2) return ;
int pivot = A [ len / 2] ;
}
int i, j;
for ( i = 0 , j = len - 1 ; ; i++, j-- ) {
while ( A [ i ] < pivot ) i++;
while ( A [ j ] > pivot ) j--;
if ( i >= j ) break ;
int temp = A [ i ] ;
A [ i ] = A [ j ] ;
A [ j ] = temp;
quicksort ( A, i ) ;
quicksort ( A + i, len - i ) ;
}
quicksort :: Ord a => [a] ->
[a] quicksort [] = []
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)
where
lesser = filter (< p) xs
greater = filter (>= p) xs