Odd word problem: Difference between revisions
m
→{{header|Haskell}}: Tidying.
(Added Wren) |
m (→{{header|Haskell}}: Tidying.) |
||
Line 1,121:
While it seems like this solution would break the task's rules, Haskell is non-strict, therefore this yields the same behavior of reading and printing one character at a time, without excess storage into a "string". To prove it, run the program and manually enter the input string (Windows command prompt does not respect buffering settings, but urxvt on on Linux does).
<lang Haskell>import System.IO
(BufferMode(..), getContents, hSetBuffering, stdin, stdout)
import Data.Char (isAlpha)
split :: String -> (String, String)
split =
parse :: String -> String
parse [] = []
parse l
let (a, w) = split l
(b, x) = splitAt 1 w
(c, y) = split x
(d, z) = splitAt 1 y
in a
main :: IO ()
main =
putStrLn "."</lang>
If the above is not acceptable, or if Haskell was implicitly strict, then this solution would satisfy the requirements:
<lang Haskell>isAlpha :: Char -> Bool
|