Help for this page

Select Code to Download


  1. or download this
    sub create_iterator{
         my $val = shift;
    ...
    }
    my $iter_even = create_iterator(0);
    my $iter_odd = create_iterator(1);
    
  2. or download this
    sub create_iter {
         my ($code_ref, @rest) = @_;
         return sub {$code_ref->();}
    }
    
  3. or download this
    my $even = create_iter(sub {my $c; $c += 2; return $c;},  0);   #  Doe
    +s NOT work
    
  4. or download this
    use strict;
    use warnings;
    ...
        1, 1);
    print "Fibonacci numbers: \n";
    print $fibonacci->(), " ", for 1..7;
    
  5. or download this
    Fibonacci:
    2 3 5 8 13 21 34
    
  6. or download this
    
    my $fact = create_iter (<<'EOS'
    ...
        , 1, 1);
    print "\n\nFact: \n";
    print $fact->(), " ", for 1..5;
    
  7. or download this
    Fact:
    2 6 24 120 720