added replace...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-02-11 21:15:57 +04:00
parent bdc6c936d2
commit 7bb29115e0

View File

@ -747,18 +747,30 @@ var BOOTSTRAP = [
'-- push element to tail of block...', '-- push element to tail of block...',
':: push ( b e -- b ) [ swap len rot swap tor to ]', ':: push ( b e -- b ) [ swap len rot swap tor to ]',
'', '',
'-- Replace a pattern (p) in block with value (v)...',
'-- NOTE: this will replace ALL patterns...',
':: replace ( l v p -- l ) [',
' swap',
' [ . \\ VALUE ] clone',
' swap 2 to',
' rot',
' -- XXX for some reason ? without else messes things up...',
' [ dup \\ PATTERN eq ? VALUE_BLOCK else [ ] ] clone',
' swap 2 to',
' tor 5 to',
' map ]',
'',
'-- Filter the block via a condition...', '-- Filter the block via a condition...',
'--', '--',
'-- the condition block must have the folowing stack effect: elem -- bool', '-- the condition block must have the folowing stack effect: elem -- bool',
':: filter ( b c -- b ) [', ':: filter ( b c -- b ) [',
' -- prepare the condition...', ' -- prepare the condition...',
' [ dup \\ TEST exec ] clone', ' [ dup \\ TEST exec ] clone',
' swap 2 to', ' swap TEST replace',
' -- prepare the template...', ' -- prepare the template...',
' [ TEST ? [ ] else [ . ] ] clone', ' [ TEST ? [ ] else [ . ] ] clone',
' swap 0 to', ' swap TEST replace',
' -- do the filtering', ' map ]',
' map ]',
'', '',
'-- Create a block containing a range of numbers form 0 to n-1...', '-- Create a block containing a range of numbers form 0 to n-1...',
':: range ( n -- b ) [', ':: range ( n -- b ) [',
@ -807,7 +819,7 @@ var BOOTSTRAP = [
' -- exec the right side and arragne the args for WORD...', ' -- exec the right side and arragne the args for WORD...',
' \\ exec \\ WORD 2 1 _swapN ] clone', ' \\ exec \\ WORD 2 1 _swapN ] clone',
' -- get the WORD and insert it into the template above (opsition 8)...', ' -- get the WORD and insert it into the template above (opsition 8)...',
' swap 8 to', ' swap WORD replace',
'', '',
' -- push to code / run', ' -- push to code / run',
' 3 0 _swapN ', ' 3 0 _swapN ',