mirror of
https://github.com/flynx/Slang.git
synced 2025-10-29 10:40:07 +00:00
more docs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2596b93e84
commit
402466f11a
@ -546,45 +546,80 @@ var BOOTSTRAP = [
|
|||||||
'',
|
'',
|
||||||
'-------------------------------------------------------------------------------',
|
'-------------------------------------------------------------------------------',
|
||||||
'',
|
'',
|
||||||
'Basic words for block manipulation:',
|
' Basic words for block manipulation:',
|
||||||
|
'',
|
||||||
|
' Get block length',
|
||||||
'',
|
'',
|
||||||
'Get block length',
|
|
||||||
' [ 1 2 3 ] len',
|
' [ 1 2 3 ] len',
|
||||||
' Result:',
|
' -> [ 1 2 3 ] 3',
|
||||||
' [ 1 2 3 ] 3',
|
'',
|
||||||
|
'',
|
||||||
|
' Pop element form block tail',
|
||||||
'',
|
'',
|
||||||
'Pop element form block tail',
|
|
||||||
' [ 1 2 3 ] pop',
|
' [ 1 2 3 ] pop',
|
||||||
' Result:',
|
' -> [ 1 2 ] 3',
|
||||||
' [ 1 2 ] 3',
|
'',
|
||||||
|
'',
|
||||||
|
' Push element to block tail',
|
||||||
'',
|
'',
|
||||||
'Push element to block tail',
|
|
||||||
' [ 1 2 3 ] 4 push',
|
' [ 1 2 3 ] 4 push',
|
||||||
' Result:',
|
' -> [ 1 2 3 4 ]',
|
||||||
' [ 1 2 3 4 ]',
|
|
||||||
'',
|
'',
|
||||||
'NOTE: all indexes can be negative values, these will indicate the',
|
'',
|
||||||
|
' NOTE: all indexes can be negative values, these will indicate the',
|
||||||
' position relative to the tail, -1 being the last element.',
|
' position relative to the tail, -1 being the last element.',
|
||||||
'',
|
'',
|
||||||
'Get element at position (0)',
|
' Get element at position (0)',
|
||||||
|
'',
|
||||||
' [ 1 2 3 ] -1 at',
|
' [ 1 2 3 ] -1 at',
|
||||||
' Result:',
|
' -> [ 1 2 3 ] 3',
|
||||||
' [ 1 2 3 ] 3',
|
'',
|
||||||
|
'',
|
||||||
|
' Put element (123) at position (0)',
|
||||||
'',
|
'',
|
||||||
'Put element (123) at position (0)',
|
|
||||||
' [ 1 2 3 ] 123 0 to',
|
' [ 1 2 3 ] 123 0 to',
|
||||||
' Result:',
|
' -> [ 123 2 3 ]',
|
||||||
' [ 123 2 3 ]',
|
'',
|
||||||
|
'',
|
||||||
|
' Put element (123) before position (0)',
|
||||||
'',
|
'',
|
||||||
'Put element (123) before position (0)',
|
|
||||||
' [ 1 2 3 ] 123 0 before',
|
' [ 1 2 3 ] 123 0 before',
|
||||||
' Result:',
|
' -> [ 123 1 2 3 ]',
|
||||||
' [ 123 1 2 3 ]',
|
'',
|
||||||
|
'',
|
||||||
|
' Like before but puts the element after position',
|
||||||
|
'',
|
||||||
|
' [ 1 2 3 ] 123 0 after',
|
||||||
|
' -> [ 1 123 2 3 ]',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
' Expand block to stack -- "block 2 stack"',
|
||||||
'',
|
'',
|
||||||
'Expand block to stack -- "block 2 stack"',
|
|
||||||
' [ 1 2 3 ] b2s',
|
' [ 1 2 3 ] b2s',
|
||||||
' Result:',
|
' -> 1 2 3',
|
||||||
' 1 2 3',
|
'',
|
||||||
|
'',
|
||||||
|
' Map a block/word to each element in a block',
|
||||||
|
'',
|
||||||
|
' [ 1 2 3 ] [ 1 add ] map',
|
||||||
|
' -> [ 2 3 4 ]',
|
||||||
|
|
||||||
|
' the returned value (stack) of the input block is put into the result',
|
||||||
|
' block, this enables us to both remove (empty stack) and expand (more',
|
||||||
|
' than one value) the resulting list...',
|
||||||
|
'',
|
||||||
|
' [ 1 2 3 4 ] [ dup ] map',
|
||||||
|
' -> [ 1 1 2 2 3 3 4 4 ]',
|
||||||
|
|
||||||
|
' [ 1 2 3 4 ] [ dup 2 gt ? [ ] else [ . ] ] map',
|
||||||
|
' -> [ 3 4 ]',
|
||||||
|
'',
|
||||||
|
' this enables us to construct words like filter, which makes the code',
|
||||||
|
' in the last example more readable:',
|
||||||
|
'',
|
||||||
|
' [ 1 2 3 4 ] [ 2 gt ] filter',
|
||||||
|
' -> [ 3 4 ]',
|
||||||
|
'',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'-------------------------------------------------------------------------------',
|
'-------------------------------------------------------------------------------',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user