I'm learning about TAD but, I don't understand so much the syntax, that's why its too difficult to me to create a single list, but i understand how it works such as TAD, please, someone can tell how to implement this TAD(Linked List), with basic instructions and describing them
abstract type AbstractList{T} end
abstract type AbstractNode{T} end
mutable struct Nodo{T} <: AbstractNode{T}
value ::T
next ::Nodo{T}
Nodo{T}() where T =(x=new();x;x.next=x)
Nodo{T}(v,n) where T =new(v,n)
end
mutable struct LList{T} <: AbstractList{T}
first ::Nodo{T}
LList{T}() where T =new(Nodo{T}())
end
Lista=LList;
function Append(lista,value)
current=Nodo(value,new(Nodo()))
if Lista.size==0
lista.head=current
else
MyNode=Lista.first;
while MyNode.next!=nothing
MyNode=MyNode.next;
MyNode.next=current;
end
end
Lista.size+=1
end
Append(Lista,2)
I'm trying this, but i don't know why it doesn't works, I'm getting confused because i was reading many posts about the instructions that I used, but I don't understand Nodo{T}() where T =(x=new();x;x.next=x) this instruction at all, I need help.