|
|
precise, logical types
term | description | Python type | Python expressions* |
primitive types |
boolean | | int | 1, 0, 1==0 |
integer | | int,long | 0, 1, 2, -1 |
floating point | | float | 2.718, -1.0 |
string | | string | "3 is the best number!" |
none | trivial type with just 1 value | None | None |
void | type with no values | None | mylist.append(123) |
the indiscriminate type | | | input: function from string to action returning the indiscriminate type |
derived types |
tuple of | | | ("hello", "my", "name", "is", "Phil", "."): tuple of string (11, 16, 18, 50, 52): tuple of integer |
list of | | | ["hello", "my", "name", "is", "Phil", "."]: list of string [11, 16, 18, 50, 52]: list of integer |
function from to | | | string.atoi: function from string to integer
car: for all t, function from list of t to t |
action returning | | | put-newline: action returning the trivial type
random.choice: for all e, function from (list of e) to action returning e |
and | | | subst: for all t, function from (t and t and (list of t)) to (list of t) |
or | | | talky: function from the indiscriminate type to (boolean or the trivial type) |
quantified types |
for all type-parameter, | | | cons: for all t, function from (t and (list of t)) to (list of t) |
*: some of the later examples are of Scheme functions rather than Python.
|