Description:
Discussion about LISP.
|
|
|
Tail recursion & CL
|
| |
...
...
Racket:
(define (fac n [result 1])
(if (zero? n)
result
(fac (sub1 n) (* n result))))
|
|
ELSE in LOOP
|
| |
...
...
Wrong. In SBCL:
* (loop for i from 0 to 10
if (evenp i)
do (print i)
and if (= i 6)
do (print 'BINGO!!)
else do ()
else
do (print 'odd))
debugger invoked on a SB-INT:SIMPLE-PROGRAM-ERROR:
A compound form was expected, but NIL found.... more »
|
|
OT: How to calculate reputation scores?
|
| |
General question (not LISP related):
Many web sites have an article/message/user reputation based on the up or
down votes the article/message/user receives. How is a reputation score
calculated given only up and down votes? (The user is not presented with
a 1 to 5 scale for scoring something.)... more »
|
|
DOLIST as DO
|
| |
...
...
...
...
Racket:
(define-syntax-rule (dolist (var list result-form ...) expr ...)
(do ((listvar list (cdr listvar))
(var null))
((null? listvar) result-form ...)
(set! var (car listvar))
expr ...))
* (dolist (x '(a b c) 'ok) (display '--) (displayln x))... more »
|
|
What is the main advantage of macros over functions?
|
| |
...
...
Racket:
(define (count-lines-in-file file-name)
(with-input-from-file file-name
(lambda() (sequence-length (in-lines)))))
(for/sum ([file-name (find-files (curry regexp-match "\\.bak"))])
(count-lines-in-file file-name))
|
|
|