Update.
This commit is contained in:
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "scheduler" for Scheduler, Future
|
||||
|
||||
var step1 = async { |x| x + 10 }
|
||||
var step2 = async { |x| x * 2 }
|
||||
var step3 = async { |x| x - 5 }
|
||||
|
||||
var result = 5
|
||||
result = await step1(result)
|
||||
System.print(result) // expect: 15
|
||||
result = await step2(result)
|
||||
System.print(result) // expect: 30
|
||||
result = await step3(result)
|
||||
System.print(result) // expect: 25
|
||||
|
||||
var pipeline = async { |x|
|
||||
var r1 = await step1(x)
|
||||
var r2 = await step2(r1)
|
||||
var r3 = await step3(r2)
|
||||
return r3
|
||||
}
|
||||
|
||||
System.print(await pipeline(0)) // expect: 15
|
||||
System.print(await pipeline(10)) // expect: 35
|
||||
Reference in New Issue
Block a user