Commits

Jürgen Bömmels committed 2f84a6d

Implement not function

  • Participants
  • Parent commits 9eb92cb

Comments (0)

Files changed (1)

scheme/procedure.py

         W_Number, W_Real, W_Integer, W_List, W_Character, W_Vector, \
         Body, W_Procedure, W_String, W_Promise, plst2lst, w_undefined, \
         SchemeSyntaxError, SchemeQuit, WrongArgType, WrongArgsNumber, \
-        w_nil
+        w_nil, w_true, w_false
 
 ##
 # operations
     def predicate(self, w_obj):
         return w_obj is w_nil
 
+class Not(W_Procedure):
+    _symbol_name = "not"
+
+    def procedure(self, ctx, lst):
+        if len(lst) != 1:
+            raise WrongArgsNumber
+
+        w_bool = lst[0]
+        if w_bool.to_boolean():
+            return w_false
+        else:
+            return w_true
+
 
 ##
 # Input/Output procedures