Singly-linked list/Element definition: Difference between revisions

m
Spelling/grammar/aesthetics
m (Changed over to headers.)
m (Spelling/grammar/aesthetics)
Line 1:
{{task}}[[Category:Data Structures]]Define the data structure for a [[singly-linked list]] element. Said element should contain a data member capable of holding a numeric value, and the link to the next element should be mutable.
{{task}}
[[Category:Data Structures]]
Define the data structure for a [[singly-linked list]] element. Said element should contain a data member capable of holding a numeric value, and the link to the next element should be mutable.
 
=={{header|Ada}}==
Line 60 ⟶ 58:
=={{header|Delphi}}==
 
A simple one way list. I use a generic pointer for the data that way it can point to any structure, individual variable or whatever. Note that in Standard Pascal, there are no generic pointers, therefore one has to settle for a specific data type there.
 
Type
Line 109 ⟶ 107:
=={{header|Haskell}}==
 
This task is not idiomatic for Haskell. Usually, all data in pure functional programming is immutable, and deconstructed through [[Pattern Matching]]. The Prelude already contains a parametrically polymorphic list type that can take any data member type, including numeric values. These lists are then used very frequently. Because of this, lists have additional special syntactic sugar.
This task is not idiomatic for Haskell. Usually, all data
in pure functional programming is immutable, and deconstructed through [[Pattern Matching]]. The Prelude already contains a parametrically polymorphic list type that can take any data member type, including numeric values. These lists are then used very frequently. Because of this, lists have additional special syntactic sugar.
 
An equivalent declaration for such a list type without the special syntax would look like this:
Line 152 ⟶ 149:
l2 =>
 
If however one wants to definiedefinite equivalent user-defined type, one can do this:
can do this:
 
uses objectclass;
Anonymous user