all repos — min @ 6cca020401008ab0a24987088c885ae8896e65b9

A small but practical concatenative programming language.

site/contents/_includes/_reference.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
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
{@ _defs_.md || 0 @}

min includes a small but powerful standard library organized into the following _modules_:

{#link-module||lang#}
: Defines the basic language constructs, such as control flow, symbol definition and binding, exception handling,  etc.
{#link-module||stack#}
: Defines combinators and stack-shufflers like dip, dup, swap, cons, etc.
{#link-module||seq#}
: Defines operators for quotations and dictionaries, like map, filter, reduce, etc.
{#link-module||io#}
: Provides operators for reading and writing files as well as printing to STDOUT and reading from STDIN.
{#link-module||fs#}
: Provides operators for accessing file information and properties. 
{#link-module||logic#}
: Provides comparison operators for all min data types and other boolean logic operators.
{#link-module||str#}
: Provides operators to perform operations on strings, use regular expressions, and convert strings into other data types.
{#link-module||sys#}
: Provides operators to use as basic shell commands, access environment variables, and execute external commands.
{#link-module||num#}
: Provides operators to perform simple mathematical operations on integer and floating point numbers.
{#link-module||time#}
: Provides a few basic operators to manage dates, times, and timestamps.
{#link-module||crypto#}
: Provides operators to compute hashes (MD5, SHA1, SHA224, SHA256, SHA384, sha512), base64 encoding/decoding, and AES encryption/decryption.

## Notation

The following notation is used in the signature of all min operators:

### Types and Values

{{null}}
: No value.
{{any}}
: A value of any type.
{{b}}
: A boolean value
{{i}}
: An integer value.
{{flt}}
: A float value.
{{n}}
: A numeric (integer or float) value.
{{s}}
: A string value.
{{sl}}
: A string-like value (string or quoted symbol).
{{q}}
: A quotation (also expressed as parenthesis enclosing other values).
{{d}}
: A dictionary value.
{{tinfo}}
: A timeinfo dictionary:
  <pre><code>(
    ("year" 2017)
    ("month" 7)
    ("day" 8)
    ("weekday" 6)
    ("yearday" 188)
    ("hour" 15)
    ("minute" 16)
    ("second" 25)
    ("dst" true)
    ("timezone" -3600)
  )
  </code></pre>
{{e}}
: An error dictionary:
  <pre><code>(
    ("error" "MyError")
    ("message" "An error occurred")
    ("symbol" "symbol1")
    ("filename" "dir1/file1.min")
    ("line" 3)
    ("column" 13)
  )
  </code></pre>
{{t}}
: true (boolean type).
{{f}}
: false (boolean type)

#### Floating point
Floating point in computers is always problematic. Min has three constants <code>nan</code>, <code>inf</code>, and <code>ninf</code> to deal with some of the edge cases and it implements a more forgiving equality check for floating point values to avoid rounding errors. This check also allows <code>nan</code> to be compared with any other <code>nan</code> and return true.

### Suffixes

The following suffixes can be placed at the end of a value or type to indicate ordering or quantities.

{{1}}
: The first value of the specified type.
{{2}}
: The second value of the specified type.
{{3}}
: The third value of the specified type.
{{4}}
: The fourth value of the specified type.
{{01}}
: Zero or one.
{{0p}}
: Zero or more.
{{1p}}
: One or more