Re: append and &

new topic     » goto parent     » topic index » view thread      » older message » newer message

thanks Derek....

george
----- Original Message -----
From: "Derek Parnell" <ddparnell at bigpond.com>
To: "EUforum" <EUforum at topica.com>
Subject: Re: append and &


>
> ----- Original Message -----
> From: "George Walters" <gwalters at sc.rr.com>
> To: "EUforum" <EUforum at topica.com>
> Sent: Thursday, March 21, 2002 10:43 PM
> Subject: append and &
>
>
> > Can someone explain the difference between these two statements
> > -----------------------------
> > sequence a
> > a = "a"
> > for i = 1 to 10
> >     a = append(a,"a")
> > end for
> > ----------------------------
> > sequence a
> > a = "a"
> > for i = 1 to 10
> >     a = a & "a"
> > end for
> > ----------------------------
> >
> > I'm having some conceptual confusion with results from above as compared
> > with 'vectors', 'matrices' from prior languages.
>
>
> append() always increases the result by exactly one element.
>
> & always increases the results by the length of the source.
>
> In both cases, atoms are considered to have a length of 1 for this
exercise.
>
> Thus a = append(b, c) always adds a single element, c, as a new element to
> the end of b.
>   eg:
>
>     a = {1,2,3}
>     a = append(a,a)
>       ==> {1,2,3,{1,2,3}} The length increases by 1.
>     a = append(a,a)
>       ==> {1,2,3,{1,2,3},{1,2,3,{1,2,3}}} The length increases by 1.
>
> And a = b & c always just joins c to the back of b, increasing the length
by
> how ever long c is.
>
>     a = {1,2,3}
>     a = a & a
>       ==> {1,2,3,1,2,3} The length increases by 3.
>     a = a & a
>       ==> {1,2,3,1,2,3,1,2,3,1,2,3} The length increases by 6.
>
> For sequences,  a = append(a,a) is equivalent to  a &= {a}
>
> For atoms, a = append(a,a) is equivalent to a &= a.
>
> -----------
> Derek.
>
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu