Search Top Index
HELP MAPDATA Mark Rubinstein and Tom Khabaza, June 1985. mapdata(<object>, <procedure>) -> <object>; ncmapdata(<object>, <procedure>) -> <object>; MAPDATA is to structures what *MAPLIST is to lists. Given a vector or record type object (see HELP *CLASSES) and a procedure, MAPDATA returns a copy of the object in which each element of the object has been modified by the procedrue. NCMAPDATA is similar to MAPDATA except it doesn't copy the object. Because you cannot change the characters in a word NCMAPDATA won't work on *WORDS. However MAPDATA, because it returns a copy, will work on words. MAPDATA does not behave the same as *APPDATA. MAPDATA assumes a vector-object is to be constructed and that it is of the same length as the original. Examples: mapdata('This MiXeD caSe String', uppertolower) => ** this mixed case string mapdata("word", lowertoupper) => ** WORD *DUP duplicates the top item on the user stack. Here we can see the difference between APPDATA and MAPDATA: mapdata({a b c d e}, dup) => ** a a b b c {c d d e e} appdata({a b c d e}, dup) => ** a a b b c c d d e e define add1(x); x + 1 enddefine; mapdata({1 3 5 7}, add1) => ** {2 4 6 8} recordclass human weight height; vars tom mark; conshuman(24, 32) -> tom; mapdata(tom, add1) -> mark; tom => ** <human 24 32> mark => ** <human 25 33> ncmapdata(tom, add1) => ;;; ncmapdata alters the object. ** <human 25 33> tom => ;;; tom is changed <human 25 33> vars x = {1 3 5 7}; ncmapdata(x, add1) => ** {2 4 6 8} x => ;;; x is also changed ** {2 4 6 8} --- C.all/help/mapdata ------------------------------------------------- --- Copyright University of Sussex 1987. All rights reserved. ----------