From 20c4b90298d429f3e4d368735a94955c22838699 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Thu, 8 Sep 2022 08:46:34 -0700 Subject: [PATCH] make type checks into Joy functions --- implementations/Python/simplejoy.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/implementations/Python/simplejoy.py b/implementations/Python/simplejoy.py index 91eb352..e3f0552 100755 --- a/implementations/Python/simplejoy.py +++ b/implementations/Python/simplejoy.py @@ -1289,6 +1289,7 @@ def isnt_int(i): ''' if not isinstance(i, int) or isinstance(i, bool): raise NotAnIntError(f'Not an integer: {_s(i)}') + return i def isnt_bool(b): @@ -1297,6 +1298,7 @@ def isnt_bool(b): ''' if not isinstance(b, bool): raise NotABoolError(f'Not a Boolean value: {_s(b)}') + return b def isnt_stack(el): @@ -1305,6 +1307,15 @@ def isnt_stack(el): ''' if not isinstance(el, tuple): raise NotAListError(f'Not a list: {_s(el)}') + return el + + +# Put these into the dictionary so users can, uh, use them. +# Not as decorators because we want to use the unwrapped +# functions in our python code. +inscribe(UnaryWrapper(isnt_int)) +inscribe(UnaryWrapper(isnt_bool)) +inscribe(UnaryWrapper(isnt_stack)) if __name__ == '__main__': -- 2.11.0