private IValue CharacterAtIndex(List <IValue> arguments, Scope s) { WulString str = (WulString)arguments.First(); Number index = (Number)arguments.Skip(1).First(); return(new WulString(str.Value[index].ToString())); }
private IValue Comparison(List <IValue> arguments, Scope s) { var strings = arguments.Select(a => a as WulString).ToArray(); WulString first = strings[0]; WulString second = strings[1]; return((Number)string.CompareOrdinal(first.Value, second.Value)); }
private IValue AreEqual(List <IValue> arguments, Scope s) { var strings = arguments.Select(a => a as WulString).ToArray(); WulString first = strings[0]; WulString second = strings[1]; return(first.Value.Equals(second.Value) ? Bool.True : Bool.False); }
internal static List <IValue> MetaStringify(ListNode list, Scope scope) { var children = list.Children.Skip(1).ToArray(); if (children.Length == 1) { IValue first = children.First(); var str = new WulString(first.ToString()); return(Value.ListWith(str)); } else if (children.Length > 1) { var results = children.Select(c => new WulString(c.ToString())).Cast <IValue>(); return(Value.ListWith(results.ToArray())); } throw new Exception("no arguments supplied to string"); }
internal static IValue Print(List <IValue> list, Scope scope) { foreach (IValue value in list) { string stringValue; if (value.MetaType?.AsString?.IsDefined ?? false) { WulString ustring = (WulString)value.MetaType.AsString.Invoke(new List <IValue> { value }, scope).First(); stringValue = ustring.Value; } else { stringValue = value.AsString(); } Console.WriteLine(stringValue); } return(Value.Nil); }
private IValue Length(List <IValue> arguments, Scope s) { WulString first = (WulString)arguments[0]; return((Number)first.Value.Length); }