Skip to content

Instantly share code, notes, and snippets.

@Baha
Created December 17, 2011 17:20
Show Gist options
  • Save Baha/1490798 to your computer and use it in GitHub Desktop.
Save Baha/1490798 to your computer and use it in GitHub Desktop.
A well functioning definiton for the add function in a partial evaluator.
> add :: [(String,[Expr])] -> [(String,[Expr])] -> [(String,[Expr])] -> [(String,[Expr])]
>
> add succ pending marked = difference (union pending succ) marked
>
> union pending [] = pending
> union pending (call:res)
> | elem call pending = union pending res
> | otherwise = union (call:pending) res
>
> difference pend marked = [x | x <- pend, not (elem x marked)]
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment