-1

I want to make free variable checking function in lambda.

lambda experience is 
type exp =
Var of var
| Lambda of var * exp
| App of exp * exp
and var = string

In checking function, if free variable is included, then return false, else true.

For example, Lambda ("x", Var "x") is true, Lambda ("y", Var "x") is false.

ESCoder
  • 15,431
  • 2
  • 19
  • 42
  • Likely duplicate of https://stackoverflow.com/questions/13783338/free-variables-list-of-a-lambda-expression?rq=1 – Ulugbek Abdullaev Jun 14 '20 at 13:35
  • Does this answer your question? [Free variables list of a lambda expression](https://stackoverflow.com/questions/13783338/free-variables-list-of-a-lambda-expression) – Ulugbek Abdullaev Jun 14 '20 at 13:36

1 Answers1

1

The task seems to be a homework assignment, so it is unlikely to get solution-answers.

A couple of hints:

  • think of what type should your function have
  • your function needs to pattern match on exp, so think of how to handle each variant, i.e. Lambda, App, Var.
  • think of definition of a free variable to help you with handling cases in the hint above

You could also address Benjamin Pierce's book Types and Programming Languages on further reading on this topic.