4 ms·
Great, I think it has a very clean, elegant syntax, which is very nice; I don't write much lisp but it seems that every time I look at a piece of code in lisp,
by plainOldText 13y ago
Great, I think it has a very clean, elegant syntax, which is very nice; I don't write much lisp but it seems that every time I look at a piece of code in lisp, I tend to appreciate even more how minimalist lisp is.
- codygman 13y ago#lang racket (define (naive-for start end my-body) (let ([operator (if (< start end) + -)]) (my-body) (cond [(not (eq? start end)) (naive-for (operator start 1) end my-body)]))) (naive-for 1 -2 (lambda () (displayln "For loop? Who needs those!")))
- yoklov 13y agoClearly this calls for a macro (define-syntax naive-for (syntax-rules () [(naive-for start end body ...) (let ([op (if (< start end) + -)]) (let loop ([s start] [e end]) (begin body ...) (cond [(not (eq? s e)) (loop (op s 1) e)])))])) (naive-for 1 -2 (displayln "Lambda? What lambda?"))
- codygman 13y agoThank you! I haven't gotten to macros yet, but I can see they are very straight-forward!