Example #1
0
 public virtual void RegisterMessages()
 {
     registerMessage("string".get(), (obj, _) => String.StringObject(obj.AsString));
     registerMessage("image".get(), (obj, _) => String.StringObject(obj.Image));
     registerMessage("hash".get(), (obj, _) => Int.IntObject(obj.Hash));
     registerMessage("equals(_)", (obj, _) => Boolean.BooleanObject(obj.IsEqualTo(_.Arguments[0])));
     registerMessage("className".get(), (obj, _) => String.StringObject(obj.ClassName));
     registerMessage("class".get(), (obj, _) => new Class(obj.ClassName));
     registerMessage("match(_)", match);
     messages["isNumber".get()] = (_, _) => Boolean.False;
     registerMessage("send(_,_)",
                     (obj, _) => function <IObject, String>(obj, _, (o, n) => sendMessage(o, n.Value, _.Arguments.Pass(1))));
     registerMessage("respondsTo(_)", (obj, _) => (Boolean)classOf(obj).RespondsTo(_.Arguments[0].AsString));
     registerMessage("seq(_)", (obj, _) => new OpenRange(obj, (Lambda)_.Arguments[0]));
     registerMessage("format(_)", (obj, _) => format(obj, _.Arguments[0].AsString));
 }
Example #2
0
 public virtual void RegisterClassMessages()
 {
     registerClassMessage("name".get(), (_, _) => String.StringObject(Name));
 }
Example #3
0
 protected static IObject getIndexed(String s, IObject i)
 {
     return(CollectionFunctions.getIndexed(s, i, (str, index) => str[index], (str, list) => str[list]));
 }
Example #4
0
 public IObject Revert(IEnumerable <IObject> list) => String.StringObject(list.Select(i => i.AsString).ToString(""));
Example #5
0
 public IObject Readln()
 {
     return(Machine.Current.Context.ReadLine()
            .Map(s => Success.Object(String.StringObject(s)))
            .Recover(e => Failure.Object(e.Message)));
 }