Singly-linked list/Element insertion: Difference between revisions

→‎{{header|jq}}: def insert($x):
(Added Odin variant)
(→‎{{header|jq}}: def insert($x):)
Line 1,447:
 
def insert($x):
if is_empty_singly_linked_list then {item: $x, next: null}
.next |= new($x; .);</syntaxhighlight>
else .next |= new($x; .)
.next |= new($x; .)end;</syntaxhighlight>
'''An example''':
<syntaxhighlight lang="jq">
2,442

edits