From: Jan Rychter
Subject: Series question
Date: 
Message-ID: <m28ysn98w1.fsf@tnuctip.rychter.com>
I'm puzzled. I have a function:

(defun sum-of-signs (s d)
  (let ((returns (map-fn 'float #'-
			 (subseries s 0 d)
			 (subseries s 1 (+ d 1)))))
    (collect-fn 'float
	      #'(lambda () 0)
	      #'(lambda (v1 v2)
		  (+ v1 (signum v2)))
	      returns)))


which doesn't work correctly. I get a warning:


  Warning 28 in series expression:
  (COLLECT-FN 'FLOAT
              #'(LAMBDA () 0)
              #'(LAMBDA (V1 V2) (+ V1 (SIGNUM V2)))
              RETURNS)
  Non-series to series data flow from:
  RETURNS
  to:
  (COLLECT-FN 'FLOAT
              #'(LAMBDA () 0)
              #'(LAMBDA (V1 V2) (+ V1 (SIGNUM V2)))
              RETURNS)
  
  ; In: LAMBDA (#:G1159)
  
  ;   (COLLECT-FN 'FLOAT #'(LAMBDA # 0) #'(LAMBDA # #) RETURNS)
  ; Warning: 
  ; 


And the return value is 0 for my test cases.

Testing the collect-fn form with sample data generated by (scan '(1 2
3)) gives correct results. But somehow collect-fn won't accept the
series data returned by map-fn, even though setting a breakpoint and
checking (type-of returns) gives the expected SERIES::BASIC-SERIES.

What am I doing wrong?

--J.
PS: CMUCL-18e.
From: Joe Marshall
Subject: Re: Series question
Date: 
Message-ID: <ENVBa.58459$_t5.46954@rwcrnsc52.ops.asp.att.net>
"Jan Rychter" <···@rychter.com> wrote in message ···················@tnuctip.rychter.com...
> I'm puzzled. I have a function:
>
> (defun sum-of-signs (s d)
>   (let ((returns (map-fn 'float #'-
> (subseries s 0 d)
> (subseries s 1 (+ d 1)))))
>     (collect-fn 'float
>       #'(lambda () 0)
>       #'(lambda (v1 v2)
>   (+ v1 (signum v2)))
>       returns)))
>
>
> which doesn't work correctly. I get a warning:
>
>
>   Warning 28 in series expression:
>   (COLLECT-FN 'FLOAT
>               #'(LAMBDA () 0)
>               #'(LAMBDA (V1 V2) (+ V1 (SIGNUM V2)))
>               RETURNS)
>   Non-series to series data flow from:
>   RETURNS
>   to:
>   (COLLECT-FN 'FLOAT
>               #'(LAMBDA () 0)
>               #'(LAMBDA (V1 V2) (+ V1 (SIGNUM V2)))
>               RETURNS)
>
>   ; In: LAMBDA (#:G1159)
>
>   ;   (COLLECT-FN 'FLOAT #'(LAMBDA # 0) #'(LAMBDA # #) RETURNS)
>   ; Warning:
>   ;
>
>
> And the return value is 0 for my test cases.

Your series is recursively referring to itself.  That can't
be optimized.