├── Interpreted ├── man-or-boy │ ├── args.txt │ ├── mob.mrb │ ├── mob.rb │ ├── mob.jl │ ├── mob.pl6 │ ├── mob.cr │ ├── mob.pl │ ├── mob.gvy │ ├── mob.sc │ ├── mob.lua │ ├── mob.ml │ ├── mob.py │ ├── mob.tcl │ ├── mob.php │ └── mob.clj ├── coin-sums │ ├── args.txt │ ├── csum.py │ ├── csum.rb │ ├── csum.jl │ ├── csum.cr │ ├── csum.gvy │ ├── csum.sc │ ├── csum.pl │ ├── csum.lua │ ├── csum.php │ ├── csum.pike │ └── csum.awk ├── ackermann-function │ ├── args.txt │ ├── ack.gvy │ ├── ack.sc │ ├── ack.pl │ ├── ack.mrb │ ├── ack.rb │ ├── ack.lua │ ├── ack.cr │ ├── ack.ml │ ├── ack.jl │ ├── ack.awk │ ├── ack.clj │ ├── ack.py │ ├── ack.exs │ ├── ack.php │ ├── ack.pike │ └── ack.tcl ├── fibonacci-recursive │ ├── args.txt │ ├── ignore.txt │ ├── fib.jl │ ├── fib.cr │ ├── fib.mrb │ ├── fib.rb │ ├── fib.gvy │ ├── fib.lua │ ├── fib.pl │ ├── fib.php │ ├── fib.sc │ ├── fib.awk │ ├── fib.py │ ├── fib.tcl │ ├── fib.clj │ ├── fib.ml │ ├── fib.pike │ └── fib.exs ├── mutual-recursion │ ├── args.txt │ ├── mrec.jl │ ├── mrec.mrb │ ├── mrec.rb │ ├── mrec.cr │ ├── mrec.lua │ ├── mrec.sc │ ├── mrec.py │ ├── mrec.gvy │ ├── mrec.pl │ ├── mrec.awk │ ├── mrec.php │ ├── mrec.pike │ ├── mrec.exs │ ├── mrec.ml │ ├── mrec.tcl │ └── mrec.clj ├── tak-function │ ├── args.txt │ ├── tak.mrb │ ├── tak.rb │ ├── tak.lua │ ├── tak.cr │ ├── tak.awk │ ├── tak.gvy │ ├── tak.jl │ ├── tak.pl │ ├── tak.php │ ├── tak.tcl │ ├── tak.py │ ├── tak.ml │ ├── tak.pike │ ├── tak.sc │ ├── tak.clj │ └── tak.exs ├── lev-distance-recursive │ ├── args.txt │ ├── lev.py │ ├── lev.mrb │ ├── lev.sc │ ├── lev.rb │ ├── lev.jl │ ├── lev.cr │ ├── lev.lua │ ├── lev.ml │ ├── lev.gvy │ ├── lev.pl │ ├── lev.clj │ ├── lev.php │ ├── lev.pike │ ├── lev.exs │ └── lev.awk ├── lcs-recursive │ ├── args.txt │ ├── lcs.clj │ ├── lcs.rb │ ├── lcs.cr │ ├── lcs.jl │ ├── lcs.sc │ ├── lcs.tcl │ ├── lcs.py │ ├── lcs.pl │ ├── lcs.gvy │ ├── lcs.php │ ├── lcs.lua │ ├── lcs.pike │ └── lcs.awk └── interpreters.txt ├── Compiled ├── array-reverse │ ├── args.txt │ ├── rev.go │ └── rev.c ├── fibonacci-recursive │ ├── args.txt │ ├── fib.scala │ ├── fib.ml │ ├── fib.go │ ├── fib.c │ └── fib.cpp └── compilers.txt ├── Stats └── Interpreted │ ├── all.png │ ├── lcs-test.png │ ├── fibonacci-35.png │ ├── lev-distance.png │ ├── man-or-boy-12.png │ ├── tak-30-22-12.png │ ├── ack-function-3-9.png │ ├── coin-sums-0-250.png │ └── mutual-recursion-130.png ├── Reports ├── Compiled │ ├── man-or-boy 20.csv │ ├── array-reverse 1000000 1000.csv │ ├── fibonacci-recursive 40.csv │ ├── man-or-boy 16.csv │ └── man-or-boy 15.csv ├── Interpreted │ ├── coin-sums 0 250.csv │ ├── man-or-boy 12.csv │ ├── lev-distance-recursive rosettacode raisethysword.csv │ ├── lcs-recursive thisisatest testing123testingtrizen.csv │ ├── fibonacci-recursive 35.csv │ ├── ackermann-function 3 9.csv │ ├── mutual-recursion 130.csv │ └── tak-function 30 22 12.csv ├── create_final_report.pl └── overview.csv ├── .gitignore ├── update_names.sf ├── README.md ├── benchmark.pl └── LICENSE /Interpreted/man-or-boy/args.txt: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/args.txt: -------------------------------------------------------------------------------- 1 | 0 250 2 | -------------------------------------------------------------------------------- /Compiled/array-reverse/args.txt: -------------------------------------------------------------------------------- 1 | 1000000 1000 2 | -------------------------------------------------------------------------------- /Compiled/fibonacci-recursive/args.txt: -------------------------------------------------------------------------------- 1 | 40 2 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/args.txt: -------------------------------------------------------------------------------- 1 | 3 9 2 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/args.txt: -------------------------------------------------------------------------------- 1 | 35 2 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/args.txt: -------------------------------------------------------------------------------- 1 | 130 2 | -------------------------------------------------------------------------------- /Interpreted/tak-function/args.txt: -------------------------------------------------------------------------------- 1 | 30 22 12 2 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/ignore.txt: -------------------------------------------------------------------------------- 1 | fib.tcl 2 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/args.txt: -------------------------------------------------------------------------------- 1 | rosettacode raisethysword 2 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/args.txt: -------------------------------------------------------------------------------- 1 | thisisatest testing123testingtrizen 2 | -------------------------------------------------------------------------------- /Stats/Interpreted/all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trizen/language-benchmarks/HEAD/Stats/Interpreted/all.png -------------------------------------------------------------------------------- /Stats/Interpreted/lcs-test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trizen/language-benchmarks/HEAD/Stats/Interpreted/lcs-test.png -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.jl: -------------------------------------------------------------------------------- 1 | fib(n) = n > 1 ? fib(n-1) + fib(n-2) : n; 2 | 3 | println(fib(parse(Int, ARGS[1]))); 4 | -------------------------------------------------------------------------------- /Stats/Interpreted/fibonacci-35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trizen/language-benchmarks/HEAD/Stats/Interpreted/fibonacci-35.png -------------------------------------------------------------------------------- /Stats/Interpreted/lev-distance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trizen/language-benchmarks/HEAD/Stats/Interpreted/lev-distance.png -------------------------------------------------------------------------------- /Stats/Interpreted/man-or-boy-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trizen/language-benchmarks/HEAD/Stats/Interpreted/man-or-boy-12.png -------------------------------------------------------------------------------- /Stats/Interpreted/tak-30-22-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trizen/language-benchmarks/HEAD/Stats/Interpreted/tak-30-22-12.png -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.cr: -------------------------------------------------------------------------------- 1 | def fib(n) 2 | n > 1 ? fib(n-1) + fib(n-2) : n; 3 | end 4 | 5 | puts fib(ARGV[0].to_i); 6 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.mrb: -------------------------------------------------------------------------------- 1 | def fib(n) 2 | n > 1 ? fib(n-1) + fib(n-2) : n; 3 | end 4 | 5 | puts fib(ARGV[0].to_i); 6 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.rb: -------------------------------------------------------------------------------- 1 | def fib(n) 2 | n > 1 ? fib(n-1) + fib(n-2) : n; 3 | end 4 | 5 | puts fib(ARGV[0].to_i); 6 | -------------------------------------------------------------------------------- /Stats/Interpreted/ack-function-3-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trizen/language-benchmarks/HEAD/Stats/Interpreted/ack-function-3-9.png -------------------------------------------------------------------------------- /Stats/Interpreted/coin-sums-0-250.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trizen/language-benchmarks/HEAD/Stats/Interpreted/coin-sums-0-250.png -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.gvy: -------------------------------------------------------------------------------- 1 | def fib(n) { 2 | n >= 2 ? fib(n-2) + fib(n-1) : n; 3 | } 4 | 5 | println(fib(args[0].toInteger())); 6 | -------------------------------------------------------------------------------- /Stats/Interpreted/mutual-recursion-130.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trizen/language-benchmarks/HEAD/Stats/Interpreted/mutual-recursion-130.png -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.lua: -------------------------------------------------------------------------------- 1 | function fib(n) 2 | return n>1 and fib(n-1)+fib(n-2) or n 3 | end 4 | 5 | print(fib(tonumber(arg[1]))); 6 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.pl: -------------------------------------------------------------------------------- 1 | sub fib { 2 | $_[0] > 1 ? fib($_[0]-1) + fib($_[0]-2) : $_[0]; 3 | } 4 | 5 | print fib($ARGV[0]), "\n"; 6 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.php: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.sc: -------------------------------------------------------------------------------- 1 | def fib( n : Int) : Int = n match { 2 | case 0 | 1 => n 3 | case _ => fib(n-1) + fib(n-2) 4 | } 5 | 6 | println(fib(args(0).toInt)) 7 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.awk: -------------------------------------------------------------------------------- 1 | function fib(n) { 2 | if (n < 2) return n; 3 | return (fib(n-1) + fib(n-2)); 4 | } 5 | 6 | BEGIN { 7 | print fib(ARGV[1]); 8 | } 9 | -------------------------------------------------------------------------------- /Compiled/fibonacci-recursive/fib.scala: -------------------------------------------------------------------------------- 1 | 2 | def fib(n: Int): Int = { 3 | if (n <= 1) 4 | return n; 5 | 6 | return fib(n-1) + fib(n-2) 7 | } 8 | 9 | println(fib(40)); 10 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.gvy: -------------------------------------------------------------------------------- 1 | def ack ( m, n ) { 2 | m == 0 ? n + 1 : n == 0 ? ack(m-1, 1) : ack(m-1, ack(m, n-1)) 3 | } 4 | 5 | println(ack(args[0].toInteger(), args[1].toInteger())); 6 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.jl: -------------------------------------------------------------------------------- 1 | F(n) = n == 0 ? one(n) : n - M(F(n - 1)) 2 | M(n) = n == 0 ? zero(n) : n - F(M(n - 1)) 3 | 4 | println(F(parse(Int, ARGS[1]))); 5 | println(M(parse(Int, ARGS[1]))); 6 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def fib(n): 4 | if n > 1: 5 | return fib(n-1) + fib(n-2); 6 | 7 | return n; 8 | 9 | 10 | print(fib(int(sys.argv[1]))); 11 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.mrb: -------------------------------------------------------------------------------- 1 | def f(n) 2 | n == 0 ? 1 : n - m(f(n-1)) 3 | end 4 | def m(n) 5 | n == 0 ? 0 : n - f(m(n-1)) 6 | end 7 | 8 | puts f(ARGV[0].to_i); 9 | puts m(ARGV[0].to_i); 10 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.rb: -------------------------------------------------------------------------------- 1 | def f(n) 2 | n == 0 ? 1 : n - m(f(n-1)) 3 | end 4 | def m(n) 5 | n == 0 ? 0 : n - f(m(n-1)) 6 | end 7 | 8 | puts f(ARGV[0].to_i); 9 | puts m(ARGV[0].to_i); 10 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.sc: -------------------------------------------------------------------------------- 1 | def ack(m: Int, n: Int): Int = { 2 | if (m==0) n+1 3 | else if (n==0) ack(m-1, 1) 4 | else ack(m-1, ack(m, n-1)) 5 | } 6 | 7 | println(ack(args(0).toInt, args(1).toInt)) 8 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.tcl: -------------------------------------------------------------------------------- 1 | proc fib {n} { 2 | if { $n < 2 } { expr $n } else { 3 | expr { [fib [expr {$n-1}] ] + [fib [expr {$n-2}] ] } 4 | } 5 | } 6 | 7 | puts [fib [lindex $argv 0]] 8 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.mrb: -------------------------------------------------------------------------------- 1 | def tak(x, y, z) 2 | y < x ? tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y)) 3 | : z; 4 | end 5 | 6 | puts tak(ARGV[0].to_i, ARGV[1].to_i, ARGV[2].to_i); 7 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.rb: -------------------------------------------------------------------------------- 1 | def tak(x, y, z) 2 | y < x ? tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y)) 3 | : z; 4 | end 5 | 6 | puts tak(ARGV[0].to_i, ARGV[1].to_i, ARGV[2].to_i); 7 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.pl: -------------------------------------------------------------------------------- 1 | sub A { 2 | my ($m, $n) = @_; 3 | $m == 0 ? $n + 1 : 4 | $n == 0 ? A($m - 1, 1) : 5 | A($m - 1, A($m, $n - 1)) 6 | } 7 | 8 | print A($ARGV[0], $ARGV[1]), "\n"; 9 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.clj: -------------------------------------------------------------------------------- 1 | (defn fib [n] 2 | (case n 3 | 0 0 4 | 1 1 5 | (+ (fib (- n 1)) 6 | (fib (- n 2))))) 7 | 8 | (println (fib (Integer/parseInt (first *command-line-args* )))) 9 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.cr: -------------------------------------------------------------------------------- 1 | def f(n : Int) 2 | n == 0 ? 1 : n - m(f(n-1)) 3 | end 4 | def m(n : Int) 5 | n == 0 ? 0 : n - f(m(n-1)) 6 | end 7 | 8 | puts f(ARGV[0].to_i); 9 | puts m(ARGV[0].to_i); 10 | -------------------------------------------------------------------------------- /Compiled/fibonacci-recursive/fib.ml: -------------------------------------------------------------------------------- 1 | let rec fib_rec n = 2 | if n < 2 then 3 | n 4 | else 5 | fib_rec (n - 1) + fib_rec (n - 2) 6 | 7 | let () = 8 | Printf.printf "%d\n" (fib_rec (int_of_string Sys.argv.(1))) 9 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.lua: -------------------------------------------------------------------------------- 1 | function f(n) return n == 0 and 1 or n - m(f(n-1)) end 2 | function m(n) return n == 0 and 0 or n - f(m(n-1)) end 3 | 4 | print(f(tonumber(arg[1]))); 5 | print(m(tonumber(arg[1]))); 6 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.sc: -------------------------------------------------------------------------------- 1 | def F(n:Int):Int = 2 | if (n == 0) 1 else n - M(F(n-1)) 3 | def M(n:Int):Int = 4 | if (n == 0) 0 else n - F(M(n-1)) 5 | 6 | println(F(args(0).toInt)); 7 | println(M(args(0).toInt)); 8 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.lua: -------------------------------------------------------------------------------- 1 | function tak(x, y, z) 2 | return y 1 ? fib(n-2) + fib(n-1) : n); 3 | } 4 | 5 | int main(int argc, array(string) argv) { 6 | write(fib((int)argv[1]) + "\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def F(n): return 1 if n == 0 else n - M(F(n-1)) 4 | def M(n): return 0 if n == 0 else n - F(M(n-1)) 5 | 6 | print(F(int(sys.argv[1]))); 7 | print(M(int(sys.argv[1]))); 8 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.cr: -------------------------------------------------------------------------------- 1 | def tak(x : Int, y : Int, z : Int) 2 | y < x ? tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y)) 3 | : z 4 | end 5 | 6 | puts tak(ARGV[0].to_i, ARGV[1].to_i, ARGV[2].to_i) 7 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.mrb: -------------------------------------------------------------------------------- 1 | def a(k, x1, x2, x3, x4, x5) 2 | b = ->() { k -= 1; a(k, b, x1, x2, x3, x4) } 3 | k <= 0 ? x4.call + x5.call : b.call 4 | end 5 | 6 | puts a(ARGV[0].to_i, -> {1}, -> {-1}, -> {-1}, -> {1}, -> {0}) 7 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.rb: -------------------------------------------------------------------------------- 1 | def a(k, x1, x2, x3, x4, x5) 2 | b = ->() { k -= 1; a(k, b, x1, x2, x3, x4) } 3 | k <= 0 ? x4.call + x5.call : b.call 4 | end 5 | 6 | puts a(ARGV[0].to_i, -> {1}, -> {-1}, -> {-1}, -> {1}, -> {0}) 7 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.gvy: -------------------------------------------------------------------------------- 1 | def F(n) { 2 | n == 0 ? 1 : n - M(F(n-1)) 3 | } 4 | def M(n) { 5 | n == 0 ? 0 : n - F(M(n-1)) 6 | } 7 | 8 | println(F(args[0].toInteger())); 9 | println(M(args[0].toInteger())); 10 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.awk: -------------------------------------------------------------------------------- 1 | function tak(x, y, z) { 2 | if (y < x) return tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y)); 3 | return z; 4 | } 5 | 6 | BEGIN { 7 | print tak(ARGV[1], ARGV[2], ARGV[3]); 8 | } 9 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.mrb: -------------------------------------------------------------------------------- 1 | def ack(m, n) 2 | if m == 0 3 | n + 1 4 | elsif n == 0 5 | ack(m-1, 1) 6 | else 7 | ack(m-1, ack(m, n-1)) 8 | end 9 | end 10 | 11 | puts ack(ARGV[0].to_i, ARGV[1].to_i) 12 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.rb: -------------------------------------------------------------------------------- 1 | def ack(m, n) 2 | if m == 0 3 | n + 1 4 | elsif n == 0 5 | ack(m-1, 1) 6 | else 7 | ack(m-1, ack(m, n-1)) 8 | end 9 | end 10 | 11 | puts ack(ARGV[0].to_i, ARGV[1].to_i) 12 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.jl: -------------------------------------------------------------------------------- 1 | function a(k::Int, x1, x2, x3, x4, x5) 2 | b = ()-> a(k-=1, b, x1, x2, x3, x4); 3 | k <= 0 ? (x4() + x5()) : b(); 4 | end 5 | 6 | println(a(parse(Int, ARGS[1]), ()->1, ()->-1, ()->-1, ()->1, ()->0)); 7 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.pl: -------------------------------------------------------------------------------- 1 | 2 | use experimental qw(signatures); 3 | 4 | sub F($n) { $n == 0 ? 1 : $n - M(F($n-1)) } 5 | sub M($n) { $n == 0 ? 0 : $n - F(M($n-1)) } 6 | 7 | print F($ARGV[0]), "\n"; 8 | print M($ARGV[0]), "\n"; 9 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.gvy: -------------------------------------------------------------------------------- 1 | def tak(x, y, z) { 2 | y < x ? tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y)) 3 | : z; 4 | } 5 | 6 | println(tak(args[0].toInteger(), args[1].toInteger(), args[2].toInteger())); 7 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.jl: -------------------------------------------------------------------------------- 1 | function tak(x, y, z) 2 | (y < x ? tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y)) 3 | : z) 4 | end 5 | 6 | println(tak(parse(Int,ARGS[1]),parse(Int,ARGS[2]),parse(Int,ARGS[3]))); 7 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.lua: -------------------------------------------------------------------------------- 1 | function ack(M,N) 2 | if M == 0 then return N + 1 end 3 | if N == 0 then return ack(M-1,1) end 4 | return ack(M-1,ack(M, N-1)) 5 | end 6 | 7 | print(ack(tonumber(arg[1]), tonumber(arg[2]))) 8 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.pl: -------------------------------------------------------------------------------- 1 | sub tak { 2 | my ($x, $y, $z) = @_; 3 | $y < $x ? tak(tak($x - 1, $y, $z), tak($y - 1, $z, $x), tak($z - 1, $x, $y)) 4 | : $z; 5 | } 6 | 7 | print tak($ARGV[0], $ARGV[1], $ARGV[2]), "\n"; 8 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.cr: -------------------------------------------------------------------------------- 1 | def ack(m : Int, n : Int) 2 | if m == 0 3 | n + 1 4 | elsif n == 0 5 | ack(m-1, 1) 6 | else 7 | ack(m-1, ack(m, n-1)) 8 | end 9 | end 10 | 11 | puts ack(ARGV[0].to_i, ARGV[1].to_i) 12 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.ml: -------------------------------------------------------------------------------- 1 | let rec a m n = 2 | if m=0 then (n+1) else 3 | if n=0 then (a (m-1) 1) else 4 | (a (m-1) (a m (n-1))) 5 | 6 | let () = 7 | Printf.printf "%d\n" (a (int_of_string Sys.argv.(1)) (int_of_string Sys.argv.(2))) 8 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.pl6: -------------------------------------------------------------------------------- 1 | sub A(Int $k is copy, &x1, &x2, &x3, &x4, &x5) { 2 | $k <= 0 3 | ?? x4() + x5() 4 | !! (my &B = { A(--$k, &B, &x1, &x2, &x3, &x4) })(); 5 | }; 6 | 7 | say A(Int(@*ARGS[0]), {1}, {-1}, {-1}, {1}, {0}); 8 | -------------------------------------------------------------------------------- /Reports/Compiled/man-or-boy 20.csv: -------------------------------------------------------------------------------- 1 | language,file,time_min,time_max,time_avg 2 | "Go (go)",mob2.go,0.472929,0.473625,0.473166666666667 3 | "Go (go)",mob.go,0.492592,0.496272,0.494354333333333 4 | "OCaml (ocamlopt)",mob.ml,0.036739,0.037396,0.0370853333333333 5 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.php: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.cr: -------------------------------------------------------------------------------- 1 | def a(k, x1, x2, x3, x4, x5) 2 | b = uninitialized -> typeof(k) 3 | b = ->() { k -= 1; a(k, b, x1, x2, x3, x4) } 4 | k <= 0 ? x4.call + x5.call : b.call 5 | end 6 | 7 | puts a(ARGV[0].to_i, -> {1}, -> {-1}, -> {-1}, -> {1}, -> {0}) 8 | -------------------------------------------------------------------------------- /Interpreted/fibonacci-recursive/fib.exs: -------------------------------------------------------------------------------- 1 | defmodule Fib do 2 | def fib(0), do: 0 3 | def fib(1), do: 1 4 | def fib(n) do 5 | fib(n-2) + fib(n-1) 6 | end 7 | end 8 | 9 | [n | _] = System.argv 10 | {n, _} = Integer.parse(n) 11 | 12 | IO.puts Fib.fib(n) 13 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.pl: -------------------------------------------------------------------------------- 1 | sub A { 2 | my ($k, $x1, $x2, $x3, $x4, $x5) = @_; 3 | my($B); 4 | $B = sub { A(--$k, $B, $x1, $x2, $x3, $x4) }; 5 | $k <= 0 ? &$x4 + &$x5 : &$B; 6 | } 7 | 8 | print A($ARGV[0], sub{1}, sub {-1}, sub{-1}, sub{1}, sub{0} ), "\n"; 9 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.tcl: -------------------------------------------------------------------------------- 1 | proc tak {x y z} { 2 | if { $y < $x } { tak [tak [expr {$x - 1}] $y $z] [tak [expr {$y - 1}] $z $x] [tak [expr {$z - 1}] $x $y] } else { 3 | expr { $z } 4 | } 5 | } 6 | 7 | puts [tak [lindex $argv 0] [lindex $argv 1] [lindex $argv 2]] 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /blib/ 2 | /.build/ 3 | _build/ 4 | cover_db/ 5 | inc/ 6 | Build 7 | !Build/ 8 | Build.bat 9 | .last_cover_stats 10 | /Makefile 11 | /Makefile.old 12 | /MANIFEST.bak 13 | /META.yml 14 | /META.json 15 | /MYMETA.* 16 | nytprof.out 17 | /pm_to_blib 18 | *.o 19 | *.bs 20 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.py: -------------------------------------------------------------------------------- 1 | import sys; 2 | 3 | def tak(x, y, z): 4 | if (y < x): 5 | return tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y)) 6 | else: 7 | return z 8 | 9 | print(tak(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]))); 10 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.ml: -------------------------------------------------------------------------------- 1 | let rec tak x y z = 2 | if y < x then 3 | (tak (tak (x-1) y z) (tak (y-1) z x) (tak (z-1) x y)) 4 | else 5 | z 6 | 7 | let () = 8 | Printf.printf "%d\n" (tak (int_of_string Sys.argv.(1)) (int_of_string Sys.argv.(2)) (int_of_string Sys.argv.(3))) 9 | -------------------------------------------------------------------------------- /Reports/Compiled/array-reverse 1000000 1000.csv: -------------------------------------------------------------------------------- 1 | language,file,time_min,time_max,time_avg 2 | "Go (go)",rev.go,1.076515,1.076515,1.076515 3 | "C (gcc -O2)",rev.c,0.000818,0.000818,0.000818 4 | "C (gcc -O0)",rev.c,2.406096,2.406096,2.406096 5 | "C (gcc -Ofast)",rev.c,0.000814,0.000814,0.000814 6 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.jl: -------------------------------------------------------------------------------- 1 | function ack(m,n) 2 | if m == 0 3 | return n + 1 4 | elseif n == 0 5 | return ack(m-1,1) 6 | else 7 | return ack(m-1,ack(m,n-1)) 8 | end 9 | end 10 | 11 | println(ack(parse(Int, ARGS[1]), parse(Int, ARGS[2]))); 12 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.gvy: -------------------------------------------------------------------------------- 1 | def a; a = { k, x1, x2, x3, x4, x5 -> 2 | def b; b = { 3 | a (--k, b, x1, x2, x3, x4) 4 | } 5 | k <= 0 ? x4() + x5() : b() 6 | } 7 | 8 | def x = { n -> { it -> n } } 9 | println (a(args[0].toInteger(), x(1), x(-1), x(-1), x(1), x(0))) 10 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.pike: -------------------------------------------------------------------------------- 1 | int tak(int x, int y, int z) { 2 | return(y 15 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.awk: -------------------------------------------------------------------------------- 1 | function ackermann(m, n) { 2 | if (m == 0) { 3 | return n+1; 4 | } 5 | if (n == 0) { 6 | return ackermann(m-1, 1); 7 | } 8 | return ackermann(m-1, ackermann(m, n-1)); 9 | } 10 | 11 | BEGIN { 12 | print ackermann(ARGV[1], ARGV[2]); 13 | } 14 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.sc: -------------------------------------------------------------------------------- 1 | def tak(x:Int, y:Int, z:Int):Int = { 2 | if (y < x) { 3 | return tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y)) 4 | } 5 | else { 6 | return z; 7 | } 8 | }; 9 | 10 | println(tak(args(0).toInt, args(1).toInt, args(2).toInt)); 11 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.sc: -------------------------------------------------------------------------------- 1 | def A(in_k: Int, x1: =>Int, x2: =>Int, x3: =>Int, x4: =>Int, x5: =>Int): Int = { 2 | var k = in_k 3 | def B: Int = { 4 | k = k-1 5 | A(k, B, x1, x2, x3, x4) 6 | } 7 | if (k<=0) x4+x5 else B 8 | } 9 | println(A(args(0).toInt, 1, -1, -1, 1, 0)) 10 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.clj: -------------------------------------------------------------------------------- 1 | (defn ackermann [m n] 2 | (cond (zero? m) (inc n) 3 | (zero? n) (ackermann (dec m) 1) 4 | :else (ackermann (dec m) (ackermann m (dec n))))) 5 | 6 | (println (ackermann (Integer/parseInt (first *command-line-args* )) (Integer/parseInt (second *command-line-args* )))) 7 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.pike: -------------------------------------------------------------------------------- 1 | int main(int argc, array(string) argv) { 2 | write(F((int)argv[1]) + "\n"); 3 | write(M((int)argv[1]) + "\n"); 4 | } 5 | 6 | int F(int n) { 7 | return (n == 0 ? 1 : n - M(F(n-1))); 8 | } 9 | 10 | int M(int n) { 11 | return (n == 0 ? 0 : n - F(M(n-1))); 12 | } 13 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.clj: -------------------------------------------------------------------------------- 1 | 2 | (defn tak [x y z] 3 | (if (< y x) 4 | (tak (tak (dec x) y z) (tak (dec y) z x) (tak (dec z) x y)) 5 | z)) 6 | 7 | (println (tak (Integer/parseInt (first *command-line-args* )) (Integer/parseInt (second *command-line-args* )) (Integer/parseInt (last *command-line-args* )))) 8 | -------------------------------------------------------------------------------- /Compiled/fibonacci-recursive/fib.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "strconv" 7 | ) 8 | 9 | func fib(n int) int { 10 | if n > 1 { 11 | return fib(n-1) + fib(n-2) 12 | } 13 | return n 14 | } 15 | 16 | func main() { 17 | n, _ := strconv.Atoi(os.Args[1]) 18 | fmt.Println(fib(n)) 19 | } 20 | -------------------------------------------------------------------------------- /Compiled/fibonacci-recursive/fib.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int fib(int n) { 5 | if (n > 1) { 6 | return fib(n-1) + fib(n-2); 7 | } 8 | return n; 9 | } 10 | 11 | int main(int argc, const char * argv[]) { 12 | printf("%d\n", fib(atoi(argv[1]))); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.setrecursionlimit(10000) 3 | 4 | def ack(M, N): 5 | if M == 0: 6 | return N + 1 7 | elif N == 0: 8 | return ack(M - 1, 1) 9 | else: 10 | return ack(M - 1, ack(M, N - 1)) 11 | 12 | print(ack(int(sys.argv[1]), int(sys.argv[2]))) 13 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.exs: -------------------------------------------------------------------------------- 1 | defmodule MutualRecursion do 2 | def f(0), do: 1 3 | def f(n), do: n - m(f(n - 1)) 4 | def m(0), do: 0 5 | def m(n), do: n - f(m(n - 1)) 6 | end 7 | 8 | [n | _] = System.argv 9 | {n, _} = Integer.parse(n) 10 | 11 | IO.puts MutualRecursion.f(n) 12 | IO.puts MutualRecursion.m(n) 13 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.ml: -------------------------------------------------------------------------------- 1 | let rec f = function 2 | | 0 -> 1 3 | | n -> n - m(f(n-1)) 4 | and m = function 5 | | 0 -> 0 6 | | n -> n - f(m(n-1)) 7 | ;; 8 | 9 | let () = 10 | Printf.printf "%d\n" (f (int_of_string Sys.argv.(1))) 11 | 12 | let () = 13 | Printf.printf "%d\n" (m (int_of_string Sys.argv.(1))) 14 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.exs: -------------------------------------------------------------------------------- 1 | defmodule Ackermann do 2 | def ack(0, n), do: n + 1 3 | def ack(m, 0), do: ack(m - 1, 1) 4 | def ack(m, n), do: ack(m - 1, ack(m, n - 1)) 5 | end 6 | 7 | [n | tail] = System.argv 8 | [m | _] = tail 9 | 10 | {n, _} = Integer.parse(n) 11 | {m, _} = Integer.parse(m) 12 | 13 | IO.puts Ackermann.ack(n, m) 14 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.tcl: -------------------------------------------------------------------------------- 1 | proc m {n} { 2 | if { $n == 0 } { expr 0 } else { 3 | expr {$n - [f [m [expr {$n-1}] ]]}; 4 | } 5 | } 6 | proc f {n} { 7 | if { $n == 0 } { expr 1 } else { 8 | expr {$n - [m [f [expr {$n-1}] ]]}; 9 | } 10 | } 11 | 12 | puts [f [lindex $argv 0]] 13 | puts [m [lindex $argv 0]] 14 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.php: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /Compiled/fibonacci-recursive/fib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int fib(int n) { 7 | if (n > 1) { 8 | return fib(n-1) + fib(n-2); 9 | } 10 | return n; 11 | } 12 | 13 | int main(int argc, const char * argv[]) { 14 | cout << fib(atoi(argv[1])) << endl; 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.lua: -------------------------------------------------------------------------------- 1 | function a(k,x1,x2,x3,x4,x5) 2 | local function b() 3 | k = k - 1 4 | return a(k,b,x1,x2,x3,x4) 5 | end 6 | if k <= 0 then return x4() + x5() else return b() end 7 | end 8 | 9 | function K(n) 10 | return function() 11 | return n 12 | end 13 | end 14 | 15 | print(a(tonumber(arg[1]), K(1), K(-1), K(-1), K(1), K(0))) 16 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.pike: -------------------------------------------------------------------------------- 1 | int main(int argc, array(string) argv) { 2 | write(ackermann((int)argv[1], (int)argv[2]) + "\n"); 3 | } 4 | 5 | int ackermann(int m, int n){ 6 | if(m == 0){ 7 | return n + 1; 8 | } else if(n == 0){ 9 | return ackermann(m-1, 1); 10 | } else { 11 | return ackermann(m-1, ackermann(m, n-1)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Interpreted/mutual-recursion/mrec.clj: -------------------------------------------------------------------------------- 1 | (declare F) ; forward reference 2 | 3 | (defn M [n] 4 | (if (zero? n) 5 | 0 6 | (- n (F (M (dec n)))))) 7 | 8 | (defn F [n] 9 | (if (zero? n) 10 | 1 11 | (- n (M (F (dec n)))))) 12 | 13 | (println (F (Integer/parseInt (first *command-line-args* )))) 14 | (println (M (Integer/parseInt (first *command-line-args* )))) 15 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.ml: -------------------------------------------------------------------------------- 1 | let rec a k x1 x2 x3 x4 x5 = 2 | if k <= 0 then 3 | x4 () + x5 () 4 | else 5 | let m = ref k in 6 | let rec b () = 7 | decr m; 8 | a !m b x1 x2 x3 x4 9 | in 10 | b () 11 | 12 | let () = 13 | Printf.printf "%d\n" (a (int_of_string Sys.argv.(1)) (fun () -> 1) (fun () -> -1) (fun () -> -1) (fun () -> 1) (fun () -> 0)) 14 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/csum.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def num_paths(startsum,lastcoin): 4 | if (startsum==250): return 1 5 | paths = 0 6 | for coin in [1,2,5,10,20,50,100,200]: 7 | if ((lastcoin>=coin) and (startsum<=(250-coin))): 8 | paths += num_paths(startsum+coin,coin) 9 | 10 | return paths 11 | 12 | print(num_paths(int(sys.argv[1]), int(sys.argv[2]))) 13 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.clj: -------------------------------------------------------------------------------- 1 | (defn longest [xs ys] (if (> (count xs) (count ys)) xs ys)) 2 | 3 | (def lcs 4 | (fn [[x & xs] [y & ys]] 5 | (cond 6 | (or (= x nil) (= y nil) ) nil 7 | (= x y) (cons x (lcs xs ys)) 8 | :else (longest (lcs (cons x xs) ys) (lcs xs (cons y ys)))))) 9 | 10 | (println (lcs (first *command-line-args* ) (second *command-line-args* ))) 11 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | sys.setrecursionlimit(40000) 5 | 6 | def a(k, x1, x2, x3, x4, x5): 7 | def b(): 8 | b.k -= 1 9 | return a(b.k, b, x1, x2, x3, x4) 10 | b.k = k 11 | return x4() + x5() if b.k <= 0 else b() 12 | 13 | x = lambda i: lambda: i 14 | print(a(int(sys.argv[1]), x(1), x(-1), x(-1), x(1), x(0))) 15 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.tcl: -------------------------------------------------------------------------------- 1 | proc A {k x1 x2 x3 x4 x5} { 2 | expr {$k<=0 ? [eval $x4]+[eval $x5] : [B \#[info level]]} 3 | } 4 | proc B {level} { 5 | upvar $level k k x1 x1 x2 x2 x3 x3 x4 x4 6 | incr k -1 7 | A $k [info level 0] $x1 $x2 $x3 $x4 8 | } 9 | proc C {val} {return $val} 10 | interp recursionlimit {} 40000 11 | puts [A [lindex $argv 0] {C 1} {C -1} {C -1} {C 1} {C 0}] 12 | -------------------------------------------------------------------------------- /Interpreted/ackermann-function/ack.tcl: -------------------------------------------------------------------------------- 1 | interp recursionlimit {} [expr {10000}] 2 | 3 | namespace import ::tcl::mathop::* 4 | 5 | proc ack {m n} { 6 | if {! $m} { 7 | incr n 8 | } elseif {! $n} { 9 | incr m -1 10 | ack $m 1 11 | } else { 12 | incr n -1 13 | ack [- $m 1] [ack $m $n] 14 | } 15 | } 16 | 17 | puts [ack [lindex $argv 0] [lindex $argv 1]] 18 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/csum.rb: -------------------------------------------------------------------------------- 1 | def num_paths(startsum,lastcoin) 2 | return 1 if (startsum==250); 3 | paths = 0 4 | [1,2,5,10,20,50,100,200].each do |coin| 5 | if ((lastcoin>=coin) and (startsum<=(250-coin))) 6 | paths = paths + num_paths(startsum+coin,coin) 7 | end 8 | end 9 | 10 | paths 11 | end 12 | 13 | puts(num_paths(ARGV[0].to_i, ARGV[1].to_i)) 14 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/csum.jl: -------------------------------------------------------------------------------- 1 | function num_paths(startsum,lastcoin) 2 | startsum == 250 && return 1; 3 | paths = 0; 4 | for coin in [1,2,5,10,20,50,100,200] 5 | if ((lastcoin>=coin) && (startsum<=(250-coin))) 6 | paths += num_paths(startsum+coin,coin) 7 | end 8 | end 9 | return paths 10 | end 11 | 12 | println(num_paths(parse(Int,ARGS[1]),parse(Int,ARGS[2]))); 13 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/csum.cr: -------------------------------------------------------------------------------- 1 | def num_paths(startsum : Int,lastcoin : Int) 2 | return 1 if (startsum==250) 3 | 4 | paths = 0 5 | [1,2,5,10,20,50,100,200].each do |coin| 6 | if (lastcoin >= coin) && (startsum <= (250-coin)) 7 | paths = paths + num_paths(startsum+coin, coin) 8 | end 9 | end 10 | 11 | paths 12 | end 13 | 14 | puts(num_paths(ARGV[0].to_i, ARGV[1].to_i)) 15 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/csum.gvy: -------------------------------------------------------------------------------- 1 | def num_paths(startsum,lastcoin) { 2 | if (startsum == 250) {return 1} 3 | def paths = 0; 4 | [1,2,5,10,20,50,100,200].each { coin -> 5 | if ((lastcoin>=coin) && (startsum<=(250-coin))) { 6 | paths += num_paths(startsum+coin,coin) 7 | } 8 | } 9 | return paths 10 | } 11 | 12 | println(num_paths(args[0].toInteger(), args[1].toInteger())); 13 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/csum.sc: -------------------------------------------------------------------------------- 1 | def num_paths(startsum:Int,lastcoin:Int):Int = { 2 | if (startsum == 250) {return 1} 3 | var paths = 0; 4 | for (coin <- List(1,2,5,10,20,50,100,200)) { 5 | if ((lastcoin>=coin) && (startsum<=(250-coin))) { 6 | paths += num_paths(startsum+coin,coin) 7 | } 8 | } 9 | return paths 10 | } 11 | 12 | println(num_paths(args(0).toInt, args(1).toInt)); 13 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.rb: -------------------------------------------------------------------------------- 1 | def lcs(xstr, ystr) 2 | 3 | xstr.empty? || ystr.empty? and return ""; 4 | 5 | x = xstr[0]; 6 | xs = xstr[1..-1]; 7 | y = ystr[0]; 8 | ys = ystr[1..-1]; 9 | 10 | x == y and return(x + lcs(xs, ys)); 11 | 12 | lcs1 = lcs(xstr, ys); 13 | lcs2 = lcs(xs, ystr); 14 | 15 | lcs1.size > lcs2.size ? lcs1 : lcs2; 16 | end 17 | 18 | puts lcs(ARGV[0], ARGV[1]); 19 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.cr: -------------------------------------------------------------------------------- 1 | def lcs(xstr : String, ystr : String) 2 | 3 | (xstr.empty? || ystr.empty?) && return "" 4 | 5 | x = xstr[0] 6 | xs = xstr[1..-1] 7 | y = ystr[0] 8 | ys = ystr[1..-1] 9 | 10 | x == y && return(x + lcs(xs, ys)) 11 | 12 | lcs1 = lcs(xstr, ys) 13 | lcs2 = lcs(xs, ystr) 14 | 15 | lcs1.size > lcs2.size ? lcs1 : lcs2 16 | end 17 | 18 | puts lcs(ARGV[0], ARGV[1]) 19 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def leven(s, t): 4 | 5 | if s == '': return len(t) 6 | if t == '': return len(s) 7 | 8 | s1 = s[1:] 9 | t1 = t[1:] 10 | 11 | if s[0] == t[0]: 12 | return leven(s1, t1) 13 | 14 | return 1 + min( 15 | leven(s, t1), 16 | leven(s1, t ), 17 | leven(s1, t1) 18 | ) 19 | 20 | print(leven(sys.argv[1], sys.argv[2])) 21 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.jl: -------------------------------------------------------------------------------- 1 | function lcs(xstr, ystr) 2 | 3 | (xstr == "" || ystr == "") && return ""; 4 | 5 | x = xstr[1:1]; 6 | xs = xstr[2:end]; 7 | y = ystr[1:1]; 8 | ys = ystr[2:end]; 9 | 10 | x == y && return(x * lcs(xs, ys)); 11 | 12 | lcs1 = lcs(xstr, ys); 13 | lcs2 = lcs(xs, ystr); 14 | 15 | length(lcs1) > length(lcs2) ? lcs1 : lcs2; 16 | end 17 | 18 | println(lcs(ARGS[1], ARGS[2])); 19 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.mrb: -------------------------------------------------------------------------------- 1 | def leven(s,t) 2 | 3 | return t.size if (s == "") 4 | return s.size if (t == "") 5 | 6 | s1 = s[1..-1] 7 | t1 = t[1..-1] 8 | 9 | s[0] == t[0] ? leven(s1, t1) : 1 + [ 10 | leven(s1, t1), 11 | leven(s, t1), 12 | leven(s1, t ) 13 | ].min 14 | end 15 | 16 | puts leven(ARGV[0], ARGV[1]) 17 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.sc: -------------------------------------------------------------------------------- 1 | 2 | def min(a:Int, b:Int, c:Int) = Math.min( Math.min( a, b ), c) 3 | def sd(s1: List[Char], s2: List[Char]): Int = (s1, s2) match { 4 | case (_, Nil) => s1.length 5 | case (Nil, _) => s2.length 6 | case (c1::t1, c2::t2) => min( sd(t1,s2) + 1, sd(s1,t2) + 1, 7 | sd(t1,t2) + (if (c1==c2) 0 else 1) ) 8 | } 9 | 10 | println(sd(args(0).toList, args(1).toList)) 11 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/csum.pl: -------------------------------------------------------------------------------- 1 | sub num_paths { 2 | my ($startsum, $lastcoin) = @_; 3 | 4 | return 1 if $startsum == 250; 5 | 6 | my $paths = 0; 7 | foreach my $coin (1, 2, 5, 10, 20, 50, 100, 200) { 8 | if ($lastcoin >= $coin and $startsum <= 250 - $coin) { 9 | $paths += num_paths($startsum + $coin, $coin); 10 | } 11 | } 12 | 13 | $paths; 14 | } 15 | 16 | print num_paths($ARGV[0], $ARGV[1]), "\n"; 17 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/csum.lua: -------------------------------------------------------------------------------- 1 | function num_paths(startsum,lastcoin) 2 | if (startsum==250) then return 1 end 3 | local paths = 0 4 | for _,coin in ipairs({1, 2, 5, 10, 20, 50, 100, 200}) do 5 | if (((lastcoin>=coin) and (startsum<=(250-coin)))) then 6 | paths = paths + num_paths(startsum + coin, coin) 7 | end 8 | end 9 | 10 | return paths 11 | end 12 | 13 | print(num_paths(tonumber(arg[1]), tonumber(arg[2]))) 14 | -------------------------------------------------------------------------------- /Interpreted/tak-function/tak.exs: -------------------------------------------------------------------------------- 1 | defmodule Tak do 2 | def tak(x, y, z) do 3 | if y < x do 4 | tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y)) 5 | else 6 | z 7 | end 8 | end 9 | end 10 | 11 | [a | tail] = System.argv 12 | [b | tail] = tail 13 | [c | _ ] = tail 14 | 15 | {a, _} = Integer.parse(a) 16 | {b, _} = Integer.parse(b) 17 | {c, _} = Integer.parse(c) 18 | 19 | IO.puts Tak.tak(a, b, c) 20 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.rb: -------------------------------------------------------------------------------- 1 | def leven(s,t) 2 | 3 | return t.size if (s == "") 4 | return s.size if (t == "") 5 | 6 | s1 = s[1..-1] 7 | t1 = t[1..-1] 8 | 9 | s[0] == t[0] ? leven(s1, t1) 10 | : 1 + [ 11 | leven(s1, t1), 12 | leven(s, t1), 13 | leven(s1, t ) 14 | ].min 15 | end 16 | 17 | puts leven(ARGV[0], ARGV[1]) 18 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.jl: -------------------------------------------------------------------------------- 1 | function leven(s, t) 2 | 3 | s == "" && return length(t); 4 | t == "" && return length(s); 5 | 6 | s1 = s[2:end]; 7 | t1 = t[2:end]; 8 | 9 | return (s[1] == t[1] 10 | ? leven(s1, t1) 11 | : 1 + min( 12 | leven(s1, t1), 13 | leven(s, t1), 14 | leven(s1, t) 15 | ) 16 | ); 17 | end 18 | 19 | println(leven(ARGS[1], ARGS[2])); 20 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.cr: -------------------------------------------------------------------------------- 1 | def leven(s : String, t : String) 2 | 3 | return t.size if (s == "") 4 | return s.size if (t == "") 5 | 6 | s1 = s[1..-1] 7 | t1 = t[1..-1] 8 | 9 | s[0] == t[0] ? leven(s1, t1) 10 | : 1 + [ 11 | leven(s1, t1), 12 | leven(s, t1), 13 | leven(s1, t ) 14 | ].min 15 | end 16 | 17 | puts leven(ARGV[0], ARGV[1]) 18 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.lua: -------------------------------------------------------------------------------- 1 | function leven(s,t) 2 | if s == '' then return t:len() end 3 | if t == '' then return s:len() end 4 | 5 | local s1 = s:sub(2, -1) 6 | local t1 = t:sub(2, -1) 7 | 8 | if s:sub(0, 1) == t:sub(0, 1) then 9 | return leven(s1, t1) 10 | end 11 | 12 | return 1 + math.min( 13 | leven(s1, t1), 14 | leven(s, t1), 15 | leven(s1, t ) 16 | ) 17 | end 18 | 19 | print(leven(arg[1], arg[2])) 20 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.ml: -------------------------------------------------------------------------------- 1 | let levenshtein s t = 2 | let rec dist i j = match (i,j) with 3 | | (i,0) -> i 4 | | (0,j) -> j 5 | | (i,j) -> 6 | if s.[i-1] = t.[j-1] then dist (i-1) (j-1) 7 | else let d1, d2, d3 = dist (i-1) j, dist i (j-1), dist (i-1) (j-1) in 8 | 1 + min d1 (min d2 d3) 9 | in 10 | dist (String.length s) (String.length t) 11 | 12 | let () = 13 | Printf.printf "%d\n" (levenshtein Sys.argv.(1) Sys.argv.(2)) 14 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.gvy: -------------------------------------------------------------------------------- 1 | def leven(s, t) { 2 | 3 | if (s == "") {return t.size()} 4 | if (t == "") {return s.size()} 5 | 6 | def s1 = s.size() > 1 ? s[1..-1] : ""; 7 | def t1 = t.size() > 1 ? t[1..-1] : ""; 8 | 9 | s[0] == t[0] 10 | ? leven(s1, t1) 11 | : 1 + [ 12 | leven(s1, t1), 13 | leven(s, t1), 14 | leven(s1, t) 15 | ].min() 16 | } 17 | 18 | println(leven(args[0], args[1])); 19 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.sc: -------------------------------------------------------------------------------- 1 | def lcs[T]: (List[T], List[T]) => List[T] = { 2 | case (_, Nil) => Nil 3 | case (Nil, _) => Nil 4 | case (x :: xs, y :: ys) if x == y => x :: lcs(xs, ys) 5 | case (x :: xs, y :: ys) => { 6 | (lcs(x :: xs, ys), lcs(xs, y :: ys)) match { 7 | case (xs, ys) if xs.length > ys.length => xs 8 | case (xs, ys) => ys 9 | } 10 | } 11 | } 12 | 13 | println(lcs(args(0).toList, args(1).toList).mkString); 14 | -------------------------------------------------------------------------------- /Reports/Compiled/fibonacci-recursive 40.csv: -------------------------------------------------------------------------------- 1 | language,file,time_min,time_max,time_avg 2 | "Go (go)",fib.go,0.969457,0.969457,0.969457 3 | "C++ (g++ -Ofast)",fib.cpp,0.517753,0.517753,0.517753 4 | "C++ (g++ -O2)",fib.cpp,0.460053,0.460053,0.460053 5 | "C++ (g++ -O0)",fib.cpp,0.837772,0.837772,0.837772 6 | "OCaml (ocamlopt)",fib.ml,0.590155,0.590155,0.590155 7 | "C (gcc -O2)",fib.c,0.464293,0.464293,0.464293 8 | "C (gcc -Ofast)",fib.c,0.518329,0.518329,0.518329 9 | "C (gcc -O0)",fib.c,0.867048,0.867048,0.867048 10 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.php: -------------------------------------------------------------------------------- 1 | 15 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.tcl: -------------------------------------------------------------------------------- 1 | 2 | proc r_lcs {a b} { 3 | if {$a eq "" || $b eq ""} {return ""} 4 | set a_ [string range $a 1 end] 5 | set b_ [string range $b 1 end] 6 | if {[set c [string index $a 0]] eq [string index $b 0]} { 7 | return "$c[r_lcs $a_ $b_]" 8 | } else { 9 | set x [r_lcs $a $b_] 10 | set y [r_lcs $a_ $b] 11 | return [expr {[string length $x] > [string length $y] ? $x :$y}] 12 | } 13 | } 14 | 15 | puts [r_lcs [lindex $argv 0] [lindex $argv 1]] 16 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def lcs(xstr, ystr): 4 | 5 | if (xstr == "" or ystr == ""): 6 | return ""; 7 | 8 | x = xstr[0]; 9 | xs = xstr[1:]; 10 | y = ystr[0]; 11 | ys = ystr[1:]; 12 | 13 | if x == y: 14 | return(x + lcs(xs, ys)); 15 | 16 | lcs1 = lcs(xstr, ys); 17 | lcs2 = lcs(xs, ystr); 18 | 19 | if len(lcs1) > len(lcs2): 20 | return lcs1 21 | else: 22 | return lcs2; 23 | 24 | 25 | print(lcs(sys.argv[1], sys.argv[2])); 26 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.pl: -------------------------------------------------------------------------------- 1 | use List::Util 'min'; 2 | 3 | sub leven { 4 | my ($s, $t) = @_; 5 | 6 | return length($t) if $s eq ''; 7 | return length($s) if $t eq ''; 8 | 9 | my ($s1, $t1) = (substr($s, 1), substr($t, 1)); 10 | 11 | (substr($s, 0, 1) eq substr($t, 0, 1)) 12 | ? leven($s1, $t1) 13 | : 1 + min( 14 | leven($s1, $t1), 15 | leven($s, $t1), 16 | leven($s1, $t) 17 | ); 18 | } 19 | 20 | print leven($ARGV[0], $ARGV[1]), "\n"; 21 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/csum.php: -------------------------------------------------------------------------------- 1 | = $coin) && ($startsum <= (250 - $coin))) { 13 | $paths += num_paths($startsum + $coin, $coin); 14 | } 15 | } 16 | 17 | return $paths; 18 | } 19 | 20 | echo num_paths($argv[1], $argv[2]), "\n"; 21 | ?> 22 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/csum.pike: -------------------------------------------------------------------------------- 1 | int main(int argc, array(string) argv) { 2 | write(num_paths((int)argv[1], (int)argv[2]) + "\n"); 3 | } 4 | 5 | int num_paths(int startsum, int lastcoin) { 6 | 7 | if (startsum == 250) { 8 | return 1; 9 | } 10 | 11 | int paths = 0; 12 | foreach(({ 1, 2, 5, 10, 20, 50, 100, 200 }), int coin) { 13 | if (lastcoin >= coin && startsum <= 250 - coin) { 14 | paths += num_paths(startsum + coin, coin); 15 | } 16 | } 17 | 18 | return paths; 19 | } 20 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.pl: -------------------------------------------------------------------------------- 1 | sub lcs { 2 | my ($xstr, $ystr) = @_; 3 | ($xstr eq '' or $ystr eq '') && return ''; 4 | 5 | my ($x, $xs, $y, $ys) = (substr($xstr, 0, 1), substr($xstr, 1), 6 | substr($ystr, 0, 1), substr($ystr, 1)); 7 | 8 | if ($x eq $y) { 9 | return ($x . lcs($xs, $ys)); 10 | } 11 | 12 | my $lcs1 = lcs($xstr, $ys); 13 | my $lcs2 = lcs($xs, $ystr); 14 | length($lcs1) > length($lcs2) ? $lcs1 : $lcs2; 15 | } 16 | 17 | print lcs($ARGV[0], $ARGV[1]), "\n"; 18 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.gvy: -------------------------------------------------------------------------------- 1 | def lcs(xstr, ystr) { 2 | if (xstr == "" || ystr == "") { 3 | return ""; 4 | } 5 | 6 | def x = xstr[0]; 7 | def xs = xstr.size() > 1 ? xstr[1..-1] : ""; 8 | def y = ystr[0]; 9 | def ys = ystr.size() > 1 ? ystr[1..-1] : ""; 10 | 11 | if (x == y) { 12 | return (x + lcs(xs, ys)); 13 | } 14 | 15 | def lcs1 = lcs(xstr, ys); 16 | def lcs2 = lcs(xs, ystr); 17 | 18 | lcs1.size() > lcs2.size() ? lcs1 : lcs2; 19 | } 20 | 21 | println(lcs(args[0], args[1])); 22 | -------------------------------------------------------------------------------- /Interpreted/man-or-boy/mob.clj: -------------------------------------------------------------------------------- 1 | (declare a) 2 | 3 | (defn man-or-boy 4 | [k] 5 | (let [k (atom k)] 6 | (a k 7 | (fn [] 1) 8 | (fn [] -1) 9 | (fn [] -1) 10 | (fn [] 1) 11 | (fn [] 0)))) 12 | 13 | (defn a 14 | [k x1 x2 x3 x4 x5] 15 | (let [k (atom @k)] 16 | (letfn [(b [] 17 | (swap! k dec) 18 | (a k b x1 x2 x3 x4))] 19 | (if (<= @k 0) 20 | (+ (x4) (x5)) 21 | (b))))) 22 | 23 | (println (man-or-boy (Integer/parseInt (first *command-line-args* )))) 24 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.php: -------------------------------------------------------------------------------- 1 | strlen($lcs2) ? $lcs1 : $lcs2; 21 | } 22 | 23 | echo lcs($argv[1], $argv[2]), "\n"; 24 | ?> 25 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.lua: -------------------------------------------------------------------------------- 1 | function lcs(xstr, ystr) 2 | if (xstr == "" or ystr == "") then return "" end; 3 | 4 | local x = xstr:sub(0,1); 5 | local xs = xstr:sub(2,-1); 6 | local y = ystr:sub(0,1); 7 | local ys = ystr:sub(2,-1); 8 | 9 | if x == y then 10 | return (x .. lcs(xs, ys)) 11 | end 12 | 13 | local lcs1 = lcs(xstr, ys); 14 | local lcs2 = lcs(xs, ystr); 15 | 16 | if lcs1:len() > lcs2:len() then 17 | return lcs1 18 | else 19 | return lcs2 20 | end 21 | end 22 | 23 | print(lcs(arg[1], arg[2])) 24 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.clj: -------------------------------------------------------------------------------- 1 | (defn levenshtein [str1 str2] 2 | (let [len1 (count str1) 3 | len2 (count str2)] 4 | (cond (zero? len1) len2 5 | (zero? len2) len1 6 | :else 7 | (let [cost (if (= (first str1) (first str2)) 0 1)] 8 | (min (inc (levenshtein (rest str1) str2)) 9 | (inc (levenshtein str1 (rest str2))) 10 | (+ cost 11 | (levenshtein (rest str1) (rest str2)))))))) 12 | 13 | (println (levenshtein (first *command-line-args*) (second *command-line-args*))) 14 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.php: -------------------------------------------------------------------------------- 1 | 26 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.pike: -------------------------------------------------------------------------------- 1 | int main(int argc, array(string) argv) { 2 | write(lcs(argv[1], argv[2]) + "\n"); 3 | } 4 | 5 | string lcs(string xstr, string ystr) { 6 | 7 | if (xstr == "" || ystr == "") { 8 | return ""; 9 | } 10 | 11 | string x = xstr[0..0]; 12 | string y = ystr[0..0]; 13 | 14 | string xs = xstr[1..]; 15 | string ys = ystr[1..]; 16 | 17 | if (x == y) { 18 | return (x + lcs(xs, ys)); 19 | } 20 | 21 | string lcs1 = lcs(xstr, ys); 22 | string lcs2 = lcs(xs, ystr); 23 | 24 | return (sizeof(lcs1) > sizeof(lcs2) ? lcs1 : lcs2); 25 | } 26 | -------------------------------------------------------------------------------- /Interpreted/lcs-recursive/lcs.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | print lcs(ARGV[1], ARGV[2]); 3 | } 4 | 5 | function lcs(xstr, ystr, lcs1, lcs2, l1, l2, x,xs,y,ys) { 6 | 7 | l1 = length(xstr); 8 | l2 = length(ystr); 9 | if(l1 == 0 || l2 == 0) { 10 | return ""; 11 | } 12 | 13 | x = substr(xstr, 1, 1); 14 | xs = substr(xstr, 2, l1); 15 | y = substr(ystr, 1, 1); 16 | ys = substr(ystr, 2, l2); 17 | 18 | if (x == y) { 19 | return (x lcs(xs, ys)); 20 | } 21 | 22 | lcs1 = lcs(xstr, ys); 23 | lcs2 = lcs(xs, ystr); 24 | return(length(lcs1) > length(lcs2) ? lcs1 : lcs2); 25 | } 26 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.pike: -------------------------------------------------------------------------------- 1 | int main(int argc, array(string) argv) { 2 | write(leven(argv[1], argv[2]) + "\n"); 3 | } 4 | 5 | int leven(string s, string t) { 6 | 7 | if (s == "") { 8 | return sizeof(t); 9 | } 10 | 11 | if (t == "") { 12 | return sizeof(s); 13 | } 14 | 15 | string s1 = s[1..]; 16 | string t1 = t[1..]; 17 | 18 | return ( 19 | s[0] == t[0] 20 | ? leven(s1, t1) 21 | : 1 + min( 22 | leven(s1, t1), 23 | leven(s, t1), 24 | leven(s1, t ) 25 | ) 26 | ); 27 | } 28 | -------------------------------------------------------------------------------- /Interpreted/coin-sums/csum.awk: -------------------------------------------------------------------------------- 1 | 2 | BEGIN { 3 | coins[1] = 1; 4 | coins[2] = 2; 5 | coins[3] = 5; 6 | coins[4] = 10; 7 | coins[5] = 20; 8 | coins[6] = 50; 9 | coins[7] = 100; 10 | coins[8] = 200; 11 | } 12 | 13 | function num_paths(startsum, lastcoin, paths) { 14 | 15 | if (startsum == 250) { 16 | return 1; 17 | } 18 | 19 | paths = 0; 20 | for (i in coins) { 21 | if (lastcoin >= coins[i] && startsum <= 250-coins[i]) { 22 | paths += num_paths(startsum + coins[i], coins[i]); 23 | } 24 | } 25 | 26 | return paths; 27 | } 28 | 29 | BEGIN { 30 | a = ARGV[1]; 31 | b = ARGV[2]; 32 | print num_paths(a, b); 33 | } 34 | -------------------------------------------------------------------------------- /Reports/Compiled/man-or-boy 16.csv: -------------------------------------------------------------------------------- 1 | language,file,time_min,time_max,time_avg 2 | "OCaml (ocamlopt)",mob.ml,0.002486,0.002676,0.00256766666666667 3 | "Go (go)",mob.go,0.034676,0.035621,0.035194 4 | "C (gcc -O0)",mob2.c,0.004511,0.004565,0.00453033333333333 5 | "C (gcc -O2)",mob2.c,0.002739,0.002767,0.00274933333333333 6 | "C (gcc -Ofast)",mob2.c,0.002685,0.002705,0.00269266666666667 7 | "C (gcc -O0)",mob3.c,0.00543,0.005452,0.005439 8 | "C (gcc -Ofast)",mob3.c,0.002462,0.002559,0.00251333333333333 9 | "C (gcc -O2)",mob3.c,0.002706,0.002867,0.00277 10 | "C (gcc -O0)",mob.c,0.00788,0.008201,0.008016 11 | "C (gcc -Ofast)",mob.c,0.005949,0.006132,0.006038 12 | "C (gcc -O2)",mob.c,0.005951,0.006055,0.00601433333333333 13 | "Go (go)",mob2.go,0.032674,0.033158,0.0328806666666667 14 | -------------------------------------------------------------------------------- /Compiled/array-reverse/rev.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "strconv" 7 | ) 8 | 9 | func reverseArray(l []int) { 10 | for i := 0; i < (len(l) >> 1); i++ { 11 | lastIdx := len(l) - i - 1 12 | l[lastIdx], l[i] = l[i], l[lastIdx] 13 | } 14 | } 15 | 16 | func main() { 17 | if len(os.Args) != 3 { 18 | fmt.Fprintln(os.Stderr, "Usage: array-reverse ") 19 | os.Exit(1) 20 | } 21 | 22 | count, _ := strconv.Atoi(os.Args[1]) 23 | iterations, _ := strconv.Atoi(os.Args[2]) 24 | 25 | array := make([]int, count) 26 | for i := 0; i < count; i++ { 27 | array[i] = i 28 | } 29 | 30 | for i := 0; i < iterations; i++ { 31 | reverseArray(array) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.exs: -------------------------------------------------------------------------------- 1 | defmodule Levenshtein do 2 | def first_letter_check(one_letter, two_letter) do 3 | case one_letter == two_letter do 4 | true -> 0 5 | false -> 1 6 | end 7 | end 8 | 9 | def distance(string_1, string_1), do: 0 10 | def distance(string, ''), do: :string.len(string) 11 | def distance('', string), do: :string.len(string) 12 | def distance([h1|rest1], [h2|rest2]) do 13 | cost = first_letter_check(h1, h2) 14 | 15 | :lists.min([ 16 | distance(rest1, [h2|rest2]) + 1, 17 | distance([h1|rest1], rest2) + 1, 18 | distance(rest1, rest2) + cost 19 | ]) 20 | end 21 | end 22 | 23 | [s | tail] = System.argv 24 | [t | _] = tail 25 | 26 | s = s |> to_charlist 27 | t = t |> to_charlist 28 | 29 | IO.puts Levenshtein.distance(s, t); 30 | -------------------------------------------------------------------------------- /Compiled/array-reverse/rev.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void reverseArray(int * theList, int count) { 5 | for (int i = 0; i < count >> 1; i++) { 6 | int lastIdx = count - i - 1; 7 | int lastValue = theList[lastIdx]; 8 | theList[lastIdx] = theList[i]; 9 | theList[i] = lastValue; 10 | } 11 | } 12 | 13 | int main(int argc, const char * argv[]) { 14 | if (argc != 3) { 15 | fprintf(stderr, "Usage: array-reverse \n"); 16 | return 1; 17 | } 18 | 19 | int count = atoi(argv[1]); 20 | int iterations = atoi(argv[2]); 21 | 22 | int * array = malloc(sizeof(int) * count); 23 | for (int i = 0; i < count; i++) { 24 | array[i] = i; 25 | } 26 | 27 | for (int i = 0; i < iterations; i++) { 28 | reverseArray(array, count); 29 | } 30 | 31 | free(array); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /Reports/Interpreted/coin-sums 0 250.csv: -------------------------------------------------------------------------------- 1 | language,file,load_time,time_min,time_max,time_avg 2 | LuaJIT 2.0.5,csum.lua,0,0.943415,0.96638,0.953252666666667 3 | Julia 0.6.0,csum.jl,0,1.121647,1.138813,1.12756666666667 4 | PyPy 5.8.0,csum.py,0,1.199566,1.247784,1.222191 5 | PHP 7.1.9,csum.php,0,2.204736,2.233374,2.219356 6 | Crystal 0.23.1,csum.cr,0,2.204122,2.275234,2.23989266666667 7 | Scala 2.12.3,csum.sc,0,3.522936,3.969891,3.73228833333333 8 | Python 3.6.2,csum.py,0,4.841316,5.012906,4.93194533333333 9 | Python 2.7.14,csum.py,0,5.017473,5.106227,5.057483 10 | Mawk 1.3.4,csum.awk,0,5.98821,5.992055,5.98988133333333 11 | Ruby 2.4.2,csum.rb,0,6.194344,6.323258,6.27081966666667 12 | Perl 5.26.1,csum.pl,0,7.030063,7.137051,7.10025733333333 13 | Lua 5.3.4,csum.lua,0,7.173901,7.270687,7.22468966666667 14 | JRuby 9.1.12,csum.rb,0,7.439618,7.767628,7.62494166666667 15 | Pike 8.0.438,csum.pike,0,9.911434,10.216829,10.0814566666667 16 | Gawk 4.1.4,csum.awk,0,13.341185,13.469059,13.4084 17 | -------------------------------------------------------------------------------- /Reports/Compiled/man-or-boy 15.csv: -------------------------------------------------------------------------------- 1 | language,file,time_min,time_max,time_avg 2 | "C++ (g++ -O2)",mob2.cpp,5.615563,5.663022,5.64448 3 | "Go (go)",mob.go,0.017163,0.017737,0.017458 4 | "C (gcc -O0)",mob.c,0.00413,0.004226,0.00419333333333333 5 | "C (gcc -Ofast)",mob.c,0.003234,0.003241,0.00323733333333333 6 | "C (gcc -O2)",mob.c,0.003197,0.003245,0.00322166666666667 7 | "C++ (g++ -Ofast)",mob.cpp,1.563152,1.575926,1.567669 8 | "C++ (g++ -O0)",mob.cpp,4.510254,4.517279,4.514192 9 | "C++ (g++ -O2)",mob.cpp,1.671606,1.685594,1.6775 10 | "C (gcc -O0)",mob3.c,0.002747,0.002783,0.00276533333333333 11 | "C (gcc -O2)",mob3.c,0.001675,0.001719,0.00169766666666667 12 | "C (gcc -Ofast)",mob3.c,0.001578,0.001656,0.00160966666666667 13 | "C (gcc -O0)",mob2.c,0.002586,0.002623,0.00261 14 | "C (gcc -O2)",mob2.c,0.001704,0.001726,0.001715 15 | "C (gcc -Ofast)",mob2.c,0.001654,0.001741,0.00168733333333333 16 | "OCaml (ocamlopt)",mob.ml,0.00161,0.001735,0.00166033333333333 17 | "Go (go)",mob2.go,0.016551,0.016865,0.0167026666666667 18 | -------------------------------------------------------------------------------- /Reports/Interpreted/man-or-boy 12.csv: -------------------------------------------------------------------------------- 1 | language,file,load_time,time_min,time_max,time_avg 2 | LuaJIT 2.0.5,mob.lua,0,0.002844,0.003157,0.002977666666667 3 | Lua 5.3.4,mob.lua,0,0.004243,0.006667,0.005244666666667 4 | Perl 5.26.1,mob.pl,0,0.008744,0.010305,0.009373 5 | PHP 7.1.9,mob.php,0,0.014253,0.016052,0.014901333333333 6 | mRuby 1.3.0,mob.mrb,0,0.014583,0.015739,0.015227666666667 7 | Tcl 8.6.7,mob.tcl,0,0.018442,0.02047,0.019173666666667 8 | Python 2.7.14,mob.py,0,0.019901,0.020522,0.020245333333333 9 | OCaml 4.05.0,mob.ml,0,0.022416,0.023097,0.022790666666667 10 | Python 3.6.2,mob.py,0,0.029397,0.030969,0.030017 11 | Ruby 2.4.2,mob.rb,0,0.043909,0.047325,0.045440333333333 12 | PyPy 5.8.0,mob.py,0,0.138977,0.140227,0.139471 13 | Rakudo 2017.09,mob.pl6,0,0.190855,0.197136,0.193055 14 | Crystal 0.23.1,mob.cr,0,0.562839,0.582261,0.571567333333333 15 | Julia 0.6.0,mob.jl,0,0.574199,0.575367,0.57491 16 | Clojure 1.8.0,mob.clj,0,0.835705,0.893875,0.870777666666667 17 | Scala 2.12.3,mob.sc,0,1.140119,1.173235,1.157877 18 | -------------------------------------------------------------------------------- /Reports/Interpreted/lev-distance-recursive rosettacode raisethysword.csv: -------------------------------------------------------------------------------- 1 | language,file,load_time,time_min,time_max,time_avg 2 | LuaJIT 2.0.5,lev.lua,0,0.24178,0.242359,0.242156333333333 3 | Julia 0.6.0,lev.jl,0,0.768694,0.787576,0.776607666666667 4 | PyPy 5.8.0,lev.py,0,0.858463,0.87839,0.868685333333333 5 | PHP 7.1.9,lev.php,0,1.355831,1.385751,1.36967566666667 6 | Mawk 1.3.4,lev.awk,0,1.869657,1.911328,1.896051 7 | OCaml 4.05.0,lev.ml,0,1.928611,1.967399,1.94162733333333 8 | Crystal 0.23.1,lev.cr,0,1.929977,1.993144,1.970693 9 | Groovy 2.4.12,lev.gvy,0,2.04317,2.239777,2.14203066666667 10 | Ruby 2.4.2,lev.rb,0,2.532446,2.551706,2.54268766666667 11 | Lua 5.3.4,lev.lua,0,2.597618,2.622566,2.61143166666667 12 | Python 2.7.14,lev.py,0,2.65753,2.702434,2.67374966666667 13 | Scala 2.12.3,lev.sc,0,3.001837,3.037136,3.016578 14 | Python 3.6.2,lev.py,0,3.542646,3.607826,3.57503966666667 15 | JRuby 9.1.12,lev.rb,0,3.79608,4.232895,4.013781 16 | Perl 5.26.1,lev.pl,0,4.340322,4.394633,4.36262366666667 17 | Pike 8.0.438,lev.pike,0,4.36913,4.531802,4.43998733333333 18 | Gawk 4.1.4,lev.awk,0,5.174292,5.213033,5.198645 19 | -------------------------------------------------------------------------------- /Reports/Interpreted/lcs-recursive thisisatest testing123testingtrizen.csv: -------------------------------------------------------------------------------- 1 | language,file,load_time,time_min,time_max,time_avg 2 | LuaJIT 2.0.5,lcs.lua,0,0.2275,0.229506,0.228219333333333 3 | PyPy 5.8.0,lcs.py,0,0.512402,0.513653,0.513047333333333 4 | Julia 0.6.0,lcs.jl,0,1.008598,1.022032,1.017156 5 | PHP 7.1.9,lcs.php,0,1.307021,1.337889,1.322207 6 | Scala 2.12.3,lcs.sc,0,1.333456,1.373008,1.35236266666667 7 | Groovy 2.4.12,lcs.gvy,0,1.692509,1.71704,1.70362666666667 8 | Mawk 1.3.4,lcs.awk,0,2.022283,2.063685,2.04181466666667 9 | Crystal 0.23.1,lcs.cr,0,1.857947,2.429093,2.04912033333333 10 | Python 2.7.14,lcs.py,0,2.410372,2.488097,2.437555 11 | Lua 5.3.4,lcs.lua,0,2.716956,2.75494,2.74099333333333 12 | Python 3.6.2,lcs.py,0,3.046179,3.066485,3.05968 13 | Ruby 2.4.2,lcs.rb,0,2.999235,3.314004,3.12278333333333 14 | JRuby 9.1.12,lcs.rb,0,3.717222,4.167659,3.88650733333333 15 | Clojure 1.8.0,lcs.clj,0,4.888963,4.988947,4.928205 16 | Pike 8.0.438,lcs.pike,0,4.879621,5.03528,4.952137 17 | Perl 5.26.1,lcs.pl,0,5.180633,5.215771,5.19936333333333 18 | Tcl 8.6.7,lcs.tcl,0,5.195886,5.234574,5.20903466666667 19 | Gawk 4.1.4,lcs.awk,0,5.797635,5.922995,5.839775 20 | -------------------------------------------------------------------------------- /update_names.sf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sidef 2 | 3 | # Change the names of the interpreters inside the generated reports. 4 | 5 | var replaces = Hash( 6 | 'Elixir' => 'Elixir 1.5.1', 7 | 'Julia' => 'Julia 0.6.0', 8 | 'OCaml' => 'OCaml 4.05.0', 9 | 'Groovy' => 'Groovy 2.4.12', 10 | 'LuaJIT' => 'LuaJIT 2.0.5', 11 | 'PyPy' => 'PyPy 5.8.0', 12 | 'Crystal' => 'Crystal 0.23.1', 13 | 'Scala' => 'Scala 2.12.3', 14 | 'PHP' => 'PHP 7.1.9', 15 | 'Python 2' => 'Python 2.7.14', 16 | 'Python 3' => 'Python 3.6.2', 17 | 'JRuby' => 'JRuby 9.1.12', 18 | 'mRuby' => 'mRuby 1.3.0', 19 | 'AWK (mawk)', 'Mawk 1.3.4', 20 | 'Perl6 MoarVM' => 'Rakudo 2017.09', 21 | 'Ruby' => 'Ruby 2.4.2', 22 | 'Lua' => 'Lua 5.3.4', 23 | 'Perl' => 'Perl 5.26.1', 24 | 'AWK (gawk)' => 'Gawk 4.1.4', 25 | 'Clojure' => 'Clojure 1.8.0', 26 | 'Tcl' => 'Tcl 8.6.7', 27 | 'Pike' => 'Pike 8.0.438', 28 | ) 29 | 30 | glob("Reports/Interpreted/*").each { |file| 31 | file ~~ /\.csv\z/ || next 32 | File(file).edit { |line| 33 | replaces.each_kv { |key, value| 34 | line.sub!(Regex('^"?\K' + key.escape + '(?="?,)', 'i'), value) 35 | } 36 | line 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Compiled/compilers.txt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | [ 4 | { 5 | name => 'C (gcc -O0)', 6 | cmd => ['gcc', '--std=c99', '-march=native', '-O0', '-o', '%out%', '%in%'], 7 | ext => ['c'], 8 | }, 9 | 10 | { 11 | name => 'C (gcc -O2)', 12 | cmd => ['gcc', '--std=c99', '-march=native', '-O2', '-o', '%out%', '%in%'], 13 | ext => ['c'], 14 | }, 15 | 16 | { 17 | name => 'C (gcc -Ofast)', 18 | cmd => ['gcc', '--std=c99', '-march=native', '-Ofast', '-o', '%out%', '%in%'], 19 | ext => ['c'], 20 | }, 21 | 22 | { 23 | name => 'C++ (g++ -O0)', 24 | cmd => ['g++', '--std=c++11', '-march=native', '-O0', '-o', '%out%', '%in%'], 25 | ext => ['cpp'], 26 | }, 27 | 28 | { 29 | name => 'C++ (g++ -O2)', 30 | cmd => ['g++', '--std=c++11', '-march=native', '-O2', '-o', '%out%', '%in%'], 31 | ext => ['cpp'], 32 | }, 33 | 34 | { 35 | name => 'C++ (g++ -Ofast)', 36 | cmd => ['g++', '--std=c++11', '-march=native', '-Ofast', '-o', '%out%', '%in%'], 37 | ext => ['cpp'], 38 | }, 39 | 40 | { 41 | name => 'Go (go)', 42 | cmd => ['go', 'build', '-o', '%out%', '%in%'], 43 | ext => ['go'], 44 | }, 45 | 46 | { 47 | name => 'OCaml (ocamlopt)', 48 | cmd => ['ocamlopt', '-o', '%out%', '%in%'], 49 | ext => ['ml'], 50 | }, 51 | 52 | ] 53 | -------------------------------------------------------------------------------- /Interpreted/lev-distance-recursive/lev.awk: -------------------------------------------------------------------------------- 1 | 2 | BEGIN { 3 | a = ARGV[1]; 4 | b = ARGV[2]; 5 | print levenshteinDistance(a, b); 6 | } 7 | 8 | function levenshteinDistance(s, t, s1, t1, distA, distB, distC, minDist) { 9 | 10 | # If either string is empty, 11 | # then distance is insertion of the other's characters. 12 | if (length(s) == 0) return length(t); 13 | if (length(t) == 0) return length(s); 14 | 15 | # Rest of process uses first characters 16 | # and remainder of each string. 17 | s1 = substr(s, 2, length(s)); 18 | t1 = substr(t, 2, length(t)); 19 | 20 | # If leading characters are the same, 21 | # then distance is that between the rest of the strings. 22 | if (substr(s, 1, 1) == substr(t, 1, 1)) { 23 | return levenshteinDistance(s1, t1); 24 | } 25 | 26 | # Find the distances between sub strings. 27 | distA = levenshteinDistance(s1, t1); 28 | distB = levenshteinDistance(s, t1); 29 | distC = levenshteinDistance(s1, t ); 30 | 31 | # Return the minimum distance between substrings. 32 | minDist = distA; 33 | if (distB < minDist) minDist = distB; 34 | if (distC < minDist) minDist = distC; 35 | return minDist + 1; # Include change for the first character. 36 | } 37 | -------------------------------------------------------------------------------- /Reports/Interpreted/fibonacci-recursive 35.csv: -------------------------------------------------------------------------------- 1 | language,file,load_time,time_min,time_max,time_avg 2 | LuaJIT 2.0.5,fib.lua,0,0.192539,0.194584,0.193556666666667 3 | Julia 0.6.0,fib.jl,0,0.358003,0.361345,0.360108333333333 4 | PyPy 5.8.0,fib.py,0,0.411485,0.426291,0.417603666666667 5 | OCaml 4.05.0,fib.ml,0,0.431009,0.452374,0.438348333333333 6 | Crystal 0.23.1,fib.cr,0,0.656881,0.668832,0.662744666666667 7 | Elixir 1.5.1,fib.exs,0,0.92486,0.930281,0.928220666666667 8 | PHP 7.1.9,fib.php,0,1.111888,1.137481,1.123851 9 | Clojure 1.8.0,fib.clj,0,1.113863,1.159771,1.139616 10 | Scala 2.12.3,fib.sc,0,1.162404,1.256648,1.204198 11 | Ruby 2.4.2,fib.rb,0,1.256471,1.296622,1.27937166666667 12 | Mawk 1.3.4,fib.awk,0,1.295869,1.311602,1.30501433333333 13 | Groovy 2.4.12,fib.gvy,0,1.335179,1.350486,1.34198566666667 14 | Lua 5.3.4,fib.lua,0,1.757264,1.818564,1.79492233333333 15 | JRuby 9.1.12,fib.rb,0,3.064552,3.353803,3.18329866666667 16 | Python 2.7.14,fib.py,0,3.444807,3.52375,3.490034 17 | Gawk 4.1.4,fib.awk,0,3.6456,3.650238,3.64836066666667 18 | Python 3.6.2,fib.py,0,3.988464,4.267336,4.09467433333333 19 | Perl 5.26.1,fib.pl,0,4.988508,5.040266,5.01812766666667 20 | Pike 8.0.438,fib.pike,0,5.468513,5.481652,5.476207 21 | mRuby 1.3.0,fib.mrb,0,6.517395,6.661495,6.57141166666667 22 | -------------------------------------------------------------------------------- /Reports/Interpreted/ackermann-function 3 9.csv: -------------------------------------------------------------------------------- 1 | language,file,load_time,time_min,time_max,time_avg 2 | LuaJIT 2.0.5,ack.lua,0,0.04323,0.054702,0.047059666666667 3 | OCaml 4.05.0,ack.ml,0,0.160414,0.161986,0.161070333333333 4 | Julia 0.6.0,ack.jl,0,0.343975,0.345806,0.344643333333333 5 | PHP 7.1.9,ack.php,0,0.443664,0.451341,0.448660666666667 6 | Lua 5.3.4,ack.lua,0,0.586311,0.615727,0.597851 7 | Ruby 2.4.2,ack.rb,0,0.594626,0.633779,0.608116333333333 8 | Elixir 1.5.1,ack.exs,0,0.611047,0.654021,0.629091 9 | Mawk 1.3.4,ack.awk,0,0.668727,0.671823,0.670161333333333 10 | Crystal 0.23.1,ack.cr,0,0.618846,1.253798,0.845774666666667 11 | Clojure 1.8.0,ack.clj,0,1.000451,1.08735,1.03014033333333 12 | PyPy 5.8.0,ack.py,0,1.02195,1.04869,1.03767633333333 13 | Groovy 2.4.12,ack.gvy,0,1.153963,1.163969,1.15814166666667 14 | Scala 2.12.3,ack.sc,0,1.152734,1.191747,1.17622366666667 15 | Gawk 4.1.4,ack.awk,0,2.015209,2.025598,2.018702 16 | Pike 8.0.438,ack.pike,0,2.481427,2.499324,2.490879 17 | Python 2.7.14,ack.py,0,2.648949,2.669742,2.66095933333333 18 | mRuby 1.3.0,ack.mrb,0,2.770472,2.801397,2.789678 19 | JRuby 9.1.12,ack.rb,0,3.018393,3.018393,3.018393 20 | Perl 5.26.1,ack.pl,0,3.139105,3.197075,3.16894266666667 21 | Python 3.6.2,ack.py,0,3.12177,3.223476,3.16917433333333 22 | Tcl 8.6.7,ack.tcl,0,3.847794,4.005135,3.90330933333333 23 | -------------------------------------------------------------------------------- /Reports/Interpreted/mutual-recursion 130.csv: -------------------------------------------------------------------------------- 1 | language,file,load_time,time_min,time_max,time_avg 2 | LuaJIT 2.0.5,mrec.lua,0,0.260644,0.260812,0.260737666666667 3 | Julia 0.6.0,mrec.jl,0,0.377956,0.378952,0.378525666666667 4 | OCaml 4.05.0,mrec.ml,0,0.643447,0.648292,0.645306666666667 5 | Crystal 0.23.1,mrec.cr,0,0.83355,0.898308,0.873575333333333 6 | Elixir 1.5.1,mrec.exs,0,1.011409,1.038099,1.02753033333333 7 | Scala 2.12.3,mrec.sc,0,1.178223,1.223781,1.208373 8 | Clojure 1.8.0,mrec.clj,0,1.181198,1.280726,1.23123633333333 9 | PHP 7.1.9,mrec.php,0,1.484316,1.492612,1.48958066666667 10 | Groovy 2.4.12,mrec.gvy,0,1.716096,1.759919,1.73121433333333 11 | PyPy 5.8.0,mrec.py,0,1.750799,1.788169,1.77327566666667 12 | Mawk 1.3.4,mrec.awk,0,1.988114,2.01849,2.00576733333333 13 | Ruby 2.4.2,mrec.rb,0,1.996922,2.059699,2.02406033333333 14 | Lua 5.3.4,mrec.lua,0,2.472873,2.599346,2.549713 15 | JRuby 9.1.12,mrec.rb,0,3.224504,3.51104,3.33311633333333 16 | Python 2.7.14,mrec.py,0,5.100861,5.130893,5.115713 17 | Gawk 4.1.4,mrec.awk,0,5.346207,5.36221,5.351645 18 | Python 3.6.2,mrec.py,0,5.906175,6.085459,5.96988166666667 19 | Perl 5.26.1,mrec.pl,0,8.923228,8.998843,8.94934533333333 20 | Pike 8.0.438,mrec.pike,0,9.457853,9.579186,9.53739266666667 21 | mRuby 1.3.0,mrec.mrb,0,10.216957,10.832159,10.560208 22 | Tcl 8.6.7,mrec.tcl,0,13.982075,14.127575,14.069283 23 | -------------------------------------------------------------------------------- /Reports/Interpreted/tak-function 30 22 12.csv: -------------------------------------------------------------------------------- 1 | language,file,load_time,time_min,time_max,time_avg 2 | LuaJIT 2.0.5,tak.lua,0,0.14611,0.14624,0.146184666666667 3 | Julia 0.6.0,tak.jl,0,0.404671,0.415545,0.409584666666667 4 | Crystal 0.23.1,tak.cr,0,0.639743,0.687683,0.657442666666667 5 | OCaml 4.05.0,tak.ml,0,0.668132,0.694523,0.681859 6 | Elixir 1.5.1,tak.exs,0,0.974229,0.999244,0.983816666666667 7 | Scala 2.12.3,tak.sc,0,1.163486,1.211361,1.18016766666667 8 | Clojure 1.8.0,tak.clj,0,1.228158,1.476175,1.316481 9 | Groovy 2.4.12,tak.gvy,0,1.550353,1.625802,1.58856966666667 10 | PyPy 5.8.0,tak.py,0,1.685369,1.68883,1.687314 11 | Ruby 2.4.2,tak.rb,0,1.753466,1.790296,1.77127866666667 12 | PHP 7.1.9,tak.php,0,1.933389,1.97664,1.94974133333333 13 | Lua 5.3.4,tak.lua,0,2.252242,2.289415,2.27645466666667 14 | Mawk 1.3.4,tak.awk,0,2.91558,2.969461,2.93577966666667 15 | JRuby 9.1.12,tak.rb,0,3.038085,3.257484,3.13118733333333 16 | Python 2.7.14,tak.py,0,4.585764,4.745255,4.65581466666667 17 | Python 3.6.2,tak.py,0,5.253524,5.378415,5.29803566666667 18 | Gawk 4.1.4,tak.awk,0,5.956637,6.081141,5.99855333333333 19 | Pike 8.0.438,tak.pike,0,7.296467,7.494473,7.39868966666667 20 | mRuby 1.3.0,tak.mrb,0,8.487449,8.669071,8.58115433333333 21 | Perl 5.26.1,tak.pl,0,11.744379,11.922505,11.8584506666667 22 | Tcl 8.6.7,tak.tcl,0,12.12067,12.394767,12.2396086666667 23 | -------------------------------------------------------------------------------- /Reports/create_final_report.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Creates an overview report, given a directory of CSV files. 4 | 5 | use 5.010; 6 | use strict; 7 | use autodie; 8 | use warnings; 9 | 10 | use Text::CSV; 11 | use List::Util qw(uniq); 12 | use File::Basename qw(basename); 13 | 14 | my $csv = Text::CSV->new( 15 | { 16 | binary => 1, 17 | allow_whitespace => 1, 18 | empty_is_undef => 1, 19 | blank_is_undef => 1, 20 | eol => "\n", 21 | } 22 | ) 23 | or die "Cannot use CSV: " . Text::CSV->error_diag(); 24 | 25 | my $dir = shift(@ARGV) || die "usage: $0 [dir]\n"; 26 | 27 | my %report; 28 | 29 | foreach my $csv_file (glob("$dir/*.csv")) { 30 | 31 | my $basename = basename($csv_file); 32 | open my $fh, '<:utf8', $csv_file; 33 | 34 | $csv->column_names(@{$csv->getline($fh)}); 35 | 36 | while (my $row = $csv->getline_hr($fh)) { 37 | $report{$row->{language}}{$basename} = $row->{time_avg}; 38 | } 39 | } 40 | 41 | my @langs = sort { lc($a) cmp lc($b) } keys %report; 42 | my @tasks = sort { lc($a) cmp lc($b) } uniq(map { keys %{$report{$_}} } @langs); 43 | 44 | open my $fh, '>:utf8', 'overview.csv'; 45 | 46 | $csv->print($fh, ['', @tasks]); 47 | 48 | foreach my $lang (@langs) { 49 | $csv->print($fh, [$lang, map { $report{$lang}{$_} } @tasks]); 50 | } 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Performance comparison of programming languages 2 | 3 | A simple benchmark system with support for compiled and interpreted languages, generating CSV reports. 4 | 5 | ### Overview 6 | ![Overview](https://raw.githubusercontent.com/trizen/language-benchmarks/master/Stats/Interpreted/all.png) 7 | 8 | ### Ackermann function (`ack(3,9)`) 9 | ![Ackermann recursive](https://raw.githubusercontent.com/trizen/language-benchmarks/master/Stats/Interpreted/ack-function-3-9.png) 10 | 11 | ### Tak function (`tak(30,22,12)`) 12 | ![Tak function](https://raw.githubusercontent.com/trizen/language-benchmarks/master/Stats/Interpreted/tak-30-22-12.png) 13 | 14 | ### 35th Fibonacci number (recursive) 15 | ![Fibonacci recursive](https://raw.githubusercontent.com/trizen/language-benchmarks/master/Stats/Interpreted/fibonacci-35.png) 16 | 17 | ### Mutual recursion (`F(130); M(130)`) 18 | ![Mutual recursion](https://raw.githubusercontent.com/trizen/language-benchmarks/master/Stats/Interpreted/mutual-recursion-130.png) 19 | 20 | ### Levenshtein distance (recursive) 21 | ![Levenshtein Distance](https://raw.githubusercontent.com/trizen/language-benchmarks/master/Stats/Interpreted/lev-distance.png) 22 | 23 | ### The LCS problem (recursive) 24 | ![LCS](https://raw.githubusercontent.com/trizen/language-benchmarks/master/Stats/Interpreted/lcs-test.png) 25 | 26 | ### Coin sums (recursive) 27 | ![Coin sums](https://raw.githubusercontent.com/trizen/language-benchmarks/master/Stats/Interpreted/coin-sums-0-250.png) 28 | 29 | ### Man or boy (`mob(12)`) 30 | ![Man or boy](https://raw.githubusercontent.com/trizen/language-benchmarks/master/Stats/Interpreted/man-or-boy-12.png) 31 | 32 | _The y-axis is measuring the average execution time of a process, in seconds. Lower values are better._ 33 | -------------------------------------------------------------------------------- /Reports/overview.csv: -------------------------------------------------------------------------------- 1 | ,Ackermann,Coin sums,Fibonacci,LCS,Levenshtein,Mutual recursion,Tak 2 | Clojure 1.8.0,1.03014033333333,,1.139616,4.928205,,1.23123633333333,1.316481 3 | Crystal 0.23.1,0.845774666666667,2.23989266666667,0.662744666666667,2.04912033333333,1.970693,0.873575333333333,0.657442666666667 4 | Elixir 1.5.1,0.629091,,0.928220666666667,,,1.02753033333333,0.983816666666667 5 | Gawk 4.1.4,2.018702,13.4084,3.64836066666667,5.839775,5.198645,5.351645,5.99855333333333 6 | Groovy 2.4.12,1.15814166666667,,1.34198566666667,1.70362666666667,2.14203066666667,1.73121433333333,1.58856966666667 7 | JRuby 9.1.12,3.018393,7.62494166666667,3.18329866666667,3.88650733333333,4.013781,3.33311633333333,3.13118733333333 8 | Julia 0.6.0,0.344643333333333,1.12756666666667,0.360108333333333,1.017156,0.776607666666667,0.378525666666667,0.409584666666667 9 | Lua 5.3.4,0.597851,7.22468966666667,1.79492233333333,2.74099333333333,2.61143166666667,2.549713,2.27645466666667 10 | LuaJIT 2.0.5,0.047059666666667,0.953252666666667,0.193556666666667,0.228219333333333,0.242156333333333,0.260737666666667,0.146184666666667 11 | Mawk 1.3.4,0.670161333333333,5.98988133333333,1.30501433333333,2.04181466666667,1.896051,2.00576733333333,2.93577966666667 12 | mRuby 1.3.0,2.789678,,6.57141166666667,,,10.560208,8.58115433333333 13 | OCaml 4.05.0,0.161070333333333,,0.438348333333333,,1.94162733333333,0.645306666666667,0.681859 14 | Perl 5.26.1,3.16894266666667,7.10025733333333,5.01812766666667,5.19936333333333,4.36262366666667,8.94934533333333,11.8584506666667 15 | PHP 7.1.9,0.448660666666667,2.219356,1.123851,1.322207,1.36967566666667,1.48958066666667,1.94974133333333 16 | Pike 8.0.438,2.490879,10.0814566666667,5.476207,4.952137,4.43998733333333,9.53739266666667,7.39868966666667 17 | PyPy 5.8.0,1.03767633333333,1.222191,0.417603666666667,0.513047333333333,0.868685333333333,1.77327566666667,1.687314 18 | Python 2.7.14,2.66095933333333,5.057483,3.490034,2.437555,2.67374966666667,5.115713,4.65581466666667 19 | Python 3.6.2,3.16917433333333,4.93194533333333,4.09467433333333,3.05968,3.57503966666667,5.96988166666667,5.29803566666667 20 | Ruby 2.4.2,0.608116333333333,6.27081966666667,1.27937166666667,3.12278333333333,2.54268766666667,2.02406033333333,1.77127866666667 21 | Scala 2.12.3,1.17622366666667,3.73228833333333,1.204198,1.35236266666667,3.016578,1.208373,1.18016766666667 22 | Tcl 8.6.7,3.90330933333333,,,5.20903466666667,,14.069283,12.2396086666667 23 | -------------------------------------------------------------------------------- /Interpreted/interpreters.txt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | [ 4 | { 5 | name => 'Ruby', 6 | cmd => ['ruby', '%in%'], 7 | ext => ['rb'], 8 | }, 9 | 10 | { 11 | name => 'mRuby', 12 | cmd => ['mruby', '%in%'], 13 | ext => ['mrb'], 14 | }, 15 | 16 | { 17 | name => 'Perl', 18 | cmd => ['perl', '%in%'], 19 | ext => ['pl'], 20 | }, 21 | 22 | { 23 | name => 'Pike', 24 | cmd => ['pike', '%in%'], 25 | ext => ['pike'], 26 | }, 27 | 28 | { 29 | name => 'Python 2', 30 | cmd => ['python2', '%in%'], 31 | ext => ['py', 'py2'], 32 | }, 33 | 34 | { 35 | name => 'Python 3', 36 | cmd => ['python3', '%in%'], 37 | ext => ['py', 'py3'], 38 | }, 39 | 40 | { 41 | name => 'PyPy', 42 | cmd => ['pypy', '%in%'], 43 | ext => ['py', 'pypy'], 44 | }, 45 | 46 | { 47 | name => 'Lua', 48 | cmd => ['lua', '%in%'], 49 | ext => ['lua'], 50 | }, 51 | 52 | { 53 | name => 'LuaJIT', 54 | cmd => ['luajit', '%in%'], 55 | ext => ['lua'], 56 | }, 57 | 58 | { 59 | name => 'AWK (gawk)', 60 | cmd => ['gawk', '-f', '%in%'], 61 | ext => ['awk', 'gawk'], 62 | }, 63 | 64 | { 65 | name => 'AWK (nawk)', 66 | cmd => ['nawk', '-f', '%in%'], 67 | ext => ['awk', 'nawk'], 68 | }, 69 | 70 | { 71 | name => 'AWK (mawk)', 72 | cmd => ['mawk', '-f', '%in%'], 73 | ext => ['awk', 'mawk'], 74 | }, 75 | 76 | { 77 | name => 'OCaml', 78 | cmd => ['ocaml', '%in%'], 79 | ext => ['ml', 'ocaml'], 80 | }, 81 | 82 | { 83 | name => 'Scala', 84 | cmd => ['scala', '%in%'], 85 | ext => ['sc', 'scala'], 86 | }, 87 | 88 | { 89 | name => 'Brat', 90 | cmd => ['brat', '%in%'], 91 | ext => ['brat'], 92 | }, 93 | 94 | { 95 | name => 'Tcl', 96 | cmd => ['tclsh', '%in%'], 97 | ext => ['tcl'], 98 | }, 99 | 100 | { 101 | name => 'Julia', 102 | cmd => ['julia', '%in%'], 103 | ext => ['jl', 'julia'], 104 | }, 105 | 106 | { 107 | name => 'PHP', 108 | cmd => ['php', '%in%'], 109 | ext => ['php'], 110 | }, 111 | 112 | { 113 | name => 'Perl6 MoarVM', 114 | cmd => ['perl6-m', '%in%'], 115 | ext => ['p6', 'pl6'], 116 | }, 117 | 118 | { 119 | name => 'Groovy', 120 | cmd => ['groovy', '%in%'], 121 | ext => ['gvy', 'groovy', 'gy'], 122 | }, 123 | 124 | { 125 | name => 'Elixir', 126 | cmd => ['elixir', '%in%'], 127 | ext => ['ex', 'exs'], 128 | }, 129 | 130 | { 131 | name => 'Clojure', 132 | cmd => ['clojure', '%in%'], 133 | ext => ['clj'], 134 | }, 135 | 136 | { 137 | name => 'Crystal', 138 | cmd => ['crystal', '%in%', '--'], 139 | ext => ['cr'], 140 | }, 141 | 142 | { 143 | name => 'JRuby', 144 | cmd => ['jruby', '%in%'], 145 | ext => ['rb'], 146 | }, 147 | ] 148 | -------------------------------------------------------------------------------- /benchmark.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Author: Daniel "Trizen" Șuteu 4 | # License: GPLv3 5 | # Date: 14 February 2015 6 | # Edit: 15 February 2015 7 | # Website: http://github.com/trizen 8 | 9 | # Speed comparison of common programming languages. 10 | # The results are stored in separate CSV files for each test. 11 | 12 | use 5.014; 13 | use strict; 14 | use autodie; 15 | use warnings; 16 | 17 | use Text::CSV qw(); 18 | use Text::ParseWords qw(quotewords); 19 | 20 | use File::Path qw(make_path); 21 | use File::Temp qw(mktemp tempfile tempdir); 22 | use File::Basename qw(basename); 23 | use File::Spec::Functions qw(rel2abs catfile catdir tmpdir curdir updir); 24 | 25 | use List::Util qw(min max sum); 26 | use Getopt::Long qw(GetOptions); 27 | use Time::HiRes qw(gettimeofday tv_interval); 28 | 29 | # The main directories which contain sub-directories with source files 30 | my $compiled_langs_dir = 'Compiled'; 31 | my $interpreted_langs_dir = 'Interpreted'; 32 | 33 | # The test specific files 34 | my $arguments_file = 'args.txt'; 35 | my $ignore_file = 'ignore.txt'; 36 | 37 | # The directories where the reports are written 38 | my $reports_dir = 'Reports'; 39 | my $compiled_reports_dir = catdir($reports_dir, 'Compiled'); 40 | my $interpreted_reports_dir = catdir($reports_dir, 'Interpreted'); 41 | 42 | # The compilers and interpreters definitions 43 | my $compilers = do(rel2abs(catfile($compiled_langs_dir, 'compilers.txt'))); 44 | my $interpreters = do(rel2abs(catfile($interpreted_langs_dir, 'interpreters.txt'))); 45 | 46 | # Flags 47 | my $test_compiled = 0; 48 | my $test_interpreted = 0; 49 | my $repeat_n = 3; 50 | my $test_loadtime = 0; 51 | my $test_name = ''; 52 | 53 | sub help { 54 | print <<"USAGE"; 55 | usage: $0 [options] 56 | 57 | options: 58 | -i : test interpreted languages 59 | -c : test compiled languages 60 | -t name : run only a specific test 61 | -r int : repeat each test this many times (default: $repeat_n) 62 | -l : time loadtime and subtract it from runtime (default: $test_loadtime) 63 | 64 | example: 65 | $0 -i -r 1 -t "fibonacci-recursive" 66 | 67 | USAGE 68 | 69 | exit; 70 | } 71 | 72 | GetOptions( 73 | 'i!' => \$test_interpreted, 74 | 'c!' => \$test_compiled, 75 | 'r=i' => \$repeat_n, 76 | 't=s' => \$test_name, 77 | 'l!' => \$test_loadtime, 78 | 'help|h' => \&help, 79 | ) 80 | or die("Error in command line arguments!"); 81 | 82 | sub create_cmd { 83 | my ($cmd, $in, $out) = @_; 84 | 85 | my @new_cmd; 86 | foreach my $field (@{$cmd}) { 87 | if (defined $in) { 88 | if ($field eq '%in' or $field eq '%in%') { 89 | push @new_cmd, $in; 90 | next; 91 | } 92 | } 93 | if (defined $out) { 94 | if ($field eq '%out' or $field eq '%out%') { 95 | push @new_cmd, $out; 96 | next; 97 | } 98 | } 99 | push @new_cmd, $field; 100 | } 101 | 102 | return @new_cmd; 103 | } 104 | 105 | sub get_dir_entries { 106 | my ($dirname) = @_; 107 | opendir(my $dir_h, $dirname); 108 | map { $_ => catfile($dirname, $_) } 109 | grep { $_ ne curdir() and $_ ne updir() } readdir($dir_h); 110 | } 111 | 112 | sub files_by_ext { 113 | my ($ext_array, $files_array) = @_; 114 | 115 | my @files; 116 | foreach my $file (@{$files_array}) { 117 | foreach my $ext (@{$ext_array}) { 118 | if ($file =~ /\.\Q$ext\E\z/i) { 119 | push @files, $file; 120 | last; 121 | } 122 | } 123 | } 124 | 125 | return @files; 126 | } 127 | 128 | sub get_arguments { 129 | my ($files_array) = @_; 130 | 131 | my @args; 132 | foreach my $file (@{$files_array}) { 133 | if (basename($file) eq $arguments_file) { 134 | open my $fh, '<:utf8', $file; 135 | push @args, quotewords(qr/\s+/, 0, unpack('A*', scalar(<$fh>))); 136 | last; 137 | } 138 | } 139 | 140 | return @args; 141 | } 142 | 143 | sub get_ignores { 144 | my ($files_array) = @_; 145 | 146 | my %ignore; 147 | foreach my $file (@{$files_array}) { 148 | if (basename($file) eq $ignore_file) { 149 | open my $fh, '<:utf8', $file; 150 | while (defined(my $line = <$fh>)) { 151 | $ignore{unpack 'A*', $line} = 1; 152 | } 153 | last; 154 | } 155 | } 156 | 157 | return %ignore; 158 | } 159 | 160 | sub map_files_to_dirs { 161 | my (%entries) = @_; 162 | 163 | my %files; 164 | while (my ($key, $dir) = each %entries) { 165 | if (-d $dir) { 166 | my %dir_entries = get_dir_entries($dir); 167 | my @files = map { $dir_entries{$_} } grep { -f $dir_entries{$_} } keys %dir_entries; 168 | @files ? (push @{$files{$key}}, @files) : (); 169 | } 170 | } 171 | 172 | return %files; 173 | } 174 | 175 | sub execute_cmd { 176 | system(@_) == 0; 177 | } 178 | 179 | sub time_cmd { 180 | my ($seconds, $microseconds) = gettimeofday(); 181 | execute_cmd(@_) || return -1; 182 | tv_interval([$seconds, $microseconds], [gettimeofday()]); 183 | } 184 | 185 | sub mMavg { 186 | (min(@_), max(@_), sum(@_) / @_); 187 | } 188 | 189 | sub write_report { 190 | my ($report_ref, $report_dir) = @_; 191 | 192 | my $csv = Text::CSV->new( 193 | { 194 | eol => "\n", 195 | binary => 1, 196 | sep_char => ',', 197 | } 198 | ) 199 | or die "Cannot use CSV: " . Text::CSV->error_diag(); 200 | 201 | my @columns = qw( 202 | language 203 | file 204 | load_time 205 | time_min 206 | time_max 207 | time_avg 208 | ); 209 | 210 | # Create the report directory (if needed) 211 | if (not -d $report_dir) { 212 | make_path($report_dir); 213 | } 214 | 215 | foreach my $name (keys %{$report_ref}) { 216 | my $csv_file = catfile($report_dir, $name . '.csv'); 217 | open my $fh, '>:encoding(UTF-8)', $csv_file; 218 | 219 | # Print the CSV columns 220 | $csv->print($fh, \@columns); 221 | 222 | while (my ($file, $langs) = each %{$report_ref->{$name}}) { 223 | while (my ($lang, $data) = each %{$langs}) { 224 | 225 | # Set the row values 226 | my %row = ( 227 | language => $lang, 228 | file => basename($file), 229 | ); 230 | 231 | my @time_keys = qw(load_time time_min time_max time_avg); 232 | @row{@time_keys} = @{$data}{@time_keys}; 233 | 234 | # Print the CSV row 235 | $csv->print($fh, [@row{@columns}]); 236 | } 237 | } 238 | 239 | close $fh; # close the report 240 | } 241 | 242 | return 1; 243 | } 244 | 245 | sub start_test { 246 | my ($languages_dir, $executors, $compile_bool) = @_; 247 | 248 | my %report; 249 | my %entries = get_dir_entries($languages_dir); 250 | my %files = map_files_to_dirs(%entries); 251 | 252 | my %tmpcache; 253 | my $tmpdir = tempdir(CLEANUP => 1); 254 | 255 | foreach my $name (sort keys %files) { 256 | 257 | # Run only a specific test name 258 | if ($test_name ne '') { 259 | basename($test_name) eq $name or next; 260 | } 261 | 262 | printf("\n\t=>> Running test: %s\n", $name); 263 | 264 | foreach my $i (0 .. $#{$executors}) { 265 | 266 | my $executor = $executors->[$i]; 267 | my $lang = $executor->{name}; 268 | printf("\n[%s of %s] Testing language: %s\n", $i + 1, $#{$executors} + 1, $lang); 269 | 270 | my @args = get_arguments($files{$name}); 271 | my %ignore = get_ignores($files{$name}); 272 | my @files = files_by_ext($executor->{ext}, $files{$name}); 273 | 274 | if (@files == 0) { 275 | warn sprintf(" `-> no file has been found with the extension%s: %s\n", 276 | @{$executor->{ext}} > 1 ? 's' : '', join(', ', @{$executor->{ext}})); 277 | next; 278 | } 279 | 280 | foreach my $input_file (@files) { 281 | 282 | my $basename = basename($input_file); 283 | if (exists $ignore{$basename}) { 284 | printf(" `-> ignoring file: %s\n", $basename); 285 | next; 286 | } 287 | 288 | my @run_cmd; 289 | my $temp_file; 290 | 291 | my $load_time = 0; 292 | 293 | # Case for compiled languages 294 | if ($compile_bool) { 295 | printf(" `-> compilling file: %s\n", $input_file); 296 | 297 | my $output_file = mktemp(catfile(tmpdir, 'XXXXXXXX')); 298 | my @cmd = create_cmd($executor->{cmd}, $input_file, $output_file); 299 | 300 | # Compile the program 301 | execute_cmd(@cmd) 302 | || do { 303 | warn "[!] Error ($!) in executing the command: @cmd\n"; 304 | next; 305 | }; 306 | 307 | if (not -x $output_file) { 308 | warn "[!] The output file ($output_file) is not executable!\n"; 309 | next; 310 | } 311 | 312 | $temp_file = $output_file; 313 | push @run_cmd, $output_file; 314 | } 315 | 316 | # Case for interpreted languages 317 | else { 318 | 319 | # Test the load-time of the interpreter by executing an empty program 320 | if ($test_loadtime) { 321 | my $tmpfile = $tmpcache{$executor->{ext}[0]} // do { 322 | my (undef, $file) = tempfile(DIR => $tmpdir, SUFFIX => ".$executor->{ext}[0]"); 323 | $tmpcache{$executor->{ext}[0]} = $file; 324 | $file; 325 | }; 326 | 327 | my @cmd = create_cmd($executor->{cmd}, $tmpfile); 328 | my $time = time_cmd(@cmd); 329 | 330 | if ($time > 0) { 331 | $load_time = time_cmd(@cmd); # time again to get a more accurate result 332 | } 333 | else { 334 | warn "[!] An error occurred while timing the loading time: @cmd"; 335 | } 336 | } 337 | 338 | push @run_cmd, create_cmd($executor->{cmd}, $input_file); 339 | } 340 | 341 | printf(" `-> testing %d times: %s\n", $repeat_n, basename($input_file)); 342 | 343 | # The array used to store the elapsed times 344 | my @times; 345 | 346 | # Run the test N times and store the elapsed times 347 | foreach my $i (1 .. $repeat_n) { 348 | my $elapsed_time = time_cmd(@run_cmd, @args); 349 | if ($elapsed_time == -1) { 350 | warn "[!] An error occurred while executing the command: @run_cmd\n"; 351 | last; 352 | } 353 | 354 | push @times, ($test_loadtime ? ($elapsed_time - $load_time) : $elapsed_time); 355 | } 356 | 357 | # Delete the compiled file 358 | if ($compile_bool and defined $temp_file) { 359 | unlink($temp_file); 360 | } 361 | 362 | # Store the collected data 363 | if (@times > 0) { 364 | my $report_name = join(' ', $name, map { s{/}{%}r } @args); 365 | @{$report{$report_name}{$input_file}{$lang}}{qw(load_time time_min time_max time_avg)} = 366 | ($load_time, mMavg(@times)); 367 | } 368 | else { 369 | warn "[!] No test has been timed! Skipping file...\n"; 370 | next; 371 | } 372 | } 373 | } 374 | } 375 | 376 | return %report; 377 | } 378 | 379 | # 380 | ## Test the compiled languages 381 | # 382 | if ($test_compiled) { 383 | my %report = start_test($compiled_langs_dir, $compilers, 1); 384 | 385 | if (%report) { 386 | print "\n** Generating the reports for compiled languages...\n"; 387 | write_report(\%report, $compiled_reports_dir); 388 | print "** Done!\n"; 389 | } 390 | else { 391 | warn "\n** No report has been generated for compiled languages!\n"; 392 | } 393 | } 394 | 395 | # 396 | ## Test the interpreted languages 397 | # 398 | if ($test_interpreted) { 399 | my %report = start_test($interpreted_langs_dir, $interpreters, 0); 400 | 401 | if (%report) { 402 | print "\n** Generating the reports for interpreted languages...\n"; 403 | write_report(\%report, $interpreted_reports_dir); 404 | print "** Done!\n"; 405 | } 406 | else { 407 | warn "\n** No report has been generated for interpreted languages!\n"; 408 | } 409 | } 410 | 411 | if (not $test_compiled and not $test_interpreted) { 412 | help(); 413 | } 414 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | --------------------------------------------------------------------------------