Search found 8 matches

by SterlingM
Mon Sep 13, 2010 11:02 pm
Forum: Common Lisp
Topic: Adding two Polynomials
Replies: 3
Views: 6252

Re: Adding two Polynomials

Another update to code adding a recursive call to the first if condition (if the powers are equal) - (defun add-poly (poly1 poly2) (if (null poly1) poly2 (if (null poly2) poly1 (let ( (term1 (car poly1)) (term2 (car poly2)) ) (if (= (findpower term1) (findpower term2)) (append (maketerm (+ (findfact...
by SterlingM
Mon Sep 13, 2010 10:59 pm
Forum: Common Lisp
Topic: Adding two Polynomials
Replies: 3
Views: 6252

Re: Adding two Polynomials

Also, if I change the recursive line to

(add-poly (rest poly1) (rest poly2))))))

And input two two-term polynomials, I get nil...
by SterlingM
Mon Sep 13, 2010 10:49 pm
Forum: Common Lisp
Topic: Adding two Polynomials
Replies: 3
Views: 6252

Adding two Polynomials

I want to make a function to add two polynomials that are in the form of (factor power). The problem I am having is how to implement the recursion call to add a polynomial with more than one term. This is my function I have now and three small functions supporting it - (defun findfactor (term) (car ...
by SterlingM
Thu Sep 02, 2010 10:16 pm
Forum: Common Lisp
Topic: Taking exponent of a number
Replies: 2
Views: 3168

Taking exponent of a number

I am trying to make a function to take the yth power of number n. (defun xp (x y) (loop while (> 1 y) do (setf x (* x x)) (setf y (- y 1))) (print x)) That is what I have now. Everytime I run the, the only output is whatever I enter for x, twice. Ex. (xp 2 3) should print 8. Instead it just prints 2...
by SterlingM
Tue Mar 23, 2010 3:14 pm
Forum: Common Lisp
Topic: CL-USER> is unbound
Replies: 8
Views: 23054

Re: CL-USER> is unbound

Okay, it is working how I expect now. You're right, I was confused about files and buffers. Thanks for the help.
by SterlingM
Mon Mar 22, 2010 10:04 pm
Forum: Common Lisp
Topic: CL-USER> is unbound
Replies: 8
Views: 23054

Re: CL-USER> is unbound

It tells me that the CL-USER> variable is unbound. I'm not sure how to make the variable...bound? Can anyone tell me how to fix this? Thanks. It would help if you posted the code in question, so that we can see what CL is trying to evaluate. At a guess, you've taken the example a bit too literally ...
by SterlingM
Mon Mar 22, 2010 8:01 am
Forum: Common Lisp
Topic: CL-USER> is unbound
Replies: 8
Views: 23054

Re: CL-USER> is unbound

You posted in the Emacs Lisp subforum, but "CL" indicates Common Lisp. Are you aware of the difference? Where do you type your form in? Also, "CL-USER>" is not a variable, it is usually a SLIME prompt indicating current package. How did you save your file? I'm aware that they ar...
by SterlingM
Sun Mar 21, 2010 8:22 pm
Forum: Common Lisp
Topic: CL-USER> is unbound
Replies: 8
Views: 23054

CL-USER> is unbound

I am trying to load a previously saved file. I type in

Code: Select all

(load "/home/sterling/helloworld.cl") 
But everytime it tells me that the CL-USER> variable is unbound. I'm not sure how to make the variable...bound? Can anyone tell me how to fix this? Thanks.