• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# LSharp.Cons类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中LSharp.Cons的典型用法代码示例。如果您正苦于以下问题:C# Cons类的具体用法?C# Cons怎么用?C# Cons使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Cons类属于LSharp命名空间,在下文中一共展示了Cons类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GuiInspect

 /// <summary>
 /// (gui-inspect OBJECT)
 /// shows a Form with data on the item OBJECT
 /// </summary>
 /// <param name="args"></param>
 /// <param name="environment"></param>
 /// <returns></returns>
 public static object GuiInspect(Cons args, Environment environment)
 {
     // TODO : Fix
     //string sname = (string) Functions.SymbolName(new Cons(args.First()), environment);
     InspectorForm i = new InspectorForm(args.Car(), environment);
     i.ShowDialog();
     return args.First();
 }
开发者ID:mlnlover11,项目名称:MP.LSharp,代码行数:15,代码来源:Container.cs


示例2: And

		/// <summary>
		/// Returns true if all arguments are true, false otherwise.
		/// Performs short circuit evaluation on its arguments.
		/// </summary>
		/// <param name="args"></param>
		/// <param name="environment"></param>
		/// <returns></returns>
		public static Object And(Cons args, Environment environment) 
		{
			foreach (Object item in args) 
			{
				if (Conversions.ObjectToBoolean(Runtime.Eval(item,environment)) == false)
					return false;
			}
			return true;
		}
开发者ID:mlnlover11,项目名称:MP.LSharp,代码行数:16,代码来源:SpecialForms.cs


示例3: Eq

		public static bool Eq(Cons args)
		{
			object last = args.First();

			foreach (object item in (Cons)args.Rest()) 
			{
				if (!(object.ReferenceEquals(last,item)))
					return false;
				last = item;
			}
			return true;
		}
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:12,代码来源:Primitives.cs


示例4: Add

        /// <summary>
        /// (add object*)
        /// Returns the sum of all the specified objects.
        /// Each object must be a numerical type such as System.In32 or System.Double.
        /// </summary>
        /// <param name="args"></param>
        /// <param name="environment"></param>
        /// <returns></returns>
        public static Object Add(Cons args, Environment environment)
        {
            Type type = args.First().GetType();
            Double result = 0;
            foreach (Object item in args)
            {
                if (item is Double)
                    type = item.GetType();

                result += Convert.ToDouble(item);
            }
            return Convert.ChangeType(result,type);

        }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:22,代码来源:Functions.cs


示例5: EvalList

		/// <summary>
		/// Maps eval to a list of expressions
		/// </summary>
		/// <param name="list"></param>
		/// <param name="environment"></param>
		/// <returns></returns>
		public static Cons EvalList(object list, Environment environment) 
		{
			if (list == null)
				return null;

			object result = null;

			foreach (object item in (Cons)list ) 
			{
				result = new Cons(Eval(item,environment) ,result);
			}

			return  ((Cons)result).Reverse();

		}
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:21,代码来源:Runtime.cs


示例6: Expand

		public Object Expand(Cons arguments) 
		{
			// Create a new lexical environment
			Environment localEnvironment = new Environment(environment);

			Primitives.ProcessArguments(argumentNames, arguments, localEnvironment);

			object result = null;
			foreach (object o in body) 
			{
				result = Runtime.Eval(o,localEnvironment);
			}
			return result;

		}
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:15,代码来源:Macro.cs


示例7: MoveNext

		public bool MoveNext()
		{
			object o = list.Cdr();
			if (o==null)
				return false;
			
			if (o is Cons)
			{
				list = (Cons)o;
			} 
			else 
			{
				list = new Cons(o);
			}

			return true;
		}
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:17,代码来源:ListEnumerator.cs


示例8: Invoke

		/// <summary>
		/// Invokes the closure with arguments bound to the values specified in the 
		/// argument list
		/// </summary>
		/// <param name="arguments"></param>
		/// <returns></returns>
		public Object Invoke(Cons arguments) 
		{
			// Create a new lexical environment
			Environment localEnvironment = new Environment(environment);

			Primitives.ProcessArguments(argumentNames, arguments, localEnvironment);

			// Evaluate the body within this lexical environment
			object result = null;
            if (body != null)
            {
                foreach (object o in body)
                {
                    result = Runtime.Eval(o, localEnvironment);
                }
            }
			return result;

		}
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:25,代码来源:Closure.cs


示例9: Append

        // TODO

        public static Object Append(Cons args, Environment environment)
        {
            if (args.Rest() == null)
            {
                return args.First();
            }
            else
            {
                Cons result;

                if (args.First() == null)
                {
                    result = (Cons)Append((Cons)args.Rest(), environment);
                }
                else
                {
                    result = ((Cons)args.First()).CopyList();
                    ((Cons)result.Last()).Rplacd(Append((Cons)args.Rest(), environment));
                }
                return result;
            }
        }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:24,代码来源:Functions.cs


