Skip to content

bmel:for-range

Category: Logic & Control Flow · Returns: bmel:array

Signature
bmel:for-range(from: bmel:integer, to: bmel:integer, body: bmel:expression)

Description

Iterates from bmel:from to bmel:to (both inclusive, step +1) and evaluates bmel:body at each step, collecting results into an array. Within bmel:body the current loop index is accessible as the special reference bmel:i. Returns an empty array when bmel:from is greater than bmel:to.

Arguments

Parameter Type Required Description
from bmel:integer Start index (inclusive).
to bmel:integer End index (inclusive). When bmel:to < bmel:from the function returns an empty array without error.
body bmel:expression Expression evaluated at each iteration step. The current index value is accessible within this expression as the special reference bmel:i.

Examples

Indexes from 1 to 5
bmel:for-range(1, 5, bmel:i)
Squares from 1 to 10
bmel:for-range(1, 10, bmel:i * bmel:i)

← Back to BMEL Reference