本文整理汇总了C#中LSharp.Cons.Nth方法的典型用法代码示例。如果您正苦于以下问题:C# Cons.Nth方法的具体用法?C# Cons.Nth怎么用?C# Cons.Nth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LSharp.Cons
的用法示例。
在下文中一共展示了Cons.Nth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefMethod
/// <summary>
/// (defmethod name "arg1 arg2" "(expression1)" "(expression 2)" [...])
/// Created methods used for DefClass <br />
/// </summary>
/// <param name="args"></param>
/// <param name="e"></param>
/// <returns></returns>
public static object DefMethod(Cons args, Environment e)
{
string name;
string[] _args;
string commands = "";
name = args.First().ToString();
_args = args.Second().ToString().Split(new string[] {" "}, StringSplitOptions.None);;
for (int i = 2; i < args.Length(); i++)
commands += args.Nth(i) + " ";
commands = commands.Replace("\\", "\\\\");
commands = commands.Replace("\"", "\\\"");
//FIXME:
//code = code.Replace("\n", "\\n");
DefinedMethod ret = new DefinedMethod(commands, name, _args);
e.AssignLocal(Symbol.FromName(name), ret);
Console.WriteLine("Assigned '" + ret.Name + "' as a DefinedMethod");
return ret;
}
示例2: Nconc
/// <summary>
/// (nconc list*)
/// Returns a list whose elements are the elements of each list in
/// order. Destructively modifies all but the last list, such that
/// the cdr of the last cons in each list is the next list.
/// </summary>
/// <param name="args"></param>
/// <param name="environment"></param>
/// <returns></returns>
public static Object Nconc(Cons args, Environment environment)
{
// With no argument, returns null
if (args == null)
return null;
// With one argument, returns that argument
if (args.Length() < 2)
return args.First();
for (int i = 0; i < args.Length() -1; i ++)
{
Cons cons = (Cons)args.Nth(i);
cons = (Cons)cons.Last();
cons.Rplacd(args.Nth(i+1));
}
return args.First();
}
示例3: DefClass
/// <summary>
/// Creates a dynamic class
/// (defclass "classname" "inheritsfrom" [defmethod])
/// e.g. (defclass "class1" "Object" DefinedMethods*)
/// </summary>
/// <param name="args"></param>
/// <param name="environment"></param>
/// <returns></returns>
public static Object DefClass(Cons args, Environment environment)
{
string className = args.First().ToString();
string superClass = args.Second().ToString();
DefinedMethod[] methods = new DefinedMethod[args.Length() - 2];
for (int i = 2; i < args.Length(); i++)
{
try {
Symbol toFind = (Symbol) args.Nth(i);
object foundMethod = environment.GetValue(toFind);
methods[i - 2] = (DefinedMethod) foundMethod;
} catch (Exception e ) {
Console.WriteLine("DEFCLASS ERROR: " + e.Message + " " + e.StackTrace);
}
}
return ClassBuilder.CreateClass(className, superClass, "", methods);
}