Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding 'if'

  • Loading branch information...
commit 6184efb6d36c434b4ffa5f0a1ca17e1a445f4424 1 parent cac917c
@abedra authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 valence.hs
View
5 valence.hs
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.