Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Clearly 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?"))


Thank you! I haven't gotten to macros yet, but I can see they are very straight-forward!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: