-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda.hpp
More file actions
42 lines (34 loc) · 776 Bytes
/
lambda.hpp
File metadata and controls
42 lines (34 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef LAMBDA_H
#define LAMBDA_H
#include <iostream>
#include <string>
#include <memory>
class Lambda
{
public:
enum Type
{
VARIABLE,
ABSTRACTION,
APPLICATION
};
// Constructors
Lambda(std::string variable);
Lambda(std::string variable, std::unique_ptr<Lambda> body);
Lambda(std::unique_ptr<Lambda> func, std::unique_ptr<Lambda> param);
// Query methods
Type type() const;
// Output
friend std::ostream &operator<<(std::ostream &os, const std::unique_ptr<Lambda> &term);
private:
Type type_;
std::string variable_;
std::unique_ptr<Lambda> left_;
std::unique_ptr<Lambda> right_;
};
template <typename... T>
constexpr std::unique_ptr<Lambda> lambda(T&&... args)
{
return std::make_unique<Lambda>(std::move(args)...);
}
#endif