Changeset 35897fb for doc/theses/jiada_liang_MMath/relatedwork.tex
- Timestamp:
- May 1, 2024, 1:36:04 PM (2 months ago)
- Branches:
- master
- Children:
- d414664
- Parents:
- de3a579 (diff), 69867ad9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/relatedwork.tex
rde3a579 r35897fb 12 12 The definition of member types and their constructors are from the outer lexical scope. 13 13 14 In general, an \ Newterm{algebraic data type} (ADT) is a composite type, \ie, a type formed by combining other types.15 Three common classes of algebraic types are \ Newterm{array type}, \ie homogeneous types, \Newterm{product type}, \ie heterogeneous tuples and records (structures), and \Newterm{sum type}, \ie tagged product-types (unions).14 In general, an \newterm{algebraic data type} (ADT) is a composite type, \ie, a type formed by combining other types. 15 Three common classes of algebraic types are \newterm{array type}, \ie homogeneous types, \newterm{product type}, \ie heterogeneous tuples and records (structures), and \newterm{sum type}, \ie tagged product-types (unions). 16 16 Enumerated types are a special case of product/sum types with non-mutable fields, \ie initialized (constructed) once at the type's declaration, possible restricted to compile-time initialization. 17 17 Values of algebraic types are access by subscripting, field qualification, or type (pattern) matching. … … 51 51 \section{Ada} 52 52 53 An Ada enumeration type is a set of ordered unscoped identifiers (enumerators) bound to \emph{unique} \ Newterm{literals}.\footnote{%53 An Ada enumeration type is a set of ordered unscoped identifiers (enumerators) bound to \emph{unique} \newterm{literals}.\footnote{% 54 54 Ada is \emph{case-insensitive} so identifiers may appear in multiple forms and still be the same, \eg \lstinline{Mon}, \lstinline{moN}, and \lstinline{MON} (a questionable design decision).} 55 55 \begin{ada} … … 2177 2177 Here, function @take_class@ has a @weekday@ parameter, and returns @"CS442"@, if the weekday value is @Mon@ or @Wed@, @"CS343"@, if the value is @Tue@ or @Thu@, and @"Tutorial"@ for @Fri@. 2178 2178 The ``@_@'' is a wildcard matching any @weekday@ value, so the function returns @"Take a break"@ for values @Sat@ or @Sun@, which are not matched by the previous cases. 2179 Since the variant has no type, it has a \ Newterm{0-arity constructor}, \ie no parameters.2180 Because @weekday@ is a union of values @Mon@ to @Sun@, it is a \ Newterm{union type} in turns of the functional-programming paradigm.2179 Since the variant has no type, it has a \newterm{0-arity constructor}, \ie no parameters. 2180 Because @weekday@ is a union of values @Mon@ to @Sun@, it is a \newterm{union type} in turns of the functional-programming paradigm. 2181 2181 2182 2182 Each variant can have an associated heterogeneous type, with an n-ary constructor for creating a corresponding value. … … 2202 2202 type @stringList@ = Empty | Pair of string * @stringList@ 2203 2203 \end{ocaml} 2204 which is a recursive sum of product of types, called an \ Newterm{algebraic data-type}.2204 which is a recursive sum of product of types, called an \newterm{algebraic data-type}. 2205 2205 A recursive function is often used to pattern match against a recursive variant type. 2206 2206 \begin{ocaml}
Note: See TracChangeset
for help on using the changeset viewer.