Arc Forumnew | comments | leaders | submitlogin
3 points by akkartik 3325 days ago | link | parent

I think you can go pretty far treating Arc as a dialect of Scheme. Arc is basically like Scheme + Lisp-style macros. So until you start dealing with macros things should correspond pretty closely. The names change, as you already noticed, so () is nil and not is no[1]. A second point of difference is that Arc tends to have fewer parens, so for example this Scheme code:

  (let ((x 3) (y 4))
    ...)
turns into this in Arc:

  (with (x 3 y 4)
    ...)
Kinnard is right that the atom primitive is pretty much what you want. The exact transliteration of your definition would be:

  (def atom? (x)
    (and (no x) (no (alist x))))
Or, with more syntactic sugar:

  (def atom? (x)
    (and no.x (~alist x)))
[1] Hmm, somebody should write a "Arc for Scheme programmers" primer, just with a quick cheatsheet of common names and their equivalents. Any takers?


3 points by rocketnia 3325 days ago | link

That version of `atom?` always returns nil, so I'll offer a correction.

Here's a very direct transliteration:

  (= atom?
    (fn (x)
      (and (no (acons x)) (no (no x)))))
The equivalents for `not` and `null?` in Arc are both `no`, because the empty list is the only falsy value. Scheme uses dedicated values for true and false, `t` and `#f`, but Arc uses the symbols `t` and `nil`, and `nil` doubles as the empty list.

Here's a version that uses the utilities Arc provides out of the box:

  (= atom? ~alist)

-----

3 points by Styx 3325 days ago | link

Also, from an outside perspective, I think your idea for a "Arc for Scheme" primer would be a great idea. The Little Schemer is widely recommended, so it could potentially result in more people finding their way into Arc.

-----

2 points by Styx 3325 days ago | link

Hey thanks Akkartik, I'll give it a go.

-----