The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


###
### iterator-to-stream.pl
###
### Originally from Higher-Order Perl by Mark Dominus, published by Morgan
### Kaufmann Publishers, Copyright 2005 by Elsevier Inc
###
### Ported to Perl6 by Dan Brook
###

## Chapter 8 section 1.4

use FindBin;
use lib ('../Chap6', $FindBin::RealDir);
use Stream 'node';

sub iterator_to_stream(Code $it) { # is exported(:all)
  my $v = $it.();
  return
    unless defined $v;
  return node($v, -> { iterator_to_stream($it) });
}

1;