File tree Expand file tree Collapse file tree 5 files changed +16
-12
lines changed
Expand file tree Collapse file tree 5 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 11
22IO :: import std.io
3- Error :: import std.errors { Error { new , getValueOr } }
3+ Error :: import std.errors { Error { error, success , getValueOr } }
44
55safeDiv :: (x, y) =
66 when (x, y) {
7- is (_, 0) -> Error::new ("Divide by zero")
7+ is (_, 0) -> Error::error ("Divide by zero")
88 else -> Error::success(x / y)
99 }
1010
1111result := Error::getValueOr(
12- safeDiv(50, 0 ),
12+ safeDiv(50, 2 ),
1313 |err| -> -1
1414)
1515
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ getContents :: ({fileName: path}) =
99 result := file catch return Error::error("Failed to read file: {err}")
1010 in Error::success(result)
1111
12- result := getContents({fileName: "main.pics "}) catch err
12+ result := getContents({fileName: "pom.xmlz "}) catch err
1313IO::println(result)
1414
1515
Original file line number Diff line number Diff line change 11
22import std.io
3- import std.array
4- import std.proc.loops
3+ import std.list
4+ import std.proc.loop
55
6- arr := Array ::fromRange(1, 5)
6+ arr := List ::fromRange(1, 5)
77
88Loops::forEach(arr, |item| -> do {
99 IO::println(item)
Original file line number Diff line number Diff line change @@ -11,12 +11,15 @@ song := "Feel good Inc"
1111
1212// Arrays
1313numbers := [1,2,3]
14- first := numbers.0
14+ first := numbers[0]
1515joined := first:numbers
1616
17+ IO::println(first)
18+
1719// Tuples
1820numbers := (1,2,3)
1921first := numbers[0]
22+ IO::println(first)
2023
2124
2225
Original file line number Diff line number Diff line change @@ -4,23 +4,24 @@ Args :: import std.args
44List :: import std.list
55Virtual :: import std.virtual
66
7- #[Virtual]
8- getUser :: (0) =
7+ getUser :: (0) = Virtual::task(|_| -> do {
98 let
109 userId := "Admin:{id}"
1110 in do {
1211 Virtual::sleep(100 * id)
1312 {user: userId, id: id, root: true}
1413 }
14+ })
1515
16- #[Virtual]
17- getUser :: (id) =
16+
17+ getUser :: (id) = Virtual::task(|_| -> do {
1818 let
1919 userId := "User:{id}"
2020 in do {
2121 Virtual::sleep(100 * id)
2222 {user: userId, id: id}
2323 }
24+ })
2425
2526getUsers :: (end=1) =
2627 let
You can’t perform that action at this time.
0 commit comments