diff options
author | Walter Bender <walter.bender@gmail.com> | 2011-03-17 16:20:39 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2011-03-17 16:20:39 (GMT) |
commit | 8ba7e9f64e91719e6ca4bdb0d0f6784391a3b4c2 (patch) | |
tree | 9823400e429b69d2bdd8988859502ee4b2e9bcb4 /TurtleArt/tabasics.py | |
parent | e46262988a4f02f1ebbcb6602f8d93fbd1dad907 (diff) |
cleaned up regression with AND and OR blocks
Diffstat (limited to 'TurtleArt/tabasics.py')
-rw-r--r-- | TurtleArt/tabasics.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py index 9e4a171..da991dd 100644 --- a/TurtleArt/tabasics.py +++ b/TurtleArt/tabasics.py @@ -556,21 +556,25 @@ operators')) help_string=_('logical NOT operator')) self.tw.lc.def_prim('not', 1, lambda self, x: not x) + primitive_dictionary['and'] = self._prim_and palette.add_block('and2', style='boolean-style', label=_('and'), prim_name='and', special_name=_('and'), help_string=_('logical AND operator')) - self.tw.lc.def_prim('not', 2, lambda self, x, y: x & y) + self.tw.lc.def_prim( + 'and', 2, lambda self, x, y: primitive_dictionary['and'](x, y)) + primitive_dictionary['or'] = self._prim_or palette.add_block('or2', style='boolean-style', label=_('or'), prim_name='or', special_name=_('or'), help_string=_('logical OR operator')) - self.tw.lc.def_prim('not', 2, lambda self, x, y: x | y) + self.tw.lc.def_prim( + 'or', 2, lambda self, x, y: primitive_dictionary['or'](x, y)) def _flow_palette(self): """ The basic Turtle Art flow palette """ @@ -805,6 +809,10 @@ variable')) # Block primitives + def _prim_and(self, x, y): + """ Logical and """ + return x & y + def _prim_arc(self, cmd, value1, value2): """ Turtle draws an arc of degree, radius """ cmd(float(value1), float(value2)) @@ -862,6 +870,10 @@ variable')) self.tw.lc.update_label_value('ycor', self.tw.canvas.ycor / self.tw.coord_scale) + def _prim_or(self, x, y): + """ Logical or """ + return x | y + def _prim_repeat(self, num, blklist): """ Repeat list num times. """ num = self.tw.lc.int(num) |