2 ms·
map1 and map2 repeat code. abstract this part to a general mapper function: (loop for n from start to end do then you will write the content of the first mapp
by qqq 18y ago
map1 and map2 repeat code. abstract this part to a general mapper function:
(loop for n from start to end do
then you will write the content of the first mapping as a function foo and call the general mapper and pass it foo to accomplish the same thing map1 does.
same with map2, except baz instead of foo.
then map3 is easy. call the general mapper again and pass in something like this: (lambda (x) (baz (foo x)))
or actually it looks like you wanted to add the results, so (lambda (x) (+ (baz x) (foo x)))
basically if you define the interesting part of map1 as one individual thing, and ditto for map2, then you can write the combination easily.
i hope that's clear and didn't miss the point somehow.