Skip to content

Recur

Name Mandatory Description Default Type
⬅️ Input After the first cycle of Recur, the output of the Wire that calls Recur will be fed back as input for the next cycle. Any
Output ➡️ The output of Recur will be the output of the Wire that calls it. Any

The Recur shard executes the Wire that calls it recursively, using the output of the Wire as input again, until the base cases are reached. It then combines the results to produce the final result. For the shard not to Recur endlessly, a base case needs to be defined, usually through a When or If shard.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
@wire(fibo {
  >= n
  If(IsLess(2)
    Then: {Pass}
    Else: {n | Math.Subtract(2) (Recur) >= a
      n | Math.Subtract(1) (Recur) >= b
      a | Math.Add(b)
    }
  )
})

@wire(main-wire {
  16
  Do(fibo)
  Log("Result")
  Assert.Is(987 true)
})

@mesh(main)
@schedule(main main-wire)
@run(main)