basic: string array is a thing now

This commit is contained in:
minjaesong
2020-12-27 20:47:31 +09:00
parent 74cde2f5b1
commit e37a382fe2
2 changed files with 5 additions and 5 deletions

View File

@@ -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]);
});
}},

View File

@@ -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.