Arc Forumnew | comments | leaders | submitlogin
1 point by FredBrach 4648 days ago | link | parent

arc> (+ (eval (car '(x))) 2)

7

arc> (+ (car (car '(x))) 2)

Error: "Can't take car of x"

arc> (+ car( (eval (car '(x)))) 2)

Error: "Function call on inappropriate object 5 ()"

arc> car x

#<procedure:car>

arc> 5

What's the trick in this?



1 point by rocketnia 4648 days ago | link

  (+ (car (car '(x))) 2)
You're trying to access the first element of the first element of '(x). You can't access the first element of a symbol....

---

  (+ car( (eval (car '(x)))) 2)
You're trying to add three things together here:

- The car function

- ((eval (car '(x)))), which is a roundabout way of saying (x) here

- 2

---

  car x
Here you've entered two commands at once: One is "car", which evaluates to the car function, and the other is "x", which evaluates to 5. They're both printed to the console, but "arc>" is printed before each command is read, so the output looks quirky.

-----

2 points by Pauan 4643 days ago | link

"They're both printed to the console, but "arc>" is printed before each command is read, so the output looks quirky."

Not to be a bother, but Arc/Nu and Lite-Nu don't have this problem:

  > car x
  #<fn:car>
  5
I still highly recommend either of them to anybody who wishes for a simple, working, no-nonsense implementation of Arc 3.1.

-----

1 point by FredBrach 4648 days ago | link

oh well, the

car x

instead of

(car x)

was my mistake and why I've asked the question.

-----