- or download this
my @fn_refs = map {sub { print "$_\n"}} qw(foo bar baz);
for (@fn_refs) {
$_->();
}
- or download this
CODE(0x8105f9c)
CODE(0x8105f9c)
CODE(0x8105f9c)
- or download this
my @fn_refs = map {my $x=$_; sub { print "$x\n"}} qw(foo bar baz);
for (@fn_refs) {
$_->();
}
- or download this
foo
bar
baz
- 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)
- or download this
factorial n
| n == 0 = 1
| otherwise = n * factorial (n-1)