Skip to content

Commit

Permalink
Rearrange series op to be less eager, fixes TimToady's primer
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jan 5, 2012
1 parent fa69aee commit 123d639
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/CORE.setting
Original file line number Diff line number Diff line change
Expand Up @@ -2176,8 +2176,11 @@ our sub Niecza::generate-series(@lhs, $rhs, :$exclude-limit) {
my sub infinite-series (@lhs, $limit ) {
gather {
my $i = 0;
while @lhs[$i+1].defined { take @lhs[$i]; $i++; } #We blindly take all elems of the LHS except last one.
if @lhs[$i] !~~ Code { take @lhs[$i]; $i++; } #We take the last element only when it is not code
# Take all items from the LHS except for terminal Codes
# (ordered this way to avoid overeager evaluation)
while @lhs[$i] !~~ Code || @lhs[$i+1].defined {
take @lhs[$i]; $i++;
}
my $next = get-next-closure(@lhs , $limit );
my $arity = $next.count;
Expand Down

0 comments on commit 123d639

Please sign in to comment.