Search found 16 matches

by simon
Tue Jun 16, 2009 2:13 pm
Forum: Common Lisp
Topic: Coercing to double-float
Replies: 4
Views: 6097

Re: Coercing to double-float

Don't forget that floating point numbers are just rational approximations, you can't get around issues of precision. CL-USER> (integer-decode-float .2d0) 7205759403792794 -55 1 CL-USER> (integer-decode-float .2) 13421773 -26 1 Your implementation may not have the exact same representations as mine, ...
by simon
Tue Jun 16, 2009 1:02 pm
Forum: Common Lisp
Topic: Copying a multidimensional array
Replies: 10
Views: 12649

Re: Copying a multidimensional array

I am not making a double copy. As far as I understood, :displaced-to makes the new array a kind of alias for the original array (or possibly a sub-array thereof). The array data are thus only copied once, through the COPY-SEQ. Sorry, I think I conflated a statement in your original and gugamilare's...
by simon
Tue Jun 16, 2009 11:45 am
Forum: Common Lisp
Topic: Copying a multidimensional array
Replies: 10
Views: 12649

Re: Copying a multidimensional array

Something like this: (defun copy-array (a) (do ((b (make-array (array-dimensions a) :element-type (array-element-type a))) (n 0 (1+ n))) ((>= n (array-total-size a)) b) (setf (row-major-aref b n) (row-major-aref a n)))) Avoids the double copy you are making. Also note the existence of #'array-total-...
by simon
Tue Jun 16, 2009 7:58 am
Forum: Lisp Quiz
Topic: Lisp Quiz #3
Replies: 3
Views: 31134

Re: Lisp Quiz #3

So nobody does these things, right? I thought about your quiz question over coffee. I've never dealt with XML in lisp before, or web interfaces so I thought it might be fun to see how much is involved. Luckily people have thought about this sort of problem and come up with some neat programs. So, he...
by simon
Thu Jun 11, 2009 2:41 pm
Forum: Common Lisp
Topic: Extending a simple array dynamically
Replies: 4
Views: 5733

Re: Extending a simple array dynamically

VECTOR-PUSH-EXTEND is what you want but array must be adjustable. http://www.lispworks.com/documentation/HyperSpec/Body/f_vec_ps.htm Arrays are continuous blocks of memory I really doubt you will gain much if at all by using simple array especially in accesing elements. Maybe it would be better if ...
by simon
Wed May 13, 2009 9:20 am
Forum: Lisp Quiz
Topic: Lisp Quiz #2?
Replies: 9
Views: 61740

Re: Lisp Quiz #2?

Because of the support for complex numbers, this is pretty simply expressed in common lisp. I've made it a little more flexible with optional height/width arguments but otherwise left along. A clear improvement would be add a look up table into a list of characters ordered by "brightness"....