Just uses the simple formule 180-360/n
used on other answers.
Due to ... sub-optimal ... math support, the formule was adapted to (-360/$n)+180
(it's almost the same, calculated in a different order).
{@set/A-360 argv}{@incby180A}{@echoA}
You can try it on: http://sandbox.onlinephpfunctions.com/code/00b314dee3c10139928928d124be9fc1c59ef4bf
On line 918, you can change between golfed
, ungolfed
and fn
, to try the variants below.
Ungolfed:
{@set/ A -360 argv}
{@inc by 180 A}
{@echo A}
Yeah, there's not much to ungolf...
Explanation:
{@set/ A -360 argv}
- Stores in A
the result of -360/argv
.
argv
is a variable that holds all passed arguments (in a function or when running the code).
A
is now an array with argc
elements (argc
holds the number of aguments passed).
{@inc by 180 A}
- Increments all values of A
by 180 (A+180
, basically)
{@echo A}
- Outputs the values of A, without delimiter.
One could use {@return A}
if inside a function, to get an usable array.
Function alternative:
Converting to a function to get an usable array is easy:
{@fn N}
{@set/ A -360 argv}
{@inc by 180 A}
{@return A}
{@/}
Creates a function N
that takes multiple arguments and returns an array.
Just call it as {@call N into <variable> <argument, arguments...>}
.
If you are curious, this code compiles to the following:
// {@set/A-360 argv}
$DATA['A'] = array_map(function($value)use(&$DATA){return (-360 / $value);}, $FN['array_flat']((isset($DATA['argv'])?$DATA['argv']:null)));
// {@incby180A}
$DATA['A'] = $FN['inc'](isset($DATA['A'])?$DATA['A']:0, 180);
// {@echoA}
echo implode('', $FN['array_flat']((isset($DATA['A'])?$DATA['A']:null)));