diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-06 22:13:14 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-06 22:13:14 -0500 |
| commit | 53beaa0a6ddd9d8a5fb531f97c44a9c7129d1de7 (patch) | |
| tree | aad0aa97a9a7f54aed1cc26561aa22cea931f2fe /cs/printer.cs | |
| parent | b2ff794a97a80f8acac1914c679222fda5a3355c (diff) | |
| download | mal-53beaa0a6ddd9d8a5fb531f97c44a9c7129d1de7.tar.gz mal-53beaa0a6ddd9d8a5fb531f97c44a9c7129d1de7.zip | |
CS: add step1_read_print
Diffstat (limited to 'cs/printer.cs')
| -rw-r--r-- | cs/printer.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cs/printer.cs b/cs/printer.cs new file mode 100644 index 0000000..7ee5c03 --- /dev/null +++ b/cs/printer.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using Mal; +using MalVal = Mal.types.MalVal; +using MalList = Mal.types.MalList; + +namespace Mal { + public class printer { + public static string join(List<MalVal> value, + string delim, bool print_readably) { + List<string> strs = new List<string>(); + foreach (MalVal mv in value) { + strs.Add(mv.ToString(print_readably)); + } + return String.Join(delim, strs.ToArray()); + } + + public static string join(Dictionary<string,MalVal> value, + string delim, bool print_readably) { + List<string> strs = new List<string>(); + foreach (KeyValuePair<string, MalVal> entry in value) { + if (print_readably) { + strs.Add("\"" + entry.Key.ToString() + "\""); + } else { + strs.Add(entry.Key.ToString()); + } + strs.Add(entry.Value.ToString(print_readably)); + } + return String.Join(delim, strs.ToArray()); + } + + public static string _pr_str(MalVal mv, bool print_readably) { + return mv.ToString(print_readably); + } + + /* + public static string _pr_str_args(MalList args, String sep, + bool print_readably) { + return join(args.getList(), sep, print_readably); + } + */ + + } +} |
