;'<<SPEC'
<!--
Copyright (c) 2012-2024, Chris Pressey, Cat's Eye Technologies.
This file is distributed under a 2-clause BSD license. See LICENSES/ dir.
SPDX-License-Identifier: LicenseRef-BSD-2-Clause-X-Robin
-->
### `map` ###
-> Tests for functionality "Evaluate Robin Expression (with List)"
`map` evaluates its first argument to obtain an operator, and its second argument
to obtain a list. It then evaluates to a list which is obtained by applying
the operator to each element of the given list. The operator is generally assumed
to be a one-argument function.
| (map (fun (x) (list x)) (literal (three dog night)))
= ((three) (dog) (night))
While it is possible to pass an operator that is not a function, it is not
very productive. (Also, it exposes the implementation of `map`, so this
is not a very good test.)
| (map (fexpr (args env) args) (literal (three dog night)))
= (((head li)) ((head li)) ((head li)))
'<<SPEC'
;(requires empty?)
(define map (fun (app li)
(bind map-r
(fun (self app li)
(if (empty? li)
()
(prepend (app (head li)) (self self app (tail li)))))
(map-r map-r app li))))