NH
nop head
Sat, Jul 19, 2025 3:23 PM
It seems that assert can't be used in a list comprehension? Is this
correct, if so, why not?
It seems that assert can't be used in a list comprehension? Is this
correct, if so, why not?
TP
Torsten Paul
Sat, Jul 19, 2025 3:28 PM
On 19.07.25 17:23, nop head via Discuss wrote:
It seems that assert can't be used in a list comprehension? Is this
correct, if so, why not?
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
On 19.07.25 17:23, nop head via Discuss wrote:
> It seems that assert can't be used in a list comprehension? Is this
> correct, if so, why not?
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
NH
nop head
Sat, Jul 19, 2025 3:56 PM
[for(i = [0 : len(transforms) - 1])
assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
each profile4 * transforms[i],
];
On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:
On 19.07.25 17:23, nop head via Discuss wrote:
It seems that assert can't be used in a list comprehension? Is this
correct, if so, why not?
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
[for(i = [0 : len(transforms) - 1])
assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
each profile4 * transforms[i],
];
On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:
> On 19.07.25 17:23, nop head via Discuss wrote:
> > It seems that assert can't be used in a list comprehension? Is this
> > correct, if so, why not?
>
> That could be a parser conflict for a specific case as this works
>
> a = [ for (x = [0:10]) assert(x < 10) x ];
> echo(a);
>
> So what's the code that fails?
>
> ciao,
> Torsten.
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
NH
nop head
Sat, Jul 19, 2025 4:01 PM
The error square in the editor is actually on the space after the each but
if I remove the assert that line is fine.
On Sat, 19 Jul 2025 at 16:56, nop head nop.head@gmail.com wrote:
[for(i = [0 : len(transforms) - 1])
assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
each profile4 * transforms[i],
];
On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:
On 19.07.25 17:23, nop head via Discuss wrote:
It seems that assert can't be used in a list comprehension? Is this
correct, if so, why not?
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
The error square in the editor is actually on the space after the each but
if I remove the assert that line is fine.
On Sat, 19 Jul 2025 at 16:56, nop head <nop.head@gmail.com> wrote:
> [for(i = [0 : len(transforms) - 1])
> assert(len(profiles[i]) == len(profiles[0]))
> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
> each profile4 * transforms[i],
> ];
>
>
> On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> On 19.07.25 17:23, nop head via Discuss wrote:
>> > It seems that assert can't be used in a list comprehension? Is this
>> > correct, if so, why not?
>>
>> That could be a parser conflict for a specific case as this works
>>
>> a = [ for (x = [0:10]) assert(x < 10) x ];
>> echo(a);
>>
>> So what's the code that fails?
>>
>> ciao,
>> Torsten.
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
>
AM
Adrian Mariano
Sat, Jul 19, 2025 4:09 PM
Problem appears to be the "each". Looks like putting each before the
assert() may work.
On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
The error square in the editor is actually on the space after the each but
if I remove the assert that line is fine.
On Sat, 19 Jul 2025 at 16:56, nop head nop.head@gmail.com wrote:
[for(i = [0 : len(transforms) - 1])
assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
each profile4 * transforms[i],
];
On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:
On 19.07.25 17:23, nop head via Discuss wrote:
It seems that assert can't be used in a list comprehension? Is this
correct, if so, why not?
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Problem appears to be the "each". Looks like putting each before the
assert() may work.
On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
> The error square in the editor is actually on the space after the each but
> if I remove the assert that line is fine.
>
> On Sat, 19 Jul 2025 at 16:56, nop head <nop.head@gmail.com> wrote:
>
>> [for(i = [0 : len(transforms) - 1])
>> assert(len(profiles[i]) == len(profiles[0]))
>> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
>> each profile4 * transforms[i],
>> ];
>>
>>
>> On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
>> discuss@lists.openscad.org> wrote:
>>
>>> On 19.07.25 17:23, nop head via Discuss wrote:
>>> > It seems that assert can't be used in a list comprehension? Is this
>>> > correct, if so, why not?
>>>
>>> That could be a parser conflict for a specific case as this works
>>>
>>> a = [ for (x = [0:10]) assert(x < 10) x ];
>>> echo(a);
>>>
>>> So what's the code that fails?
>>>
>>> ciao,
>>> Torsten.
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>
>> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
NH
nop head
Sat, Jul 19, 2025 4:24 PM
Yes, that works, thanks. Not sure why each not allowed after an
assert though?
On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
Problem appears to be the "each". Looks like putting each before the
assert() may work.
On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
The error square in the editor is actually on the space after the each
but if I remove the assert that line is fine.
On Sat, 19 Jul 2025 at 16:56, nop head nop.head@gmail.com wrote:
[for(i = [0 : len(transforms) - 1])
assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
each profile4 * transforms[i],
];
On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:
On 19.07.25 17:23, nop head via Discuss wrote:
It seems that assert can't be used in a list comprehension? Is this
correct, if so, why not?
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Yes, that works, thanks. Not sure why each not allowed after an
assert though?
On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
> Problem appears to be the "each". Looks like putting each before the
> assert() may work.
>
>
> On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> The error square in the editor is actually on the space after the each
>> but if I remove the assert that line is fine.
>>
>> On Sat, 19 Jul 2025 at 16:56, nop head <nop.head@gmail.com> wrote:
>>
>>> [for(i = [0 : len(transforms) - 1])
>>> assert(len(profiles[i]) == len(profiles[0]))
>>> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
>>> each profile4 * transforms[i],
>>> ];
>>>
>>>
>>> On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
>>> discuss@lists.openscad.org> wrote:
>>>
>>>> On 19.07.25 17:23, nop head via Discuss wrote:
>>>> > It seems that assert can't be used in a list comprehension? Is this
>>>> > correct, if so, why not?
>>>>
>>>> That could be a parser conflict for a specific case as this works
>>>>
>>>> a = [ for (x = [0:10]) assert(x < 10) x ];
>>>> echo(a);
>>>>
>>>> So what's the code that fails?
>>>>
>>>> ciao,
>>>> Torsten.
>>>> _______________________________________________
>>>> OpenSCAD mailing list
>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>
>>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
AM
Adrian Mariano
Sat, Jul 19, 2025 4:37 PM
If I had to guess I would say that the problem is what does assert do? It
passes the "child" object up as a return value. So
assert( ...) x
is the same as
x
from the perspective of the calling code, to which the assert is basically
invisible.
But when you insert an each you are now exploding the x from being one item
into a bunch of items. It seems like assert cannot accept an exploded list
as one child item. I would say that there are very few contexts where
each is permitted. You can't write a = each list. So it doesn't seem
shocking that the each needs to be outside the assert.
Perhaps Torsten will have a more formal explanation.
On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
Yes, that works, thanks. Not sure why each not allowed after an
assert though?
On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
Problem appears to be the "each". Looks like putting each before the
assert() may work.
On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
The error square in the editor is actually on the space after the each
but if I remove the assert that line is fine.
On Sat, 19 Jul 2025 at 16:56, nop head nop.head@gmail.com wrote:
[for(i = [0 : len(transforms) - 1])
assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
each profile4 * transforms[i],
];
On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:
On 19.07.25 17:23, nop head via Discuss wrote:
It seems that assert can't be used in a list comprehension? Is this
correct, if so, why not?
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
If I had to guess I would say that the problem is what does assert do? It
passes the "child" object up as a return value. So
assert( ...) x
is the same as
x
from the perspective of the calling code, to which the assert is basically
invisible.
But when you insert an each you are now exploding the x from being one item
into a bunch of items. It seems like assert cannot accept an exploded list
as one child item. I would say that there are very few contexts where
each is permitted. You can't write a = each list. So it doesn't seem
shocking that the each needs to be outside the assert.
Perhaps Torsten will have a more formal explanation.
On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
> Yes, that works, thanks. Not sure why each not allowed after an
> assert though?
>
> On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> Problem appears to be the "each". Looks like putting each before the
>> assert() may work.
>>
>>
>> On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
>> discuss@lists.openscad.org> wrote:
>>
>>> The error square in the editor is actually on the space after the each
>>> but if I remove the assert that line is fine.
>>>
>>> On Sat, 19 Jul 2025 at 16:56, nop head <nop.head@gmail.com> wrote:
>>>
>>>> [for(i = [0 : len(transforms) - 1])
>>>> assert(len(profiles[i]) == len(profiles[0]))
>>>> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
>>>> each profile4 * transforms[i],
>>>> ];
>>>>
>>>>
>>>> On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
>>>> discuss@lists.openscad.org> wrote:
>>>>
>>>>> On 19.07.25 17:23, nop head via Discuss wrote:
>>>>> > It seems that assert can't be used in a list comprehension? Is this
>>>>> > correct, if so, why not?
>>>>>
>>>>> That could be a parser conflict for a specific case as this works
>>>>>
>>>>> a = [ for (x = [0:10]) assert(x < 10) x ];
>>>>> echo(a);
>>>>>
>>>>> So what's the code that fails?
>>>>>
>>>>> ciao,
>>>>> Torsten.
>>>>> _______________________________________________
>>>>> OpenSCAD mailing list
>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>
>>>> _______________________________________________
>>> OpenSCAD mailing list
>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
NH
nop head
Sat, Jul 19, 2025 4:43 PM
It isn't clear to me if moving it after the each make the assert executed
more times or not.
On Sat, 19 Jul 2025 at 17:37, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
If I had to guess I would say that the problem is what does assert do? It
passes the "child" object up as a return value. So
assert( ...) x
is the same as
x
from the perspective of the calling code, to which the assert is basically
invisible.
But when you insert an each you are now exploding the x from being one
item into a bunch of items. It seems like assert cannot accept an
exploded list as one child item. I would say that there are very few
contexts where each is permitted. You can't write a = each list. So it
doesn't seem shocking that the each needs to be outside the assert.
Perhaps Torsten will have a more formal explanation.
On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
Yes, that works, thanks. Not sure why each not allowed after an
assert though?
On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
Problem appears to be the "each". Looks like putting each before the
assert() may work.
On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
The error square in the editor is actually on the space after the each
but if I remove the assert that line is fine.
On Sat, 19 Jul 2025 at 16:56, nop head nop.head@gmail.com wrote:
[for(i = [0 : len(transforms) - 1])
assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
each profile4 * transforms[i],
];
On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:
On 19.07.25 17:23, nop head via Discuss wrote:
It seems that assert can't be used in a list comprehension? Is this
correct, if so, why not?
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
It isn't clear to me if moving it after the each make the assert executed
more times or not.
On Sat, 19 Jul 2025 at 17:37, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
> If I had to guess I would say that the problem is what does assert do? It
> passes the "child" object up as a return value. So
>
> assert( ...) x
>
> is the same as
>
> x
>
> from the perspective of the calling code, to which the assert is basically
> invisible.
>
> But when you insert an each you are now exploding the x from being one
> item into a bunch of items. It seems like assert cannot accept an
> exploded list as one child item. I would say that there are very few
> contexts where each is permitted. You can't write a = each list. So it
> doesn't seem shocking that the each needs to be outside the assert.
>
> Perhaps Torsten will have a more formal explanation.
>
> On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> Yes, that works, thanks. Not sure why each not allowed after an
>> assert though?
>>
>> On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
>> discuss@lists.openscad.org> wrote:
>>
>>> Problem appears to be the "each". Looks like putting each before the
>>> assert() may work.
>>>
>>>
>>> On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
>>> discuss@lists.openscad.org> wrote:
>>>
>>>> The error square in the editor is actually on the space after the each
>>>> but if I remove the assert that line is fine.
>>>>
>>>> On Sat, 19 Jul 2025 at 16:56, nop head <nop.head@gmail.com> wrote:
>>>>
>>>>> [for(i = [0 : len(transforms) - 1])
>>>>> assert(len(profiles[i]) == len(profiles[0]))
>>>>> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
>>>>> each profile4 * transforms[i],
>>>>> ];
>>>>>
>>>>>
>>>>> On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
>>>>> discuss@lists.openscad.org> wrote:
>>>>>
>>>>>> On 19.07.25 17:23, nop head via Discuss wrote:
>>>>>> > It seems that assert can't be used in a list comprehension? Is this
>>>>>> > correct, if so, why not?
>>>>>>
>>>>>> That could be a parser conflict for a specific case as this works
>>>>>>
>>>>>> a = [ for (x = [0:10]) assert(x < 10) x ];
>>>>>> echo(a);
>>>>>>
>>>>>> So what's the code that fails?
>>>>>>
>>>>>> ciao,
>>>>>> Torsten.
>>>>>> _______________________________________________
>>>>>> OpenSCAD mailing list
>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>>
>>>>> _______________________________________________
>>>> OpenSCAD mailing list
>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
TP
Torsten Paul
Sat, Jul 19, 2025 4:45 PM
On 19.07.25 18:37, Adrian Mariano via Discuss wrote:
Perhaps Torsten will have a more formal explanation.
My view is just that this is not intentional and likely
caused by the parser getting the parser order wrong or
so.
Maybe related to the value exploding behavior of each
you mentioned. Considering this, there might not even
be a good solution, but I guess the full answer would
need some digging into what's happening under the hood
in this case.
I think there was discussion about a similar issue with
let() too, quite some time ago.
ciao,
Torsten.
On 19.07.25 18:37, Adrian Mariano via Discuss wrote:
> Perhaps Torsten will have a more formal explanation.
My view is just that this is not intentional and likely
caused by the parser getting the parser order wrong or
so.
Maybe related to the value exploding behavior of each
you mentioned. Considering this, there might not even
be a good solution, but I guess the full answer would
need some digging into what's happening under the hood
in this case.
I think there was discussion about a similar issue with
let() too, quite some time ago.
ciao,
Torsten.
AM
Adrian Mariano
Sat, Jul 19, 2025 4:54 PM
I was thinking of this, which appears to produce the same result (though
it's hard to be certain since you didn't provide a runable example)
[for(i = [0 : len(transforms) - 1])
each assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
profile4 * transforms[i],
];
which seems to obviously run the assert only once. You could also insert
the assert inside the let with a dummy assignment, or inside the profile4
assignment, though both are a little ugly.
On Sat, Jul 19, 2025 at 12:44 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
It isn't clear to me if moving it after the each make the assert executed
more times or not.
On Sat, 19 Jul 2025 at 17:37, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
If I had to guess I would say that the problem is what does assert do?
It passes the "child" object up as a return value. So
assert( ...) x
is the same as
x
from the perspective of the calling code, to which the assert is
basically invisible.
But when you insert an each you are now exploding the x from being one
item into a bunch of items. It seems like assert cannot accept an
exploded list as one child item. I would say that there are very few
contexts where each is permitted. You can't write a = each list. So it
doesn't seem shocking that the each needs to be outside the assert.
Perhaps Torsten will have a more formal explanation.
On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
Yes, that works, thanks. Not sure why each not allowed after an
assert though?
On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
Problem appears to be the "each". Looks like putting each before the
assert() may work.
On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
The error square in the editor is actually on the space after the each
but if I remove the assert that line is fine.
On Sat, 19 Jul 2025 at 16:56, nop head nop.head@gmail.com wrote:
[for(i = [0 : len(transforms) - 1])
assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
each profile4 * transforms[i],
];
On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:
On 19.07.25 17:23, nop head via Discuss wrote:
It seems that assert can't be used in a list comprehension? Is
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
I was thinking of this, which appears to produce the same result (though
it's hard to be certain since you didn't provide a runable example)
[for(i = [0 : len(transforms) - 1])
each assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
profile4 * transforms[i],
];
which seems to obviously run the assert only once. You could also insert
the assert inside the let with a dummy assignment, or inside the profile4
assignment, though both are a little ugly.
On Sat, Jul 19, 2025 at 12:44 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
> It isn't clear to me if moving it after the each make the assert executed
> more times or not.
>
> On Sat, 19 Jul 2025 at 17:37, Adrian Mariano via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> If I had to guess I would say that the problem is what does assert do?
>> It passes the "child" object up as a return value. So
>>
>> assert( ...) x
>>
>> is the same as
>>
>> x
>>
>> from the perspective of the calling code, to which the assert is
>> basically invisible.
>>
>> But when you insert an each you are now exploding the x from being one
>> item into a bunch of items. It seems like assert cannot accept an
>> exploded list as one child item. I would say that there are very few
>> contexts where each is permitted. You can't write a = each list. So it
>> doesn't seem shocking that the each needs to be outside the assert.
>>
>> Perhaps Torsten will have a more formal explanation.
>>
>> On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
>> discuss@lists.openscad.org> wrote:
>>
>>> Yes, that works, thanks. Not sure why each not allowed after an
>>> assert though?
>>>
>>> On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
>>> discuss@lists.openscad.org> wrote:
>>>
>>>> Problem appears to be the "each". Looks like putting each before the
>>>> assert() may work.
>>>>
>>>>
>>>> On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
>>>> discuss@lists.openscad.org> wrote:
>>>>
>>>>> The error square in the editor is actually on the space after the each
>>>>> but if I remove the assert that line is fine.
>>>>>
>>>>> On Sat, 19 Jul 2025 at 16:56, nop head <nop.head@gmail.com> wrote:
>>>>>
>>>>>> [for(i = [0 : len(transforms) - 1])
>>>>>> assert(len(profiles[i]) == len(profiles[0]))
>>>>>> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
>>>>>> each profile4 * transforms[i],
>>>>>> ];
>>>>>>
>>>>>>
>>>>>> On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
>>>>>> discuss@lists.openscad.org> wrote:
>>>>>>
>>>>>>> On 19.07.25 17:23, nop head via Discuss wrote:
>>>>>>> > It seems that assert can't be used in a list comprehension? Is
>>>>>>> this
>>>>>>> > correct, if so, why not?
>>>>>>>
>>>>>>> That could be a parser conflict for a specific case as this works
>>>>>>>
>>>>>>> a = [ for (x = [0:10]) assert(x < 10) x ];
>>>>>>> echo(a);
>>>>>>>
>>>>>>> So what's the code that fails?
>>>>>>>
>>>>>>> ciao,
>>>>>>> Torsten.
>>>>>>> _______________________________________________
>>>>>>> OpenSCAD mailing list
>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>>>
>>>>>> _______________________________________________
>>>>> OpenSCAD mailing list
>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>
>>>> _______________________________________________
>>>> OpenSCAD mailing list
>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>