View previous topic :: View next topic |
Author |
Message |
Ripley Beginner
Joined: 30 Mar 2005 Posts: 15 Topics: 8
|
Posted: Sun Apr 30, 2006 9:17 pm Post subject: Rexx how to implement linkedlist data structure? |
|
|
hello everybody:
i hava not study for a period
i so miss this place which for mvs
i change to write java last three month for my company
now , i change again
i need to study rexx
i read the book Rexx Programmer's Reference (Wiley)
i hava a question that
Rexx has its special feature abouy array which is
called ''compound variables"
i don't know how to implement linkedlist data structure
because this is so different from other language
Does any one know it?
http://www.amazon.com/gp/product/0764579967/sr=1-1/qid=1146449456/ref=sr_1_1/104-7996049-5490334?%5Fencoding=UTF8&s=books |
|
Back to top |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Sun Apr 30, 2006 10:07 pm Post subject: |
|
|
Rexx does not really handle that type of data structure directly. You can simulate it using stem variables but there is rarely a need to do that.
One way to simulate a linked list is something like this. It is not easy to read or maintain and worst of all, the way this is written, it depends on Rexx's automatic assignment of unassigned variables to the name of the variable, so if your program uses any of the tail segments as variable names, it can break. You can code around that without to much difficulty, but it makes the code almost impossible to read because it would probably use the interpret or value() functions a great deal... Code: | link. = 'null'
link.id1.value = 'something'
link.id1.next = id2
link.id2.value = 'something else'
link.id2.next = id3
link.id3.value = 'something more'
link.id3.next = 'null' /* End of list */
/* Insert an element */
link.newelement.value = 'inserted item'
link.newelement.next = link.id1.next
link.id1.next = newelement
/* Traverse the list */
id = id1
Do While id <> 'null'
Say link.id.value
id = link.id.next
End
|
The more important question for you is, What type of problem are you trying to solve? Rather than assuming a solution that is applicable to other programming languages, it is best to start with the problem. |
|
Back to top |
|
|
Ripley Beginner
Joined: 30 Mar 2005 Posts: 15 Topics: 8
|
Posted: Sun Apr 30, 2006 10:59 pm Post subject: |
|
|
thanks semigeezer:
Your idea is good
i can insert data by this way
What type of problem i try to solve?
Because i need to maintain a ca7 job flow chart
it is a dirty work (i hate it )
it looks like a tree
i need to paint it on a text file
(other depatment people need to read the files to work)
so i want to evaluate can i write prog to automate this work
Maybe i can add link.id1.before ......
summary, this way is like two commands of the ca7
FSTRUC
FRJOB
anyone has other idea |
|
Back to top |
|
|
|
|