mirror of
https://github.com/flynx/Slang.git
synced 2025-10-29 18:50:08 +00:00
added replace...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
bdc6c936d2
commit
7bb29115e0
@ -747,17 +747,29 @@ var BOOTSTRAP = [
|
||||
'-- push element to tail of block...',
|
||||
':: 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...',
|
||||
'--',
|
||||
'-- the condition block must have the folowing stack effect: elem -- bool',
|
||||
':: filter ( b c -- b ) [',
|
||||
' -- prepare the condition...',
|
||||
' [ dup \\ TEST exec ] clone',
|
||||
' swap 2 to',
|
||||
' swap TEST replace',
|
||||
' -- prepare the template...',
|
||||
' [ TEST ? [ ] else [ . ] ] clone',
|
||||
' swap 0 to',
|
||||
' -- do the filtering',
|
||||
' swap TEST replace',
|
||||
' map ]',
|
||||
'',
|
||||
'-- Create a block containing a range of numbers form 0 to n-1...',
|
||||
@ -807,7 +819,7 @@ var BOOTSTRAP = [
|
||||
' -- exec the right side and arragne the args for WORD...',
|
||||
' \\ exec \\ WORD 2 1 _swapN ] clone',
|
||||
' -- get the WORD and insert it into the template above (opsition 8)...',
|
||||
' swap 8 to',
|
||||
' swap WORD replace',
|
||||
'',
|
||||
' -- push to code / run',
|
||||
' 3 0 _swapN ',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user