Skip to content

Commit e5f8fb0

Browse files
authored
changing method to routine for deepmap, in type/Any (#4704)
* changing method to routine for deepmap Adding documentation for the sub form of deepmap as per docs issue #4560 * add missing semicolons
1 parent a771b1e commit e5f8fb0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

doc/Type/Any.rakudoc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,23 +186,28 @@ say gather for 1 {
186186
In this case, C<gather> sinks the C<for> statement, and the result of sinking
187187
the L<C<Seq>|/type/Seq> will be iterating over its elements, calling C<.take> on them.
188188

189-
190-
=head2 method deepmap
189+
=head2 routine deepmap
191190

192191
method deepmap(&block --> List) is nodal
192+
multi deepmap(&op, \obj)
193193

194-
C<deepmap> will apply C<&block> to each element and return a new
195-
L<C<List>|/type/List> with the return values of C<&block>, unless the element does
196-
the L<C<Iterable>|/type/Iterable> role. For those elements
194+
C<deepmap> will apply its argument (or first argument for the sub form) to
195+
each element and return a new L<C<Iterable>|/type/Iterable> with the return
196+
values of the argument, unless the element does the
197+
L<C<Iterable>|/type/Iterable> role. For those elements
197198
L<deepmap|/routine/deepmap> will descend recursively into the sublist.
198199

199200
say [[1,2,3],[[4,5],6,7]].deepmap(* + 1);
200201
# OUTPUT: «[[2 3 4] [[5 6] 7 8]]␤»
202+
say deepmap * + 1, [[1,2,3],[[4,5],6,7]];
203+
# OUTPUT: «[[2 3 4] [[5 6] 7 8]]␤»
201204

202205
In the case of L<C<Associative>|/type/Associative>s, it will be applied to its values:
203206

204207
=for code
205-
{ what => "is", this => "thing", a => <real list> }.deepmap( *.flip ).say
208+
{ what => "is", this => "thing", a => <real list> }.deepmap( *.flip ).say;
209+
# OUTPUT: «{a => (laer tsil), this => gniht, what => si}␤»
210+
say deepmap *.flip, {what=>'is', this=>'thing', a=><real list>};
206211
# OUTPUT: «{a => (laer tsil), this => gniht, what => si}␤»
207212

208213
=head2 method duckmap

0 commit comments

Comments
 (0)