本文整理汇总了C#中ISeq.rest方法的典型用法代码示例。如果您正苦于以下问题:C# ISeq.rest方法的具体用法?C# ISeq.rest怎么用?C# ISeq.rest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISeq
的用法示例。
在下文中一共展示了ISeq.rest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyISeqRestMaintainsMeta
public void VerifyISeqRestMaintainsMeta(ISeq s)
{
IPersistentMap meta = ((IMeta)s).meta();
for (; s.rest() != null; s = s.rest())
Expect(((IMeta)s.rest()).meta(), EqualTo(meta));
}
示例2: create
/// <summary>
/// Create a <see cref="PersistentHashSet">PersistentHashSet</see> initialized from an <see cref="ISeq">ISeq</see> of items.
/// </summary>
/// <param name="items">An <see cref="ISeq">ISeq</see> of items</param>
/// <returns>A <see cref="PersistentHashSet">PersistentHashSet</see>.</returns>
public static PersistentHashSet create(ISeq items)
{
PersistentHashSet ret = EMPTY;
for (; items != null; items = items.rest())
ret = (PersistentHashSet)ret.cons(items.first());
return ret;
}
示例3: VerifyISeqContents
public void VerifyISeqContents(ISeq s, IList<object> values)
{
int i=0;
for (; s != null; s = s.rest(), i++)
Expect(s.first(), EqualTo(values[i]));
Expect(i, EqualTo(values.Count));
}
示例4: construct
/// <summary>
/// Create a struct from a struct definition and values (in order) for the fixed keys.
/// </summary>
/// <param name="def">A struct definition</param>
/// <param name="valseq">A sequence of values for the fixed keys (in definition order).</param>
/// <returns>A <see cref="PersistentStructMap">PersistentStructMap</see>.</returns>
public static PersistentStructMap construct(Def def, ISeq valseq)
{
object[] vals = new object[def.Keyslots.count()];
IPersistentMap ext = PersistentHashMap.EMPTY;
for (int i = 0; i < vals.Length && valseq != null; valseq = valseq.rest(), i++)
{
vals[i] = valseq.first();
}
if (valseq != null)
throw new ArgumentException("Too many arguments to struct constructor");
return new PersistentStructMap(null, def, vals, ext);
}
示例5: sqExpandList
private static ISeq sqExpandList(ISeq seq)
{
IPersistentVector ret = PersistentVector.EMPTY;
for (; seq != null; seq = seq.rest())
{
Object item = seq.first();
//if (item is Unquote)
// ret = ret.cons(RT.list(LIST, ((Unquote)item).Obj));
// REV 1184
if (isUnquote(item))
ret = ret.cons(RT.list(LIST, RT.second(item)));
else if (isUnquoteSplicing(item))
ret = ret.cons(RT.second(item));
else
ret = ret.cons(RT.list(LIST, syntaxQuote(item)));
}
return ret.seq();
}
示例6: VerifyISeqRestTypes
public void VerifyISeqRestTypes(ISeq s, Type type)
{
for ( ; s.rest() != null; s = s.rest())
Expect(s.rest(), InstanceOfType(type));
}
示例7: create
/// <summary>
/// Create a <see cref="PersistentTreeMap">PersistentTreeMap</see> from a comparison method
/// an <see cref="ISeq">ISeq</see> of alternating keys and values.
/// </summary>
/// <param name="comp">A comparison method.</param>
/// <param name="items">The <see cref="ISeq">ISeq</see> of alternating keys and values.</param>
/// <returns>A <see cref="PersistentTreeMap">PersistentTreeMap</see>.</returns>
public static PersistentTreeMap create(IComparer comp, ISeq items)
{
IPersistentMap ret = new PersistentTreeMap(comp);
for (; items != null; items = items.rest().rest())
{
if (items.rest() == null)
throw new ArgumentException(string.Format("No value supplied for key: %s", items.first()));
ret = ret.assoc(items.first(), items.rest().first());
}
return (PersistentTreeMap)ret;
}
示例8: ApplyToHelper
public static object ApplyToHelper(IFn ifn, ISeq arglist)
{
switch (RT.BoundedLength(arglist, 20))
{
case 0:
return ifn.invoke();
case 1:
return ifn.invoke(arglist.first());
case 2:
return ifn.invoke(arglist.first()
, (arglist = arglist.rest()).first()
);
case 3:
return ifn.invoke(arglist.first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
);
case 4:
return ifn.invoke(arglist.first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
);
case 5:
return ifn.invoke(arglist.first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
);
case 6:
return ifn.invoke(arglist.first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
);
case 7:
return ifn.invoke(arglist.first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
);
case 8:
return ifn.invoke(arglist.first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
);
case 9:
return ifn.invoke(arglist.first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
);
case 10:
return ifn.invoke(arglist.first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
);
case 11:
return ifn.invoke(arglist.first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
);
case 12:
return ifn.invoke(arglist.first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
, (arglist = arglist.rest()).first()
//.........这里部分代码省略.........
示例9: GenerateRecurExpr
// Don't do what I did the first time: Evaluate the forms/assignments sequentially.
// Need to evaluate all the forms, then assign them.
private static Expression GenerateRecurExpr(ISeq form)
{
IPersistentVector loopLocals = (IPersistentVector) LOOP_LOCALS.deref();
if ( IN_TAIL_POSITION.deref() == null || loopLocals == null )
throw new InvalidOperationException("Can only recur from tail position");
if (IN_CATCH_FINALLY.deref() != null)
throw new InvalidOperationException("Cannot recur from catch/finally.");
IPersistentVector args = PersistentVector.EMPTY;
for ( ISeq s = form.rest(); s != null; s = s.rest() )
args = args.cons(Generate(s.first()));
if ( args.count() != loopLocals.count())
throw new ArgumentException(string.Format("Mismatched argument count to recur, expected: {0} args, got {1}",loopLocals.count(),args.count()));
LabelTarget loopLabel = (LabelTarget)LOOP_LABEL.deref();
if (loopLabel == null)
throw new InvalidOperationException("Recur not in proper context.");
int argCount = args.count();
List<ParameterExpression> tempVars = new List<ParameterExpression>(argCount);
List<Expression> tempAssigns = new List<Expression>(2 * argCount+1);
List<Expression> finalAssigns = new List<Expression>(argCount);
// Evaluate all the init forms into local variables.
for ( int i=0; i<loopLocals.count(); i++ )
{
LocalBinding b = (LocalBinding)loopLocals.nth(i);
ParameterExpression tempVar = Expression.Parameter(b.ParamExpression.Type, "local" + i); //asdf-tag
Expression arg = (Expression) args.nth(i);
tempVars.Add(tempVar);
if ( tempVar.Type == typeof(Object) )
tempAssigns.Add(Expression.Assign(tempVar,MaybeBox(arg)));
else
tempAssigns.Add(Expression.Assign(tempVar, Expression.Convert(arg, tempVar.Type))); //asdf-tag
finalAssigns.Add(Expression.Assign(b.ParamExpression, tempVar)); //asdf-tag
}
List<Expression> exprs = tempAssigns;
exprs.AddRange(finalAssigns);
exprs.Add(Expression.Goto(loopLabel));
// need to do this to get a return value in the type inferencing -- else can't use this in a then or else clause.
exprs.Add(Expression.Constant(null));
return Expression.Block(tempVars,exprs);
}
示例10: applyTo
public override object applyTo(ISeq args)
{
if (RT.BoundedLength(args, _reqArity) <= _reqArity)
return base.applyTo(args);
switch (_reqArity)
{
case 0:
return doInvoke(args);
case 1:
return doInvoke(args.first()
, args.rest());
case 2:
return doInvoke(args.first()
, (args = args.rest()).first()
, args.rest());
case 3:
return doInvoke(args.first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, args.rest());
case 4:
return doInvoke(args.first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, args.rest());
case 5:
return doInvoke(args.first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, args.rest());
case 6:
return doInvoke(args.first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, args.rest());
case 7:
return doInvoke(args.first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, args.rest());
case 8:
return doInvoke(args.first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, args.rest());
case 9:
return doInvoke(args.first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, args.rest());
case 10:
return doInvoke(args.first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, args.rest());
case 11:
return doInvoke(args.first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, (args = args.rest()).first()
, args.rest());
case 12:
return doInvoke(args.first()
, (args = args.rest()).first()
//.........这里部分代码省略.........
示例11: FindKey
// do we need this?
protected static ISeq FindKey(object key, ISeq args)
{
while (args != null)
{
if (key == args.first())
return args.rest();
args = RT.rest(args);
args = RT.rest(args);
}
return null;
}
示例12: create
/// <summary>
/// Create a <see cref="PersistentHashMap">PersistentHashMap</see> initialized from
/// an <see cref="ISeq">ISeq</see> of alternating keys and values.
/// </summary>
/// <param name="items">An <see cref="ISeq">ISeq</see> of alternating keys and values.</param>
/// <returns>A <see cref="PersistentHashMap">PersistentHashMap</see>.</returns>
public static PersistentHashMap create(ISeq items)
{
IPersistentMap ret = EMPTY;
for ( ; items != null; items = items.rest().rest() )
{
if ( items.rest() == null )
throw new ArgumentException(String.Format("No value supplied for key: {0}", items.first()));
ret = ret.assoc(items.first(), items.rest().first() );
}
return (PersistentHashMap)ret;
}
示例13: GenerateInvoke
private static Expression GenerateInvoke(ISeq form)
{
Expression fn = Generate(form.first());
fn = Expression.Convert(fn,typeof(IFn));
ISeq s = RT.seq(form.rest());
int n = s == null ? 0 : s.count();
Expression[] args = new Expression[n];
for (int i = 0; s != null; s = s.rest(), i++)
args[i] = MaybeBox(Generate(s.first()));
Type returnType = ComputeInvocationReturnType(form.first(), form);
Expression call = GenerateInvocation(returnType, fn, args);
return call;
}
示例14: ComputeNames
internal void ComputeNames(ISeq form)
{
MethodDef enclosingMethod = (MethodDef)METHODS.deref();
string baseName = enclosingMethod != null
? (enclosingMethod.Fn.Name + "$")
: (munge(CurrentNamespace.Name.Name) + "$");
if (form.rest().first() is Symbol)
_thisName = ((Symbol)form.rest().first()).Name;
_simpleName = (_thisName == null ? "fn" : munge(_thisName).Replace(".","_DOT_"));
_name = baseName + _simpleName;
_internalName = _name.Replace('.','/');
// fn.fntype = Type.getObjectType(fn.internalName) -- JAVA
}
示例15: MacroexpandSeq1
private static object MacroexpandSeq1(ISeq form)
{
object op = RT.first(form);
if (Compiler.isSpecial(op))
return form;
// macro expansion
Var v = IsMacro(op);
if (v != null)
{
try
{
Var.pushThreadBindings(RT.map(RT.MACRO_META, RT.meta(form)));
return v.applyTo(form.rest());
}
finally
{
Var.popThreadBindings();
}
}
else
{
if (op is Symbol)
{
Symbol sym = (Symbol)op;
string sname = sym.Name;
// (.substring s 2 5) => (. x substring 2 5)
if (sname[0] == '.')
{
if (form.count() < 2)
throw new ArgumentException("Malformed member expression, expecting (.member target ...)");
Symbol method = Symbol.intern(sname.Substring(1));
// TODO: Figure out why the following change made in Java Rev 1158 breaks ants.clj
// Note on that revision: force instance member interpretation of (.method ClassName), e.g. (.getMethods String) works
// However, when I do this, it makes ants.clj choke on: (def white-brush (new SolidBrush (.White Color)))
//object target = Second(form);
//if (MaybeType(target, false) != null)
// target = RT.list(Compiler.IDENTITY, target);
//return RT.listStar(Compiler.DOT, target, method, form.rest().rest());
return RT.listStar(Compiler.DOT, RT.second(form), method, form.rest().rest());
}
else if (NamesStaticMember(sym))
{
Symbol target = Symbol.intern(sym.Namespace);
Type t = MaybeType(target, false);
if (t != null)
{
Symbol method = Symbol.intern(sym.Name);
return RT.listStar(Compiler.DOT, target, method, form.rest());
}
}
else
{
// (x.substring 2 5) => (. s substring 2 5)
int index = sname.LastIndexOf('.');
if (index == sname.Length - 1)
return RT.listStar(Compiler.NEW, Symbol.intern(sname.Substring(0, index)), form.rest());
}
}
}
return form;
}