From dce251fbc9f0e80bb959a79c66d24bc29c68dc83 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 27 Dec 2020 01:38:33 +0900 Subject: [PATCH] basic: currying is not left-associative --- assets/disk0/home/basic/usrapply.bas | 7 +++++++ assets/disk0/tbas/basic.js | 4 ++-- assets/disk0/tbas/doc/langref.tex | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 assets/disk0/home/basic/usrapply.bas diff --git a/assets/disk0/home/basic/usrapply.bas b/assets/disk0/home/basic/usrapply.bas new file mode 100644 index 0000000..a01be20 --- /dev/null +++ b/assets/disk0/home/basic/usrapply.bas @@ -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 diff --git a/assets/disk0/tbas/basic.js b/assets/disk0/tbas/basic.js index 73559a0..96f1c7c 100644 --- a/assets/disk0/tbas/basic.js +++ b/assets/disk0/tbas/basic.js @@ -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; diff --git a/assets/disk0/tbas/doc/langref.tex b/assets/disk0/tbas/doc/langref.tex index a71c9db..a2b205c 100644 --- a/assets/disk0/tbas/doc/langref.tex +++ b/assets/disk0/tbas/doc/langref.tex @@ -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}