kimtg / arcadia

An implementation of the Arc programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

library.arc line 48 (def rev ...

cthammett opened this issue · comments

Good Evening Sir,

I downloaded arcadia today and took it for a test run. I noticed in library.arc line 48
(def rev (list)
(reduce (fn (a x) (cons x a)) nil list))

I tried out the above function and got the following result.
(rev '(1 2 3 4 5 6 7 8))
Wrong number of arguments: list

Thank you. Bug fixed.

(def rev (xs)
"Returns a list containing the elements of 'xs' back to front."
  ((rfn recur (xs acc)
    (if (no xs)
      acc
      (recur cdr.xs
             (cons car.xs acc)))) xs nil))

> (rev '())
nil
> (rev '(1))
(1)
> (rev '(1 2))
(2 1)
> (rev '(1 2 3))
(3 2 1)