discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Array question

R
runsun
Sun, Dec 4, 2016 12:27 AM

Try this:

m= [[1,2],[3,4]];

function has(m,pt)=
(
len( [for(p=m) if(p==pt) 1] )>0
);

echo( has(m, [3,4] ) ); // true
echo( has(m, [3,5] ) ); // false


$  Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 );   $ tips: Bezier , hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2, 3 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg , tests ( 2 ), text , triang , unit ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf )

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

Try this: m= [[1,2],[3,4]]; function has(m,pt)= ( len( [for(p=m) if(p==pt) 1] )>0 ); echo( has(m, [3,4] ) ); // true echo( has(m, [3,5] ) ); // false ----- $ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 );   $ tips: Bezier , hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2, 3 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg , tests ( 2 ), text , triang , unit ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf ) -- View this message in context: http://forum.openscad.org/Array-question-tp19450p19451.html Sent from the OpenSCAD mailing list archive at Nabble.com.