mirror of
				https://github.com/flynx/Slang.git
				synced 2025-10-30 19:10:13 +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 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...', | ||||||
| @ -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 ', | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user