Go to the first, previous, next, last section, table of contents.


Hauptprogramm

----------------------------------------------------------------------
> module Main           (  main  )
> where
----------------------------------------------------------------------

----------------------------------------------------------------------
> import Support
> import IOSupport
>
> import CLI
> import Pretty
> import CPSParser
>
> import Prim
> import Expr
> import Print
> import Parse
> import Function       hiding (  zero  )
> import Derive
> import Convert
> import Simplify       hiding (  summ, prod  )
> import Replace
> import Table
> import Integrate
> import Limes
----------------------------------------------------------------------

Kommandozeileninterpreter

----------------------------------------------------------------------
> type State            =  (Expr, Table)
----------------------------------------------------------------------

----------------------------------------------------------------------
> main                  =  readTable "integrals"                >>= \t ->
>                          putLine "for help type /help"        >>
>                          commandLineInterpreter
>                              "> " commands evaluate (Var "x", t)
----------------------------------------------------------------------

----------------------------------------------------------------------
> evaluate              :: State -> String -> IO State
> evaluate s x          =  case runParser (expression s) x of
>                          Left (Nothing, _) -> 
>                              putLine "sorry" >> return s
>                          Left (Just (t, s'), _) -> 
>                              putLine (pretty 78 t) >> return s'
>                          Right _     ->
>                              putLine "syntax error" >> return s
----------------------------------------------------------------------

Abarbeitung von Ausdr"ucken

----------------------------------------------------------------------
> expression (e, t)     =  ((lit '\" & var &= \x -> opt expr e &= \e ->
>                            unit (wrap x (Just . derive) e))
>                       ?   (lit '|' & var &= \x -> opt expr e &= \e ->
>                            unit (wrap x (integrate t) e))
>                       ?   (lit '[' & expr &= \e1 -> lit '/' & expr &= \e2 ->
>                            lit ']' & opt expr e &= \e ->
>                            unit (wrap "" (Just . replace (abstract "" e1,
>                                                           abstract "" e2)) e))
>                       ?   (lits "lim" & var &= \x -> lits "->" &
>                            ext expr &= \a -> opt expr e &= \e ->
>                            unit (wrap' x (limes (mapE (abstract "") a)) e))
>                       ?   (lits "st2" &
>                            unit (wrap "" (Just . standard2) e))
>                       ?   (lits "st3" & number &= \n ->
>                            unit (wrap "" (Just . standard3 (read n)) e))
>                       ?   (expr &= \e ->
>                            unit (wrap "" Just e)))
>                       &= \r -> end & unit r
>     where
>     wrap x f          =  abstract x # standard1 # f 
>                       #  mapM (standard1 # rapply x # \e' -> (pp e', (e', t)))
>     wrap' x f         =  abstract x # standard1 # f 
>                       #  mapM (mapE (standard1 # rapply "") # \v -> (pp v, (e, t)))
----------------------------------------------------------------------

----------------------------------------------------------------------
> rapply x f            =  apply f (Var x)
----------------------------------------------------------------------

----------------------------------------------------------------------
> mapM f Nothing        =  Nothing
> mapM f (Just a)       =  Just (f a)
----------------------------------------------------------------------

Abarbeitung von Kommandos

Standardformen zu `expression'!!!

----------------------------------------------------------------------
> commands              =  [
>     (["/exit", "/quit"], \_ _ ->
>                          exit),
>     (["?", "/help"],     \s _ ->
>                          help >> return s)]
----------------------------------------------------------------------

----------------------------------------------------------------------
> help                  =  sequence (map putStr [
>     "<exp>                    enter expression\n",
>     "'<var> <exp>             differentiate <exp> (or current expression)\n",
>     "|<var> <exp>             integrate <exp> (or current expression)\n",
>     "[<exp1>/<exp2>] <exp>    replace <exp1> by <exp2> in <exp> (or current)\n",
>     "lim ...                  <not yet>",
>     "st2                     standard form 2\n",
>     "st3 <nat>               standard form 3 [n]\n",
>     "?                        display this command summary\n",
>     "/exit                    quit the system\n",
>     "/help                    display this command summary\n",
>     "/quit                    quit the system\n"])
----------------------------------------------------------------------

Hilfsfunktionen

----------------------------------------------------------------------
> singleton a   =  [a]
----------------------------------------------------------------------

----------------------------------------------------------------------
> getNatArg             :: [String] -> IO (Integer, [String])
> getNatArg []          =  failWith (UserError "argument expected")
> getNatArg (arg:args)
>     | all isDigit arg =  return (read arg, args)
>     | otherwise       =  failWith (UserError "number expected")
----------------------------------------------------------------------


Go to the first, previous, next, last section, table of contents.