示例10: LogXor

        /// <summary>
        /// (^ expression*)
        /// Performs a bitwise logical exclusive or operation on its arguments
        /// </summary>
        /// <param name="args"></param>
        /// <param name="environment"></param>
        /// <returns></returns>
        public static Object LogXor(Cons args, Environment environment)
        {
            Type type = args.First().GetType();
            object result = args.First();
            foreach (Object item in (Cons)args.Rest())
            {

                // The integral types dont define operator overload methods
                // for performace reasons, so we have to implement this
                // operator on each integral type

                if (type == typeof(sbyte))
                    result = (sbyte)result ^ (sbyte)(item);
                else if (type == typeof(byte))
                    result = (byte)result ^ (byte)(item);
                else if (type == typeof(char))
                    result = (char)result ^ (char)(item);
                else if (type == typeof(short))
                    result = (short)result ^ (short)(item);
                else if (type == typeof(ushort))
                    result = (ushort)result ^ (ushort)(item);
                else if (type == typeof(int))
                    result = (int)result ^ (int)(item);
                else if (type == typeof(uint))
                    result = (uint)result ^ (uint)(item);
                else if (type == typeof(long))
                    result = (long)result ^ (long)(item);
                else if (type == typeof(ulong))
                    result = (ulong)result ^ (ulong)(item);
                else
                    return Runtime.Call("op_ExclusiveOr",args);

            }

            return Convert.ChangeType(result,type);
        }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:43,代码来源:Functions.cs


示例11: MacroExpand

        public static Object MacroExpand(Cons args, Environment environment)
        {
            Macro macro = (Macro)args.First();
            Cons arguments = (Cons)args.Rest();
            return macro.Expand(arguments);

        }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:7,代码来源:Functions.cs


示例12: List

 /// <summary>
 /// (list object*)
 /// Creates a new cons, an ordered list with each object as a member.
 /// </summary>
 /// <param name="args"></param>
 /// <param name="environment"></param>
 /// <returns></returns>
 public static Object List(Cons args, Environment environment)
 {
     return args;
 }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:11,代码来源:Functions.cs


示例13: Load

        /// <summary>
        /// (load filename) Loads and evaluates all statements in the given
        /// filename which must be a text file.
        /// </summary>
        /// <param name="args"></param>
        /// <param name="environment"></param>
        /// <returns></returns>
        public static Object Load(Cons args, Environment environment)
        {
            object filename = args.First();

            if (filename is string)
            {
                TextReader textReader;
                // 9/29/11: Enabled "short" filenames (adds .ls if needed)
                if (System.IO.File.Exists((string)filename))
                    textReader = new StreamReader((string)filename);
                else if (File.Exists(filename + ".ls")) // short file specified?
                    textReader = new StreamReader((string)filename + ".ls");
                else
                    throw new LSharpException("Cannot find file " + filename);
                string buffer = textReader.ReadToEnd();

                textReader.Close();

                // We want to evaluate the whole file, so there is an implicit do
                // which we now make explicit
                string expression = string.Format("(do {0}\n)",buffer);

                object input = Reader.Read(new StringReader(expression),ReadTable.DefaultReadTable());
                object output = Runtime.Eval(input, environment);

                return output;
            }
            throw new LSharpException(String.Format("Load: {0} is not a string", filename));
        }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:36,代码来源:Functions.cs


示例14: Eval

 /// <summary>
 /// Evaluates an LSharp expression in a given environment
 /// </summary>
 /// <param name="args"></param>
 /// <param name="environment"></param>
 /// <returns></returns>
 public static Object Eval(Cons args, Environment environment)
 {
     if (args.Length() == 1)
         return Runtime.Eval(args.First(), environment);
     else
         throw new LSharpException("Incorrect arguments given to eval");
 }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:13,代码来源:Functions.cs


示例15: LessThanEqual

        /// <summary>
        /// (<= object1 object2 object*) Less than or equal
        /// </summary>
        /// <param name="args"></param>
        /// <param name="environment"></param>
        /// <returns></returns>
        public static Object LessThanEqual(Cons args, Environment environment)
        {
            Double last = Convert.ToDouble(args.First());

            foreach (object item in (Cons)args.Rest())
            {
                Double current = Convert.ToDouble(item);
                if (!(last <= current))
                    return false;
                last = current;
            }
            return true;
        }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:19,代码来源:Functions.cs


示例16: Inspect

 /// <summary>
 /// (inspect object) Returns a description of the specified object, using reflection.
 /// Useful for debugging.
 /// </summary>
 /// <param name="args"></param>
 /// <param name="environment"></param>
 /// <returns></returns>
 public static Object Inspect(Cons args, Environment environment)
 {
     object o = args.First();
     string s = Inspector.Inspect(o);
     Console.WriteLine(s);
     return null;
 }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:14,代码来源:Functions.cs


示例17: Member

        /// <summary>
        /// (member item list)
        /// </summary>
        /// <param name="args"></param>
        /// <param name="environment"></param>
        /// <returns></returns>
        public static Object Member(Cons args, Environment environment)
        {
            object value = args.First();
            object list = args.Second();

            // TODO potential speed ups if list is IList or IDictionary

            foreach (object o in (IEnumerable)list)
            {
                if (Primitives.Eql(o,value))
                    return o;
            }

            return null;
        }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:21,代码来源:Functions.cs


示例18: 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();
        }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:28,代码来源:Functions.cs


示例19: Environment

 /// <summary>
 /// Returns an object representing the curent lexical environment
 /// </summary>
 /// <param name="args"></param>
 /// <param name="environment"></param>
 /// <returns></returns>
 public static Object Environment(Cons args, Environment environment)
 {
     return environment;
 }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:10,代码来源:Functions.cs


示例20: Gensym

 /// <summary>
 /// Generates a new symbol
 /// </summary>
 /// <param name="args"></param>
 /// <param name="environment"></param>
 /// <returns></returns>
 public static Object Gensym(Cons args, Environment environment)
 {
     return new Symbol("#:G" + Guid.NewGuid());
 }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:10,代码来源:Functions.cs



注:本文中的LSharp.Cons类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LWF.ColorTransform类代码示例发布时间:2022-05-26
下一篇:
C# LS2IL.FlatOperand类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap