Skip to main content
Commonmark migration
Source Link

#pl, 4 bytes

pl, 4 bytes

☼ç▲÷

Try it online.

##Explanation

Explanation

In pl, functions take their arguments off the stack and push the result back onto the stack. Normally when there are not enough arguments on the stack, the function simply fails silently. However, something special happens when the amount of arguments on the stack is one off from the arity of the function -- the input variable _ is added to the argument list:

☼ç▲÷

☼      double: takes _ as the argument since there is nothing on the stack
 ç     combinations: since there is only one item on the stack (and arity is 2), it adds _ to the argument list (combinations(2_,_))
  ▲    increment last used var (_)
   ÷   divide: adds _ to the argument list again

In effect, this is the pseudocode:

divide(combinations(double(_),_),_+1);

#pl, 4 bytes

☼ç▲÷

Try it online.

##Explanation

In pl, functions take their arguments off the stack and push the result back onto the stack. Normally when there are not enough arguments on the stack, the function simply fails silently. However, something special happens when the amount of arguments on the stack is one off from the arity of the function -- the input variable _ is added to the argument list:

☼ç▲÷

☼      double: takes _ as the argument since there is nothing on the stack
 ç     combinations: since there is only one item on the stack (and arity is 2), it adds _ to the argument list (combinations(2_,_))
  ▲    increment last used var (_)
   ÷   divide: adds _ to the argument list again

In effect, this is the pseudocode:

divide(combinations(double(_),_),_+1);

pl, 4 bytes

☼ç▲÷

Try it online.

Explanation

In pl, functions take their arguments off the stack and push the result back onto the stack. Normally when there are not enough arguments on the stack, the function simply fails silently. However, something special happens when the amount of arguments on the stack is one off from the arity of the function -- the input variable _ is added to the argument list:

☼ç▲÷

☼      double: takes _ as the argument since there is nothing on the stack
 ç     combinations: since there is only one item on the stack (and arity is 2), it adds _ to the argument list (combinations(2_,_))
  ▲    increment last used var (_)
   ÷   divide: adds _ to the argument list again

In effect, this is the pseudocode:

divide(combinations(double(_),_),_+1);
Source Link
a spaghetto
  • 11.3k
  • 3
  • 46
  • 82

#pl, 4 bytes

☼ç▲÷

Try it online.

##Explanation

In pl, functions take their arguments off the stack and push the result back onto the stack. Normally when there are not enough arguments on the stack, the function simply fails silently. However, something special happens when the amount of arguments on the stack is one off from the arity of the function -- the input variable _ is added to the argument list:

☼ç▲÷

☼      double: takes _ as the argument since there is nothing on the stack
 ç     combinations: since there is only one item on the stack (and arity is 2), it adds _ to the argument list (combinations(2_,_))
  ▲    increment last used var (_)
   ÷   divide: adds _ to the argument list again

In effect, this is the pseudocode:

divide(combinations(double(_),_),_+1);