Archive for January, 2008

@program = ::poem

January 23rd, 2008 | Category: Computers & 570x0FF, Personal (Español)

La poesía no es algo. La poesía lo es todo.

Música con idea es poesía. Música sin idea es simplemente música.

Hoy vi algo en un blog del PLT que me dejó anonadado. Un pequeño programita, tan bello y hermoso que tuve que leerlo varias veces para asimilar la experiencia estética. Lo pongo aquí, con crédito a matthias en este post de un blog perdido por ahí.

;; [LISTOF X] -> ( -> X u 'you-fell-off-the-end-off-the-list)
(define (generate-one-element-at-a-time a-list)
  ;; (-> X u 'you-fell-off-the-end-off-the-list)
  ;; this is the actual generator, producing one item from a-list at a time
  (define (generator)
     (call/cc control-state))
  ;; [CONTINUATION X] -> EMPTY
  ;; hand the next item from a-list to "return" (or an end-of-list marker)'
  (define (control-state return)
     (for-each
        (lambda (an-element-from-a-list)
           (set! return ;; fixed
             (call/cc
               (lambda (resume-here)
                 (set! control-state resume-here)
                 (return an-element-from-a-list)))))
        a-list)
     (return 'you-fell-off-the-end-off-the-list))
  ;; time to return the generator
  generator)
1 comment