minor tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-02-12 02:07:34 +04:00
parent 7bb29115e0
commit f5329f8210

View File

@ -368,9 +368,16 @@ var NAMESPACE = {
context.stack.pop() context.stack.pop()
}, },
// a -- b
// NOTE: all names are also strings so moo string? and 'moo' string?
// are the same...
'string?': function(context){
return typeof(context.stack.pop()) == typeof('str')
},
// basic number operations... // basic number operations...
// a -- b // a -- b
'isNumber': function(context){ 'number?': function(context){
return typeof(context.stack.pop()) == typeof(123) return typeof(context.stack.pop()) == typeof(123)
}, },
// a b -- c // a b -- c
@ -388,7 +395,7 @@ var NAMESPACE = {
}, },
// block/list operations... // block/list operations...
'isBlock': function(context){ 'block?': function(context){
var e = context.stack.pop() var e = context.stack.pop()
return typeof(e) == typeof([]) && e.constructor.name == 'Array' return typeof(e) == typeof([]) && e.constructor.name == 'Array'
}, },
@ -775,14 +782,14 @@ var BOOTSTRAP = [
'-- 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...',
':: range ( n -- b ) [', ':: range ( n -- b ) [',
' -- initial state...', ' -- initial state...',
' [ dup isNumber ] ? ', ' [ dup number? ] ? ',
' [ [] swap ]', ' [ [] swap ]',
' -- get first elem...', ' -- get first elem...',
' else', ' else',
' [ 0 at ]', ' [ 0 at ]',
' -- we got to the end...', ' -- we got to the end...',
' [ dup 0 eq ] ? ', ' [ dup 0 eq ] ? ',
' [ drop ]', ' drop',
' -- dec push new and continue...', ' -- dec push new and continue...',
' else', ' else',
' [ 1 sub 0 before range ]]', ' [ 1 sub 0 before range ]]',
@ -795,7 +802,7 @@ var BOOTSTRAP = [
' [ . 0 ]', ' [ . 0 ]',
' -- sum of list of len 1 is it\'s content, so just pop it...', ' -- sum of list of len 1 is it\'s content, so just pop it...',
' else [ [ len 1 eq ] ?', ' else [ [ len 1 eq ] ?',
' [ pop swap . ]', ' b2s',
' -- and now recursively sum up elements till the list is 1 in length...', ' -- and now recursively sum up elements till the list is 1 in length...',
' else', ' else',
' [ pop rot pop tor add push sum ]]', ' [ pop rot pop tor add push sum ]]',