discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] ranges to vectors

R
runsun
Wed, Nov 11, 2015 6:53 PM

doug.moen wrote

In my opinion, len([0:9]) ought to work. A range ought to be accepted in
any context where a vector is accepted, and should be automatically
converted to a vector if necessary. Eg, concat([0:2], [8,9,10]) should
return [0,1,2,8,9,10].

+1


$  Runsun Pan, PhD

$ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 , git );

$ tips: hash( 1 , 2 ), sweep , var , lerp , animGif

--
View this message in context: http://forum.openscad.org/ranges-to-vectors-tp7651p14373.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

doug.moen wrote > In my opinion, len([0:9]) ought to work. A range ought to be accepted in > any context where a vector is accepted, and should be automatically > converted to a vector if necessary. Eg, concat([0:2], [8,9,10]) should > return [0,1,2,8,9,10]. +1 ----- $ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 , git ); $ tips: hash( 1 , 2 ), sweep , var , lerp , animGif -- View this message in context: http://forum.openscad.org/ranges-to-vectors-tp7651p14373.html Sent from the OpenSCAD mailing list archive at Nabble.com.
DM
doug moen
Thu, Nov 12, 2015 2:25 AM

My range proposal is here:
https://github.com/doug-moen/openscad2/blob/master/rfc/Sequences.md

On 11 November 2015 at 13:53, runsun runsun@gmail.com wrote:

doug.moen wrote

In my opinion, len([0:9]) ought to work. A range ought to be accepted in
any context where a vector is accepted, and should be automatically
converted to a vector if necessary. Eg, concat([0:2], [8,9,10]) should
return [0,1,2,8,9,10].

+1


$  Runsun Pan, PhD

$ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 ,
git );

$ tips: hash( 1 , 2 ), sweep , var , lerp , animGif

--
View this message in context:
http://forum.openscad.org/ranges-to-vectors-tp7651p14373.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

My range proposal is here: https://github.com/doug-moen/openscad2/blob/master/rfc/Sequences.md On 11 November 2015 at 13:53, runsun <runsun@gmail.com> wrote: > doug.moen wrote > > In my opinion, len([0:9]) ought to work. A range ought to be accepted in > > any context where a vector is accepted, and should be automatically > > converted to a vector if necessary. Eg, concat([0:2], [8,9,10]) should > > return [0,1,2,8,9,10]. > > +1 > > > > > ----- > > $ Runsun Pan, PhD > > $ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 , > git ); > > $ tips: hash( 1 , 2 ), sweep , var , lerp , animGif > > > > > > > -- > View this message in context: > http://forum.openscad.org/ranges-to-vectors-tp7651p14373.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 > > >
V
vicnet
Thu, Nov 12, 2015 8:10 AM

Hello,

doug.moen wrote

Wahou, nice compilation !

Just add that end parameter for slice could be negative.

For exemple v[:-1] returns v without it's last element.

Don't like .. notation, espcially for increments [start,start+inc..end].
Too complex for me.
Prefer current notation with :

a+
Vicnet

--
View this message in context: http://forum.openscad.org/ranges-to-vectors-tp7651p14393.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hello, doug.moen wrote > My range proposal is here: > https://github.com/doug-moen/openscad2/blob/master/rfc/Sequences.md Wahou, nice compilation ! Just add that end parameter for slice could be negative. For exemple v[:-1] returns v without it's last element. Don't like .. notation, espcially for increments [start,start+inc..end]. Too complex for me. Prefer current notation with : a+ Vicnet -- View this message in context: http://forum.openscad.org/ranges-to-vectors-tp7651p14393.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
runsun
Thu, Nov 12, 2015 6:19 PM

doug.moen wrote

Nice summary of sequences and suggestions !!

echo([1..5]) prints [1,2,3,4,5]. Ranges in Python2 and Haskell work the
same way.

Just a minor side note: it seems that [i..j] gives syntax error in python2.
Also, python range ends with last_index+1.


$  Runsun Pan, PhD

$ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 , git );

$ tips: hash( 1 , 2 ), sweep , var , lerp , animGif

--
View this message in context: http://forum.openscad.org/ranges-to-vectors-tp7651p14410.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

doug.moen wrote > My range proposal is here: > https://github.com/doug-moen/openscad2/blob/master/rfc/Sequences.md Nice summary of sequences and suggestions !! > echo([1..5]) prints [1,2,3,4,5]. Ranges in Python2 and Haskell work the > same way. Just a minor side note: it seems that [i..j] gives syntax error in python2. Also, python range ends with last_index+1. ----- $ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 , git ); $ tips: hash( 1 , 2 ), sweep , var , lerp , animGif -- View this message in context: http://forum.openscad.org/ranges-to-vectors-tp7651p14410.html Sent from the OpenSCAD mailing list archive at Nabble.com.