Permalink
Browse files

Adding 'if'

  • Loading branch information...
1 parent cac917c commit 6184efb6d36c434b4ffa5f0a1ca17e1a445f4424 @abedra committed Apr 6, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 valence.hs
View
@@ -167,6 +167,11 @@ eval :: LispVal -> ThrowsError LispVal
eval val@(String _) = return val
eval val@(Number _) = return val
eval val@(Bool _) = return val
+eval (List [Atom "if", pred, conseq, alt]) =
+ do result <- eval pred
+ case result of
+ Bool False -> eval alt
+ otherwise -> eval conseq
eval (List [Atom "quote", val]) = return val
eval (List (Atom func : args)) = mapM eval args >>= apply func
eval badForm = throwError $ BadSpecialForm "Unrecognized special form" badForm

0 comments on commit 6184efb

Please sign in to comment.