You can subscribe to this list here.
2002 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(4) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(19) |
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(7) |
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(15) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Robin L. P. <rlp...@di...> - 2008-08-11 07:37:31
|
Is there any way to expand a series? What I would like to do is something (very loosely) like this: (let ((orig #z(1 -2 3 4 -5 6)) ([do some other series stuff on orig]) (x (choose-if #'minusp #z(1 -2 3 4 -5 6)))) (alter x [turn -N into -N ... 0, thus changing the length of the series])) In other words, given a series, I want to replace some of the values with a bunch more values, but without losing the lazy-ness of the library. Is there any way to do this at all? -Robin -- Lojban Reason #17: http://en.wikipedia.org/wiki/Buffalo_buffalo Proud Supporter of the Singularity Institute - http://singinst.org/ http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/ |
From: Robin L. P. <rlp...@di...> - 2008-08-11 03:11:48
|
On Sun, Aug 10, 2008 at 07:50:03PM -0700, Robin Lee Powell wrote: > The goal of the function in question is to turn a (finite) series > into a series of all the possible sub-series; there are *no* > non-series calls in the function: > > (defun subseries-all (start-ser) > (DECLARE (OPTIMIZABLE-SERIES-FUNCTION)) > (multiple-value-bind > (index-ser initial-ser) > (cotruncate (scan-range) start-ser) > (mapping ((x index-ser)) > (subseries initial-ser x)))) Wrapping (subseries initial-ser x) in (collect ...) so I have a series of sublists still works just fine, but then I get the somewhat scarier error: WARNING: ; in: LAMBDA NIL ; (SERIES:COLLECT (SERIES:SUBSERIES SPATH::INITIAL-SER SPATH::X)) ; --> FLET BLOCK SB-CLTL2:COMPILER-LET LET COND IF COND IF COND IF COND IF COND ; --> IF PROGN SETQ THE IF CONSP CADR CAR ; ==> ; (CDR SERIES::SEQ-TYPE) ; ; caught WARNING: ; Asserted type LIST conflicts with derived type (VALUES (MEMBER LIST) &OPTIONAL). ; See also: ; The SBCL Manual, Node "Handling of Types" ; ; compilation unit finished ; caught 1 WARNING condition -Robin |
From: Robin L. P. <rlp...@di...> - 2008-08-11 02:50:07
|
Brand new to Series, but it seems like my sort of thing; I always kind of enjoyed the lazy evaluation stuff that Haskell did. For this particural bit of code, I'm starting with finite lists and digging through them to find sub-sections. I'm a little surprised by some of the warnings I'm getting, and I'm hoping someone can shed some light on these. Everything seems to be working just fine, for the record. Restriction violation 12 in series expression: NIL Series var INITIAL-SER referenced in nested non-series LAMBDA. WARNING: Warning 28 in series expression: (COLLECT-FIRST X) Non-series to series data flow from: X to: (COLLECT-FIRST X) The goal of the function in question is to turn a (finite) series into a series of all the possible sub-series; there are *no* non-series calls in the function: (defun subseries-all (start-ser) (DECLARE (OPTIMIZABLE-SERIES-FUNCTION)) (multiple-value-bind (index-ser initial-ser) (cotruncate (scan-range) start-ser) (mapping ((x index-ser)) (subseries initial-ser x)))) Just to be clear, initial-ser and start-ser should be the same in all respects; I couldn't figure out any other way to get a 0-to-n series of the same length as start-ser. There's no way I can see to get the legth of a finite series. WARNING: Warning 28 in series expression: (DEFUN SPATH-FIND (SER ITEM) (DECLARE (OPTIMIZABLE-SERIES-FUNCTION)) (CHOOSE-IF #'(LAMBDA (X) (FORMAT T "val: ~A~%" X) (EQUAL ITEM (COLLECT-FIRST X))) (SUBSERIES-ALL SER))) Non-series to series data flow from: (SUBSERIES-ALL SER) to: (CHOOSE-IF #'(LAMBDA (X) (FORMAT T "val: ~A~%" X) (EQUAL ITEM (COLLECT-FIRST X))) (SUBSERIES-ALL SER)) WARNING: Restriction violation 13 in series expression: (COLLECT-FIRST (SPATH-FIND (SCAN '(B 3 C 1 B 5)) 'B)) Series to non-series data flow from: (SCAN '(B 3 C 1 B 5)) to: (SPATH-FIND (SCAN '(B 3 C 1 B 5)) 'B) Both of these come from the same function, spath-find, helpfully printed there in its entirety. The point of the choose-if predicate (ignoring the format call) is to compare the first item of the series (remember, subseries-all returns a series of series) to a given value. I'm quite surprised by the total lack of accessors; there's no way that I can see to get at the first element of the sub-series there at all without converting out of series mode and getting those warnings. I'm hoping someone can show me something I missed. Thanks. -Robin -- Lojban Reason #17: http://en.wikipedia.org/wiki/Buffalo_buffalo Proud Supporter of the Singularity Institute - http://singinst.org/ http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/ |
From: Marko T. M. <mm...@gm...> - 2008-06-02 21:01:51
|
Hi, i got this error, when trying to load iolib: No MAKE-LOAD-FORM method is defined for #<CCL::SIMPLE-PROGRAM-ERROR #x3000413AE9BD> [Condition of type SIMPLE-ERROR] Backtrace: 0: (CCL::NO-MAKE-LOAD-FORM-FOR #<CCL::SIMPLE-PROGRAM-ERROR #x3000413AE9BD>) Locals: CCL::OBJECT = #<CCL::SIMPLE-PROGRAM-ERROR #x3000413AE9BD> 1: (CCL::FASL-SCAN-USER-FORM #<CCL::SIMPLE-PROGRAM-ERROR #x3000413AE9BD>) [No Locals] 2: (CCL::FASL-SCAN-CLFUN #<Anonymous Function #x3000413AE92F>) Locals: CCL::F = #<Anonymous Function #x3000413AE92F> CCL::NCODE-WORDS = 9 3: (CCL::FASL-SCAN-CLFUN #<Anonymous Function #x3000413AE09F>) Locals: CCL::F = #<Anonymous Function #x3000413AE09F> CCL::NCODE-WORDS = 18 4: (CCL::FASL-SCAN '((23 83) (47 "home:lisp;libs;series-2.2.9;s- code.lisp.newest") (4 #<Anonymous Function #x30004121A8FF>) (41 SERIES:*SUPPRESS-SERIES-WARNINGS* NIL "Suppress warnings when the restrictions are violated.") (41 SERIES:*SERIES-EXPRESSION-CACHE* T "Avoids multiple expansions") (41 SERIES:*LAST-SERIES-LOOP* NIL "Loop most recently created by SERIES.") (41 SERIES:*LAST-SERIES-ERROR* NIL "Info about error found most recently by SERIES.") ..)))) Locals: CCL::FORMS = ((23 83) (47 "home:lisp;libs;series-2.2.9;s- code.lisp.newest") (4 #<Anonymous Function #x30004121A8FF>) (41 SERIES:*SUPPRESS-SERIES-WARNINGS* NIL "Suppress warnings when the restrictions are violated.") (41 SERIES:*SERIES-EXPRESSION-CACHE* T "Avoids multiple expansions") (41 SERIES:*LAST-SERIES-LOOP* NIL "Loop most recently created by SERIES.") ...) CCL::*FASDUMP-HASH* = #<Unbound> CCL::*MAKE-LOAD-FORM-HASH* = #<Unbound> CCL::*FASDUMP-READ-PACKAGE* = #<Unbound> CCL::*FASDUMP-GLOBAL-OFFSETS* = #<Unbound> CCL::OP = (4 #<Anonymous Function #x3000413AE09F>) 5: (CCL::FASL-SCAN-FORMS-AND-DUMP-FILE '((23 83) (47 "home:lisp;libs;series-2.2.9;s-code.lisp.newest") (4 #<Anonymous Function #x30004121A8FF>) (41 SERIES:*SUPPRESS-SERIES-WARNINGS* NIL "Suppress warnings when the restrictions are violated.") (41 SERIES:*SERIES-EXPRESSION-CACHE* T "Avoids multiple expansions") (41 SERIES:*LAST-SERIES-LOOP* NIL "Loop most recently created by SERIES.") (41 SERIES:*LAST-SERIES-ERROR* NIL "Info about error found most recently by SERIES.") ..))) "/ Users/mmstud/lisp/libs/series-2.2.9/s-code.dx64fsl" #<LEXICAL- ENVIRONMENT #x30004121AE5D>) 6: (CCL::%COMPILE-FILE "/Users/mmstud/lisp/libs/series-2.2.9/s- code.lisp" "/Users/mmstud/lisp/libs/series-2.2.9/s-code.dx64fsl" 'T 'NIL 'NIL 'NIL 'T 'T 'NIL 'NIL #<BACKEND DARWINX8664 #x30004071783D> ':DEFAULT) 7: (COMPILE-FILE #P"/Users/mmstud/lisp/libs/series-2.2.9/s- code.lisp" ':OUTPUT-FILE #P"/Users/mmstud/lisp/libs/series-2.2.9/s- code.dx64fsl" ':VERBOSE 'T ':PRINT 'NIL ':LOAD 'NIL ':FEATURES 'NIL ':TARGET ':DARWINX8664 ':SAVE-LOCAL-SYMBOLS 'NIL ':SAVE-DOC-STRINGS 'T ':SAVE-DEFINITIONS 'T ':EXTERNAL-FORMAT 'NIL ':FORCE ':DEFAULT) 8: (#<STANDARD-METHOD ASDF:PERFORM (ASDF:COMPILE-OP ASDF:CL-SOURCE-FILE)> #<COMPILE- OP NIL #x3000411F9FED> #<CL-SOURCE-FILE "s-code" #x3000411FB94D>) 9: (CCL::%%BEFORE-AND-AFTER-COMBINED-METHOD-DCODE '(NIL #<STANDARD-METHOD ASDF:PERFORM (ASDF:COMPILE-OP ASDF:CL-SOURCE-FILE)> . 4265093)) 10: (CCL::%%STANDARD-COMBINED-METHOD-DCODE '((#<STANDARD-METHOD ASDF:PERFORM :BEFORE (ASDF:COMPILE-OP ASDF:SOURCE-FILE)>) (#<STANDARD-METHOD ASDF:PERFORM :AFTER (ASDF:OPERATION ASDF:COMPONENT)>) #<STANDARD-METHOD ASDF:PERFORM (ASDF:COMPILE-OP ASDF:CL-SOURCE-FILE)>) 4265093) 11: (ASDF:OPERATE 'ASDF:LOAD-OP ':IOLIB-TESTS) 12: (#<STANDARD-METHOD ASDF:PERFORM (ASDF:TEST-OP (EQL #<SYSTEM "iolib-tests" #x300040F9786D>))> #<TEST-OP NIL #x300040F97E3D> #<SYSTEM "iolib- tests" #x300040F9786D>) 13: (CCL::%%BEFORE-AND-AFTER-COMBINED-METHOD-DCODE '(NIL #<STANDARD-METHOD ASDF:PERFORM (ASDF:TEST-OP (EQL #<SYSTEM "iolib-tests" #x300040F9786D>))> . 4265152)) 14: (CCL::%%STANDARD-COMBINED-METHOD-DCODE '(NIL (#<STANDARD-METHOD ASDF:PERFORM :AFTER (ASDF:OPERATION ASDF:COMPONENT)>) #<STANDARD-METHOD ASDF:PERFORM (ASDF:TEST-OP (EQL #<SYSTEM "iolib-tests" #x300040F9786D>))>) 4265152) 15: (ASDF:OPERATE 'ASDF:TEST-OP ':IOLIB-TESTS) 16: (CCL::%%BEFORE-AND-AFTER-COMBINED-METHOD-DCODE '(NIL #<STANDARD-METHOD ASDF:PERFORM (ASDF:TEST-OP (EQL #<SYSTEM "iolib" #x300040F9488D>))> . 4265212)) 17: (CCL::%%STANDARD-COMBINED-METHOD-DCODE '(NIL (#<STANDARD-METHOD ASDF:PERFORM :AFTER (ASDF:OPERATION ASDF:COMPONENT)>) #<STANDARD-METHOD ASDF:PERFORM (ASDF:TEST-OP (EQL #<SYSTEM "iolib" #x300040F9488D>))>) 4265212) 18: (ASDF:OPERATE 'ASDF:TEST-OP ':IOLIB) 19: (CCL::CALL-CHECK-REGS 'ASDF:OOS 'ASDF:TEST-OP ':IOLIB) 32: (SWANK::CALL-WITH-CONNECTION #<CONNECTION #x300040EDCC8D> #<Compiled-function (:INTERNAL SWANK::HANDLE-REQUEST) (Non-Global) #x300040E6C25F>) 33: (SWANK::HANDLE-REQUEST #<CONNECTION #x300040EDCC8D>) 34: (SWANK::REPL-LOOP #<CONNECTION #x300040EDCC8D>) 35: (SWANK::CALL-WITH-BINDINGS 'NIL #<COMPILED-LEXICAL-CLOSURE (:INTERNAL SWANK::SPAWN-REPL-THREAD) #x300040EFCC8F>) 36: (CCL::RUN-PROCESS-INITIAL-FORM #<PROCESS repl-thread(5) [Active] #x300040ECAE5D> '(#<COMPILED-LEXICAL-CLOSURE (:INTERNAL CCL::%PROCESS-RUN-FUNCTION) #x300040ECADCF>)) 37: ((:INTERNAL CCL::%PROCESS-PRESET-INTERNAL) #<PROCESS repl- thread(5) [Active] #x300040ECAE5D> '(#<COMPILED-LEXICAL-CLOSURE (:INTERNAL CCL::%PROCESS-RUN-FUNCTION) #x300040ECADCF>)) 38: ((:INTERNAL CCL::THREAD-MAKE-STARTUP-FUNCTION)) I used most recent packages and repositories available today, and thought if it is worth of reporting. Im sending this message to both series-users (which seems not very active) and iolib-devel (which seems active). |
From: <to...@rt...> - 2005-12-19 15:35:50
|
>>>>> "Chris" == Chris Dean <ct...@so...> writes: Chris> [Looks like I'm on a roll with all these questions!] Chris> How do I write a function to return the last N elements of a series? Chris> I'd prefer that the result of this function be a series itself. Chris> Here's one way that doesn't really work: Chris> (defun series-tail (items &optional (how-many 1)) Chris> (declare (optimizable-series-function 1)) Chris> (let ((len (collect-length items))) Chris> (if (<= 0 how-many len) Chris> (subseries items (- len how-many)) Chris> items))) Chris> I suppose I could keep a ring of the last HOW-MANY elements, but I'm Chris> not sure how to do that. Not sure if this is exactly what you want, but here is a function that takes a series and returns a new series whose elements are a list of the last N elements seen thus far. (defun series-tail (items how-many) (declare (optimizable-series-function 1)) (#Mreverse (collecting-fn t #'(lambda () (make-list 0)) #'(lambda (r x) (values (subseq (cons x r) 0 how-many) (cons x r))) items))) (series-tail (scan-range :below 10) 3) => #Z((0) (0 1) (0 1 2) (1 2 3) (2 3 4) (3 4 5) (4 5 6) (5 6 7) (6 7 8) (7 8 9)) And if you really want the last set, then (collect-last (series-tail (scan-range :below 10) 3)) => (7 8 9) or even (scan (collect-last (series-tail (scan-range :below 10) 3))) if you want a series. This implementation does generate quite a bit of garbage because it does cons up new lists for each iteration. Ray |
From: Chris D. <ct...@so...> - 2005-12-19 11:38:55
|
"Hoehle, Joerg-Cyril" <Joe...@t-...> writes: > (map-fn t #'ring-ref (scan-range :below (ring-current-length ring))) Very nice! With your change: (defun scan-ring (ring) (declare (optimizable-series-function 1)) (map-fn t (lambda (i) (ring-ref ring i)) (scan-range :below (ring-current-length ring)))) We produce very efficient code. >>(defun ring->list (ring) >> "Convert the ring to a list" >> (collect (scan-ring ring))) > This looks more like a testsuite -- create a throw-away series just > to get the values?! Why not just (coerce 'list (ring-vec ring))? One reason is that (coerce (ring-vec ring) 'list) doesn't always give me the correct order - that is, the 0th index of the vector might not be the first element in the ring. The main reason though is that Series is very good at using a throw-away series. The efficiency of that one line is on par with a hand coded DO loop. That, to me, is the main point of series: High level descriptive code that runs as efficiently as something I've hand coded. Regards, Chris Dean |
From: Chris D. <ct...@so...> - 2005-12-19 10:59:25
|
"Hoehle, Joerg-Cyril" <Joe...@t-...> writes: > a) Either take a code generation approach and create code that latches > (= delay by one) N times, > > b) Or take a functional approach, implement a ring datastructure and > use that. Thanks for the great advice. This is the same reasoning I used. I have since implemented collect-tail and series-tail using a ring and I will say that it was more straight forward to write collect-tail for the iterate system. > since you're asking similar questions in series-users and > iterate-devel, This is my standard looping question in any language: Read the last N lines of a file, transform them, filter them, and return the unique elements. This is a nice test because (to use Series lingo I didn't know until recently) it combines on-line and off-line processing. > I'm starting to wonder whether you're going to write a paper on > comparisons of some looping frameworks? :-) :-) Some papers one might wish to read are the recent Shivers paper [1] and the Egner paper [2]. They provide a decent overview from a Scheme perspective. These papers don't really go into the use of iterators/generators ala Python, Ruby, and CLU. (This is the approach where one uses yield in the generator to return control to the loop.) It's too bad they don't delve into iterators because it is a very elegant approach to the problem (albeit with some performance hurdles). It would be an interesting problem to write a performant iterator system in Common Lisp. Thanks again, Chris Dean Footnotes: [1] The anatomy of a loop: a story of scope and control. Olin Shivers. http://www.cc.gatech.edu/~shivers/citations.html#loop [2] Eager Comprehensions in Scheme: The design of SRFI-42 Sebastian Egner http://www.deinprogramm.de/scheme-2005/program.html |
From: Hoehle, Joerg-C. <Joe...@t-...> - 2005-12-19 10:35:04
|
Chris Dean writes: >I eagerly await a code critique. >(defun scan-ring (ring) > "Return the ring as a series." > (declare (optimizable-series-function)) > (let ((i 0) (len (ring-current-length ring))) > (scan-fn t > (lambda () (and (/= i len) (ring-ref ring i))) > (lambda (x) (declare (ignore x)) (ring-ref ring (incf i))) > (lambda (x) (declare (ignore x)) (= i len))))) I think you somewhat misued scan-fn here. Scan-fn allows to write purely functional code. In order to achieve this, it passes state around explicitly. This is what the init function is for, and the first values of the step and test functions. In effect, scan-fn is very similar to REDUCE with :INITIAL-VALUE, or the fold procedure in functional programming. The (INCF i) and DECLARE IGNORE is IMHO a sign of the misuse. Here's my solution (untested): (map-fn t #'ring-ref (scan-range :below (ring-current-length ring))) >(defun ring->list (ring) > "Convert the ring to a list" > (collect (scan-ring ring))) This looks more like a testsuite -- create a throw-away series just to get the values?! Why not just (coerce 'list (ring-vec ring))? Regards, Jorg Hohle. |
From: Hoehle, Joerg-C. <Joe...@t-...> - 2005-12-19 09:41:47
|
Chris, since you're asking similar questions in series-users and iterate-devel, I'm starting to wonder whether you're going to write a paper on comparisons of some looping frameworks? :-) >how do I go about collecting the last N elements of anything? > (iter (for line :in-file my-file :using #'read-line) > (collect-tail line :how-many 10)) If 10 is known at macro-expansion time, you can always write a macro that expands to a series of 10 uses of PREVIOUS in Iterate, or 10 consecutive latches in Series. I.e., IMHO there are always two ways, either with series of iterate: a) Either take a code generation approach and create code that latches (= delay by one) N times, b) Or take a functional approach, implement a ring datastructure and use that. The former looks like a better use of Series: it could be a series of the 10 last values (as a list, or 10 series of values farther and farther behind). In/After the last iteration, you'll have the 10 last values. As to which approach is better... Probably you wouldn't want to generate code for the last 100 values. BTW, you'll have to defined what happens when less than 10 iterations were taken. Straight-forward code is likely to return (val1 val2 nil nil ...6xnil), whereas one could wish for (val1 val2) with only 2 iterations. Regards, Jorg Hohle. |
From: Chris D. <ct...@so...> - 2005-12-15 08:01:27
|
Chris Dean <ct...@so...> writes: > How do I write a function to return the last N elements of a series? > I'd prefer that the result of this function be a series itself. Here's one way. Assume a ring data structure and only keep the last N elements: (defun series-tail (items how-many) "Returns the last HOW-MANY elements of the series ITEMS. If HOW-MANY is greater than (collect-length ITEMS) then all of the elements in ITEMS are returned." (declare (optimizable-series-function 1) (off-line-port items)) (let ((ring (make-ring how-many))) (iterate ((x items)) (ring-enqueue ring x)) (scan-ring ring))) I eagerly await a code critique. If found this very difficult to write, mostly due to the cryptic (to me) error messages. However, once it was done it looks very nice and elegant. Using series-tail makes the series expression not parallelizable which is expensive, but no more expensive than another non-series looping construct. (The ring code is below for those interested.) Regards, Chris Dean ;;; ;;; rings ;;; (defstruct (ring (:constructor make-ring-storage)) size index current-length vec) (defun make-ring (size) "Create a ring. A ring is like a fixed sized queue except that when the ring is full and an element is inserted, the oldest element is deleted to make room. SIZE is the size of the ring." (make-ring-storage :size size :index 0 :current-length 0 :vec (make-array size))) (defun ring-enqueue (ring obj) "Add a new element to the ring. The oldest element in the ring may be deleted to make room." (with-slots (size index current-length vec) ring (setf (svref vec index) obj) (setf index (mod (1+ index) size)) (setf current-length (min size (1+ current-length))) obj)) (defun ring-dequeue (ring) "Remove the oldest element from the ring. It is an error to remove from an empty ring." (when (ring-empty? ring) (error "ring is empty")) (prog1 (ring-ref ring 0) (decf (ring-current-length ring)))) (defun ring-ref (ring i) "Get the element at the index I. The oldest element is index 0." (with-slots (size index current-length vec) ring (let ((ii (mod (+ i (- index current-length)) size))) (svref vec ii)))) (defun ring-empty? (ring) (zerop (ring-current-length ring))) (defun ring-full? (ring) (= (ring-current-length ring) (ring-size ring))) (defun scan-ring (ring) "Return the ring as a series." (declare (optimizable-series-function)) (let ((i 0) (len (ring-current-length ring))) (scan-fn t (lambda () (and (/= i len) (ring-ref ring i))) (lambda (x) (declare (ignore x)) (ring-ref ring (incf i))) (lambda (x) (declare (ignore x)) (= i len))))) (defun ring->list (ring) "Convert the ring to a list" (collect (scan-ring ring))) |
From: Chris D. <ct...@so...> - 2005-12-13 19:07:53
|
Raymond Toy <ray...@er...> writes: > Chris> Is there a way to use gathering to collect a series? ... > I'm not at all familiar with the generator/gather part of series. > I'll have to think about this. Do you need to do it this way instead > of using series itself? I'm searching for the "right way" to handle the problem, so another way would be fine but the gathering code seemed like a natural fit. I used to have this code that returned a list of URLs from a string: (defun html-body->raw-urls (body &key use-javascript) (let ((res nil)) (do-scans (s e rs re *AHREF-RE* body) (push (subseq body (aref rs 0) (aref re 0)) res)) (do-scans (s e rs re *ANY-URL-RE* body) (push (subseq body (aref rs 0) (aref re 0)) res)) (when use-javascript (do-scans (s e rs re *JS-RE* body) (push (subseq body (aref rs 0) (aref re 0)) res))) res)) What I'd like to do is replace it with this code that returns a series: (defun html-body->raw-urls (body) (scan (gathering ((res collect)) (cl-ppcre:do-scans (s e rs re *AHREF-RE* body) (next-out res (subseq body (aref rs 0) (aref re 0)))) (cl-ppcre:do-scans (s e rs re *ANY-URL-RE* body) (next-out res (subseq body (aref rs 0) (aref re 0)))) (when use-javascript (do-scans (s e rs re *JS-RE* body) (next-out res (subseq body (aref rs 0) (aref re 0)))))))) If you can suggest any natural way of doing this, that would be wonderful. Regards, Chris Dean |
From: Chris D. <ct...@so...> - 2005-12-13 18:46:46
|
to...@rt... writes: > With this change, does LW run the testsuite correctly now? Hmm. I'm not sure. I did get a break and this message when running do-tests: Restriction violation 6 in series expression: NIL The form LOAD-TIME-VALUE not allowed in SERIES expressions. If I just continued from that break and everything else seemed ok. Output below. Regards, Chris Dean Doing 563 pending tests of 563 tests total. Type a string representing a pathname of a scratch disk file: "~/tmp/foo.scratch2" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 487 488 489 490 491 492 493 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 553 554 555 556 557 558 Restriction violation 6 in series expression: NIL The form LOAD-TIME-VALUE not allowed in SERIES expressions. Warning: 559 560 561 1000 1001 3000 5000 5001 5002 5003 5004 No tests failed. T |
From: Hoehle, Joerg-C. <Joe...@t-...> - 2005-12-13 17:56:44
|
Raymond Toy wrote: >>>>>> "Chris" == Chris Dean <ct...@so...> writes: > Chris> (delete-duplicates '("3" "1" "4" "1" "5" "9") >:test #'string-equal) > Chris> => ("3" "4" "1" "5" "9") > Chris> What's the equivalent idiom in series? Should I just write > Chris> series-delete-duplicates? >Off the top of my head, I don't think you can. I believe otherwise. I think there must be such an idiom somewhere in series (I haven't used it for quite some time now). Because IIRC, the a-list and p-list converters are documented to do so (IIRC, just for one of the directiones). Thus I suppose that another collector with variable predicates can be built, modeled after the present a-list and p-list processing functions. Actually, when I read the documentation, I was surprised by this behaviour since it's more expensive than a simple mapping of a list (in either a-list or p-list format) to the series of keys and values, disregarding duplicates. Regards, Jorg Hohle. |
From: <to...@rt...> - 2005-12-13 14:39:54
|
>>>>> "Chris" == Chris Dean <ct...@so...> writes: Chris> Chris Dean <ct...@so...> writes: >> I'm trying to compile Series 2.2.9 under LispWorks and am getting this >> error Chris> ... Chris> Looks like coerce-maybe-fold needed a eval-when around it. Patch Chris> below. With this change, does LW run the testsuite correctly now? Ray |
From: <to...@rt...> - 2005-12-13 13:56:00
|
>>>>> "Chris" == Chris Dean <ct...@so...> writes: Chris> Is there a way to use gathering to collect a series? For example, Chris> here's a function that uses gathering and scan to produce a series as Chris> a result: Chris> (defun foo () Chris> (scan (gathering ((res collect)) Chris> (next-out res 1) Chris> (next-out res 2) Chris> (next-out res 3)))) [snip] I'm not at all familiar with the generator/gather part of series. I'll have to think about this. Do you need to do it this way instead of using series itself? Ray |
From: <to...@rt...> - 2005-12-13 13:54:57
|
>>>>> "Chris" == Chris Dean <ct...@so...> writes: Chris> [Looks like I'm on a roll with all these questions!] Chris> How do I write a function to return the last N elements of a series? Chris> I'd prefer that the result of this function be a series itself. Chris> Here's one way that doesn't really work: Chris> (defun series-tail (items &optional (how-many 1)) Chris> (declare (optimizable-series-function 1)) Chris> (let ((len (collect-length items))) Chris> (if (<= 0 how-many len) Chris> (subseries items (- len how-many)) Chris> items))) I don't think you can do that because you don't know how long the series is until you traverse it. I suppose you could keep a list of the last N elements as you traverse it so you have the last N at any point as you traverse the list, but I suspect this isn't what you really want. Ray |
From: Raymond T. <to...@rt...> - 2005-12-13 13:50:06
|
>>>>> "Chris" == Chris Dean <ct...@so...> writes: Chris> The delete-duplicates function has the nice feature of being able to Chris> define test to compare elements: Chris> (delete-duplicates '("3" "1" "4" "1" "5" "9") :test #'string-equal) Chris> => ("3" "4" "1" "5" "9") Chris> What's the equivalent idiom in series? Should I just write Chris> series-delete-duplicates? Off the top of my head, I don't think you can. To delete the duplicates (naively), you have to scan the list several times, or keep additional information, or sort it. Series doesn't like that. I think I'd just collect the series, delete the duplicates, and scan the list again. Ray |
From: Chris D. <ct...@so...> - 2005-12-13 03:01:06
|
[Looks like I'm on a roll with all these questions!] How do I write a function to return the last N elements of a series? I'd prefer that the result of this function be a series itself. Here's one way that doesn't really work: (defun series-tail (items &optional (how-many 1)) (declare (optimizable-series-function 1)) (let ((len (collect-length items))) (if (<= 0 how-many len) (subseries items (- len how-many)) items))) I suppose I could keep a ring of the last HOW-MANY elements, but I'm not sure how to do that. Thanks again! Regards, Chris Dean |
From: Chris D. <ct...@so...> - 2005-12-13 00:00:01
|
The delete-duplicates function has the nice feature of being able to define test to compare elements: (delete-duplicates '("3" "1" "4" "1" "5" "9") :test #'string-equal) => ("3" "4" "1" "5" "9") What's the equivalent idiom in series? Should I just write series-delete-duplicates? I can't use (collect 'set ...) because it doesn't take a :test or :key parameter. Regards, Chris Dean |
From: <to...@rt...> - 2005-12-12 14:02:16
|
>>>>> "Chris" == Chris Dean <ct...@so...> writes: Chris> Chris Dean <ct...@so...> writes: >> I'm trying to compile Series 2.2.9 under LispWorks and am getting this >> error Chris> ... Chris> Looks like coerce-maybe-fold needed a eval-when around it. Patch Chris> below. Sorry for the long delay. I'll apply this patch very soon. And thanks for testing this with Lispworks! Ray |
From: Chris D. <ct...@so...> - 2005-12-09 20:40:20
|
Is there a way to use gathering to collect a series? For example, here's a function that uses gathering and scan to produce a series as a result: (defun foo () (scan (gathering ((res collect)) (next-out res 1) (next-out res 2) (next-out res 3)))) Even if it just syntactic sugar, I'd rather type something like (defun foo2 () (gathering ((res collect-series)) (next-out res 1) (next-out res 2) (next-out res 3))) Thanks for any pointers. Regards, Chris Dean |
From: Chris D. <ct...@so...> - 2005-12-09 19:39:19
|
Chris Dean <ct...@so...> writes: > I'm trying to compile Series 2.2.9 under LispWorks and am getting this > error ... Looks like coerce-maybe-fold needed a eval-when around it. Patch below. Regards, Chris Dean --- s-code.lisp.orig 2005-11-15 07:07:57.000000000 -0800 +++ s-code.lisp.new 2005-12-08 20:34:06.000000000 -0800 @@ -1452,8 +1452,9 @@ ) ; end of eval-when #-allegro -(defmacro coerce-maybe-fold (thing type) - `(coerce ,thing ,type)) +(eval-when (:compile-toplevel :load-toplevel :execute) + (defmacro coerce-maybe-fold (thing type) + `(coerce ,thing ,type))) #+allegro |
From: Chris D. <ct...@so...> - 2005-12-03 10:32:42
|
I'm trying to compile Series 2.2.9 under LispWorks and am getting this error: **++++ Error in SERIES:SCAN: Undefined function COERCE-MAYBE-FOLD called with arguments ((COERCE-MAYBE-FOLD 0 VAR-TYPE) #<Augmented Environment venv (#<Venv 269269520 VAR-TYPE> #<Venv 269269428 TYPE>) fenv ((#:SOURCE-LEVEL-ENVIRONMENT-MARKER . #<COMPILER::FLET-INFO (NIL . #<EQ Hash Table{663} 112209F3>)>) (#:FUNCTOR-MARKER . #<COMPILER::FLET-INFO ((TYPE) (DECLARE (SYSTEM::SOURCE-LEVEL #<# Hash Table{#} #>)) (DECLARE (HARLEQUIN-COMMON-LISP:LAMBDA-NAME INIT-ELEM)) (COMMON-LISP:LET (#) (COND # # # # # # # #)))>)) benv NIL tenv NIL decl NIL>). Is this typical? I tried just to used asdf to load it like I normally do, and when that didn't work I followed the instructions in the RELEASE-NOTES. Both time I got the same error. Any advice on how to fix this? I'm running LispWorks 4.4.5 on Mac OS X. Thanks! Regards, Chris Dean |
From: Joel B. <jo...@ev...> - 2005-11-10 21:50:23
|
Note: I sent this message earlier to series-bugs, but it was held up for administrative approval. Raymond Toy asked that I resend to the list for archival purposes. ====================================================== Hi, When trying to load the system definition for series in a recent sbcl (0.9.5 linux x86-64), I get the following error: ### symbol SERIES:SERIES cannot be both the name of a type and the name of a declaration [Condition of type SB-KERNEL:DECLARATION-TYPE-CONFLICT-ERROR] See also: Common Lisp Hyperspec, 3.8.21 [section] ### It looks like the change added to sbcl that causes this error to be thrown was added around the end of May. From the Changelog: ### 2005-05-31 23:06 jsnell * NEWS, package-data-list.lisp-expr, version.lisp-expr, src/code/condition.lisp, src/compiler/globaldb.lisp, src/pcl/boot.lisp: 0.9.1.9: Fix a few ansi-test failures. Symbols can't be both the name of a type and the name of a declaration (ANSI 3.8.21). ### Hope this information is useful. Thanks, Joel |
From: Dirk G. <di...@di...> - 2005-01-27 21:26:07
|
Raymond Toy <ray...@er...> writes: > I've checked in the changes. Let me know how it goes. (Might have to > wait a day for anoncvs to catch up.) Oh I forgot to ask: should I create a CVS snapshot package for Gentoo Linux, or will these changes be in an official release in the foreseeable future? Kind regards, Dirk Gerrits |