I wonder whether '(1 . 2)
and '(1 2)
mean the same data (equal to each other) in Scheme or not? I think they are the same thing, is this correct?
Pairs are used to combine two Scheme objects into one compound object. Hence the name: A pair stores a pair of objects. The data type pair is extremely important in Scheme, just like in any other Lisp dialect.
In contrast to Scheme's unstructured data types, such as symbols and numbers, lists are structures that contain other values as elements. A list is an ordered collection of values. In Scheme, lists can be heterogeneous, in that they may contain different kinds of values.
Scheme Lists. The first argument of cons may be any Scheme object, and the second is a list; the value of (cons x xs) is a new list which contains x followed by the elements of xs . (Scheme's way of printing lists uses a shorthand which hides the final () .
No, they are not the same.
'(1 . 2)
means (cons 1 2)
whereas
'(1 2)
means (cons 1 (cons 2 nil))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With