listMap

Iterates over every entry of the List and calls the closure function to work on the item of the list. The returned value will be set at the same index in a new list and the new list will be returned.

listMap(list, function(item [,index, list]) [,delimiter, includeEmptyFields) → returns String

listMap Argument Reference

list
Required

The input list.

function
Required

Closure or a function reference that will be called for each of the iteration. The arguments passed to the callback are

item: value
index : current index for the iteration
list : reference of the original list

intialValue

Initial value which will be used for the reduce operation.

delimiter
Default: comma

The list delimiter.

includeEmptyFields
Default: false

Include empty values

Links more information about listMap

Examples sample code invoking the listMap function


Script Syntax

Rainbow = "Whero, Karaka, Kowhai, Kakariki, Kikorangi, Tawatawa, Mawhero"; 
 externalList = ""; 
 reverseRainbow = listMap( rainbow, function(v,i,l) 
 { 
 var newValue = "#i#:#v.reverse()#";  
 externalList = externalList.append(newValue); 
 return newValue; 
 }); 
 riteDump([{rainbow=rainbow},{reverseRainbow=reverseRainbow},{externalList=externalList}]);  

Fork me on GitHub