diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-08-05 21:11:30 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-08-05 21:11:30 -0700 |
commit | 2844bb73b485450660d70de2de489590d0995d9e (patch) | |
tree | c13cce580f6a983db3db2086e141917b7b645cb6 /txr.1 | |
parent | 905a08374e2901e97b18e58d970f95a25ec6fc10 (diff) | |
download | txr-2844bb73b485450660d70de2de489590d0995d9e.tar.gz txr-2844bb73b485450660d70de2de489590d0995d9e.tar.bz2 txr-2844bb73b485450660d70de2de489590d0995d9e.zip |
Add sum and prod convenience functions.
* eval.c (eval_init): prod and sum intrinsics registered.
* lib.c (sum, prod): New functions.
* lib.h (sum, prod): Declared.
* txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -33472,6 +33472,50 @@ follows, then that value is divided by that subsequent divisor. This process repeats until all divisors are exhausted, and the value of the last division is returned. +.coNP Functions @ sum and @ prod +.synb +.mets (sum << num-sequence ) +.mets (prod << num-sequence ) +.syne +.desc +The +.code sum +and +.code prod +functions operate on a single argument +.metn num-sequence , +which is a sequence of numbers. + +The +.code sum +function returns the left-associative sum of the elements of +.meta num-sequence +calculated as if using the +.code + +function. Similarly, the +.code prod +function calculates the left-associative product of the elements of +.metn num-sequence , +as if using the +.code * +function. + +If +.meta num-sequence +is empty then +.code sum +returns +.code 0 +and +.code prod +returns +.codn 1 . + +If +.meta num-sequence +contains one number, then both functions +return that number. + .coNP Functions @ wrap and @ wrap* .synb .mets (wrap < start < end << number ) |