Help for this page

Select Code to Download


  1. or download this
    my @fn_refs = map {sub { print "$_\n"}} qw(foo bar baz);
    
    for (@fn_refs) {
        $_->();
    }
    
  2. or download this
    CODE(0x8105f9c)
    CODE(0x8105f9c)
    CODE(0x8105f9c)
    
  3. or download this
    my @fn_refs = map {my $x=$_; sub { print "$x\n"}} qw(foo bar baz);
    
    for (@fn_refs) {
        $_->();
    }
    
  4. or download this
    foo
    bar
    baz
    
  5. or download this
    sieve :: [Int] -> [Int] -> [Int]
    -- sieve [] xs
    ...
    --  of marking composite numbers, we remove them.
    sieve p []      = reverse p
    sieve p (x:xs)  = sieve (x:p) (filter (\t -> (rem t x /= 0)) xs)
    
  6. or download this
    factorial n
      | n == 0    = 1
      | otherwise = n * factorial (n-1)