Loading

MFILTER

maps

The MFILTER function filters the element of a MAP according to the result of a macro execution on each key/value pair of the MAP. It produces a MAP containing only the elements for which the macro returned true.

The macro is called with a stack containing the MAP index on top and the key/value pair at that particular index below it. You can override this behaviour with a boolean.

MFILTER is available since version 2.9.0.

See also

Signatures

Examples

{ 'klingon' 10 'vulcan' 127 'romulan' 78 'ferengi' 2 'borg' 0 } <% [ 'k' 'v' ] STORE $k -1 GET 'n' == // Last letter in a 'n' $v 2 % 0 == // Even number AND %> false MFILTER

Examples

A = { 'klingon': 10, 'vulcan': 127, 'romulan': 78, 'ferengi': 2, 'borg': 0 } M = (k,v) -> { i = GET(k, -1) == 'n' // Last letter in a 'n' j = v % 2 == 0 // Even number return AND(i, j) } return MFILTER(A, M, false)