Skip to content

Commit

Permalink
Slurpy generators for series operator
Browse files Browse the repository at this point in the history
Plus whitespace fixes, and a comment fixes by Moritz

Signed-off-by: moritz <moritz@faui2k3.org>
  • Loading branch information
eternaleye authored and moritz committed Jun 29, 2009
1 parent 6c43f93 commit d3e040f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CREDITS
Expand Up @@ -310,4 +310,8 @@ N: Zach Morgan
E: zpmorgan@gmail.com
D: Rakudo patch

N: Alex Elsayed
U: eternaleye
E: eternaleye@gmail.com

=cut
18 changes: 12 additions & 6 deletions src/setting/Operators.pm
Expand Up @@ -7,12 +7,18 @@ multi sub infix:<...> (@lhs, Code $generator) {
}
my @result = @lhs;
my @r;
# XXX work around http://rt.perl.org/rt3/Ticket/Display.html?id=66824
# this is a bit ugly.. since @a[1..1] returns a single item and not
# an array, |@result[$one-item-range] throws the error
# "argument doesn't array"
while @r = $generator(|@(@result[*-$c..*-1])) {
@result.push: @r;
if ?any( $generator.signature.params>>.<slurpy> ) {
while @r = $generator(|@result) {
@result.push: @r;
}
} else {
# XXX work around http://rt.perl.org/rt3/Ticket/Display.html?id=66824
# this is a bit ugly.. since @a[1..1] returns a single item and not
# an array, |@result[$one-item-range] throws the error
# "argument doesn't array"
while @r = $generator(|@(@result[*-$c..*-1])) {
@result.push: @r;
}
}
return @result;
}
Expand Down

0 comments on commit d3e040f

Please sign in to comment.