-- $Id: back_prop.hs,v 1.5 2004/03/31 13:51:15 orlov Exp $
module Main (
main
) where
import Prelude hiding (Num (negate))
import Char
import IOExts
import Parse
import XSG
import URA
progs = unsafePerformIO $ compileFile "back_prop.xsg"
prog1 = take 7 progs
prog2 = drop 7 progs
cio n = ((es_in, es_out), [])
where es_in = [lst (map (\i -> x [i]) [1..n])]
es_out = [toOI n, x [0]]
str :: String -> Exp
str [] = at "NIL"
str (c:cs) = cons (at [c]) (str cs)
lst :: [Exp] -> Exp
lst [] = at "NIL"
lst (e:es) = cons e (lst es)
at :: String -> Exp
at s = c s []
toOI 0 = at "O"
toOI n = c "I" [toOI (n-1)]
cons :: Exp -> Exp -> Exp
cons e1 e2 = c "CONS" [e1, e2]
x = VAR . X
back_prop n = xURA prog1 prog2 (cio n)
main = do
x <- getChar
y <- getChar
let n = (digitToInt x)*10 + (digitToInt y)
print (back_prop n)