Difference between revisions of "Unix tools/yes"

From HaskellWiki
Jump to navigation Jump to search
m (Reverted edits by Tomjaguarpaw (talk) to last revision by Knome)
m (Just keeping it simple...)
Line 19: Line 19:
 
<haskell>
 
<haskell>
 
main = putStrLn "y" >> main
 
main = putStrLn "y" >> main
  +
</haskell>
  +
  +
<haskell>
  +
main = putStrLn $ cycle "y\n"
 
</haskell>
 
</haskell>

Revision as of 03:17, 26 April 2021

yes

A simple utility to repeatedly print y to standard out.

Here are some various ways this simple program can be written.

  main = let y = putStrLn "y" >> y in y
  main =  putStrLn $ concat $ repeat "y\n"
  main = let y = 'y' : '\n' : y in putStrLn y
  main = putStrLn "y" >> main
  main = putStrLn $ cycle "y\n"