If I look at
https://github.com/hemmecke/fricas-svn/blob/master/src/algebra/stream.spad.pamphlet#L552
I read...

"A stream is an implementation of an infinite sequence ..."

The documentation clearly doesn't match the implementation.

Ralf

On 06/06/2011 08:05 PM, Martin Rubey wrote:
Xiaojun Liu<[email protected]>  writes:

Hi,

    I have two Stream of integers, called s1 and s2. I want to
add their corresponding elements to form a new stream called s.
I use map(f,x,y) to do this, but the result is unexpected if s1 is
actually a finite stream, i.e.

(1) ->  s1 := [i for i in 1..3] :: Stream INT

    (1)  [1,2,3]
                                                         Type: Stream(Integer)
(2) ->  s2 := [j for j in 1..] :: Stream INT

    (2)  [1,2,3,4,5,6,7,8,9,10,...]
                                                         Type: Stream(Integer)
(3) ->  map(+, s1, s2)

    (3)  [2,4,6]
                                                         Type: Stream(Integer)

But I want the result :  [2,4,6,4,5,6,7,8,9,10,...].
Is there any simple way to do this?

Do I have to append s1 to a infinite stream by letting the rest
elements all be 0 manually?

I think that's the way to go.  It's not that bad:

[i+j for i in concat(s1, repeating [0]) for j in s2]

Martin


--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to