Next: , Previous: , Up: Associative Maps   [Contents][Index]


11.8.5 Amap mapping and folding

procedure: amap-map procedure amap [comparator arg …]

Returns a newly allocated associative map as if by (make-amap comparator arg …). Calls procedure for every association in amap with the value of the association. The key of the association and the result of invoking procedure are entered into the new map.

If comparator recognizes multiple keys in amap as equivalent, any one of such associations is taken.

procedure: amap-for-each procedure amap

Calls procedure for every association in amap with two arguments: the key of the association and the value of the association. The value returned by procedure is discarded. Returns an unspecified value.

procedure: amap-map! procedure amap

Calls procedure for every association in amap with two arguments: the key of the association and the value of the association. The value returned by procedure is used to update the value of the association. Returns an unspecified value.

procedure: amap-map->list procedure amap

Calls procedure for every association in amap with two arguments: the key of the association and the value of the association. The values returned by the invocations of procedure are accumulated into a list, which is returned.

procedure: amap-fold kons knil amap

Calls kons for every association in amap with three arguments: the key of the association, the value of the association, and an accumulated value val. The argument knil is seed for the first invocation of kons, and for subsequent invocations of kons, the returned value of the previous invocation. The value returned by amap-fold is the return value of the last invocation of kons.

procedure: amap-prune! predicate amap

Calls predicate for every association in amap with two arguments, the key and the value of the association, and removes all associations from amap for which predicate returns true. Returns an unspecified value.


Next: , Previous: , Up: Associative Maps   [Contents][Index]