Created
January 16, 2017 20:26
-
-
Save deque-blog/654519ddf0ab16db665c7e7aa11b8899 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
dependencies :: Expr -> Set.Set Id | |
dependencies (Var v) = Set.singleton v | |
dependencies (Op _ xs) = foldl1' Set.union (map dependencies xs) | |
dependencies e = Set.empty | |
eval' :: Env -> Expr -> Int | |
eval' env e = | |
case optimize (partial env e) of | |
Cst n -> n | |
e -> error $ "Missing vars: " ++ show (dependencies e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment