diff options
author | Marion <marion.zepf@gmail.com> | 2013-09-16 11:20:55 (GMT) |
---|---|---|
committer | Marion <marion.zepf@gmail.com> | 2013-09-16 11:20:55 (GMT) |
commit | 2f3ccc0fcbb5318e50f1e429b93d2ae36a55aad5 (patch) | |
tree | 48dca4bcde3dd10bdc2bcf4fa1c43e70383da272 /TurtleArt/taprimitive.py | |
parent | 01fb102f1f6063b85d442baebb77958b23869dc2 (diff) |
add Primitive for the 'f(x)' block
Diffstat (limited to 'TurtleArt/taprimitive.py')
-rw-r--r-- | TurtleArt/taprimitive.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py index 36ad49c..7f30071 100644 --- a/TurtleArt/taprimitive.py +++ b/TurtleArt/taprimitive.py @@ -417,6 +417,16 @@ class Primitive(object): else: return ast.BinOp(op=op, left=left, right=right) + # f(x) + elif self == LogoCode.prim_myfunction: + param_asts = [] + for id_ in ['x', 'y', 'z'][:len(new_arg_asts)-1]: + param_asts.append(ast.Name(id=id_, ctx=ast.Param)) + func_ast = ast.Lambda(body=new_arg_asts[0], args=ast.arguments( + args=param_asts, vararg=None, kwarg=None, defaults=[])) + return get_call_ast(func_ast, new_arg_asts[1:], + return_type=self.return_type) + # square root elif self == Primitive.square_root: return get_call_ast('sqrt', new_arg_asts, new_kwarg_asts, |