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}"
}
}
[
[
"officia_tempora/suscipit.pptx",
"eligendi_dolorum/magni.mp4",
"omnis_rem/blanditiis.xlsx",
"totam_ipsam/veritatis.csv"
],
[
"repudiandae_laboriosam/pariatur.ppt",
"accusantium_accusamus/voluptates.tiff",
"occaecati_veniam/quam.js",
"aliquid_similique/quis.csv",
"assumenda_excepturi/dolorum.ppt"
],
[
"harum_a/quis.ppt"
],
[
"hic_magnam/mollitia.jpg",
"cum_eveniet/est.doc",
"culpa_esse/deserunt.pdf"
],
[
"accusantium_fugit/laborum.html",
"vitae_accusantium/quam.csv",
"laboriosam_sed/repellendus.pdf",
"repellendus_et/fugit.jpg"
]
]
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": 35.16211108393365,
"b": 35.16211108393365
},
{
"a": 61.214853246732936,
"b": 61.214853246732936
},
{
"a": 52.04425270103643,
"b": 52.04425270103643
}
],
[
{
"a": 52.75114930584194,
"b": 52.75114930584194
},
{
"a": 46.88178498866818,
"b": 46.88178498866818
},
{
"a": 73.98214678625841,
"b": 73.98214678625841
}
],
[
{
"a": 30.10466610840182,
"b": 30.10466610840182
},
{
"a": 45.49545274218041,
"b": 45.49545274218041
},
{
"a": 54.62911865345987,
"b": 54.62911865345987
}
]
]
Specification
JSON schema
{
"type": "object",
"properties": {
"iterateVars": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
}
},
"required": [
"n",
"target"
]
}