diff options
author | Marion <marion.zepf@gmail.com> | 2013-08-15 12:14:42 (GMT) |
---|---|---|
committer | Marion <marion.zepf@gmail.com> | 2013-08-15 12:14:42 (GMT) |
commit | d1d8ca69baadda3e948205d25c5352a4d8ab0377 (patch) | |
tree | f4b966d5d39cee4aab9b7061fe7c30bd0755b9d8 | |
parent | 0417bd0f7ae460c25c15321e7b4cd96addfc580e (diff) |
add Primitive for 'division' block
-rw-r--r-- | TurtleArt/tabasics.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py index b0f1e54..3d4752f 100644 --- a/TurtleArt/tabasics.py +++ b/TurtleArt/tabasics.py @@ -653,7 +653,6 @@ minus :y\nend\n') 'product', 2, lambda self, x, y: primitive_dictionary['product'](x, y)) - primitive_dictionary['division'] = self._prim_careful_divide palette.add_block('division2', style='number-style-porch', label=' /', @@ -662,9 +661,20 @@ minus :y\nend\n') logo_command='quotient', help_string=_('divides top numeric input \ (numerator) by bottom numeric input (denominator)')) - self.tw.lc.def_prim( - 'division', 2, - lambda self, x, y: primitive_dictionary['division'](x, y)) + self.tw.lc.def_prim('division', 2, + # TODO re-enable use with lists + Primitive(Primitive.divide, slot_wrappers={ + 0: Primitive(self.check_number, + export_me=False, + slot_wrappers={ + 0: self.prim_cache["convert_to_number"]}), + 1: Primitive(self.check_non_zero, + export_me=False, + slot_wrappers={ + 0: Primitive(self.check_number, + export_me=False, + slot_wrappers={ + 0: self.prim_cache["convert_to_number"]})})})) palette.add_block('identity2', style='number-style-1arg', @@ -1304,7 +1314,7 @@ variable')) self.tw.lc.ireturn() yield True - # Math primitivies + # Math primitives def _prim_careful_divide(self, x, y): ''' Raise error on divide by zero ''' |