Created
October 26, 2015 19:48
-
-
Save acfoltzer/f34e4ae122e2749f66a2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
emptyK :: r -> r | |
emptyK = id | |
myLength :: [a] -> (Int -> r) -> r | |
myLength xs k = | |
case xs of | |
[] -> k 0 | |
(_:xs') -> myLength xs' $ \n -> k (n+1) | |
ex1 = myLength [] emptyK | |
ex2 = myLength [1..10] emptyK | |
showLengths :: [[a]] -> (String -> r) -> r | |
showLengths xss k = | |
case xss of | |
[] -> k "" | |
(xs:xss') -> myLength xs $ \n -> | |
showLengths xss' $ \s -> | |
k (show n ++ ", " ++ s) | |
ex3 = showLengths [[], [1..10]] emptyK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment