Skip to content

Instantly share code, notes, and snippets.

@vsalbaba
Created February 10, 2011 16:01
Show Gist options
  • Save vsalbaba/820767 to your computer and use it in GitHub Desktop.
Save vsalbaba/820767 to your computer and use it in GitHub Desktop.
faktorial 0 = 1
faktorial 1 = 1
faktorial n = if (n < 0)
then error "ArgumentError: Negative argument"
else (*) n (faktorial ((-) n 1))
ahoj = 3
--- fibonaci
fib 0 = 1
fib 1 = 1
fib n = (+) (fib (n-1)) (fib (n-2))
fib' n = f 0 1 n
where
f x _ 0 = x
f x y n = f y (x + y) (n - 1)
spoj [] ys = ys
spoj (x:xs) ys = x:(spoj xs ys)
obrat [] = []
obrat (x:xs) = spoj (obrat xs) [x]
filtrujsuda = filter even
quicksort [] = []
quicksort (x:xs) = (quicksort (filter (<x) xs))++[x]++(quicksort (filter (>x) xs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment