-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcell.lua
44 lines (33 loc) · 888 Bytes
/
cell.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
-- Biological cell simulation
-- Disclaimer: I am not a molecular biologist! (Nor am I a computer scientist.)
foobar: Cell {
cell: self
dna: [
foo: 40
]
rna: Queue new
ribosomes: Set new
transcribe: '(value)' => {
instructions: {
-- ...
}
dna foo | ≥ 42 | if true -> rna put (instructions)
}
ribosome: {
process: '(instructions)' => {
protein: Protein from (instructions)
cell << events emit "protein" (protein)
}
loop -> {
instructions: await (rna take promise)
process (instructions)
}
}
ribosomes add (ribosome)
dna on change (transcribe)
'increase foo' => {
dna foo | increment
}
}
foobar increase foo
foobar increase foo -- A new protein is emitted!