discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

search function

K
kitwallace
Wed, Jan 21, 2015 1:22 PM

v=[[1,2],[2,3],[3,4]];
echo(search([1,2],v));

returns [0,1]

I would like it to return [0] i.e. to match the vector as a unit .

any ideas?  I can use a recursive function or even a list comprehension but
they must be quite slow.

Chris

--
View this message in context: http://forum.openscad.org/search-function-tp11171.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

v=[[1,2],[2,3],[3,4]]; echo(search([1,2],v)); returns [0,1] I would like it to return [0] i.e. to match the vector as a unit . any ideas? I can use a recursive function or even a list comprehension but they must be quite slow. Chris -- View this message in context: http://forum.openscad.org/search-function-tp11171.html Sent from the OpenSCAD mailing list archive at Nabble.com.
AP
Andrew Plumb
Wed, Jan 21, 2015 1:30 PM

Try making it a list of vectors instead of a list of numbers:

echo(search([[2,3]],v));
echo(search([[2,3],[3,4],[1,2]],v));

Andrew.

On Jan 21, 2015, at 8:22 AM, kitwallace kit.wallace@gmail.com wrote:

v=[[1,2],[2,3],[3,4]];
echo(search([1,2],v));

returns [0,1]

I would like it to return [0] i.e. to match the vector as a unit .

any ideas?  I can use a recursive function or even a list comprehension but
they must be quite slow.

Chris

--
View this message in context: http://forum.openscad.org/search-function-tp11171.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--

"The future is already here.  It's just not very evenly distributed" -- William Gibson

Me: http://clothbot.com/wiki/

Try making it a list of vectors instead of a list of numbers: echo(search([[2,3]],v)); echo(search([[2,3],[3,4],[1,2]],v)); Andrew. > On Jan 21, 2015, at 8:22 AM, kitwallace <kit.wallace@gmail.com> wrote: > > > v=[[1,2],[2,3],[3,4]]; > echo(search([1,2],v)); > > returns [0,1] > > I would like it to return [0] i.e. to match the vector as a unit . > > any ideas? I can use a recursive function or even a list comprehension but > they must be quite slow. > > Chris > > > > > > -- > View this message in context: http://forum.openscad.org/search-function-tp11171.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- "The future is already here. It's just not very evenly distributed" -- William Gibson Me: http://clothbot.com/wiki/
K
kitwallace
Wed, Jan 21, 2015 1:46 PM

Genius! Many thanks.

--
View this message in context: http://forum.openscad.org/search-function-tp11171p11174.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Genius! Many thanks. -- View this message in context: http://forum.openscad.org/search-function-tp11171p11174.html Sent from the OpenSCAD mailing list archive at Nabble.com.