Updated smnp.lang (markdown)

Bartłomiej Przemysław Pluta
2020-04-01 21:16:40 +02:00
parent ac87b89839
commit 071d84946a

@@ -3,14 +3,14 @@ The `smnp.lang` module provides essential functions and methods that haven't bee
# Constructors
Constructors technically are nothing but functions. They just "emulate" real constructors from other general purpose programming languages that support object-oriented programming paradigm.
## Int
```
```php
Int(value: <int, float>)
```
Creates new `int` from other `int` or `float`.
The construction is typically used in other stdlib modules to round `float` types down.
#### Example
```
```php
x = 3.14;
y = Int(x);
@@ -19,7 +19,7 @@ println(y); # 3
```
## Note
```
```php
Note(pitch: string, octave: int, duration: int, dot: bool) #1
Note(pitch: string, octave: int, durNumerator: int, durDenominator: int) #2
```
@@ -44,7 +44,7 @@ durNumerator == 0.25 * durDenominator -> quarter note
* `durDenominator` - as above
#### Example
```
```php
x = Note("Eb", 3, 16, true);
y = Note("Eb", 3, 3, 32);
println(x == @Eb3:16d); # true
@@ -53,13 +53,13 @@ println(y == @Eb3:16d); # true
# Functions
## typeOf
```php
typeOf(item)
```
typeOf(object)
```
Returns the type name of passed object.
Returns the type name of passed item.
#### Example
```
```php
println(typeOf(14)); # integer
println(typeOf(@A#)); # note
println(typeOf([1, 2, 3])); # list
@@ -69,26 +69,26 @@ println(typeOf({ c -> @c, d -> @d })); # map
# Methods
## list.get
```
```php
list.get(index: int)
```
Returns list element of given index or throws error if index is greater than `list.size - 1`.
#### Example
```
```php
myList = [1, 2, 3, 4];
lastElement = myList.get(3);
println(lastElement); # 4
```
## map.get
```
```php
map.get(key: <int, note, string, bool>)
```
Returns map element associated with given key or throws an error if key doesn't exist in the map.
#### Example
```
```php
myMap = {
true -> false,
@Eb3:2d -> 14,
@@ -100,19 +100,19 @@ println(element); # world
```
## string.charAt
```
```php
string.charAt(index: int)
```
Returns string's character of given index or throws error if index is greater than `string.length - 1`.
#### Example
```
```php
x = "hello";
println(x.charAt(1)); # e
```
## \<any\>.toString
```
```php
<any>.toString()
```
Returns a string representation of object.