Are Lists just a hack to represent sequences functionally?
Are Lists just a hack to represent sequences functionally?
I'm very interested in functional programming as a way to represent abstractions without lying as to what they truly are for convenience. Something feels off to me about lists (in the way they are recursively defined in functional programming).
Why do functional programming languages generally have lists defined with an Empty
case? Is a collection of things really a sum-type? Or is my conception of a list separate from what this is:
Empty
type List = Empty | Element head (List tail)
I know that pattern matching makes the above safe to do, but to me it seems analogous to making all types Option types by default.
Is there a term for the right-hand side of this List
definition?
List
Also is this List
something from Mathematics? Are we representing things which are truly sequences as lists for convenience?
List
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.