aboutsummaryrefslogtreecommitdiff
path: root/module/hnh/util/lens.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-09-05 00:55:35 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-09-05 00:55:35 +0200
commitc64a4bc56f93c08cf55fb907078e588ad737684c (patch)
treef70767074a4550a2be180dd4659e2dedc922b0b4 /module/hnh/util/lens.scm
parentMove lens test. (diff)
downloadcalp-c64a4bc56f93c08cf55fb907078e588ad737684c.tar.gz
calp-c64a4bc56f93c08cf55fb907078e588ad737684c.tar.xz
Major work on, something.
Diffstat (limited to 'module/hnh/util/lens.scm')
-rw-r--r--module/hnh/util/lens.scm8
1 files changed, 7 insertions, 1 deletions
diff --git a/module/hnh/util/lens.scm b/module/hnh/util/lens.scm
index 7a8fbd19..26c75be7 100644
--- a/module/hnh/util/lens.scm
+++ b/module/hnh/util/lens.scm
@@ -9,7 +9,9 @@
compose-lenses
lens-compose
- ref car* cdr*))
+ ref car* cdr*
+
+ each))
(define (modify object lens f . args)
@@ -97,3 +99,7 @@
(define car* (make-lens car (lambda (pair value) (cons value (cdr pair)))))
(define cdr* (make-lens cdr (lambda (pair value) (cons (car pair) value))))
+
+(define (each obj lens proc)
+ (modify obj lens
+ (lambda (lst) (map proc lst))))