For more syntax like matlab:
(define (piecewise func) (lambda more (apply map func more))) (define pw piecewise) ((pw +) '(1 2 3 4 5) '(6 7 8 9 0)) ((pw -) '(1 2 3 4 5) '(6 7 8 9 0)) ((pw *) '(1 2 3 4 5) '(6 7 8 9 0)) ((pw /) '(1 2 3 4 5) '(6 7 8 9 0.1))
outputs:
(7 9 11 13 5) (-5 -5 -5 -5 5) (6 14 24 36 0) (1/6 2/7 3/8 4/9 50.0)
source share