diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-08-22 14:00:59 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-08-22 14:00:59 (GMT) |
commit | 1a968a318193f9b6b4a7bc72adfbb27e72edf4ce (patch) | |
tree | a3931e979c91765c73de25ebfc2126640a0fcb0b | |
parent | 9c00d612cdeb0902ba1f21fbfbb6fef9cee7efac (diff) |
heap empty? should be a boolean
-rw-r--r-- | plugins/turtle_blocks_extras/turtle_blocks_extras.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py index f3b0d8f..ff9eebe 100644 --- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py +++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py @@ -513,6 +513,7 @@ make "tmp first :taheap\rmake "taheap butfirst :taheap\routput :tmp\rend\r') primitive_dictionary['isheapempty'] = self._prim_is_heap_empty palette.add_block('isheapempty', + hidden=True, style='box-style', label=_('empty heap?'), prim_name='isheapempty', @@ -521,6 +522,16 @@ make "tmp first :taheap\rmake "taheap butfirst :taheap\routput :tmp\rend\r') self.tw.lc.def_prim('isheapempty', 0, lambda self: primitive_dictionary['isheapempty']()) + primitive_dictionary['isheapempty2'] = self._prim_is_heap_empty_bool + palette.add_block('isheapempty2', + style='boolean-block-style', + label=_('empty heap?'), + prim_name='isheapempty2', + value_block=True, + help_string=_('returns True if heap is empty')) + self.tw.lc.def_prim('isheapempty2', 0, + lambda self: primitive_dictionary['isheapempty2']()) + primitive_dictionary['print'] = self._prim_print palette.add_block('comment', style='basic-style-1arg', @@ -1106,6 +1117,13 @@ bullets')) else: return 0 + def _prim_is_heap_empty_bool(self): + """ is FILO empty? """ + if len(self.tw.lc.heap) == 0: + return True + else: + return False + def _prim_pop(self): """ Pop value off of FILO """ if len(self.tw.lc.heap) == 0: |