The B Programming Language by

data TF = T | F | If (TF,TF,TF)

parse::[String]->(TF,[String])
parse("true":xs) =(T,xs)
parse("false":xs)=(F,xs)
parse("if":xs)=(If (a,b,c),cs) where
 (a,as)=parse xs
 (b,bs)=parse as
 (c,cs)=parse bs
parse(_:xs)=parse xs

exec::[String]->TF
exec=fst.parse

instance Show TF where
 show T="true"
 show F="false"
 show(If (a,b,c))= case(show a)of
  "true"->show b
  _->show c

main=do c<-getContents;mapM_ putStrLn$(lines c)>>=(return.show.exec.words)

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

To protect the system from spam, please input your favorite sport (hint: I believe its name must start with 'g', case insensitive)

download

return to the top page