JB
Jordan Brown
Mon, Feb 14, 2022 4:35 PM
On 2/13/2022 3:14 PM, Adrian Mariano wrote:
I can't imagine why anybody thought issuing a warning when you don't
find something was a good idea.
Nor can I. But removing a warning is a compatible change...
On 2/13/2022 3:14 PM, Adrian Mariano wrote:
> I can't imagine why anybody thought issuing a warning when you don't
> find something was a good idea.
Nor can I. But removing a warning is a compatible change...
NH
nop head
Mon, Feb 14, 2022 4:44 PM
The warning itself seems broken because no matter what the string key is it
only warns about the second letter. Or perhaps I don't understand search. I
have never used it because it is pretty incomprehensible to me.
On Mon, 14 Feb 2022 at 16:36, Jordan Brown openscad@jordan.maileater.net
wrote:
On 2/13/2022 3:14 PM, Adrian Mariano wrote:
I can't imagine why anybody thought issuing a warning when you don't find
something was a good idea.
Nor can I. But removing a warning is a compatible change...
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
The warning itself seems broken because no matter what the string key is it
only warns about the second letter. Or perhaps I don't understand search. I
have never used it because it is pretty incomprehensible to me.
On Mon, 14 Feb 2022 at 16:36, Jordan Brown <openscad@jordan.maileater.net>
wrote:
> On 2/13/2022 3:14 PM, Adrian Mariano wrote:
>
> I can't imagine why anybody thought issuing a warning when you don't find
> something was a good idea.
>
>
> Nor can I. But removing a warning is a compatible change...
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
AC
A. Craig West
Tue, Feb 15, 2022 5:09 AM
I feel certain that I fell into this rabbit hole the first time I tried to
use search for something. I believe my solution then was to wrap it in more
meaningful functions
On Mon, 14 Feb 2022, 11:45 nop head, nop.head@gmail.com wrote:
The warning itself seems broken because no matter what the string key is
it only warns about the second letter. Or perhaps I don't understand
search. I have never used it because it is pretty incomprehensible to me.
On Mon, 14 Feb 2022 at 16:36, Jordan Brown openscad@jordan.maileater.net
wrote:
On 2/13/2022 3:14 PM, Adrian Mariano wrote:
I can't imagine why anybody thought issuing a warning when you don't find
something was a good idea.
Nor can I. But removing a warning is a compatible change...
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
I feel certain that I fell into this rabbit hole the first time I tried to
use search for something. I believe my solution then was to wrap it in more
meaningful functions
On Mon, 14 Feb 2022, 11:45 nop head, <nop.head@gmail.com> wrote:
> The warning itself seems broken because no matter what the string key is
> it only warns about the second letter. Or perhaps I don't understand
> search. I have never used it because it is pretty incomprehensible to me.
>
> On Mon, 14 Feb 2022 at 16:36, Jordan Brown <openscad@jordan.maileater.net>
> wrote:
>
>> On 2/13/2022 3:14 PM, Adrian Mariano wrote:
>>
>> I can't imagine why anybody thought issuing a warning when you don't find
>> something was a good idea.
>>
>>
>> Nor can I. But removing a warning is a compatible change...
>>
>> _______________________________________________
>> 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
Tue, Feb 15, 2022 5:17 AM
Yeah, that is surely the way to go. The trouble is that it's harder
to do than it appears. Suppose you want to find the first match. So
you do search([5], [3,4,[5,6],3,5]). Search returns the index 2
referring to [5,6] which is wrong. So how do you find the first
match? You need to look for the second match now? Or find all
matches from the beginning? There's not really a good solution. I
mean, you could assume that this case is rare and just recurse,
looking for the 2nd match if it fails. But it's complicated.
On Tue, Feb 15, 2022 at 12:10 AM A. Craig West acraigwest@gmail.com wrote:
I feel certain that I fell into this rabbit hole the first time I tried to use search for something. I believe my solution then was to wrap it in more meaningful functions
On Mon, 14 Feb 2022, 11:45 nop head, nop.head@gmail.com wrote:
The warning itself seems broken because no matter what the string key is it only warns about the second letter. Or perhaps I don't understand search. I have never used it because it is pretty incomprehensible to me.
On Mon, 14 Feb 2022 at 16:36, Jordan Brown openscad@jordan.maileater.net wrote:
On 2/13/2022 3:14 PM, Adrian Mariano wrote:
I can't imagine why anybody thought issuing a warning when you don't find something was a good idea.
Nor can I. But removing a warning is a compatible change...
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
Yeah, that is surely the way to go. The trouble is that it's harder
to do than it appears. Suppose you want to find the first match. So
you do search([5], [3,4,[5,6],3,5]). Search returns the index 2
referring to [5,6] which is wrong. So how do you find the first
match? You need to look for the second match now? Or find all
matches from the beginning? There's not really a good solution. I
mean, you could assume that this case is rare and just recurse,
looking for the 2nd match if it fails. But it's complicated.
On Tue, Feb 15, 2022 at 12:10 AM A. Craig West <acraigwest@gmail.com> wrote:
>
> I feel certain that I fell into this rabbit hole the first time I tried to use search for something. I believe my solution then was to wrap it in more meaningful functions
>
> On Mon, 14 Feb 2022, 11:45 nop head, <nop.head@gmail.com> wrote:
>>
>> The warning itself seems broken because no matter what the string key is it only warns about the second letter. Or perhaps I don't understand search. I have never used it because it is pretty incomprehensible to me.
>>
>> On Mon, 14 Feb 2022 at 16:36, Jordan Brown <openscad@jordan.maileater.net> wrote:
>>>
>>> On 2/13/2022 3:14 PM, Adrian Mariano wrote:
>>>
>>> I can't imagine why anybody thought issuing a warning when you don't find something was a good idea.
>>>
>>>
>>> Nor can I. But removing a warning is a compatible change...
>>>
>>> _______________________________________________
>>> 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
M
MichaelAtOz
Tue, Feb 15, 2022 7:11 AM
Search returns the index 2
referring to [5,6] which is wrong.
It's not wrong, it's what it does.
If you have a data in a wrong structure, you will get wrong results. GIGO
So if you only want to operate on atomic entries in an unknown structure of course it is more work.
list=[3,4,[5,6],3,5,7,9,5,4,3];
// 0,1,2 ,3,4,5,6,7,8,9
function searchAtomic(needle,haystack,nth=0) =[
for (i = search([needle], haystack , 1e12) )
for (r = i)
if (!is_list(haystack[r]))
r ][nth];
echo(searchAtomic(5, list)); // 4
echo(searchAtomic(5, list,1)); // 7
echo(searchAtomic(5, list,9)); // undef
-----Original Message-----
From: Adrian Mariano [mailto:avm4@cornell.edu]
Sent: Tue, 15 Feb 2022 16:17
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: search function is broken
Yeah, that is surely the way to go. The trouble is that it's harder
to do than it appears. Suppose you want to find the first match. So
you do search([5], [3,4,[5,6],3,5]). Search returns the index 2
referring to [5,6] which is wrong. So how do you find the first
match? You need to look for the second match now? Or find all
matches from the beginning? There's not really a good solution. I
mean, you could assume that this case is rare and just recurse,
looking for the 2nd match if it fails. But it's complicated.
On Tue, Feb 15, 2022 at 12:10 AM A. Craig West acraigwest@gmail.com wrote:
I feel certain that I fell into this rabbit hole the first time I tried to use search
for something. I believe my solution then was to wrap it in more meaningful functions
The warning itself seems broken because no matter what the string key is it only warns
about the second letter. Or perhaps I don't understand search. I have never used it
because it is pretty incomprehensible to me.
On 2/13/2022 3:14 PM, Adrian Mariano wrote:
I can't imagine why anybody thought issuing a warning when you don't find something
> Search returns the index 2
> referring to [5,6] which is wrong.
It's not wrong, it's what it does.
If you have a data in a wrong structure, you will get wrong results. GIGO
So if you only want to operate on atomic entries in an unknown structure of course it is more work.
list=[3,4,[5,6],3,5,7,9,5,4,3];
// 0,1,2 ,3,4,5,6,7,8,9
function searchAtomic(needle,haystack,nth=0) =[
for (i = search([needle], haystack , 1e12) )
for (r = i)
if (!is_list(haystack[r]))
r ][nth];
echo(searchAtomic(5, list)); // 4
echo(searchAtomic(5, list,1)); // 7
echo(searchAtomic(5, list,9)); // undef
> -----Original Message-----
> From: Adrian Mariano [mailto:avm4@cornell.edu]
> Sent: Tue, 15 Feb 2022 16:17
> To: OpenSCAD general discussion
> Subject: [OpenSCAD] Re: search function is broken
>
> Yeah, that is surely the way to go. The trouble is that it's harder
> to do than it appears. Suppose you want to find the first match. So
> you do search([5], [3,4,[5,6],3,5]). Search returns the index 2
> referring to [5,6] which is wrong. So how do you find the first
> match? You need to look for the second match now? Or find all
> matches from the beginning? There's not really a good solution. I
> mean, you could assume that this case is rare and just recurse,
> looking for the 2nd match if it fails. But it's complicated.
>
>
>
> On Tue, Feb 15, 2022 at 12:10 AM A. Craig West <acraigwest@gmail.com> wrote:
> >
> > I feel certain that I fell into this rabbit hole the first time I tried to use search
> for something. I believe my solution then was to wrap it in more meaningful functions
> >
> > On Mon, 14 Feb 2022, 11:45 nop head, <nop.head@gmail.com> wrote:
> >>
> >> The warning itself seems broken because no matter what the string key is it only warns
> about the second letter. Or perhaps I don't understand search. I have never used it
> because it is pretty incomprehensible to me.
> >>
> >> On Mon, 14 Feb 2022 at 16:36, Jordan Brown <openscad@jordan.maileater.net> wrote:
> >>>
> >>> On 2/13/2022 3:14 PM, Adrian Mariano wrote:
> >>>
> >>> I can't imagine why anybody thought issuing a warning when you don't find something
> was a good idea.
> >>>
> >>>
> >>> Nor can I. But removing a warning is a compatible change...
> >>>
> >>> _______________________________________________
> >>> 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
--
This email has been checked for viruses by AVG.
https://www.avg.com
AM
Adrian Mariano
Tue, Feb 15, 2022 11:25 AM
If your goal is to write a normal search that returns the items that
actually match, then it's wrong. The code you show chooses the
option of finding all matches and then looking through that result for
the desired output. What if your list has a million entries and the
desired result is in position 8, and there are half a million positive
results. Then maybe that's not an efficient way to do it. So it it
better to write that method the way you did? Or is it better to write
it as a recursive function that calls search repeatedly---in principle
a quadratic algorithm. Or is it better to just write a recursion
that walks the list and looks for the first match and doesn't use
search()? The point I'm getting at is that the whole benefit of using
search() with the option to return only N hits is that it presumably
can save time vs searching the entire list, and you give up that
advantage if you want actual matches instead of the quirky type
matches it returns.
On Tue, Feb 15, 2022 at 2:12 AM MichaelAtOz oz.at.michael@gmail.com wrote:
Search returns the index 2
referring to [5,6] which is wrong.
It's not wrong, it's what it does.
If you have a data in a wrong structure, you will get wrong results. GIGO
So if you only want to operate on atomic entries in an unknown structure of course it is more work.
list=[3,4,[5,6],3,5,7,9,5,4,3];
// 0,1,2 ,3,4,5,6,7,8,9
function searchAtomic(needle,haystack,nth=0) =[
for (i = search([needle], haystack , 1e12) )
for (r = i)
if (!is_list(haystack[r]))
r ][nth];
echo(searchAtomic(5, list)); // 4
echo(searchAtomic(5, list,1)); // 7
echo(searchAtomic(5, list,9)); // undef
-----Original Message-----
From: Adrian Mariano [mailto:avm4@cornell.edu]
Sent: Tue, 15 Feb 2022 16:17
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: search function is broken
Yeah, that is surely the way to go. The trouble is that it's harder
to do than it appears. Suppose you want to find the first match. So
you do search([5], [3,4,[5,6],3,5]). Search returns the index 2
referring to [5,6] which is wrong. So how do you find the first
match? You need to look for the second match now? Or find all
matches from the beginning? There's not really a good solution. I
mean, you could assume that this case is rare and just recurse,
looking for the 2nd match if it fails. But it's complicated.
On Tue, Feb 15, 2022 at 12:10 AM A. Craig West acraigwest@gmail.com wrote:
I feel certain that I fell into this rabbit hole the first time I tried to use search
for something. I believe my solution then was to wrap it in more meaningful functions
On Mon, 14 Feb 2022, 11:45 nop head, nop.head@gmail.com wrote:
The warning itself seems broken because no matter what the string key is it only warns
about the second letter. Or perhaps I don't understand search. I have never used it
because it is pretty incomprehensible to me.
On Mon, 14 Feb 2022 at 16:36, Jordan Brown openscad@jordan.maileater.net wrote:
On 2/13/2022 3:14 PM, Adrian Mariano wrote:
I can't imagine why anybody thought issuing a warning when you don't find something
was a good idea.
Nor can I. But removing a warning is a compatible change...
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
--
This email has been checked for viruses by AVG.
https://www.avg.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
If your goal is to write a normal search that returns the items that
actually match, then it's wrong. The code you show chooses the
option of finding all matches and then looking through that result for
the desired output. What if your list has a million entries and the
desired result is in position 8, and there are half a million positive
results. Then maybe that's not an efficient way to do it. So it it
better to write that method the way you did? Or is it better to write
it as a recursive function that calls search repeatedly---in principle
a quadratic algorithm. Or is it better to just write a recursion
that walks the list and looks for the first match and doesn't use
search()? The point I'm getting at is that the whole benefit of using
search() with the option to return only N hits is that it presumably
can save time vs searching the entire list, and you give up that
advantage if you want actual matches instead of the quirky type
matches it returns.
On Tue, Feb 15, 2022 at 2:12 AM MichaelAtOz <oz.at.michael@gmail.com> wrote:
>
> > Search returns the index 2
> > referring to [5,6] which is wrong.
>
> It's not wrong, it's what it does.
> If you have a data in a wrong structure, you will get wrong results. GIGO
> So if you only want to operate on atomic entries in an unknown structure of course it is more work.
>
> list=[3,4,[5,6],3,5,7,9,5,4,3];
> // 0,1,2 ,3,4,5,6,7,8,9
> function searchAtomic(needle,haystack,nth=0) =[
> for (i = search([needle], haystack , 1e12) )
> for (r = i)
> if (!is_list(haystack[r]))
> r ][nth];
> echo(searchAtomic(5, list)); // 4
> echo(searchAtomic(5, list,1)); // 7
> echo(searchAtomic(5, list,9)); // undef
>
>
>
> > -----Original Message-----
> > From: Adrian Mariano [mailto:avm4@cornell.edu]
> > Sent: Tue, 15 Feb 2022 16:17
> > To: OpenSCAD general discussion
> > Subject: [OpenSCAD] Re: search function is broken
> >
> > Yeah, that is surely the way to go. The trouble is that it's harder
> > to do than it appears. Suppose you want to find the first match. So
> > you do search([5], [3,4,[5,6],3,5]). Search returns the index 2
> > referring to [5,6] which is wrong. So how do you find the first
> > match? You need to look for the second match now? Or find all
> > matches from the beginning? There's not really a good solution. I
> > mean, you could assume that this case is rare and just recurse,
> > looking for the 2nd match if it fails. But it's complicated.
> >
> >
> >
> > On Tue, Feb 15, 2022 at 12:10 AM A. Craig West <acraigwest@gmail.com> wrote:
> > >
> > > I feel certain that I fell into this rabbit hole the first time I tried to use search
> > for something. I believe my solution then was to wrap it in more meaningful functions
> > >
> > > On Mon, 14 Feb 2022, 11:45 nop head, <nop.head@gmail.com> wrote:
> > >>
> > >> The warning itself seems broken because no matter what the string key is it only warns
> > about the second letter. Or perhaps I don't understand search. I have never used it
> > because it is pretty incomprehensible to me.
> > >>
> > >> On Mon, 14 Feb 2022 at 16:36, Jordan Brown <openscad@jordan.maileater.net> wrote:
> > >>>
> > >>> On 2/13/2022 3:14 PM, Adrian Mariano wrote:
> > >>>
> > >>> I can't imagine why anybody thought issuing a warning when you don't find something
> > was a good idea.
> > >>>
> > >>>
> > >>> Nor can I. But removing a warning is a compatible change...
> > >>>
> > >>> _______________________________________________
> > >>> 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
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.com
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
M
MichaelAtOz
Tue, Feb 15, 2022 12:50 PM
"Goal", "normal search", "actually match".
You use the tools available, don't blame the hammer because you want to use a screw.
You miss my point, IF you use appropriate data structures, it works.
If you have garbage structures you get garbage, it is entirely up to you.
search() does as advertised, it is not inherently wrong, use it the right way, it works.
[and you get warnings...just because your choice of haystack is a vector of vectors, does not mean
a non-match is a warning...I argued on GitHub...]
-----Original Message-----
From: Adrian Mariano [mailto:avm4@cornell.edu]
Sent: Tue, 15 Feb 2022 22:26
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: search function is broken
If your goal is to write a normal search that returns the items that
actually match, then it's wrong. The code you show chooses the
option of finding all matches and then looking through that result for
the desired output. What if your list has a million entries and the
desired result is in position 8, and there are half a million positive
results. Then maybe that's not an efficient way to do it. So it it
better to write that method the way you did? Or is it better to write
it as a recursive function that calls search repeatedly---in principle
a quadratic algorithm. Or is it better to just write a recursion
that walks the list and looks for the first match and doesn't use
search()? The point I'm getting at is that the whole benefit of using
search() with the option to return only N hits is that it presumably
can save time vs searching the entire list, and you give up that
advantage if you want actual matches instead of the quirky type
matches it returns.
On Tue, Feb 15, 2022 at 2:12 AM MichaelAtOz oz.at.michael@gmail.com wrote:
Search returns the index 2
referring to [5,6] which is wrong.
It's not wrong, it's what it does.
If you have a data in a wrong structure, you will get wrong results. GIGO
So if you only want to operate on atomic entries in an unknown structure of course it is
list=[3,4,[5,6],3,5,7,9,5,4,3];
// 0,1,2 ,3,4,5,6,7,8,9
function searchAtomic(needle,haystack,nth=0) =[
for (i = search([needle], haystack , 1e12) )
for (r = i)
if (!is_list(haystack[r]))
r ][nth];
echo(searchAtomic(5, list)); // 4
echo(searchAtomic(5, list,1)); // 7
echo(searchAtomic(5, list,9)); // undef
-----Original Message-----
From: Adrian Mariano [mailto:avm4@cornell.edu]
Sent: Tue, 15 Feb 2022 16:17
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: search function is broken
Yeah, that is surely the way to go. The trouble is that it's harder
to do than it appears. Suppose you want to find the first match. So
you do search([5], [3,4,[5,6],3,5]). Search returns the index 2
referring to [5,6] which is wrong. So how do you find the first
match? You need to look for the second match now? Or find all
matches from the beginning? There's not really a good solution. I
mean, you could assume that this case is rare and just recurse,
looking for the 2nd match if it fails. But it's complicated.
On Tue, Feb 15, 2022 at 12:10 AM A. Craig West acraigwest@gmail.com wrote:
I feel certain that I fell into this rabbit hole the first time I tried to use
for something. I believe my solution then was to wrap it in more meaningful functions
The warning itself seems broken because no matter what the string key is it only
about the second letter. Or perhaps I don't understand search. I have never used it
because it is pretty incomprehensible to me.
On 2/13/2022 3:14 PM, Adrian Mariano wrote:
I can't imagine why anybody thought issuing a warning when you don't find
"Goal", "normal search", "actually match".
You use the tools available, don't blame the hammer because you want to use a screw.
You miss my point, IF you use appropriate data structures, it works.
If you have garbage structures you get garbage, it is entirely up to you.
search() does as advertised, it is not inherently wrong, use it the right way, it works.
[and you get warnings...just because your choice of haystack is a vector of vectors, does not mean
a non-match is a warning...I argued on GitHub...]
> -----Original Message-----
> From: Adrian Mariano [mailto:avm4@cornell.edu]
> Sent: Tue, 15 Feb 2022 22:26
> To: OpenSCAD general discussion
> Subject: [OpenSCAD] Re: search function is broken
>
> If your goal is to write a normal search that returns the items that
> actually match, then it's wrong. The code you show chooses the
> option of finding all matches and then looking through that result for
> the desired output. What if your list has a million entries and the
> desired result is in position 8, and there are half a million positive
> results. Then maybe that's not an efficient way to do it. So it it
> better to write that method the way you did? Or is it better to write
> it as a recursive function that calls search repeatedly---in principle
> a quadratic algorithm. Or is it better to just write a recursion
> that walks the list and looks for the first match and doesn't use
> search()? The point I'm getting at is that the whole benefit of using
> search() with the option to return only N hits is that it presumably
> can save time vs searching the entire list, and you give up that
> advantage if you want actual matches instead of the quirky type
> matches it returns.
>
> On Tue, Feb 15, 2022 at 2:12 AM MichaelAtOz <oz.at.michael@gmail.com> wrote:
> >
> > > Search returns the index 2
> > > referring to [5,6] which is wrong.
> >
> > It's not wrong, it's what it does.
> > If you have a data in a wrong structure, you will get wrong results. GIGO
> > So if you only want to operate on atomic entries in an unknown structure of course it is
> more work.
> >
> > list=[3,4,[5,6],3,5,7,9,5,4,3];
> > // 0,1,2 ,3,4,5,6,7,8,9
> > function searchAtomic(needle,haystack,nth=0) =[
> > for (i = search([needle], haystack , 1e12) )
> > for (r = i)
> > if (!is_list(haystack[r]))
> > r ][nth];
> > echo(searchAtomic(5, list)); // 4
> > echo(searchAtomic(5, list,1)); // 7
> > echo(searchAtomic(5, list,9)); // undef
> >
> >
> >
> > > -----Original Message-----
> > > From: Adrian Mariano [mailto:avm4@cornell.edu]
> > > Sent: Tue, 15 Feb 2022 16:17
> > > To: OpenSCAD general discussion
> > > Subject: [OpenSCAD] Re: search function is broken
> > >
> > > Yeah, that is surely the way to go. The trouble is that it's harder
> > > to do than it appears. Suppose you want to find the first match. So
> > > you do search([5], [3,4,[5,6],3,5]). Search returns the index 2
> > > referring to [5,6] which is wrong. So how do you find the first
> > > match? You need to look for the second match now? Or find all
> > > matches from the beginning? There's not really a good solution. I
> > > mean, you could assume that this case is rare and just recurse,
> > > looking for the 2nd match if it fails. But it's complicated.
> > >
> > >
> > >
> > > On Tue, Feb 15, 2022 at 12:10 AM A. Craig West <acraigwest@gmail.com> wrote:
> > > >
> > > > I feel certain that I fell into this rabbit hole the first time I tried to use
> search
> > > for something. I believe my solution then was to wrap it in more meaningful functions
> > > >
> > > > On Mon, 14 Feb 2022, 11:45 nop head, <nop.head@gmail.com> wrote:
> > > >>
> > > >> The warning itself seems broken because no matter what the string key is it only
> warns
> > > about the second letter. Or perhaps I don't understand search. I have never used it
> > > because it is pretty incomprehensible to me.
> > > >>
> > > >> On Mon, 14 Feb 2022 at 16:36, Jordan Brown <openscad@jordan.maileater.net> wrote:
> > > >>>
> > > >>> On 2/13/2022 3:14 PM, Adrian Mariano wrote:
> > > >>>
> > > >>> I can't imagine why anybody thought issuing a warning when you don't find
> something
> > > was a good idea.
> > > >>>
> > > >>>
> > > >>> Nor can I. But removing a warning is a compatible change...
> > > >>>
> > > >>> _______________________________________________
> > > >>> 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
> >
> >
> > --
> > This email has been checked for viruses by AVG.
> > https://www.avg.com
> > _______________________________________________
> > 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
--
This email has been checked for viruses by AVG.
https://www.avg.com
RP
Ronaldo Persiano
Tue, Feb 15, 2022 4:21 PM
It's not wrong, it's what it does.
If you have a data in a wrong structure, you will get wrong results. GIGO
You miss my point, IF you use appropriate data structures, it works.
If you have garbage structures you get garbage, it is entirely up to you.
Do your consider garbage a list mixing types, for instance, with singletons
and vectors? Aren't you blaming the patient for a wrong medical diagnosis?
I understand the rationale behind the function search(). It has an argument
index_col_num to allow the specification of the vector component of the
input list entries it should search. Its default is 0, that is, the first
component. But the trouble is we don't have a way to specify the search
target should be just singleton entries. The default value of
index_col_num means we want to search singletons and lists. (It is
interesting that when index_col_num has a value other than 0 singletons
are ignored by search() )
You may not consider that is a wrong design but it is a bad design. A very
bad one.
Function search() should not have a default for index_col_num. If the
argument is missing (undef) it should look just for matching singletons.
And if index_col_num is given, it should look only that entry in vectors.
It is dangerous to use a hammer working sometimes as a hatchet even if you
know this is what it does.
MichaelAtOz <oz.at.michael@gmail.com> wrote:
> It's not wrong, it's what it does.
> If you have a data in a wrong structure, you will get wrong results. GIGO
>
You miss my point, IF you use appropriate data structures, it works.
> If you have garbage structures you get garbage, it is entirely up to you.
Do your consider garbage a list mixing types, for instance, with singletons
and vectors? Aren't you blaming the patient for a wrong medical diagnosis?
I understand the rationale behind the function search(). It has an argument
*index_col_num* to allow the specification of the vector component of the
input list entries it should search. Its default is 0, that is, the first
component. But the trouble is we don't have a way to specify the search
target should be just singleton entries. The default value of
*index_col_num* means we want to search singletons and lists. (It is
interesting that when *index_col_num* has a value other than 0 singletons
are ignored by search() )
You may not consider that is a wrong design but it is a bad design. A very
bad one.
Function search() should not have a default for *index_col_num*. If the
argument is missing (undef) it should look just for matching singletons.
And if *index_col_num* is given, it should look only that entry in vectors.
It is dangerous to use a hammer working sometimes as a hatchet even if you
know this is what it does.
J
jon
Tue, Feb 15, 2022 5:22 PM
I sense a little more emotion than usual around this topic. I don't use
Search at all, but as a community we should be able to have this
conversation based solely on the merits of the technical issues at hand.
Jon
On 2/15/2022 11:21 AM, Ronaldo Persiano wrote:
MichaelAtOz oz.at.michael@gmail.com wrote:
It's not wrong, it's what it does.
If you have a data in a wrong structure, you will get wrong
results. GIGO
You miss my point, IF you use appropriate data structures, it works.
If you have garbage structures you get garbage, it is entirely up
to you.
Do your consider garbage a list mixing types, for instance, with
singletons and vectors? Aren't you blaming the patient for a wrong
medical diagnosis?
I understand the rationale behind the function search(). It has an
argument index_col_numto allow the specification of the vector
component of the input list entries it should search. Its default is
0, that is, the first component. But the trouble is we don't have a
way to specify the search target should be just singleton entries. The
default value of index_col_num means we want to search singletons
and lists. (It is interesting that when index_col_num has a value
other than 0 singletons are ignored by search() )
You may not consider that is a wrong design but it is a bad design. A
very bad one.
Function search() should not have a default for index_col_num. If
the argument is missing (undef) it should look just for matching
singletons. And if index_col_num is given, it should look only that
entry in vectors.
It is dangerous to use a hammer working sometimes as a hatchet even if
you know this is what it does.
OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org
I sense a little more emotion than usual around this topic. I don't use
Search at all, but as a community we should be able to have this
conversation based solely on the merits of the technical issues at hand.
Jon
On 2/15/2022 11:21 AM, Ronaldo Persiano wrote:
>
>
> MichaelAtOz <oz.at.michael@gmail.com> wrote:
>
> It's not wrong, it's what it does.
> If you have a data in a wrong structure, you will get wrong
> results. GIGO
>
>
> You miss my point, IF you use appropriate data structures, it works.
> If you have garbage structures you get garbage, it is entirely up
> to you.
>
>
> Do your consider garbage a list mixing types, for instance, with
> singletons and vectors? Aren't you blaming the patient for a wrong
> medical diagnosis?
>
> I understand the rationale behind the function search(). It has an
> argument *index_col_num*to allow the specification of the vector
> component of the input list entries it should search. Its default is
> 0, that is, the first component. But the trouble is we don't have a
> way to specify the search target should be just singleton entries. The
> default value of *index_col_num* means we want to search singletons
> and lists. (It is interesting that when *index_col_num* has a value
> other than 0 singletons are ignored by search() )
>
> You may not consider that is a wrong design but it is a bad design. A
> very bad one.
> Function search() should not have a default for *index_col_num*. If
> the argument is missing (undef) it should look just for matching
> singletons. And if *index_col_num* is given, it should look only that
> entry in vectors.
>
> It is dangerous to use a hammer working sometimes as a hatchet even if
> you know this is what it does.
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email todiscuss-leave@lists.openscad.org
RP
Ronaldo Persiano
Tue, Feb 15, 2022 9:18 PM
I was imprecise in the alternative behavior of search() I suggested in my
last message. It should be:
Function search() should not have a default value for index_col_num. If
the argument is missing (undef), search() should look just for matching
full list entries (either a singleton or a vector). And if index_col_num is
given, it should look only at the prescribed column of vectors that have
that column.
Despite the disputable warnings, function search() doesn't like to report
errors even when it should. For instance, if some of the arguments
num_returns_per_match or index_col_num is not a positive integer,
the function resets the argument to its default value. That is bad because
the argument value might be defined elsewhere and the bug will not be
evident because search() will silently return a valid response. To report
an error in these cases seems a better choice.
echo(search([5], [[1,2], 5, [5,1]],num_returns_per_match =
"a",index_col_num = []));
// ECHO: [[1, 2]]
Em ter., 15 de fev. de 2022 às 13:21, Ronaldo Persiano <
rcmpersiano@gmail.com> escreveu:
It's not wrong, it's what it does.
If you have a data in a wrong structure, you will get wrong results. GIGO
You miss my point, IF you use appropriate data structures, it works.
If you have garbage structures you get garbage, it is entirely up to you.
Do your consider garbage a list mixing types, for instance, with
singletons and vectors? Aren't you blaming the patient for a wrong medical
diagnosis?
I understand the rationale behind the function search(). It has an
argument index_col_num to allow the specification of the vector
component of the input list entries it should search. Its default is 0,
that is, the first component. But the trouble is we don't have a way to
specify the search target should be just singleton entries. The default
value of index_col_num means we want to search singletons and lists.
(It is interesting that when index_col_num has a value other than 0
singletons are ignored by search() )
You may not consider that is a wrong design but it is a bad design. A very
bad one.
Function search() should not have a default for index_col_num. If the
argument is missing (undef) it should look just for matching singletons.
And if index_col_num is given, it should look only that entry in
vectors.
It is dangerous to use a hammer working sometimes as a hatchet even if
you know this is what it does.
I was imprecise in the alternative behavior of search() I suggested in my
last message. It should be:
Function search() should not have a default value for *index_col_num*. If
the argument is missing (undef), search() should look just for matching
full list entries (either a singleton or a vector). And if *index_col_num* is
given, it should look only at the prescribed column of vectors that have
that column.
Despite the disputable warnings, function search() doesn't like to report
errors even when it should. For instance, if some of the arguments
*num_returns_per_match* or *index_col_num* is not a positive integer,
the function resets the argument to its default value. That is bad because
the argument value might be defined elsewhere and the bug will not be
evident because search() will silently return a valid response. To report
an error in these cases seems a better choice.
echo(search([5], [[1,2], 5, [5,1]],num_returns_per_match =
"a",index_col_num = []));
// ECHO: [[1, 2]]
Em ter., 15 de fev. de 2022 às 13:21, Ronaldo Persiano <
rcmpersiano@gmail.com> escreveu:
>
>
> MichaelAtOz <oz.at.michael@gmail.com> wrote:
>
>> It's not wrong, it's what it does.
>> If you have a data in a wrong structure, you will get wrong results. GIGO
>>
>
> You miss my point, IF you use appropriate data structures, it works.
>> If you have garbage structures you get garbage, it is entirely up to you.
>
>
> Do your consider garbage a list mixing types, for instance, with
> singletons and vectors? Aren't you blaming the patient for a wrong medical
> diagnosis?
>
> I understand the rationale behind the function search(). It has an
> argument *index_col_num* to allow the specification of the vector
> component of the input list entries it should search. Its default is 0,
> that is, the first component. But the trouble is we don't have a way to
> specify the search target should be just singleton entries. The default
> value of *index_col_num* means we want to search singletons and lists.
> (It is interesting that when *index_col_num* has a value other than 0
> singletons are ignored by search() )
>
> You may not consider that is a wrong design but it is a bad design. A very
> bad one.
>
> Function search() should not have a default for *index_col_num*. If the
> argument is missing (undef) it should look just for matching singletons.
> And if *index_col_num* is given, it should look only that entry in
> vectors.
>
> It is dangerous to use a hammer working sometimes as a hatchet even if
> you know this is what it does.
>