Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Re: Re: Re: Are strings lists of characters?

by Chmrr (Vicar)
on Oct 18, 2002 at 05:43 UTC ( #206224=note: print w/ replies, xml ) Need Help??

in reply to Re: Re: Re: Are strings lists of characters?
in thread Are strings lists of characters?

I have not read Dominus' chapter, so I spent a minute pondering and came up with the following definition of imap, which is probably much less elegant than his:

sub imap(&$) {defined($_=$_[1]->())?($_[0]->($_),&imap(@_)):()}

Can you tell I've been writing too much Scheme recently? ;> I also was pondering other implementations of the example iterator discussed earlier, and thought that

sub sub_iter { my ($s) = @_; return sub {$s?substr $s, 0, 1, '':undef} }

..might be a hair faster than the reverse. Benchmark says it's not, though; oh, well.

perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

Comment on Re: Re: Re: Re: Are strings lists of characters?
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://206224]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2015-11-30 10:03 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (769 votes), past polls