/usr/lib/tree-map.scm is in scheme9 2013.11.26-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2010
; Placed in the Public Domain
;
; (tree-map procedure1 procedure2 pair) ==> pair
;
; Apply PROCEDURE2 to each node of the tree rooted at PAIR
; to which the predicate PROCEDURE1 applies. Return a fresh
; tree.
;
; Example: (tree-map number? list '((a . 1) (b . 2)))
; ==> ((a . (1)) (b . (2)))
; (tree-map (lambda (x) (and (pair? x)
; (string? (car x))
; (string? (cdr x))))
; (lambda (x) (string-append (car x) (cdr x)))
; '(("foo" . "bar") ("bar" . "baz")))
; ==> ("foobar" "barbaz")
(define (tree-map p f x)
(letrec
((tree-map1
(lambda (x)
(cond ((p x)
(f x))
((pair? x)
(cons (tree-map1 (car x))
(tree-map1 (cdr x))))
(else
x)))))
(tree-map1 x)))
|