[cad-linux-dev] Re: lisp and math

  • From: "cr88192" <cr88192@xxxxxxxxxxx>
  • To: <cad-linux-dev@xxxxxxxxxxxxx>
  • Date: Sun, 7 Dec 2003 10:37:49 -0800

----- Original Message -----
From: "Eric Wilhelm" <ewilhelm@xxxxxxxxxxxxx>
To: <cad-linux-dev@xxxxxxxxxxxxx>
Sent: Sunday, December 07, 2003 9:29 AM
Subject: [cad-linux-dev] lisp and math


> > The following was supposedly scribed by
> > cr88192
> > on Sunday 07 December 2003 02:04 am:
>
> >> I'm not too keen on lisp, since I have always found it to be
> >> counter-intuitive when it comes to mathematical operations.
>
> >I am not sure what is so "counter intuitive" about math in lisp though,
> >unless maybe you are referring to the fact that it does not like thinking
in
> >terms of mathmatical expressions (instead viewing it as function
> >application)?...
>
> How do you write "a + 2 * b - c * 4 / q" in lisp?  My experience with it
is
> very limited.  I had started to study autolisp and got as far as:
>
> apply( '1 - '4)
> 3
>
err, it is not infix...
(- (+ a (* 2 b)) (/ (* c 4) q))

it may seem a little weird, but it is managable...

> At that point I closed the book.  If there is a way to maintain the
typical
> order-of-operations (as you see them in algebra) in lisp, tell me what it
is
> and I'll get another book:)
>
you have to think very much differently, as:
it is not infix;
the concept of "order of operations" does not exist;
arithmatic operators are not language primitives;
..

thus, try to imagine math as how you would apply things to get the desired
result.
see if you can figure how the example above works.

another simpler one is the normal mx+b form of linear equations:
(+ (* m x) b)

all for now.


Other related posts: