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