Advertisement
Guest User

Untitled

a guest
May 28th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.66 KB | None | 0 0
  1.  
  2. let performOneReduction var term =
  3.     let rec performOneReduction' = function
  4.        | Const(x) -> Const(x)
  5.        | Var(c) when c = var -> term
  6.        | Var(c) -> Var(c)
  7.        | Term(t1, t2) -> Term(performOneReduction' t1, performOneReduction' t2)
  8.    performOneReduction'
  9.  
  10. let isVar = function
  11.         | Var(c) -> true
  12.         | _ -> false
  13.  
  14. let variableToChar = function
  15.         | Var(c) -> c
  16.         | _ -> '-'
  17.            
  18. let termReduction =
  19.     let rec termReduction' = function
  20.        | Const(x) -> Const(x)
  21.        | Var(c) -> Variable(c)
  22.        | Term(t1, t2) -> TermTerm(termReduction' t1, termReduction' t2)
  23.    termReduction'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement