Arc Forumnew | comments | leaders | submitlogin
5 points by pgwoden 5815 days ago | link | parent

Would you care to share your macros?

I'm a noob with respect to both CL and Arc. For a long time I've wanted to familiarize myself with Lisp. My need for speed (driven by lots of number crunching) pushes me toward CL, but the fact that I'm only an occasional programmer makes CL's historical baggage painful (gotta remember that that the non-consing version of APPEND is not NAPPEND but NCONC, for example [and I don't want to touch of a flame war on this point, please {I've done so by accident in the past}: I can fully appreciate that if you program in CL every day, all of these little quirks cease to be difficulties and may even seem charming, just as do the inconsistencies of spelling in English]). I have high hopes for Arc, but I need more hand-holding (e.g., comprehensive texts) than it can provide right now, and I'm too squeamish to be programming at the frontier.

Macros making CL more Arc-like would be great.



8 points by almkglor 5815 days ago | link

> gotta remember that that the non-consing version of APPEND is not NAPPEND but NCONC, for example

Ah, consistency: yet another thing lacking in Arc. Take 'afn and 'acons, for example. Or 'acons and 'number. Or 'number and 'string. Or 'string and 'sym...

-----

7 points by listic 5815 days ago | link

I hope this will get sorted out in the next 100 years.

-----

2 points by kennytilton 5813 days ago | link

(w (v (rv))

w is my let but I still want a pair of parens.

(rv) generates a random algebraic variable. I am writing an algebra tutorial in CL and this code is from my DSL for the bit where I randomly generate algebra problems. (rv 2) would return a list of two variables one would reasonably find in a typical text. ie, x and y or m and n, but not x and a.

      (dsb (a b c) (shuffle (cons 1
                      (random-primes 2 2 10)))
dsb is destructuring-bind. I did not use random-primes very oftwn so no abbrev. yet. :)

        (dsb (x y z) (rpu 3 (r+ 5))
(rp n form) expands into a loop expression that repeats that many times collecting the result of the form shown. rpu is the version that ensures no duplicates (u for unique). (r+ n) generates a random number from 1 to n inclusive.

          (m+- (m+- (ms* a (ms^ v x))
(m+- x y) generates either a mathematical expression tree my software will use for tutoring, randomly x+y or x-y

ms* generates a product as does m, but is smart about it and tosses a factor of 1. likewise ms^ returns a power but not if the exponent is 1, then just the variable. mss^ is supersmart and converts x^0 to 1.

                 (ms* b (ms^ (xqv v) y)))
xqv is short for mx-equiv, which copies a mathematical expression to get an equivalent expression. (mx-copy creates a Lisp copy that is "EQ" the original at the application's level of abstraction.

            (ms* c (ms^ (xqv v) z))))))
Hmmm. This is a problem in factoring out the gcf of three terms ax^i + bx^j +cx^k.

Note that the above is as much about DSLs as it is about abbreviation, and I think if I wanted to delay shipping even further <g> I would break down and do a full parser of something like "ax^i + bx^j +cx^k,(abc)=[1 5],....".

-----