site/contents/learn-data-types.md
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
-----
content-type: "page"
title: "Learn: Data Types"
-----
{@ _defs_.md || 0 @}
The type system of min is very simple -- only the following data types are available:
integer
: An integer number like 1, 27 or -15.
float
: A floating-point number like 3.14 or -56.9876.
string
: A series of characters wrapped in double quotes: "Hello, World!".
quotation
: A list of elements, which may also contain symbols. Quotations can be be used to create heterogenous lists of elements of any data type, and also to create a block of code that will be evaluated later on (quoted program).
Additionally, quotations structured in a particular way can be used as dictionaries, and a few operators are available to manage them more easily (`dhas?`, `dget`, `ddel` and `dset`). A dictionary is a quotation containing zero or more quotations of two elements, the first of which is a string that has not already be used in any of the other inner quotations.
> %sidebar%
> Example
>
> The following is a simple dictionary containing three keys: *name*, *paradigm*, and *first-release-year*:
>
> (
> ("name" "min")
> ("paradigm" "concatenative")
> ("first-release-year" 2017)
> )
The {#link-module||logic#} provides predicate operators to check if an element belong to a particular data type or pseudo-type (`boolean?`, `number?`, `integer?`, `float?`, `string?`, `quotation?`, `dictionary?`).
Additionally, the {#link-module||lang#} provides operators to convert values from a data type to another (e.g. {#link-operator||lang||int#}, {#link-operator||lang||string#}, and so on).
> %note%
> Note
>
> Most of the operators defined in the {#link-module||num#} are able to operate on both integers and floats.
{#link-learn||operators||Operators#}
|