The Cheat Sheet seems to have some problems at the moment. Click on the
List link and you end up at Program Structures
I want to generate a list like this (I only show the first 2 triplets here):
[
[a, 0, 0],
[b, 0, 0],
[c, 0, 0],
[a+1, 0, 0],
[b+1, 0, 0],
[c+1, 0, 0]
];
I tried something like this (which is ridiculously wrong)
posns =
for (x = [1:4]) (
[a + x-1, 0, 0],
[b + x-1, 0, 0],
[c + x-1, 0, 0]);
I do not want a list of list triplets, but rather a long one level list.
Without the Cheat Sheet to guide me, I am lost.
I welcome recommendations
Thanks
Jon
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
On 7/29/2025 12:39 PM, Jon Bondy via Discuss wrote:
The Cheat Sheet seems to have some problems at the moment. Click on
the List link and you end up at Program Structures
Yeah, somebody is working on a pretty major overhaul of the manual and a
lot of things are broken at the moment.
I do not want a list of list triplets, but rather a long one level list.
Each of which is a triplet, right?
That is, you want a list of triplets, not a list of triplets, each of
which is a triplet.
I suspect that you want the "each" list comprehension operator, which
busts apart lists.
Does this do what you want?
a = 100;
b = 200;
c = 300;
posns = [
for (x = [1:4]) each [
[a + x-1, 0, 0],
[b + x-1, 0, 0],
[c + x-1, 0, 0]
]
];
echo(posns);
yields (reformatted for readability):
ECHO: [ [100, 0, 0], [200, 0, 0], [300, 0, 0], [101, 0, 0], [201, 0, 0],
[301, 0, 0], [102, 0, 0], [202, 0, 0], [302, 0, 0], [103, 0, 0], [203,
0, 0], [303, 0, 0] ]
Perfect! Thank you!
On 7/29/2025 3:59 PM, Jordan Brown wrote:
On 7/29/2025 12:39 PM, Jon Bondy via Discuss wrote:
The Cheat Sheet seems to have some problems at the moment. Click on the List link and you end up at Program Structures
Yeah, somebody is working on a pretty major overhaul of the manual and a lot of things are broken at the moment.
I do not want a list of list triplets, but rather a long one level list.
Each of which is a triplet, right?
That is, you want a list of triplets, not a list of triplets, each of which is a triplet.
I suspect that you want the "each" list comprehension operator, which busts apart lists.
Does this do what you want?
a = 100;
b = 200;
c = 300;
posns = [
for (x = [1:4]) each [
[a + x-1, 0, 0],
[b + x-1, 0, 0],
[c + x-1, 0, 0]
]
];
echo(posns);
yields (reformatted for readability):
ECHO: [
[100, 0, 0],
[200, 0, 0],
[300, 0, 0],
[101, 0, 0],
[201, 0, 0],
[301, 0, 0],
[102, 0, 0],
[202, 0, 0],
[302, 0, 0],
[103, 0, 0],
[203, 0, 0],
[303, 0, 0]
]
i will take a look at the cheat sheet now .. my work on it is in my own branch tho and i have not merged back nor done a PR