Share your repls and programming experiences

← Back to all posts
π in APL

@TheForArkLD recommended that I make a pi approximation in APL, so here it is! By the way, I don't know if I did it the way you are technically supposed to, but it works! APL has almost no available documentation online...

theangryepicbanana (1670)

You could probably simplify this whole thing:

``((4÷(c×((c×(c+3))+2)))×s)``

to:

``((4÷c×(c×c+3)+2)×s)``

because I believe the APL evaluates from right to left (rather than left to right). It might even be able to be simplified further.

TheForArkLD (745)

Thanks :D
Really cool!
(Dyalog is our friends)

AmazingMech2418 (994)

@TheForArkLD I don't think Repl.it uses Dyalog. Loops don't work. I had to use tail-end recursion.

AmazingMech2418 (994)

@TheForArkLD Well, ngn doesn't support loops with the same syntax as Dyalog...

AmazingMech2418 (994)

@TheForArkLD You have to use tail-end recursion though...

TheForArkLD (745)
``````n←0
max←10
func←{
⍝Do something
n←n+1
{n < max:func 1} 1
}
func 1``````
TheForArkLD (745)

@AmazingMech2418 I found symbol that recursion for function, lol