Method code for $data_lib.data_map()

[Turn off line numbering]
  1: arg val, method, options, @args;
  2: var i, args, object, class;
  3: 
  4: object = (| options['object] |);
  5: switch (type(val)) {
  6:     case 'list:
  7:         if ((| options['list] |))
  8:             return object ? object.(method)(val, @args) : val.(method)(@args);
  9:         return map i in (val) to (refresh() && .data_map(i, method, options, @args));
 10:     case 'dictionary:
 11:         if ((| options['dictionary] |))
 12:             return object ? object.(method)(val, @args) : val.(method)(@args);
 13:         if ((| options['keys] |))
 14:             return hash i in (val) to ([.data_map(i[1], method, options, @args), refresh() && .data_map(i[2], method, options, @args)]);
 15:         return hash i in (val) to ([i[1], refresh() && .data_map(i[2], method, options, @args)]);
 16:     case 'frob:
 17:         if ((| (class = options['class]) |)) {
 18:             if ((| class(val) in class |))
 19:                 return object ? object.(method)(val, @args) : val.(method)(@args);
 20:             else
 21:                 return val;
 22:         }
 23:         return (<class(val), (.data_map(val.value(), method, options, @args))>);
 24:     default:
 25:         if ((| options['all] |) || (| options[type(val)] |))
 26:             return object ? object.(method)(val, @args) : val.(method)(@args);
 27:         return val;
 28: }
 29: 
 30: // $#Edited: 04 Aug 97 14:17 $miro

["// Created 07-Dec-1996 as a part of ColdCore, see: @help Credit"]

the Cold Dark