more refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-02-10 09:17:36 +04:00
parent 22a22fd083
commit 01a0b7872a

View File

@ -551,7 +551,7 @@ var BOOTSTRAP = [
'Get block length', 'Get block length',
' [ 1 2 3 ] len', ' [ 1 2 3 ] len',
' Result:', ' Result:',
' 3', ' [ 1 2 3 ] 3',
'', '',
'Pop element form block tail', 'Pop element form block tail',
' [ 1 2 3 ] pop', ' [ 1 2 3 ] pop',
@ -680,15 +680,15 @@ var BOOTSTRAP = [
'-- 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 0 before', ' [ dup \\ TEST exec ] clone',
' -- define the template...', ' swap 2 to',
' -- prepare the template...',
' [ TEST ? [ ] else [ . ] ] clone', ' [ TEST ? [ ] else [ . ] ] clone',
' -- prepare the template...',
' swap 0 to', ' swap 0 to',
' -- do the filtering', ' -- do the filtering',
' map ]', ' 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 ) [', ':: range ( n -- b ) [',
' -- initial state...', ' -- initial state...',
' [ dup isNumber ] ? ', ' [ dup isNumber ] ? ',
@ -703,6 +703,20 @@ var BOOTSTRAP = [
' else', ' else',
' [ 1 sub 0 before range ] ]', ' [ 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)...', '-- Meta-word examples (experimental)...',
@ -753,19 +767,6 @@ var BOOTSTRAP = [
':: range2 ( n s -- b )', ':: range2 ( n s -- b )',
' [ swap range swap [] swap push \\ * 0 before map ]', ' [ 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') ''].join('\n')