列表構造函數
Sign in to saveAlso known as cons cell
In computer programming, '''' ( or ) is a fundamental function in most dialects of the Lisp programming language. constructs memory objects which hold two values or pointers to two values. These objects are referred to as (cons) cells, conses, non-atomic s-expressions ("NATSes"), or (cons) pairs. In Lisp jargon, the expression "to cons x onto y" means to construct a new object with (cons x y). The resulting pair has a left half, referred to as the (the first element, or contents of the address part of register), and a right half, referred to as the (the second element, or contents of the decre
Article · 中文
列表構造函數是用來構造列表的基本函數,在大多數 LISP 體系的計算機編程語言中,使用的函數名稱是cons。 cons構成了存放兩個變量與其指針的記憶體物件,這個物件被稱為單元、非原子的 S 表達式或對。LISP 編程中表達要把 x 加入 y 的語法:(cons <i>x</i> <i>y</i>),構造了一個新物件。產生的結果具備了左半部,稱為CAR(第一元素或暫存器位址的內容);以及右半部稱為CDR(其餘元素或遞減暫存器的內容)。 以上約略地和物件導向的構造器概念相關,即產生一個給定參數的新物件,而其與代數數據類型系統的構造函數,有更密切相關。“cons”和諸如“cons onto”的詞句,也是函數編程的通用術語。有時運算子有類似作用,特別是在列表處理的情況下,被讀作“CONS”。(例如 ML,Scala,F#和 Elm 編程的 ::運算符,或 Haskell 編程的 :運算符,都是向列表的開頭添加一個元素。)
Abstract from DBpedia / Wikipedia · CC BY-SA