File: map

package info (click to toggle)
scheme9 2025.08.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,080 kB
  • sloc: lisp: 16,752; ansic: 11,869; sh: 806; makefile: 237; sed: 6
file content (18 lines) | stat: -rw-r--r-- 776 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
R4RS 6.9  (map procedure list1 list2 ...)  ==>  list

The LISTs must be lists, and PROCEDURE must be a procedure taking
as many arguments as there are lists. If more than one list is
given, then they must all be the same length. Map applies PROCEDURE
element-wise to the elements of the lists and returns a list of the
results, in order from left to right. The dynamic order in which
PROCEDURE is applied to the elements of the lists is unspecified.

(map cadr '((a b) (d e) (g h)))             ==>  (b e h)
(map (lambda (n) (expt n n)) '(1 2 3 4 5))  ==>  (1 4 27 256 3125)
(map + '(1 2 3) '(4 5 6))                   ==>  (5 7 9)

(let ((count 0))
  (map (lambda (ignored)
         (set! count (+ count 1))
         count)
       '(a b c)))                 ==>  unspecified