Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

FoxtrotUniform's scratchpad

by FoxtrotUniform (Prior)
on Jun 02, 2004 at 00:20 UTC ( #358884=scratchpad: print w/replies, xml ) Need Help??

$_ localization in map:

my @fn_refs = map {sub { print "$_\n"}} qw(foo bar baz); for (@fn_refs) { $_->(); }
CODE(0x8105f9c) CODE(0x8105f9c) CODE(0x8105f9c)
my @fn_refs = map {my $x=$_; sub { print "$x\n"}} qw(foo bar baz); for (@fn_refs) { $_->(); }
foo bar baz
$_ doesn't get localized to the codeblock in this call to map; assign to a local var first.

Sieve of Eratosthenes in Haskell:

sieve :: [Int] -> [Int] -> [Int] -- sieve [] xs -- Assuming that xs is a list of the form [2..max], returns a list of -- primes between 2 and max. The first parameter is an accumulator -- list. -- -- This is a loose interpretation of the Sieve of Eratosthenes; instea +d -- 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)

More pattern matching in Haskell:

factorial n | n == 0 = 1 | otherwise = n * factorial (n-1)

Opening too many files?
Perl/mod_perl on shared web servers
Hacking the perl core. Where to begin?
Module writing hints?
•range-based magical autoincrement
Unit Testing Generated HTML
Taken out of Context
Re: Keeping a Count in foreach
Re: Regular Expressions: Call for Examples
Why are closures cool?
Why are closures cool, continued?
Why Closures?
Closures and scope
for loops, closures
I'm sorry, Mr. Bond
japhy's Obfuscation Review
Re: What goes in a test suite?
Re: My first attempt at obfu (attempted helpfulness)
(tye)Re: How to propose a poll
Be aware of splice
What you refuse to see, is your worst trap
Organising Large Test Suites
S And M -- modifiers, that is...
Guitar neck diagram thingy
Closure on Closures
Composing effective node titles
Consideration overhaul?
Re (tilly) 2: Why Closures?
Re (tilly) 2 (disagree): Another commenting question,
My coding guidelines
Re: Are prototypes evil?
evaluation strategy of perl
MOPT-01 - assumptions and spaces
MOPT-02 - substitution and formal systems
MOPT-03 - identification, part 1
MOPT-04 - identification, part 2
Tripwire tests and future-proofing
Unit Tests and Creative Tension
Editing features for advanced users
Learning to Parrot
When is => ne , (warning rather arcane and possibly totally useless)
The Dynamic Duo --or-- Holy Getopt::Long, Pod::UsageMan!
GetOpt::Long usage style
The Scalar Range Operator
Re: Getopt::Long good style? (tight scoping)
Re: GB, MB, KB and on..
Lessons learned from getting to 100% with Devel::Cover
Funkyness with closures...
RE: Double Interpolation of a String
RFC: perlfeaturedelta
Re: The Purpose of Commenting
Searching BiBTeX
Re: cleaning up code with "do" ?
Obfu Coroutines
Of Symbol Tables and Globs
Perl Monks User Search
My permutor
Blessables -- What Can You Make Into Objects?
May Thy Closures Be Blessed
Multi-Method closures
Re: Fractal Curves: Short & Fast Codes?
Near-free function currying in Perl
Log In?

What's my password?
Create A New User
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-01-16 18:37 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (151 votes). Check out past polls.