- #1
mt8891
- 17
- 0
i'm really going nuts here. I don't know much about lisp. however, I do know a thing or two about C. Knowing a lot about C and trying to learn lisp is like (to me) trying to learn italian when completely wasted out of your mind whilst taking a trip to italy but speaking fluent english anyway. Anyway, I'm attempting to write a couple of elementary linear algebra equations into lisp.
example 1:
i have my crossproduct function as:
(defun crossprod (v1 v2 v3 u1 u2 u3)
(list
(- (* v2 u3) (* v3 u2))
(*-1 (- (*v1 u3) (* v3 u1)))
(- (*v1 u2) (* v2 u1))))
and I mean it works fine and I've got no issues with it...if you like it go ahead and use it but there is something that tells me wait. I want to be able to use VECTORS as lists ie the vector 1,-5,8 or 6,-6,6 but of course in lisp it would be some sort of form like (1 -5 8) or (6 -6 6) and I can't seem to get how to say something like
(split vector1 vector2)
where I can use the i j k's of each vector in some other function or whatever. etc.anyway, I am more curious about a normalize-ing deal that I can use vector inputs (as lists). at the base of it all how can I smash up lists and use them in sequence so I dont, for instance, have to say: (first vector1) (second vector2) (third vector3) etc...
I'll admit I could mix and match c and this stuff only because I know loops in C(but I don't mean really I mean conceptually in my noggin, what, you never thought it'd be easy searing for those red mushrooms from mario in grandtheft auto?). I don't know loops about lisp too well. anyone who as any algorithms..let me know. thanks-mt
example 1:
i have my crossproduct function as:
(defun crossprod (v1 v2 v3 u1 u2 u3)
(list
(- (* v2 u3) (* v3 u2))
(*-1 (- (*v1 u3) (* v3 u1)))
(- (*v1 u2) (* v2 u1))))
and I mean it works fine and I've got no issues with it...if you like it go ahead and use it but there is something that tells me wait. I want to be able to use VECTORS as lists ie the vector 1,-5,8 or 6,-6,6 but of course in lisp it would be some sort of form like (1 -5 8) or (6 -6 6) and I can't seem to get how to say something like
(split vector1 vector2)
where I can use the i j k's of each vector in some other function or whatever. etc.anyway, I am more curious about a normalize-ing deal that I can use vector inputs (as lists). at the base of it all how can I smash up lists and use them in sequence so I dont, for instance, have to say: (first vector1) (second vector2) (third vector3) etc...
I'll admit I could mix and match c and this stuff only because I know loops in C(but I don't mean really I mean conceptually in my noggin, what, you never thought it'd be easy searing for those red mushrooms from mario in grandtheft auto?). I don't know loops about lisp too well. anyone who as any algorithms..let me know. thanks-mt