Skip to content

Instantly share code, notes, and snippets.

@v2m
Created July 2, 2014 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save v2m/87911eb452fc63bbbc47 to your computer and use it in GitHub Desktop.
Save v2m/87911eb452fc63bbbc47 to your computer and use it in GitHub Desktop.
let rec takeWhileFreshConsTail cons p l =
match l with
| [] ->
setFreshConsTail cons []
| x::xs ->
if p x then
let cons2 = freshConsNoTail x
setFreshConsTail cons cons2
takeWhileFreshConsTail cons2 p xs
else
setFreshConsTail cons []
let takeWhile p l =
match l with
| [] -> []
| [x] -> if p x then l else []
| x::xs ->
let cons = freshConsNoTail x
takeWhileFreshConsTail cons p xs
cons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment