Exemplo n.º 1
0
        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()));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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");
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        private IValue Length(List <IValue> arguments, Scope s)
        {
            WulString first = (WulString)arguments[0];

            return((Number)first.Value.Length);
        }