Skip to main content

Transformation functions

repeatedly

Commentary

added in 0.0.18

Generates an array of n elements of target.

By default, all elements generated by repeatedly will reference the same values in vars on each iteration. But if you set iterateVars to an array of variable names, those variables will be re-evaluated for each element. This is useful if you want to create an array whose elements are somewhat different than each other. 1


Examples

Generating arrays

{
"_gen": "repeatedly",
"n": {
"_gen": "uniformDistribution",
"bounds": [
0,
5
]
},
"target": {
"_gen": "string",
"expr": "#{File.fileName}"
}
}
[
[
"fugiat_ex/aut.ods",
"in_ipsam/quibusdam.pages",
"soluta_sapiente/quo.js",
"eum_reprehenderit/excepturi.mov"
],
[
"magni_quidem/magni.pptx",
"sequi_quos/quis.docx",
"voluptas_ex/adipisci.avi",
"nesciunt_minima/vel.jpg",
"nihil_voluptates/occaecati.pages"
],
[
"consequatur_non/quaerat.wav",
"provident_eveniet/nostrum.odt"
],
[
"vitae_fuga/exercitationem.mov",
"amet_porro/dolore.xlsx"
],
[
"error_distinctio/error.js",
"ea_nostrum/dolor.gif",
"fuga_at/ducimus.pages"
]
]

Re-evaluating variables

Set iterateVars to an array of variable names to re-evaluate them on each iteration of repeatedly. Notice how a and b hold the same value for each element, but vary between elements.

{
"topic": "sandbox",
"vars": {
"element": {
"_gen": "normalDistribution",
"mean": 50,
"sd": 10
}
},
"value": {
"_gen": "repeatedly",
"n": 3,
"iterateVars": [
"element"
],
"target": {
"a": {
"_gen": "var",
"var": "element"
},
"b": {
"_gen": "var",
"var": "element"
}
}
}
}
[
[
{
"a": 58.12348951430491,
"b": 58.12348951430491
},
{
"a": 55.81872569242069,
"b": 55.81872569242069
},
{
"a": 51.97701066735556,
"b": 51.97701066735556
}
],
[
{
"a": 50.981212643893315,
"b": 50.981212643893315
},
{
"a": 65.19653529781421,
"b": 65.19653529781421
},
{
"a": 40.28901123615394,
"b": 40.28901123615394
}
],
[
{
"a": 65.66790957475035,
"b": 65.66790957475035
},
{
"a": 35.313141362770125,
"b": 35.313141362770125
},
{
"a": 73.9677338316705,
"b": 73.9677338316705
}
]
]

Specification

JSON schema

{
"type": "object",
"properties": {
"iterateVars": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
}
},
"required": [
"n",
"target"
]
}