From: Szymon 'tichy'
Subject: strange behavior of SERIES function.
Date: 
Message-ID: <f6nm65$3f8$1@nemesis.news.tpi.pl>
Hi. I'm playing with series:

CL-USER> (positions #Z#0=(t nil . #0#))		OK.
#Z(0 2 4 6 8 10 12 14 16 18 ...)

CL-USER> (positions (series t nil))		WTF ?
#Z(0 1 3 4 6 7 9 10 12 13 ...)

CL-USER> (series t nil)				O_o
#Z(LIST T NIL LIST T NIL LIST T NIL LIST ...)

I have latest (2.2.9) SERIES relase... is this newly introduced bug ?

From: Raymond Toy
Subject: Re: strange behavior of SERIES function.
Date: 
Message-ID: <sxdhcodxokk.fsf@rtp.ericsson.se>
>>>>> "Szymon" == Szymon  <'tichy' <········@glombraz.org>> writes:

    Szymon> Hi. I'm playing with series:

    CL-USER> (positions #Z#0=(t nil . #0#))		OK.
    Szymon> #Z(0 2 4 6 8 10 12 14 16 18 ...)

    CL-USER> (positions (series t nil))		WTF ?
    Szymon> #Z(0 1 3 4 6 7 9 10 12 13 ...)

    CL-USER> (series t nil)				O_o
    Szymon> #Z(LIST T NIL LIST T NIL LIST T NIL LIST ...)

    Szymon> I have latest (2.2.9) SERIES relase... is this newly introduced bug ?

Neat.  

I notice that

(collect (choose (series t nil) (scan-range :below 20)))

returns something sensible:

(0 2 4 6 8 10 12 14 16 18)

I'm not sure what this all means, though.

Ray
From: Raymond Toy
Subject: Re: strange behavior of SERIES function.
Date: 
Message-ID: <sxdd4z0xia9.fsf@rtp.ericsson.se>
>>>>> "Szymon" == Szymon  <'tichy' <········@glombraz.org>> writes:

    Szymon> Hi. I'm playing with series:

    CL-USER> (positions #Z#0=(t nil . #0#))		OK.
    Szymon> #Z(0 2 4 6 8 10 12 14 16 18 ...)

    CL-USER> (positions (series t nil))		WTF ?
    Szymon> #Z(0 1 3 4 6 7 9 10 12 13 ...)

    CL-USER> (series t nil)				O_o
    Szymon> #Z(LIST T NIL LIST T NIL LIST T NIL LIST ...)

    Szymon> I have latest (2.2.9) SERIES relase... is this newly introduced bug ?

From looking at the history, this bug has been there since the
beginning.

I think I have this fixed now, so please grab the CVS version.  With
that version, I get:

CL-USER> (positions (series t nil))
#Z(0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 ...)
CL-USER> (series t nil)
#Z(T NIL T NIL T NIL T NIL T NIL T NIL T NIL T NIL T NIL T NIL ...)
CL-USER> (choose (series t nil) (scan-range :below 20))
#Z(0 2 4 6 8 10 12 14 16 18)
CL-USER> (collect (choose (series t nil) (scan-range :below 20)))
(0 2 4 6 8 10 12 14 16 18)

These look right to me.

Thanks for pointing this out,

Ray
From: Szymon 'tichy'
Subject: Re: problem with literal, cyclic series (was: strange behavior of SERIES function).
Date: 
Message-ID: <f70lhq$5lr$1@atlantis.news.tpi.pl>
Many thanks :)

If you are interested, there is another problem ;)

function below works as intended:

(defun join-strings (strings &key (delimiter ","))
   (collect-append 'string (spread (catenate #Z(0) (series 1))
                                   (scan strings)
                                   (string delimiter))))

CL-USER> (join-strings '("foo" "bar" "baz"))
"foo,bar,baz"

but if I replace CATENATE with literal series:

CL-USER> (setq *print-length* 11)	===>   11

CL-USER> (catenate #Z(0) (series 1))	===> #Z(0 1 1 1 1 1 1 1 1 1 1 ...)

CL-USER> #Z(0 . #0=(1 . #0#))		===> #Z(0 1 1 1 1 1 1 1 1 1 1 ...)

this function won't work (tested with 2.2.9, not CVS)

(defun join-strings (strings &key (delimiter ","))
   (collect-append 'string (spread #Z(0 . #0=(1 . #0#))
                                   (scan strings)
                                   (string delimiter))))

I think it is a bug but not important one.
Cyclic literals are rarities, aren't they ?

Regards, Szymon.
From: Raymond Toy
Subject: Re: problem with literal, cyclic series (was: strange behavior of SERIES function).
Date: 
Message-ID: <sxd4pkcx9ws.fsf@rtp.ericsson.se>
>>>>> "Szymon" == Szymon  <'tichy' <········@glombraz.org>> writes:

    Szymon> Many thanks :)

    Szymon> If you are interested, there is another problem ;)

Problems are always interesting.  Solutions, on the other hand,
.... :-)

    Szymon> this function won't work (tested with 2.2.9, not CVS)

    Szymon> (defun join-strings (strings &key (delimiter ","))
    Szymon>   (collect-append 'string (spread #Z(0 . #0=(1 . #0#))
    Szymon>                                   (scan strings)
    Szymon>                                   (string delimiter))))

    Szymon> I think it is a bug but not important one.

I'm not 100% sure, but I think the compiler/interpreter is getting
stuck here because it's trying to process the literal which is
infinite.  You don't have that problem in the previous version because
series isn't trying to process the literal infinite series but is
processing the code that would produce the infinite series.

I'll try to fix it but it's not nearly as important as the previous
bug you mentioned.

    Szymon> Cyclic literals are rarities, aren't they ?

I rarely ever use them.

Ray