mirror of
https://github.com/flynx/Slang.git
synced 2025-10-29 10:40:07 +00:00
more refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
22a22fd083
commit
01a0b7872a
@ -551,7 +551,7 @@ var BOOTSTRAP = [
|
||||
'Get block length',
|
||||
' [ 1 2 3 ] len',
|
||||
' Result:',
|
||||
' 3',
|
||||
' [ 1 2 3 ] 3',
|
||||
'',
|
||||
'Pop element form block tail',
|
||||
' [ 1 2 3 ] pop',
|
||||
@ -680,15 +680,15 @@ var BOOTSTRAP = [
|
||||
'-- the condition block must have the folowing stack effect: elem -- bool',
|
||||
':: filter ( b c -- b ) [',
|
||||
' -- prepare the condition...',
|
||||
' \\ dup 0 before',
|
||||
' -- define the template...',
|
||||
' [ TEST ? [ ] else [ . ] ] clone',
|
||||
' [ dup \\ TEST exec ] clone',
|
||||
' swap 2 to',
|
||||
' -- prepare the template...',
|
||||
' [ TEST ? [ ] else [ . ] ] clone',
|
||||
' swap 0 to',
|
||||
' -- do the filtering',
|
||||
' map ]',
|
||||
'',
|
||||
'-- Create a block containing a range numbers form 0 to n-1...',
|
||||
'-- Create a block containing a range of numbers form 0 to n-1...',
|
||||
':: range ( n -- b ) [',
|
||||
' -- initial state...',
|
||||
' [ dup isNumber ] ? ',
|
||||
@ -703,6 +703,20 @@ var BOOTSTRAP = [
|
||||
' else',
|
||||
' [ 1 sub 0 before range ] ]',
|
||||
'',
|
||||
'-- Sum up the elements of a block...',
|
||||
':: sum ( L -- s ) [',
|
||||
' clone',
|
||||
' -- empty list, sum is 0...',
|
||||
' [ len 0 eq ] ?',
|
||||
' [ . 0 ]',
|
||||
' else',
|
||||
' -- sum of list of len 1 is it\'s content, so just pop it...',
|
||||
' [ [ len 1 eq ] ?',
|
||||
' [ pop swap . ]',
|
||||
' -- and now recursively sum up elements till the list is 1 in length...',
|
||||
' else',
|
||||
' [ pop rot pop tor add push sum ] ] ]',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'-- Meta-word examples (experimental)...',
|
||||
@ -753,19 +767,6 @@ var BOOTSTRAP = [
|
||||
':: range2 ( n s -- b )',
|
||||
' [ swap range swap [] swap push \\ * 0 before map ]',
|
||||
'',
|
||||
'-- Sum up the elements of a block...',
|
||||
':: sum ( L -- s ) [',
|
||||
' -- empty list, sum is 0...',
|
||||
' [ len 0 eq ] ?',
|
||||
' [ . 0 ]',
|
||||
' else',
|
||||
' -- sum of list of len 1 is it\'s content, so just pop it...',
|
||||
' [ [ len 1 eq ] ?',
|
||||
' [ pop swap . ]',
|
||||
' -- and now recursively sum up elements till the list is 1 in length...',
|
||||
' else',
|
||||
' [ pop rot pop tor add push sum ] ] ]',
|
||||
'',
|
||||
''].join('\n')
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user