basic: currying is not left-associative

This commit is contained in:
minjaesong
2020-12-27 01:38:33 +09:00
parent cc2d3e79dd
commit dce251fbc9
3 changed files with 12 additions and 4 deletions

View File

@@ -0,0 +1,7 @@
1 OPTIONDEBUG 1:OPTIONTRACE 1
10 DEFUN APPLY(X,F)=F(X):REM bug- F<~X must return function and F(X) must return value but right now they both return a function?
20 DEFUN FUN(X)=X^2
30 K=APPLY(42,FUN)
100 PRINT K
110 PRINT TYPEOF K
120 RESOLVE K

View File

@@ -29,7 +29,7 @@ if (exec_args !== undefined && exec_args[1] !== undefined && exec_args[1].starts
return 0;
}
const PROD = true;
const PROD = false;
let INDEX_BASE = 0;
let TRACEON = (!PROD) && true;
let DBGON = (!PROD) && true;
@@ -1426,7 +1426,7 @@ bF._opPrc = {
"=":999,
"IN":1000
};
bF._opRh = {"^":1,"=":1,"!":1,"IN":1,"<~":1,"~>":1};
bF._opRh = {"^":1,"=":1,"!":1,"IN":1,"~>":1}; // <~ and ~> cannot have same associativity
// these names appear on executeSyntaxTree as "exceptional terms" on parsing (regular function calls are not "exceptional terms")
bF._tokenise = function(lnum, cmd) {
var _debugprintStateTransition = false;

View File

@@ -118,7 +118,8 @@ Order & Op & Associativity \\
16 & ! & Right \\
17 & \sim & Left\\
18 & \# & Left \\
19 & \basiccurry & Right \\
19 & \basiccurry & Left \\
%19.5 & \basicclosure & Right \\
20 & = & Right \\
\end{tabulary}
\end{longtable}
@@ -249,7 +250,7 @@ Code & Operation & Result \\
%{[}\emph{x},\,\emph{y}\ldots{]} \basicclosure\ \emph{e} & Closure & Creates a closure (anonymous function) from one or more parameters \emph{x},\,\emph{y}\ldots\ and an expression \emph{e} \\
\end{tabulary}
\emph{Currying} is an operation that returns new function that has given value applied to the original function's first parameter. See \ref{currying101} for tutorials.
\emph{Currying}\footnote{\emph{Partial Application} should be more appropriate for this operator, but oh well: \emph{currying} is less mouthful.} is an operation that returns new function that has given value applied to the original function's first parameter. See \ref{currying101} for tutorials.
\section{Constants}