Share your repls and programming experiences

← Back to all posts
π in Scheme
h
AmazingMech2418 (691)

I think I'm pretty much doing pi approximations in every language now, so, here it is in Scheme, a dialect of Lisp!

The issue with NASM has been fixed, but I still need to figure out float addition, subtraction, multiplication, and division before the NASM approximation will be ready.

Here are the other approximations so far:
Erlang - https://repl.it/talk/share/p-in-Erlang/41652
Elixir - https://repl.it/talk/share/p-in-Elixir/41530
Julia - https://repl.it/talk/share/p-in-Julia/41395
Nim - https://repl.it/talk/share/p-in-Nim/41372
PHP - https://repl.it/talk/share/p-in-PHP/41348
Crystal - https://repl.it/talk/share/p-in-Crystal/41276
F# - https://repl.it/talk/share/p-in-F/41261
Lua - https://repl.it/talk/share/p-in-Lua/41251
Dart - https://repl.it/talk/share/p-in-Dart/41240
R - https://repl.it/talk/share/p-in-R/41205
Haskell - https://repl.it/talk/share/p-in-Haskell/41199
Raku - https://repl.it/talk/share/p-in-Raku/41111
Rust - https://repl.it/talk/share/p-in-Rust/41056
Go - https://repl.it/talk/share/p-in-Go/40950
Swift - https://repl.it/talk/share/p-in-Swift/36150
C# - https://repl.it/talk/share/p-in-C/36141
Bash - https://repl.it/talk/share/p-in-Bash/36133
Kotlin - https://repl.it/talk/share/p-in-Kotlin/36125
Ruby - https://repl.it/talk/share/p-in-Ruby/34982
Java - https://repl.it/talk/share/p-in-Java/34978
QBasic - https://repl.it/talk/share/p-in-QBasic/34973
Fortran - https://repl.it/talk/share/p-in-Fortran/34890
APL - https://repl.it/talk/share/p-in-APL/34888
Forth - https://repl.it/talk/share/p-in-Forth/34652
LOLCODE - https://repl.it/talk/share/p-in-LOLCODE/34421
Python and Node.js (Node is linked in post) - https://repl.it/talk/share/2-Approximations-of-p-In-Only-Four-Lines-of-Code/32773
C - https://repl.it/talk/share/p-Approximations-in-C/33461

Credit to @NoelBryan, @TheForArkLD , @Warhawk947 , and @LizFoster for inspiring these approximations. Most of these use the Nilakantha Series, although I also use the arctangent method (multiplying the radian arctangent of 1 by 4 to get pi and getting the arctangent with an infinite series) in three of them (Python, Node, and C).

Next up is Clojure and then Emacs Lisp (Elisp). If you have any suggestions for after those, please let me know! I would prefer to save esolangs for last. Some examples for ideas for the next ones are like Quil, OCaml, Tcl, etc.

By the way, I'm starting to run out of languages, so please suggest any you would like to see me do. After Elisp, there will be no official languages left other than esolangs, but there are some other languages (like OCaml, Quil, etc.) that can be found using the method in my tutorial at https://repl.it/talk/learn/How-to-Get-a-List-of-All-Replit-Langauges/34411. Though, I am saving esolangs for last (or close to last). After I finish the approximations using the Nilakantha Series, I will go through all of the languages again and do another algorithm (I'm thinking either trapezoidal sums or Monte Carlo). I will also then make a tutorial on transpiling programming languages.

Commentshotnewtop