Singly-linked list/Element insertion: Difference between revisions
Singly-linked list/Element insertion (view source)
Revision as of 12:43, 20 June 2023
, 11 months ago→{{header|ooRexx}}: corrected linkedlist to list and added output
(→{{header|jq}}: def insert($x):) |
Walterpachl (talk | contribs) (→{{header|ooRexx}}: corrected linkedlist to list and added output) |
||
Line 1,654:
See [[Singly-linked_list/Element_definition#ooRexx|Single-linked list/Element definition]] for full class definition.
<syntaxhighlight lang="oorexx">
list = .
index = list~insert("abc") -- insert a first item, keeping the index
Call show
list~insert("def") -- adds to the end
Call show
list~insert("123", .nil) -- adds to the begining
Call show
list~insert("456", index) -- inserts between "abc" and "def"
Call show
list~remove(index) -- removes "abc"
Call show
</syntaxhighlight>▼
exit
show:
s=''
Do x over list
s=s x
end
say s
▲Return</syntaxhighlight>
{{out]]
<pre> abc
abc def
123 abc def
123 abc 456 def
123 456 def
</pre>
=={{header|Pascal}}==
|