Calling all knights of the lambda

  • Thread starter mt8891
  • Start date
  • Tags
    Lambda
In summary: This code uses the LOOP macro and the INC function to keep track of the sum, and the COLLECT function to collect the normalized elements into a new list. In summary, the conversation is about the difficulty of learning Lisp while having a strong background in C. The participant is trying to write linear algebra equations in Lisp and is struggling with using lists as vectors and iterating over them. They mention a crossproduct function they have written and express interest in a normalization function that uses vector inputs. They also mention their limited knowledge of loops in Lisp and ask for any algorithms or tips.
  • #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
 
Technology news on Phys.org
  • #2
You can use the LOOP macro in Lisp to iterate over elements of a list. Here is an example:(defun normalize-vector (vector) (let ((sum 0)) (loop for element in vector do (incf sum (* element element))) (loop for element in vector collect (/ element (sqrt sum)))))This function will take a vector (list) as input and normalize it. The first loop calculates the sum of the squares of the elements of the vector, and the second loop divides each element by the square root of the sum in order to normalize it.
 

Related to Calling all knights of the lambda

1. What is "Calling all knights of the lambda"?

"Calling all knights of the lambda" is a phrase often used in the field of computer science and programming. It refers to the concept of using the lambda symbol (λ) to represent anonymous functions in functional programming languages.

2. Why is the lambda symbol used to represent anonymous functions?

The lambda symbol is used because it was originally introduced by mathematician Alonzo Church in the 1930s to represent anonymous functions in his lambda calculus. This notation was later adopted by programming languages like Lisp, Scheme, and Python to represent anonymous functions.

3. What is the significance of "knights" and "calling" in this phrase?

The term "knights" represents the developers and programmers who use the lambda symbol to write functional code, while "calling" refers to the act of using the lambda symbol in code to call or invoke an anonymous function.

4. How is "Calling all knights of the lambda" related to functional programming?

Functional programming is a programming paradigm that focuses on writing code using functions as the main building blocks. The use of the lambda symbol and the phrase "Calling all knights of the lambda" is closely tied to this paradigm as it represents the use of anonymous functions in functional programming languages.

5. Can anyone be a knight of the lambda?

Yes, anyone who writes code using functional programming languages and understands the concept of anonymous functions can consider themselves a knight of the lambda. It is a playful and inclusive term used in the programming community.

Similar threads

  • Mechanical Engineering
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
10
Views
1K
Replies
5
Views
1K
  • Calculus and Beyond Homework Help
Replies
5
Views
2K
  • Linear and Abstract Algebra
2
Replies
59
Views
8K
Replies
4
Views
3K
  • Calculus and Beyond Homework Help
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
5
Views
4K
  • General Math
Replies
19
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
4K
Back
Top