Created
November 18, 2009 05:18
-
-
Save videlalvaro/237580 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://twitter.com/janl brought me into attention about this interesting piece of code: http://www.davispj.com/2009/11/17/unix-in-python.html and this one: http://pwpwp.blogspot.com/2009/11/unix-in-14-lines-of-ruby-its-trivial.html which is implementing a barebones Unix like system in your favorite language | |
Here's my take on the game which is some pretty basic Haskell | |
You can run this code by calling runghc unix.lhs | |
> import System.IO | |
> main = | |
> putStrLn "You have no mail" >> loop | |
> where | |
> loop = putStr "$ " >> hFlush stdout >> getLine >>= doCommand | |
> where | |
> doCommand "uname" = putStrLn "Hunix 0.1" >> loop | |
> doCommand "halt" = return () | |
> doCommand "" = putStrLn "$ " >> loop | |
> doCommand _ = putStrLn "command not found" >> loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment