Singly-linked list/Element definition: Difference between revisions
Content added Content deleted
m (Moved to Data struct cat) |
(Logo) |
||
Line 162: | Line 162: | ||
Link(T a_data, Link<T> a_next) { next = a_next; data = a_data; } |
Link(T a_data, Link<T> a_next) { next = a_next; data = a_data; } |
||
} |
} |
||
=={{header|Logo}}== |
|||
As with other list-based languages, simple lists are represented easily in Logo. |
|||
fput item list ; add item to the head of a list |
|||
first list ; get the data |
|||
butfirst list ; get the remainder |
|||
bf list ; contraction for "butfirst" |
|||
These return modified lists, but you cal also destructively modify lists. These are normally not used because you might accidentally create cycles in the list. |
|||
.setfirst list value |
|||
.setbf list remainder |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |