Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- My lispy!!!!!
- import Data.HashMap.Strict
- type Variable = String
- type Environment = HashMap
- type Operand
- = Lambda [Variable] RetType Operand
- | Operation
- | Variable Variable
- | Integer Int
- type Operator
- = Add Operand Operand
- -- | Sub Operand Operand
- -- | Mul Operand Operand
- type Oporation = Operator Operand Operand
- eval :: Operand -> Operand
- eval (Integer i) = i
- eval (Variable v) = lookup env v
- eval (Operation op o1 o2) = eval
- eval :: Operation -> Operand
- eval Add o1 o2 = eval o1 + eval o2
- -- eval Sub o1 o2 e = eval o1 - eval o2
- -- eval Mul o1 o2 e = eval o1 * eval o2
- -- eval Div o1 o1 e = eval o1 / eval o2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement