Created
October 22, 2011 20:52
-
-
Save jameskeane/1306481 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Coffeescript + types + haskell = compiled language | |
========= | |
- Increments an infinite precision number, represented as a linked list with least significant digit as head | |
increment = (x: [Num]) -> | |
switch x | |
when [] then [1] | |
when (9::tail) then 0::increment(tail) | |
when (h::t) then (h+1)::t | |
- Increments an infinite precision number, represented as a linked list with least significant digit as head | |
decrement = (x: [Num]) -> | |
switch x | |
when [1] then [] | |
when (0::tail) then 9::decrement(tail) | |
when (h::t) then (h-1)::t | |
- Quicksort | |
quicksort = (x: [Ord]) -> | |
switch x | |
when [] then [] | |
when (h::t) then l | |
smallerSorted ++ [x] ++ biggerSorted | |
where | |
smallerSorted = quicksort [a | a <- t, a <= h] | |
biggerSorted = quicksort [a | a <- t, a > x] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment