4 replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
source | link

Yet another way to avoid return

You know you should use eval for arrow functions with multiple statements and a returnuse eval for arrow functions with multiple statements and a return. In some unusual case you can save more using an inner subfunction.

I say unusual because

  1. The result returned must not be the last expression evalued in the loop

  2. There must be (at least) 2 different initializations before the loop

In this case you can use an inner subfunction without return, having one of the initial values passed as a parameter.

Example Find the reciprocal of the sum of exp function for values in a range from a to b.

The long way - 55 bytes

(a,b)=>{for(r=0,i=a;i<=b;i++)r+=Math.exp(i);return 1/r}

With eval - 54 bytes

(a,b)=>eval("for(r=0,i=a;i<=b;i++)r+=Math.exp(i);1/r")

With an inner function - 53 bytes

(a,b)=>(i=>{for(r=0;i<=b;i++)r+=Math.exp(i)})(a)||1/r

Note that without the requirement of a lower range limit a, I can merge the initializations of i and r and the eval version is shorter.

Yet another way to avoid return

You know you should use eval for arrow functions with multiple statements and a return. In some unusual case you can save more using an inner subfunction.

I say unusual because

  1. The result returned must not be the last expression evalued in the loop

  2. There must be (at least) 2 different initializations before the loop

In this case you can use an inner subfunction without return, having one of the initial values passed as a parameter.

Example Find the reciprocal of the sum of exp function for values in a range from a to b.

The long way - 55 bytes

(a,b)=>{for(r=0,i=a;i<=b;i++)r+=Math.exp(i);return 1/r}

With eval - 54 bytes

(a,b)=>eval("for(r=0,i=a;i<=b;i++)r+=Math.exp(i);1/r")

With an inner function - 53 bytes

(a,b)=>(i=>{for(r=0;i<=b;i++)r+=Math.exp(i)})(a)||1/r

Note that without the requirement of a lower range limit a, I can merge the initializations of i and r and the eval version is shorter.

Yet another way to avoid return

You know you should use eval for arrow functions with multiple statements and a return. In some unusual case you can save more using an inner subfunction.

I say unusual because

  1. The result returned must not be the last expression evalued in the loop

  2. There must be (at least) 2 different initializations before the loop

In this case you can use an inner subfunction without return, having one of the initial values passed as a parameter.

Example Find the reciprocal of the sum of exp function for values in a range from a to b.

The long way - 55 bytes

(a,b)=>{for(r=0,i=a;i<=b;i++)r+=Math.exp(i);return 1/r}

With eval - 54 bytes

(a,b)=>eval("for(r=0,i=a;i<=b;i++)r+=Math.exp(i);1/r")

With an inner function - 53 bytes

(a,b)=>(i=>{for(r=0;i<=b;i++)r+=Math.exp(i)})(a)||1/r

Note that without the requirement of a lower range limit a, I can merge the initializations of i and r and the eval version is shorter.

3 deleted 13 characters in body
source | link

Yet another way to avoid return

You know you should use eval for arrow functions with multiple statements and a return. In some unusual case you can save more using an inner subfunction.

I say unusual because

  1. The result returned must not be the last expression evalued in the loop

  2. There must be (at least) 2 different initializations before the loop

In this case you can use an inner subfunction without return, having one of the initial values passed as a parameter.

Example Find the reciprocal of the sum of exp function for values in a range from a to b.

The long way - 55 bytes

(a,b)=>{for(r=0,i=a;i<=b;i++)r+=Math.exp(i);return 1/r}

With eval - 54 bytes

(a,b)=>eval("for(r=0,i=a;i<=b;i++)r+=Math.exp(i);1/r")

With an inner function - 53 bytes

(a,b)=>(i=>{for(r=0;i<=b;i++)r+=Math.exp(i)})(a)||1/r

Note that without the requirement of a lower range limit a, I can merge the initializations of i and r and the eval version is shorter.

Example

Yet another way to avoid return

You know you should use eval for arrow functions with multiple statements and a return. In some unusual case you can save more using an inner subfunction.

I say unusual because

  1. The result returned must not be the last expression evalued in the loop

  2. There must be (at least) 2 different initializations before the loop

In this case you can use an inner subfunction without return, having one of the initial values passed as a parameter.

Example Find the reciprocal of the sum of exp function for values in a range from a to b.

The long way - 55 bytes

(a,b)=>{for(r=0,i=a;i<=b;i++)r+=Math.exp(i);return 1/r}

With eval - 54 bytes

(a,b)=>eval("for(r=0,i=a;i<=b;i++)r+=Math.exp(i);1/r")

With an inner function - 53 bytes

(a,b)=>(i=>{for(r=0;i<=b;i++)r+=Math.exp(i)})(a)||1/r

Note that without the requirement of a lower range limit a, I can merge the initializations of i and r and the eval version is shorter.

Example

Yet another way to avoid return

You know you should use eval for arrow functions with multiple statements and a return. In some unusual case you can save more using an inner subfunction.

I say unusual because

  1. The result returned must not be the last expression evalued in the loop

  2. There must be (at least) 2 different initializations before the loop

In this case you can use an inner subfunction without return, having one of the initial values passed as a parameter.

Example Find the reciprocal of the sum of exp function for values in a range from a to b.

The long way - 55 bytes

(a,b)=>{for(r=0,i=a;i<=b;i++)r+=Math.exp(i);return 1/r}

With eval - 54 bytes

(a,b)=>eval("for(r=0,i=a;i<=b;i++)r+=Math.exp(i);1/r")

With an inner function - 53 bytes

(a,b)=>(i=>{for(r=0;i<=b;i++)r+=Math.exp(i)})(a)||1/r

Note that without the requirement of a lower range limit a, I can merge the initializations of i and r and the eval version is shorter.

2 added 1 character in body
source | link

Yet another way to avoid return

You know you should use eval for arrow functions with multiple statemntsstatements and a return. In some unusual case you can save more using an inner subfunction.

I say unusual because

  1. The result returned must not be the last expression evalued in the loop

  2. There must be (at least) 2 different initializations before the loop

In this case you can use an inner subfunction without return, having one of the initial values passed as a parameter.

Example Find the reciprocal of the sum of exp function for values in a range from a to b.

The long way - 55 bytes

(a,b)=>{for(r=0,i=a;i<=b;i++)r+=Math.exp(i);return 1/r}

With eval - 54 bytes

(a,b)=>eval("for(r=0,i=a;i<=b;i++)r+=Math.exp(i);1/r")

With an inner function - 53 bytes

(a,b)=>(i=>{for(r=0;i<=b;i++)r+=Math.exp(i)})(a)||1/r

Note that without the requirement of a lower range limit a, I can merge the initializations of i and r and the eval version is shorter.

Example

Yet another way to avoid return

You know you should use eval for arrow functions with multiple statemnts and a return. In some unusual case you can save more using an inner subfunction.

I say unusual because

  1. The result returned must not be the last expression evalued in the loop

  2. There must be (at least) 2 different initializations before the loop

In this case you can use an inner subfunction without return, having one of the initial values passed as a parameter.

Example Find the reciprocal of the sum of exp function for values in a range from a to b.

The long way - 55 bytes

(a,b)=>{for(r=0,i=a;i<=b;i++)r+=Math.exp(i);return 1/r}

With eval - 54 bytes

(a,b)=>eval("for(r=0,i=a;i<=b;i++)r+=Math.exp(i);1/r")

With an inner function - 53 bytes

(a,b)=>(i=>{for(r=0;i<=b;i++)r+=Math.exp(i)})(a)||1/r

Note that without the requirement of a lower range limit a, I can merge the initializations of i and r and the eval version is shorter.

Example

Yet another way to avoid return

You know you should use eval for arrow functions with multiple statements and a return. In some unusual case you can save more using an inner subfunction.

I say unusual because

  1. The result returned must not be the last expression evalued in the loop

  2. There must be (at least) 2 different initializations before the loop

In this case you can use an inner subfunction without return, having one of the initial values passed as a parameter.

Example Find the reciprocal of the sum of exp function for values in a range from a to b.

The long way - 55 bytes

(a,b)=>{for(r=0,i=a;i<=b;i++)r+=Math.exp(i);return 1/r}

With eval - 54 bytes

(a,b)=>eval("for(r=0,i=a;i<=b;i++)r+=Math.exp(i);1/r")

With an inner function - 53 bytes

(a,b)=>(i=>{for(r=0;i<=b;i++)r+=Math.exp(i)})(a)||1/r

Note that without the requirement of a lower range limit a, I can merge the initializations of i and r and the eval version is shorter.

Example

1
source | link