本文整理汇总了C#中ScheminPair.ElementAt方法的典型用法代码示例。如果您正苦于以下问题:C# ScheminPair.ElementAt方法的具体用法?C# ScheminPair.ElementAt怎么用?C# ScheminPair.ElementAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScheminPair
的用法示例。
在下文中一共展示了ScheminPair.ElementAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckArguments
public override void CheckArguments(ScheminPair args)
{
IScheminType first = args.Car;
IScheminType second = args.ElementAt(1);
IScheminType third = args.ElementAt(2);
if (args.Length != 3)
{
throw new BadArgumentsException("expected 3 arguments");
}
if ((first as ScheminString) == null)
{
throw new BadArgumentsException("first argument must be a string");
}
if ((second as ScheminInteger) == null)
{
throw new BadArgumentsException("second argument must be an integer");
}
if ((third as ScheminInteger) == null)
{
throw new BadArgumentsException("third argument must be an integer");
}
return;
}
示例2: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
ScheminVector vec = (ScheminVector) args.Car;
ScheminInteger pos = (ScheminInteger) args.ElementAt(1);
IScheminType val = args.ElementAt(2);
int pos_int = (int) pos.IntegerValue();
vec.List[pos_int] = val;
return new ScheminPair();
}
示例3: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
bool deffun = false;
if ((args.Car as ScheminPair) != null)
{
deffun = true;
}
if (!deffun)
{
ScheminAtom symbol = (ScheminAtom) args.ElementAt(0);
IScheminType definition = args.ElementAt(1);
if (env.bindings.ContainsKey(symbol.Name))
{
env.RemoveBinding(symbol);
env.AddBinding(symbol, definition);
}
else
{
env.AddBinding(symbol, definition);
}
return new ScheminPair();
}
else
{
ScheminPair arguments = (ScheminPair) args.Car;
ScheminPair expression = args.ListCdr();
ScheminAtom name = (ScheminAtom) arguments.Car;
IScheminType lamParams = arguments.Cdr;
if (lamParams == null)
lamParams = new ScheminPair();
ScheminPair lamArgs = new ScheminPair(lamParams, expression);
ScheminLambda lam = new ScheminLambda(lamArgs, env);
if (env.bindings.ContainsKey(name.Name))
{
env.RemoveBinding(name);
env.AddBinding(name, lam);
}
else
{
env.AddBinding(name, lam);
}
return new ScheminPair();
}
}
示例4: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
ScheminString str = (ScheminString) args.Car;
ScheminInteger from = (ScheminInteger) args.ElementAt(1);
ScheminInteger to = (ScheminInteger) args.ElementAt(2);
int from_int = (int) from.IntegerValue();
int to_int = (int) to.IntegerValue();
string substring = str.Value.Substring(from_int, to_int);
return new ScheminString(substring);
}
示例5: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
ScheminPair bindings = (ScheminPair) args.Car;
IScheminType expression = args.ElementAt(1);
ScheminPair first = new ScheminPair();
ScheminPair firstBinding = new ScheminPair(bindings.Car);
first = first.Append(new ScheminPrimitive("let"));
first = first.Append(firstBinding);
if (bindings.Cdr != null)
{
ScheminPair nextLet = new ScheminPair(bindings.Cdr);
nextLet = nextLet.Cons(new ScheminPrimitive("let*"));
nextLet = nextLet.Append(expression);
first = first.Append(nextLet);
}
else
{
first = first.Append(expression);
}
return first;
}
示例6: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
IScheminType head = args.Car;
IScheminType rest = args.ElementAt(1);
if ((rest as ScheminPair) != null && ((ScheminPair) rest).Proper)
{
ScheminPair temp = (ScheminPair) rest;
if (temp.Empty)
{
return new ScheminPair(head);
}
else
{
ScheminPair consd = new ScheminPair(head);
foreach (IScheminType type in temp)
{
consd = consd.Append(type);
}
return consd;
}
}
return new ScheminPair(head, rest);
}
示例7: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
IScheminType first = args.Car;
IScheminType second = args.ElementAt(1);
return ScheminBool.GetValue(first.Equivalent(second));
}
示例8: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
ScheminPair pair = (ScheminPair) args.Car;
IScheminType val = args.ElementAt(1);
pair.Car = val;
return new ScheminPair();
}
示例9: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
ScheminString str = (ScheminString) args.Car;
ScheminInteger pos = (ScheminInteger) args.ElementAt(1);
int pos_int = (int) pos.IntegerValue();
ScheminChar chr = new ScheminChar(str.Value[pos_int]);
return chr;
}
示例10: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
ScheminBool condition = args.Car.BoolValue();
IScheminType then = args.ElementAt(1);
IScheminType otherwise = new ScheminPair();
if (args.Length > 2)
otherwise = args.ElementAt(2);
if (condition.Value)
{
return then;
}
else
{
return otherwise;
}
}
示例11: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
ScheminChar first = (ScheminChar) args.Car;
ScheminChar second = (ScheminChar) args.ElementAt(1);
if (first.Equivalent(second))
{
return ScheminBool.True;
}
return ScheminBool.False;
}
示例12: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
ScheminPair bindings = (ScheminPair) args.Car;
IScheminType expression = args.ElementAt(1);
ScheminPair letArgs = new ScheminPair();
ScheminPair argExps = new ScheminPair();
foreach (ScheminPair bindingPair in bindings)
{
letArgs = letArgs.Append(bindingPair.Car);
argExps = argExps.Append(bindingPair.ElementAt(1));
}
ScheminPair body = new ScheminPair(new ScheminPrimitive("begin"));
ScheminPair next = letArgs;
ScheminPair nextExp = argExps;
while (!next.Empty)
{
IScheminType symbol = next.Car;
IScheminType exp = nextExp.Car;
ScheminPair setExp = new ScheminPair(new ScheminPrimitive("set!"));
setExp = setExp.Append(symbol);
setExp = setExp.Append(exp);
body = body.Append(setExp);
next = next.ListCdr();
nextExp = nextExp.ListCdr();
}
body = body.Append(expression);
ScheminPair lambdaDef = new ScheminPair(letArgs);
foreach (IScheminType type in body)
{
lambdaDef = lambdaDef.Append(type);
}
Environment closure = env;
ScheminLambda lam = new ScheminLambda(lambdaDef, closure);
ScheminPair toEvaluate = new ScheminPair(lam);
foreach (IScheminType arg in argExps)
{
toEvaluate = toEvaluate.Append(new ScheminPair());
}
return toEvaluate;
}
示例13: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
ScheminChar first = (ScheminChar) args.Car;
ScheminChar second = (ScheminChar) args.ElementAt(1);
int result = first.Value.CompareTo(second.Value);
if (result > 0)
{
return ScheminBool.True;
}
return ScheminBool.False;
}
示例14: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
ScheminChar chr = (ScheminChar) args.Car;
ScheminPort writeTo = eval.CurrentOutputPort;
if (args.Length > 1)
{
writeTo = (ScheminPort) args.ElementAt(1);
}
writeTo.OutputStream.Write(chr.Value);
writeTo.OutputStream.Flush();
return new ScheminPair();
}
示例15: Execute
public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
{
IScheminNumeric first = (IScheminNumeric) args.Car;
IScheminNumeric second = (IScheminNumeric) args.ElementAt(1);
bool dec = false;
if ((first as ScheminDecimal) != null || (second as ScheminDecimal) != null)
dec = true;
if (!dec)
{
return ScheminBool.GetValue(first.IntegerValue() == second.IntegerValue());
}
return ScheminBool.GetValue(first.DecimalValue() == second.DecimalValue());
}