method nodemap
Documentation for method nodemap assembled from the following types:
class Any
From Any
(Any) method nodemap
Defined as:
method nodemap( --> List) is nodal
nodemap will apply &block to each element and return a new List with the return values of &block. In contrast to deepmap it will not descend recursively into sublists if it finds elements which do the Iterable role.
say [[1,2,3], [[4,5],6,7], 7].nodemap(*+1);# OUTPUT: «(4, 4, 8)»say [[2, 3], [4, [5, 6]]]».nodemap(*+1)# OUTPUT: «((3 4) (5 3))»
The examples above would have produced the exact same results if we had used map instead of nodemap. The difference between the two lies in the fact that map flattens out slips while nodemap doesn't.
say [[2,3], [[4,5],6,7], 7].nodemap();# OUTPUT: «(() () 7)»say [[2,3], [[4,5],6,7], 7].map();# OUTPUT: «(7)»
When applied to Associatives, it will act on the values:
.nodemap( *.flip ).say;# OUTPUT: «{this => gniht, what => si}»