diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-16 23:57:50 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-16 23:57:50 -0500 |
| commit | 8cb5cda46cf3aef847ae3926dc53a5e5f87fe261 (patch) | |
| tree | 13e5b2878f19ee24272ead8a92a9cb84b33ad0e5 /cs/core.cs | |
| parent | a05f7822b10ed4cdd61ed8384299a003baf1c1c6 (diff) | |
| download | mal-8cb5cda46cf3aef847ae3926dc53a5e5f87fe261.tar.gz mal-8cb5cda46cf3aef847ae3926dc53a5e5f87fe261.zip | |
All: move some fns to core. Major cleanup.
- Don't import/require core until step4.
- Define cond/or macros from step8
Diffstat (limited to 'cs/core.cs')
| -rw-r--r-- | cs/core.cs | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -1,4 +1,5 @@ using System; +using System.IO; using System.Collections.Generic; using MalVal = Mal.types.MalVal; using MalConstant = Mal.types.MalConstant; @@ -54,6 +55,21 @@ namespace Mal { return Nil; } ); + static public MalFunction mal_readline = new MalFunction( + a => { + var line = readline.Readline(((MalString)a[0]).getValue()); + if (line == null) { return types.Nil; } + else { return new MalString(line); } + } ); + + static public MalFunction read_string = new MalFunction( + a => reader.read_str(((MalString)a[0]).getValue())); + + static public MalFunction slurp = new MalFunction( + a => new MalString(File.ReadAllText( + ((MalString)a[0]).getValue()))); + + // List/Vector functions static public MalFunction list_Q = new MalFunction( a => a[0].GetType() == typeof(MalList) ? True : False); @@ -233,10 +249,14 @@ namespace Mal { {"true?", true_Q}, {"false?", false_Q}, {"symbol?", symbol_Q}, + {"pr-str", pr_str}, {"str", str}, {"prn", prn}, {"println", println}, + {"readline", mal_readline}, + {"read-string", read_string}, + {"slurp", slurp}, {"<", new MalFunction(a => (MalInteger)a[0] < (MalInteger)a[1])}, {"<=", new MalFunction(a => (MalInteger)a[0] <= (MalInteger)a[1])}, {">", new MalFunction(a => (MalInteger)a[0] > (MalInteger)a[1])}, |
