Substring/Top and tail: Difference between revisions

Content added Content deleted
No edit summary
m (duplicate entry removed)
Line 235: Line 235:
=={{header|Haskell}}==
=={{header|Haskell}}==
<lang Haskell>-- We define the functions to return an empty string if the argument is too
<lang Haskell>-- We define the functions to return an empty string if the argument is too
-- short for the particular operation.

remFirst, remLast, remBoth :: String -> String

remFirst "" = ""
remFirst cs = tail cs

remLast "" = ""
remLast cs = init cs

remBoth (c:cs) = remLast cs
remBoth _ = ""

main :: IO ()
main = do
let s = "Some string."
mapM_ (\f -> putStrLn . f $ s) [remFirst, remLast, remBoth]</lang>

=={{header|Haskell}}==
<lang haskell>-- We define the functions to return an empty string if the argument is too
-- short for the particular operation.
-- short for the particular operation.