mirror of
https://github.com/Dummi26/mers.git
synced 2025-10-23 17:56:27 +02:00
This commit is contained in:
parent
35efae75ac
commit
cd2db1ab27
@ -101,7 +101,7 @@ mers only has a few different expressions:
|
||||
- `loop expression`
|
||||
- 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
|
||||
- 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:
|
||||
|
||||
@ -175,7 +175,10 @@ It can also produce values.
|
||||
```
|
||||
val := loop {
|
||||
"> ".print
|
||||
().read_line.trim.parse_float
|
||||
().read_line.try(
|
||||
[(() -> (()))] () -> (())
|
||||
[((String) -> ()/(Float))] (line) -> line.trim.parse_float
|
||||
)
|
||||
}
|
||||
val.println
|
||||
```
|
||||
@ -196,7 +199,7 @@ val := if "a".eq("a") {
|
||||
}
|
||||
val.try(
|
||||
// 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
|
||||
other -> other.println
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user