develooper Front page | perl.perl6.language | Postings from June 2005

Lvalue Str::words iterator

Thread Next
From:
Ingo Blechschmidt
Date:
June 15, 2005 10:15
Subject:
Lvalue Str::words iterator
Message ID:
d8pnci$vhj$1@sea.gmane.org
Hi,

as Larry mentioned in another thread that he wants a "different notation
for word
splitting" (http://www.nntp.perl.org/group/perl.perl6.language/21874),
how about that, similar to Haskell's "words" function:

    # Str::words should return a list of words, without whitespace.
    my $str   = " hi   my name is  ingo  ";
    my @words = words $str;
    say join ",", @words;     # "hi,my,name,is,ingo";


    # The list returned should contain lvalueable objects (idea courtesy
    # of wolverian):
    my $str     = " hi   my name is  ingo  ";
    $str.words .= map:{ ucfirst };
    say $str;                 # " Hi   My Name Is  Ingo  "
    # Note: The whitespace was preserved!


Comments?


--Ingo

-- 
Linux, the choice of a GNU | We are Pentium of Borg. Division is futile.
generation on a dual AMD   | You will be approximated.  
Athlon!                    | 


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About