<commit_before>Data Types
==========

### Primitive Types

#### Integer

An integer could be represented in these ways:

1. tranditional notation

    It starts with optional + or - sign, a non-zero digit, and then other digits. E.g. -101, 987654321, +2016.

2. Octal notation

    Literals starting with a zero are interpreted as octal numbers. For example, the octal 040 is 32 in the usual base-10 notation.

3. Hexadecimal notation

    Just as in most languages, typical hexadecimal notation is supported. 0xff is 255, 0xd055 is 53333, and so on.

4. Flexible numeral bases

    You can specify the base of an integer in a prefix BrN, where N is the digits that represent the desired number, and B is the base or radix by which N should be interpreted. So we can use a prefix of 2r for binary integers (2r111 is 7), 16r for hexadecimal (16rff is 255), and so on. This is supported up to base 36.

All integers will be transformed to Erlang Integers, so they are big number integers and could have arbitrary big value.

Also notice that there is no literal syntax for rational numbers, which is quite common in Lisp dialects.

#### Float

A floating-point number has five parts: an optional sign, a whole number part, a decimal point, a fractional part, and an optional exponent part.

Here are some examples of floats:

```clojure
1.0
3.14159
-2.3e+6
23.56E-27
```

All floating-point numbers are transformed to Erlang floating-point numbers, which is internally in IEEE 754 64-bit format, and limited in the range 10^-323 to 10^308.

#### Char

A single character literal could be represented in either `$c`, `$\xhh` or `$\x{hhhhhh}`.

`$c` is for special escape charactor and other printable ascii character. There are a few special escape chars as listed below:

| char | stands for | integer value(in decimal) |
| --- | --- | --- |
| $\a | bell | 7 |
| $\b | backspace | 8 |
| $\d | delete | 127 |
| $\e | escape | 27 |
| $\f | form feed | 12 |
| $\n | line feed | 10 | 
| $\r | carriage return | 13 |
| $\s | space | 32 |
| $\t | horizontal tab | 9 |
| $\v | vertical tab | 11 |
| $\x | the prefix of hexadecimal format char(described below) | |

These escape chars are also available in string literal, e.g., it's written `"\n\t"` if you need a binary string which consist of one line feed character and then one horizontal tab.

`\xhh` is the hexadecimal format for ascii characters, e.g. `\xa` is a line feed character with value 10 in base-10 notation. And `\x41` is char 'A'.

`\x{hhhhhh}` is for utf8 character. You could put 1-6 hexadecimal digit(0-9, a-f, A-F) inside `{}` to represent a code point in utf8 encoding.

#### String

There are two string types: character list, binary string.

In Erlang, string is represented by character list. so you could get this in interative shell

```Erlang
> "hello" == [$h, $e, $l, $l, $o].<commit_msg>fix docs<commit_after>Data Types
==========

### Primitive Types

#### Integer

An integer could be represented in these ways:

1. tranditional notation

    It starts with optional + or - sign, a non-zero digit, and then other digits. E.g. -101, 987654321, +2016.

2. Octal notation

    Literals starting with a zero are interpreted as octal numbers. For example, the octal 040 is 32 in the usual base-10 notation.

3. Hexadecimal notation

    Just as in most languages, typical hexadecimal notation is supported. 0xff is 255, 0xd055 is 53333, and so on.

4. Flexible numeral bases

    You can specify the base of an integer in a prefix BrN, where N is the digits that represent the desired number, and B is the base or radix by which N should be interpreted. So we can use a prefix of 2r for binary integers (2r111 is 7), 16r for hexadecimal (16rff is 255), and so on. This is supported up to base 36.

All integers will be transformed to Erlang Integers, so they are big number integers and could have arbitrary big value.

Also notice that there is no literal syntax for rational numbers, which is quite common in Lisp dialects.

#### Float

A floating-point number has five parts: an optional sign, a whole number part, a decimal point, a fractional part, and an optional exponent part.

Here are some examples of floats:

```clojure
1.0
3.14159
-2.3e+6
23.56E-27
```

All floating-point numbers are transformed to Erlang floating-point numbers, which is internally in IEEE 754 64-bit format, and limited in the range 10^-323 to 10^308.

#### Char

A single character literal could be represented in either `$c`, `$\xhh` or `$\x{hhhhhh}`.

`$c` is for special escape charactor and other printable ascii character. There are a few special escape chars as listed below:

| char | stands for | integer value(in decimal) |
| --- | --- | --- |
| $\a | bell | 7 |
| $\b | backspace | 8 |
| $\d | delete | 127 |
| $\e | escape | 27 |
| $\f | form feed | 12 |
| $\n | line feed | 10 | 
| $\r | carriage return | 13 |
| $\s | space | 32 |
| $\t | horizontal tab | 9 |
| $\v | vertical tab | 11 |
| $\x | the prefix of hexadecimal format char(described below) | |

These escape chars are also available in string literal, e.g., it's written `"\n\t"` if you need a binary string which consist of one line feed character and then one horizontal tab.

`$\xhh` is the hexadecimal format for ascii characters, e.g. `$\xa` is a line feed character with value 10 in base-10 notation. And `$\x41` is char 'A'.

`$\x{hhhhhh}` is for utf8 character. You could put 1-6 hexadecimal digit(0-9, a-f, A-F) inside `{}` to represent a code point in utf8 encoding.

#### String

There are two string types: character list, binary string.

In Erlang, string is represented by character list. so you could get this in interative shell

```Erlang
> "hello" == [$h, $e, $l, $l, $o].
{'fraction_non_alphanumeric': 0.10005247507433969, 'fraction_numerical': 0.04093055798495714, 'mean_word_length': 3.481191222570533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4703233', 'n_tokens_mistral': 1917, 'n_tokens_neox': 1697, 'n_words': 888}