maplist

Table of Contents

Prototype: maplist(pattern, list)

Return type: slist

Description: Return a list with each element in list modified by a pattern.

The $(this) variable expands to the currently processed entry from list. This is essentially like the map() function in Perl, and applies to lists.

Arguments:

  • pattern: string, in the range: .*
  • list: string, in the range: [a-zA-Z0-9_$(){}\[\].:]+

Example:

body common control
{
      bundlesequence => { "example" };
}

bundle common g
{
  vars:

      "otherlist" slist => { "x", "y", "z" };
}


bundle agent example

{
  vars:

      "oldlist" slist => { "a", "b", "c" };

      "newlist1" slist => maplist("Element ($(this))","@(g.otherlist)");
      "newlist2" slist => maplist("Element ($(this))",@(oldlist));

  reports:
      "Transform: $(newlist1)";
      "Transform: $(newlist2)";
}

Output:

R: Transform: Element (x)
R: Transform: Element (y)
R: Transform: Element (z)
R: Transform: Element (a)
R: Transform: Element (b)
R: Transform: Element (c)

History: Was introduced in 3.3.0, Nova 2.2.0 (2011)

See also: maparray(), mapdata(), and data documentation.