Initial commit: Pi calculation benchmark with 34 languages

- Added implementations for: bash, brainfuck, c, cpp, crystal, csharp, d, dart, elixir, erlang, fortran, go, haskell, java, javascript, julia, kotlin, objective-c, scala, typescript, lua, nim, odin, perl, php, python, r, ruby, rust, swift, zig, assembly, vimscript, wolfram
- All implementations use Machin's formula: π/4 = 4*arctan(1/5) - arctan(1/239)
- Build system with ./build.sh, test system with ./test.sh
- Performance testing with ./run_all.sh
- Comprehensive README.md explaining performance differences
- Test framework verifies correctness against known π values
This commit is contained in:
Ein Anderssono
2026-04-23 00:26:18 +02:00
commit 54d2fecee0
182 changed files with 17471 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
# Bash Build Script - Bash är interpreterat, ingen kompilering behövs
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
cd "$SCRIPT_DIR"
echo "=== Bash Build ==="
echo "Bash är ett interpreterat språk, ingen kompilering behövs."
echo "Script: src/print_hej.sh"
echo ""
# Skapa wrapper script
mkdir -p bin
cat > bin/print_hej << 'EOF'
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
cd "$SCRIPT_DIR"
bash src/print_hej.sh "$@"
EOF
chmod +x bin/print_hej
echo "Wrapper script skapad: bin/print_hej"
echo ""
echo "För att köra:"
echo " ./bin/print_hej [decimaler]"
echo ""
echo "✓ Klart!"
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# Beräknar pi med angivet antal decimaler
# Användning: print_hej <antal_decimaler>
decimals=${1:-100}
# bc behöver scale = decimals + några extra för korrekt avrundning
# Ta bort backslash från utmatningen
echo "scale=$((decimals + 5)); 4*a(1)" | bc -l | tr -d '\\\n' | head -c $((decimals + 2))
echo