Skip to content

Commit

Permalink
day 6: haskell intro
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnadel committed Feb 3, 2016
1 parent a9ae472 commit 4315282
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions recursion.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sumsq 0 = 0
sumsq n = n ^ 2 + sumsq (n - 1)

sumLinear [] = 0
sumLinear (x:xs) = x + (sumLinear xs)

sumTail lst = sumTailHelper lst 0
sumTailHelper [] total = total
sumTailHelper (x:xs) total = sumTailHelper xs (total + x)

sumFoldr lst = foldr (+) 0 lst
5 changes: 5 additions & 0 deletions syntax.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

cmp a b
| a < b = -1
| a > b = 1
| otherwise = 0

0 comments on commit 4315282

Please sign in to comment.