Re: What about these?




John Thingstad ha escrito:

On Fri, 29 Dec 2006 13:11:45 +0100, Juan R.
<juanrgonzaleza@xxxxxxxxxxxxxxxxxxxx> wrote:


(<CAR><.><CDR>) the '.' or binary separator is infix, no prefix.

The same for list notation
(<token><delimiter><token><delimiter><token>) with <delimiter> being
the early ' ,' or the modern ' ' but both in infix position. That is,
(token token token).

'(one . two) means (cons 'one 'two)
(car '(one . two)) 'one
(cdr '(one . two)) 'two

This is a tuple not a list since both cons cells contain a atom.

Syntactically the dot is there to distinguish it from
'(one two) which means (cons 'one (cons 'two nil))

(car '(one two)) 'one
(cdr '(one two)) ('two)
(cadr '(one two)) 'two

It is thus not a infix operator.
Rather it is a reader macro to simplify expressing binary relations
as used by assoc.

(setq values '((x . 100) (y . 200) (z . 50))) => ((X . 100) (Y . 200) (Z
. 50))

(assoc 'y values) => (Y . 200)

I do not understand this reply. Are you really mixing S-expr syntatic
operators with LISP expr functional operators?

I think i do not said that (A . B) was a list, said I?

(A B C D) <==> (A . (B . (C . (D. NIL))))

The List notation is just a convenience was introduced in early LISP
because working directly with the dot notation was too complex in most
of cases. Also the dot notation contains more, many more, parentheses
:]

Both dot operator and delimiter operator (just space in modern lisps
but ', space' in original LISP) _are_ *infix operators* of the
underlying _S-expr syntax_ because both are in the middle of arguments.
Of course, spaces and dots are not operators of the LISP expr, which
only can be prefix. But is not i was saying. There even an Unicode
operator for this i am saying called "invisible comma".

The LISP (A B) old LISP (A, B) is <(> <A> <invisible comma> <B> <)>

Moreover, one would notice that the current LISP syntax for lists (A B
C) using just space can be ambiguous:

(p "there are two")

is a list of two elements, not four! In original LISP syntax one can
avoid _that_ syntatic ambiguity:

(p, "there are two")

Interestingly, one cannot tokenize the modern LISP notation using a
simple split(' '). One can in CanonML

.



Relevant Pages

  • Re: Why is lisp so weird?
    ... I've gotten a book on lisp, and I must say lisp is the ugliest ... > looking language syntax wise. ... here you have two lists, ... These things are all just lists, but the notation varies. ...
    (comp.lang.lisp)
  • Re: | (such that) and the same | (divides)
    ... >> else in math AFAIK, and it's right there on the keyboard. ... > It's used in a linear notation for hypergeometric functions, ... It's also used when dealing with lists of lists in math. ... news (dot) post tbrauch com ...
    (sci.math)
  • Re: flatten
    ... What's the fastest flatten of n x n list one can do in Lisp? ... Unless I've confused myself with the notation, the fastest one can traverse a singly-linked list of length n in *any* language is O, ... so any operation that involves traversing a list of lists is going to have Oas a lower bound, ...
    (comp.lang.lisp)
  • Re: Cons cell archaic!?
    ... How would the implementation of a Lisp without a using cons look like? ... the irregularity in its often cited regular syntax. ... Lisp at core is based on functional programing on lists. ...
    (comp.lang.lisp)
  • Re: Why is LISP syntax superior?
    ... mathematical notation, when it is really related to the own LISP ... have some kind of prefix-based syntax for handling declarations, ... once you have a language defined entirely by this prefix ...
    (comp.lang.lisp)