Search Top Index
HELP MAPLIST John Williams Jul 1985 Updated: Adrian Howard Mar 1992 maplist(LIST_1, P) -> LIST_2 LIST2 -> maplist(LIST1, P) This procedure takes as arguments a list and a procedure. It returns a (possibly empty) list whose elements are the result of applying the given procedure to each element of the argument list. The updater is defined in such a way that listvals -> maplist(list,proc) is equivalent to dl(listvals) -> applist(rev(list), updater(proc)) For example: maplist([1 4 9 25], sqrt) => ** [1.0 2.0 3.0 5.0] maplist([a b c d], procedure(x); [^x] endprocedure) => ** [[a] [b] [c] [d]] vars list1 = [[a 1] [b 2] [c 3]]; vars list2 = [A B C]; list2 -> maplist(list1,hd); list1 => ** [[A 1] [B 2] [C 3]] -maplist- could be defined as: define maplist(list, proc); lvars list, procedure proc; [% applist(list, proc) %] enddefine; and its -updater- as define updaterof maplist(vals,list,proc); lvars vals,list, procedure proc; dl(vals) -> applist(rev(list), updater(proc)) enddefine; Also see: HELP *APPDATA --- Apply a procedure to every element of a structure HELP *LOOPS --- For other types of iteration HELP *MAPDATA --- Similar to -maplist-, but takes other data structures REF *DATA --- Details on generic data procedures. REF *APPLIST --- Apply a procedure to every element of a list REF *LISTS --- Full information on lists in POP-11 REF *NCMAPLIST --- Non-copying version of -maplist- --- C.all/help/maplist --- Copyright University of Sussex 1992. All rights reserved. ----------