CONS,LIST,NOlist cons structures
来源:互联网 发布:冰川网络vr游戏上线没 编辑:程序博客网 时间:2024/05/22 00:52
1.CONS
The CONS function creates cons cells. It takes two inputs and
returns a pointer to a new cons cell whose CAR points to the first input and whose CDR points to the second. Then term "CONS" is shorted
for CONStruct. If we try to explain CONS using parenthesis notation, we might say that CONS adds an element to the front of a list. For example, we can add the symbol A to the front of the list (B C D).
2.LIST
Creating a list from a bunch of elements is such a commom operation that Lisp has a built-in function to do just that. The LIST
function takes any numbers of inputs and makes a list of them.That is, it makes a new cons cell chain ending in NIL, with as many cells as there are inputs.
Notes: Let's look again at the difference between CONS and LIST. CONS makes a single cons cell. LIST makes a new cons cell chain list out of
however many inputs it receives.
3. Nonlist cons structures:
A proper list is a cons cell chain ending in NIL. The convention is omit this NIL when writing lists in parenthesis notation, so the structure below is written (A B C).[Later,you will know it can written as (A B C . NIL), the same as (A B C),but usually we do not write that way.]
There are other sorts of cons cell structures that are not proper lists, because their chains
do not end in NIL. How can the structure below be represented in parenthesis notation ?
When printing a list in parenthesis notation, Lisp starts by printing a left parenthesis
followed by all the elements, separated by space. Then, if the list ends in NIL,Lisp prints a
right parenthesis. If it does not end in NIL, before printing the right parenthesis Lisp prints
a space, a period, another space, and the atom that ends the chain. The list above, which
is called a dotted list rather than a proper list, is written like this:
(A B C . D)
So far, the only way we have to produce a cons cell structure that doesn't end in
NIL is to use CONS.
The result of the CONS of A and B called a dotted pair. It is written (A . B) in parenthesis notation, while in cons cell notation it looks like this:
A dotted pair is a single cons cell whose CDR is not NIL. The dotted list (A B . C) contains two cons cells, and is constructed this way:
In cons cell notation, (A B . C)looks like this:
Although LIST is often a more convenient tool than CONS for constructing lists,
the LIST function can only build proper list, since it always constructs a chain ending
in NIL. For dotted lists CONS must be used.
- CONS,LIST,NOlist cons structures
- 9. cons
- 总结cons
- 总结cons
- 总结cons
- 总结cons
- 总结cons
- C++ cons
- CONS形式化 (一般化)
- Speech Codecs: Pros & Cons
- gc野马跑过CONS
- Audio Codecs: Pros & Cons
- Video Codecs: Pros & Cons
- Image Codecs: Pros & Cons
- Rococo(cons野马)
- cons的作用
- 理解lisp中的cons
- Erlang中的cons operator |
- 在LR中如何忽略Socket接收数据的验证
- IUnknown中的QueryInterface的实现剖析(2)
- poj 1797 Dijkstra 变形
- struts2教程:1、介绍struts2及struts2开发环境的搭建
- POJ 3093 Margaritas on the River Walk
- CONS,LIST,NOlist cons structures
- 在 Linux里设置环境变量的方法(export PATH)
- 关于VC的main dialog和sub dialog互相通讯的实现
- java 反射机制概述
- C++数组算法小练习
- 我们为什么解决不了大问题?
- visual stdio 2010中$(IncludePath)的修改
- 《锋利的jQuery》读书笔记 第6章 jQuery与Ajax的应用
- Winform TextBox中只能输入数字的几种常用方法(C#)