-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariable.java
More file actions
41 lines (36 loc) · 740 Bytes
/
Copy pathVariable.java
File metadata and controls
41 lines (36 loc) · 740 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
import java.util.HashMap;
public class Variable extends Atom {
private String ident;
/**
* Constructor.
*
* @param ident Identifier for variable.
*/
public Variable(String ident) {
this.ident = ident;
}
/**
* Returns name of variable.
*
* @return Variable name.
*/
public String getName() {
return this.ident;
}
public Boolean isVariable() {
return true;
}
/**
* Evaluate current Variable.
*
* @return Result
*/
public Sexpr eval(HashMap<String, Sexpr> variables) {
if (variables.containsKey(this.getName())) {
Sexpr expr = variables.get(this.ident);
return expr;
} else {
return this;
}
}
}