^

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

^

jlm@justinfront.net
Seems very logical to support a^b as a short cut for Math.pow( a,  
b );  I know this is not really an important feature but it would make  
some maths in haXe look a lot nicer, and would make haXe more  
approachable as unlike some fancy feature requests ^ seems fairly  
established notation, I guess if it was considered worthwhile to add  
then obviously for consistency   a ^= b   could be used   a =  
Math.pow( a, b );  probably very rare but logical in keeping  
everything consistent.  I guess I am coming from the direction of  
making haXe a language suitable for school students experimenting with  
maths practically.

For instance not tried it yet but this function currently in haXe...

     private function quadraticBezier( startPoint: Float,  
controlPoint: Float, endPoint: Float )
     {

         return  Math.pow( (1 – t), 2 ) * startPoint + 2(1 – t) * t *  
controlPoint + Math.pow( t, 2 ) * endPoint;

     }

looks cleaner as...

     private function quadraticBezier( startPoint: Float,  
controlPoint: Float, endPoint: Float )
     {

         return  (1 – t)^2 * startPoint + 2(1 – t) * t * controlPoint  
+ t^2 * endPoint;

     }

and ofcourse

        var distance = Math.pow( Math.pow( x2 - x1, 2 ) + Math.pow( y2 - y1,  
2 ), 0.5 );

would be written in a much nicer form...

        var distance = (  ( x2 - x1)^2  +  ( y2 - y1 )^2  )^0.5;

you can argue that trig is currently a bit verbose, but you can create  
a short cut in your code so that complex series can be written to be  
easier to read.

var sine = Math.sin;
var cos = Math.cos;

var x = r* sin( theta );
var y = r* cos( theta );

but this does not work so well with pow.

Anyway just a thought.


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: ^

Juraj Kirchheim
I think "using Math;" is good enough here, as it reduces things to:

   return  (1 – t).pow(2) * startPoint + 2 * (1 – t) * t *
controlPoint + t.pow(2) * endPoint;

   var x = r* theta.sin();
   var y = r* theta.cos();

Also ^ already means bitwise XOR, so something else must be used
(python's ** might be an idea).

greetz,
back2dos

On Mon, Oct 3, 2011 at 3:00 AM, [hidden email] <[hidden email]> wrote:

> Seems very logical to support a^b as a short cut for Math.pow( a, b );  I
> know this is not really an important feature but it would make some maths in
> haXe look a lot nicer, and would make haXe more approachable as unlike some
> fancy feature requests ^ seems fairly established notation, I guess if it
> was considered worthwhile to add then obviously for consistency   a ^= b
> could be used   a = Math.pow( a, b );  probably very rare but logical in
> keeping everything consistent.  I guess I am coming from the direction of
> making haXe a language suitable for school students experimenting with maths
> practically.
>
> For instance not tried it yet but this function currently in haXe...
>
>    private function quadraticBezier( startPoint: Float, controlPoint: Float,
> endPoint: Float )
>    {
>
>        return  Math.pow( (1 – t), 2 ) * startPoint + 2(1 – t) * t *
> controlPoint + Math.pow( t, 2 ) * endPoint;
>
>    }
>
> looks cleaner as...
>
>    private function quadraticBezier( startPoint: Float, controlPoint: Float,
> endPoint: Float )
>    {
>
>        return  (1 – t)^2 * startPoint + 2(1 – t) * t * controlPoint + t^2 *
> endPoint;
>
>    }
>
> and ofcourse
>
>        var distance = Math.pow( Math.pow( x2 - x1, 2 ) + Math.pow( y2 - y1,
> 2 ), 0.5 );
>
> would be written in a much nicer form...
>
>        var distance = (  ( x2 - x1)^2  +  ( y2 - y1 )^2  )^0.5;
>
> you can argue that trig is currently a bit verbose, but you can create a
> short cut in your code so that complex series can be written to be easier to
> read.
>
> var sine = Math.sin;
> var cos = Math.cos;
>
> var x = r* sin( theta );
> var y = r* cos( theta );
>
> but this does not work so well with pow.
>
> Anyway just a thought.
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: ^

Mario Carbajal
In reply to this post by jlm@justinfront.net
^ is already used for bitwise xor.

On Sun, Oct 2, 2011 at 10:00 PM, [hidden email] <[hidden email]> wrote:
Seems very logical to support a^b as a short cut for Math.pow( a, b );  I know this is not really an important feature but it would make some maths in haXe look a lot nicer, and would make haXe more approachable as unlike some fancy feature requests ^ seems fairly established notation, I guess if it was considered worthwhile to add then obviously for consistency   a ^= b   could be used   a = Math.pow( a, b );  probably very rare but logical in keeping everything consistent.  I guess I am coming from the direction of making haXe a language suitable for school students experimenting with maths practically.

For instance not tried it yet but this function currently in haXe...

   private function quadraticBezier( startPoint: Float, controlPoint: Float, endPoint: Float )
   {

       return  Math.pow( (1 – t), 2 ) * startPoint + 2(1 – t) * t * controlPoint + Math.pow( t, 2 ) * endPoint;

   }

looks cleaner as...

   private function quadraticBezier( startPoint: Float, controlPoint: Float, endPoint: Float )
   {

       return  (1 – t)^2 * startPoint + 2(1 – t) * t * controlPoint + t^2 * endPoint;

   }

and ofcourse

       var distance = Math.pow( Math.pow( x2 - x1, 2 ) + Math.pow( y2 - y1, 2 ), 0.5 );

would be written in a much nicer form...

       var distance = (  ( x2 - x1)^2  +  ( y2 - y1 )^2  )^0.5;

you can argue that trig is currently a bit verbose, but you can create a short cut in your code so that complex series can be written to be easier to read.

var sine = Math.sin;
var cos = Math.cos;

var x = r* sin( theta );
var y = r* cos( theta );

but this does not work so well with pow.

Anyway just a thought.


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: ^

jlm@justinfront.net
oops sorry :)
On 3 Oct 2011, at 02:49, Mario Carbajal wrote:

^ is already used for bitwise xor.

On Sun, Oct 2, 2011 at 10:00 PM, [hidden email] <[hidden email]> wrote:
Seems very logical to support a^b as a short cut for Math.pow( a, b );  I know this is not really an important feature but it would make some maths in haXe look a lot nicer, and would make haXe more approachable as unlike some fancy feature requests ^ seems fairly established notation, I guess if it was considered worthwhile to add then obviously for consistency   a ^= b   could be used   a = Math.pow( a, b );  probably very rare but logical in keeping everything consistent.  I guess I am coming from the direction of making haXe a language suitable for school students experimenting with maths practically.

For instance not tried it yet but this function currently in haXe...

   private function quadraticBezier( startPoint: Float, controlPoint: Float, endPoint: Float )
   {

       return  Math.pow( (1 – t), 2 ) * startPoint + 2(1 – t) * t * controlPoint + Math.pow( t, 2 ) * endPoint;

   }

looks cleaner as...

   private function quadraticBezier( startPoint: Float, controlPoint: Float, endPoint: Float )
   {

       return  (1 – t)^2 * startPoint + 2(1 – t) * t * controlPoint + t^2 * endPoint;

   }

and ofcourse

       var distance = Math.pow( Math.pow( x2 - x1, 2 ) + Math.pow( y2 - y1, 2 ), 0.5 );

would be written in a much nicer form...

       var distance = (  ( x2 - x1)^2  +  ( y2 - y1 )^2  )^0.5;

you can argue that trig is currently a bit verbose, but you can create a short cut in your code so that complex series can be written to be easier to read.

var sine = Math.sin;
var cos = Math.cos;

var x = r* sin( theta );
var y = r* cos( theta );

but this does not work so well with pow.

Anyway just a thought.


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: ^

Yanis Benson

By the way, why don't we have logical xor?

On 3 Oct 2011 06:28, "[hidden email]" <[hidden email]> wrote:
> oops sorry :)
> On 3 Oct 2011, at 02:49, Mario Carbajal wrote:
>
>> ^ is already used for bitwise xor.
>>
>> On Sun, Oct 2, 2011 at 10:00 PM, [hidden email] <[hidden email]
>> > wrote:
>> Seems very logical to support a^b as a short cut for Math.pow( a,
>> b ); I know this is not really an important feature but it would
>> make some maths in haXe look a lot nicer, and would make haXe more
>> approachable as unlike some fancy feature requests ^ seems fairly
>> established notation, I guess if it was considered worthwhile to add
>> then obviously for consistency a ^= b could be used a =
>> Math.pow( a, b ); probably very rare but logical in keeping
>> everything consistent. I guess I am coming from the direction of
>> making haXe a language suitable for school students experimenting
>> with maths practically.
>>
>> For instance not tried it yet but this function currently in haXe...
>>
>> private function quadraticBezier( startPoint: Float,
>> controlPoint: Float, endPoint: Float )
>> {
>>
>> return Math.pow( (1 – t), 2 ) * startPoint + 2(1 – t) * t *
>> controlPoint + Math.pow( t, 2 ) * endPoint;
>>
>> }
>>
>> looks cleaner as...
>>
>> private function quadraticBezier( startPoint: Float,
>> controlPoint: Float, endPoint: Float )
>> {
>>
>> return (1 – t)^2 * startPoint + 2(1 – t) * t * controlPoint
>> + t^2 * endPoint;
>>
>> }
>>
>> and ofcourse
>>
>> var distance = Math.pow( Math.pow( x2 - x1, 2 ) +
>> Math.pow( y2 - y1, 2 ), 0.5 );
>>
>> would be written in a much nicer form...
>>
>> var distance = ( ( x2 - x1)^2 + ( y2 - y1 )^2 )^0.5;
>>
>> you can argue that trig is currently a bit verbose, but you can
>> create a short cut in your code so that complex series can be
>> written to be easier to read.
>>
>> var sine = Math.sin;
>> var cos = Math.cos;
>>
>> var x = r* sin( theta );
>> var y = r* cos( theta );
>>
>> but this does not work so well with pow.
>>
>> Anyway just a thought.
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

RE: ^

luca deltodesco
... because we do?

trace([10^10,10^20,10^15]);

outputs 0,30,5

Date: Mon, 3 Oct 2011 10:57:48 +0400
Subject: Re: [haXe] ^
From: [hidden email]
To: [hidden email]

By the way, why don't we have logical xor?
On 3 Oct 2011 06:28, "[hidden email]" <[hidden email]> wrote:
> oops sorry :)
> On 3 Oct 2011, at 02:49, Mario Carbajal wrote:
>
>> ^ is already used for bitwise xor.
>>
>> On Sun, Oct 2, 2011 at 10:00 PM, [hidden email] <[hidden email]
>> > wrote:
>> Seems very logical to support a^b as a short cut for Math.pow( a,
>> b ); I know this is not really an important feature but it would
>> make some maths in haXe look a lot nicer, and would make haXe more
>> approachable as unlike some fancy feature requests ^ seems fairly
>> established notation, I guess if it was considered worthwhile to add
>> then obviously for consistency a ^= b could be used a =
>> Math.pow( a, b ); probably very rare but logical in keeping
>> everything consistent. I guess I am coming from the direction of
>> making haXe a language suitable for school students experimenting
>> with maths practically.
>>
>> For instance not tried it yet but this function currently in haXe...
>>
>> private function quadraticBezier( startPoint: Float,
>> controlPoint: Float, endPoint: Float )
>> {
>>
>> return Math.pow( (1 – t), 2 ) * startPoint + 2(1 – t) * t *
>> controlPoint + Math.pow( t, 2 ) * endPoint;
>>
>> }
>>
>> looks cleaner as...
>>
>> private function quadraticBezier( startPoint: Float,
>> controlPoint: Float, endPoint: Float )
>> {
>>
>> return (1 – t)^2 * startPoint + 2(1 – t) * t * controlPoint
>> + t^2 * endPoint;
>>
>> }
>>
>> and ofcourse
>>
>> var distance = Math.pow( Math.pow( x2 - x1, 2 ) +
>> Math.pow( y2 - y1, 2 ), 0.5 );
>>
>> would be written in a much nicer form...
>>
>> var distance = ( ( x2 - x1)^2 + ( y2 - y1 )^2 )^0.5;
>>
>> you can argue that trig is currently a bit verbose, but you can
>> create a short cut in your code so that complex series can be
>> written to be easier to read.
>>
>> var sine = Math.sin;
>> var cos = Math.cos;
>>
>> var x = r* sin( theta );
>> var y = r* cos( theta );
>>
>> but this does not work so well with pow.
>>
>> Anyway just a thought.
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>

-- haXe - an open source web programming language http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

RE: ^

luca deltodesco
In reply to this post by Yanis Benson
lol, just realised you said logical xor. in which case again, we already do :P it's called !=

true != false -> true
false != true -> true
true != true -> false
false != false -> false

same as xor.


Date: Mon, 3 Oct 2011 10:57:48 +0400
Subject: Re: [haXe] ^
From: [hidden email]
To: [hidden email]

By the way, why don't we have logical xor?
On 3 Oct 2011 06:28, "[hidden email]" <[hidden email]> wrote:
> oops sorry :)
> On 3 Oct 2011, at 02:49, Mario Carbajal wrote:
>
>> ^ is already used for bitwise xor.
>>
>> On Sun, Oct 2, 2011 at 10:00 PM, [hidden email] <[hidden email]
>> > wrote:
>> Seems very logical to support a^b as a short cut for Math.pow( a,
>> b ); I know this is not really an important feature but it would
>> make some maths in haXe look a lot nicer, and would make haXe more
>> approachable as unlike some fancy feature requests ^ seems fairly
>> established notation, I guess if it was considered worthwhile to add
>> then obviously for consistency a ^= b could be used a =
>> Math.pow( a, b ); probably very rare but logical in keeping
>> everything consistent. I guess I am coming from the direction of
>> making haXe a language suitable for school students experimenting
>> with maths practically.
>>
>> For instance not tried it yet but this function currently in haXe...
>>
>> private function quadraticBezier( startPoint: Float,
>> controlPoint: Float, endPoint: Float )
>> {
>>
>> return Math.pow( (1 – t), 2 ) * startPoint + 2(1 – t) * t *
>> controlPoint + Math.pow( t, 2 ) * endPoint;
>>
>> }
>>
>> looks cleaner as...
>>
>> private function quadraticBezier( startPoint: Float,
>> controlPoint: Float, endPoint: Float )
>> {
>>
>> return (1 – t)^2 * startPoint + 2(1 – t) * t * controlPoint
>> + t^2 * endPoint;
>>
>> }
>>
>> and ofcourse
>>
>> var distance = Math.pow( Math.pow( x2 - x1, 2 ) +
>> Math.pow( y2 - y1, 2 ), 0.5 );
>>
>> would be written in a much nicer form...
>>
>> var distance = ( ( x2 - x1)^2 + ( y2 - y1 )^2 )^0.5;
>>
>> you can argue that trig is currently a bit verbose, but you can
>> create a short cut in your code so that complex series can be
>> written to be easier to read.
>>
>> var sine = Math.sin;
>> var cos = Math.cos;
>>
>> var x = r* sin( theta );
>> var y = r* cos( theta );
>>
>> but this does not work so well with pow.
>>
>> Anyway just a thought.
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>

-- haXe - an open source web programming language http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: RE: [haXe] ^

Yanis Benson

But it's less intuitive. =[
It will bee much cooler to have ^^.

On 3 Oct 2011 12:22, "luca deltodesco" <[hidden email]> wrote:
>
> lol, just realised you said logical xor. in which case again, we already do :P it's called !=
> true != false -> truefalse != true -> truetrue != true -> falsefalse != false -> false
> same as xor.
>
> Date: Mon, 3 Oct 2011 10:57:48 +0400
> Subject: Re: [haXe] ^
> From: [hidden email]
> To: [hidden email]
>
> By the way, why don't we have logical xor?
> On 3 Oct 2011 06:28, "[hidden email]" <[hidden email]> wrote:
>> oops sorry :)
>
>> On 3 Oct 2011, at 02:49, Mario Carbajal wrote:
>>
>>> ^ is already used for bitwise xor.
>>>
>>> On Sun, Oct 2, 2011 at 10:00 PM, [hidden email] <[hidden email]
>
>>> > wrote:
>>> Seems very logical to support a^b as a short cut for Math.pow( a,
>>> b ); I know this is not really an important feature but it would
>>> make some maths in haXe look a lot nicer, and would make haXe more
>
>>> approachable as unlike some fancy feature requests ^ seems fairly
>>> established notation, I guess if it was considered worthwhile to add
>>> then obviously for consistency a ^= b could be used a =
>
>>> Math.pow( a, b ); probably very rare but logical in keeping
>>> everything consistent. I guess I am coming from the direction of
>>> making haXe a language suitable for school students experimenting
>
>>> with maths practically.
>>>
>>> For instance not tried it yet but this function currently in haXe...
>>>
>>> private function quadraticBezier( startPoint: Float,
>>> controlPoint: Float, endPoint: Float )
>
>>> {
>>>
>>> return Math.pow( (1 – t), 2 ) * startPoint + 2(1 – t) * t *
>>> controlPoint + Math.pow( t, 2 ) * endPoint;
>>>
>>> }
>>>
>>> looks cleaner as...
>
>>>
>>> private function quadraticBezier( startPoint: Float,
>>> controlPoint: Float, endPoint: Float )
>>> {
>>>
>>> return (1 – t)^2 * startPoint + 2(1 – t) * t * controlPoint
>
>>> + t^2 * endPoint;
>>>
>>> }
>>>
>>> and ofcourse
>>>
>>> var distance = Math.pow( Math.pow( x2 - x1, 2 ) +
>>> Math.pow( y2 - y1, 2 ), 0.5 );
>
>>>
>>> would be written in a much nicer form...
>>>
>>> var distance = ( ( x2 - x1)^2 + ( y2 - y1 )^2 )^0.5;
>>>
>>> you can argue that trig is currently a bit verbose, but you can
>
>>> create a short cut in your code so that complex series can be
>>> written to be easier to read.
>>>
>>> var sine = Math.sin;
>>> var cos = Math.cos;
>>>
>>> var x = r* sin( theta );
>
>>> var y = r* cos( theta );
>>>
>>> but this does not work so well with pow.
>>>
>>> Anyway just a thought.
>>>
>>>
>>> --
>>> haXe - an open source web programming language
>
>>> http://haxe.org
>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org
>>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org