Substring/Top and tail: Difference between revisions

m (→‎{{header|REXX}}: re-did the comments for the OUTPUT section comments.)
Line 480:
let s = "Some string."
mapM_ (\f -> putStrLn . f $ s) [remFirst, remLast, remBoth]</lang>
 
Alternative solution with builtin functions:
<lang Haskell>word = "knights"
 
main = do
-- You can drop the first item
-- using `tail`
putStrLn (tail word)
 
-- The `init` function will drop
-- the last item
putStrLn (init word)
 
-- We can combine these two to drop
-- the last and the first characters
putStrLn (middle word)
 
-- You can combine functions using `.`,
-- which is pronounced "compose" or "of"
middle = init . tail</lang>
 
=={{header|Icon}} and {{header|Unicon}}==
Anonymous user