mirror of
https://github.com/Dummi26/mers.git
synced 2025-10-24 18:16:28 +02:00
This commit is contained in:
parent
35efae75ac
commit
cd2db1ab27
@ -101,7 +101,7 @@ mers only has a few different expressions:
|
|||||||
- `loop expression`
|
- `loop expression`
|
||||||
- type hints `[Int] 5`
|
- type hints `[Int] 5`
|
||||||
- type definitions `[[Number] Int/Float]` or `[[TypeOfX] := x]`, which can also be used as a type check: `[[_] := expression]` checks that the expression is type-correct
|
- type definitions `[[Number] Int/Float]` or `[[TypeOfX] := x]`, which can also be used as a type check: `[[_] := expression]` checks that the expression is type-correct
|
||||||
- try: mers' switch/match: `x.try(num -> num.div(2), _ -> 0)`
|
- try: mers' switch/match: `x.try([(Int -> Int)] num -> num.div(2), _ -> 0)`
|
||||||
|
|
||||||
mers treats everything as call-by-value by default:
|
mers treats everything as call-by-value by default:
|
||||||
|
|
||||||
@ -175,7 +175,10 @@ It can also produce values.
|
|||||||
```
|
```
|
||||||
val := loop {
|
val := loop {
|
||||||
"> ".print
|
"> ".print
|
||||||
().read_line.trim.parse_float
|
().read_line.try(
|
||||||
|
[(() -> (()))] () -> (())
|
||||||
|
[((String) -> ()/(Float))] (line) -> line.trim.parse_float
|
||||||
|
)
|
||||||
}
|
}
|
||||||
val.println
|
val.println
|
||||||
```
|
```
|
||||||
@ -196,7 +199,7 @@ val := if "a".eq("a") {
|
|||||||
}
|
}
|
||||||
val.try(
|
val.try(
|
||||||
// if the value is a number, print half of it
|
// if the value is a number, print half of it
|
||||||
num -> num.div(2).println
|
[(Int -> ())] num -> num.div(2).println
|
||||||
// for any other value, print it directly
|
// for any other value, print it directly
|
||||||
other -> other.println
|
other -> other.println
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user