2021 | OriginalPaper | Buchkapitel
10. Lists and Recursion
verfasst von : Donald Sannella, Michael Fourman, Haoran Peng, Philip Wadler
Erschienen in: Introduction to Computation
Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.
Wählen Sie Textabschnitte aus um mit Künstlicher Intelligenz passenden Patente zu finden. powered by
Markieren Sie Textabschnitte, um KI-gestützt weitere passende Inhalte zu finden. powered by
Abstract
[4,6,8]
is just shorthand for the expression 4:(6:(8:[]))
. So, every list can be written using :
and []
. In fact, every list can be written using :
and []
in just one way. That fact is what makes pattern matching work on lists. Given a list l and a pattern p built using variables, []
, :
and literals, there is at most one way to match p against l. That match gives values to the variables in p. It might not match, if p requires a list that’s longer than l, or if p contains a literal that doesn’t match the value in the corresponding position in l.