[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Legacy caar to cddddr

On Sat, Oct 22, 2011 at 9:03 AM, Aubrey Jaffer <agj@x> wrote:
> But those aren't how JACAL uses pairs.  It would be something like:
>  (define poly:var car)
>  (define bunch:first car)
>  (define poly:coefficients cdr)
>  (define poly:constant-term cadr)
>  (define poly:linear-coefficient caddr)
>  (define poly:non-constant-coefficients cddr)
> Notice that we are already into the third level with CADDR.  These
> accessor names do not cover all the ways in C*R they can be used.
> CAR is also the constant in a coefficient list, or the first
> coefficient in the CDR of a coefficient list...

OK, so your polynomial is a variable plus an
ordered list of coefficients.

> CONS can be used to attach a variable to a list of coefficients, to
> raise the variable exponent by 1 on all terms in a coefficient list,
> to add an element to the front of a "bunch" (which serve as
> mathematical vectors)...  Multiple versions of MAP would be needed.

I never said you shouldn't use lists, and it sounds
like they're doing a good job here.

> I don't find your name in any JACAL correspondence or ChangeLog.  Have
> you actually looked at JACAL source?  Its unfair to declare my code
> illegible without having made a serious examination of it.

No, I would probably find the JACAL source unintelligible.
However, if you just used two accessors:

  (define make-poly cons)
  (define poly:var car)
  (define poly:coefficients cdr)

then the code would make a lot more sense.  The uses of caddr
which you referred to become:

  (cadr (poly:coefficients x))

or more likely

  (cadr coeffs)

if the coefficients are already bound in the same scope.  You
no longer have any accessors beyond depth two.  Although
in this case using `second' instead of `cadr' is probably clearer.
And `caddr' is just `third' anyway, which I acknowledged was


Scheme-reports mailing list