
-----------------------------------
cavetroll
Fri Oct 05, 2007 3:55 pm

Types?
-----------------------------------
ok I know how to use types fairly well but I am running into one main issue and I'm not sure if its resolvable

heres what I want to do

type node :
record
x : int
y : int
parent : node
end record


Is it possible to do this? If so what code do I need to add?

-----------------------------------
CodeMonkey2000
Fri Oct 05, 2007 4:29 pm

RE:Types?
-----------------------------------
Are you trying to make a linked list?

-----------------------------------
Cervantes
Fri Oct 05, 2007 5:34 pm

RE:Types?
-----------------------------------
I think for this you have to use another construction, called collections. There are examples in the [url=http://compsci.ca/v3/viewtopic.php?t=9284]linked list tutorial.

-----------------------------------
richcash
Fri Oct 05, 2007 9:04 pm

Re: Types?
-----------------------------------
I think you can still use type you just need a pointer :
type node : 
   record 
      x : int 
      y : int 
      parent : ^node 
   end record

But I no longer have Turing so I'm not sure. :)

-----------------------------------
Saad
Fri Oct 05, 2007 9:14 pm

RE:Types?
-----------------------------------
Yes that is correct, to declare a node you would have to do

var moo : ^node
% Create a  new node and assign the memmory to the pointer
new moo


At the end 

% Free the memmory assigned
free moo


-----------------------------------
cavetroll
Fri Oct 05, 2007 9:29 pm

RE:Types?
-----------------------------------
Yes I am trying to create a linked list thanks for all the help, that tutorial helped lots. I would have responded quicker to save some of you the trouble of posting but I was out. Sorry

Again thanks for the help
