Search found 20 matches

by [email protected]
Thu Feb 07, 2013 12:06 pm
Forum: Emacs Lisp
Topic: very strange sorting problem
Replies: 1
Views: 14406

Re: very strange sorting problem

Just for completeness I neve could figure this out, but it started working. So, I had some conflicting data somewhere.
by [email protected]
Thu Jan 31, 2013 2:49 pm
Forum: Emacs Lisp
Topic: very strange sorting problem
Replies: 1
Views: 14406

very strange sorting problem

I have struggled with this one for too long. I am writing a simple function to sort the records in a file. Specifically, financial transactions for the Ledger accounting program. I am using sort-subr and have defined the nextrec and endrec functions properly. This is verified by using sort-subr on t...
by [email protected]
Thu Mar 01, 2012 3:28 pm
Forum: Common Lisp
Topic: iterating through the same list with two indices
Replies: 3
Views: 5655

Re: iterating through the same list with two indices

I don't think the solution with MAPCAR is ugly at all, it's only verbose, but lispy at the same time Another option would be: (loop for (elt1 . rest) on THE-LIST do (loop for elt2 in rest do (test-the-items elt1 elt2))) That dotted list is perfect, it is easy to understand and efficient. Thanks!
by [email protected]
Thu Mar 01, 2012 10:55 am
Forum: Common Lisp
Topic: iterating through the same list with two indices
Replies: 3
Views: 5655

iterating through the same list with two indices

I need to run through a list comparing each member to every member after that member for a condition. A very naiive approach would be: (loop for i from 0 to (1- (length THE-LIST)) do (loop for j from (1+ i) to (1- (length THE-LIST)) do (test-the-items (nth i THE-LIST) (nth j THE-LIST)) This is easil...
by [email protected]
Sat Feb 25, 2012 5:46 am
Forum: Common Lisp
Topic: Optimizing speed and fixnum literal
Replies: 7
Views: 11267

Re: Optimizing speed and fixnum literal

Also see SBCLs modular arithmetic . The entry in the manual is I believe out of date, and the capabilities of the compiler in this case are actually greater than described. If you know that the result is going to be a positive fixnum then wrapping the whole computation with (logand most-positive-fi...
by [email protected]
Thu Feb 23, 2012 11:00 pm
Forum: Common Lisp
Topic: Optimizing speed and fixnum literal
Replies: 7
Views: 11267

Re: Optimizing speed and fixnum literal

Cool! Thanks, I didn't know I could do that.
by [email protected]
Thu Feb 23, 2012 3:33 pm
Forum: Common Lisp
Topic: Optimizing speed and fixnum literal
Replies: 7
Views: 11267

Optimizing speed and fixnum literal

Using sbcl and (optimize (speed 3)... I keep getting compiler notes that a literal integer is an integer not a fixnum so it can't optimize. the offending line is (let* ((b (+ (- (* 3 m) a) c)) and the note is ; note: forced to do GENERIC-- (cost 10) ; unable to do inline fixnum arithmetic (cost 2) b...
by [email protected]
Tue Feb 21, 2012 9:55 am
Forum: Common Lisp
Topic: LIST vs TICK in a LET causing a global side-effect?!?
Replies: 6
Views: 7565

Re: LIST vs TICK in a LET causing a global side-effect?!?

To fully understand this you must remember how Common Lisp is processed. The first step is the reading phase, which transforms the text source into a tree of objects. Those objects are first-class language objects, which is how macros work, by operating on that object tree before the evaluation/com...
by [email protected]
Mon Feb 20, 2012 7:51 pm
Forum: Common Lisp
Topic: LIST vs TICK in a LET causing a global side-effect?!?
Replies: 6
Views: 7565

Re: LIST vs TICK in a LET causing a global side-effect?!?

Thanks, so as a general rule should I avoid using TICK for data initialization?
by [email protected]
Mon Feb 20, 2012 4:58 pm
Forum: Common Lisp
Topic: LIST vs TICK in a LET causing a global side-effect?!?
Replies: 6
Views: 7565

LIST vs TICK in a LET causing a global side-effect?!?

I am writing some numerical routines and trying to observe a strict functional approach. Today I got bitten by a bug I can't explain with my understanding of how LET, LIST and QUOTE work. I had the following code (significantly simplified to show the bug without cluttering up with the actual purpose...