diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-11-23 06:42:52 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-11-23 06:42:52 -0800 |
commit | cdb62673a886801298c543346c2186f0e054ca6e (patch) | |
tree | 3dcdec25ff587329df02b76623c78a13dce9c7e6 /txr.1 | |
parent | 3f4b4dc10fa7e2d099b2ba0dfef78c108a671ec9 (diff) | |
download | txr-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.1 | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -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 ) |