Skip to content

Instantly share code, notes, and snippets.

@tonymorris
Created November 18, 2019 22:19
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonymorris/bbd43a9ca9d9f423b5c413eb49b5f094 to your computer and use it in GitHub Desktop.
Save tonymorris/bbd43a9ca9d9f423b5c413eb49b5f094 to your computer and use it in GitHub Desktop.
foldRight' ::
(b -> z -> z)
-> (a -> b)
-> z
-> [a]
-> z
foldRight' _ _ z [] =
z
foldRight' k f z (x:xs) =
k (f x) (foldRight' k f z xs)
map' ::
(([a] -> [a]) -> [b] -> [b]) -> (c -> a) -> [c] -> [b]
map' k f =
foldRight' k ((:) . f) []
program' ::
(([Int] -> [Int]) -> [a] -> [a])
-> [a]
program' k =
take 10 (map' k (+1) [1..])
terminates ::
[Int]
terminates =
program' id
doesNotTerminate ::
[Int]
doesNotTerminate =
program' ($!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment