示例#1
0
        public static Exp DeconstructList(this Exp list, IList <string> args, Exp body)
        {
            if (args.Count == 2)
            {
                return(list.Call(Lambda(new[] { args[0], args[1] }, body)));
            }
            var newBody = new Var("tail").DeconstructList(args.Skip(1).ToList(), body);

            return(list.Call(Lambda(new[] { args[0], "tail" }, newBody)));
        }
示例#2
0
        public static Exp PrintText(string text, Exp printSymbol, Exp printGlyphs)
        {
            var tokens      = text.Split(" ", StringSplitOptions.RemoveEmptyEntries);
            var symbols     = tokens.Select(t => PrintSymbolByName(t, printSymbol));
            var symbolsList = List(symbols.ToArray());

            return(printGlyphs.Call(symbolsList, 0));
        }
示例#3
0
        public static Exp PrintSymbolByName(string symbol, Exp printSymbol)
        {
            var sym = Renderer.Instance.GetSymbolFor(symbol);

            if (sym.Type == SymbolType.Graphics)
            {
                return(List(sym.Pixels.Select(p => Vec(p.X, p.Y)).ToArray()));
            }
            return(printSymbol.Call(sym.Type == SymbolType.Name, sym.Code));
        }
示例#4
0
 public static Exp Second(this Exp aPair) => tail.Call(aPair);
示例#5
0
 public static Exp First(this Exp aPair) => head.Call(aPair);
示例#6
0
 public static Exp If(Exp cond, Exp t, Exp f) => cond.Call(t, f);
示例#7
0
 public override Exp Apply(Exp x)
 {
     return(x.Call(Head, Tail));
 }