Search found 71 matches
- Fri Jun 19, 2009 9:24 am
- Forum: The Lounge
- Topic: RSS feed
- Replies: 25
- Views: 43560
Re: RSS feed
Regarding the HTML parsing: I haven't done this before, but I thought of Closure HTML . Try it :D (Its possible, but annoying) This should work, but I can't test it currently: (defun get-entries (path) (let ((page (chtml:parse (trivial-http:http-get path) (stp:make-builder))) (entries ())) (stp:do-...
- Fri Jun 19, 2009 8:05 am
- Forum: Common Lisp
- Topic: incorrect simple floating point math
- Replies: 28
- Views: 33718
Re: incorrect simple floating point math
Since someone mentioned financial calculations: Never do financial calculations with floats! Floats are just a representation for non-integer, non-rational measurements. Their accuracy is, of course, limited by the number of places after the point. A base 2 float with x places after the point natura...
- Thu Jun 18, 2009 1:28 pm
- Forum: The Lounge
- Topic: RSS feed
- Replies: 25
- Views: 43560
Re: RSS feed
Regarding the HTML parsing: I haven't done this before, but I thought of Closure HTML.
- Thu Jun 18, 2009 10:59 am
- Forum: The Lounge
- Topic: RSS feed
- Replies: 25
- Views: 43560
Re: RSS feed
OK, a quick refactoring (untested): (defun http-page-to-string (path) (with-open-stream (in-stream (third (trivial-http:http-get path))) (with-output-to-string (out-stream) (loop (let ((line (read-line in-stream nil))) (when (null line) (return)) (write-line line out-stream))))) Note that this uses ...
- Thu Jun 18, 2009 7:18 am
- Forum: The Lounge
- Topic: RSS feed
- Replies: 25
- Views: 43560
Re: RSS feed
Some quick comments/questions: - You actually use TAGBODY, PROG and GO in high level code? - Reading a page into a string should be possible much easier. - HTML is not a regular language. Using regular expressions to parse it can only be a brittle hack. There are some very nice XML/HTML parser libra...
- Tue Jun 16, 2009 3:39 pm
- Forum: Common Lisp
- Topic: Copying a multidimensional array
- Replies: 10
- Views: 12287
Re: Copying a multidimensional array
OK, now the metatilities version: it also uses displacement, and it also doesn't produce a simple-array. It is a bit faster than my original attempt, but much slower than my result two posts ago. This (at least the speed and memory footprint) could be a problem with the displacement implementation. ...
- Tue Jun 16, 2009 3:14 pm
- Forum: Common Lisp
- Topic: Copying a multidimensional array
- Replies: 10
- Views: 12287
Re: Copying a multidimensional array
Now the only thing left that is bugging me is that I don't like to loop when what I really do is map. I'd like something like MAP-INTO, just for multidimensional arrays.
- Tue Jun 16, 2009 2:07 pm
- Forum: Common Lisp
- Topic: Copying a multidimensional array
- Replies: 10
- Views: 12287
Re: Copying a multidimensional array
At any rate, besides being non-idiomatic, I find my code always very idiomatic. here is another problem with your approach: CL-USER> (setf *print-array* nil a (make-array (list 1024 1024) :element-type '(unsigned-byte 8))) #<(SIMPLE-ARRAY (UNSIGNED-BYTE 8) (1024 1024)) {BABE997}> CL-USER> (copy-arr...
- Tue Jun 16, 2009 1:16 pm
- Forum: Common Lisp
- Topic: Copying a multidimensional array
- Replies: 10
- Views: 12287
Re: Copying a multidimensional array
Thanks for the pointer to alexandria. Alexandria uses an effect of ADJUST-ARRAY when applied to displaced arrays: (defun copy-array (array &key (element-type (array-element-type array)) (fill-pointer (and (array-has-fill-pointer-p array) (fill-pointer array))) (adjustable (adjustable-array-p arr...
- Tue Jun 16, 2009 12:19 pm
- Forum: Common Lisp
- Topic: Copying a multidimensional array
- Replies: 10
- Views: 12287
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.