As raízes de Lisp

John McCarthy em 1960 publicou um artigo espantoso no qual fez para a programação o mesmo que Euclides fez para a geometria...

John McCarthy em 1960 publicou um artigo espantoso no qual fez para a programação o mesmo que Euclides fez para a geometria ("Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I'', Communications of the ACM 3:4, April 1960, pp. 184-195). Mostrou como construir, dado uma mão cheia de operadores simples e uma notação para funções, uma linguagem de programação completa. Denominou-a de Lisp, abreviatura de "List Processing'', porque a ideia chave era usar uma estrutura simples de dados chamada lista para o código e para os dados propriamente ditos.

Tenho andado a traduzir um artigo de Paul Graham que explica muito bem o que MacCarthy descobriu. Talvez acabe a tradução esta noite.

A motivação de Paul Graham foi:

"I wrote this article to help myself understand exactly what McCarthy discovered. You don't need to know this stuff to program in Lisp, but it should be helpful to anyone who wants to understand the essence of Lisp— both in the sense of its origins and its semantic core. The fact that it has such a core is one of Lisp's distinguishing features, and the reason why, unlike other languages, Lisp has dialects."

É a mesma que me levou a traduzir o artigo.

Deixo aqui um exemplo do método do ponto fixo em Emacs Lisp, um dos dialectos de Lisp.

(defun fixedpoint (f x &optional tol)
 "Find the fixed point of f, i. e., f(p)=p."
 (when (null tol)
   (setq tol 0.00001))
 (let*
     ((oldx x)
      (x (funcall f x)))
   (if (< (abs (- x oldx)) tol) x (fixedpoint 'f x tol))))


(defun f (x) (cos x))

(fixedpoint 'f 1 .001) ; 0.7387603198742113
Palavras chave/keywords: Emacs, Lisp, John McCarthy, tradução

Criado/Created: NaN

Última actualização/Last updated: 10-10-2022 [14:47]


Voltar à página inicial.


GNU/Emacs Creative Commons License

(c) Tiago Charters de Azevedo