aboutsummaryrefslogtreecommitdiff
path: root/cs/types.cs
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-11-15 20:38:50 -0600
committerJoel Martin <github@martintribe.org>2015-01-09 16:16:46 -0600
commitc3b508af92800f63bf99f41af68f026535f454f5 (patch)
treee94c4f555375189c69cebada164afba80f2579bd /cs/types.cs
parent95ec2d81d8661e56b7b98a1c19ad503c5083c1e4 (diff)
downloadmal-c3b508af92800f63bf99f41af68f026535f454f5.tar.gz
mal-c3b508af92800f63bf99f41af68f026535f454f5.zip
C#: use closure for RE func. Shorter type names.
Diffstat (limited to 'cs/types.cs')
-rw-r--r--cs/types.cs43
1 files changed, 22 insertions, 21 deletions
diff --git a/cs/types.cs b/cs/types.cs
index b49adb6..fd0b9fb 100644
--- a/cs/types.cs
+++ b/cs/types.cs
@@ -39,9 +39,9 @@ namespace Mal {
(a is MalList && b is MalList))) {
return false;
} else {
- if (a is MalInteger) {
- return ((MalInteger)a).getValue() ==
- ((MalInteger)b).getValue();
+ if (a is MalInt) {
+ return ((MalInt)a).getValue() ==
+ ((MalInt)b).getValue();
} else if (a is MalSymbol) {
return ((MalSymbol)a).getName() ==
((MalSymbol)b).getName();
@@ -97,10 +97,10 @@ namespace Mal {
static public MalConstant True = new MalConstant("true");
static public MalConstant False = new MalConstant("false");
- public class MalInteger : MalVal {
+ public class MalInt : MalVal {
int value;
- public MalInteger(int v) { value = v; }
- public new MalInteger copy() { return this; }
+ public MalInt(int v) { value = v; }
+ public new MalInt copy() { return this; }
public int getValue() { return value; }
public override string ToString() {
@@ -109,35 +109,36 @@ namespace Mal {
public override string ToString(bool print_readably) {
return value.ToString();
}
- public static MalConstant operator <(MalInteger a, MalInteger b) {
+ public static MalConstant operator <(MalInt a, MalInt b) {
return a.getValue() < b.getValue() ? True : False;
}
- public static MalConstant operator <=(MalInteger a, MalInteger b) {
+ public static MalConstant operator <=(MalInt a, MalInt b) {
return a.getValue() <= b.getValue() ? True : False;
}
- public static MalConstant operator >(MalInteger a, MalInteger b) {
+ public static MalConstant operator >(MalInt a, MalInt b) {
return a.getValue() > b.getValue() ? True : False;
}
- public static MalConstant operator >=(MalInteger a, MalInteger b) {
+ public static MalConstant operator >=(MalInt a, MalInt b) {
return a.getValue() >= b.getValue() ? True : False;
}
- public static MalInteger operator +(MalInteger a, MalInteger b) {
- return new MalInteger(a.getValue() + b.getValue());
+ public static MalInt operator +(MalInt a, MalInt b) {
+ return new MalInt(a.getValue() + b.getValue());
}
- public static MalInteger operator -(MalInteger a, MalInteger b) {
- return new MalInteger(a.getValue() - b.getValue());
+ public static MalInt operator -(MalInt a, MalInt b) {
+ return new MalInt(a.getValue() - b.getValue());
}
- public static MalInteger operator *(MalInteger a, MalInteger b) {
- return new MalInteger(a.getValue() * b.getValue());
+ public static MalInt operator *(MalInt a, MalInt b) {
+ return new MalInt(a.getValue() * b.getValue());
}
- public static MalInteger operator /(MalInteger a, MalInteger b) {
- return new MalInteger(a.getValue() / b.getValue());
+ public static MalInt operator /(MalInt a, MalInt b) {
+ return new MalInt(a.getValue() / b.getValue());
}
}
public class MalSymbol : MalVal {
string value;
public MalSymbol(string v) { value = v; }
+ public MalSymbol(MalString v) { value = v.getValue(); }
public new MalSymbol copy() { return this; }
public string getName() { return value; }
@@ -298,16 +299,16 @@ namespace Mal {
}
}
- public class MalFunction : MalVal {
+ public class MalFunc : MalVal {
Func<MalList, MalVal> fn = null;
MalVal ast = null;
Mal.env.Env env = null;
MalList fparams;
bool macro = false;
- public MalFunction(Func<MalList, MalVal> fn) {
+ public MalFunc(Func<MalList, MalVal> fn) {
this.fn = fn;
}
- public MalFunction(MalVal ast, Mal.env.Env env, MalList fparams,
+ public MalFunc(MalVal ast, Mal.env.Env env, MalList fparams,
Func<MalList, MalVal> fn) {
this.fn = fn;
this.ast = ast;