struct.map()

Calls the given closure with every element in the given struct.

The function returns a struct that contains all values returned by the closure.

struct.map( closure=function, parallel=boolean, maxThreads=number )

Returns: Struct

Argument Description
closure
function, required

filter can be a function/closure that implements the following constructor

[function(string key, any value[, struct struct]):any].

Alias: function, callback, udf

parallel
boolean, optional

execute closures parallel

maxThreads
number, optional

maximum number of threads executed, ignored when argument "parallel" is set to false

Examples

original = {
	    "one": {
	        1: "map"
	    },
	    "two": {
	        2: "struct"
	    },
	    "three": {
	        3: "mapstruct"
	    },
	    "four": {
	        4: "structmap"
	    }
	};
	function mapOriginal(k,v) {
	    return v[ListFirst(v.keyList())];
	}
	fixed = original.Map(mapOriginal);
	writeDump([original, fixed]);

See also