[OpenSCAD] Openscad Indirect Functions

doug moen doug at moens.org
Tue Oct 18 16:51:04 EDT 2016


Runsun said:
> Just add javascript's version of lambda, *Arrows*
>    array.map( x=> x+2 )

I'm currently using -> instead of => in my prototype.

The -> syntax is used in the syntax of anonymous functions by:
C++11, Java, Swift, Haskell, F#, Erlang, Julia

The => syntax is used by
Javascript, C#, D, Scala, Standard ML

In terms of programming language popularity, it's really a tossup. I'm
using -> for a couple of reasons.

   - The → symbol is what's used in mathematics to describe functions, eg f
   : x → x².
   - There are already too many operators that contain the = character (=,
   ==, <=, >=), and all of these operators have some connection to the
   concept of equality. The => symbol looks too much like these other
   operators.


On 18 October 2016 at 11:21, runsun <runsun at gmail.com> wrote:

> ottojas wrote
> > Python likes:
> >
> > lambda x: x+2
> >
> > For anonymous syntax.
> >
> > Lisp likes
> >
> >  (lambda (x) (+ arg 2))
> >
> > For same operation.  I don't particularly like either construct but
> > either could be implemented.
> >
> > I have now implemented
> >
> >    @(x:x+2)
>
> Just add javascript's version of lambda, *Arrows*, for the reference. This
> is more powerful than Python's, imo:
>
>
> >    f = x=> x+2
> >    f = ()=>{ do something, return something }
> >
> >    array.map( x=> x+2 )
> >    array.map( (x,i)=> `${i}:${x+2}` )  // for array [5,10], return [
> > "0:7","1:12"]
> >    array.map( (x,i)=> { do something } )
>
>
>
>
>
> -----
>
> $  Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ),
> runscad.py ( 2 , git ), synwrite ( 2 );   $ tips: 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 ); $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf )
> --
> View this message in context: http://forum.openscad.org/
> Convert-from-object-to-polygon-polyhedron-tp18522p18764.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20161018/551d795f/attachment-0002.html>


More information about the Discuss mailing list