Will.Whim

A weblog by Will Fitzgerald

Category Archives: arc

More better spec for Arc

A DESCRIBE form now creates a procedure, which, when run, returns a set of results, which can be printed. Also, errors in test forms are caught.

See spec.arc

Can an HTML format be far behind?

(= test-basics
   (describe "Basic ARC list functions"
     (prolog
      (= li '(a b c))
      (= pair '(a . b)))
     (it "CAR should return the first item in a list"
       (is (car li) 'a))
     (it "CAR should return nil for an empty list"
       (is (car '()) nil))
     (it "CADR should return the second item of a list"
       (is (cadr li) 'b))
     (it "CADR should return NIL for an empty list"
       (is (cadr '()) nil))
     (it "CADR should return NIL for the 2nd item of a one item list"
       (is (cadr '(a)) nil))
     (it "CDR should return the rest of a list"
       (iso (cdr li) '(b c)))
     (it "CDR should returns '() for an empty list"
       (is (cdr '()) '()))
     (it "CDR should return the rest of a dotted pair"
       (is (cdr pair) 'b))
     (it "CDDR should return the rest of the rest of a list"
       (iso (cddr li) '(c)))
     (it "CDDR should return '() for an empty list"
       (is (cddr '()) '()))
     (it "CDDR should returns '() for a one item list"
       (is (cddr '(a)) '()))))

(print-results (test-basics) t)

;; Basic ARC list functions
;; CAR should return the first item in a list: t	(is (car li) (quote a))
;; CAR should return nil for an empty list: t	(is (car (quote nil)) nil)
;; CADR should return the second item of a list: t	(is (cadr li) (quote b))
;; CADR should return NIL for an empty list: t	(is (cadr (quote nil)) nil)
;; CADR should return NIL for the 2nd item of a one item list: t	(is (cadr (quote (a))) nil)
;; CDR should return the rest of a list: t	(iso (cdr li) (quote (b c)))
;; CDR should returns '() for an empty list: t	(is (cdr (quote nil)) (quote nil))
;; CDR should return the rest of a dotted pair: t	(is (cdr pair) (quote b))
;; CDDR should return the rest of the rest of a list: t	(iso (cddr li) (quote (c)))
;; CDDR should return '() for an empty list: t	(is (cddr (quote nil)) (quote nil))
;; CDDR should returns '() for a one item list: t	(is (cddr (quote (a))) (quote nil))
;; Tests: 11; Good: 11; Errors: 0; Pct: 100.0

It’s not perfect. But parts of it are excellent.

Advertisements

First experiment with Arc

I decided to try to write a simple but useful program in Arc, the programming language recently released by Paul Graham.

One thing I’ve liked about using Ruby is a testing framework called Rspec, in which you describe the behavior of your program in a kind of narrative form. So I decided to try and write a similar system for Arc.
Read more of this post

arc is here

arc> (map [+ _ 1] '(1 2 3))
(2 3 4)
arc> `(arc is ,@'(finally) here)
(arc is finally here)

arclanguage.org

I should have mentioned: via lemonodor.