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}"
}
}
[
[
"corrupti_aut/dolorem.gif",
"sunt_vel/qui.webm",
"vel_placeat/reiciendis.png",
"perferendis_commodi/eveniet.avi"
],
[
"illum_enim/perspiciatis.avi",
"aut_non/veritatis.ods",
"qui_quia/quisquam.webm",
"neque_aut/nihil.webm",
"sunt_iusto/reprehenderit.html"
],
[
"officia_tenetur/molestiae.png",
"earum_eius/dignissimos.odp",
"id_facilis/eius.ods"
],
[
"enim_distinctio/ullam.key",
"excepturi_eos/inventore.ppt",
"unde_sit/qui.numbers",
"et_dolorum/amet.wav"
],
[
"omnis_incidunt/pariatur.xls",
"quasi_iusto/voluptas.numbers",
"illum_aut/sed.odp",
"illum_voluptatem/ea.flac",
"voluptas_velit/nesciunt.bmp"
]
]

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": 62.627193372680814,
"b": 62.627193372680814
},
{
"a": 30.616813420624737,
"b": 30.616813420624737
},
{
"a": 37.5634431812954,
"b": 37.5634431812954
}
],
[
{
"a": 27.59145301964995,
"b": 27.59145301964995
},
{
"a": 54.411567438838894,
"b": 54.411567438838894
},
{
"a": 54.84239938390455,
"b": 54.84239938390455
}
],
[
{
"a": 38.27237654209741,
"b": 38.27237654209741
},
{
"a": 53.171095082717414,
"b": 53.171095082717414
},
{
"a": 56.67724243662487,
"b": 56.67724243662487
}
]
]

Specification

JSON schema

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