Ignore:
Timestamp:
10/30/10 19:47:15 (10 years ago)
Author:
Mario Domenech Goulart
Message:

demonstrations/awful/fortune: bug fix and improved `random-fortune' (excellent tips from Peter Bex)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • demonstrations/awful/fortune/fortune-server.scm

    r20676 r21138  
    66(db-credentials "fortunes.db")
    77
    8 (define random-fortune
    9   (let ((num-fortunes #f))
    10     (lambda ()
    11       (unless num-fortunes
    12         (set! num-fortunes (caar ($db "select count(id) from fortunes"))))
    13       (car ($db (conc "select sentence, author from fortunes where id="
    14                       (random num-fortunes)))))))
     8(define (random-fortune)
     9  (car ($db "select sentence, author from fortunes order by random() limit 1")))
    1510
    1611(define-page (main-page-path)
Note: See TracChangeset for help on using the changeset viewer.