Church numerals in early lisp implementations?

Liste des GroupesRevenir à cl lisp 
Sujet : Church numerals in early lisp implementations?
De : jshem (at) *nospam* yaxenu.org (Julieta Shem)
Groupes : comp.lang.lisp
Date : 11. May 2024, 14:23:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <875xvkmta1.fsf@yaxenu.org>
McCarthy wrote this in ``History of Lisp''.

Numbers were originally implemented in LISP I as lists of atoms, and
this proved too slow for all but the simplest computations.

Was that Church numerals?  Does anyone have examples of code from back
then?  I'm picturing things such as

  (defconstant zero nil)
  (defconstant one (cons nil zero))

  (defun zero? (x) (eq zero x))
  (defun add1 (x) (cons nil x))
  (defun sub1 (x) (cdr x))

  (defun add (x y)
    (cond ((zero? x) y)
          (t (add (sub1 x) (add1 y)))))

  CL-USER> (add one one)
  (NIL NIL)

The paragraph continued:

A reasonably efficient implementation of numbers as atoms in
S-expressions was made in LISP 1.5, but in all the early LISPs,
numerical computations were still 10 to 100 times slower than in
FORTRAN. Efficient numerical computation requires some form of typing
in the source language and a distinction between numbers treated by
themselves and as elements of S-expressions. Some recent versions of
LISP allow distinguishing types, but at the time, this seemed
incompatible with other features.

Date Sujet#  Auteur
11 May 24 * Church numerals in early lisp implementations?8Julieta Shem
11 May 24 +- Re: Church numerals in early lisp implementations?1Daniel Cerqueira
12 May 24 +* Re: Church numerals in early lisp implementations?3Alan Bawden
12 May 24 i`* Re: Church numerals in early lisp implementations?2Julieta Shem
18 May 24 i `- Re: Church numerals in early lisp implementations?1steve
16 May 24 `* Re: Church numerals in early lisp implementations?3steve
17 May 24  `* Re: Church numerals in early lisp implementations?2Lawrence D'Oliveiro
21 May 24   `- Re: Church numerals in early lisp implementations?1Stefan Monnier

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal