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

Lvalue Str::words iterator

Thread Next
Ingo Blechschmidt
June 15, 2005 10:15
Lvalue Str::words iterator
Message ID:

as Larry mentioned in another thread that he wants a "different notation
for word
splitting" (,
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!



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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About