import Html exposing (text)
v = [1,2,3]
joinHelper : String -> List String -> String -> String
joinHelper separator list s =
case list of
[] -> s
h::t -> joinHelper separator t (s ++ separator ++ h)
join : String -> List String -> String
join separator list =
case list of
[] -> ""
h::t -> joinHelper separator t h
main =
text (toString (join "::" (List.map (\i -> toString i) v)))
Outputs the text 1::2::3
import Html exposing (text)
v = [1,2,3]
joinHelper : String -> String -> List String -> String -> String
joinHelper separator suffix list s =
case list of
[] -> s ++ suffix
h::t -> joinHelper separator suffix t (s ++ separator ++ h)
join : String -> String -> String -> List String -> String
join prefix separator suffix list =
case list of
[] -> ""
h::t -> joinHelper separator suffix t (prefix ++ h)
main =
text (toString (join "<<<" "::" ">>>" (List.map (\i -> toString i) v)))
Outputs the text <<<1::2::3>>>
import Html exposing (text)
v = ['a', 'b', 'c']
joinHelper : (a -> a -> a) -> a -> a -> List a -> a -> a
joinHelper append separator suffix list s =
case list of
[] -> append s suffixstrings
h::t -> joinHelper append separator suffix t (append s (append separator h))
join : (a -> a -> a) -> a -> a -> a -> List a -> a
join append prefix separator suffix list =
case list of
[] -> append prefix suffix
h::t -> joinHelper append separator suffix t (append prefix h)
myJoinStrings = join (\ a b -> a ++ b) "<<<" "::" ">>>"
main =
text (toString (myJoinStrings (List.map (\c -> String.fromChar c) v)))
Outputs the text <<<a::b::c>>>