Search found 406 matches

by gugamilare
Mon Mar 09, 2009 5:55 am
Forum: Common Lisp
Topic: A procedure to extract atoms from a list
Replies: 11
Views: 10228

Re: A procedure to extract atoms from a list

Actually this version seems pretty good. But it seems to be difficult to change if you problem changes a bit (at least to me). For instance, I've concluded these (both yours and eric-and-jane-smith's) algorithm is O(n^2) in the worst case. If the elements have a total order (e.g. numbers) it is poss...
by gugamilare
Sun Mar 08, 2009 11:04 am
Forum: Common Lisp
Topic: pushing links, not elements
Replies: 15
Views: 14806

Re: pushing links, not elements

Also, i can see if-let and when-let, it seems like a good idea. I used single variables and if-with, when-with, case-with, *-let does not extend to case-let well, though. I don't see anything like (defmacro if-with (var cond if-t &optional (if-f nil)) `(let ((,var ,cond)) (if ,var ,if-t ,if-f))) (d...
by gugamilare
Sat Mar 07, 2009 9:32 pm
Forum: Common Lisp
Topic: A procedure to extract atoms from a list
Replies: 11
Views: 10228

Re: A procedure to extract atoms from a list

I think it would be better to explicitly walk the tree recurring on non-atom CARs and CDRs, and use a hash table and list to record unique atoms encountered so far. Using hashtables? I really think that consing one or two cons cells for each atom extracted is way better than creating an entire hash...
by gugamilare
Sat Mar 07, 2009 8:42 pm
Forum: Common Lisp
Topic: Newb: help with factoring function
Replies: 15
Views: 12053

Re: Newb: help with factoring function

Let me take a look... (defun factor (num) (do* ((factors nil (cons factor factors)) (current-num num (/ num (apply #'* factors))) (factor (do ((x 2 (+ x 1))) ((or (zerop (rem current-num x)) (= current-num 1)) x)))) ((= num (apply #'* factors)) (reverse factors)) )) This is the version before using ...
by gugamilare
Sat Mar 07, 2009 7:28 pm
Forum: Common Lisp
Topic: pushing links, not elements
Replies: 15
Views: 14806

Re: pushing links, not elements

I think the better here would be to use a one-field structure (defstruct (pointer (:conc-name nil)) ref) Or to make it look like C (in a good way) (defstruct (pointer (:conc-name nil)) &) (let ((x (make-pointer :& 10))) (print (& x)) ; prints 10 (setf (& x) 20) (& x)) ==> 20 I believe using structur...
by gugamilare
Sat Mar 07, 2009 7:24 pm
Forum: The Lounge
Topic: Qt and Lisp...a great opportunity?
Replies: 18
Views: 26343

Re: Qt and Lisp...a great opportunity?

Now that is something I would like - to be able to use Qt with CL. It looks really great - it has nice visual effects even for Windows 98 - and it must be very flexible - not that I ever really used it, though. It is hard to see some CL aplication look good. There are a few programs that use McCLIM,...