1. Creating a sequence from integers

This is probably very basic but it's stumping me.

Lets say I have the following:

integer x
integer y

x=1
y=1

What I want is to combine them in the sequence {11}.  Can I just do this by
assigning them to a variable:

sequence combined = {xy}

Sorry, looked all thru the manual and couldn't find a representative example.

Thanks!
Rich

new topic     » topic index » view message » categorize

2. Re: Creating a sequence from integers

Rich Klender wrote:
> 
> This is probably very basic but it's stumping me.
> 
> Lets say I have the following:
> 
> integer x
> integer y
> 
> x=1
> y=1
> 
> What I want is to combine them in the sequence {11}.  Can I just do this by
> assigning them to a variable:
> 
> sequence combined = {xy}

To join arbitary sized integers, this might be what you're after ...

  -- Convert to strings and concatenate them
  combined = sprintf("%d", x) & sprintf("%d", y)
  -- Convert the combined string into an integer
  combined = value(combined)
  -- Extract the resulting integer and place it in a sequence
  combined = {integer(combined[2])} -- this might fail if result is too big

  -- Thus x=12 and y=9876 gives {129876}

-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view message » categorize

3. Re: Creating a sequence from integers

Rich Klender wrote:
> 
> This is probably very basic but it's stumping me.
> 
> Lets say I have the following:
> 
> integer x
> integer y
> 
> x=1
> y=1
> 
> What I want is to combine them in the sequence {11}

{1,1}

.  Can I just do this by
> assigning them to a variable:
> 
> sequence combined = {xy}
  {x,y}
> 
> Sorry, looked all thru the manual and couldn't find a representative example.
> 
> Thanks!
> Rich


 integer x,y
 sequence combined

 x=1
 y=2
 combined={x,y}

 --combined[1]would =1
 --combined[2]would =2


  David Gay's tutorial goes into this quit extensivly.

Hope this helps,


Don Cole

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu