Arc Forumnew | comments | leaders | submitlogin
1 point by joseph 6128 days ago | link | parent

How about a default start of 0?

  (def range (default (o end) (o step 1))
    (with (st (if end default 0)
           en (if end end default))
      (if (is step 0) (= step 1) (zap abs step))
      (let (stp-fn test) (if (> st en) `(,- ,<) `(,+ ,>))
         ((afn (i accum)
            (if (test i en) (rev accum)
                            (self (stp-fn i step) (push i accum))))
          st nil))))