Created
August 21, 2010 14:13
-
-
Save colomon/542357 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LinesIter is Iterator { | |
has $.filehandle; | |
has $.value; | |
method infinite() { False } | |
method reify() { | |
say "errrr?"; | |
unless $.value.defined { | |
my $parcel := pir::new('Parcel'); | |
my $line = $.filehandle.get; | |
say $line; | |
if $line.defined { | |
pir::push($parcel, $line); | |
pir::push($parcel, LinesIter.new(:filehandle($.filehandle))); | |
} | |
$.value = $parcel; | |
} | |
$.value; | |
} | |
} | |
say "got here..."; | |
my $count = 0; | |
for LinesIter.new(:filehandle($*IN)).list { | |
$count++; | |
} | |
say :$count.perl; | |
########################################################## | |
Wynne:rakudo colomon$ ./perl6 tt4.pl <tenthousand.txt | |
got here... | |
errrr? | |
Project Gutenberg's Songs of Angus and More Songs of Angus, by Violet Jacob | |
Cannot modify readonly value | |
in '&infix:<=>' at line 1 | |
in 'LinesIter::reify' at line 17:tt4.pl | |
in main program body at line 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment