discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

reverse() and operator for concat()?

B
Bananapeel
Fri, Jan 30, 2015 10:35 PM

It would make sense for a function like this to be included as standard:

//      reverse a(a)
//      reverse the order of the elements in the vector a
function reverse (a, i=0) =
len(a) > i ?
concat(a[i],  reverse(a, i+1)) :
[]
;

And wouldn't it be good to have an operator for concat? Something like &, ++
or @. Of course not every function can get its own operator.

function reverse (a, i=0) =
len(a) > i ?
a[i] ++ reverse(a, i+1) :
[]
;

--
View this message in context: http://forum.openscad.org/reverse-and-operator-for-concat-tp11336.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

It would make sense for a function like this to be included as standard: // reverse a(a) // reverse the order of the elements in the vector a function reverse (a, i=0) = len(a) > i ? concat(a[i], reverse(a, i+1)) : [] ; And wouldn't it be good to have an operator for concat? Something like &, ++ or @. Of course not every function can get its own operator. function reverse (a, i=0) = len(a) > i ? a[i] ++ reverse(a, i+1) : [] ; -- View this message in context: http://forum.openscad.org/reverse-and-operator-for-concat-tp11336.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MK
Marius Kintel
Fri, Jan 30, 2015 10:41 PM

On Jan 30, 2015, at 17:35 PM, Bananapeel lunatica.xiaoyu@gmail.com wrote:

It would make sense for a function like this to be included as standard:

See https://github.com/openscad/scad-utils/blob/master/lists.scad

We’re still discussing having a new, more clean standard library.

And wouldn't it be good to have an operator for concat? Something like &, ++
or @. Of course not every function can get its own operator.

It could be useful. We’ve been holding back a bit on operators, but this is indeed a possibility.

-Marius

On Jan 30, 2015, at 17:35 PM, Bananapeel <lunatica.xiaoyu@gmail.com> wrote: > It would make sense for a function like this to be included as standard: > See https://github.com/openscad/scad-utils/blob/master/lists.scad We’re still discussing having a new, more clean standard library. > And wouldn't it be good to have an operator for concat? Something like &, ++ > or @. Of course not every function can get its own operator. > It could be useful. We’ve been holding back a bit on operators, but this is indeed a possibility. -Marius
B
Bananapeel
Fri, Jan 30, 2015 10:53 PM

I see. Simply distributing scad-utils in the openscad package could be a
start.

--
View this message in context: http://forum.openscad.org/reverse-and-operator-for-concat-tp11336p11341.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I see. Simply distributing scad-utils in the openscad package could be a start. -- View this message in context: http://forum.openscad.org/reverse-and-operator-for-concat-tp11336p11341.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MK
Marius Kintel
Fri, Jan 30, 2015 10:59 PM

On Jan 30, 2015, at 17:53 PM, Bananapeel lunatica.xiaoyu@gmail.com wrote:

I see. Simply distributing scad-utils in the openscad package could be a
start.

That’s the goal, but we need to work more on the API. Some of this is already done in the MCAD dev-branch, but it’s still undecided how/when to get that into OpenSCAD proper.

-Marius

On Jan 30, 2015, at 17:53 PM, Bananapeel <lunatica.xiaoyu@gmail.com> wrote: > I see. Simply distributing scad-utils in the openscad package could be a > start. > That’s the goal, but we need to work more on the API. Some of this is already done in the MCAD dev-branch, but it’s still undecided how/when to get that into OpenSCAD proper. -Marius