Re: Integer() operation on a sequence?
>From: Derek Parnell <guest at RapidEuphoria.com>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: Re: Integer() operation on a sequence?
>Date: Sat, 05 Jun 2004 18:02:04 -0700
>
>Michael Raley wrote:
> > not too suprisingly I cannot do this
> >
> > s = integer({0.12321,0.44343,1,1,0.555})
> > - s becomes {0,0,1,1,0}
>
That is not what integer() is for. Obviously, you cannot do that.
>What were you expecting to achieve?
>
>** Did you wish to convert each of the elements into an integer?
> seq s s = floor({0.12321,0.44343,1,1,0.555})
>
>** Did wish to see if each element was an integer?
> seq s s = integer({0.12321,0.44343,1,1,0.555})
>
You'd need a for-loop for that one, Derek. You'll get a type-check error
because integer() will return 0.
>** Did you wish to see if the entire paramter was an integer?
> integer s if integer({0.12321,0.44343,1,1,0.555}) then
> s = 1 else s = 0 end if
>
>** Did you wish to convert the entire parameter into a single integer?
> sequence s s = value({0.12321,0.44343,1,1,0.555})
>
Uh... What?
>
>
> > So howabout?
> > s = integers({sequence})
>
>What is supposed to return? The number of integers in the sequence?
>
> s = integer (x)
> y = 0
> for i = 1 to length(x)
> y += x[i]
> end for
>
That would give you the sum of the values in the sequence. I'm not sure what
s if for either. You mean:
y = 0
for i = 1 to length(x) do
y += integer(x[i])
end for
> > Secondly; a sequence summation operator
> > i= ~sigma ({sequence s from above})
> > i = 2
>
Don't use the tilde! I wanted that for ignoring return values of
functions. That's a whole other topic which could be discussed in another
thread. As Derek said, though, you don't need a new operator for such a
thing.
>
[stuff written that I didn't comment on]
>
~[ WingZone ]~
http://wingzone.tripod.com/
|
Not Categorized, Please Help
|
|