diff options
Diffstat (limited to 'plugins/turtle_blocks_extras')
-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: |