summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-11-23 06:42:52 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-11-23 06:42:52 -0800
commitcdb62673a886801298c543346c2186f0e054ca6e (patch)
tree3dcdec25ff587329df02b76623c78a13dce9c7e6 /txr.1
parent3f4b4dc10fa7e2d099b2ba0dfef78c108a671ec9 (diff)
downloadtxr-cdb62673a886801298c543346c2186f0e054ca6e.tar.gz
txr-cdb62673a886801298c543346c2186f0e054ca6e.tar.bz2
txr-cdb62673a886801298c543346c2186f0e054ca6e.zip
New function: grade.
Inspired by APL. * eval.c (eval_init): Register grade intrinsic. * lib.c (grade): New function. * lib.h (grade): Declared. * txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.145
1 files changed, 45 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index d7570610..fc187aec 100644
--- a/txr.1
+++ b/txr.1
@@ -28945,6 +28945,51 @@ For strings and vectors,
.code sort
is not stable.
+.coNP Function @ grade
+.synb
+.mets (grade < sequence >> [ lessfun <> [ keyfun ]])
+.syne
+.desc
+The
+.code grade
+function returns a list of integer indices which indicate the position
+of the elements of
+.meta sequence
+in sorted order.
+
+The
+.meta lessfun
+and
+.meta keyfun
+arguments behave like those of the
+.code sort
+function.
+
+The
+.meta sequence
+object is not modified.
+
+The internal sort performed by
+.code grade
+is not stable. The indices of any elements considered equivalent under
+.code lessfun
+may appear in any order in the returned index sequence.
+
+Note: the
+.code grade
+function is inspired by the "grade up" and "grade down" operators
+in the APL language.
+
+.TP* Examples:
+
+.cblk
+ ;; Order of the 2 3 positions of the "l"
+ ;; characters is not specified:
+
+ [grade "Hello"] -> (0 1 2 3 4)
+ [grade "Hello" >] -> (4 2 3 1 0)
+.cble
+
.coNP Function @ shuffle
.synb
.mets (shuffle << sequence )