mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
basic: string array is a thing now
This commit is contained in:
@@ -719,8 +719,8 @@ if no arg text were given (e.g. "10 NEXT"), args will have zero length
|
||||
}},
|
||||
"!" : {f:function(lnum, stmtnum, args) { // Haskell-style CONS
|
||||
return twoArg(lnum, stmtnum, args, (lh,rh) => {
|
||||
if (isNaN(lh))
|
||||
throw lang.illegalType(lnum, lh); // BASIC array is numbers only
|
||||
if (Array.isArray(lh))
|
||||
throw lang.illegalType(lnum, lh); // NO ragged array!
|
||||
if (!Array.isArray(rh))
|
||||
throw lang.illegalType(lnum, rh);
|
||||
return [lh].concat(rh);
|
||||
@@ -728,10 +728,10 @@ if no arg text were given (e.g. "10 NEXT"), args will have zero length
|
||||
}},
|
||||
"~" : {f:function(lnum, stmtnum, args) { // array PUSH
|
||||
return twoArg(lnum, stmtnum, args, (lh,rh) => {
|
||||
if (isNaN(rh))
|
||||
throw lang.illegalType(lnum, rh); // BASIC array is numbers only
|
||||
if (!Array.isArray(lh))
|
||||
throw lang.illegalType(lnum, lh);
|
||||
if (Array.isArray(rh))
|
||||
throw lang.illegalType(lnum, rh); // NO ragged array!
|
||||
return lh.concat([rh]);
|
||||
});
|
||||
}},
|
||||
|
||||
@@ -15,7 +15,7 @@ There are six basic types: \emph{number}, \emph{boolean}, \emph{string}, \emph{
|
||||
|
||||
\emph{Boolean} is type of the value that is either \codebf{TRUE} or \codebf{FALSE}. Number \codebf{0} and \codebf{FALSE} make the condition \emph{false}. When used in numeric context, \codebf{FALSE} will be interpreted as 0 and \codebf{TRUE} as 1.
|
||||
|
||||
\emph{String} represents immutable\footnote{Cannot be altered directly} sequences of bytes. However, you can't weave them to make something like \emph{string array}\footnote{Future feature\ldots\ maybe\ldots? Probably not\ldots}.
|
||||
\emph{String} represents immutable\footnote{Cannot be altered directly} sequences of bytes.
|
||||
|
||||
\emph{Array} represents a collection of numbers in one or more dimensions.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user