Jump to content

Nested function: Difference between revisions

m
m (→‎{{header|Haskell}}: Added a variant.)
Line 830:
let makeItem = (<>) . (<> separator) . show
in unlines $ zipWith makeItem [1 ..] ["First", "Second", "Third"]
 
main :: IO ()
main = putStrLn $ makeList ". "</syntaxhighlight>
 
or perhaps:
<syntaxhighlight lang="haskell">makeList :: String -> String
makeList separator =
let makeItem = unlines . zipWith ((<>) . (<> separator) . show) [1..]
in makeItem ["First", "Second", "Third"]
 
main :: IO ()
9,655

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.