Arc Forumnew | comments | leaders | submitlogin
2 points by thaddeus 5577 days ago | link | parent

How about this ?....

    (= x (list "One" "Two" "Three" "Four" "Five" "Six"))

    (def first (xl)
      (car xl)) 

    (def next (xl (o n 1))
      (withs (n (+ n 1)
              nxl (cut xl 1 n))
       (if (single nxl)
           (car nxl)
           nxl)))

    (def rest (xl)
      (cdr xl))
 
So ...

    arc> (first x)
    "One"
    arc> (next x)
    "Two"
    arc> (next x 3) ; the next three
    ("Two" "Three" "Four")
    arc> (rest x)
    ("Two" "Three" "Four" "Five" "Six")
    arc> (next:rest x)
    "Three"
    arc> (rest:next x 3) ; the rest of the next 3
    ("Three" "Four")
    arc> (last:next x 3) ; the last of the next 3
    "Four"
    arc> (first:next x 3) ; the first of the next 3
    "Two"
That's six or so functions replaced by 3, that look like english and make sense.