Berry's paradox and elegant Lisp programs

Berry's paradox and elegant LISP programs in Common Lisp
defun s-expressin-length (s)
  (length (write-to-string s)))

(defun complexity (s)
  (s-expressin-length (eval s)))

(complexity  '(car '(a b)))  

(defun is-elegant (s)
  (cond ((eq (s-expressin-length s) (complexity s))
         t)
        (t
         nil)))

(defun berry1 (lst)
  (cond ((null lst) nil)
        (t
         (cond ((and (is-elegant lst) 
                     (>= (complexity lst) (s-expressin-length #'berry1)))
                #'berry1)
               (t
                lst)))))

(defun berry (lst)
  (cond ((null lst) nil)
        (t
         (cond ((and (is-elegant (car lst)) 
                     (>= (complexity (car lst)) (s-expressin-length #'berry))))
                #'berry)
               (t
                (berry (cdr lst))))))

Ref: http://www.cs.umaine.edu/~chaitin/lisp.html

Tags: lisp

2010/06/28-11:24:31

Referências

Links para referências sobre Lisp

Livros

Artigos

Tags: Lisp, livros artigos

2010/06/26-10:17:10

Utilidades em Common Lisp

Breve descrição de utilidades em CL, instalação de packages, asdf, etc

As notas aqui descritas estão pensadas para SBCL - Steel Bank Common Lisp em Debian - GNU/Linux.

  1. Pedir a CL para não gritar (inlcuir a instrução no ficheiro ~/.sbclrc):
(setf *print-case* :downcase)
  1. A maneira mais simples de instalar e manter os packages em CL é usando o ASDF. Há dois manuais que valem a pena ser lidos:
  2. Exemplo de instalação usando o asdf: Para instalar a LTK - The Lisp Toolkit faz-se:
(require 'asdf-install)
(asdf-install:install 'ltk)
O asdf faz o download dos ficheiros e diz
Downloading 240780 bytes from http://www.peter-herth.de/ltk/ltk-0.91.tgz ...
e pergunta:
Install where?
1) System-wide install: 
   System in /usr/lib/sbcl/site-systems/
   Files in /usr/lib/sbcl/site/ 
2) Personal installation: 
   System in /home/tca/.sbcl/systems/
   Files in /home/tca/.sbcl/site/ 
respondo 2.

Tags: Common Lisp, CL, utilitities, asdf, sbcl

2010/06/25-14:36:29