1. Creating a sequence from integers
- Posted by Rich Klender <rklender at excite.com> Feb 15, 2007
- 430 views
- Last edited Feb 16, 2007
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
2. Re: Creating a sequence from integers
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 15, 2007
- 411 views
- Last edited Feb 16, 2007
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
3. Re: Creating a sequence from integers
- Posted by don cole <doncole at pacbell.net> Feb 15, 2007
- 449 views
- Last edited Feb 16, 2007
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