summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-01-01 15:55:58 -0800
committerKaz Kylheku <kaz@kylheku.com>2018-01-01 15:55:58 -0800
commit79a90b980192de7410a7e688e1c831f7878f8714 (patch)
tree8aaf9ce2e0a0fb6d79c36d3cc2c117039f2a6390 /tests
parent900597a05d48be775bfb0e504e3179062806ff02 (diff)
downloadtxr-79a90b980192de7410a7e688e1c831f7878f8714.tar.gz
txr-79a90b980192de7410a7e688e1c831f7878f8714.tar.bz2
txr-79a90b980192de7410a7e688e1c831f7878f8714.zip
sub and replace redirect to structure methods.
* lib.c (replace_obj): New static function. (sub): Handle struct case via lambda method. (replace): Handle struct case via replace_obj. * txr.1: Documented. * tests/012/aseq.tl (add): The lambda method now has to handle a range argument. One test case uses the last function, which for non-lists relies on sub, which now calls the lambda method if the object has one.
Diffstat (limited to 'tests')
-rw-r--r--tests/012/aseq.tl5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/012/aseq.tl b/tests/012/aseq.tl
index fc6cf76b..dfb20118 100644
--- a/tests/012/aseq.tl
+++ b/tests/012/aseq.tl
@@ -5,7 +5,10 @@
(:method cdr (me) (if (cdr me.list) (new (add me.n (cdr me.list)))))
(:method car (me) (+ me.n (car me.list)))
(:method nullify (me) (if me.list me))
- (:method lambda (me i) (+ me.n (ref me.list i))))
+ (:method lambda (me i)
+ (if (rangep i)
+ (mapcar (op + me.n) [me.list i])
+ (+ me.n (ref me.list i)))))
(defvarl o (new (add 3 (range 10 100 10))))