Arc Forumnew | comments | leaders | submitlogin
Bug (fixed): (split seq 0) returns bad result
7 points by cchooper 5865 days ago | 1 comment
Example:

  (split '(1 2 3) 0)
  => ((1) (2 3))
which is exactly the same as

  (split '(1 2 3) 1)
  => ((1) (2 3))
So I fixed it to do this:

  (split '(1 2 3) 0)
  => (nil (1 2 3))
Hopefully that really is a bug and not intended behaviour. The problem with spec = code is that the bugs are the spec!


1 point by pg 5657 days ago | link

Ok, this is fixed.

    (def split (seq pos)
      (if (< pos 1)
          (list nil seq)
          (withs (mid (nthcdr (- pos 1) seq)
                  s2  (cdr mid))
            (wipe (cdr mid))
            (list seq s2))))

-----