Hi community,
I'm new to Nim and try to learn the basics from Exercism.
In the exercise `React`, I need to implement a spreadsheet-like function.
This exercise has little information and thus I have to figure out the
structure of the code from the test suite as follows.
suite "React":
test "setting the value of an input cell changes the observable value":
let
reactor = newReactor()
i1 = reactor.createInput(1)
check i1.value == 1
i1.value = 2
check i1.value == 2
test "the value of a compute is determined by the value of the
dependencies":
let
reactor = newReactor()
i1 = reactor.createInput(1)
# Using @[Cell i1] to avoid the compiler inferring the array type as
seq[InputCell],
# which is incompatible with seq[Cell].
c1 = reactor.createCompute(@[Cell i1], proc(vals: seq[int]): int =
vals[0] + 1)
check c1.value == 2
i1.value = 2
check c1.value == 3
Run
I have no idea of what `@[Cell i1]`, mentioned in the comment, means.
Does anybody have some idea?
Thank you.