diff --git a/Slang/slang.js b/Slang/slang.js index da02141..5aab6a7 100755 --- a/Slang/slang.js +++ b/Slang/slang.js @@ -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', -' Result:', -' [ 1 2 3 ] 3', +' -> [ 1 2 3 ] 3', +'', +'', +' Pop element form block tail', '', -'Pop element form block tail', ' [ 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', -' 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.', '', -'Get element at position (0)', +' Get element at position (0)', +'', ' [ 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', -' 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', -' 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', -' 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 ]', +'', '', '', '-------------------------------------------------------------------------------',