more examples
This commit is contained in:
parent
c5a843ea39
commit
9003149114
19 changed files with 287 additions and 0 deletions
25
examples/warp.ang
Normal file
25
examples/warp.ang
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
# Aliases
|
||||
type Receiver = fn() -> any
|
||||
type Sender = fn(any)
|
||||
|
||||
fn new_channel() -> (Sender, Receiver) {
|
||||
queue := []
|
||||
|
||||
fn send(n: any) {
|
||||
queue.push(n) # mutate in-place
|
||||
}
|
||||
|
||||
fn recv() -> any | nil {
|
||||
queue.pop()
|
||||
}
|
||||
|
||||
(send, recv)
|
||||
}
|
||||
|
||||
(send, recv) := new_channel()
|
||||
|
||||
(
|
||||
send:,
|
||||
recv:,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue