def

func:map

map(val, fn)

Map list, dict, or grid by applying the given mapping function.

If mapping a list, the mapping should be a function that takes (val) or (val, index). It should return the new value for that index.

If mapping a dict, the mapping should be a function that takes (val) or (val, name). It should return the new value for that name.

If mapping a grid, the mapping function takes (row) or (row,index) and returns a new dictionary to use for the row. The resulting grid shares the original's grid level meta. Columns left intact share the old meta-data, new columns have no meta-data. If the mapping function returns null, then that row is removed from the resulting grid (not mapped).

If mapping a range, then the mapping function takes (integer), and returns a list for each mapped integer inte the range.

If mapping a stream, the mapping functions takes (val). See Streams.

Examples:

// create list adding ten to each number
[1, 2, 3].map(v => v+10)   >>   [11, 12, 13]

// create new list that turns strings into uppercase
["ape", "bee", "cat"].map(upper)    // ["APE, "BEE", "CAT"]

// create dict adding ten to each value
{a:1, b:2, c:3}.map(v => v+10)   >>   {a:11, b:12, c:13}

// create grid with just dis, area column
readAll(site).map(s => {dis:s->dis, area:s->area})

meta

supertypes

feature

Feature namespace of definitions formatted as feature:name

    func

Axon function