Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: RFC: Should join subsume reduce?

by nothingmuch (Priest)
on Feb 24, 2006 at 00:49 UTC ( [id://532433]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    join _ [] = [] -- this means that join on the empty list is the empty 
    +string
    join delim strings = foldl1 (\left right -> left ++ delim ++ right ) s
    +trings -- this is join implemented with reduce
    ...
    
    -- or with autocurrying fun
    join = foldl1 . ((++) .) . flip (++)
    
  2. or download this
    sub join {
        my ( $delim, @strings ) = @_;
        reduce { $a . $delim . $b } @strings;
    }
    but in this case the concatenation operator is not used directly as th
    +e a curried higher order function
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-28 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found