Hi and welcome to the forum.
Might be slightly off topic but SICP videoes, lecture 4B at about 57 minutes implements adding polynomials. It's an early Scheme so you'll have to port it to CL, but it might give you some ideas and the videoes are quite entertaining
Syl
Search found 133 matches
- Sun Dec 30, 2012 8:19 pm
- Forum: Common Lisp
- Topic: Polynomial representation and manipulation
- Replies: 1
- Views: 5743
Re: Macros
Useful, but learning Lisp is all about reinventing the wheelGoheeca wrote:And after you get hygiene and a multiple evaluation issue you can stop reinventing the wheel and use well-known macros: with-gensyms & once-only.
Re: Macros
thanks for replying as I understand ( maybe I understood wrong) that we can replace the function to macro by simple changes in code , is it right????? for example if I have this function which use to insert in Binary search tree : (defun BST-insert (B E) (if (BST-empty-p B) (make-bin-tree-leaf E) (...
Re: Macros
Well. Common Lisp macroes are easy when the problem is easy. A little example here: ;; function (defun add10 (num) (+ 10 num)) Now a macro i CL is a function with the source arguments as parameters and the result is what the CL actually evaluates. It means you would make a macro with the body evalua...
- Tue Dec 25, 2012 11:08 am
- Forum: The Lounge
- Topic: Merry Christmas
- Replies: 0
- Views: 9277
Merry Christmas
Scheme version 2012 (define (x-mas) (define (x-mas-strings tokens order) (if (not (null? order)) (cons (list-ref tokens (car order)) (x-mas-strings tokens (cdr order))) '())) (apply string-append (x-mas-strings '("We wish you a Merry " "Christmas" "\n" " and a Hap...
- Tue Dec 11, 2012 5:15 pm
- Forum: Homework
- Topic: quick sort
- Replies: 2
- Views: 10694
Re: quick sort
I haven't changed your code, just put it in code-tags. I tested it and it works. (defun qsort (L) (if (null L) nil (append (qsort (list< (first L) (rest L))) (cons (first L) nil) (qsort (list>= (first L) (rest L)))))) You need to define list< and list>= as well since it's a large part that's obvious...
- Tue Nov 27, 2012 4:20 pm
- Forum: Homework
- Topic: Write A menu for dictionary
- Replies: 4
- Views: 12554
Re: Write A menu for dictionary
I tried you code with clisp and it does not fail in the manner you describe. I'm thinking you might use a different implementation that demands a line feed in the last line and you got none perhaps? Other than that you may want to separate parts of your code in functions and even put the loop into a...
- Tue Nov 13, 2012 4:53 pm
- Forum: Homework
- Topic: Finding Depth of an Expression
- Replies: 3
- Views: 10948
Re: Finding Depth of an Expression
It took a while to see that you're making your own length function. Interestingly, your function has sequential if statements,. Even if NIL was a function (which clearly you mean NULL) The first IF would evaluate to 0 and then it will continue to the second if. You really want to use (if (null L) <t...
- Thu Nov 01, 2012 3:23 pm
- Forum: Common Lisp
- Topic: A way to convert a float to integer w/o impact on memory?
- Replies: 9
- Views: 15477
Re: A way to convert a float to integer w/o impact on memory
I don't think multiple value return cons at all. It's most likely implemented in stack frame just like arguments are.
- Tue Oct 30, 2012 3:45 pm
- Forum: Common Lisp
- Topic: Behaviour of EVAL inside LET
- Replies: 14
- Views: 28025
Re: Behaviour of EVAL inside LET
(list 'lambda () command) returns a lambda-expression not a evaluated lambda-expression so this won't work in many CL-implementations. As mentioned before; If you declare a dynamically scoped it will do what you want. (defparameter a 666) (setf command (lambda () (+ a 1))) (let ((a 13)) (funcall com...