Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:perl6/doc
  • Loading branch information
jonathanstowe committed May 4, 2015
2 parents 2460f90 + 565c4d2 commit ac5f0a4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/Language/concurrency.pod
Expand Up @@ -371,7 +371,7 @@ will be kept (and consequently will evaluate to True in a boolean context,)
when the channel is closed.
Because looping over a channel in this manner is a common pattern there is
a simpler fumctional syntax to do this:
a simpler functional syntax to do this:
my $channel = Channel.new;
Expand Down
6 changes: 3 additions & 3 deletions lib/Language/operators.pod
Expand Up @@ -265,9 +265,9 @@ In most cases, a dot may be placed before a postfix or postcircumfix:
@a.[1, 2, 3]; # Same
This can be useful for visual clarity or brevity. For example, if an object's
attribute is a function, putting a pair of paretheses after the attribute name
will become part of the method call. So either two pairs of paretheses must be
used, or a dot has to come before the parentheses to seperate it from the method
attribute is a function, putting a pair of parentheses after the attribute name
will become part of the method call. So either two pairs of parentheses must be
used, or a dot has to come before the parentheses to separate it from the method
call.
class Operation {
Expand Down
21 changes: 18 additions & 3 deletions lib/Language/syntax.pod
Expand Up @@ -328,11 +328,26 @@ Long forms with explicit values:
:thing['some', 'values'] # same as thing => ['some', 'values']
:thing{a => 'b'} # same as thing => { a => 'b' }
=begin comment
=head3 Array literals
TODO
A pair of square brackets can surround an expression to for an
itmized L<Array|/type/Array> literal; typically there is a comma-delimited list
inside:
say ['a', 'b', 42].join(' '); # a b 42
# ^^^^^^^^^^^^^^ Array constructor
The array constructor flattens non-itemized arrays and lists, but not itemized
arrays themselves:
my @a = 1, 2;
# flattens:
say [@a, 3, 4].elems; # 4
# does not flatten:
say [[@a], [3, 4]].elems; # 2
=begin comment
=head3 Hash literals
Expand Down
17 changes: 17 additions & 0 deletions lib/Type/List.pod
Expand Up @@ -574,6 +574,23 @@ Combining multiple cycles and C<:partial> also works:
say ('a'..'h').rotor(1 => 1, 3 => -1, :partial).join('|');
# a|c d e|e|g h
Note that assigning the list of lists returned from C<rotor> to a variable
will flatten to an C<Array>:
my @maybe_lol = ('a'..'h').rotor(2 => 1);
@maybe_lol.perl.say; #-> ["a", "b", "d", "e", "g", "h"]<>
Which probably isn't what one wanted, since the C<rotor>-ed output looks
like this:
say ('a'..'h').rotor(2 => 1).perl; #-> (("a", "b"), ("d", "e"), ("g", "h"))
To force a C<List> of C<List>s to be returned, I<bind> the output instead of
assigning it:
my @really_lol := ('a'..'h').rotor(2 => 1);
@really_lol.perl.say; #-> (("a", "b"), ("d", "e"), ("g", "h"))
=head2 routine zip
sub zip(List:D:, List:D:, ...) returns List:D
Expand Down

0 comments on commit ac5f0a4

Please sign in to comment.