public static Object Map(Cons args, Environment environment) { Cons temp = null; foreach (object o in (IEnumerable)args.Second()) { temp = new Cons( Runtime.Apply(args.First(), new Cons(o), environment), temp); } return(temp.Reverse()); }
/// <summary> /// (map function list) Maps function to each element in list return a new /// list of return values. /// </summary> /// <param name="args"></param> /// <param name="environment"></param> /// <returns></returns> public static Object Map(Cons args, Environment environment) { if (args.Second() == null) return null; Cons temp = null; foreach (object o in (IEnumerable)args.Second()) { temp = new Cons( Runtime.Apply( args.First(),new Cons(o),environment), temp); } return temp.Reverse(); }