From 051504d65b0747d55b3e373733174cd2a0702f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Wed, 10 Apr 2013 14:58:50 -0700 Subject: [PATCH] Add all the A tasks --- Conf/.task.yaml.swp | Bin 12288 -> 12288 bytes Conf/task.yaml | 34 +++ Lang/0815/A+B | 1 + Lang/6502-Assembly/Averages-Arithmetic-mean | 1 + Lang/ABAP/A+B | 1 + Lang/ABAP/Abstract-type | 1 + Lang/ABAP/Accumulator-factory | 1 + Lang/ABAP/Align-columns | 1 + Lang/ACL2/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/ACL2/Array-concatenation | 1 + Lang/ACL2/Averages-Arithmetic-mean | 1 + Lang/ALGOL-68/A+B | 1 + Lang/ALGOL-68/Accumulator-factory | 1 + Lang/ALGOL-68/Address-of-a-variable | 1 + Lang/ALGOL-68/Align-columns | 1 + Lang/ALGOL-68/Apply-a-callback-to-an-array | 1 + Lang/ALGOL-68/Arithmetic-Complex | 1 + Lang/ALGOL-68/Arithmetic-Rational | 1 + Lang/ALGOL-68/Arithmetic-evaluation | 1 + Lang/ALGOL-68/Array-concatenation | 1 + Lang/ALGOL-68/Associative-array-Creation | 1 + Lang/ALGOL-68/Averages-Arithmetic-mean | 1 + Lang/ALGOL-68/Averages-Pythagorean-means | 1 + Lang/ALGOL-68/Averages-Root-mean-square | 1 + Lang/ALGOL-68/Averages-Simple-moving-average | 1 + Lang/ANTLR/A+B | 1 + Lang/APL/Arithmetic-Complex | 1 + Lang/APL/Array-concatenation | 1 + Lang/APL/Associative-array-Creation | 1 + Lang/APL/Averages-Arithmetic-mean | 1 + Lang/APL/Averages-Pythagorean-means | 1 + Lang/APL/Averages-Root-mean-square | 1 + Lang/AWK/A+B | 1 + Lang/AWK/Align-columns | 1 + Lang/AWK/Apply-a-callback-to-an-array | 1 + Lang/AWK/Associative-array-Creation | 1 + Lang/AWK/Associative-array-Iteration | 1 + Lang/AWK/Averages-Arithmetic-mean | 1 + Lang/AWK/Averages-Median | 1 + Lang/AWK/Averages-Pythagorean-means | 1 + Lang/AWK/Averages-Root-mean-square | 1 + Lang/AWK/Averages-Simple-moving-average | 1 + Lang/ActionScript/Abstract-type | 1 + Lang/ActionScript/Accumulator-factory | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/ActionScript/Animation | 1 + .../ActionScript/Apply-a-callback-to-an-array | 1 + Lang/ActionScript/Array-concatenation | 1 + Lang/ActionScript/Associative-array-Creation | 1 + Lang/ActionScript/Averages-Arithmetic-mean | 1 + Lang/ActionScript/Averages-Pythagorean-means | 1 + Lang/Ada/A+B | 1 + Lang/Ada/Abstract-type | 1 + Lang/Ada/Accumulator-factory | 1 + Lang/Ada/Active-object | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/Ada/Address-of-a-variable | 1 + Lang/Ada/Align-columns | 1 + Lang/Ada/Anagrams-Deranged-anagrams | 1 + Lang/Ada/Animation | 1 + Lang/Ada/Anonymous-recursion | 1 + Lang/Ada/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Ada/Arena-storage-pool | 1 + Lang/Ada/Arithmetic-Complex | 1 + Lang/Ada/Arithmetic-geometric-mean | 1 + Lang/Ada/Array-concatenation | 1 + Lang/Ada/Associative-array-Creation | 1 + Lang/Ada/Associative-array-Iteration | 1 + Lang/Ada/Atomic-updates | 1 + Lang/Ada/Average-loop-length | 1 + Lang/Ada/Averages-Arithmetic-mean | 1 + Lang/Ada/Averages-Mean-angle | 1 + Lang/Ada/Averages-Median | 1 + Lang/Ada/Averages-Pythagorean-means | 1 + Lang/Ada/Averages-Root-mean-square | 1 + Lang/Ada/Averages-Simple-moving-average | 1 + Lang/Agda/Abstract-type | 1 + Lang/Aikido/Abstract-type | 1 + Lang/Aikido/Accumulator-factory | 1 + Lang/Aikido/Associative-array-Creation | 1 + Lang/Aime/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/AmigaE/Averages-Arithmetic-mean | 1 + Lang/AppleScript/Averages-Median | 1 + Lang/Argile/A+B | 1 + Lang/Argile/Abstract-type | 1 + Lang/Argile/Accumulator-factory | 1 + Lang/Argile/Address-of-a-variable | 1 + Lang/AutoHotkey/A+B | 1 + Lang/AutoHotkey/Abstract-type | 1 + Lang/AutoHotkey/Active-Directory-Connect | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/AutoHotkey/Address-of-a-variable | 1 + Lang/AutoHotkey/Align-columns | 1 + Lang/AutoHotkey/Animation | 1 + Lang/AutoHotkey/Anonymous-recursion | 1 + Lang/AutoHotkey/Apply-a-callback-to-an-array | 1 + Lang/AutoHotkey/Arithmetic-Complex | 1 + Lang/AutoHotkey/Arithmetic-evaluation | 1 + Lang/AutoHotkey/Arithmetic-geometric-mean | 1 + Lang/AutoHotkey/Array-concatenation | 1 + Lang/AutoHotkey/Associative-array-Creation | 1 + Lang/AutoHotkey/Associative-array-Iteration | 1 + Lang/AutoHotkey/Averages-Arithmetic-mean | 1 + Lang/AutoHotkey/Averages-Median | 1 + Lang/AutoHotkey/Averages-Pythagorean-means | 1 + Lang/AutoHotkey/Averages-Root-mean-square | 1 + .../AutoHotkey/Averages-Simple-moving-average | 1 + Lang/AutoIt/A+B | 1 + Lang/AutoIt/Active-Directory-Connect | 1 + Lang/AutoIt/Array-concatenation | 1 + Lang/Axiom/Anonymous-recursion | 1 + Lang/BASIC/A+B | 1 + Lang/BASIC/Address-of-a-variable | 1 + Lang/BASIC/Arithmetic-Complex | 1 + Lang/BASIC/Averages-Arithmetic-mean | 1 + Lang/BASIC/Averages-Median | 1 + Lang/BASIC/Averages-Root-mean-square | 1 + Lang/Babel/Array-concatenation | 1 + Lang/Befunge/A+B | 1 + Lang/Befunge/Averages-Arithmetic-mean | 1 + Lang/C/A+B | 1 + Lang/C/Abstract-type | 1 + Lang/C/Accumulator-factory | 1 + Lang/C/Active-Directory-Connect | 1 + Lang/C/Active-Directory-Search-for-a-user | 1 + Lang/C/Active-object | 1 + Lang/C/Anagrams-Deranged-anagrams | 1 + Lang/C/Animation | 1 + Lang/C/Anonymous-recursion | 1 + Lang/C/Apply-a-callback-to-an-array | 1 + .../C/Arbitrary-precision-integers-(included) | 1 + Lang/C/Arena-storage-pool | 1 + Lang/C/Arithmetic-Complex | 1 + Lang/C/Arithmetic-Rational | 1 + Lang/C/Arithmetic-geometric-mean | 1 + Lang/C/Array-concatenation | 1 + Lang/C/Atomic-updates | 1 + Lang/C/Average-loop-length | 1 + Lang/C/Averages-Arithmetic-mean | 1 + Lang/C/Averages-Mean-angle | 1 + Lang/C/Averages-Mean-time-of-day | 1 + Lang/C/Averages-Median | 1 + Lang/C/Averages-Pythagorean-means | 1 + Lang/C/Averages-Root-mean-square | 1 + Lang/C/Averages-Simple-moving-average | 1 + Lang/Clojure/A+B | 1 + Lang/Clojure/Abstract-type | 1 + Lang/Clojure/Accumulator-factory | 1 + Lang/Clojure/Active-object | 1 + Lang/Clojure/Align-columns | 1 + Lang/Clojure/Anagrams-Deranged-anagrams | 1 + Lang/Clojure/Animation | 1 + Lang/Clojure/Anonymous-recursion | 1 + Lang/Clojure/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Clojure/Arithmetic-Rational | 1 + Lang/Clojure/Arithmetic-evaluation | 1 + Lang/Clojure/Array-concatenation | 1 + Lang/Clojure/Associative-array-Creation | 1 + Lang/Clojure/Associative-array-Iteration | 1 + Lang/Clojure/Atomic-updates | 1 + Lang/Clojure/Averages-Arithmetic-mean | 1 + Lang/Clojure/Averages-Median | 1 + Lang/Clojure/Averages-Pythagorean-means | 1 + Lang/Clojure/Averages-Root-mean-square | 1 + Lang/Clojure/Averages-Simple-moving-average | 1 + Lang/CoffeeScript/A+B | 1 + Lang/CoffeeScript/Accumulator-factory | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/CoffeeScript/Align-columns | 1 + Lang/CoffeeScript/Anagrams-Deranged-anagrams | 1 + Lang/CoffeeScript/Anonymous-recursion | 1 + .../CoffeeScript/Apply-a-callback-to-an-array | 1 + Lang/CoffeeScript/Arithmetic-Complex | 1 + Lang/CoffeeScript/Array-concatenation | 1 + Lang/CoffeeScript/Associative-array-Iteration | 1 + Lang/CoffeeScript/Averages-Arithmetic-mean | 1 + Lang/CoffeeScript/Averages-Root-mean-square | 1 + .../Averages-Simple-moving-average | 1 + Lang/Dylan/Anonymous-recursion | 1 + Lang/Eiffel/A+B | 1 + Lang/Eiffel/Abstract-type | 1 + Lang/Erlang/A+B | 1 + Lang/Erlang/Accumulator-factory | 1 + Lang/Erlang/Align-columns | 1 + Lang/Erlang/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Erlang/Arithmetic-Complex | 1 + Lang/Erlang/Arithmetic-geometric-mean | 1 + Lang/Erlang/Array-concatenation | 1 + Lang/Erlang/Associative-array-Creation | 1 + Lang/Erlang/Associative-array-Iteration | 1 + Lang/Erlang/Averages-Arithmetic-mean | 1 + Lang/Erlang/Averages-Median | 1 + Lang/Erlang/Averages-Pythagorean-means | 1 + Lang/Erlang/Averages-Root-mean-square | 1 + Lang/Erlang/Averages-Simple-moving-average | 1 + Lang/Forth/A+B | 1 + Lang/Forth/Abstract-type | 1 + Lang/Forth/Accumulator-factory | 1 + Lang/Forth/Align-columns | 1 + Lang/Forth/Anonymous-recursion | 1 + Lang/Forth/Apply-a-callback-to-an-array | 1 + Lang/Forth/Arithmetic-Complex | 1 + Lang/Forth/Arithmetic-Rational | 1 + Lang/Forth/Array-concatenation | 1 + Lang/Forth/Associative-array-Creation | 1 + Lang/Forth/Associative-array-Iteration | 1 + Lang/Forth/Averages-Arithmetic-mean | 1 + Lang/Forth/Averages-Median | 1 + Lang/Forth/Averages-Pythagorean-means | 1 + Lang/Forth/Averages-Root-mean-square | 1 + Lang/Forth/Averages-Simple-moving-average | 1 + Lang/Fortran/A+B | 1 + Lang/Fortran/Address-of-a-variable | 1 + Lang/Fortran/Anonymous-recursion | 1 + Lang/Fortran/Apply-a-callback-to-an-array | 1 + Lang/Fortran/Arithmetic-Complex | 1 + Lang/Fortran/Arithmetic-Rational | 1 + Lang/Fortran/Arithmetic-geometric-mean | 1 + Lang/Fortran/Array-concatenation | 1 + Lang/Fortran/Averages-Arithmetic-mean | 1 + Lang/Fortran/Averages-Median | 1 + Lang/Fortran/Averages-Pythagorean-means | 1 + Lang/Fortran/Averages-Root-mean-square | 1 + Lang/Fortran/Averages-Simple-moving-average | 1 + Lang/Go/A+B | 1 + Lang/Go/Abstract-type | 1 + Lang/Go/Accumulator-factory | 1 + Lang/Go/Active-object | 1 + Lang/Go/Address-of-a-variable | 1 + Lang/Go/Align-columns | 1 + Lang/Go/Anagrams-Deranged-anagrams | 1 + Lang/Go/Anonymous-recursion | 1 + Lang/Go/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Go/Arithmetic-Complex | 1 + Lang/Go/Arithmetic-Rational | 1 + Lang/Go/Arithmetic-geometric-mean | 1 + Lang/Go/Array-concatenation | 1 + Lang/Go/Associative-array-Creation | 1 + Lang/Go/Associative-array-Iteration | 1 + Lang/Go/Atomic-updates | 1 + Lang/Go/Averages-Arithmetic-mean | 1 + Lang/Go/Averages-Mean-angle | 1 + Lang/Go/Averages-Mean-time-of-day | 1 + Lang/Go/Averages-Median | 1 + Lang/Go/Averages-Pythagorean-means | 1 + Lang/Go/Averages-Root-mean-square | 1 + Lang/Go/Averages-Simple-moving-average | 1 + Lang/Haskell/A+B | 1 + Lang/Haskell/Abstract-type | 1 + Lang/Haskell/Accumulator-factory | 1 + Lang/Haskell/Active-object | 1 + Lang/Haskell/Align-columns | 1 + Lang/Haskell/Anagrams-Deranged-anagrams | 1 + Lang/Haskell/Animation | 1 + Lang/Haskell/Anonymous-recursion | 1 + Lang/Haskell/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Haskell/Arithmetic-Complex | 1 + Lang/Haskell/Arithmetic-Rational | 1 + Lang/Haskell/Arithmetic-evaluation | 1 + Lang/Haskell/Arithmetic-geometric-mean | 1 + Lang/Haskell/Array-concatenation | 1 + Lang/Haskell/Associative-array-Creation | 1 + Lang/Haskell/Associative-array-Iteration | 1 + Lang/Haskell/Atomic-updates | 1 + Lang/Haskell/Averages-Arithmetic-mean | 1 + Lang/Haskell/Averages-Mean-angle | 1 + Lang/Haskell/Averages-Median | 1 + Lang/Haskell/Averages-Pythagorean-means | 1 + Lang/Haskell/Averages-Root-mean-square | 1 + Lang/Haskell/Averages-Simple-moving-average | 1 + Lang/Java/A+B | 1 + Lang/Java/Abstract-type | 1 + Lang/Java/Accumulator-factory | 1 + Lang/Java/Active-Directory-Connect | 1 + Lang/Java/Active-Directory-Search-for-a-user | 1 + Lang/Java/Anagrams-Deranged-anagrams | 1 + Lang/Java/Animation | 1 + Lang/Java/Anonymous-recursion | 1 + Lang/Java/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Java/Arithmetic-Complex | 1 + Lang/Java/Arithmetic-Rational | 1 + Lang/Java/Arithmetic-evaluation | 1 + Lang/Java/Arithmetic-geometric-mean | 1 + Lang/Java/Array-concatenation | 1 + Lang/Java/Associative-array-Creation | 1 + Lang/Java/Associative-array-Iteration | 1 + Lang/Java/Atomic-updates | 1 + Lang/Java/Averages-Arithmetic-mean | 1 + Lang/Java/Averages-Median | 1 + Lang/Java/Averages-Pythagorean-means | 1 + Lang/Java/Averages-Root-mean-square | 1 + Lang/Java/Averages-Simple-moving-average | 1 + Lang/JavaScript/A+B | 1 + Lang/JavaScript/Accumulator-factory | 1 + Lang/JavaScript/Active-object | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/JavaScript/Align-columns | 1 + Lang/JavaScript/Anagrams-Deranged-anagrams | 1 + Lang/JavaScript/Animation | 1 + Lang/JavaScript/Anonymous-recursion | 1 + Lang/JavaScript/Apply-a-callback-to-an-array | 1 + Lang/JavaScript/Arithmetic-Complex | 1 + Lang/JavaScript/Arithmetic-evaluation | 1 + Lang/JavaScript/Array-concatenation | 1 + Lang/JavaScript/Associative-array-Creation | 1 + Lang/JavaScript/Associative-array-Iteration | 1 + Lang/JavaScript/Averages-Arithmetic-mean | 1 + Lang/JavaScript/Averages-Median | 1 + Lang/JavaScript/Averages-Pythagorean-means | 1 + Lang/JavaScript/Averages-Root-mean-square | 1 + .../JavaScript/Averages-Simple-moving-average | 1 + Lang/Lua/A+B | 1 + Lang/Lua/Abstract-type | 1 + Lang/Lua/Accumulator-factory | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/Lua/Align-columns | 1 + Lang/Lua/Anonymous-recursion | 1 + Lang/Lua/Apply-a-callback-to-an-array | 1 + Lang/Lua/Arithmetic-Complex | 1 + Lang/Lua/Arithmetic-Rational | 1 + Lang/Lua/Arithmetic-evaluation | 1 + Lang/Lua/Array-concatenation | 1 + Lang/Lua/Associative-array-Creation | 1 + Lang/Lua/Associative-array-Iteration | 1 + Lang/Lua/Averages-Arithmetic-mean | 1 + Lang/Lua/Averages-Median | 1 + Lang/Lua/Averages-Pythagorean-means | 1 + Lang/Lua/Averages-Root-mean-square | 1 + Lang/Lua/Averages-Simple-moving-average | 1 + Lang/PHP/A+B | 1 + Lang/PHP/Abstract-type | 1 + Lang/PHP/Accumulator-factory | 1 + Lang/PHP/Active-Directory-Connect | 1 + Lang/PHP/Active-Directory-Search-for-a-user | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/PHP/Align-columns | 1 + Lang/PHP/Anagrams-Deranged-anagrams | 1 + Lang/PHP/Anonymous-recursion | 1 + Lang/PHP/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/PHP/Arithmetic-geometric-mean | 1 + Lang/PHP/Array-concatenation | 1 + Lang/PHP/Associative-array-Creation | 1 + Lang/PHP/Associative-array-Iteration | 1 + Lang/PHP/Averages-Arithmetic-mean | 1 + Lang/PHP/Averages-Median | 1 + Lang/Perl/A+B | 1 + Lang/Perl/Abstract-type | 1 + Lang/Perl/Accumulator-factory | 1 + Lang/Perl/Active-Directory-Connect | 1 + Lang/Perl/Active-object | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/Perl/Address-of-a-variable | 1 + Lang/Perl/Align-columns | 1 + Lang/Perl/Anagrams-Deranged-anagrams | 1 + Lang/Perl/Animation | 1 + Lang/Perl/Anonymous-recursion | 1 + Lang/Perl/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Perl/Arithmetic-Complex | 1 + Lang/Perl/Arithmetic-Rational | 1 + Lang/Perl/Arithmetic-evaluation | 1 + Lang/Perl/Arithmetic-geometric-mean | 1 + Lang/Perl/Array-concatenation | 1 + Lang/Perl/Associative-array-Creation | 1 + Lang/Perl/Associative-array-Iteration | 1 + Lang/Perl/Atomic-updates | 1 + Lang/Perl/Averages-Arithmetic-mean | 1 + Lang/Perl/Averages-Median | 1 + Lang/Perl/Averages-Pythagorean-means | 1 + Lang/Perl/Averages-Root-mean-square | 1 + Lang/Perl/Averages-Simple-moving-average | 1 + Lang/PicoLisp/A+B | 1 + Lang/PicoLisp/Abstract-type | 1 + Lang/PicoLisp/Accumulator-factory | 1 + Lang/PicoLisp/Active-Directory-Connect | 1 + .../Active-Directory-Search-for-a-user | 1 + Lang/PicoLisp/Active-object | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/PicoLisp/Address-of-a-variable | 1 + Lang/PicoLisp/Align-columns | 1 + Lang/PicoLisp/Anagrams-Deranged-anagrams | 1 + Lang/PicoLisp/Animation | 1 + Lang/PicoLisp/Anonymous-recursion | 1 + Lang/PicoLisp/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/PicoLisp/Arithmetic-Complex | 1 + Lang/PicoLisp/Arithmetic-Rational | 1 + Lang/PicoLisp/Arithmetic-evaluation | 1 + Lang/PicoLisp/Arithmetic-geometric-mean | 1 + Lang/PicoLisp/Array-concatenation | 1 + Lang/PicoLisp/Associative-array-Creation | 1 + Lang/PicoLisp/Associative-array-Iteration | 1 + Lang/PicoLisp/Atomic-updates | 1 + Lang/PicoLisp/Averages-Arithmetic-mean | 1 + Lang/PicoLisp/Averages-Mean-angle | 1 + Lang/PicoLisp/Averages-Mean-time-of-day | 1 + Lang/PicoLisp/Averages-Median | 1 + Lang/PicoLisp/Averages-Pythagorean-means | 1 + Lang/PicoLisp/Averages-Root-mean-square | 1 + Lang/PicoLisp/Averages-Simple-moving-average | 1 + Lang/Prolog/A+B | 1 + Lang/Prolog/Accumulator-factory | 1 + Lang/Prolog/Align-columns | 1 + Lang/Prolog/Anagrams-Deranged-anagrams | 1 + Lang/Prolog/Animation | 1 + Lang/Prolog/Anonymous-recursion | 1 + Lang/Prolog/Apply-a-callback-to-an-array | 1 + Lang/Prolog/Arithmetic-evaluation | 1 + Lang/Prolog/Array-concatenation | 1 + Lang/Prolog/Associative-array-Creation | 1 + Lang/Prolog/Averages-Median | 1 + Lang/Python/A+B | 1 + Lang/Python/Abstract-type | 1 + Lang/Python/Accumulator-factory | 1 + Lang/Python/Active-Directory-Connect | 1 + .../Python/Active-Directory-Search-for-a-user | 1 + Lang/Python/Active-object | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/Python/Address-of-a-variable | 1 + Lang/Python/Align-columns | 1 + Lang/Python/Anagrams-Deranged-anagrams | 1 + Lang/Python/Animation | 1 + Lang/Python/Anonymous-recursion | 1 + Lang/Python/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Python/Arithmetic-Complex | 1 + Lang/Python/Arithmetic-Rational | 1 + Lang/Python/Arithmetic-evaluation | 1 + Lang/Python/Arithmetic-geometric-mean | 1 + Lang/Python/Array-concatenation | 1 + Lang/Python/Associative-array-Creation | 1 + Lang/Python/Associative-array-Iteration | 1 + Lang/Python/Atomic-updates | 1 + Lang/Python/Average-loop-length | 1 + Lang/Python/Averages-Arithmetic-mean | 1 + Lang/Python/Averages-Mean-angle | 1 + Lang/Python/Averages-Mean-time-of-day | 1 + Lang/Python/Averages-Median | 1 + Lang/Python/Averages-Pythagorean-means | 1 + Lang/Python/Averages-Root-mean-square | 1 + Lang/Python/Averages-Simple-moving-average | 1 + Lang/R/A+B | 1 + Lang/R/Accumulator-factory | 1 + Lang/R/Align-columns | 1 + Lang/R/Anagrams-Deranged-anagrams | 1 + Lang/R/Animation | 1 + Lang/R/Anonymous-recursion | 1 + Lang/R/Apply-a-callback-to-an-array | 1 + .../R/Arbitrary-precision-integers-(included) | 1 + Lang/R/Arithmetic-Complex | 1 + Lang/R/Arithmetic-geometric-mean | 1 + Lang/R/Array-concatenation | 1 + Lang/R/Associative-array-Creation | 1 + Lang/R/Associative-array-Iteration | 1 + Lang/R/Averages-Arithmetic-mean | 1 + Lang/R/Averages-Median | 1 + Lang/R/Averages-Pythagorean-means | 1 + Lang/R/Averages-Root-mean-square | 1 + Lang/R/Averages-Simple-moving-average | 1 + Lang/REXX/A+B | 1 + Lang/REXX/Accumulator-factory | 1 + Lang/REXX/Active-Directory-Search-for-a-user | 1 + Lang/REXX/Address-of-a-variable | 1 + Lang/REXX/Align-columns | 1 + Lang/REXX/Anagrams-Deranged-anagrams | 1 + Lang/REXX/Anonymous-recursion | 1 + Lang/REXX/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/REXX/Arena-storage-pool | 1 + Lang/REXX/Arithmetic-Complex | 1 + Lang/REXX/Arithmetic-Rational | 1 + Lang/REXX/Arithmetic-evaluation | 1 + Lang/REXX/Arithmetic-geometric-mean | 1 + Lang/REXX/Array-concatenation | 1 + Lang/REXX/Associative-array-Creation | 1 + Lang/REXX/Associative-array-Iteration | 1 + Lang/REXX/Average-loop-length | 1 + Lang/REXX/Averages-Arithmetic-mean | 1 + Lang/REXX/Averages-Mean-angle | 1 + Lang/REXX/Averages-Median | 1 + Lang/REXX/Averages-Pythagorean-means | 1 + Lang/REXX/Averages-Root-mean-square | 1 + Lang/REXX/Averages-Simple-moving-average | 1 + Lang/Racket/A+B | 1 + Lang/Racket/Abstract-type | 1 + Lang/Racket/Accumulator-factory | 1 + Lang/Racket/Active-object | 1 + Lang/Racket/Address-of-a-variable | 1 + Lang/Racket/Align-columns | 1 + Lang/Racket/Animation | 1 + Lang/Racket/Anonymous-recursion | 1 + Lang/Racket/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Racket/Arithmetic-Complex | 1 + Lang/Racket/Arithmetic-geometric-mean | 1 + Lang/Racket/Array-concatenation | 1 + Lang/Racket/Associative-array-Creation | 1 + Lang/Racket/Associative-array-Iteration | 1 + Lang/Racket/Averages-Arithmetic-mean | 1 + Lang/Racket/Averages-Mean-angle | 1 + Lang/Racket/Averages-Median | 1 + Lang/Racket/Averages-Pythagorean-means | 1 + Lang/Ruby/A+B | 1 + Lang/Ruby/Abstract-type | 1 + Lang/Ruby/Accumulator-factory | 1 + Lang/Ruby/Active-Directory-Connect | 1 + Lang/Ruby/Active-Directory-Search-for-a-user | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/Ruby/Address-of-a-variable | 1 + Lang/Ruby/Align-columns | 1 + Lang/Ruby/Anagrams-Deranged-anagrams | 1 + Lang/Ruby/Animation | 1 + Lang/Ruby/Anonymous-recursion | 1 + Lang/Ruby/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Ruby/Arithmetic-Complex | 1 + Lang/Ruby/Arithmetic-Rational | 1 + Lang/Ruby/Arithmetic-evaluation | 1 + Lang/Ruby/Arithmetic-geometric-mean | 1 + Lang/Ruby/Array-concatenation | 1 + Lang/Ruby/Associative-array-Creation | 1 + Lang/Ruby/Associative-array-Iteration | 1 + Lang/Ruby/Atomic-updates | 1 + Lang/Ruby/Averages-Arithmetic-mean | 1 + Lang/Ruby/Averages-Mean-angle | 1 + Lang/Ruby/Averages-Median | 1 + Lang/Ruby/Averages-Pythagorean-means | 1 + Lang/Ruby/Averages-Root-mean-square | 1 + Lang/Ruby/Averages-Simple-moving-average | 1 + Lang/Sather/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Sather/Associative-array-Creation | 1 + Lang/Sather/Averages-Arithmetic-mean | 1 + Lang/Sather/Averages-Root-mean-square | 1 + Lang/Scala/A+B | 1 + Lang/Scala/Abstract-type | 1 + Lang/Scala/Accumulator-factory | 1 + Lang/Scala/Active-object | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/Scala/Align-columns | 1 + Lang/Scala/Anagrams-Deranged-anagrams | 1 + Lang/Scala/Animation | 1 + Lang/Scala/Anonymous-recursion | 1 + Lang/Scala/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Scala/Arithmetic-Complex | 1 + Lang/Scala/Arithmetic-Rational | 1 + Lang/Scala/Arithmetic-evaluation | 1 + Lang/Scala/Arithmetic-geometric-mean | 1 + Lang/Scala/Array-concatenation | 1 + Lang/Scala/Associative-array-Creation | 1 + Lang/Scala/Associative-array-Iteration | 1 + Lang/Scala/Atomic-updates | 1 + Lang/Scala/Averages-Arithmetic-mean | 1 + Lang/Scala/Averages-Median | 1 + Lang/Scala/Averages-Pythagorean-means | 1 + Lang/Scala/Averages-Root-mean-square | 1 + Lang/Scala/Averages-Simple-moving-average | 1 + Lang/Scheme/A+B | 1 + Lang/Scheme/Accumulator-factory | 1 + Lang/Scheme/Anonymous-recursion | 1 + Lang/Scheme/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Scheme/Arithmetic-Complex | 1 + Lang/Scheme/Arithmetic-Rational | 1 + Lang/Scheme/Array-concatenation | 1 + Lang/Scheme/Associative-array-Creation | 1 + Lang/Scheme/Averages-Arithmetic-mean | 1 + Lang/Scheme/Averages-Median | 1 + Lang/Scheme/Averages-Pythagorean-means | 1 + Lang/Scheme/Averages-Root-mean-square | 1 + Lang/Scheme/Averages-Simple-moving-average | 1 + Lang/Smalltalk/A+B | 1 + Lang/Smalltalk/Accumulator-factory | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/Smalltalk/Address-of-a-variable | 1 + Lang/Smalltalk/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Smalltalk/Arithmetic-Complex | 1 + Lang/Smalltalk/Arithmetic-Rational | 1 + Lang/Smalltalk/Array-concatenation | 1 + Lang/Smalltalk/Associative-array-Creation | 1 + Lang/Smalltalk/Associative-array-Iteration | 1 + Lang/Smalltalk/Averages-Arithmetic-mean | 1 + Lang/Smalltalk/Averages-Median | 1 + Lang/Smalltalk/Averages-Pythagorean-means | 1 + Lang/Smalltalk/Averages-Root-mean-square | 1 + Lang/Smalltalk/Averages-Simple-moving-average | 1 + Lang/Tcl/A+B | 1 + Lang/Tcl/Abstract-type | 1 + Lang/Tcl/Accumulator-factory | 1 + Lang/Tcl/Active-Directory-Connect | 1 + Lang/Tcl/Active-Directory-Search-for-a-user | 1 + Lang/Tcl/Active-object | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/Tcl/Address-of-a-variable | 1 + Lang/Tcl/Align-columns | 1 + Lang/Tcl/Anagrams-Deranged-anagrams | 1 + Lang/Tcl/Animation | 1 + Lang/Tcl/Anonymous-recursion | 1 + Lang/Tcl/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Tcl/Arena-storage-pool | 1 + Lang/Tcl/Arithmetic-Complex | 1 + Lang/Tcl/Arithmetic-evaluation | 1 + Lang/Tcl/Arithmetic-geometric-mean | 1 + Lang/Tcl/Array-concatenation | 1 + Lang/Tcl/Associative-array-Creation | 1 + Lang/Tcl/Associative-array-Iteration | 1 + Lang/Tcl/Atomic-updates | 1 + Lang/Tcl/Average-loop-length | 1 + Lang/Tcl/Averages-Arithmetic-mean | 1 + Lang/Tcl/Averages-Mean-angle | 1 + Lang/Tcl/Averages-Mean-time-of-day | 1 + Lang/Tcl/Averages-Median | 1 + Lang/Tcl/Averages-Pythagorean-means | 1 + Lang/Tcl/Averages-Root-mean-square | 1 + Lang/Tcl/Averages-Simple-moving-average | 1 + Meta/00Tasks.yaml | 124 +++++++++ Task/A+B/0815/a+b.0815 | 1 + Task/A+B/0DESCRIPTION | 23 ++ Task/A+B/ABAP/a+b.abap | 15 ++ Task/A+B/ALGOL-68/a+b-1.alg | 1 + Task/A+B/ALGOL-68/a+b-2.alg | 3 + Task/A+B/ANTLR/a+b.antlr | 14 ++ Task/A+B/AWK/a+b.awk | 1 + Task/A+B/Ada/a+b-1.ada | 10 + Task/A+B/Ada/a+b-2.ada | 12 + Task/A+B/Argile/a+b-1.argile | 4 + Task/A+B/Argile/a+b-2.argile | 10 + Task/A+B/AutoHotkey/a+b.ahk | 3 + Task/A+B/AutoIt/a+b.autoit | 7 + Task/A+B/BASIC/a+b.bas | 16 ++ Task/A+B/Befunge/a+b.bf | 1 + Task/A+B/C/a+b-1.c | 9 + Task/A+B/C/a+b-2.c | 12 + Task/A+B/Clojure/a+b-1.clj | 4 + Task/A+B/Clojure/a+b-2.clj | 3 + Task/A+B/CoffeeScript/a+b.coffee | 14 ++ Task/A+B/Eiffel/a+b.e | 13 + Task/A+B/Erlang/a+b.erl | 10 + Task/A+B/Forth/a+b.fth | 1 + Task/A+B/Fortran/a+b.f | 10 + Task/A+B/Go/a+b.go | 9 + Task/A+B/Haskell/a+b.hs | 1 + Task/A+B/Java/a+b-1.java | 8 + Task/A+B/Java/a+b-2.java | 27 ++ Task/A+B/Java/a+b-3.java | 19 ++ Task/A+B/JavaScript/a+b-1.js | 14 ++ Task/A+B/JavaScript/a+b-2.js | 10 + Task/A+B/Lua/a+b.lua | 2 + Task/A+B/PHP/a+b-1.php | 2 + Task/A+B/PHP/a+b-2.php | 7 + Task/A+B/Perl/a+b.pl | 2 + Task/A+B/PicoLisp/a+b.l | 3 + Task/A+B/Prolog/a+b-1.pro | 7 + Task/A+B/Prolog/a+b-2.pro | 4 + Task/A+B/Python/a+b-1.py | 4 + Task/A+B/Python/a+b-2.py | 4 + Task/A+B/R/a+b.r | 1 + Task/A+B/REXX/a+b-1.rexx | 2 + Task/A+B/REXX/a+b-2.rexx | 2 + Task/A+B/REXX/a+b-3.rexx | 4 + Task/A+B/REXX/a+b-4.rexx | 9 + Task/A+B/Racket/a+b-1.rkt | 2 + Task/A+B/Racket/a+b-2.rkt | 6 + Task/A+B/Ruby/a+b-1.rb | 1 + Task/A+B/Ruby/a+b-2.rb | 1 + Task/A+B/Scala/a+b.scala | 1 + Task/A+B/Scheme/a+b.ss | 3 + Task/A+B/Smalltalk/a+b-1.st | 30 +++ Task/A+B/Smalltalk/a+b-2.st | 19 ++ Task/A+B/Smalltalk/a+b-3.st | 1 + Task/A+B/Tcl/a+b-1.tcl | 2 + Task/A+B/Tcl/a+b-2.tcl | 1 + Task/A+B/Tcl/a+b-3.tcl | 6 + Task/Abstract-type/0DESCRIPTION | 11 + Task/Abstract-type/1META.yaml | 5 + Task/Abstract-type/ABAP/abstract-type-1.abap | 13 + Task/Abstract-type/ABAP/abstract-type-2.abap | 5 + .../ActionScript/abstract-type.as | 8 + Task/Abstract-type/Ada/abstract-type-1.ada | 3 + Task/Abstract-type/Ada/abstract-type-2.ada | 2 + Task/Abstract-type/Ada/abstract-type-3.ada | 10 + Task/Abstract-type/Agda/abstract-type.agda | 53 ++++ .../Aikido/abstract-type-1.aikido | 5 + .../Aikido/abstract-type-2.aikido | 5 + .../Abstract-type/Argile/abstract-type.argile | 38 +++ .../AutoHotkey/abstract-type.ahk | 28 +++ Task/Abstract-type/C/abstract-type-1.c | 33 +++ Task/Abstract-type/C/abstract-type-2.c | 9 + Task/Abstract-type/C/abstract-type-3.c | 42 ++++ Task/Abstract-type/C/abstract-type-4.c | 13 + Task/Abstract-type/Clojure/abstract-type.clj | 1 + Task/Abstract-type/Eiffel/abstract-type.e | 17 ++ Task/Abstract-type/Forth/abstract-type.fth | 25 ++ Task/Abstract-type/Go/abstract-type.go | 5 + Task/Abstract-type/Haskell/abstract-type-1.hs | 3 + Task/Abstract-type/Haskell/abstract-type-2.hs | 5 + Task/Abstract-type/Haskell/abstract-type-3.hs | 2 + Task/Abstract-type/Haskell/abstract-type-4.hs | 1 + Task/Abstract-type/Haskell/abstract-type-5.hs | 3 + Task/Abstract-type/Haskell/abstract-type-6.hs | 3 + Task/Abstract-type/Java/abstract-type-1.java | 7 + Task/Abstract-type/Java/abstract-type-2.java | 5 + Task/Abstract-type/Lua/abstract-type-1.lua | 34 +++ Task/Abstract-type/Lua/abstract-type-2.lua | 8 + Task/Abstract-type/PHP/abstract-type-1.php | 7 + Task/Abstract-type/PHP/abstract-type-2.php | 5 + Task/Abstract-type/Perl/abstract-type-1.pl | 14 ++ Task/Abstract-type/Perl/abstract-type-2.pl | 13 + Task/Abstract-type/Perl/abstract-type-3.pl | 12 + Task/Abstract-type/Perl/abstract-type-4.pl | 12 + Task/Abstract-type/PicoLisp/abstract-type.l | 11 + Task/Abstract-type/Python/abstract-type-1.py | 13 + Task/Abstract-type/Python/abstract-type-2.py | 21 ++ Task/Abstract-type/Racket/abstract-type.rkt | 13 + Task/Abstract-type/Ruby/abstract-type.rb | 17 ++ Task/Abstract-type/Scala/abstract-type.scala | 10 + Task/Abstract-type/Tcl/abstract-type.tcl | 9 + Task/Accumulator-factory/0DESCRIPTION | 20 ++ Task/Accumulator-factory/1META.yaml | 3 + .../ABAP/accumulator-factory-1.abap | 27 ++ .../ABAP/accumulator-factory-2.abap | 24 ++ .../ALGOL-68/accumulator-factory.alg | 33 +++ .../ActionScript/accumulator-factory.as | 14 ++ .../Ada/accumulator-factory-1.ada | 11 + .../Ada/accumulator-factory-2.ada | 11 + .../Ada/accumulator-factory-3.ada | 64 +++++ .../Aikido/accumulator-factory.aikido | 8 + .../Argile/accumulator-factory.argile | 53 ++++ .../C/accumulator-factory.c | 18 ++ .../Clojure/accumulator-factory-1.clj | 3 + .../Clojure/accumulator-factory-2.clj | 3 + .../CoffeeScript/accumulator-factory.coffee | 6 + .../Erlang/accumulator-factory.erl | 17 ++ .../Forth/accumulator-factory.fth | 9 + .../Go/accumulator-factory.go | 34 +++ .../Haskell/accumulator-factory.hs | 17 ++ .../Java/accumulator-factory-1.java | 16 ++ .../Java/accumulator-factory-2.java | 19 ++ .../Java/accumulator-factory-3.java | 30 +++ .../JavaScript/accumulator-factory-1.js | 9 + .../JavaScript/accumulator-factory-2.js | 5 + .../Lua/accumulator-factory-1.lua | 7 + .../Lua/accumulator-factory-2.lua | 13 + .../Lua/accumulator-factory-3.lua | 6 + .../PHP/accumulator-factory-1.php | 8 + .../PHP/accumulator-factory-2.php | 8 + .../Perl/accumulator-factory.pl | 9 + .../PicoLisp/accumulator-factory.l | 8 + .../Prolog/accumulator-factory.pro | 15 ++ .../Python/accumulator-factory-1.py | 26 ++ .../Python/accumulator-factory-2.py | 11 + .../Python/accumulator-factory-3.py | 9 + .../R/accumulator-factory.r | 7 + .../REXX/accumulator-factory.rexx | 13 + .../Racket/accumulator-factory.rkt | 6 + .../Ruby/accumulator-factory.rb | 30 +++ .../Scala/accumulator-factory.scala | 8 + .../Scheme/accumulator-factory.ss | 15 ++ .../Smalltalk/accumulator-factory-1.st | 19 ++ .../Smalltalk/accumulator-factory-2.st | 15 ++ .../Tcl/accumulator-factory-1.tcl | 28 +++ .../Tcl/accumulator-factory-2.tcl | 8 + Task/Active-Directory-Connect/0DESCRIPTION | 1 + Task/Active-Directory-Connect/1META.yaml | 2 + .../AutoHotkey/active-directory-connect.ahk | 4 + .../AutoIt/active-directory-connect.autoit | 2 + .../C/active-directory-connect.c | 8 + .../Java/active-directory-connect.java | 59 +++++ .../PHP/active-directory-connect.php | 3 + .../Perl/active-directory-connect.pl | 4 + .../PicoLisp/active-directory-connect.l | 4 + .../Python/active-directory-connect.py | 10 + .../Ruby/active-directory-connect.rb | 4 + .../Tcl/active-directory-connect.tcl | 3 + .../0DESCRIPTION | 1 + .../1META.yaml | 2 + .../C/active-directory-search-for-a-user.c | 21 ++ .../active-directory-search-for-a-user.java | 153 ++++++++++++ .../active-directory-search-for-a-user.php | 16 ++ .../active-directory-search-for-a-user.l | 8 + .../active-directory-search-for-a-user.py | 18 ++ .../active-directory-search-for-a-user.rexx | 32 +++ .../active-directory-search-for-a-user.rb | 14 ++ .../active-directory-search-for-a-user-1.tcl | 4 + .../active-directory-search-for-a-user-2.tcl | 1 + .../active-directory-search-for-a-user-3.tcl | 3 + .../active-directory-search-for-a-user-4.tcl | 4 + .../active-directory-search-for-a-user-5.tcl | 5 + Task/Active-object/0DESCRIPTION | 17 ++ Task/Active-object/1META.yaml | 8 + Task/Active-object/Ada/active-object.ada | 65 +++++ Task/Active-object/C/active-object.c | 70 ++++++ Task/Active-object/Clojure/active-object.clj | 36 +++ Task/Active-object/Go/active-object.go | 80 ++++++ Task/Active-object/Haskell/active-object.hs | 77 ++++++ .../JavaScript/active-object-1.js | 26 ++ .../JavaScript/active-object-2.js | 20 ++ Task/Active-object/Perl/active-object.pl | 69 +++++ Task/Active-object/PicoLisp/active-object.l | 44 ++++ Task/Active-object/Python/active-object.py | 38 +++ Task/Active-object/Racket/active-object.rkt | 30 +++ Task/Active-object/Scala/active-object.scala | 48 ++++ Task/Active-object/Tcl/active-object.tcl | 50 ++++ .../0DESCRIPTION | 3 + .../1META.yaml | 2 + ...riable-to-a-class-instance-at-runtime-1.as | 2 + ...riable-to-a-class-instance-at-runtime-2.as | 7 + ...riable-to-a-class-instance-at-runtime-3.as | 2 + ...ariable-to-a-class-instance-at-runtime.ada | 40 +++ ...ariable-to-a-class-instance-at-runtime.ahk | 2 + ...able-to-a-class-instance-at-runtime.coffee | 18 ++ ...variable-to-a-class-instance-at-runtime.js | 3 + ...ariable-to-a-class-instance-at-runtime.lua | 2 + ...ariable-to-a-class-instance-at-runtime.php | 9 + ...variable-to-a-class-instance-at-runtime.pl | 12 + ...-variable-to-a-class-instance-at-runtime.l | 8 + ...riable-to-a-class-instance-at-runtime-1.py | 3 + ...riable-to-a-class-instance-at-runtime-2.py | 1 + ...riable-to-a-class-instance-at-runtime-3.py | 1 + ...riable-to-a-class-instance-at-runtime-4.py | 13 + ...variable-to-a-class-instance-at-runtime.rb | 12 + ...ble-to-a-class-instance-at-runtime-1.scala | 12 + ...ble-to-a-class-instance-at-runtime-2.scala | 8 + ...riable-to-a-class-instance-at-runtime-1.st | 16 ++ ...riable-to-a-class-instance-at-runtime-2.st | 6 + ...riable-to-a-class-instance-at-runtime-3.st | 15 ++ ...riable-to-a-class-instance-at-runtime-4.st | 6 + ...riable-to-a-class-instance-at-runtime-5.st | 58 +++++ ...iable-to-a-class-instance-at-runtime-1.tcl | 27 ++ ...iable-to-a-class-instance-at-runtime-2.tcl | 28 +++ Task/Address-of-a-variable/0DESCRIPTION | 1 + Task/Address-of-a-variable/1META.yaml | 2 + .../ALGOL-68/address-of-a-variable-1.alg | 4 + .../ALGOL-68/address-of-a-variable-2.alg | 1 + .../Ada/address-of-a-variable-1.ada | 3 + .../Ada/address-of-a-variable-2.ada | 2 + .../Ada/address-of-a-variable-3.ada | 3 + .../Argile/address-of-a-variable-1.argile | 6 + .../Argile/address-of-a-variable-2.argile | 3 + .../AutoHotkey/address-of-a-variable.ahk | 1 + .../BASIC/address-of-a-variable.bas | 8 + .../Fortran/address-of-a-variable.f | 10 + .../Go/address-of-a-variable-1.go | 16 ++ .../Go/address-of-a-variable-2.go | 29 +++ .../Go/address-of-a-variable-3.go | 3 + .../Perl/address-of-a-variable-1.pl | 2 + .../Perl/address-of-a-variable-2.pl | 4 + .../Perl/address-of-a-variable-3.pl | 6 + .../PicoLisp/address-of-a-variable.l | 14 ++ .../Python/address-of-a-variable.py | 2 + .../REXX/address-of-a-variable.rexx | 1 + .../Racket/address-of-a-variable-1.rkt | 6 + .../Racket/address-of-a-variable-2.rkt | 6 + .../Ruby/address-of-a-variable.rb | 3 + .../Smalltalk/address-of-a-variable-1.st | 5 + .../Smalltalk/address-of-a-variable-2.st | 4 + .../Tcl/address-of-a-variable-1.tcl | 21 ++ .../Tcl/address-of-a-variable-2.tcl | 7 + Task/Align-columns/0DESCRIPTION | 22 ++ Task/Align-columns/1META.yaml | 2 + Task/Align-columns/ABAP/align-columns.abap | 77 ++++++ Task/Align-columns/ALGOL-68/align-columns.alg | 66 +++++ Task/Align-columns/AWK/align-columns.awk | 34 +++ Task/Align-columns/Ada/align-columns.ada | 65 +++++ .../AutoHotkey/align-columns.ahk | 50 ++++ Task/Align-columns/Clojure/align-columns.clj | 41 +++ .../CoffeeScript/align-columns-1.coffee | 48 ++++ .../CoffeeScript/align-columns-2.coffee | 25 ++ Task/Align-columns/Erlang/align-columns.erl | 68 +++++ Task/Align-columns/Forth/align-columns.fth | 70 ++++++ Task/Align-columns/Go/align-columns.go | 61 +++++ Task/Align-columns/Haskell/align-columns.hs | 25 ++ .../Align-columns/JavaScript/align-columns.js | 31 +++ Task/Align-columns/Lua/align-columns-1.lua | 60 +++++ Task/Align-columns/Lua/align-columns-2.lua | 12 + Task/Align-columns/PHP/align-columns.php | 47 ++++ Task/Align-columns/Perl/align-columns-1.pl | 56 +++++ Task/Align-columns/Perl/align-columns-2.pl | 24 ++ Task/Align-columns/PicoLisp/align-columns.l | 21 ++ Task/Align-columns/Prolog/align-columns.pro | 79 ++++++ Task/Align-columns/Python/align-columns-1.py | 45 ++++ Task/Align-columns/Python/align-columns-2.py | 21 ++ Task/Align-columns/R/align-columns.r | 25 ++ Task/Align-columns/REXX/align-columns-1.rexx | 49 ++++ Task/Align-columns/REXX/align-columns-2.rexx | 35 +++ Task/Align-columns/REXX/align-columns-3.rexx | 43 ++++ Task/Align-columns/Racket/align-columns.rkt | 34 +++ Task/Align-columns/Ruby/align-columns.rb | 50 ++++ .../Align-columns/Scala/align-columns-1.scala | 28 +++ .../Align-columns/Scala/align-columns-2.scala | 22 ++ Task/Align-columns/Tcl/align-columns.tcl | 48 ++++ Task/Anagrams-Deranged-anagrams/0DESCRIPTION | 7 + .../Ada/anagrams-deranged-anagrams.ada | 45 ++++ .../C/anagrams-deranged-anagrams.c | 110 ++++++++ .../Clojure/anagrams-deranged-anagrams.clj | 5 + .../anagrams-deranged-anagrams.coffee | 39 +++ .../Go/anagrams-deranged-anagrams.go | 52 ++++ .../Haskell/anagrams-deranged-anagrams.hs | 35 +++ .../Java/anagrams-deranged-anagrams.java | 62 +++++ .../anagrams-deranged-anagrams-1.js | 75 ++++++ .../anagrams-deranged-anagrams-2.js | 45 ++++ .../PHP/anagrams-deranged-anagrams.php | 51 ++++ .../Perl/anagrams-deranged-anagrams.pl | 37 +++ .../PicoLisp/anagrams-deranged-anagrams.l | 19 ++ .../Prolog/anagrams-deranged-anagrams.pro | 58 +++++ .../Python/anagrams-deranged-anagrams-1.py | 39 +++ .../Python/anagrams-deranged-anagrams-2.py | 27 ++ .../R/anagrams-deranged-anagrams-1.r | 25 ++ .../R/anagrams-deranged-anagrams-2.r | 3 + .../REXX/anagrams-deranged-anagrams.rexx | 40 +++ .../Ruby/anagrams-deranged-anagrams.rb | 46 ++++ .../Scala/anagrams-deranged-anagrams.scala | 34 +++ .../Tcl/anagrams-deranged-anagrams.tcl | 53 ++++ Task/Animation/0DESCRIPTION | 3 + Task/Animation/1META.yaml | 6 + Task/Animation/ActionScript/animation.as | 21 ++ Task/Animation/Ada/animation.ada | 92 +++++++ Task/Animation/AutoHotkey/animation.ahk | 15 ++ Task/Animation/C/animation.c | 72 ++++++ Task/Animation/Clojure/animation.clj | 33 +++ Task/Animation/Haskell/animation-1.hs | 26 ++ Task/Animation/Haskell/animation-2.hs | 1 + Task/Animation/Java/animation.java | 59 +++++ Task/Animation/JavaScript/animation.js | 23 ++ Task/Animation/Perl/animation.pl | 11 + Task/Animation/PicoLisp/animation-1.l | 14 ++ Task/Animation/PicoLisp/animation-2.l | 18 ++ Task/Animation/PicoLisp/animation-3.l | 22 ++ Task/Animation/Prolog/animation.pro | 74 ++++++ Task/Animation/Python/animation-1.py | 55 ++++ Task/Animation/Python/animation-2.py | 23 ++ Task/Animation/R/animation.r | 39 +++ Task/Animation/Racket/animation.rkt | 40 +++ Task/Animation/Ruby/animation-1.rb | 27 ++ Task/Animation/Ruby/animation-2.rb | 11 + Task/Animation/Scala/animation.scala | 32 +++ Task/Animation/Tcl/animation.tcl | 20 ++ Task/Anonymous-recursion/0DESCRIPTION | 15 ++ Task/Anonymous-recursion/1META.yaml | 2 + .../Ada/anonymous-recursion.ada | 16 ++ .../AutoHotkey/anonymous-recursion-1.ahk | 8 + .../AutoHotkey/anonymous-recursion-2.ahk | 3 + .../Axiom/anonymous-recursion-1.axiom | 10 + .../Axiom/anonymous-recursion-2.axiom | 10 + .../C/anonymous-recursion.c | 29 +++ .../Clojure/anonymous-recursion.clj | 7 + .../CoffeeScript/anonymous-recursion.coffee | 17 ++ .../Dylan/anonymous-recursion.dylan | 13 + .../Forth/anonymous-recursion-1.fth | 7 + .../Forth/anonymous-recursion-2.fth | 5 + .../Fortran/anonymous-recursion.f | 18 ++ .../Go/anonymous-recursion.go | 47 ++++ .../Haskell/anonymous-recursion-1.hs | 7 + .../Haskell/anonymous-recursion-2.hs | 6 + .../Haskell/anonymous-recursion-3.hs | 2 + .../Java/anonymous-recursion-1.java | 9 + .../Java/anonymous-recursion-2.java | 24 ++ .../JavaScript/anonymous-recursion-1.js | 11 + .../JavaScript/anonymous-recursion-2.js | 11 + .../Lua/anonymous-recursion-1.lua | 7 + .../Lua/anonymous-recursion-2.lua | 4 + .../PHP/anonymous-recursion-1.php | 13 + .../PHP/anonymous-recursion-2.php | 14 ++ .../Perl/anonymous-recursion-1.pl | 14 ++ .../Perl/anonymous-recursion-2.pl | 13 + .../Perl/anonymous-recursion-3.pl | 6 + .../Perl/anonymous-recursion-4.pl | 5 + .../PicoLisp/anonymous-recursion-1.l | 7 + .../PicoLisp/anonymous-recursion-2.l | 2 + .../Prolog/anonymous-recursion.pro | 23 ++ .../Python/anonymous-recursion-1.py | 4 + .../Python/anonymous-recursion-2.py | 4 + .../Python/anonymous-recursion-3.py | 5 + .../R/anonymous-recursion.r | 4 + .../REXX/anonymous-recursion.rexx | 11 + .../Racket/anonymous-recursion-1.rkt | 18 ++ .../Racket/anonymous-recursion-2.rkt | 20 ++ .../Ruby/anonymous-recursion-1.rb | 4 + .../Ruby/anonymous-recursion-2.rb | 2 + .../Ruby/anonymous-recursion-3.rb | 4 + .../Ruby/anonymous-recursion-4.rb | 7 + .../Ruby/anonymous-recursion-5.rb | 5 + .../Ruby/anonymous-recursion-6.rb | 20 ++ .../Ruby/anonymous-recursion-7.rb | 32 +++ .../Scala/anonymous-recursion.scala | 9 + .../Scheme/anonymous-recursion.ss | 9 + .../Tcl/anonymous-recursion-1.tcl | 10 + .../Tcl/anonymous-recursion-2.tcl | 1 + .../Tcl/anonymous-recursion-3.tcl | 9 + .../Tcl/anonymous-recursion-4.tcl | 8 + .../Apply-a-callback-to-an-array/0DESCRIPTION | 1 + Task/Apply-a-callback-to-an-array/1META.yaml | 4 + .../ACL2/apply-a-callback-to-an-array.acl2 | 5 + .../ALGOL-68/apply-a-callback-to-an-array.alg | 17 ++ .../AWK/apply-a-callback-to-an-array.awk | 6 + .../apply-a-callback-to-an-array.as | 19 ++ .../Ada/apply-a-callback-to-an-array.ada | 37 +++ .../Aime/apply-a-callback-to-an-array.aime | 35 +++ .../apply-a-callback-to-an-array.ahk | 10 + .../C/apply-a-callback-to-an-array-1.c | 16 ++ .../C/apply-a-callback-to-an-array-2.c | 27 ++ .../apply-a-callback-to-an-array-1.clj | 2 + .../apply-a-callback-to-an-array-2.clj | 2 + .../apply-a-callback-to-an-array-3.clj | 2 + .../apply-a-callback-to-an-array.coffee | 4 + .../Erlang/apply-a-callback-to-an-array-1.erl | 2 + .../Erlang/apply-a-callback-to-an-array-2.erl | 2 + .../Erlang/apply-a-callback-to-an-array-3.erl | 2 + .../Erlang/apply-a-callback-to-an-array-4.erl | 2 + .../Forth/apply-a-callback-to-an-array-1.fth | 2 + .../Forth/apply-a-callback-to-an-array-2.fth | 2 + .../Fortran/apply-a-callback-to-an-array-1.f | 9 + .../Fortran/apply-a-callback-to-an-array-2.f | 17 ++ .../Fortran/apply-a-callback-to-an-array-3.f | 14 ++ .../Go/apply-a-callback-to-an-array-1.go | 9 + .../Go/apply-a-callback-to-an-array-2.go | 31 +++ .../Haskell/apply-a-callback-to-an-array-1.hs | 3 + .../Haskell/apply-a-callback-to-an-array-2.hs | 1 + .../Haskell/apply-a-callback-to-an-array-3.hs | 2 + .../Haskell/apply-a-callback-to-an-array-4.hs | 4 + .../Java/apply-a-callback-to-an-array-1.java | 11 + .../Java/apply-a-callback-to-an-array-2.java | 13 + .../apply-a-callback-to-an-array-1.js | 7 + .../apply-a-callback-to-an-array-2.js | 1 + .../apply-a-callback-to-an-array-3.js | 15 ++ .../apply-a-callback-to-an-array-4.js | 1 + .../Lua/apply-a-callback-to-an-array-1.lua | 1 + .../Lua/apply-a-callback-to-an-array-2.lua | 7 + .../Lua/apply-a-callback-to-an-array-3.lua | 4 + .../PHP/apply-a-callback-to-an-array.php | 8 + .../Perl/apply-a-callback-to-an-array.pl | 30 +++ .../PicoLisp/apply-a-callback-to-an-array.l | 16 ++ .../Prolog/apply-a-callback-to-an-array.pro | 5 + .../Python/apply-a-callback-to-an-array-1.py | 18 ++ .../Python/apply-a-callback-to-an-array-2.py | 1 + .../Python/apply-a-callback-to-an-array-3.py | 1 + .../Python/apply-a-callback-to-an-array-4.py | 1 + .../R/apply-a-callback-to-an-array-1.r | 3 + .../R/apply-a-callback-to-an-array-2.r | 5 + .../R/apply-a-callback-to-an-array-3.r | 2 + .../REXX/apply-a-callback-to-an-array.rexx | 29 +++ .../Racket/apply-a-callback-to-an-array.rkt | 7 + .../Ruby/apply-a-callback-to-an-array-1.rb | 3 + .../Ruby/apply-a-callback-to-an-array-2.rb | 1 + .../Ruby/apply-a-callback-to-an-array-3.rb | 1 + .../Sather/apply-a-callback-to-an-array.sa | 12 + .../apply-a-callback-to-an-array-1.scala | 2 + .../apply-a-callback-to-an-array-2.scala | 1 + .../apply-a-callback-to-an-array-3.scala | 3 + .../apply-a-callback-to-an-array-4.scala | 2 + .../apply-a-callback-to-an-array-5.scala | 1 + .../apply-a-callback-to-an-array-6.scala | 1 + .../apply-a-callback-to-an-array-7.scala | 1 + .../Scheme/apply-a-callback-to-an-array-1.ss | 3 + .../Scheme/apply-a-callback-to-an-array-2.ss | 1 + .../Scheme/apply-a-callback-to-an-array-3.ss | 4 + .../Smalltalk/apply-a-callback-to-an-array.st | 1 + .../Tcl/apply-a-callback-to-an-array-1.tcl | 3 + .../Tcl/apply-a-callback-to-an-array-2.tcl | 3 + .../Tcl/apply-a-callback-to-an-array-3.tcl | 9 + .../0DESCRIPTION | 11 + .../1META.yaml | 2 + ...bitrary-precision-integers-(included).acl2 | 19 ++ ...rbitrary-precision-integers-(included).ada | 16 ++ ...itrary-precision-integers-(included).alore | 9 + ...rbitrary-precision-integers-(included)-1.c | 21 ++ ...rbitrary-precision-integers-(included)-2.c | 65 +++++ ...itrary-precision-integers-(included)-1.clj | 12 + ...itrary-precision-integers-(included)-2.clj | 5 + ...rbitrary-precision-integers-(included).erl | 20 ++ ...arbitrary-precision-integers-(included).go | 18 ++ ...arbitrary-precision-integers-(included).hs | 4 + ...bitrary-precision-integers-(included).java | 11 + ...rbitrary-precision-integers-(included).php | 4 + ...bitrary-precision-integers-(included)-1.pl | 4 + ...bitrary-precision-integers-(included)-2.pl | 4 + ...bitrary-precision-integers-(included)-3.pl | 3 + .../arbitrary-precision-integers-(included).l | 3 + ...arbitrary-precision-integers-(included).py | 3 + .../arbitrary-precision-integers-(included).r | 6 + ...trary-precision-integers-(included)-1.rexx | 12 + ...trary-precision-integers-(included)-2.rexx | 21 ++ ...rbitrary-precision-integers-(included).rkt | 9 + ...arbitrary-precision-integers-(included).rb | 2 + ...arbitrary-precision-integers-(included).sa | 22 ++ ...itrary-precision-integers-(included).scala | 21 ++ ...arbitrary-precision-integers-(included).ss | 5 + ...bitrary-precision-integers-(included)-1.st | 5 + ...bitrary-precision-integers-(included)-2.st | 7 + ...rbitrary-precision-integers-(included).tcl | 7 + Task/Arena-storage-pool/0DESCRIPTION | 16 ++ Task/Arena-storage-pool/1META.yaml | 3 + .../Ada/arena-storage-pool-1.ada | 2 + .../Ada/arena-storage-pool-2.ada | 27 ++ .../Ada/arena-storage-pool-3.ada | 22 ++ .../Ada/arena-storage-pool-4.ada | 15 ++ .../C/arena-storage-pool-1.c | 1 + .../C/arena-storage-pool-2.c | 3 + .../C/arena-storage-pool-3.c | 3 + .../C/arena-storage-pool-4.c | 6 + .../C/arena-storage-pool-5.c | 1 + .../C/arena-storage-pool-6.c | 1 + .../REXX/arena-storage-pool.rexx | 11 + .../Tcl/arena-storage-pool-1.tcl | 81 ++++++ .../Tcl/arena-storage-pool-2.tcl | 53 ++++ Task/Arithmetic-Complex/0DESCRIPTION | 6 + Task/Arithmetic-Complex/1META.yaml | 2 + .../ALGOL-68/arithmetic-complex.alg | 27 ++ .../APL/arithmetic-complex.apl | 10 + .../Ada/arithmetic-complex.ada | 46 ++++ .../AutoHotkey/arithmetic-complex.ahk | 47 ++++ .../BASIC/arithmetic-complex.bas | 46 ++++ .../C/arithmetic-complex-1.c | 32 +++ .../C/arithmetic-complex-2.c | 61 +++++ .../CoffeeScript/arithmetic-complex-1.coffee | 60 +++++ .../CoffeeScript/arithmetic-complex-2.coffee | 7 + .../Erlang/arithmetic-complex-1.erl | 58 +++++ .../Erlang/arithmetic-complex-2.erl | 5 + .../Forth/arithmetic-complex.fth | 13 + .../Fortran/arithmetic-complex-1.f | 9 + .../Fortran/arithmetic-complex-2.f | 28 +++ .../Go/arithmetic-complex.go | 18 ++ .../Haskell/arithmetic-complex-1.hs | 14 ++ .../Haskell/arithmetic-complex-2.hs | 8 + .../Java/arithmetic-complex.java | 44 ++++ .../JavaScript/arithmetic-complex.js | 55 ++++ .../Lua/arithmetic-complex.lua | 31 +++ .../Perl/arithmetic-complex.pl | 10 + .../PicoLisp/arithmetic-complex.l | 42 ++++ .../Python/arithmetic-complex.py | 23 ++ .../Arithmetic-Complex/R/arithmetic-complex.r | 13 + .../REXX/arithmetic-complex.rexx | 25 ++ .../Racket/arithmetic-complex.rkt | 12 + .../Ruby/arithmetic-complex-1.rb | 14 ++ .../Ruby/arithmetic-complex-2.rb | 4 + .../Scala/arithmetic-complex-1.scala | 35 +++ .../Scala/arithmetic-complex-2.scala | 26 ++ .../Scheme/arithmetic-complex.ss | 7 + .../Smalltalk/arithmetic-complex.st | 13 + .../Tcl/arithmetic-complex.tcl | 9 + Task/Arithmetic-Rational/0DESCRIPTION | 16 ++ Task/Arithmetic-Rational/1META.yaml | 4 + .../ALGOL-68/arithmetic-rational.alg | 131 ++++++++++ .../C/arithmetic-rational.c | 69 +++++ .../Clojure/arithmetic-rational.clj | 6 + .../Forth/arithmetic-rational.fth | 38 +++ .../Fortran/arithmetic-rational-1.f | 236 ++++++++++++++++++ .../Fortran/arithmetic-rational-2.f | 28 +++ .../Go/arithmetic-rational.go | 32 +++ .../Haskell/arithmetic-rational.hs | 10 + .../Java/arithmetic-rational.java | 30 +++ .../Lua/arithmetic-rational.lua | 58 +++++ .../Perl/arithmetic-rational.pl | 13 + .../PicoLisp/arithmetic-rational.l | 14 ++ .../Python/arithmetic-rational-1.py | 10 + .../Python/arithmetic-rational-2.py | 33 +++ .../REXX/arithmetic-rational.rexx | 92 +++++++ .../Ruby/arithmetic-rational.rb | 14 ++ .../Scala/arithmetic-rational-1.scala | 44 ++++ .../Scala/arithmetic-rational-2.scala | 15 ++ .../Scheme/arithmetic-rational.ss | 8 + .../Smalltalk/arithmetic-rational.st | 18 ++ Task/Arithmetic-evaluation/0DESCRIPTION | 20 ++ Task/Arithmetic-evaluation/1META.yaml | 3 + .../ALGOL-68/arithmetic-evaluation.alg | 142 +++++++++++ .../AutoHotkey/arithmetic-evaluation-1.ahk | 150 +++++++++++ .../AutoHotkey/arithmetic-evaluation-2.ahk | 67 +++++ .../Clojure/arithmetic-evaluation.clj | 53 ++++ .../Haskell/arithmetic-evaluation.hs | 29 +++ .../Java/arithmetic-evaluation.java | 138 ++++++++++ .../JavaScript/arithmetic-evaluation.js | 55 ++++ .../Lua/arithmetic-evaluation.lua | 40 +++ .../Perl/arithmetic-evaluation.pl | 61 +++++ .../PicoLisp/arithmetic-evaluation-1.l | 23 ++ .../PicoLisp/arithmetic-evaluation-2.l | 5 + .../Prolog/arithmetic-evaluation.pro | 50 ++++ .../Python/arithmetic-evaluation-1.py | 116 +++++++++ .../Python/arithmetic-evaluation-2.py | 24 ++ .../REXX/arithmetic-evaluation.rexx | 117 +++++++++ .../Ruby/arithmetic-evaluation-1.rb | 96 +++++++ .../Ruby/arithmetic-evaluation-2.rb | 8 + .../Scala/arithmetic-evaluation.scala | 46 ++++ .../Tcl/arithmetic-evaluation.tcl | 44 ++++ Task/Arithmetic-geometric-mean/0DESCRIPTION | 10 + .../Ada/arithmetic-geometric-mean.ada | 26 ++ .../AutoHotkey/arithmetic-geometric-mean.ahk | 11 + .../C/arithmetic-geometric-mean.c | 32 +++ .../Erlang/arithmetic-geometric-mean-1.erl | 19 ++ .../Erlang/arithmetic-geometric-mean-2.erl | 1 + .../Fortran/arithmetic-geometric-mean.f | 15 ++ .../Go/arithmetic-geometric-mean-1.go | 19 ++ .../Go/arithmetic-geometric-mean-2.go | 21 ++ .../Haskell/arithmetic-geometric-mean.hs | 17 ++ .../Java/arithmetic-geometric-mean.java | 25 ++ .../PHP/arithmetic-geometric-mean.php | 22 ++ .../Perl/arithmetic-geometric-mean.pl | 17 ++ .../PicoLisp/arithmetic-geometric-mean.l | 10 + .../Python/arithmetic-geometric-mean-1.py | 16 ++ .../Python/arithmetic-geometric-mean-2.py | 10 + .../R/arithmetic-geometric-mean-1.r | 14 ++ .../R/arithmetic-geometric-mean-2.r | 4 + .../REXX/arithmetic-geometric-mean.rexx | 29 +++ .../Racket/arithmetic-geometric-mean-1.rkt | 7 + .../Racket/arithmetic-geometric-mean-2.rkt | 4 + .../Ruby/arithmetic-geometric-mean.rb | 22 ++ .../Scala/arithmetic-geometric-mean.scala | 6 + .../Tcl/arithmetic-geometric-mean.tcl | 10 + Task/Array-concatenation/0DESCRIPTION | 1 + Task/Array-concatenation/1META.yaml | 2 + .../ACL2/array-concatenation.acl2 | 1 + .../ALGOL-68/array-concatenation.alg | 30 +++ .../APL/array-concatenation.apl | 2 + .../ActionScript/array-concatenation.as | 3 + .../Ada/array-concatenation.ada | 3 + .../AutoHotkey/array-concatenation-1.ahk | 18 ++ .../AutoHotkey/array-concatenation-2.ahk | 37 +++ .../AutoIt/array-concatenation.autoit | 18 ++ .../Babel/array-concatenation.pb | 1 + .../C/array-concatenation.c | 32 +++ .../Clojure/array-concatenation.clj | 1 + .../CoffeeScript/array-concatenation.coffee | 4 + .../Erlang/array-concatenation.erl | 5 + .../Forth/array-concatenation.fth | 13 + .../Fortran/array-concatenation.f | 14 ++ .../Go/array-concatenation-1.go | 35 +++ .../Go/array-concatenation-2.go | 57 +++++ .../Haskell/array-concatenation.hs | 1 + .../Java/array-concatenation-1.java | 9 + .../Java/array-concatenation-2.java | 4 + .../JavaScript/array-concatenation.js | 4 + .../Lua/array-concatenation.lua | 4 + .../PHP/array-concatenation.php | 3 + .../Perl/array-concatenation-1.pl | 3 + .../Perl/array-concatenation-2.pl | 4 + .../PicoLisp/array-concatenation-1.l | 6 + .../PicoLisp/array-concatenation-2.l | 8 + .../Prolog/array-concatenation.pro | 2 + .../Python/array-concatenation-1.py | 7 + .../Python/array-concatenation-2.py | 4 + .../R/array-concatenation.r | 3 + .../REXX/array-concatenation-1.rexx | 3 + .../REXX/array-concatenation-2.rexx | 9 + .../REXX/array-concatenation-3.rexx | 22 ++ .../Racket/array-concatenation.rkt | 1 + .../Ruby/array-concatenation.rb | 5 + .../Scala/array-concatenation.scala | 8 + .../Scheme/array-concatenation.ss | 5 + .../Smalltalk/array-concatenation.st | 5 + .../Tcl/array-concatenation.tcl | 3 + Task/Associative-array-Creation/0DESCRIPTION | 5 + Task/Associative-array-Creation/1META.yaml | 4 + .../ALGOL-68/associative-array-creation.alg | 70 ++++++ .../APL/associative-array-creation.apl | 21 ++ .../AWK/associative-array-creation.awk | 16 ++ .../associative-array-creation.as | 9 + .../Ada/associative-array-creation.ada | 33 +++ .../Aikido/associative-array-creation.aikido | 17 ++ .../associative-array-creation-1.ahk | 3 + .../associative-array-creation-2.ahk | 6 + .../Clojure/associative-array-creation.clj | 3 + .../Erlang/associative-array-creation.erl | 14 ++ .../Forth/associative-array-creation-1.fth | 21 ++ .../Forth/associative-array-creation-2.fth | 19 ++ .../Go/associative-array-creation.go | 16 ++ .../Haskell/associative-array-creation-1.hs | 5 + .../Haskell/associative-array-creation-2.hs | 3 + .../Java/associative-array-creation-1.java | 5 + .../Java/associative-array-creation-2.java | 6 + .../Java/associative-array-creation-3.java | 2 + .../Java/associative-array-creation-4.java | 2 + .../Java/associative-array-creation-5.java | 2 + .../Java/associative-array-creation-6.java | 2 + .../associative-array-creation-1.js | 14 ++ .../associative-array-creation-2.js | 4 + .../associative-array-creation-3.js | 1 + .../Lua/associative-array-creation.lua | 4 + .../PHP/associative-array-creation-1.php | 11 + .../PHP/associative-array-creation-2.php | 4 + .../Perl/associative-array-creation-1.pl | 15 ++ .../Perl/associative-array-creation-2.pl | 5 + .../Perl/associative-array-creation-3.pl | 6 + .../Perl/associative-array-creation-4.pl | 5 + .../PicoLisp/associative-array-creation.l | 16 ++ .../Prolog/associative-array-creation.pro | 5 + .../Python/associative-array-creation-1.py | 4 + .../Python/associative-array-creation-2.py | 20 ++ .../Python/associative-array-creation-3.py | 1 + .../R/associative-array-creation-1.r | 3 + .../R/associative-array-creation-10.r | 1 + .../R/associative-array-creation-11.r | 1 + .../R/associative-array-creation-2.r | 3 + .../R/associative-array-creation-3.r | 1 + .../R/associative-array-creation-4.r | 1 + .../R/associative-array-creation-5.r | 1 + .../R/associative-array-creation-6.r | 2 + .../R/associative-array-creation-7.r | 1 + .../R/associative-array-creation-8.r | 1 + .../R/associative-array-creation-9.r | 2 + .../REXX/associative-array-creation-1.rexx | 10 + .../REXX/associative-array-creation-2.rexx | 27 ++ .../Racket/associative-array-creation.rkt | 13 + .../Ruby/associative-array-creation-1.rb | 4 + .../Ruby/associative-array-creation-2.rb | 4 + .../Ruby/associative-array-creation-3.rb | 4 + .../Ruby/associative-array-creation-4.rb | 4 + .../Sather/associative-array-creation.sa | 20 ++ .../Scala/associative-array-creation-1.scala | 6 + .../Scala/associative-array-creation-2.scala | 10 + .../Scala/associative-array-creation-3.scala | 4 + .../Scala/associative-array-creation-4.scala | 4 + .../Scheme/associative-array-creation-1.ss | 2 + .../Scheme/associative-array-creation-2.ss | 2 + .../Smalltalk/associative-array-creation.st | 3 + .../Tcl/associative-array-creation-1.tcl | 17 ++ .../Tcl/associative-array-creation-2.tcl | 20 ++ Task/Associative-array-Iteration/0DESCRIPTION | 3 + Task/Associative-array-Iteration/1META.yaml | 5 + .../AWK/associative-array-iteration.awk | 10 + .../Ada/associative-array-iteration.ada | 19 ++ .../associative-array-iteration.ahk | 6 + .../Clojure/associative-array-iteration.clj | 8 + .../associative-array-iteration.coffee | 9 + .../Erlang/associative-array-iteration.erl | 13 + .../Forth/associative-array-iteration.fth | 22 ++ .../Go/associative-array-iteration.go | 19 ++ .../Haskell/associative-array-iteration.hs | 10 + .../Java/associative-array-iteration.java | 21 ++ .../associative-array-iteration-1.js | 15 ++ .../associative-array-iteration-2.js | 13 + .../Lua/associative-array-iteration.lua | 8 + .../PHP/associative-array-iteration.php | 20 ++ .../Perl/associative-array-iteration.pl | 32 +++ .../PicoLisp/associative-array-iteration-1.l | 12 + .../PicoLisp/associative-array-iteration-2.l | 12 + .../Python/associative-array-iteration.py | 18 ++ .../R/associative-array-iteration-1.r | 3 + .../R/associative-array-iteration-2.r | 5 + .../R/associative-array-iteration-3.r | 2 + .../R/associative-array-iteration-4.r | 1 + .../R/associative-array-iteration-5.r | 2 + .../R/associative-array-iteration-6.r | 1 + .../REXX/associative-array-iteration.rexx | 59 +++++ .../Racket/associative-array-iteration.rkt | 10 + .../Ruby/associative-array-iteration.rb | 14 ++ .../Scala/associative-array-iteration.scala | 13 + .../associative-array-iteration-1.st | 18 ++ .../associative-array-iteration-2.st | 2 + .../Tcl/associative-array-iteration-1.tcl | 16 ++ .../Tcl/associative-array-iteration-2.tcl | 16 ++ Task/Atomic-updates/0DESCRIPTION | 16 ++ Task/Atomic-updates/1META.yaml | 4 + Task/Atomic-updates/Ada/atomic-updates.ada | 85 +++++++ Task/Atomic-updates/C/atomic-updates-1.c | 111 ++++++++ Task/Atomic-updates/C/atomic-updates-2.c | 51 ++++ Task/Atomic-updates/C/atomic-updates-3.c | 8 + .../Clojure/atomic-updates-1.clj | 7 + .../Clojure/atomic-updates-2.clj | 2 + .../Clojure/atomic-updates-3.clj | 22 ++ Task/Atomic-updates/Go/atomic-updates-1.go | 106 ++++++++ Task/Atomic-updates/Go/atomic-updates-2.go | 78 ++++++ Task/Atomic-updates/Go/atomic-updates-3.go | 83 ++++++ Task/Atomic-updates/Go/atomic-updates-4.go | 63 +++++ Task/Atomic-updates/Go/atomic-updates-5.go | 109 ++++++++ Task/Atomic-updates/Haskell/atomic-updates.hs | 69 +++++ Task/Atomic-updates/Java/atomic-updates.java | 119 +++++++++ Task/Atomic-updates/Perl/atomic-updates.pl | 52 ++++ Task/Atomic-updates/PicoLisp/atomic-updates.l | 71 ++++++ Task/Atomic-updates/Python/atomic-updates.py | 74 ++++++ Task/Atomic-updates/Ruby/atomic-updates.rb | 94 +++++++ .../Atomic-updates/Scala/atomic-updates.scala | 75 ++++++ Task/Atomic-updates/Tcl/atomic-updates.tcl | 102 ++++++++ Task/Average-loop-length/0DESCRIPTION | 32 +++ .../Ada/average-loop-length.ada | 53 ++++ .../C/average-loop-length.c | 56 +++++ .../Python/average-loop-length.py | 27 ++ .../REXX/average-loop-length.rexx | 36 +++ .../Tcl/average-loop-length.tcl | 40 +++ Task/Averages-Arithmetic-mean/0DESCRIPTION | 3 + Task/Averages-Arithmetic-mean/1META.yaml | 2 + .../averages-arithmetic-mean.6502 | 40 +++ .../ACL2/averages-arithmetic-mean.acl2 | 13 + .../ALGOL-68/averages-arithmetic-mean.alg | 13 + .../APL/averages-arithmetic-mean.apl | 3 + .../AWK/averages-arithmetic-mean.awk | 27 ++ .../ActionScript/averages-arithmetic-mean.as | 7 + .../Ada/averages-arithmetic-mean.ada | 25 ++ .../AmigaE/averages-arithmetic-mean.amiga | 14 ++ .../AutoHotkey/averages-arithmetic-mean.ahk | 7 + .../BASIC/averages-arithmetic-mean.bas | 12 + .../Befunge/averages-arithmetic-mean.bf | 3 + .../C/averages-arithmetic-mean.c | 24 ++ .../Clojure/averages-arithmetic-mean.clj | 6 + .../averages-arithmetic-mean.coffee | 7 + .../Erlang/averages-arithmetic-mean.erl | 2 + .../Forth/averages-arithmetic-mean.fth | 10 + .../Fortran/averages-arithmetic-mean.f | 20 ++ .../Go/averages-arithmetic-mean.go | 65 +++++ .../Haskell/averages-arithmetic-mean-1.hs | 3 + .../Haskell/averages-arithmetic-mean-2.hs | 2 + .../Haskell/averages-arithmetic-mean-3.hs | 5 + .../Java/averages-arithmetic-mean.java | 7 + .../JavaScript/averages-arithmetic-mean-1.js | 11 + .../JavaScript/averages-arithmetic-mean-2.js | 4 + .../Lua/averages-arithmetic-mean.lua | 8 + .../PHP/averages-arithmetic-mean.php | 5 + .../Perl/averages-arithmetic-mean-1.pl | 8 + .../Perl/averages-arithmetic-mean-2.pl | 5 + .../PicoLisp/averages-arithmetic-mean.l | 4 + .../Python/averages-arithmetic-mean-1.py | 5 + .../Python/averages-arithmetic-mean-2.py | 2 + .../Python/averages-arithmetic-mean-3.py | 4 + .../Python/averages-arithmetic-mean-4.py | 2 + .../Python/averages-arithmetic-mean-5.py | 6 + .../Python/averages-arithmetic-mean-6.py | 1 + .../R/averages-arithmetic-mean.r | 4 + .../REXX/averages-arithmetic-mean.rexx | 20 ++ .../Racket/averages-arithmetic-mean.rkt | 6 + .../Ruby/averages-arithmetic-mean.rb | 2 + .../Sather/averages-arithmetic-mean.sa | 14 ++ .../Scala/averages-arithmetic-mean-1.scala | 1 + .../Scala/averages-arithmetic-mean-2.scala | 4 + .../Scala/averages-arithmetic-mean-3.scala | 1 + .../Scheme/averages-arithmetic-mean.ss | 4 + .../Smalltalk/averages-arithmetic-mean-1.st | 8 + .../Smalltalk/averages-arithmetic-mean-2.st | 4 + .../Smalltalk/averages-arithmetic-mean-3.st | 4 + .../Smalltalk/averages-arithmetic-mean-4.st | 4 + .../Tcl/averages-arithmetic-mean.tcl | 6 + Task/Averages-Mean-angle/0DESCRIPTION | 23 ++ .../Ada/averages-mean-angle.ada | 34 +++ .../C/averages-mean-angle.c | 30 +++ .../Go/averages-mean-angle.go | 22 ++ .../Haskell/averages-mean-angle.hs | 6 + .../PicoLisp/averages-mean-angle.l | 14 ++ .../Python/averages-mean-angle.py | 12 + .../REXX/averages-mean-angle.rexx | 57 +++++ .../Racket/averages-mean-angle.rkt | 15 ++ .../Ruby/averages-mean-angle.rb | 17 ++ .../Tcl/averages-mean-angle-1.tcl | 10 + .../Tcl/averages-mean-angle-2.tcl | 9 + Task/Averages-Mean-time-of-day/0DESCRIPTION | 3 + Task/Averages-Mean-time-of-day/1META.yaml | 2 + .../C/averages-mean-time-of-day.c | 72 ++++++ .../Go/averages-mean-time-of-day.go | 50 ++++ .../PicoLisp/averages-mean-time-of-day-1.l | 10 + .../PicoLisp/averages-mean-time-of-day-2.l | 2 + .../Python/averages-mean-time-of-day.py | 24 ++ .../Tcl/averages-mean-time-of-day.tcl | 18 ++ Task/Averages-Median/0DESCRIPTION | 5 + Task/Averages-Median/1META.yaml | 2 + Task/Averages-Median/AWK/averages-median.awk | 46 ++++ Task/Averages-Median/Ada/averages-median.ada | 31 +++ .../AppleScript/averages-median.applescript | 44 ++++ .../AutoHotkey/averages-median.ahk | 10 + .../Averages-Median/BASIC/averages-median.bas | 30 +++ Task/Averages-Median/C/averages-median-1.c | 32 +++ Task/Averages-Median/C/averages-median-2.c | 63 +++++ .../Clojure/averages-median.clj | 7 + .../Erlang/averages-median.erl | 10 + .../Forth/averages-median-1.fth | 30 +++ .../Forth/averages-median-2.fth | 4 + .../Averages-Median/Fortran/averages-median.f | 43 ++++ Task/Averages-Median/Go/averages-median.go | 21 ++ .../Haskell/averages-median-1.hs | 8 + .../Haskell/averages-median-2.hs | 2 + .../Java/averages-median-1.java | 5 + .../Java/averages-median-2.java | 10 + .../JavaScript/averages-median.js | 15 ++ Task/Averages-Median/Lua/averages-median.lua | 9 + Task/Averages-Median/PHP/averages-median.php | 17 ++ Task/Averages-Median/Perl/averages-median.pl | 3 + .../PicoLisp/averages-median.l | 12 + .../Prolog/averages-median.pro | 9 + .../Averages-Median/Python/averages-median.py | 9 + Task/Averages-Median/R/averages-median.r | 20 ++ .../Averages-Median/REXX/averages-median.rexx | 33 +++ .../Racket/averages-median.rkt | 14 ++ .../Averages-Median/Ruby/averages-median-1.rb | 14 ++ .../Averages-Median/Ruby/averages-median-2.rb | 5 + .../Scala/averages-median.scala | 5 + .../Scheme/averages-median-1.ss | 3 + .../Scheme/averages-median-2.ss | 3 + .../Smalltalk/averages-median-1.st | 13 + .../Smalltalk/averages-median-2.st | 4 + Task/Averages-Median/Tcl/averages-median.tcl | 16 ++ Task/Averages-Mode/0DESCRIPTION | 5 + Task/Averages-Mode/1META.yaml | 2 + Task/Averages-Pythagorean-means/0DESCRIPTION | 12 + .../ALGOL-68/averages-pythagorean-means.alg | 26 ++ .../APL/averages-pythagorean-means.apl | 13 + .../AWK/averages-pythagorean-means.awk | 14 ++ .../averages-pythagorean-means.as | 25 ++ .../Ada/averages-pythagorean-means-1.ada | 6 + .../Ada/averages-pythagorean-means-2.ada | 33 +++ .../Ada/averages-pythagorean-means-3.ada | 13 + .../AutoHotkey/averages-pythagorean-means.ahk | 41 +++ .../C/averages-pythagorean-means.c | 23 ++ .../Clojure/averages-pythagorean-means.clj | 15 ++ .../Erlang/averages-pythagorean-means-1.erl | 35 +++ .../Erlang/averages-pythagorean-means-2.erl | 3 + .../Forth/averages-pythagorean-means.fth | 27 ++ .../Fortran/averages-pythagorean-means.f | 16 ++ .../Go/averages-pythagorean-means.go | 18 ++ .../Haskell/averages-pythagorean-means.hs | 11 + .../Java/averages-pythagorean-means.java | 41 +++ .../JavaScript/averages-pythagorean-means.js | 21 ++ .../Lua/averages-pythagorean-means.lua | 12 + .../Perl/averages-pythagorean-means.pl | 26 ++ .../PicoLisp/averages-pythagorean-means.l | 15 ++ .../Python/averages-pythagorean-means.py | 16 ++ .../R/averages-pythagorean-means-1.r | 1 + .../R/averages-pythagorean-means-2.r | 1 + .../R/averages-pythagorean-means-3.r | 1 + .../R/averages-pythagorean-means-4.r | 1 + .../R/averages-pythagorean-means-5.r | 1 + .../R/averages-pythagorean-means-6.r | 1 + .../R/averages-pythagorean-means-7.r | 1 + .../REXX/averages-pythagorean-means.rexx | 68 +++++ .../Racket/averages-pythagorean-means.rkt | 19 ++ .../Ruby/averages-pythagorean-means.rb | 28 +++ .../Scala/averages-pythagorean-means.scala | 15 ++ .../Scheme/averages-pythagorean-means-1.ss | 23 ++ .../Scheme/averages-pythagorean-means-2.ss | 2 + .../Smalltalk/averages-pythagorean-means.st | 27 ++ .../Tcl/averages-pythagorean-means.tcl | 23 ++ Task/Averages-Root-mean-square/0DESCRIPTION | 8 + .../ALGOL-68/averages-root-mean-square.alg | 28 +++ .../APL/averages-root-mean-square.apl | 5 + .../AWK/averages-root-mean-square.awk | 11 + .../Ada/averages-root-mean-square.ada | 20 ++ .../averages-root-mean-square-1.ahk | 11 + .../averages-root-mean-square-2.ahk | 8 + .../BASIC/averages-root-mean-square.bas | 14 ++ .../C/averages-root-mean-square.c | 18 ++ .../Clojure/averages-root-mean-square.clj | 7 + .../averages-root-mean-square.coffee | 5 + .../Erlang/averages-root-mean-square.erl | 4 + .../Forth/averages-root-mean-square.fth | 9 + .../Fortran/averages-root-mean-square.f | 1 + .../Go/averages-root-mean-square.go | 15 ++ .../Haskell/averages-root-mean-square.hs | 1 + .../Java/averages-root-mean-square.java | 14 ++ .../JavaScript/averages-root-mean-square.js | 6 + .../Lua/averages-root-mean-square.lua | 4 + .../Perl/averages-root-mean-square.pl | 9 + .../PicoLisp/averages-root-mean-square.l | 12 + .../Python/averages-root-mean-square.py | 6 + .../R/averages-root-mean-square-1.r | 1 + .../R/averages-root-mean-square-2.r | 2 + .../REXX/averages-root-mean-square.rexx | 19 ++ .../Ruby/averages-root-mean-square-1.rb | 13 + .../Ruby/averages-root-mean-square-2.rb | 4 + .../Sather/averages-root-mean-square.sa | 16 ++ .../Scala/averages-root-mean-square.scala | 2 + .../Scheme/averages-root-mean-square.ss | 5 + .../Smalltalk/averages-root-mean-square.st | 1 + .../Tcl/averages-root-mean-square.tcl | 7 + .../0DESCRIPTION | 33 +++ .../Averages-Simple-moving-average/1META.yaml | 2 + .../averages-simple-moving-average.alg | 88 +++++++ .../AWK/averages-simple-moving-average.awk | 13 + .../Ada/averages-simple-moving-average-1.ada | 8 + .../Ada/averages-simple-moving-average-2.ada | 40 +++ .../Ada/averages-simple-moving-average-3.ada | 19 ++ .../averages-simple-moving-average-1.ahk | 18 ++ .../averages-simple-moving-average-2.ahk | 11 + .../C/averages-simple-moving-average-1.c | 69 +++++ .../C/averages-simple-moving-average-2.c | 18 ++ .../averages-simple-moving-average.clj | 12 + .../averages-simple-moving-average-1.coffee | 44 ++++ .../averages-simple-moving-average-2.coffee | 11 + .../averages-simple-moving-average-1.erl | 41 +++ .../averages-simple-moving-average-2.erl | 12 + .../Forth/averages-simple-moving-average.fth | 27 ++ .../Fortran/averages-simple-moving-average.f | 33 +++ .../Go/averages-simple-moving-average.go | 34 +++ .../Haskell/averages-simple-moving-average.hs | 10 + .../Java/averages-simple-moving-average.java | 38 +++ .../averages-simple-moving-average.js | 24 ++ .../Lua/averages-simple-moving-average.lua | 10 + .../Perl/averages-simple-moving-average.pl | 7 + .../averages-simple-moving-average-1.l | 5 + .../averages-simple-moving-average-2.l | 11 + .../averages-simple-moving-average-1.py | 17 ++ .../averages-simple-moving-average-2.py | 21 ++ .../averages-simple-moving-average-3.py | 15 ++ .../R/averages-simple-moving-average.r | 31 +++ .../REXX/averages-simple-moving-average.rexx | 35 +++ .../Ruby/averages-simple-moving-average-1.rb | 18 ++ .../Ruby/averages-simple-moving-average-2.rb | 28 +++ .../averages-simple-moving-average.scala | 11 + .../Scheme/averages-simple-moving-average.ss | 6 + .../averages-simple-moving-average-1.st | 31 +++ .../averages-simple-moving-average-2.st | 10 + .../Tcl/averages-simple-moving-average-1.tcl | 11 + .../Tcl/averages-simple-moving-average-2.tcl | 5 + 1608 files changed, 18584 insertions(+) create mode 120000 Lang/0815/A+B create mode 120000 Lang/6502-Assembly/Averages-Arithmetic-mean create mode 120000 Lang/ABAP/A+B create mode 120000 Lang/ABAP/Abstract-type create mode 120000 Lang/ABAP/Accumulator-factory create mode 120000 Lang/ABAP/Align-columns create mode 120000 Lang/ACL2/Apply-a-callback-to-an-array create mode 120000 Lang/ACL2/Arbitrary-precision-integers-(included) create mode 120000 Lang/ACL2/Array-concatenation create mode 120000 Lang/ACL2/Averages-Arithmetic-mean create mode 120000 Lang/ALGOL-68/A+B create mode 120000 Lang/ALGOL-68/Accumulator-factory create mode 120000 Lang/ALGOL-68/Address-of-a-variable create mode 120000 Lang/ALGOL-68/Align-columns create mode 120000 Lang/ALGOL-68/Apply-a-callback-to-an-array create mode 120000 Lang/ALGOL-68/Arithmetic-Complex create mode 120000 Lang/ALGOL-68/Arithmetic-Rational create mode 120000 Lang/ALGOL-68/Arithmetic-evaluation create mode 120000 Lang/ALGOL-68/Array-concatenation create mode 120000 Lang/ALGOL-68/Associative-array-Creation create mode 120000 Lang/ALGOL-68/Averages-Arithmetic-mean create mode 120000 Lang/ALGOL-68/Averages-Pythagorean-means create mode 120000 Lang/ALGOL-68/Averages-Root-mean-square create mode 120000 Lang/ALGOL-68/Averages-Simple-moving-average create mode 120000 Lang/ANTLR/A+B create mode 120000 Lang/APL/Arithmetic-Complex create mode 120000 Lang/APL/Array-concatenation create mode 120000 Lang/APL/Associative-array-Creation create mode 120000 Lang/APL/Averages-Arithmetic-mean create mode 120000 Lang/APL/Averages-Pythagorean-means create mode 120000 Lang/APL/Averages-Root-mean-square create mode 120000 Lang/AWK/A+B create mode 120000 Lang/AWK/Align-columns create mode 120000 Lang/AWK/Apply-a-callback-to-an-array create mode 120000 Lang/AWK/Associative-array-Creation create mode 120000 Lang/AWK/Associative-array-Iteration create mode 120000 Lang/AWK/Averages-Arithmetic-mean create mode 120000 Lang/AWK/Averages-Median create mode 120000 Lang/AWK/Averages-Pythagorean-means create mode 120000 Lang/AWK/Averages-Root-mean-square create mode 120000 Lang/AWK/Averages-Simple-moving-average create mode 120000 Lang/ActionScript/Abstract-type create mode 120000 Lang/ActionScript/Accumulator-factory create mode 120000 Lang/ActionScript/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/ActionScript/Animation create mode 120000 Lang/ActionScript/Apply-a-callback-to-an-array create mode 120000 Lang/ActionScript/Array-concatenation create mode 120000 Lang/ActionScript/Associative-array-Creation create mode 120000 Lang/ActionScript/Averages-Arithmetic-mean create mode 120000 Lang/ActionScript/Averages-Pythagorean-means create mode 120000 Lang/Ada/A+B create mode 120000 Lang/Ada/Abstract-type create mode 120000 Lang/Ada/Accumulator-factory create mode 120000 Lang/Ada/Active-object create mode 120000 Lang/Ada/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/Ada/Address-of-a-variable create mode 120000 Lang/Ada/Align-columns create mode 120000 Lang/Ada/Anagrams-Deranged-anagrams create mode 120000 Lang/Ada/Animation create mode 120000 Lang/Ada/Anonymous-recursion create mode 120000 Lang/Ada/Apply-a-callback-to-an-array create mode 120000 Lang/Ada/Arbitrary-precision-integers-(included) create mode 120000 Lang/Ada/Arena-storage-pool create mode 120000 Lang/Ada/Arithmetic-Complex create mode 120000 Lang/Ada/Arithmetic-geometric-mean create mode 120000 Lang/Ada/Array-concatenation create mode 120000 Lang/Ada/Associative-array-Creation create mode 120000 Lang/Ada/Associative-array-Iteration create mode 120000 Lang/Ada/Atomic-updates create mode 120000 Lang/Ada/Average-loop-length create mode 120000 Lang/Ada/Averages-Arithmetic-mean create mode 120000 Lang/Ada/Averages-Mean-angle create mode 120000 Lang/Ada/Averages-Median create mode 120000 Lang/Ada/Averages-Pythagorean-means create mode 120000 Lang/Ada/Averages-Root-mean-square create mode 120000 Lang/Ada/Averages-Simple-moving-average create mode 120000 Lang/Agda/Abstract-type create mode 120000 Lang/Aikido/Abstract-type create mode 120000 Lang/Aikido/Accumulator-factory create mode 120000 Lang/Aikido/Associative-array-Creation create mode 120000 Lang/Aime/Apply-a-callback-to-an-array create mode 120000 Lang/Alore/Arbitrary-precision-integers-(included) create mode 120000 Lang/AmigaE/Averages-Arithmetic-mean create mode 120000 Lang/AppleScript/Averages-Median create mode 120000 Lang/Argile/A+B create mode 120000 Lang/Argile/Abstract-type create mode 120000 Lang/Argile/Accumulator-factory create mode 120000 Lang/Argile/Address-of-a-variable create mode 120000 Lang/AutoHotkey/A+B create mode 120000 Lang/AutoHotkey/Abstract-type create mode 120000 Lang/AutoHotkey/Active-Directory-Connect create mode 120000 Lang/AutoHotkey/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/AutoHotkey/Address-of-a-variable create mode 120000 Lang/AutoHotkey/Align-columns create mode 120000 Lang/AutoHotkey/Animation create mode 120000 Lang/AutoHotkey/Anonymous-recursion create mode 120000 Lang/AutoHotkey/Apply-a-callback-to-an-array create mode 120000 Lang/AutoHotkey/Arithmetic-Complex create mode 120000 Lang/AutoHotkey/Arithmetic-evaluation create mode 120000 Lang/AutoHotkey/Arithmetic-geometric-mean create mode 120000 Lang/AutoHotkey/Array-concatenation create mode 120000 Lang/AutoHotkey/Associative-array-Creation create mode 120000 Lang/AutoHotkey/Associative-array-Iteration create mode 120000 Lang/AutoHotkey/Averages-Arithmetic-mean create mode 120000 Lang/AutoHotkey/Averages-Median create mode 120000 Lang/AutoHotkey/Averages-Pythagorean-means create mode 120000 Lang/AutoHotkey/Averages-Root-mean-square create mode 120000 Lang/AutoHotkey/Averages-Simple-moving-average create mode 120000 Lang/AutoIt/A+B create mode 120000 Lang/AutoIt/Active-Directory-Connect create mode 120000 Lang/AutoIt/Array-concatenation create mode 120000 Lang/Axiom/Anonymous-recursion create mode 120000 Lang/BASIC/A+B create mode 120000 Lang/BASIC/Address-of-a-variable create mode 120000 Lang/BASIC/Arithmetic-Complex create mode 120000 Lang/BASIC/Averages-Arithmetic-mean create mode 120000 Lang/BASIC/Averages-Median create mode 120000 Lang/BASIC/Averages-Root-mean-square create mode 120000 Lang/Babel/Array-concatenation create mode 120000 Lang/Befunge/A+B create mode 120000 Lang/Befunge/Averages-Arithmetic-mean create mode 120000 Lang/C/A+B create mode 120000 Lang/C/Abstract-type create mode 120000 Lang/C/Accumulator-factory create mode 120000 Lang/C/Active-Directory-Connect create mode 120000 Lang/C/Active-Directory-Search-for-a-user create mode 120000 Lang/C/Active-object create mode 120000 Lang/C/Anagrams-Deranged-anagrams create mode 120000 Lang/C/Animation create mode 120000 Lang/C/Anonymous-recursion create mode 120000 Lang/C/Apply-a-callback-to-an-array create mode 120000 Lang/C/Arbitrary-precision-integers-(included) create mode 120000 Lang/C/Arena-storage-pool create mode 120000 Lang/C/Arithmetic-Complex create mode 120000 Lang/C/Arithmetic-Rational create mode 120000 Lang/C/Arithmetic-geometric-mean create mode 120000 Lang/C/Array-concatenation create mode 120000 Lang/C/Atomic-updates create mode 120000 Lang/C/Average-loop-length create mode 120000 Lang/C/Averages-Arithmetic-mean create mode 120000 Lang/C/Averages-Mean-angle create mode 120000 Lang/C/Averages-Mean-time-of-day create mode 120000 Lang/C/Averages-Median create mode 120000 Lang/C/Averages-Pythagorean-means create mode 120000 Lang/C/Averages-Root-mean-square create mode 120000 Lang/C/Averages-Simple-moving-average create mode 120000 Lang/Clojure/A+B create mode 120000 Lang/Clojure/Abstract-type create mode 120000 Lang/Clojure/Accumulator-factory create mode 120000 Lang/Clojure/Active-object create mode 120000 Lang/Clojure/Align-columns create mode 120000 Lang/Clojure/Anagrams-Deranged-anagrams create mode 120000 Lang/Clojure/Animation create mode 120000 Lang/Clojure/Anonymous-recursion create mode 120000 Lang/Clojure/Apply-a-callback-to-an-array create mode 120000 Lang/Clojure/Arbitrary-precision-integers-(included) create mode 120000 Lang/Clojure/Arithmetic-Rational create mode 120000 Lang/Clojure/Arithmetic-evaluation create mode 120000 Lang/Clojure/Array-concatenation create mode 120000 Lang/Clojure/Associative-array-Creation create mode 120000 Lang/Clojure/Associative-array-Iteration create mode 120000 Lang/Clojure/Atomic-updates create mode 120000 Lang/Clojure/Averages-Arithmetic-mean create mode 120000 Lang/Clojure/Averages-Median create mode 120000 Lang/Clojure/Averages-Pythagorean-means create mode 120000 Lang/Clojure/Averages-Root-mean-square create mode 120000 Lang/Clojure/Averages-Simple-moving-average create mode 120000 Lang/CoffeeScript/A+B create mode 120000 Lang/CoffeeScript/Accumulator-factory create mode 120000 Lang/CoffeeScript/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/CoffeeScript/Align-columns create mode 120000 Lang/CoffeeScript/Anagrams-Deranged-anagrams create mode 120000 Lang/CoffeeScript/Anonymous-recursion create mode 120000 Lang/CoffeeScript/Apply-a-callback-to-an-array create mode 120000 Lang/CoffeeScript/Arithmetic-Complex create mode 120000 Lang/CoffeeScript/Array-concatenation create mode 120000 Lang/CoffeeScript/Associative-array-Iteration create mode 120000 Lang/CoffeeScript/Averages-Arithmetic-mean create mode 120000 Lang/CoffeeScript/Averages-Root-mean-square create mode 120000 Lang/CoffeeScript/Averages-Simple-moving-average create mode 120000 Lang/Dylan/Anonymous-recursion create mode 120000 Lang/Eiffel/A+B create mode 120000 Lang/Eiffel/Abstract-type create mode 120000 Lang/Erlang/A+B create mode 120000 Lang/Erlang/Accumulator-factory create mode 120000 Lang/Erlang/Align-columns create mode 120000 Lang/Erlang/Apply-a-callback-to-an-array create mode 120000 Lang/Erlang/Arbitrary-precision-integers-(included) create mode 120000 Lang/Erlang/Arithmetic-Complex create mode 120000 Lang/Erlang/Arithmetic-geometric-mean create mode 120000 Lang/Erlang/Array-concatenation create mode 120000 Lang/Erlang/Associative-array-Creation create mode 120000 Lang/Erlang/Associative-array-Iteration create mode 120000 Lang/Erlang/Averages-Arithmetic-mean create mode 120000 Lang/Erlang/Averages-Median create mode 120000 Lang/Erlang/Averages-Pythagorean-means create mode 120000 Lang/Erlang/Averages-Root-mean-square create mode 120000 Lang/Erlang/Averages-Simple-moving-average create mode 120000 Lang/Forth/A+B create mode 120000 Lang/Forth/Abstract-type create mode 120000 Lang/Forth/Accumulator-factory create mode 120000 Lang/Forth/Align-columns create mode 120000 Lang/Forth/Anonymous-recursion create mode 120000 Lang/Forth/Apply-a-callback-to-an-array create mode 120000 Lang/Forth/Arithmetic-Complex create mode 120000 Lang/Forth/Arithmetic-Rational create mode 120000 Lang/Forth/Array-concatenation create mode 120000 Lang/Forth/Associative-array-Creation create mode 120000 Lang/Forth/Associative-array-Iteration create mode 120000 Lang/Forth/Averages-Arithmetic-mean create mode 120000 Lang/Forth/Averages-Median create mode 120000 Lang/Forth/Averages-Pythagorean-means create mode 120000 Lang/Forth/Averages-Root-mean-square create mode 120000 Lang/Forth/Averages-Simple-moving-average create mode 120000 Lang/Fortran/A+B create mode 120000 Lang/Fortran/Address-of-a-variable create mode 120000 Lang/Fortran/Anonymous-recursion create mode 120000 Lang/Fortran/Apply-a-callback-to-an-array create mode 120000 Lang/Fortran/Arithmetic-Complex create mode 120000 Lang/Fortran/Arithmetic-Rational create mode 120000 Lang/Fortran/Arithmetic-geometric-mean create mode 120000 Lang/Fortran/Array-concatenation create mode 120000 Lang/Fortran/Averages-Arithmetic-mean create mode 120000 Lang/Fortran/Averages-Median create mode 120000 Lang/Fortran/Averages-Pythagorean-means create mode 120000 Lang/Fortran/Averages-Root-mean-square create mode 120000 Lang/Fortran/Averages-Simple-moving-average create mode 120000 Lang/Go/A+B create mode 120000 Lang/Go/Abstract-type create mode 120000 Lang/Go/Accumulator-factory create mode 120000 Lang/Go/Active-object create mode 120000 Lang/Go/Address-of-a-variable create mode 120000 Lang/Go/Align-columns create mode 120000 Lang/Go/Anagrams-Deranged-anagrams create mode 120000 Lang/Go/Anonymous-recursion create mode 120000 Lang/Go/Apply-a-callback-to-an-array create mode 120000 Lang/Go/Arbitrary-precision-integers-(included) create mode 120000 Lang/Go/Arithmetic-Complex create mode 120000 Lang/Go/Arithmetic-Rational create mode 120000 Lang/Go/Arithmetic-geometric-mean create mode 120000 Lang/Go/Array-concatenation create mode 120000 Lang/Go/Associative-array-Creation create mode 120000 Lang/Go/Associative-array-Iteration create mode 120000 Lang/Go/Atomic-updates create mode 120000 Lang/Go/Averages-Arithmetic-mean create mode 120000 Lang/Go/Averages-Mean-angle create mode 120000 Lang/Go/Averages-Mean-time-of-day create mode 120000 Lang/Go/Averages-Median create mode 120000 Lang/Go/Averages-Pythagorean-means create mode 120000 Lang/Go/Averages-Root-mean-square create mode 120000 Lang/Go/Averages-Simple-moving-average create mode 120000 Lang/Haskell/A+B create mode 120000 Lang/Haskell/Abstract-type create mode 120000 Lang/Haskell/Accumulator-factory create mode 120000 Lang/Haskell/Active-object create mode 120000 Lang/Haskell/Align-columns create mode 120000 Lang/Haskell/Anagrams-Deranged-anagrams create mode 120000 Lang/Haskell/Animation create mode 120000 Lang/Haskell/Anonymous-recursion create mode 120000 Lang/Haskell/Apply-a-callback-to-an-array create mode 120000 Lang/Haskell/Arbitrary-precision-integers-(included) create mode 120000 Lang/Haskell/Arithmetic-Complex create mode 120000 Lang/Haskell/Arithmetic-Rational create mode 120000 Lang/Haskell/Arithmetic-evaluation create mode 120000 Lang/Haskell/Arithmetic-geometric-mean create mode 120000 Lang/Haskell/Array-concatenation create mode 120000 Lang/Haskell/Associative-array-Creation create mode 120000 Lang/Haskell/Associative-array-Iteration create mode 120000 Lang/Haskell/Atomic-updates create mode 120000 Lang/Haskell/Averages-Arithmetic-mean create mode 120000 Lang/Haskell/Averages-Mean-angle create mode 120000 Lang/Haskell/Averages-Median create mode 120000 Lang/Haskell/Averages-Pythagorean-means create mode 120000 Lang/Haskell/Averages-Root-mean-square create mode 120000 Lang/Haskell/Averages-Simple-moving-average create mode 120000 Lang/Java/A+B create mode 120000 Lang/Java/Abstract-type create mode 120000 Lang/Java/Accumulator-factory create mode 120000 Lang/Java/Active-Directory-Connect create mode 120000 Lang/Java/Active-Directory-Search-for-a-user create mode 120000 Lang/Java/Anagrams-Deranged-anagrams create mode 120000 Lang/Java/Animation create mode 120000 Lang/Java/Anonymous-recursion create mode 120000 Lang/Java/Apply-a-callback-to-an-array create mode 120000 Lang/Java/Arbitrary-precision-integers-(included) create mode 120000 Lang/Java/Arithmetic-Complex create mode 120000 Lang/Java/Arithmetic-Rational create mode 120000 Lang/Java/Arithmetic-evaluation create mode 120000 Lang/Java/Arithmetic-geometric-mean create mode 120000 Lang/Java/Array-concatenation create mode 120000 Lang/Java/Associative-array-Creation create mode 120000 Lang/Java/Associative-array-Iteration create mode 120000 Lang/Java/Atomic-updates create mode 120000 Lang/Java/Averages-Arithmetic-mean create mode 120000 Lang/Java/Averages-Median create mode 120000 Lang/Java/Averages-Pythagorean-means create mode 120000 Lang/Java/Averages-Root-mean-square create mode 120000 Lang/Java/Averages-Simple-moving-average create mode 120000 Lang/JavaScript/A+B create mode 120000 Lang/JavaScript/Accumulator-factory create mode 120000 Lang/JavaScript/Active-object create mode 120000 Lang/JavaScript/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/JavaScript/Align-columns create mode 120000 Lang/JavaScript/Anagrams-Deranged-anagrams create mode 120000 Lang/JavaScript/Animation create mode 120000 Lang/JavaScript/Anonymous-recursion create mode 120000 Lang/JavaScript/Apply-a-callback-to-an-array create mode 120000 Lang/JavaScript/Arithmetic-Complex create mode 120000 Lang/JavaScript/Arithmetic-evaluation create mode 120000 Lang/JavaScript/Array-concatenation create mode 120000 Lang/JavaScript/Associative-array-Creation create mode 120000 Lang/JavaScript/Associative-array-Iteration create mode 120000 Lang/JavaScript/Averages-Arithmetic-mean create mode 120000 Lang/JavaScript/Averages-Median create mode 120000 Lang/JavaScript/Averages-Pythagorean-means create mode 120000 Lang/JavaScript/Averages-Root-mean-square create mode 120000 Lang/JavaScript/Averages-Simple-moving-average create mode 120000 Lang/Lua/A+B create mode 120000 Lang/Lua/Abstract-type create mode 120000 Lang/Lua/Accumulator-factory create mode 120000 Lang/Lua/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/Lua/Align-columns create mode 120000 Lang/Lua/Anonymous-recursion create mode 120000 Lang/Lua/Apply-a-callback-to-an-array create mode 120000 Lang/Lua/Arithmetic-Complex create mode 120000 Lang/Lua/Arithmetic-Rational create mode 120000 Lang/Lua/Arithmetic-evaluation create mode 120000 Lang/Lua/Array-concatenation create mode 120000 Lang/Lua/Associative-array-Creation create mode 120000 Lang/Lua/Associative-array-Iteration create mode 120000 Lang/Lua/Averages-Arithmetic-mean create mode 120000 Lang/Lua/Averages-Median create mode 120000 Lang/Lua/Averages-Pythagorean-means create mode 120000 Lang/Lua/Averages-Root-mean-square create mode 120000 Lang/Lua/Averages-Simple-moving-average create mode 120000 Lang/PHP/A+B create mode 120000 Lang/PHP/Abstract-type create mode 120000 Lang/PHP/Accumulator-factory create mode 120000 Lang/PHP/Active-Directory-Connect create mode 120000 Lang/PHP/Active-Directory-Search-for-a-user create mode 120000 Lang/PHP/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/PHP/Align-columns create mode 120000 Lang/PHP/Anagrams-Deranged-anagrams create mode 120000 Lang/PHP/Anonymous-recursion create mode 120000 Lang/PHP/Apply-a-callback-to-an-array create mode 120000 Lang/PHP/Arbitrary-precision-integers-(included) create mode 120000 Lang/PHP/Arithmetic-geometric-mean create mode 120000 Lang/PHP/Array-concatenation create mode 120000 Lang/PHP/Associative-array-Creation create mode 120000 Lang/PHP/Associative-array-Iteration create mode 120000 Lang/PHP/Averages-Arithmetic-mean create mode 120000 Lang/PHP/Averages-Median create mode 120000 Lang/Perl/A+B create mode 120000 Lang/Perl/Abstract-type create mode 120000 Lang/Perl/Accumulator-factory create mode 120000 Lang/Perl/Active-Directory-Connect create mode 120000 Lang/Perl/Active-object create mode 120000 Lang/Perl/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/Perl/Address-of-a-variable create mode 120000 Lang/Perl/Align-columns create mode 120000 Lang/Perl/Anagrams-Deranged-anagrams create mode 120000 Lang/Perl/Animation create mode 120000 Lang/Perl/Anonymous-recursion create mode 120000 Lang/Perl/Apply-a-callback-to-an-array create mode 120000 Lang/Perl/Arbitrary-precision-integers-(included) create mode 120000 Lang/Perl/Arithmetic-Complex create mode 120000 Lang/Perl/Arithmetic-Rational create mode 120000 Lang/Perl/Arithmetic-evaluation create mode 120000 Lang/Perl/Arithmetic-geometric-mean create mode 120000 Lang/Perl/Array-concatenation create mode 120000 Lang/Perl/Associative-array-Creation create mode 120000 Lang/Perl/Associative-array-Iteration create mode 120000 Lang/Perl/Atomic-updates create mode 120000 Lang/Perl/Averages-Arithmetic-mean create mode 120000 Lang/Perl/Averages-Median create mode 120000 Lang/Perl/Averages-Pythagorean-means create mode 120000 Lang/Perl/Averages-Root-mean-square create mode 120000 Lang/Perl/Averages-Simple-moving-average create mode 120000 Lang/PicoLisp/A+B create mode 120000 Lang/PicoLisp/Abstract-type create mode 120000 Lang/PicoLisp/Accumulator-factory create mode 120000 Lang/PicoLisp/Active-Directory-Connect create mode 120000 Lang/PicoLisp/Active-Directory-Search-for-a-user create mode 120000 Lang/PicoLisp/Active-object create mode 120000 Lang/PicoLisp/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/PicoLisp/Address-of-a-variable create mode 120000 Lang/PicoLisp/Align-columns create mode 120000 Lang/PicoLisp/Anagrams-Deranged-anagrams create mode 120000 Lang/PicoLisp/Animation create mode 120000 Lang/PicoLisp/Anonymous-recursion create mode 120000 Lang/PicoLisp/Apply-a-callback-to-an-array create mode 120000 Lang/PicoLisp/Arbitrary-precision-integers-(included) create mode 120000 Lang/PicoLisp/Arithmetic-Complex create mode 120000 Lang/PicoLisp/Arithmetic-Rational create mode 120000 Lang/PicoLisp/Arithmetic-evaluation create mode 120000 Lang/PicoLisp/Arithmetic-geometric-mean create mode 120000 Lang/PicoLisp/Array-concatenation create mode 120000 Lang/PicoLisp/Associative-array-Creation create mode 120000 Lang/PicoLisp/Associative-array-Iteration create mode 120000 Lang/PicoLisp/Atomic-updates create mode 120000 Lang/PicoLisp/Averages-Arithmetic-mean create mode 120000 Lang/PicoLisp/Averages-Mean-angle create mode 120000 Lang/PicoLisp/Averages-Mean-time-of-day create mode 120000 Lang/PicoLisp/Averages-Median create mode 120000 Lang/PicoLisp/Averages-Pythagorean-means create mode 120000 Lang/PicoLisp/Averages-Root-mean-square create mode 120000 Lang/PicoLisp/Averages-Simple-moving-average create mode 120000 Lang/Prolog/A+B create mode 120000 Lang/Prolog/Accumulator-factory create mode 120000 Lang/Prolog/Align-columns create mode 120000 Lang/Prolog/Anagrams-Deranged-anagrams create mode 120000 Lang/Prolog/Animation create mode 120000 Lang/Prolog/Anonymous-recursion create mode 120000 Lang/Prolog/Apply-a-callback-to-an-array create mode 120000 Lang/Prolog/Arithmetic-evaluation create mode 120000 Lang/Prolog/Array-concatenation create mode 120000 Lang/Prolog/Associative-array-Creation create mode 120000 Lang/Prolog/Averages-Median create mode 120000 Lang/Python/A+B create mode 120000 Lang/Python/Abstract-type create mode 120000 Lang/Python/Accumulator-factory create mode 120000 Lang/Python/Active-Directory-Connect create mode 120000 Lang/Python/Active-Directory-Search-for-a-user create mode 120000 Lang/Python/Active-object create mode 120000 Lang/Python/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/Python/Address-of-a-variable create mode 120000 Lang/Python/Align-columns create mode 120000 Lang/Python/Anagrams-Deranged-anagrams create mode 120000 Lang/Python/Animation create mode 120000 Lang/Python/Anonymous-recursion create mode 120000 Lang/Python/Apply-a-callback-to-an-array create mode 120000 Lang/Python/Arbitrary-precision-integers-(included) create mode 120000 Lang/Python/Arithmetic-Complex create mode 120000 Lang/Python/Arithmetic-Rational create mode 120000 Lang/Python/Arithmetic-evaluation create mode 120000 Lang/Python/Arithmetic-geometric-mean create mode 120000 Lang/Python/Array-concatenation create mode 120000 Lang/Python/Associative-array-Creation create mode 120000 Lang/Python/Associative-array-Iteration create mode 120000 Lang/Python/Atomic-updates create mode 120000 Lang/Python/Average-loop-length create mode 120000 Lang/Python/Averages-Arithmetic-mean create mode 120000 Lang/Python/Averages-Mean-angle create mode 120000 Lang/Python/Averages-Mean-time-of-day create mode 120000 Lang/Python/Averages-Median create mode 120000 Lang/Python/Averages-Pythagorean-means create mode 120000 Lang/Python/Averages-Root-mean-square create mode 120000 Lang/Python/Averages-Simple-moving-average create mode 120000 Lang/R/A+B create mode 120000 Lang/R/Accumulator-factory create mode 120000 Lang/R/Align-columns create mode 120000 Lang/R/Anagrams-Deranged-anagrams create mode 120000 Lang/R/Animation create mode 120000 Lang/R/Anonymous-recursion create mode 120000 Lang/R/Apply-a-callback-to-an-array create mode 120000 Lang/R/Arbitrary-precision-integers-(included) create mode 120000 Lang/R/Arithmetic-Complex create mode 120000 Lang/R/Arithmetic-geometric-mean create mode 120000 Lang/R/Array-concatenation create mode 120000 Lang/R/Associative-array-Creation create mode 120000 Lang/R/Associative-array-Iteration create mode 120000 Lang/R/Averages-Arithmetic-mean create mode 120000 Lang/R/Averages-Median create mode 120000 Lang/R/Averages-Pythagorean-means create mode 120000 Lang/R/Averages-Root-mean-square create mode 120000 Lang/R/Averages-Simple-moving-average create mode 120000 Lang/REXX/A+B create mode 120000 Lang/REXX/Accumulator-factory create mode 120000 Lang/REXX/Active-Directory-Search-for-a-user create mode 120000 Lang/REXX/Address-of-a-variable create mode 120000 Lang/REXX/Align-columns create mode 120000 Lang/REXX/Anagrams-Deranged-anagrams create mode 120000 Lang/REXX/Anonymous-recursion create mode 120000 Lang/REXX/Apply-a-callback-to-an-array create mode 120000 Lang/REXX/Arbitrary-precision-integers-(included) create mode 120000 Lang/REXX/Arena-storage-pool create mode 120000 Lang/REXX/Arithmetic-Complex create mode 120000 Lang/REXX/Arithmetic-Rational create mode 120000 Lang/REXX/Arithmetic-evaluation create mode 120000 Lang/REXX/Arithmetic-geometric-mean create mode 120000 Lang/REXX/Array-concatenation create mode 120000 Lang/REXX/Associative-array-Creation create mode 120000 Lang/REXX/Associative-array-Iteration create mode 120000 Lang/REXX/Average-loop-length create mode 120000 Lang/REXX/Averages-Arithmetic-mean create mode 120000 Lang/REXX/Averages-Mean-angle create mode 120000 Lang/REXX/Averages-Median create mode 120000 Lang/REXX/Averages-Pythagorean-means create mode 120000 Lang/REXX/Averages-Root-mean-square create mode 120000 Lang/REXX/Averages-Simple-moving-average create mode 120000 Lang/Racket/A+B create mode 120000 Lang/Racket/Abstract-type create mode 120000 Lang/Racket/Accumulator-factory create mode 120000 Lang/Racket/Active-object create mode 120000 Lang/Racket/Address-of-a-variable create mode 120000 Lang/Racket/Align-columns create mode 120000 Lang/Racket/Animation create mode 120000 Lang/Racket/Anonymous-recursion create mode 120000 Lang/Racket/Apply-a-callback-to-an-array create mode 120000 Lang/Racket/Arbitrary-precision-integers-(included) create mode 120000 Lang/Racket/Arithmetic-Complex create mode 120000 Lang/Racket/Arithmetic-geometric-mean create mode 120000 Lang/Racket/Array-concatenation create mode 120000 Lang/Racket/Associative-array-Creation create mode 120000 Lang/Racket/Associative-array-Iteration create mode 120000 Lang/Racket/Averages-Arithmetic-mean create mode 120000 Lang/Racket/Averages-Mean-angle create mode 120000 Lang/Racket/Averages-Median create mode 120000 Lang/Racket/Averages-Pythagorean-means create mode 120000 Lang/Ruby/A+B create mode 120000 Lang/Ruby/Abstract-type create mode 120000 Lang/Ruby/Accumulator-factory create mode 120000 Lang/Ruby/Active-Directory-Connect create mode 120000 Lang/Ruby/Active-Directory-Search-for-a-user create mode 120000 Lang/Ruby/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/Ruby/Address-of-a-variable create mode 120000 Lang/Ruby/Align-columns create mode 120000 Lang/Ruby/Anagrams-Deranged-anagrams create mode 120000 Lang/Ruby/Animation create mode 120000 Lang/Ruby/Anonymous-recursion create mode 120000 Lang/Ruby/Apply-a-callback-to-an-array create mode 120000 Lang/Ruby/Arbitrary-precision-integers-(included) create mode 120000 Lang/Ruby/Arithmetic-Complex create mode 120000 Lang/Ruby/Arithmetic-Rational create mode 120000 Lang/Ruby/Arithmetic-evaluation create mode 120000 Lang/Ruby/Arithmetic-geometric-mean create mode 120000 Lang/Ruby/Array-concatenation create mode 120000 Lang/Ruby/Associative-array-Creation create mode 120000 Lang/Ruby/Associative-array-Iteration create mode 120000 Lang/Ruby/Atomic-updates create mode 120000 Lang/Ruby/Averages-Arithmetic-mean create mode 120000 Lang/Ruby/Averages-Mean-angle create mode 120000 Lang/Ruby/Averages-Median create mode 120000 Lang/Ruby/Averages-Pythagorean-means create mode 120000 Lang/Ruby/Averages-Root-mean-square create mode 120000 Lang/Ruby/Averages-Simple-moving-average create mode 120000 Lang/Sather/Apply-a-callback-to-an-array create mode 120000 Lang/Sather/Arbitrary-precision-integers-(included) create mode 120000 Lang/Sather/Associative-array-Creation create mode 120000 Lang/Sather/Averages-Arithmetic-mean create mode 120000 Lang/Sather/Averages-Root-mean-square create mode 120000 Lang/Scala/A+B create mode 120000 Lang/Scala/Abstract-type create mode 120000 Lang/Scala/Accumulator-factory create mode 120000 Lang/Scala/Active-object create mode 120000 Lang/Scala/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/Scala/Align-columns create mode 120000 Lang/Scala/Anagrams-Deranged-anagrams create mode 120000 Lang/Scala/Animation create mode 120000 Lang/Scala/Anonymous-recursion create mode 120000 Lang/Scala/Apply-a-callback-to-an-array create mode 120000 Lang/Scala/Arbitrary-precision-integers-(included) create mode 120000 Lang/Scala/Arithmetic-Complex create mode 120000 Lang/Scala/Arithmetic-Rational create mode 120000 Lang/Scala/Arithmetic-evaluation create mode 120000 Lang/Scala/Arithmetic-geometric-mean create mode 120000 Lang/Scala/Array-concatenation create mode 120000 Lang/Scala/Associative-array-Creation create mode 120000 Lang/Scala/Associative-array-Iteration create mode 120000 Lang/Scala/Atomic-updates create mode 120000 Lang/Scala/Averages-Arithmetic-mean create mode 120000 Lang/Scala/Averages-Median create mode 120000 Lang/Scala/Averages-Pythagorean-means create mode 120000 Lang/Scala/Averages-Root-mean-square create mode 120000 Lang/Scala/Averages-Simple-moving-average create mode 120000 Lang/Scheme/A+B create mode 120000 Lang/Scheme/Accumulator-factory create mode 120000 Lang/Scheme/Anonymous-recursion create mode 120000 Lang/Scheme/Apply-a-callback-to-an-array create mode 120000 Lang/Scheme/Arbitrary-precision-integers-(included) create mode 120000 Lang/Scheme/Arithmetic-Complex create mode 120000 Lang/Scheme/Arithmetic-Rational create mode 120000 Lang/Scheme/Array-concatenation create mode 120000 Lang/Scheme/Associative-array-Creation create mode 120000 Lang/Scheme/Averages-Arithmetic-mean create mode 120000 Lang/Scheme/Averages-Median create mode 120000 Lang/Scheme/Averages-Pythagorean-means create mode 120000 Lang/Scheme/Averages-Root-mean-square create mode 120000 Lang/Scheme/Averages-Simple-moving-average create mode 120000 Lang/Smalltalk/A+B create mode 120000 Lang/Smalltalk/Accumulator-factory create mode 120000 Lang/Smalltalk/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/Smalltalk/Address-of-a-variable create mode 120000 Lang/Smalltalk/Apply-a-callback-to-an-array create mode 120000 Lang/Smalltalk/Arbitrary-precision-integers-(included) create mode 120000 Lang/Smalltalk/Arithmetic-Complex create mode 120000 Lang/Smalltalk/Arithmetic-Rational create mode 120000 Lang/Smalltalk/Array-concatenation create mode 120000 Lang/Smalltalk/Associative-array-Creation create mode 120000 Lang/Smalltalk/Associative-array-Iteration create mode 120000 Lang/Smalltalk/Averages-Arithmetic-mean create mode 120000 Lang/Smalltalk/Averages-Median create mode 120000 Lang/Smalltalk/Averages-Pythagorean-means create mode 120000 Lang/Smalltalk/Averages-Root-mean-square create mode 120000 Lang/Smalltalk/Averages-Simple-moving-average create mode 120000 Lang/Tcl/A+B create mode 120000 Lang/Tcl/Abstract-type create mode 120000 Lang/Tcl/Accumulator-factory create mode 120000 Lang/Tcl/Active-Directory-Connect create mode 120000 Lang/Tcl/Active-Directory-Search-for-a-user create mode 120000 Lang/Tcl/Active-object create mode 120000 Lang/Tcl/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/Tcl/Address-of-a-variable create mode 120000 Lang/Tcl/Align-columns create mode 120000 Lang/Tcl/Anagrams-Deranged-anagrams create mode 120000 Lang/Tcl/Animation create mode 120000 Lang/Tcl/Anonymous-recursion create mode 120000 Lang/Tcl/Apply-a-callback-to-an-array create mode 120000 Lang/Tcl/Arbitrary-precision-integers-(included) create mode 120000 Lang/Tcl/Arena-storage-pool create mode 120000 Lang/Tcl/Arithmetic-Complex create mode 120000 Lang/Tcl/Arithmetic-evaluation create mode 120000 Lang/Tcl/Arithmetic-geometric-mean create mode 120000 Lang/Tcl/Array-concatenation create mode 120000 Lang/Tcl/Associative-array-Creation create mode 120000 Lang/Tcl/Associative-array-Iteration create mode 120000 Lang/Tcl/Atomic-updates create mode 120000 Lang/Tcl/Average-loop-length create mode 120000 Lang/Tcl/Averages-Arithmetic-mean create mode 120000 Lang/Tcl/Averages-Mean-angle create mode 120000 Lang/Tcl/Averages-Mean-time-of-day create mode 120000 Lang/Tcl/Averages-Median create mode 120000 Lang/Tcl/Averages-Pythagorean-means create mode 120000 Lang/Tcl/Averages-Root-mean-square create mode 120000 Lang/Tcl/Averages-Simple-moving-average create mode 100644 Task/A+B/0815/a+b.0815 create mode 100644 Task/A+B/0DESCRIPTION create mode 100644 Task/A+B/ABAP/a+b.abap create mode 100644 Task/A+B/ALGOL-68/a+b-1.alg create mode 100644 Task/A+B/ALGOL-68/a+b-2.alg create mode 100644 Task/A+B/ANTLR/a+b.antlr create mode 100644 Task/A+B/AWK/a+b.awk create mode 100644 Task/A+B/Ada/a+b-1.ada create mode 100644 Task/A+B/Ada/a+b-2.ada create mode 100644 Task/A+B/Argile/a+b-1.argile create mode 100644 Task/A+B/Argile/a+b-2.argile create mode 100644 Task/A+B/AutoHotkey/a+b.ahk create mode 100644 Task/A+B/AutoIt/a+b.autoit create mode 100644 Task/A+B/BASIC/a+b.bas create mode 100644 Task/A+B/Befunge/a+b.bf create mode 100644 Task/A+B/C/a+b-1.c create mode 100644 Task/A+B/C/a+b-2.c create mode 100644 Task/A+B/Clojure/a+b-1.clj create mode 100644 Task/A+B/Clojure/a+b-2.clj create mode 100644 Task/A+B/CoffeeScript/a+b.coffee create mode 100644 Task/A+B/Eiffel/a+b.e create mode 100644 Task/A+B/Erlang/a+b.erl create mode 100644 Task/A+B/Forth/a+b.fth create mode 100644 Task/A+B/Fortran/a+b.f create mode 100644 Task/A+B/Go/a+b.go create mode 100644 Task/A+B/Haskell/a+b.hs create mode 100644 Task/A+B/Java/a+b-1.java create mode 100644 Task/A+B/Java/a+b-2.java create mode 100644 Task/A+B/Java/a+b-3.java create mode 100644 Task/A+B/JavaScript/a+b-1.js create mode 100644 Task/A+B/JavaScript/a+b-2.js create mode 100644 Task/A+B/Lua/a+b.lua create mode 100644 Task/A+B/PHP/a+b-1.php create mode 100644 Task/A+B/PHP/a+b-2.php create mode 100644 Task/A+B/Perl/a+b.pl create mode 100644 Task/A+B/PicoLisp/a+b.l create mode 100644 Task/A+B/Prolog/a+b-1.pro create mode 100644 Task/A+B/Prolog/a+b-2.pro create mode 100644 Task/A+B/Python/a+b-1.py create mode 100644 Task/A+B/Python/a+b-2.py create mode 100644 Task/A+B/R/a+b.r create mode 100644 Task/A+B/REXX/a+b-1.rexx create mode 100644 Task/A+B/REXX/a+b-2.rexx create mode 100644 Task/A+B/REXX/a+b-3.rexx create mode 100644 Task/A+B/REXX/a+b-4.rexx create mode 100644 Task/A+B/Racket/a+b-1.rkt create mode 100644 Task/A+B/Racket/a+b-2.rkt create mode 100644 Task/A+B/Ruby/a+b-1.rb create mode 100644 Task/A+B/Ruby/a+b-2.rb create mode 100644 Task/A+B/Scala/a+b.scala create mode 100644 Task/A+B/Scheme/a+b.ss create mode 100644 Task/A+B/Smalltalk/a+b-1.st create mode 100644 Task/A+B/Smalltalk/a+b-2.st create mode 100644 Task/A+B/Smalltalk/a+b-3.st create mode 100644 Task/A+B/Tcl/a+b-1.tcl create mode 100644 Task/A+B/Tcl/a+b-2.tcl create mode 100644 Task/A+B/Tcl/a+b-3.tcl create mode 100644 Task/Abstract-type/0DESCRIPTION create mode 100644 Task/Abstract-type/1META.yaml create mode 100644 Task/Abstract-type/ABAP/abstract-type-1.abap create mode 100644 Task/Abstract-type/ABAP/abstract-type-2.abap create mode 100644 Task/Abstract-type/ActionScript/abstract-type.as create mode 100644 Task/Abstract-type/Ada/abstract-type-1.ada create mode 100644 Task/Abstract-type/Ada/abstract-type-2.ada create mode 100644 Task/Abstract-type/Ada/abstract-type-3.ada create mode 100644 Task/Abstract-type/Agda/abstract-type.agda create mode 100644 Task/Abstract-type/Aikido/abstract-type-1.aikido create mode 100644 Task/Abstract-type/Aikido/abstract-type-2.aikido create mode 100644 Task/Abstract-type/Argile/abstract-type.argile create mode 100644 Task/Abstract-type/AutoHotkey/abstract-type.ahk create mode 100644 Task/Abstract-type/C/abstract-type-1.c create mode 100644 Task/Abstract-type/C/abstract-type-2.c create mode 100644 Task/Abstract-type/C/abstract-type-3.c create mode 100644 Task/Abstract-type/C/abstract-type-4.c create mode 100644 Task/Abstract-type/Clojure/abstract-type.clj create mode 100644 Task/Abstract-type/Eiffel/abstract-type.e create mode 100644 Task/Abstract-type/Forth/abstract-type.fth create mode 100644 Task/Abstract-type/Go/abstract-type.go create mode 100644 Task/Abstract-type/Haskell/abstract-type-1.hs create mode 100644 Task/Abstract-type/Haskell/abstract-type-2.hs create mode 100644 Task/Abstract-type/Haskell/abstract-type-3.hs create mode 100644 Task/Abstract-type/Haskell/abstract-type-4.hs create mode 100644 Task/Abstract-type/Haskell/abstract-type-5.hs create mode 100644 Task/Abstract-type/Haskell/abstract-type-6.hs create mode 100644 Task/Abstract-type/Java/abstract-type-1.java create mode 100644 Task/Abstract-type/Java/abstract-type-2.java create mode 100644 Task/Abstract-type/Lua/abstract-type-1.lua create mode 100644 Task/Abstract-type/Lua/abstract-type-2.lua create mode 100644 Task/Abstract-type/PHP/abstract-type-1.php create mode 100644 Task/Abstract-type/PHP/abstract-type-2.php create mode 100644 Task/Abstract-type/Perl/abstract-type-1.pl create mode 100644 Task/Abstract-type/Perl/abstract-type-2.pl create mode 100644 Task/Abstract-type/Perl/abstract-type-3.pl create mode 100644 Task/Abstract-type/Perl/abstract-type-4.pl create mode 100644 Task/Abstract-type/PicoLisp/abstract-type.l create mode 100644 Task/Abstract-type/Python/abstract-type-1.py create mode 100644 Task/Abstract-type/Python/abstract-type-2.py create mode 100644 Task/Abstract-type/Racket/abstract-type.rkt create mode 100644 Task/Abstract-type/Ruby/abstract-type.rb create mode 100644 Task/Abstract-type/Scala/abstract-type.scala create mode 100644 Task/Abstract-type/Tcl/abstract-type.tcl create mode 100644 Task/Accumulator-factory/0DESCRIPTION create mode 100644 Task/Accumulator-factory/1META.yaml create mode 100644 Task/Accumulator-factory/ABAP/accumulator-factory-1.abap create mode 100644 Task/Accumulator-factory/ABAP/accumulator-factory-2.abap create mode 100644 Task/Accumulator-factory/ALGOL-68/accumulator-factory.alg create mode 100644 Task/Accumulator-factory/ActionScript/accumulator-factory.as create mode 100644 Task/Accumulator-factory/Ada/accumulator-factory-1.ada create mode 100644 Task/Accumulator-factory/Ada/accumulator-factory-2.ada create mode 100644 Task/Accumulator-factory/Ada/accumulator-factory-3.ada create mode 100644 Task/Accumulator-factory/Aikido/accumulator-factory.aikido create mode 100644 Task/Accumulator-factory/Argile/accumulator-factory.argile create mode 100644 Task/Accumulator-factory/C/accumulator-factory.c create mode 100644 Task/Accumulator-factory/Clojure/accumulator-factory-1.clj create mode 100644 Task/Accumulator-factory/Clojure/accumulator-factory-2.clj create mode 100644 Task/Accumulator-factory/CoffeeScript/accumulator-factory.coffee create mode 100644 Task/Accumulator-factory/Erlang/accumulator-factory.erl create mode 100644 Task/Accumulator-factory/Forth/accumulator-factory.fth create mode 100644 Task/Accumulator-factory/Go/accumulator-factory.go create mode 100644 Task/Accumulator-factory/Haskell/accumulator-factory.hs create mode 100644 Task/Accumulator-factory/Java/accumulator-factory-1.java create mode 100644 Task/Accumulator-factory/Java/accumulator-factory-2.java create mode 100644 Task/Accumulator-factory/Java/accumulator-factory-3.java create mode 100644 Task/Accumulator-factory/JavaScript/accumulator-factory-1.js create mode 100644 Task/Accumulator-factory/JavaScript/accumulator-factory-2.js create mode 100644 Task/Accumulator-factory/Lua/accumulator-factory-1.lua create mode 100644 Task/Accumulator-factory/Lua/accumulator-factory-2.lua create mode 100644 Task/Accumulator-factory/Lua/accumulator-factory-3.lua create mode 100644 Task/Accumulator-factory/PHP/accumulator-factory-1.php create mode 100644 Task/Accumulator-factory/PHP/accumulator-factory-2.php create mode 100644 Task/Accumulator-factory/Perl/accumulator-factory.pl create mode 100644 Task/Accumulator-factory/PicoLisp/accumulator-factory.l create mode 100644 Task/Accumulator-factory/Prolog/accumulator-factory.pro create mode 100644 Task/Accumulator-factory/Python/accumulator-factory-1.py create mode 100644 Task/Accumulator-factory/Python/accumulator-factory-2.py create mode 100644 Task/Accumulator-factory/Python/accumulator-factory-3.py create mode 100644 Task/Accumulator-factory/R/accumulator-factory.r create mode 100644 Task/Accumulator-factory/REXX/accumulator-factory.rexx create mode 100644 Task/Accumulator-factory/Racket/accumulator-factory.rkt create mode 100644 Task/Accumulator-factory/Ruby/accumulator-factory.rb create mode 100644 Task/Accumulator-factory/Scala/accumulator-factory.scala create mode 100644 Task/Accumulator-factory/Scheme/accumulator-factory.ss create mode 100644 Task/Accumulator-factory/Smalltalk/accumulator-factory-1.st create mode 100644 Task/Accumulator-factory/Smalltalk/accumulator-factory-2.st create mode 100644 Task/Accumulator-factory/Tcl/accumulator-factory-1.tcl create mode 100644 Task/Accumulator-factory/Tcl/accumulator-factory-2.tcl create mode 100644 Task/Active-Directory-Connect/0DESCRIPTION create mode 100644 Task/Active-Directory-Connect/1META.yaml create mode 100644 Task/Active-Directory-Connect/AutoHotkey/active-directory-connect.ahk create mode 100644 Task/Active-Directory-Connect/AutoIt/active-directory-connect.autoit create mode 100644 Task/Active-Directory-Connect/C/active-directory-connect.c create mode 100644 Task/Active-Directory-Connect/Java/active-directory-connect.java create mode 100644 Task/Active-Directory-Connect/PHP/active-directory-connect.php create mode 100644 Task/Active-Directory-Connect/Perl/active-directory-connect.pl create mode 100644 Task/Active-Directory-Connect/PicoLisp/active-directory-connect.l create mode 100644 Task/Active-Directory-Connect/Python/active-directory-connect.py create mode 100644 Task/Active-Directory-Connect/Ruby/active-directory-connect.rb create mode 100644 Task/Active-Directory-Connect/Tcl/active-directory-connect.tcl create mode 100644 Task/Active-Directory-Search-for-a-user/0DESCRIPTION create mode 100644 Task/Active-Directory-Search-for-a-user/1META.yaml create mode 100644 Task/Active-Directory-Search-for-a-user/C/active-directory-search-for-a-user.c create mode 100644 Task/Active-Directory-Search-for-a-user/Java/active-directory-search-for-a-user.java create mode 100644 Task/Active-Directory-Search-for-a-user/PHP/active-directory-search-for-a-user.php create mode 100644 Task/Active-Directory-Search-for-a-user/PicoLisp/active-directory-search-for-a-user.l create mode 100644 Task/Active-Directory-Search-for-a-user/Python/active-directory-search-for-a-user.py create mode 100644 Task/Active-Directory-Search-for-a-user/REXX/active-directory-search-for-a-user.rexx create mode 100644 Task/Active-Directory-Search-for-a-user/Ruby/active-directory-search-for-a-user.rb create mode 100644 Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-1.tcl create mode 100644 Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-2.tcl create mode 100644 Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-3.tcl create mode 100644 Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-4.tcl create mode 100644 Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-5.tcl create mode 100644 Task/Active-object/0DESCRIPTION create mode 100644 Task/Active-object/1META.yaml create mode 100644 Task/Active-object/Ada/active-object.ada create mode 100644 Task/Active-object/C/active-object.c create mode 100644 Task/Active-object/Clojure/active-object.clj create mode 100644 Task/Active-object/Go/active-object.go create mode 100644 Task/Active-object/Haskell/active-object.hs create mode 100644 Task/Active-object/JavaScript/active-object-1.js create mode 100644 Task/Active-object/JavaScript/active-object-2.js create mode 100644 Task/Active-object/Perl/active-object.pl create mode 100644 Task/Active-object/PicoLisp/active-object.l create mode 100644 Task/Active-object/Python/active-object.py create mode 100644 Task/Active-object/Racket/active-object.rkt create mode 100644 Task/Active-object/Scala/active-object.scala create mode 100644 Task/Active-object/Tcl/active-object.tcl create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/0DESCRIPTION create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/1META.yaml create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-1.as create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-2.as create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-3.as create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Ada/add-a-variable-to-a-class-instance-at-runtime.ada create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/AutoHotkey/add-a-variable-to-a-class-instance-at-runtime.ahk create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/CoffeeScript/add-a-variable-to-a-class-instance-at-runtime.coffee create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/JavaScript/add-a-variable-to-a-class-instance-at-runtime.js create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Lua/add-a-variable-to-a-class-instance-at-runtime.lua create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/PHP/add-a-variable-to-a-class-instance-at-runtime.php create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Perl/add-a-variable-to-a-class-instance-at-runtime.pl create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/PicoLisp/add-a-variable-to-a-class-instance-at-runtime.l create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-1.py create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-2.py create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-3.py create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-4.py create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Ruby/add-a-variable-to-a-class-instance-at-runtime.rb create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Scala/add-a-variable-to-a-class-instance-at-runtime-1.scala create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Scala/add-a-variable-to-a-class-instance-at-runtime-2.scala create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-1.st create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-2.st create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-3.st create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-4.st create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-5.st create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Tcl/add-a-variable-to-a-class-instance-at-runtime-1.tcl create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Tcl/add-a-variable-to-a-class-instance-at-runtime-2.tcl create mode 100644 Task/Address-of-a-variable/0DESCRIPTION create mode 100644 Task/Address-of-a-variable/1META.yaml create mode 100644 Task/Address-of-a-variable/ALGOL-68/address-of-a-variable-1.alg create mode 100644 Task/Address-of-a-variable/ALGOL-68/address-of-a-variable-2.alg create mode 100644 Task/Address-of-a-variable/Ada/address-of-a-variable-1.ada create mode 100644 Task/Address-of-a-variable/Ada/address-of-a-variable-2.ada create mode 100644 Task/Address-of-a-variable/Ada/address-of-a-variable-3.ada create mode 100644 Task/Address-of-a-variable/Argile/address-of-a-variable-1.argile create mode 100644 Task/Address-of-a-variable/Argile/address-of-a-variable-2.argile create mode 100644 Task/Address-of-a-variable/AutoHotkey/address-of-a-variable.ahk create mode 100644 Task/Address-of-a-variable/BASIC/address-of-a-variable.bas create mode 100644 Task/Address-of-a-variable/Fortran/address-of-a-variable.f create mode 100644 Task/Address-of-a-variable/Go/address-of-a-variable-1.go create mode 100644 Task/Address-of-a-variable/Go/address-of-a-variable-2.go create mode 100644 Task/Address-of-a-variable/Go/address-of-a-variable-3.go create mode 100644 Task/Address-of-a-variable/Perl/address-of-a-variable-1.pl create mode 100644 Task/Address-of-a-variable/Perl/address-of-a-variable-2.pl create mode 100644 Task/Address-of-a-variable/Perl/address-of-a-variable-3.pl create mode 100644 Task/Address-of-a-variable/PicoLisp/address-of-a-variable.l create mode 100644 Task/Address-of-a-variable/Python/address-of-a-variable.py create mode 100644 Task/Address-of-a-variable/REXX/address-of-a-variable.rexx create mode 100644 Task/Address-of-a-variable/Racket/address-of-a-variable-1.rkt create mode 100644 Task/Address-of-a-variable/Racket/address-of-a-variable-2.rkt create mode 100644 Task/Address-of-a-variable/Ruby/address-of-a-variable.rb create mode 100644 Task/Address-of-a-variable/Smalltalk/address-of-a-variable-1.st create mode 100644 Task/Address-of-a-variable/Smalltalk/address-of-a-variable-2.st create mode 100644 Task/Address-of-a-variable/Tcl/address-of-a-variable-1.tcl create mode 100644 Task/Address-of-a-variable/Tcl/address-of-a-variable-2.tcl create mode 100644 Task/Align-columns/0DESCRIPTION create mode 100644 Task/Align-columns/1META.yaml create mode 100644 Task/Align-columns/ABAP/align-columns.abap create mode 100644 Task/Align-columns/ALGOL-68/align-columns.alg create mode 100644 Task/Align-columns/AWK/align-columns.awk create mode 100644 Task/Align-columns/Ada/align-columns.ada create mode 100644 Task/Align-columns/AutoHotkey/align-columns.ahk create mode 100644 Task/Align-columns/Clojure/align-columns.clj create mode 100644 Task/Align-columns/CoffeeScript/align-columns-1.coffee create mode 100644 Task/Align-columns/CoffeeScript/align-columns-2.coffee create mode 100644 Task/Align-columns/Erlang/align-columns.erl create mode 100644 Task/Align-columns/Forth/align-columns.fth create mode 100644 Task/Align-columns/Go/align-columns.go create mode 100644 Task/Align-columns/Haskell/align-columns.hs create mode 100644 Task/Align-columns/JavaScript/align-columns.js create mode 100644 Task/Align-columns/Lua/align-columns-1.lua create mode 100644 Task/Align-columns/Lua/align-columns-2.lua create mode 100644 Task/Align-columns/PHP/align-columns.php create mode 100644 Task/Align-columns/Perl/align-columns-1.pl create mode 100644 Task/Align-columns/Perl/align-columns-2.pl create mode 100644 Task/Align-columns/PicoLisp/align-columns.l create mode 100644 Task/Align-columns/Prolog/align-columns.pro create mode 100644 Task/Align-columns/Python/align-columns-1.py create mode 100644 Task/Align-columns/Python/align-columns-2.py create mode 100644 Task/Align-columns/R/align-columns.r create mode 100644 Task/Align-columns/REXX/align-columns-1.rexx create mode 100644 Task/Align-columns/REXX/align-columns-2.rexx create mode 100644 Task/Align-columns/REXX/align-columns-3.rexx create mode 100644 Task/Align-columns/Racket/align-columns.rkt create mode 100644 Task/Align-columns/Ruby/align-columns.rb create mode 100644 Task/Align-columns/Scala/align-columns-1.scala create mode 100644 Task/Align-columns/Scala/align-columns-2.scala create mode 100644 Task/Align-columns/Tcl/align-columns.tcl create mode 100644 Task/Anagrams-Deranged-anagrams/0DESCRIPTION create mode 100644 Task/Anagrams-Deranged-anagrams/Ada/anagrams-deranged-anagrams.ada create mode 100644 Task/Anagrams-Deranged-anagrams/C/anagrams-deranged-anagrams.c create mode 100644 Task/Anagrams-Deranged-anagrams/Clojure/anagrams-deranged-anagrams.clj create mode 100644 Task/Anagrams-Deranged-anagrams/CoffeeScript/anagrams-deranged-anagrams.coffee create mode 100644 Task/Anagrams-Deranged-anagrams/Go/anagrams-deranged-anagrams.go create mode 100644 Task/Anagrams-Deranged-anagrams/Haskell/anagrams-deranged-anagrams.hs create mode 100644 Task/Anagrams-Deranged-anagrams/Java/anagrams-deranged-anagrams.java create mode 100644 Task/Anagrams-Deranged-anagrams/JavaScript/anagrams-deranged-anagrams-1.js create mode 100644 Task/Anagrams-Deranged-anagrams/JavaScript/anagrams-deranged-anagrams-2.js create mode 100644 Task/Anagrams-Deranged-anagrams/PHP/anagrams-deranged-anagrams.php create mode 100644 Task/Anagrams-Deranged-anagrams/Perl/anagrams-deranged-anagrams.pl create mode 100644 Task/Anagrams-Deranged-anagrams/PicoLisp/anagrams-deranged-anagrams.l create mode 100644 Task/Anagrams-Deranged-anagrams/Prolog/anagrams-deranged-anagrams.pro create mode 100644 Task/Anagrams-Deranged-anagrams/Python/anagrams-deranged-anagrams-1.py create mode 100644 Task/Anagrams-Deranged-anagrams/Python/anagrams-deranged-anagrams-2.py create mode 100644 Task/Anagrams-Deranged-anagrams/R/anagrams-deranged-anagrams-1.r create mode 100644 Task/Anagrams-Deranged-anagrams/R/anagrams-deranged-anagrams-2.r create mode 100644 Task/Anagrams-Deranged-anagrams/REXX/anagrams-deranged-anagrams.rexx create mode 100644 Task/Anagrams-Deranged-anagrams/Ruby/anagrams-deranged-anagrams.rb create mode 100644 Task/Anagrams-Deranged-anagrams/Scala/anagrams-deranged-anagrams.scala create mode 100644 Task/Anagrams-Deranged-anagrams/Tcl/anagrams-deranged-anagrams.tcl create mode 100644 Task/Animation/0DESCRIPTION create mode 100644 Task/Animation/1META.yaml create mode 100644 Task/Animation/ActionScript/animation.as create mode 100644 Task/Animation/Ada/animation.ada create mode 100644 Task/Animation/AutoHotkey/animation.ahk create mode 100644 Task/Animation/C/animation.c create mode 100644 Task/Animation/Clojure/animation.clj create mode 100644 Task/Animation/Haskell/animation-1.hs create mode 100644 Task/Animation/Haskell/animation-2.hs create mode 100644 Task/Animation/Java/animation.java create mode 100644 Task/Animation/JavaScript/animation.js create mode 100644 Task/Animation/Perl/animation.pl create mode 100644 Task/Animation/PicoLisp/animation-1.l create mode 100644 Task/Animation/PicoLisp/animation-2.l create mode 100644 Task/Animation/PicoLisp/animation-3.l create mode 100644 Task/Animation/Prolog/animation.pro create mode 100644 Task/Animation/Python/animation-1.py create mode 100644 Task/Animation/Python/animation-2.py create mode 100644 Task/Animation/R/animation.r create mode 100644 Task/Animation/Racket/animation.rkt create mode 100644 Task/Animation/Ruby/animation-1.rb create mode 100644 Task/Animation/Ruby/animation-2.rb create mode 100644 Task/Animation/Scala/animation.scala create mode 100644 Task/Animation/Tcl/animation.tcl create mode 100644 Task/Anonymous-recursion/0DESCRIPTION create mode 100644 Task/Anonymous-recursion/1META.yaml create mode 100644 Task/Anonymous-recursion/Ada/anonymous-recursion.ada create mode 100644 Task/Anonymous-recursion/AutoHotkey/anonymous-recursion-1.ahk create mode 100644 Task/Anonymous-recursion/AutoHotkey/anonymous-recursion-2.ahk create mode 100644 Task/Anonymous-recursion/Axiom/anonymous-recursion-1.axiom create mode 100644 Task/Anonymous-recursion/Axiom/anonymous-recursion-2.axiom create mode 100644 Task/Anonymous-recursion/C/anonymous-recursion.c create mode 100644 Task/Anonymous-recursion/Clojure/anonymous-recursion.clj create mode 100644 Task/Anonymous-recursion/CoffeeScript/anonymous-recursion.coffee create mode 100644 Task/Anonymous-recursion/Dylan/anonymous-recursion.dylan create mode 100644 Task/Anonymous-recursion/Forth/anonymous-recursion-1.fth create mode 100644 Task/Anonymous-recursion/Forth/anonymous-recursion-2.fth create mode 100644 Task/Anonymous-recursion/Fortran/anonymous-recursion.f create mode 100644 Task/Anonymous-recursion/Go/anonymous-recursion.go create mode 100644 Task/Anonymous-recursion/Haskell/anonymous-recursion-1.hs create mode 100644 Task/Anonymous-recursion/Haskell/anonymous-recursion-2.hs create mode 100644 Task/Anonymous-recursion/Haskell/anonymous-recursion-3.hs create mode 100644 Task/Anonymous-recursion/Java/anonymous-recursion-1.java create mode 100644 Task/Anonymous-recursion/Java/anonymous-recursion-2.java create mode 100644 Task/Anonymous-recursion/JavaScript/anonymous-recursion-1.js create mode 100644 Task/Anonymous-recursion/JavaScript/anonymous-recursion-2.js create mode 100644 Task/Anonymous-recursion/Lua/anonymous-recursion-1.lua create mode 100644 Task/Anonymous-recursion/Lua/anonymous-recursion-2.lua create mode 100644 Task/Anonymous-recursion/PHP/anonymous-recursion-1.php create mode 100644 Task/Anonymous-recursion/PHP/anonymous-recursion-2.php create mode 100644 Task/Anonymous-recursion/Perl/anonymous-recursion-1.pl create mode 100644 Task/Anonymous-recursion/Perl/anonymous-recursion-2.pl create mode 100644 Task/Anonymous-recursion/Perl/anonymous-recursion-3.pl create mode 100644 Task/Anonymous-recursion/Perl/anonymous-recursion-4.pl create mode 100644 Task/Anonymous-recursion/PicoLisp/anonymous-recursion-1.l create mode 100644 Task/Anonymous-recursion/PicoLisp/anonymous-recursion-2.l create mode 100644 Task/Anonymous-recursion/Prolog/anonymous-recursion.pro create mode 100644 Task/Anonymous-recursion/Python/anonymous-recursion-1.py create mode 100644 Task/Anonymous-recursion/Python/anonymous-recursion-2.py create mode 100644 Task/Anonymous-recursion/Python/anonymous-recursion-3.py create mode 100644 Task/Anonymous-recursion/R/anonymous-recursion.r create mode 100644 Task/Anonymous-recursion/REXX/anonymous-recursion.rexx create mode 100644 Task/Anonymous-recursion/Racket/anonymous-recursion-1.rkt create mode 100644 Task/Anonymous-recursion/Racket/anonymous-recursion-2.rkt create mode 100644 Task/Anonymous-recursion/Ruby/anonymous-recursion-1.rb create mode 100644 Task/Anonymous-recursion/Ruby/anonymous-recursion-2.rb create mode 100644 Task/Anonymous-recursion/Ruby/anonymous-recursion-3.rb create mode 100644 Task/Anonymous-recursion/Ruby/anonymous-recursion-4.rb create mode 100644 Task/Anonymous-recursion/Ruby/anonymous-recursion-5.rb create mode 100644 Task/Anonymous-recursion/Ruby/anonymous-recursion-6.rb create mode 100644 Task/Anonymous-recursion/Ruby/anonymous-recursion-7.rb create mode 100644 Task/Anonymous-recursion/Scala/anonymous-recursion.scala create mode 100644 Task/Anonymous-recursion/Scheme/anonymous-recursion.ss create mode 100644 Task/Anonymous-recursion/Tcl/anonymous-recursion-1.tcl create mode 100644 Task/Anonymous-recursion/Tcl/anonymous-recursion-2.tcl create mode 100644 Task/Anonymous-recursion/Tcl/anonymous-recursion-3.tcl create mode 100644 Task/Anonymous-recursion/Tcl/anonymous-recursion-4.tcl create mode 100644 Task/Apply-a-callback-to-an-array/0DESCRIPTION create mode 100644 Task/Apply-a-callback-to-an-array/1META.yaml create mode 100644 Task/Apply-a-callback-to-an-array/ACL2/apply-a-callback-to-an-array.acl2 create mode 100644 Task/Apply-a-callback-to-an-array/ALGOL-68/apply-a-callback-to-an-array.alg create mode 100644 Task/Apply-a-callback-to-an-array/AWK/apply-a-callback-to-an-array.awk create mode 100644 Task/Apply-a-callback-to-an-array/ActionScript/apply-a-callback-to-an-array.as create mode 100644 Task/Apply-a-callback-to-an-array/Ada/apply-a-callback-to-an-array.ada create mode 100644 Task/Apply-a-callback-to-an-array/Aime/apply-a-callback-to-an-array.aime create mode 100644 Task/Apply-a-callback-to-an-array/AutoHotkey/apply-a-callback-to-an-array.ahk create mode 100644 Task/Apply-a-callback-to-an-array/C/apply-a-callback-to-an-array-1.c create mode 100644 Task/Apply-a-callback-to-an-array/C/apply-a-callback-to-an-array-2.c create mode 100644 Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-1.clj create mode 100644 Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-2.clj create mode 100644 Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-3.clj create mode 100644 Task/Apply-a-callback-to-an-array/CoffeeScript/apply-a-callback-to-an-array.coffee create mode 100644 Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-1.erl create mode 100644 Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-2.erl create mode 100644 Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-3.erl create mode 100644 Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-4.erl create mode 100644 Task/Apply-a-callback-to-an-array/Forth/apply-a-callback-to-an-array-1.fth create mode 100644 Task/Apply-a-callback-to-an-array/Forth/apply-a-callback-to-an-array-2.fth create mode 100644 Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-1.f create mode 100644 Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-2.f create mode 100644 Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-3.f create mode 100644 Task/Apply-a-callback-to-an-array/Go/apply-a-callback-to-an-array-1.go create mode 100644 Task/Apply-a-callback-to-an-array/Go/apply-a-callback-to-an-array-2.go create mode 100644 Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-1.hs create mode 100644 Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-2.hs create mode 100644 Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-3.hs create mode 100644 Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-4.hs create mode 100644 Task/Apply-a-callback-to-an-array/Java/apply-a-callback-to-an-array-1.java create mode 100644 Task/Apply-a-callback-to-an-array/Java/apply-a-callback-to-an-array-2.java create mode 100644 Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-1.js create mode 100644 Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-2.js create mode 100644 Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-3.js create mode 100644 Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-4.js create mode 100644 Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-1.lua create mode 100644 Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-2.lua create mode 100644 Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-3.lua create mode 100644 Task/Apply-a-callback-to-an-array/PHP/apply-a-callback-to-an-array.php create mode 100644 Task/Apply-a-callback-to-an-array/Perl/apply-a-callback-to-an-array.pl create mode 100644 Task/Apply-a-callback-to-an-array/PicoLisp/apply-a-callback-to-an-array.l create mode 100644 Task/Apply-a-callback-to-an-array/Prolog/apply-a-callback-to-an-array.pro create mode 100644 Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-1.py create mode 100644 Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-2.py create mode 100644 Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-3.py create mode 100644 Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-4.py create mode 100644 Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-1.r create mode 100644 Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-2.r create mode 100644 Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-3.r create mode 100644 Task/Apply-a-callback-to-an-array/REXX/apply-a-callback-to-an-array.rexx create mode 100644 Task/Apply-a-callback-to-an-array/Racket/apply-a-callback-to-an-array.rkt create mode 100644 Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-1.rb create mode 100644 Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-2.rb create mode 100644 Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-3.rb create mode 100644 Task/Apply-a-callback-to-an-array/Sather/apply-a-callback-to-an-array.sa create mode 100644 Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-1.scala create mode 100644 Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-2.scala create mode 100644 Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-3.scala create mode 100644 Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-4.scala create mode 100644 Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-5.scala create mode 100644 Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-6.scala create mode 100644 Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-7.scala create mode 100644 Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-1.ss create mode 100644 Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-2.ss create mode 100644 Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-3.ss create mode 100644 Task/Apply-a-callback-to-an-array/Smalltalk/apply-a-callback-to-an-array.st create mode 100644 Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-1.tcl create mode 100644 Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-2.tcl create mode 100644 Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-3.tcl create mode 100644 Task/Arbitrary-precision-integers-(included)/0DESCRIPTION create mode 100644 Task/Arbitrary-precision-integers-(included)/1META.yaml create mode 100644 Task/Arbitrary-precision-integers-(included)/ACL2/arbitrary-precision-integers-(included).acl2 create mode 100644 Task/Arbitrary-precision-integers-(included)/Ada/arbitrary-precision-integers-(included).ada create mode 100644 Task/Arbitrary-precision-integers-(included)/Alore/arbitrary-precision-integers-(included).alore create mode 100644 Task/Arbitrary-precision-integers-(included)/C/arbitrary-precision-integers-(included)-1.c create mode 100644 Task/Arbitrary-precision-integers-(included)/C/arbitrary-precision-integers-(included)-2.c create mode 100644 Task/Arbitrary-precision-integers-(included)/Clojure/arbitrary-precision-integers-(included)-1.clj create mode 100644 Task/Arbitrary-precision-integers-(included)/Clojure/arbitrary-precision-integers-(included)-2.clj create mode 100644 Task/Arbitrary-precision-integers-(included)/Erlang/arbitrary-precision-integers-(included).erl create mode 100644 Task/Arbitrary-precision-integers-(included)/Go/arbitrary-precision-integers-(included).go create mode 100644 Task/Arbitrary-precision-integers-(included)/Haskell/arbitrary-precision-integers-(included).hs create mode 100644 Task/Arbitrary-precision-integers-(included)/Java/arbitrary-precision-integers-(included).java create mode 100644 Task/Arbitrary-precision-integers-(included)/PHP/arbitrary-precision-integers-(included).php create mode 100644 Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-1.pl create mode 100644 Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-2.pl create mode 100644 Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-3.pl create mode 100644 Task/Arbitrary-precision-integers-(included)/PicoLisp/arbitrary-precision-integers-(included).l create mode 100644 Task/Arbitrary-precision-integers-(included)/Python/arbitrary-precision-integers-(included).py create mode 100644 Task/Arbitrary-precision-integers-(included)/R/arbitrary-precision-integers-(included).r create mode 100644 Task/Arbitrary-precision-integers-(included)/REXX/arbitrary-precision-integers-(included)-1.rexx create mode 100644 Task/Arbitrary-precision-integers-(included)/REXX/arbitrary-precision-integers-(included)-2.rexx create mode 100644 Task/Arbitrary-precision-integers-(included)/Racket/arbitrary-precision-integers-(included).rkt create mode 100644 Task/Arbitrary-precision-integers-(included)/Ruby/arbitrary-precision-integers-(included).rb create mode 100644 Task/Arbitrary-precision-integers-(included)/Sather/arbitrary-precision-integers-(included).sa create mode 100644 Task/Arbitrary-precision-integers-(included)/Scala/arbitrary-precision-integers-(included).scala create mode 100644 Task/Arbitrary-precision-integers-(included)/Scheme/arbitrary-precision-integers-(included).ss create mode 100644 Task/Arbitrary-precision-integers-(included)/Smalltalk/arbitrary-precision-integers-(included)-1.st create mode 100644 Task/Arbitrary-precision-integers-(included)/Smalltalk/arbitrary-precision-integers-(included)-2.st create mode 100644 Task/Arbitrary-precision-integers-(included)/Tcl/arbitrary-precision-integers-(included).tcl create mode 100644 Task/Arena-storage-pool/0DESCRIPTION create mode 100644 Task/Arena-storage-pool/1META.yaml create mode 100644 Task/Arena-storage-pool/Ada/arena-storage-pool-1.ada create mode 100644 Task/Arena-storage-pool/Ada/arena-storage-pool-2.ada create mode 100644 Task/Arena-storage-pool/Ada/arena-storage-pool-3.ada create mode 100644 Task/Arena-storage-pool/Ada/arena-storage-pool-4.ada create mode 100644 Task/Arena-storage-pool/C/arena-storage-pool-1.c create mode 100644 Task/Arena-storage-pool/C/arena-storage-pool-2.c create mode 100644 Task/Arena-storage-pool/C/arena-storage-pool-3.c create mode 100644 Task/Arena-storage-pool/C/arena-storage-pool-4.c create mode 100644 Task/Arena-storage-pool/C/arena-storage-pool-5.c create mode 100644 Task/Arena-storage-pool/C/arena-storage-pool-6.c create mode 100644 Task/Arena-storage-pool/REXX/arena-storage-pool.rexx create mode 100644 Task/Arena-storage-pool/Tcl/arena-storage-pool-1.tcl create mode 100644 Task/Arena-storage-pool/Tcl/arena-storage-pool-2.tcl create mode 100644 Task/Arithmetic-Complex/0DESCRIPTION create mode 100644 Task/Arithmetic-Complex/1META.yaml create mode 100644 Task/Arithmetic-Complex/ALGOL-68/arithmetic-complex.alg create mode 100644 Task/Arithmetic-Complex/APL/arithmetic-complex.apl create mode 100644 Task/Arithmetic-Complex/Ada/arithmetic-complex.ada create mode 100644 Task/Arithmetic-Complex/AutoHotkey/arithmetic-complex.ahk create mode 100644 Task/Arithmetic-Complex/BASIC/arithmetic-complex.bas create mode 100644 Task/Arithmetic-Complex/C/arithmetic-complex-1.c create mode 100644 Task/Arithmetic-Complex/C/arithmetic-complex-2.c create mode 100644 Task/Arithmetic-Complex/CoffeeScript/arithmetic-complex-1.coffee create mode 100644 Task/Arithmetic-Complex/CoffeeScript/arithmetic-complex-2.coffee create mode 100644 Task/Arithmetic-Complex/Erlang/arithmetic-complex-1.erl create mode 100644 Task/Arithmetic-Complex/Erlang/arithmetic-complex-2.erl create mode 100644 Task/Arithmetic-Complex/Forth/arithmetic-complex.fth create mode 100644 Task/Arithmetic-Complex/Fortran/arithmetic-complex-1.f create mode 100644 Task/Arithmetic-Complex/Fortran/arithmetic-complex-2.f create mode 100644 Task/Arithmetic-Complex/Go/arithmetic-complex.go create mode 100644 Task/Arithmetic-Complex/Haskell/arithmetic-complex-1.hs create mode 100644 Task/Arithmetic-Complex/Haskell/arithmetic-complex-2.hs create mode 100644 Task/Arithmetic-Complex/Java/arithmetic-complex.java create mode 100644 Task/Arithmetic-Complex/JavaScript/arithmetic-complex.js create mode 100644 Task/Arithmetic-Complex/Lua/arithmetic-complex.lua create mode 100644 Task/Arithmetic-Complex/Perl/arithmetic-complex.pl create mode 100644 Task/Arithmetic-Complex/PicoLisp/arithmetic-complex.l create mode 100644 Task/Arithmetic-Complex/Python/arithmetic-complex.py create mode 100644 Task/Arithmetic-Complex/R/arithmetic-complex.r create mode 100644 Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx create mode 100644 Task/Arithmetic-Complex/Racket/arithmetic-complex.rkt create mode 100644 Task/Arithmetic-Complex/Ruby/arithmetic-complex-1.rb create mode 100644 Task/Arithmetic-Complex/Ruby/arithmetic-complex-2.rb create mode 100644 Task/Arithmetic-Complex/Scala/arithmetic-complex-1.scala create mode 100644 Task/Arithmetic-Complex/Scala/arithmetic-complex-2.scala create mode 100644 Task/Arithmetic-Complex/Scheme/arithmetic-complex.ss create mode 100644 Task/Arithmetic-Complex/Smalltalk/arithmetic-complex.st create mode 100644 Task/Arithmetic-Complex/Tcl/arithmetic-complex.tcl create mode 100644 Task/Arithmetic-Rational/0DESCRIPTION create mode 100644 Task/Arithmetic-Rational/1META.yaml create mode 100644 Task/Arithmetic-Rational/ALGOL-68/arithmetic-rational.alg create mode 100644 Task/Arithmetic-Rational/C/arithmetic-rational.c create mode 100644 Task/Arithmetic-Rational/Clojure/arithmetic-rational.clj create mode 100644 Task/Arithmetic-Rational/Forth/arithmetic-rational.fth create mode 100644 Task/Arithmetic-Rational/Fortran/arithmetic-rational-1.f create mode 100644 Task/Arithmetic-Rational/Fortran/arithmetic-rational-2.f create mode 100644 Task/Arithmetic-Rational/Go/arithmetic-rational.go create mode 100644 Task/Arithmetic-Rational/Haskell/arithmetic-rational.hs create mode 100644 Task/Arithmetic-Rational/Java/arithmetic-rational.java create mode 100644 Task/Arithmetic-Rational/Lua/arithmetic-rational.lua create mode 100644 Task/Arithmetic-Rational/Perl/arithmetic-rational.pl create mode 100644 Task/Arithmetic-Rational/PicoLisp/arithmetic-rational.l create mode 100644 Task/Arithmetic-Rational/Python/arithmetic-rational-1.py create mode 100644 Task/Arithmetic-Rational/Python/arithmetic-rational-2.py create mode 100644 Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx create mode 100644 Task/Arithmetic-Rational/Ruby/arithmetic-rational.rb create mode 100644 Task/Arithmetic-Rational/Scala/arithmetic-rational-1.scala create mode 100644 Task/Arithmetic-Rational/Scala/arithmetic-rational-2.scala create mode 100644 Task/Arithmetic-Rational/Scheme/arithmetic-rational.ss create mode 100644 Task/Arithmetic-Rational/Smalltalk/arithmetic-rational.st create mode 100644 Task/Arithmetic-evaluation/0DESCRIPTION create mode 100644 Task/Arithmetic-evaluation/1META.yaml create mode 100644 Task/Arithmetic-evaluation/ALGOL-68/arithmetic-evaluation.alg create mode 100644 Task/Arithmetic-evaluation/AutoHotkey/arithmetic-evaluation-1.ahk create mode 100644 Task/Arithmetic-evaluation/AutoHotkey/arithmetic-evaluation-2.ahk create mode 100644 Task/Arithmetic-evaluation/Clojure/arithmetic-evaluation.clj create mode 100644 Task/Arithmetic-evaluation/Haskell/arithmetic-evaluation.hs create mode 100644 Task/Arithmetic-evaluation/Java/arithmetic-evaluation.java create mode 100644 Task/Arithmetic-evaluation/JavaScript/arithmetic-evaluation.js create mode 100644 Task/Arithmetic-evaluation/Lua/arithmetic-evaluation.lua create mode 100644 Task/Arithmetic-evaluation/Perl/arithmetic-evaluation.pl create mode 100644 Task/Arithmetic-evaluation/PicoLisp/arithmetic-evaluation-1.l create mode 100644 Task/Arithmetic-evaluation/PicoLisp/arithmetic-evaluation-2.l create mode 100644 Task/Arithmetic-evaluation/Prolog/arithmetic-evaluation.pro create mode 100644 Task/Arithmetic-evaluation/Python/arithmetic-evaluation-1.py create mode 100644 Task/Arithmetic-evaluation/Python/arithmetic-evaluation-2.py create mode 100644 Task/Arithmetic-evaluation/REXX/arithmetic-evaluation.rexx create mode 100644 Task/Arithmetic-evaluation/Ruby/arithmetic-evaluation-1.rb create mode 100644 Task/Arithmetic-evaluation/Ruby/arithmetic-evaluation-2.rb create mode 100644 Task/Arithmetic-evaluation/Scala/arithmetic-evaluation.scala create mode 100644 Task/Arithmetic-evaluation/Tcl/arithmetic-evaluation.tcl create mode 100644 Task/Arithmetic-geometric-mean/0DESCRIPTION create mode 100644 Task/Arithmetic-geometric-mean/Ada/arithmetic-geometric-mean.ada create mode 100644 Task/Arithmetic-geometric-mean/AutoHotkey/arithmetic-geometric-mean.ahk create mode 100644 Task/Arithmetic-geometric-mean/C/arithmetic-geometric-mean.c create mode 100644 Task/Arithmetic-geometric-mean/Erlang/arithmetic-geometric-mean-1.erl create mode 100644 Task/Arithmetic-geometric-mean/Erlang/arithmetic-geometric-mean-2.erl create mode 100644 Task/Arithmetic-geometric-mean/Fortran/arithmetic-geometric-mean.f create mode 100644 Task/Arithmetic-geometric-mean/Go/arithmetic-geometric-mean-1.go create mode 100644 Task/Arithmetic-geometric-mean/Go/arithmetic-geometric-mean-2.go create mode 100644 Task/Arithmetic-geometric-mean/Haskell/arithmetic-geometric-mean.hs create mode 100644 Task/Arithmetic-geometric-mean/Java/arithmetic-geometric-mean.java create mode 100644 Task/Arithmetic-geometric-mean/PHP/arithmetic-geometric-mean.php create mode 100644 Task/Arithmetic-geometric-mean/Perl/arithmetic-geometric-mean.pl create mode 100644 Task/Arithmetic-geometric-mean/PicoLisp/arithmetic-geometric-mean.l create mode 100644 Task/Arithmetic-geometric-mean/Python/arithmetic-geometric-mean-1.py create mode 100644 Task/Arithmetic-geometric-mean/Python/arithmetic-geometric-mean-2.py create mode 100644 Task/Arithmetic-geometric-mean/R/arithmetic-geometric-mean-1.r create mode 100644 Task/Arithmetic-geometric-mean/R/arithmetic-geometric-mean-2.r create mode 100644 Task/Arithmetic-geometric-mean/REXX/arithmetic-geometric-mean.rexx create mode 100644 Task/Arithmetic-geometric-mean/Racket/arithmetic-geometric-mean-1.rkt create mode 100644 Task/Arithmetic-geometric-mean/Racket/arithmetic-geometric-mean-2.rkt create mode 100644 Task/Arithmetic-geometric-mean/Ruby/arithmetic-geometric-mean.rb create mode 100644 Task/Arithmetic-geometric-mean/Scala/arithmetic-geometric-mean.scala create mode 100644 Task/Arithmetic-geometric-mean/Tcl/arithmetic-geometric-mean.tcl create mode 100644 Task/Array-concatenation/0DESCRIPTION create mode 100644 Task/Array-concatenation/1META.yaml create mode 100644 Task/Array-concatenation/ACL2/array-concatenation.acl2 create mode 100644 Task/Array-concatenation/ALGOL-68/array-concatenation.alg create mode 100644 Task/Array-concatenation/APL/array-concatenation.apl create mode 100644 Task/Array-concatenation/ActionScript/array-concatenation.as create mode 100644 Task/Array-concatenation/Ada/array-concatenation.ada create mode 100644 Task/Array-concatenation/AutoHotkey/array-concatenation-1.ahk create mode 100644 Task/Array-concatenation/AutoHotkey/array-concatenation-2.ahk create mode 100644 Task/Array-concatenation/AutoIt/array-concatenation.autoit create mode 100644 Task/Array-concatenation/Babel/array-concatenation.pb create mode 100644 Task/Array-concatenation/C/array-concatenation.c create mode 100644 Task/Array-concatenation/Clojure/array-concatenation.clj create mode 100644 Task/Array-concatenation/CoffeeScript/array-concatenation.coffee create mode 100644 Task/Array-concatenation/Erlang/array-concatenation.erl create mode 100644 Task/Array-concatenation/Forth/array-concatenation.fth create mode 100644 Task/Array-concatenation/Fortran/array-concatenation.f create mode 100644 Task/Array-concatenation/Go/array-concatenation-1.go create mode 100644 Task/Array-concatenation/Go/array-concatenation-2.go create mode 100644 Task/Array-concatenation/Haskell/array-concatenation.hs create mode 100644 Task/Array-concatenation/Java/array-concatenation-1.java create mode 100644 Task/Array-concatenation/Java/array-concatenation-2.java create mode 100644 Task/Array-concatenation/JavaScript/array-concatenation.js create mode 100644 Task/Array-concatenation/Lua/array-concatenation.lua create mode 100644 Task/Array-concatenation/PHP/array-concatenation.php create mode 100644 Task/Array-concatenation/Perl/array-concatenation-1.pl create mode 100644 Task/Array-concatenation/Perl/array-concatenation-2.pl create mode 100644 Task/Array-concatenation/PicoLisp/array-concatenation-1.l create mode 100644 Task/Array-concatenation/PicoLisp/array-concatenation-2.l create mode 100644 Task/Array-concatenation/Prolog/array-concatenation.pro create mode 100644 Task/Array-concatenation/Python/array-concatenation-1.py create mode 100644 Task/Array-concatenation/Python/array-concatenation-2.py create mode 100644 Task/Array-concatenation/R/array-concatenation.r create mode 100644 Task/Array-concatenation/REXX/array-concatenation-1.rexx create mode 100644 Task/Array-concatenation/REXX/array-concatenation-2.rexx create mode 100644 Task/Array-concatenation/REXX/array-concatenation-3.rexx create mode 100644 Task/Array-concatenation/Racket/array-concatenation.rkt create mode 100644 Task/Array-concatenation/Ruby/array-concatenation.rb create mode 100644 Task/Array-concatenation/Scala/array-concatenation.scala create mode 100644 Task/Array-concatenation/Scheme/array-concatenation.ss create mode 100644 Task/Array-concatenation/Smalltalk/array-concatenation.st create mode 100644 Task/Array-concatenation/Tcl/array-concatenation.tcl create mode 100644 Task/Associative-array-Creation/0DESCRIPTION create mode 100644 Task/Associative-array-Creation/1META.yaml create mode 100644 Task/Associative-array-Creation/ALGOL-68/associative-array-creation.alg create mode 100644 Task/Associative-array-Creation/APL/associative-array-creation.apl create mode 100644 Task/Associative-array-Creation/AWK/associative-array-creation.awk create mode 100644 Task/Associative-array-Creation/ActionScript/associative-array-creation.as create mode 100644 Task/Associative-array-Creation/Ada/associative-array-creation.ada create mode 100644 Task/Associative-array-Creation/Aikido/associative-array-creation.aikido create mode 100644 Task/Associative-array-Creation/AutoHotkey/associative-array-creation-1.ahk create mode 100644 Task/Associative-array-Creation/AutoHotkey/associative-array-creation-2.ahk create mode 100644 Task/Associative-array-Creation/Clojure/associative-array-creation.clj create mode 100644 Task/Associative-array-Creation/Erlang/associative-array-creation.erl create mode 100644 Task/Associative-array-Creation/Forth/associative-array-creation-1.fth create mode 100644 Task/Associative-array-Creation/Forth/associative-array-creation-2.fth create mode 100644 Task/Associative-array-Creation/Go/associative-array-creation.go create mode 100644 Task/Associative-array-Creation/Haskell/associative-array-creation-1.hs create mode 100644 Task/Associative-array-Creation/Haskell/associative-array-creation-2.hs create mode 100644 Task/Associative-array-Creation/Java/associative-array-creation-1.java create mode 100644 Task/Associative-array-Creation/Java/associative-array-creation-2.java create mode 100644 Task/Associative-array-Creation/Java/associative-array-creation-3.java create mode 100644 Task/Associative-array-Creation/Java/associative-array-creation-4.java create mode 100644 Task/Associative-array-Creation/Java/associative-array-creation-5.java create mode 100644 Task/Associative-array-Creation/Java/associative-array-creation-6.java create mode 100644 Task/Associative-array-Creation/JavaScript/associative-array-creation-1.js create mode 100644 Task/Associative-array-Creation/JavaScript/associative-array-creation-2.js create mode 100644 Task/Associative-array-Creation/JavaScript/associative-array-creation-3.js create mode 100644 Task/Associative-array-Creation/Lua/associative-array-creation.lua create mode 100644 Task/Associative-array-Creation/PHP/associative-array-creation-1.php create mode 100644 Task/Associative-array-Creation/PHP/associative-array-creation-2.php create mode 100644 Task/Associative-array-Creation/Perl/associative-array-creation-1.pl create mode 100644 Task/Associative-array-Creation/Perl/associative-array-creation-2.pl create mode 100644 Task/Associative-array-Creation/Perl/associative-array-creation-3.pl create mode 100644 Task/Associative-array-Creation/Perl/associative-array-creation-4.pl create mode 100644 Task/Associative-array-Creation/PicoLisp/associative-array-creation.l create mode 100644 Task/Associative-array-Creation/Prolog/associative-array-creation.pro create mode 100644 Task/Associative-array-Creation/Python/associative-array-creation-1.py create mode 100644 Task/Associative-array-Creation/Python/associative-array-creation-2.py create mode 100644 Task/Associative-array-Creation/Python/associative-array-creation-3.py create mode 100644 Task/Associative-array-Creation/R/associative-array-creation-1.r create mode 100644 Task/Associative-array-Creation/R/associative-array-creation-10.r create mode 100644 Task/Associative-array-Creation/R/associative-array-creation-11.r create mode 100644 Task/Associative-array-Creation/R/associative-array-creation-2.r create mode 100644 Task/Associative-array-Creation/R/associative-array-creation-3.r create mode 100644 Task/Associative-array-Creation/R/associative-array-creation-4.r create mode 100644 Task/Associative-array-Creation/R/associative-array-creation-5.r create mode 100644 Task/Associative-array-Creation/R/associative-array-creation-6.r create mode 100644 Task/Associative-array-Creation/R/associative-array-creation-7.r create mode 100644 Task/Associative-array-Creation/R/associative-array-creation-8.r create mode 100644 Task/Associative-array-Creation/R/associative-array-creation-9.r create mode 100644 Task/Associative-array-Creation/REXX/associative-array-creation-1.rexx create mode 100644 Task/Associative-array-Creation/REXX/associative-array-creation-2.rexx create mode 100644 Task/Associative-array-Creation/Racket/associative-array-creation.rkt create mode 100644 Task/Associative-array-Creation/Ruby/associative-array-creation-1.rb create mode 100644 Task/Associative-array-Creation/Ruby/associative-array-creation-2.rb create mode 100644 Task/Associative-array-Creation/Ruby/associative-array-creation-3.rb create mode 100644 Task/Associative-array-Creation/Ruby/associative-array-creation-4.rb create mode 100644 Task/Associative-array-Creation/Sather/associative-array-creation.sa create mode 100644 Task/Associative-array-Creation/Scala/associative-array-creation-1.scala create mode 100644 Task/Associative-array-Creation/Scala/associative-array-creation-2.scala create mode 100644 Task/Associative-array-Creation/Scala/associative-array-creation-3.scala create mode 100644 Task/Associative-array-Creation/Scala/associative-array-creation-4.scala create mode 100644 Task/Associative-array-Creation/Scheme/associative-array-creation-1.ss create mode 100644 Task/Associative-array-Creation/Scheme/associative-array-creation-2.ss create mode 100644 Task/Associative-array-Creation/Smalltalk/associative-array-creation.st create mode 100644 Task/Associative-array-Creation/Tcl/associative-array-creation-1.tcl create mode 100644 Task/Associative-array-Creation/Tcl/associative-array-creation-2.tcl create mode 100644 Task/Associative-array-Iteration/0DESCRIPTION create mode 100644 Task/Associative-array-Iteration/1META.yaml create mode 100644 Task/Associative-array-Iteration/AWK/associative-array-iteration.awk create mode 100644 Task/Associative-array-Iteration/Ada/associative-array-iteration.ada create mode 100644 Task/Associative-array-Iteration/AutoHotkey/associative-array-iteration.ahk create mode 100644 Task/Associative-array-Iteration/Clojure/associative-array-iteration.clj create mode 100644 Task/Associative-array-Iteration/CoffeeScript/associative-array-iteration.coffee create mode 100644 Task/Associative-array-Iteration/Erlang/associative-array-iteration.erl create mode 100644 Task/Associative-array-Iteration/Forth/associative-array-iteration.fth create mode 100644 Task/Associative-array-Iteration/Go/associative-array-iteration.go create mode 100644 Task/Associative-array-Iteration/Haskell/associative-array-iteration.hs create mode 100644 Task/Associative-array-Iteration/Java/associative-array-iteration.java create mode 100644 Task/Associative-array-Iteration/JavaScript/associative-array-iteration-1.js create mode 100644 Task/Associative-array-Iteration/JavaScript/associative-array-iteration-2.js create mode 100644 Task/Associative-array-Iteration/Lua/associative-array-iteration.lua create mode 100644 Task/Associative-array-Iteration/PHP/associative-array-iteration.php create mode 100644 Task/Associative-array-Iteration/Perl/associative-array-iteration.pl create mode 100644 Task/Associative-array-Iteration/PicoLisp/associative-array-iteration-1.l create mode 100644 Task/Associative-array-Iteration/PicoLisp/associative-array-iteration-2.l create mode 100644 Task/Associative-array-Iteration/Python/associative-array-iteration.py create mode 100644 Task/Associative-array-Iteration/R/associative-array-iteration-1.r create mode 100644 Task/Associative-array-Iteration/R/associative-array-iteration-2.r create mode 100644 Task/Associative-array-Iteration/R/associative-array-iteration-3.r create mode 100644 Task/Associative-array-Iteration/R/associative-array-iteration-4.r create mode 100644 Task/Associative-array-Iteration/R/associative-array-iteration-5.r create mode 100644 Task/Associative-array-Iteration/R/associative-array-iteration-6.r create mode 100644 Task/Associative-array-Iteration/REXX/associative-array-iteration.rexx create mode 100644 Task/Associative-array-Iteration/Racket/associative-array-iteration.rkt create mode 100644 Task/Associative-array-Iteration/Ruby/associative-array-iteration.rb create mode 100644 Task/Associative-array-Iteration/Scala/associative-array-iteration.scala create mode 100644 Task/Associative-array-Iteration/Smalltalk/associative-array-iteration-1.st create mode 100644 Task/Associative-array-Iteration/Smalltalk/associative-array-iteration-2.st create mode 100644 Task/Associative-array-Iteration/Tcl/associative-array-iteration-1.tcl create mode 100644 Task/Associative-array-Iteration/Tcl/associative-array-iteration-2.tcl create mode 100644 Task/Atomic-updates/0DESCRIPTION create mode 100644 Task/Atomic-updates/1META.yaml create mode 100644 Task/Atomic-updates/Ada/atomic-updates.ada create mode 100644 Task/Atomic-updates/C/atomic-updates-1.c create mode 100644 Task/Atomic-updates/C/atomic-updates-2.c create mode 100644 Task/Atomic-updates/C/atomic-updates-3.c create mode 100644 Task/Atomic-updates/Clojure/atomic-updates-1.clj create mode 100644 Task/Atomic-updates/Clojure/atomic-updates-2.clj create mode 100644 Task/Atomic-updates/Clojure/atomic-updates-3.clj create mode 100644 Task/Atomic-updates/Go/atomic-updates-1.go create mode 100644 Task/Atomic-updates/Go/atomic-updates-2.go create mode 100644 Task/Atomic-updates/Go/atomic-updates-3.go create mode 100644 Task/Atomic-updates/Go/atomic-updates-4.go create mode 100644 Task/Atomic-updates/Go/atomic-updates-5.go create mode 100644 Task/Atomic-updates/Haskell/atomic-updates.hs create mode 100644 Task/Atomic-updates/Java/atomic-updates.java create mode 100644 Task/Atomic-updates/Perl/atomic-updates.pl create mode 100644 Task/Atomic-updates/PicoLisp/atomic-updates.l create mode 100644 Task/Atomic-updates/Python/atomic-updates.py create mode 100644 Task/Atomic-updates/Ruby/atomic-updates.rb create mode 100644 Task/Atomic-updates/Scala/atomic-updates.scala create mode 100644 Task/Atomic-updates/Tcl/atomic-updates.tcl create mode 100644 Task/Average-loop-length/0DESCRIPTION create mode 100644 Task/Average-loop-length/Ada/average-loop-length.ada create mode 100644 Task/Average-loop-length/C/average-loop-length.c create mode 100644 Task/Average-loop-length/Python/average-loop-length.py create mode 100644 Task/Average-loop-length/REXX/average-loop-length.rexx create mode 100644 Task/Average-loop-length/Tcl/average-loop-length.tcl create mode 100644 Task/Averages-Arithmetic-mean/0DESCRIPTION create mode 100644 Task/Averages-Arithmetic-mean/1META.yaml create mode 100644 Task/Averages-Arithmetic-mean/6502-Assembly/averages-arithmetic-mean.6502 create mode 100644 Task/Averages-Arithmetic-mean/ACL2/averages-arithmetic-mean.acl2 create mode 100644 Task/Averages-Arithmetic-mean/ALGOL-68/averages-arithmetic-mean.alg create mode 100644 Task/Averages-Arithmetic-mean/APL/averages-arithmetic-mean.apl create mode 100644 Task/Averages-Arithmetic-mean/AWK/averages-arithmetic-mean.awk create mode 100644 Task/Averages-Arithmetic-mean/ActionScript/averages-arithmetic-mean.as create mode 100644 Task/Averages-Arithmetic-mean/Ada/averages-arithmetic-mean.ada create mode 100644 Task/Averages-Arithmetic-mean/AmigaE/averages-arithmetic-mean.amiga create mode 100644 Task/Averages-Arithmetic-mean/AutoHotkey/averages-arithmetic-mean.ahk create mode 100644 Task/Averages-Arithmetic-mean/BASIC/averages-arithmetic-mean.bas create mode 100644 Task/Averages-Arithmetic-mean/Befunge/averages-arithmetic-mean.bf create mode 100644 Task/Averages-Arithmetic-mean/C/averages-arithmetic-mean.c create mode 100644 Task/Averages-Arithmetic-mean/Clojure/averages-arithmetic-mean.clj create mode 100644 Task/Averages-Arithmetic-mean/CoffeeScript/averages-arithmetic-mean.coffee create mode 100644 Task/Averages-Arithmetic-mean/Erlang/averages-arithmetic-mean.erl create mode 100644 Task/Averages-Arithmetic-mean/Forth/averages-arithmetic-mean.fth create mode 100644 Task/Averages-Arithmetic-mean/Fortran/averages-arithmetic-mean.f create mode 100644 Task/Averages-Arithmetic-mean/Go/averages-arithmetic-mean.go create mode 100644 Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-1.hs create mode 100644 Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-2.hs create mode 100644 Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-3.hs create mode 100644 Task/Averages-Arithmetic-mean/Java/averages-arithmetic-mean.java create mode 100644 Task/Averages-Arithmetic-mean/JavaScript/averages-arithmetic-mean-1.js create mode 100644 Task/Averages-Arithmetic-mean/JavaScript/averages-arithmetic-mean-2.js create mode 100644 Task/Averages-Arithmetic-mean/Lua/averages-arithmetic-mean.lua create mode 100644 Task/Averages-Arithmetic-mean/PHP/averages-arithmetic-mean.php create mode 100644 Task/Averages-Arithmetic-mean/Perl/averages-arithmetic-mean-1.pl create mode 100644 Task/Averages-Arithmetic-mean/Perl/averages-arithmetic-mean-2.pl create mode 100644 Task/Averages-Arithmetic-mean/PicoLisp/averages-arithmetic-mean.l create mode 100644 Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-1.py create mode 100644 Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-2.py create mode 100644 Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-3.py create mode 100644 Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-4.py create mode 100644 Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-5.py create mode 100644 Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-6.py create mode 100644 Task/Averages-Arithmetic-mean/R/averages-arithmetic-mean.r create mode 100644 Task/Averages-Arithmetic-mean/REXX/averages-arithmetic-mean.rexx create mode 100644 Task/Averages-Arithmetic-mean/Racket/averages-arithmetic-mean.rkt create mode 100644 Task/Averages-Arithmetic-mean/Ruby/averages-arithmetic-mean.rb create mode 100644 Task/Averages-Arithmetic-mean/Sather/averages-arithmetic-mean.sa create mode 100644 Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-1.scala create mode 100644 Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-2.scala create mode 100644 Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-3.scala create mode 100644 Task/Averages-Arithmetic-mean/Scheme/averages-arithmetic-mean.ss create mode 100644 Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-1.st create mode 100644 Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-2.st create mode 100644 Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-3.st create mode 100644 Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-4.st create mode 100644 Task/Averages-Arithmetic-mean/Tcl/averages-arithmetic-mean.tcl create mode 100644 Task/Averages-Mean-angle/0DESCRIPTION create mode 100644 Task/Averages-Mean-angle/Ada/averages-mean-angle.ada create mode 100644 Task/Averages-Mean-angle/C/averages-mean-angle.c create mode 100644 Task/Averages-Mean-angle/Go/averages-mean-angle.go create mode 100644 Task/Averages-Mean-angle/Haskell/averages-mean-angle.hs create mode 100644 Task/Averages-Mean-angle/PicoLisp/averages-mean-angle.l create mode 100644 Task/Averages-Mean-angle/Python/averages-mean-angle.py create mode 100644 Task/Averages-Mean-angle/REXX/averages-mean-angle.rexx create mode 100644 Task/Averages-Mean-angle/Racket/averages-mean-angle.rkt create mode 100644 Task/Averages-Mean-angle/Ruby/averages-mean-angle.rb create mode 100644 Task/Averages-Mean-angle/Tcl/averages-mean-angle-1.tcl create mode 100644 Task/Averages-Mean-angle/Tcl/averages-mean-angle-2.tcl create mode 100644 Task/Averages-Mean-time-of-day/0DESCRIPTION create mode 100644 Task/Averages-Mean-time-of-day/1META.yaml create mode 100644 Task/Averages-Mean-time-of-day/C/averages-mean-time-of-day.c create mode 100644 Task/Averages-Mean-time-of-day/Go/averages-mean-time-of-day.go create mode 100644 Task/Averages-Mean-time-of-day/PicoLisp/averages-mean-time-of-day-1.l create mode 100644 Task/Averages-Mean-time-of-day/PicoLisp/averages-mean-time-of-day-2.l create mode 100644 Task/Averages-Mean-time-of-day/Python/averages-mean-time-of-day.py create mode 100644 Task/Averages-Mean-time-of-day/Tcl/averages-mean-time-of-day.tcl create mode 100644 Task/Averages-Median/0DESCRIPTION create mode 100644 Task/Averages-Median/1META.yaml create mode 100644 Task/Averages-Median/AWK/averages-median.awk create mode 100644 Task/Averages-Median/Ada/averages-median.ada create mode 100644 Task/Averages-Median/AppleScript/averages-median.applescript create mode 100644 Task/Averages-Median/AutoHotkey/averages-median.ahk create mode 100644 Task/Averages-Median/BASIC/averages-median.bas create mode 100644 Task/Averages-Median/C/averages-median-1.c create mode 100644 Task/Averages-Median/C/averages-median-2.c create mode 100644 Task/Averages-Median/Clojure/averages-median.clj create mode 100644 Task/Averages-Median/Erlang/averages-median.erl create mode 100644 Task/Averages-Median/Forth/averages-median-1.fth create mode 100644 Task/Averages-Median/Forth/averages-median-2.fth create mode 100644 Task/Averages-Median/Fortran/averages-median.f create mode 100644 Task/Averages-Median/Go/averages-median.go create mode 100644 Task/Averages-Median/Haskell/averages-median-1.hs create mode 100644 Task/Averages-Median/Haskell/averages-median-2.hs create mode 100644 Task/Averages-Median/Java/averages-median-1.java create mode 100644 Task/Averages-Median/Java/averages-median-2.java create mode 100644 Task/Averages-Median/JavaScript/averages-median.js create mode 100644 Task/Averages-Median/Lua/averages-median.lua create mode 100644 Task/Averages-Median/PHP/averages-median.php create mode 100644 Task/Averages-Median/Perl/averages-median.pl create mode 100644 Task/Averages-Median/PicoLisp/averages-median.l create mode 100644 Task/Averages-Median/Prolog/averages-median.pro create mode 100644 Task/Averages-Median/Python/averages-median.py create mode 100644 Task/Averages-Median/R/averages-median.r create mode 100644 Task/Averages-Median/REXX/averages-median.rexx create mode 100644 Task/Averages-Median/Racket/averages-median.rkt create mode 100644 Task/Averages-Median/Ruby/averages-median-1.rb create mode 100644 Task/Averages-Median/Ruby/averages-median-2.rb create mode 100644 Task/Averages-Median/Scala/averages-median.scala create mode 100644 Task/Averages-Median/Scheme/averages-median-1.ss create mode 100644 Task/Averages-Median/Scheme/averages-median-2.ss create mode 100644 Task/Averages-Median/Smalltalk/averages-median-1.st create mode 100644 Task/Averages-Median/Smalltalk/averages-median-2.st create mode 100644 Task/Averages-Median/Tcl/averages-median.tcl create mode 100644 Task/Averages-Mode/0DESCRIPTION create mode 100644 Task/Averages-Mode/1META.yaml create mode 100644 Task/Averages-Pythagorean-means/0DESCRIPTION create mode 100644 Task/Averages-Pythagorean-means/ALGOL-68/averages-pythagorean-means.alg create mode 100644 Task/Averages-Pythagorean-means/APL/averages-pythagorean-means.apl create mode 100644 Task/Averages-Pythagorean-means/AWK/averages-pythagorean-means.awk create mode 100644 Task/Averages-Pythagorean-means/ActionScript/averages-pythagorean-means.as create mode 100644 Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-1.ada create mode 100644 Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-2.ada create mode 100644 Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-3.ada create mode 100644 Task/Averages-Pythagorean-means/AutoHotkey/averages-pythagorean-means.ahk create mode 100644 Task/Averages-Pythagorean-means/C/averages-pythagorean-means.c create mode 100644 Task/Averages-Pythagorean-means/Clojure/averages-pythagorean-means.clj create mode 100644 Task/Averages-Pythagorean-means/Erlang/averages-pythagorean-means-1.erl create mode 100644 Task/Averages-Pythagorean-means/Erlang/averages-pythagorean-means-2.erl create mode 100644 Task/Averages-Pythagorean-means/Forth/averages-pythagorean-means.fth create mode 100644 Task/Averages-Pythagorean-means/Fortran/averages-pythagorean-means.f create mode 100644 Task/Averages-Pythagorean-means/Go/averages-pythagorean-means.go create mode 100644 Task/Averages-Pythagorean-means/Haskell/averages-pythagorean-means.hs create mode 100644 Task/Averages-Pythagorean-means/Java/averages-pythagorean-means.java create mode 100644 Task/Averages-Pythagorean-means/JavaScript/averages-pythagorean-means.js create mode 100644 Task/Averages-Pythagorean-means/Lua/averages-pythagorean-means.lua create mode 100644 Task/Averages-Pythagorean-means/Perl/averages-pythagorean-means.pl create mode 100644 Task/Averages-Pythagorean-means/PicoLisp/averages-pythagorean-means.l create mode 100644 Task/Averages-Pythagorean-means/Python/averages-pythagorean-means.py create mode 100644 Task/Averages-Pythagorean-means/R/averages-pythagorean-means-1.r create mode 100644 Task/Averages-Pythagorean-means/R/averages-pythagorean-means-2.r create mode 100644 Task/Averages-Pythagorean-means/R/averages-pythagorean-means-3.r create mode 100644 Task/Averages-Pythagorean-means/R/averages-pythagorean-means-4.r create mode 100644 Task/Averages-Pythagorean-means/R/averages-pythagorean-means-5.r create mode 100644 Task/Averages-Pythagorean-means/R/averages-pythagorean-means-6.r create mode 100644 Task/Averages-Pythagorean-means/R/averages-pythagorean-means-7.r create mode 100644 Task/Averages-Pythagorean-means/REXX/averages-pythagorean-means.rexx create mode 100644 Task/Averages-Pythagorean-means/Racket/averages-pythagorean-means.rkt create mode 100644 Task/Averages-Pythagorean-means/Ruby/averages-pythagorean-means.rb create mode 100644 Task/Averages-Pythagorean-means/Scala/averages-pythagorean-means.scala create mode 100644 Task/Averages-Pythagorean-means/Scheme/averages-pythagorean-means-1.ss create mode 100644 Task/Averages-Pythagorean-means/Scheme/averages-pythagorean-means-2.ss create mode 100644 Task/Averages-Pythagorean-means/Smalltalk/averages-pythagorean-means.st create mode 100644 Task/Averages-Pythagorean-means/Tcl/averages-pythagorean-means.tcl create mode 100644 Task/Averages-Root-mean-square/0DESCRIPTION create mode 100644 Task/Averages-Root-mean-square/ALGOL-68/averages-root-mean-square.alg create mode 100644 Task/Averages-Root-mean-square/APL/averages-root-mean-square.apl create mode 100644 Task/Averages-Root-mean-square/AWK/averages-root-mean-square.awk create mode 100644 Task/Averages-Root-mean-square/Ada/averages-root-mean-square.ada create mode 100644 Task/Averages-Root-mean-square/AutoHotkey/averages-root-mean-square-1.ahk create mode 100644 Task/Averages-Root-mean-square/AutoHotkey/averages-root-mean-square-2.ahk create mode 100644 Task/Averages-Root-mean-square/BASIC/averages-root-mean-square.bas create mode 100644 Task/Averages-Root-mean-square/C/averages-root-mean-square.c create mode 100644 Task/Averages-Root-mean-square/Clojure/averages-root-mean-square.clj create mode 100644 Task/Averages-Root-mean-square/CoffeeScript/averages-root-mean-square.coffee create mode 100644 Task/Averages-Root-mean-square/Erlang/averages-root-mean-square.erl create mode 100644 Task/Averages-Root-mean-square/Forth/averages-root-mean-square.fth create mode 100644 Task/Averages-Root-mean-square/Fortran/averages-root-mean-square.f create mode 100644 Task/Averages-Root-mean-square/Go/averages-root-mean-square.go create mode 100644 Task/Averages-Root-mean-square/Haskell/averages-root-mean-square.hs create mode 100644 Task/Averages-Root-mean-square/Java/averages-root-mean-square.java create mode 100644 Task/Averages-Root-mean-square/JavaScript/averages-root-mean-square.js create mode 100644 Task/Averages-Root-mean-square/Lua/averages-root-mean-square.lua create mode 100644 Task/Averages-Root-mean-square/Perl/averages-root-mean-square.pl create mode 100644 Task/Averages-Root-mean-square/PicoLisp/averages-root-mean-square.l create mode 100644 Task/Averages-Root-mean-square/Python/averages-root-mean-square.py create mode 100644 Task/Averages-Root-mean-square/R/averages-root-mean-square-1.r create mode 100644 Task/Averages-Root-mean-square/R/averages-root-mean-square-2.r create mode 100644 Task/Averages-Root-mean-square/REXX/averages-root-mean-square.rexx create mode 100644 Task/Averages-Root-mean-square/Ruby/averages-root-mean-square-1.rb create mode 100644 Task/Averages-Root-mean-square/Ruby/averages-root-mean-square-2.rb create mode 100644 Task/Averages-Root-mean-square/Sather/averages-root-mean-square.sa create mode 100644 Task/Averages-Root-mean-square/Scala/averages-root-mean-square.scala create mode 100644 Task/Averages-Root-mean-square/Scheme/averages-root-mean-square.ss create mode 100644 Task/Averages-Root-mean-square/Smalltalk/averages-root-mean-square.st create mode 100644 Task/Averages-Root-mean-square/Tcl/averages-root-mean-square.tcl create mode 100644 Task/Averages-Simple-moving-average/0DESCRIPTION create mode 100644 Task/Averages-Simple-moving-average/1META.yaml create mode 100644 Task/Averages-Simple-moving-average/ALGOL-68/averages-simple-moving-average.alg create mode 100644 Task/Averages-Simple-moving-average/AWK/averages-simple-moving-average.awk create mode 100644 Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-1.ada create mode 100644 Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-2.ada create mode 100644 Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-3.ada create mode 100644 Task/Averages-Simple-moving-average/AutoHotkey/averages-simple-moving-average-1.ahk create mode 100644 Task/Averages-Simple-moving-average/AutoHotkey/averages-simple-moving-average-2.ahk create mode 100644 Task/Averages-Simple-moving-average/C/averages-simple-moving-average-1.c create mode 100644 Task/Averages-Simple-moving-average/C/averages-simple-moving-average-2.c create mode 100644 Task/Averages-Simple-moving-average/Clojure/averages-simple-moving-average.clj create mode 100644 Task/Averages-Simple-moving-average/CoffeeScript/averages-simple-moving-average-1.coffee create mode 100644 Task/Averages-Simple-moving-average/CoffeeScript/averages-simple-moving-average-2.coffee create mode 100644 Task/Averages-Simple-moving-average/Erlang/averages-simple-moving-average-1.erl create mode 100644 Task/Averages-Simple-moving-average/Erlang/averages-simple-moving-average-2.erl create mode 100644 Task/Averages-Simple-moving-average/Forth/averages-simple-moving-average.fth create mode 100644 Task/Averages-Simple-moving-average/Fortran/averages-simple-moving-average.f create mode 100644 Task/Averages-Simple-moving-average/Go/averages-simple-moving-average.go create mode 100644 Task/Averages-Simple-moving-average/Haskell/averages-simple-moving-average.hs create mode 100644 Task/Averages-Simple-moving-average/Java/averages-simple-moving-average.java create mode 100644 Task/Averages-Simple-moving-average/JavaScript/averages-simple-moving-average.js create mode 100644 Task/Averages-Simple-moving-average/Lua/averages-simple-moving-average.lua create mode 100644 Task/Averages-Simple-moving-average/Perl/averages-simple-moving-average.pl create mode 100644 Task/Averages-Simple-moving-average/PicoLisp/averages-simple-moving-average-1.l create mode 100644 Task/Averages-Simple-moving-average/PicoLisp/averages-simple-moving-average-2.l create mode 100644 Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-1.py create mode 100644 Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-2.py create mode 100644 Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-3.py create mode 100644 Task/Averages-Simple-moving-average/R/averages-simple-moving-average.r create mode 100644 Task/Averages-Simple-moving-average/REXX/averages-simple-moving-average.rexx create mode 100644 Task/Averages-Simple-moving-average/Ruby/averages-simple-moving-average-1.rb create mode 100644 Task/Averages-Simple-moving-average/Ruby/averages-simple-moving-average-2.rb create mode 100644 Task/Averages-Simple-moving-average/Scala/averages-simple-moving-average.scala create mode 100644 Task/Averages-Simple-moving-average/Scheme/averages-simple-moving-average.ss create mode 100644 Task/Averages-Simple-moving-average/Smalltalk/averages-simple-moving-average-1.st create mode 100644 Task/Averages-Simple-moving-average/Smalltalk/averages-simple-moving-average-2.st create mode 100644 Task/Averages-Simple-moving-average/Tcl/averages-simple-moving-average-1.tcl create mode 100644 Task/Averages-Simple-moving-average/Tcl/averages-simple-moving-average-2.tcl diff --git a/Conf/.task.yaml.swp b/Conf/.task.yaml.swp index 1c46e5b3ff21ebdc9f8cf8745ff0c5dac99af224..e47b69c5f4b4a3a6043a0b4a0217c3eaaab62801 100644 GIT binary patch literal 12288 zcmeI2ONd-W6oxAb8XqwsSqKVJWiuR~LRNy)kD1C4Ku{|5hON$F(_T0hy`GNf#*AXaAi3&so zq5@HYs6bR8Di9Tj3Pc5NR0Vvoi@k*8Z<=gi`io%K5`fv5muB4zCL-HiQy8`Qx6|EItIf7{F0FW`G{30wqUfDgcV@G^K7 ztb_Z&t>BNl82c4m1Q)=E;2m%dY=8zh4EBOQ_b~Po_zrvuJ_hfDH-HAufi+MA_kh3d zL~QT__#C_kUIVWJ3!VpU&;U!|AlMIX23PK2>}T*T_z1iW-U1a+paa&x<6sdS0K37J z+ZnqIJ_DbCcfon^CU^xnAVC7ofaBm1a2VVR?gsn7EgnX%~vUBo8ovrDf)Y4bM_X$xH z71w3nC5y<%4PTY6UuUbvlJmSLEvBu?;jmc_hhf68ElNsHymMlsbE?jcX>Uz|P%Grg z=E#`K9ya5=#Ve*CynOaiVw+}U{IKhNj({o43C-cgmhL2nFdQ? zWiGuO5Kn~{+*bu0=lBXykxZ5s*l5RxO}9**llGY3GRjzPMhPXBNb^E&ks28kB_3%6 zFNJqtou4m+v{=b>73E=6I1GnnT79F)ZB{&`#N>r>NX2Nl^eNdajMR|6(n;SMEr()< zjr+a`A}Zpvg>sFfVFya+ZP8mokxoaM3v$BpL>7I*Mw+Ekj-$LhF=sKiDYdZGMB5$D zqYes*P8?F1$*@*4lyFx3W>_^r7okug4(!vBt`*59g(<8tAS*I*wT{dSZuC*&d@-Xu82!2u=f`%GrWg8{J_-0eN8z)@#_V^cK~gFD&8G2nP@S8kTkZL8%i} zrj#CnV^OFICoK_5b;EuzM%9`#AIOem*6p}1m75xt%ybiA?vo~?K39Wgr z)T3J?cqe6EDuHOcCq_Xr*u}kvhsg!ic&LdJb@V828t-v~ggrGWthMwo&qT;`abba{ I#)P}~Z-bD66951J delta 324 zcmXBNze~el5XSL~9b6Kd;!--jN>Q??p+ZX$q39ywUO@sjtUO0euD=e?irrr`n7&d)#o->)>Lt(AdD^YIrP^jooA^|iL`XH zHyGsamakKW#NR1p8g87if6`XT6vnkONw$sxWqY5aEvZ?v4vGEpad7w$XfA)y=cb2 t&e@1t2}3{Vv<`GwmP!zKy<}^z8F=j^HTM0W?P;xcy1J3n%F%Gv`2*;-K~w+$ diff --git a/Conf/task.yaml b/Conf/task.yaml index 6f7b785603..1584fd26f4 100644 --- a/Conf/task.yaml +++ b/Conf/task.yaml @@ -1,10 +1,44 @@ 100 doors: 24 game: 99 Bottles of Beer: +A+B: +Abstract type: +Accumulator factory: Ackermann function: +Active Directory/Connect: +Active Directory/Search for a user: +Active object: +Add a variable to a class instance at runtime: +Address of a variable: +Align columns: Anagrams: +Anagrams/Deranged anagrams: +# Animate a pendulum: +Animation: +Anonymous recursion: +Apply a callback to an array: +Arbitrary-precision integers (included): +Arena storage pool: +Arithmetic evaluation: +Arithmetic-geometric mean: +Arithmetic/Complex: +# Arithmetic/Integer: +Arithmetic/Rational: +Array concatenation: Arrays: Assertions: +Associative array/Creation: +Associative array/Iteration: +Atomic updates: +Average loop length: +Averages/Arithmetic mean: +Averages/Mean angle: +Averages/Mean time of day: +Averages/Median: +# Averages/Mode: +Averages/Pythagorean means: +Averages/Root mean square: +Averages/Simple moving average: Balanced brackets: Balanced ternary: Best shuffle: diff --git a/Lang/0815/A+B b/Lang/0815/A+B new file mode 120000 index 0000000000..f38b996359 --- /dev/null +++ b/Lang/0815/A+B @@ -0,0 +1 @@ +../../Task/A+B/0815 \ No newline at end of file diff --git a/Lang/6502-Assembly/Averages-Arithmetic-mean b/Lang/6502-Assembly/Averages-Arithmetic-mean new file mode 120000 index 0000000000..e34f0812cd --- /dev/null +++ b/Lang/6502-Assembly/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/6502-Assembly \ No newline at end of file diff --git a/Lang/ABAP/A+B b/Lang/ABAP/A+B new file mode 120000 index 0000000000..b9771e4c98 --- /dev/null +++ b/Lang/ABAP/A+B @@ -0,0 +1 @@ +../../Task/A+B/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Abstract-type b/Lang/ABAP/Abstract-type new file mode 120000 index 0000000000..13183a131f --- /dev/null +++ b/Lang/ABAP/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Accumulator-factory b/Lang/ABAP/Accumulator-factory new file mode 120000 index 0000000000..e077ef8972 --- /dev/null +++ b/Lang/ABAP/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Align-columns b/Lang/ABAP/Align-columns new file mode 120000 index 0000000000..0fb48803c1 --- /dev/null +++ b/Lang/ABAP/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/ABAP \ No newline at end of file diff --git a/Lang/ACL2/Apply-a-callback-to-an-array b/Lang/ACL2/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..431956f14a --- /dev/null +++ b/Lang/ACL2/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Arbitrary-precision-integers-(included) b/Lang/ACL2/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..6d88a77c49 --- /dev/null +++ b/Lang/ACL2/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Array-concatenation b/Lang/ACL2/Array-concatenation new file mode 120000 index 0000000000..2702f3d362 --- /dev/null +++ b/Lang/ACL2/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Averages-Arithmetic-mean b/Lang/ACL2/Averages-Arithmetic-mean new file mode 120000 index 0000000000..4f5b671a9c --- /dev/null +++ b/Lang/ACL2/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/ACL2 \ No newline at end of file diff --git a/Lang/ALGOL-68/A+B b/Lang/ALGOL-68/A+B new file mode 120000 index 0000000000..5765d580e0 --- /dev/null +++ b/Lang/ALGOL-68/A+B @@ -0,0 +1 @@ +../../Task/A+B/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Accumulator-factory b/Lang/ALGOL-68/Accumulator-factory new file mode 120000 index 0000000000..bdb4432e3b --- /dev/null +++ b/Lang/ALGOL-68/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Address-of-a-variable b/Lang/ALGOL-68/Address-of-a-variable new file mode 120000 index 0000000000..805b2d2c6a --- /dev/null +++ b/Lang/ALGOL-68/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Align-columns b/Lang/ALGOL-68/Align-columns new file mode 120000 index 0000000000..4ad8e89cf4 --- /dev/null +++ b/Lang/ALGOL-68/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Apply-a-callback-to-an-array b/Lang/ALGOL-68/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..74b4e2171b --- /dev/null +++ b/Lang/ALGOL-68/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Arithmetic-Complex b/Lang/ALGOL-68/Arithmetic-Complex new file mode 120000 index 0000000000..85cf01a240 --- /dev/null +++ b/Lang/ALGOL-68/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Arithmetic-Rational b/Lang/ALGOL-68/Arithmetic-Rational new file mode 120000 index 0000000000..0abbe747f3 --- /dev/null +++ b/Lang/ALGOL-68/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Arithmetic-evaluation b/Lang/ALGOL-68/Arithmetic-evaluation new file mode 120000 index 0000000000..4b9c60d1b4 --- /dev/null +++ b/Lang/ALGOL-68/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Array-concatenation b/Lang/ALGOL-68/Array-concatenation new file mode 120000 index 0000000000..2f058e02b5 --- /dev/null +++ b/Lang/ALGOL-68/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Associative-array-Creation b/Lang/ALGOL-68/Associative-array-Creation new file mode 120000 index 0000000000..9bec4c1294 --- /dev/null +++ b/Lang/ALGOL-68/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Averages-Arithmetic-mean b/Lang/ALGOL-68/Averages-Arithmetic-mean new file mode 120000 index 0000000000..48ce7b81af --- /dev/null +++ b/Lang/ALGOL-68/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Averages-Pythagorean-means b/Lang/ALGOL-68/Averages-Pythagorean-means new file mode 120000 index 0000000000..ba720f78e7 --- /dev/null +++ b/Lang/ALGOL-68/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Averages-Root-mean-square b/Lang/ALGOL-68/Averages-Root-mean-square new file mode 120000 index 0000000000..cd7cc0fb12 --- /dev/null +++ b/Lang/ALGOL-68/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Averages-Simple-moving-average b/Lang/ALGOL-68/Averages-Simple-moving-average new file mode 120000 index 0000000000..39fd39ac0f --- /dev/null +++ b/Lang/ALGOL-68/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/ALGOL-68 \ No newline at end of file diff --git a/Lang/ANTLR/A+B b/Lang/ANTLR/A+B new file mode 120000 index 0000000000..d8dee80ad6 --- /dev/null +++ b/Lang/ANTLR/A+B @@ -0,0 +1 @@ +../../Task/A+B/ANTLR \ No newline at end of file diff --git a/Lang/APL/Arithmetic-Complex b/Lang/APL/Arithmetic-Complex new file mode 120000 index 0000000000..4221960f23 --- /dev/null +++ b/Lang/APL/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/APL \ No newline at end of file diff --git a/Lang/APL/Array-concatenation b/Lang/APL/Array-concatenation new file mode 120000 index 0000000000..051f271f82 --- /dev/null +++ b/Lang/APL/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/APL \ No newline at end of file diff --git a/Lang/APL/Associative-array-Creation b/Lang/APL/Associative-array-Creation new file mode 120000 index 0000000000..8d0833b2ea --- /dev/null +++ b/Lang/APL/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/APL \ No newline at end of file diff --git a/Lang/APL/Averages-Arithmetic-mean b/Lang/APL/Averages-Arithmetic-mean new file mode 120000 index 0000000000..75ff376c96 --- /dev/null +++ b/Lang/APL/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/APL \ No newline at end of file diff --git a/Lang/APL/Averages-Pythagorean-means b/Lang/APL/Averages-Pythagorean-means new file mode 120000 index 0000000000..050c9d4805 --- /dev/null +++ b/Lang/APL/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/APL \ No newline at end of file diff --git a/Lang/APL/Averages-Root-mean-square b/Lang/APL/Averages-Root-mean-square new file mode 120000 index 0000000000..e163b71ef9 --- /dev/null +++ b/Lang/APL/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/APL \ No newline at end of file diff --git a/Lang/AWK/A+B b/Lang/AWK/A+B new file mode 120000 index 0000000000..9c92e79227 --- /dev/null +++ b/Lang/AWK/A+B @@ -0,0 +1 @@ +../../Task/A+B/AWK \ No newline at end of file diff --git a/Lang/AWK/Align-columns b/Lang/AWK/Align-columns new file mode 120000 index 0000000000..81a3a045db --- /dev/null +++ b/Lang/AWK/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/AWK \ No newline at end of file diff --git a/Lang/AWK/Apply-a-callback-to-an-array b/Lang/AWK/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..9e6feb290b --- /dev/null +++ b/Lang/AWK/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/AWK \ No newline at end of file diff --git a/Lang/AWK/Associative-array-Creation b/Lang/AWK/Associative-array-Creation new file mode 120000 index 0000000000..b2398418d2 --- /dev/null +++ b/Lang/AWK/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/AWK \ No newline at end of file diff --git a/Lang/AWK/Associative-array-Iteration b/Lang/AWK/Associative-array-Iteration new file mode 120000 index 0000000000..5331487a81 --- /dev/null +++ b/Lang/AWK/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/AWK \ No newline at end of file diff --git a/Lang/AWK/Averages-Arithmetic-mean b/Lang/AWK/Averages-Arithmetic-mean new file mode 120000 index 0000000000..8e6e9d3785 --- /dev/null +++ b/Lang/AWK/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/AWK \ No newline at end of file diff --git a/Lang/AWK/Averages-Median b/Lang/AWK/Averages-Median new file mode 120000 index 0000000000..b949778e98 --- /dev/null +++ b/Lang/AWK/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/AWK \ No newline at end of file diff --git a/Lang/AWK/Averages-Pythagorean-means b/Lang/AWK/Averages-Pythagorean-means new file mode 120000 index 0000000000..e88c6bdc4e --- /dev/null +++ b/Lang/AWK/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/AWK \ No newline at end of file diff --git a/Lang/AWK/Averages-Root-mean-square b/Lang/AWK/Averages-Root-mean-square new file mode 120000 index 0000000000..779fb02521 --- /dev/null +++ b/Lang/AWK/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/AWK \ No newline at end of file diff --git a/Lang/AWK/Averages-Simple-moving-average b/Lang/AWK/Averages-Simple-moving-average new file mode 120000 index 0000000000..1444a44a26 --- /dev/null +++ b/Lang/AWK/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/AWK \ No newline at end of file diff --git a/Lang/ActionScript/Abstract-type b/Lang/ActionScript/Abstract-type new file mode 120000 index 0000000000..e609845b0a --- /dev/null +++ b/Lang/ActionScript/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Accumulator-factory b/Lang/ActionScript/Accumulator-factory new file mode 120000 index 0000000000..fb443f73d4 --- /dev/null +++ b/Lang/ActionScript/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Add-a-variable-to-a-class-instance-at-runtime b/Lang/ActionScript/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..47d24efb7c --- /dev/null +++ b/Lang/ActionScript/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Animation b/Lang/ActionScript/Animation new file mode 120000 index 0000000000..3ba1d230b4 --- /dev/null +++ b/Lang/ActionScript/Animation @@ -0,0 +1 @@ +../../Task/Animation/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Apply-a-callback-to-an-array b/Lang/ActionScript/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..e0be1c6f2e --- /dev/null +++ b/Lang/ActionScript/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Array-concatenation b/Lang/ActionScript/Array-concatenation new file mode 120000 index 0000000000..162f5f6abd --- /dev/null +++ b/Lang/ActionScript/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Associative-array-Creation b/Lang/ActionScript/Associative-array-Creation new file mode 120000 index 0000000000..0a381b5532 --- /dev/null +++ b/Lang/ActionScript/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Averages-Arithmetic-mean b/Lang/ActionScript/Averages-Arithmetic-mean new file mode 120000 index 0000000000..84157504c8 --- /dev/null +++ b/Lang/ActionScript/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Averages-Pythagorean-means b/Lang/ActionScript/Averages-Pythagorean-means new file mode 120000 index 0000000000..41031ff03c --- /dev/null +++ b/Lang/ActionScript/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/ActionScript \ No newline at end of file diff --git a/Lang/Ada/A+B b/Lang/Ada/A+B new file mode 120000 index 0000000000..cdcbbb4a76 --- /dev/null +++ b/Lang/Ada/A+B @@ -0,0 +1 @@ +../../Task/A+B/Ada \ No newline at end of file diff --git a/Lang/Ada/Abstract-type b/Lang/Ada/Abstract-type new file mode 120000 index 0000000000..b11f17c165 --- /dev/null +++ b/Lang/Ada/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Ada \ No newline at end of file diff --git a/Lang/Ada/Accumulator-factory b/Lang/Ada/Accumulator-factory new file mode 120000 index 0000000000..2c8f8993a5 --- /dev/null +++ b/Lang/Ada/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Ada \ No newline at end of file diff --git a/Lang/Ada/Active-object b/Lang/Ada/Active-object new file mode 120000 index 0000000000..01c3a5f7ac --- /dev/null +++ b/Lang/Ada/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/Ada \ No newline at end of file diff --git a/Lang/Ada/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Ada/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..c306690156 --- /dev/null +++ b/Lang/Ada/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Ada \ No newline at end of file diff --git a/Lang/Ada/Address-of-a-variable b/Lang/Ada/Address-of-a-variable new file mode 120000 index 0000000000..625c8babac --- /dev/null +++ b/Lang/Ada/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Ada \ No newline at end of file diff --git a/Lang/Ada/Align-columns b/Lang/Ada/Align-columns new file mode 120000 index 0000000000..2df935f24e --- /dev/null +++ b/Lang/Ada/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Ada \ No newline at end of file diff --git a/Lang/Ada/Anagrams-Deranged-anagrams b/Lang/Ada/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..64d5aae26c --- /dev/null +++ b/Lang/Ada/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Ada \ No newline at end of file diff --git a/Lang/Ada/Animation b/Lang/Ada/Animation new file mode 120000 index 0000000000..bcf24516a3 --- /dev/null +++ b/Lang/Ada/Animation @@ -0,0 +1 @@ +../../Task/Animation/Ada \ No newline at end of file diff --git a/Lang/Ada/Anonymous-recursion b/Lang/Ada/Anonymous-recursion new file mode 120000 index 0000000000..0bde74aef8 --- /dev/null +++ b/Lang/Ada/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Ada \ No newline at end of file diff --git a/Lang/Ada/Apply-a-callback-to-an-array b/Lang/Ada/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..0fc1583080 --- /dev/null +++ b/Lang/Ada/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Ada \ No newline at end of file diff --git a/Lang/Ada/Arbitrary-precision-integers-(included) b/Lang/Ada/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..2edc64c8fa --- /dev/null +++ b/Lang/Ada/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Ada \ No newline at end of file diff --git a/Lang/Ada/Arena-storage-pool b/Lang/Ada/Arena-storage-pool new file mode 120000 index 0000000000..29f429b811 --- /dev/null +++ b/Lang/Ada/Arena-storage-pool @@ -0,0 +1 @@ +../../Task/Arena-storage-pool/Ada \ No newline at end of file diff --git a/Lang/Ada/Arithmetic-Complex b/Lang/Ada/Arithmetic-Complex new file mode 120000 index 0000000000..371bb9be6e --- /dev/null +++ b/Lang/Ada/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Ada \ No newline at end of file diff --git a/Lang/Ada/Arithmetic-geometric-mean b/Lang/Ada/Arithmetic-geometric-mean new file mode 120000 index 0000000000..d6e7d9beb5 --- /dev/null +++ b/Lang/Ada/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Ada \ No newline at end of file diff --git a/Lang/Ada/Array-concatenation b/Lang/Ada/Array-concatenation new file mode 120000 index 0000000000..667d693832 --- /dev/null +++ b/Lang/Ada/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Ada \ No newline at end of file diff --git a/Lang/Ada/Associative-array-Creation b/Lang/Ada/Associative-array-Creation new file mode 120000 index 0000000000..ddd7cbd8ee --- /dev/null +++ b/Lang/Ada/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Ada \ No newline at end of file diff --git a/Lang/Ada/Associative-array-Iteration b/Lang/Ada/Associative-array-Iteration new file mode 120000 index 0000000000..9cc668a8f6 --- /dev/null +++ b/Lang/Ada/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Ada \ No newline at end of file diff --git a/Lang/Ada/Atomic-updates b/Lang/Ada/Atomic-updates new file mode 120000 index 0000000000..a187280b46 --- /dev/null +++ b/Lang/Ada/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Ada \ No newline at end of file diff --git a/Lang/Ada/Average-loop-length b/Lang/Ada/Average-loop-length new file mode 120000 index 0000000000..018a67faa7 --- /dev/null +++ b/Lang/Ada/Average-loop-length @@ -0,0 +1 @@ +../../Task/Average-loop-length/Ada \ No newline at end of file diff --git a/Lang/Ada/Averages-Arithmetic-mean b/Lang/Ada/Averages-Arithmetic-mean new file mode 120000 index 0000000000..e6b772e374 --- /dev/null +++ b/Lang/Ada/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Ada \ No newline at end of file diff --git a/Lang/Ada/Averages-Mean-angle b/Lang/Ada/Averages-Mean-angle new file mode 120000 index 0000000000..981e315ed5 --- /dev/null +++ b/Lang/Ada/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Ada \ No newline at end of file diff --git a/Lang/Ada/Averages-Median b/Lang/Ada/Averages-Median new file mode 120000 index 0000000000..25029e581f --- /dev/null +++ b/Lang/Ada/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Ada \ No newline at end of file diff --git a/Lang/Ada/Averages-Pythagorean-means b/Lang/Ada/Averages-Pythagorean-means new file mode 120000 index 0000000000..0a29e389c9 --- /dev/null +++ b/Lang/Ada/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Ada \ No newline at end of file diff --git a/Lang/Ada/Averages-Root-mean-square b/Lang/Ada/Averages-Root-mean-square new file mode 120000 index 0000000000..c46e2ec09f --- /dev/null +++ b/Lang/Ada/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Ada \ No newline at end of file diff --git a/Lang/Ada/Averages-Simple-moving-average b/Lang/Ada/Averages-Simple-moving-average new file mode 120000 index 0000000000..04b3d15ce2 --- /dev/null +++ b/Lang/Ada/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Ada \ No newline at end of file diff --git a/Lang/Agda/Abstract-type b/Lang/Agda/Abstract-type new file mode 120000 index 0000000000..8e1f88cf3d --- /dev/null +++ b/Lang/Agda/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Agda \ No newline at end of file diff --git a/Lang/Aikido/Abstract-type b/Lang/Aikido/Abstract-type new file mode 120000 index 0000000000..a5fdaa604a --- /dev/null +++ b/Lang/Aikido/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Accumulator-factory b/Lang/Aikido/Accumulator-factory new file mode 120000 index 0000000000..ffff56a508 --- /dev/null +++ b/Lang/Aikido/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Associative-array-Creation b/Lang/Aikido/Associative-array-Creation new file mode 120000 index 0000000000..6360524f26 --- /dev/null +++ b/Lang/Aikido/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Aikido \ No newline at end of file diff --git a/Lang/Aime/Apply-a-callback-to-an-array b/Lang/Aime/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..6afdcf646b --- /dev/null +++ b/Lang/Aime/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Aime \ No newline at end of file diff --git a/Lang/Alore/Arbitrary-precision-integers-(included) b/Lang/Alore/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..b45566aca9 --- /dev/null +++ b/Lang/Alore/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Alore \ No newline at end of file diff --git a/Lang/AmigaE/Averages-Arithmetic-mean b/Lang/AmigaE/Averages-Arithmetic-mean new file mode 120000 index 0000000000..f7e53cdf5c --- /dev/null +++ b/Lang/AmigaE/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/AmigaE \ No newline at end of file diff --git a/Lang/AppleScript/Averages-Median b/Lang/AppleScript/Averages-Median new file mode 120000 index 0000000000..d63352232b --- /dev/null +++ b/Lang/AppleScript/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/AppleScript \ No newline at end of file diff --git a/Lang/Argile/A+B b/Lang/Argile/A+B new file mode 120000 index 0000000000..ba39627c1b --- /dev/null +++ b/Lang/Argile/A+B @@ -0,0 +1 @@ +../../Task/A+B/Argile \ No newline at end of file diff --git a/Lang/Argile/Abstract-type b/Lang/Argile/Abstract-type new file mode 120000 index 0000000000..835ea31039 --- /dev/null +++ b/Lang/Argile/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Argile \ No newline at end of file diff --git a/Lang/Argile/Accumulator-factory b/Lang/Argile/Accumulator-factory new file mode 120000 index 0000000000..3e23f0d4a7 --- /dev/null +++ b/Lang/Argile/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Argile \ No newline at end of file diff --git a/Lang/Argile/Address-of-a-variable b/Lang/Argile/Address-of-a-variable new file mode 120000 index 0000000000..0ca42e507d --- /dev/null +++ b/Lang/Argile/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Argile \ No newline at end of file diff --git a/Lang/AutoHotkey/A+B b/Lang/AutoHotkey/A+B new file mode 120000 index 0000000000..34306562a1 --- /dev/null +++ b/Lang/AutoHotkey/A+B @@ -0,0 +1 @@ +../../Task/A+B/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Abstract-type b/Lang/AutoHotkey/Abstract-type new file mode 120000 index 0000000000..bf4c5e9139 --- /dev/null +++ b/Lang/AutoHotkey/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Active-Directory-Connect b/Lang/AutoHotkey/Active-Directory-Connect new file mode 120000 index 0000000000..2906a045c7 --- /dev/null +++ b/Lang/AutoHotkey/Active-Directory-Connect @@ -0,0 +1 @@ +../../Task/Active-Directory-Connect/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Add-a-variable-to-a-class-instance-at-runtime b/Lang/AutoHotkey/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..da19636063 --- /dev/null +++ b/Lang/AutoHotkey/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Address-of-a-variable b/Lang/AutoHotkey/Address-of-a-variable new file mode 120000 index 0000000000..404123e5c6 --- /dev/null +++ b/Lang/AutoHotkey/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Align-columns b/Lang/AutoHotkey/Align-columns new file mode 120000 index 0000000000..0a02232b4d --- /dev/null +++ b/Lang/AutoHotkey/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Animation b/Lang/AutoHotkey/Animation new file mode 120000 index 0000000000..1bdb219dcc --- /dev/null +++ b/Lang/AutoHotkey/Animation @@ -0,0 +1 @@ +../../Task/Animation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Anonymous-recursion b/Lang/AutoHotkey/Anonymous-recursion new file mode 120000 index 0000000000..c992ee0ed1 --- /dev/null +++ b/Lang/AutoHotkey/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Apply-a-callback-to-an-array b/Lang/AutoHotkey/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..6342659003 --- /dev/null +++ b/Lang/AutoHotkey/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Arithmetic-Complex b/Lang/AutoHotkey/Arithmetic-Complex new file mode 120000 index 0000000000..5fbe29aa86 --- /dev/null +++ b/Lang/AutoHotkey/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Arithmetic-evaluation b/Lang/AutoHotkey/Arithmetic-evaluation new file mode 120000 index 0000000000..eafa630655 --- /dev/null +++ b/Lang/AutoHotkey/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Arithmetic-geometric-mean b/Lang/AutoHotkey/Arithmetic-geometric-mean new file mode 120000 index 0000000000..0a6f3749df --- /dev/null +++ b/Lang/AutoHotkey/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Array-concatenation b/Lang/AutoHotkey/Array-concatenation new file mode 120000 index 0000000000..96659ecb14 --- /dev/null +++ b/Lang/AutoHotkey/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Associative-array-Creation b/Lang/AutoHotkey/Associative-array-Creation new file mode 120000 index 0000000000..902453f4a7 --- /dev/null +++ b/Lang/AutoHotkey/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Associative-array-Iteration b/Lang/AutoHotkey/Associative-array-Iteration new file mode 120000 index 0000000000..bd261cf5b7 --- /dev/null +++ b/Lang/AutoHotkey/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Averages-Arithmetic-mean b/Lang/AutoHotkey/Averages-Arithmetic-mean new file mode 120000 index 0000000000..b14364eecd --- /dev/null +++ b/Lang/AutoHotkey/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Averages-Median b/Lang/AutoHotkey/Averages-Median new file mode 120000 index 0000000000..36c7dde6d9 --- /dev/null +++ b/Lang/AutoHotkey/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Averages-Pythagorean-means b/Lang/AutoHotkey/Averages-Pythagorean-means new file mode 120000 index 0000000000..67fe1a3d86 --- /dev/null +++ b/Lang/AutoHotkey/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Averages-Root-mean-square b/Lang/AutoHotkey/Averages-Root-mean-square new file mode 120000 index 0000000000..6cbe5d5b52 --- /dev/null +++ b/Lang/AutoHotkey/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Averages-Simple-moving-average b/Lang/AutoHotkey/Averages-Simple-moving-average new file mode 120000 index 0000000000..2f61f2e44e --- /dev/null +++ b/Lang/AutoHotkey/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoIt/A+B b/Lang/AutoIt/A+B new file mode 120000 index 0000000000..44236fda80 --- /dev/null +++ b/Lang/AutoIt/A+B @@ -0,0 +1 @@ +../../Task/A+B/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Active-Directory-Connect b/Lang/AutoIt/Active-Directory-Connect new file mode 120000 index 0000000000..f359ebee59 --- /dev/null +++ b/Lang/AutoIt/Active-Directory-Connect @@ -0,0 +1 @@ +../../Task/Active-Directory-Connect/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Array-concatenation b/Lang/AutoIt/Array-concatenation new file mode 120000 index 0000000000..46ffba5419 --- /dev/null +++ b/Lang/AutoIt/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/AutoIt \ No newline at end of file diff --git a/Lang/Axiom/Anonymous-recursion b/Lang/Axiom/Anonymous-recursion new file mode 120000 index 0000000000..2b40e55390 --- /dev/null +++ b/Lang/Axiom/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Axiom \ No newline at end of file diff --git a/Lang/BASIC/A+B b/Lang/BASIC/A+B new file mode 120000 index 0000000000..411c8f5da4 --- /dev/null +++ b/Lang/BASIC/A+B @@ -0,0 +1 @@ +../../Task/A+B/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Address-of-a-variable b/Lang/BASIC/Address-of-a-variable new file mode 120000 index 0000000000..5514047823 --- /dev/null +++ b/Lang/BASIC/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Arithmetic-Complex b/Lang/BASIC/Arithmetic-Complex new file mode 120000 index 0000000000..74a0b1041c --- /dev/null +++ b/Lang/BASIC/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Averages-Arithmetic-mean b/Lang/BASIC/Averages-Arithmetic-mean new file mode 120000 index 0000000000..83ec4efa0a --- /dev/null +++ b/Lang/BASIC/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Averages-Median b/Lang/BASIC/Averages-Median new file mode 120000 index 0000000000..0a9d99da14 --- /dev/null +++ b/Lang/BASIC/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Averages-Root-mean-square b/Lang/BASIC/Averages-Root-mean-square new file mode 120000 index 0000000000..0c2a677902 --- /dev/null +++ b/Lang/BASIC/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/BASIC \ No newline at end of file diff --git a/Lang/Babel/Array-concatenation b/Lang/Babel/Array-concatenation new file mode 120000 index 0000000000..a5d8271da7 --- /dev/null +++ b/Lang/Babel/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Babel \ No newline at end of file diff --git a/Lang/Befunge/A+B b/Lang/Befunge/A+B new file mode 120000 index 0000000000..efc3c0bc5d --- /dev/null +++ b/Lang/Befunge/A+B @@ -0,0 +1 @@ +../../Task/A+B/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Averages-Arithmetic-mean b/Lang/Befunge/Averages-Arithmetic-mean new file mode 120000 index 0000000000..b597f7ac56 --- /dev/null +++ b/Lang/Befunge/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Befunge \ No newline at end of file diff --git a/Lang/C/A+B b/Lang/C/A+B new file mode 120000 index 0000000000..2d2c133c4a --- /dev/null +++ b/Lang/C/A+B @@ -0,0 +1 @@ +../../Task/A+B/C \ No newline at end of file diff --git a/Lang/C/Abstract-type b/Lang/C/Abstract-type new file mode 120000 index 0000000000..d072f8c205 --- /dev/null +++ b/Lang/C/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/C \ No newline at end of file diff --git a/Lang/C/Accumulator-factory b/Lang/C/Accumulator-factory new file mode 120000 index 0000000000..20c554d881 --- /dev/null +++ b/Lang/C/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/C \ No newline at end of file diff --git a/Lang/C/Active-Directory-Connect b/Lang/C/Active-Directory-Connect new file mode 120000 index 0000000000..1f69357681 --- /dev/null +++ b/Lang/C/Active-Directory-Connect @@ -0,0 +1 @@ +../../Task/Active-Directory-Connect/C \ No newline at end of file diff --git a/Lang/C/Active-Directory-Search-for-a-user b/Lang/C/Active-Directory-Search-for-a-user new file mode 120000 index 0000000000..7425b60b8c --- /dev/null +++ b/Lang/C/Active-Directory-Search-for-a-user @@ -0,0 +1 @@ +../../Task/Active-Directory-Search-for-a-user/C \ No newline at end of file diff --git a/Lang/C/Active-object b/Lang/C/Active-object new file mode 120000 index 0000000000..eacbf9b3f5 --- /dev/null +++ b/Lang/C/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/C \ No newline at end of file diff --git a/Lang/C/Anagrams-Deranged-anagrams b/Lang/C/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..cce75923ac --- /dev/null +++ b/Lang/C/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/C \ No newline at end of file diff --git a/Lang/C/Animation b/Lang/C/Animation new file mode 120000 index 0000000000..53547d535d --- /dev/null +++ b/Lang/C/Animation @@ -0,0 +1 @@ +../../Task/Animation/C \ No newline at end of file diff --git a/Lang/C/Anonymous-recursion b/Lang/C/Anonymous-recursion new file mode 120000 index 0000000000..45e6607743 --- /dev/null +++ b/Lang/C/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/C \ No newline at end of file diff --git a/Lang/C/Apply-a-callback-to-an-array b/Lang/C/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..10b0b8a58e --- /dev/null +++ b/Lang/C/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/C \ No newline at end of file diff --git a/Lang/C/Arbitrary-precision-integers-(included) b/Lang/C/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..ba9a232ceb --- /dev/null +++ b/Lang/C/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/C \ No newline at end of file diff --git a/Lang/C/Arena-storage-pool b/Lang/C/Arena-storage-pool new file mode 120000 index 0000000000..b86d9bbaff --- /dev/null +++ b/Lang/C/Arena-storage-pool @@ -0,0 +1 @@ +../../Task/Arena-storage-pool/C \ No newline at end of file diff --git a/Lang/C/Arithmetic-Complex b/Lang/C/Arithmetic-Complex new file mode 120000 index 0000000000..2bc23504ae --- /dev/null +++ b/Lang/C/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/C \ No newline at end of file diff --git a/Lang/C/Arithmetic-Rational b/Lang/C/Arithmetic-Rational new file mode 120000 index 0000000000..63a88334b5 --- /dev/null +++ b/Lang/C/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/C \ No newline at end of file diff --git a/Lang/C/Arithmetic-geometric-mean b/Lang/C/Arithmetic-geometric-mean new file mode 120000 index 0000000000..bd6f30952e --- /dev/null +++ b/Lang/C/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/C \ No newline at end of file diff --git a/Lang/C/Array-concatenation b/Lang/C/Array-concatenation new file mode 120000 index 0000000000..088cf4a241 --- /dev/null +++ b/Lang/C/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/C \ No newline at end of file diff --git a/Lang/C/Atomic-updates b/Lang/C/Atomic-updates new file mode 120000 index 0000000000..d4f8bccc3d --- /dev/null +++ b/Lang/C/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/C \ No newline at end of file diff --git a/Lang/C/Average-loop-length b/Lang/C/Average-loop-length new file mode 120000 index 0000000000..1872864a57 --- /dev/null +++ b/Lang/C/Average-loop-length @@ -0,0 +1 @@ +../../Task/Average-loop-length/C \ No newline at end of file diff --git a/Lang/C/Averages-Arithmetic-mean b/Lang/C/Averages-Arithmetic-mean new file mode 120000 index 0000000000..e2e36923ca --- /dev/null +++ b/Lang/C/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/C \ No newline at end of file diff --git a/Lang/C/Averages-Mean-angle b/Lang/C/Averages-Mean-angle new file mode 120000 index 0000000000..73da7e2a2b --- /dev/null +++ b/Lang/C/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/C \ No newline at end of file diff --git a/Lang/C/Averages-Mean-time-of-day b/Lang/C/Averages-Mean-time-of-day new file mode 120000 index 0000000000..212546de46 --- /dev/null +++ b/Lang/C/Averages-Mean-time-of-day @@ -0,0 +1 @@ +../../Task/Averages-Mean-time-of-day/C \ No newline at end of file diff --git a/Lang/C/Averages-Median b/Lang/C/Averages-Median new file mode 120000 index 0000000000..5035bf8ca9 --- /dev/null +++ b/Lang/C/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/C \ No newline at end of file diff --git a/Lang/C/Averages-Pythagorean-means b/Lang/C/Averages-Pythagorean-means new file mode 120000 index 0000000000..a8756389aa --- /dev/null +++ b/Lang/C/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/C \ No newline at end of file diff --git a/Lang/C/Averages-Root-mean-square b/Lang/C/Averages-Root-mean-square new file mode 120000 index 0000000000..1625e4325b --- /dev/null +++ b/Lang/C/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/C \ No newline at end of file diff --git a/Lang/C/Averages-Simple-moving-average b/Lang/C/Averages-Simple-moving-average new file mode 120000 index 0000000000..5680fea65d --- /dev/null +++ b/Lang/C/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/C \ No newline at end of file diff --git a/Lang/Clojure/A+B b/Lang/Clojure/A+B new file mode 120000 index 0000000000..5ff18e4897 --- /dev/null +++ b/Lang/Clojure/A+B @@ -0,0 +1 @@ +../../Task/A+B/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Abstract-type b/Lang/Clojure/Abstract-type new file mode 120000 index 0000000000..163145930c --- /dev/null +++ b/Lang/Clojure/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Accumulator-factory b/Lang/Clojure/Accumulator-factory new file mode 120000 index 0000000000..6d242a6840 --- /dev/null +++ b/Lang/Clojure/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Active-object b/Lang/Clojure/Active-object new file mode 120000 index 0000000000..30b02e1866 --- /dev/null +++ b/Lang/Clojure/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Align-columns b/Lang/Clojure/Align-columns new file mode 120000 index 0000000000..fa093cf949 --- /dev/null +++ b/Lang/Clojure/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Anagrams-Deranged-anagrams b/Lang/Clojure/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..b62366de97 --- /dev/null +++ b/Lang/Clojure/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Animation b/Lang/Clojure/Animation new file mode 120000 index 0000000000..3dc3c61896 --- /dev/null +++ b/Lang/Clojure/Animation @@ -0,0 +1 @@ +../../Task/Animation/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Anonymous-recursion b/Lang/Clojure/Anonymous-recursion new file mode 120000 index 0000000000..155d5ed703 --- /dev/null +++ b/Lang/Clojure/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Apply-a-callback-to-an-array b/Lang/Clojure/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..765467661e --- /dev/null +++ b/Lang/Clojure/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Arbitrary-precision-integers-(included) b/Lang/Clojure/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..ab98cf4e31 --- /dev/null +++ b/Lang/Clojure/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Arithmetic-Rational b/Lang/Clojure/Arithmetic-Rational new file mode 120000 index 0000000000..3bcf7dc296 --- /dev/null +++ b/Lang/Clojure/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Arithmetic-evaluation b/Lang/Clojure/Arithmetic-evaluation new file mode 120000 index 0000000000..ef6cbf0bfc --- /dev/null +++ b/Lang/Clojure/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Array-concatenation b/Lang/Clojure/Array-concatenation new file mode 120000 index 0000000000..3a02454b13 --- /dev/null +++ b/Lang/Clojure/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Associative-array-Creation b/Lang/Clojure/Associative-array-Creation new file mode 120000 index 0000000000..7e32910515 --- /dev/null +++ b/Lang/Clojure/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Associative-array-Iteration b/Lang/Clojure/Associative-array-Iteration new file mode 120000 index 0000000000..66a4a4e1c0 --- /dev/null +++ b/Lang/Clojure/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Atomic-updates b/Lang/Clojure/Atomic-updates new file mode 120000 index 0000000000..25bb5c356d --- /dev/null +++ b/Lang/Clojure/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Averages-Arithmetic-mean b/Lang/Clojure/Averages-Arithmetic-mean new file mode 120000 index 0000000000..3731529069 --- /dev/null +++ b/Lang/Clojure/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Averages-Median b/Lang/Clojure/Averages-Median new file mode 120000 index 0000000000..2a72e570dc --- /dev/null +++ b/Lang/Clojure/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Averages-Pythagorean-means b/Lang/Clojure/Averages-Pythagorean-means new file mode 120000 index 0000000000..e657f6cc89 --- /dev/null +++ b/Lang/Clojure/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Averages-Root-mean-square b/Lang/Clojure/Averages-Root-mean-square new file mode 120000 index 0000000000..5f9efd9f42 --- /dev/null +++ b/Lang/Clojure/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Averages-Simple-moving-average b/Lang/Clojure/Averages-Simple-moving-average new file mode 120000 index 0000000000..05b2073ffa --- /dev/null +++ b/Lang/Clojure/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Clojure \ No newline at end of file diff --git a/Lang/CoffeeScript/A+B b/Lang/CoffeeScript/A+B new file mode 120000 index 0000000000..bf9fdbd57c --- /dev/null +++ b/Lang/CoffeeScript/A+B @@ -0,0 +1 @@ +../../Task/A+B/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Accumulator-factory b/Lang/CoffeeScript/Accumulator-factory new file mode 120000 index 0000000000..eea0f9c9cc --- /dev/null +++ b/Lang/CoffeeScript/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Add-a-variable-to-a-class-instance-at-runtime b/Lang/CoffeeScript/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..ebc8a4ec8e --- /dev/null +++ b/Lang/CoffeeScript/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Align-columns b/Lang/CoffeeScript/Align-columns new file mode 120000 index 0000000000..6bdbf1396f --- /dev/null +++ b/Lang/CoffeeScript/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Anagrams-Deranged-anagrams b/Lang/CoffeeScript/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..7579790a7b --- /dev/null +++ b/Lang/CoffeeScript/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Anonymous-recursion b/Lang/CoffeeScript/Anonymous-recursion new file mode 120000 index 0000000000..759653e38e --- /dev/null +++ b/Lang/CoffeeScript/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Apply-a-callback-to-an-array b/Lang/CoffeeScript/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..ff3ef1c6cf --- /dev/null +++ b/Lang/CoffeeScript/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Arithmetic-Complex b/Lang/CoffeeScript/Arithmetic-Complex new file mode 120000 index 0000000000..fd88d74769 --- /dev/null +++ b/Lang/CoffeeScript/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Array-concatenation b/Lang/CoffeeScript/Array-concatenation new file mode 120000 index 0000000000..f2bef02cab --- /dev/null +++ b/Lang/CoffeeScript/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Associative-array-Iteration b/Lang/CoffeeScript/Associative-array-Iteration new file mode 120000 index 0000000000..ba2ccebae4 --- /dev/null +++ b/Lang/CoffeeScript/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Averages-Arithmetic-mean b/Lang/CoffeeScript/Averages-Arithmetic-mean new file mode 120000 index 0000000000..0033b6079f --- /dev/null +++ b/Lang/CoffeeScript/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Averages-Root-mean-square b/Lang/CoffeeScript/Averages-Root-mean-square new file mode 120000 index 0000000000..f135f029dd --- /dev/null +++ b/Lang/CoffeeScript/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Averages-Simple-moving-average b/Lang/CoffeeScript/Averages-Simple-moving-average new file mode 120000 index 0000000000..4d5389053a --- /dev/null +++ b/Lang/CoffeeScript/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/CoffeeScript \ No newline at end of file diff --git a/Lang/Dylan/Anonymous-recursion b/Lang/Dylan/Anonymous-recursion new file mode 120000 index 0000000000..f32a353a3a --- /dev/null +++ b/Lang/Dylan/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Dylan \ No newline at end of file diff --git a/Lang/Eiffel/A+B b/Lang/Eiffel/A+B new file mode 120000 index 0000000000..f6b4b82eee --- /dev/null +++ b/Lang/Eiffel/A+B @@ -0,0 +1 @@ +../../Task/A+B/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Abstract-type b/Lang/Eiffel/Abstract-type new file mode 120000 index 0000000000..cba4435f4b --- /dev/null +++ b/Lang/Eiffel/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Eiffel \ No newline at end of file diff --git a/Lang/Erlang/A+B b/Lang/Erlang/A+B new file mode 120000 index 0000000000..c73fac22d5 --- /dev/null +++ b/Lang/Erlang/A+B @@ -0,0 +1 @@ +../../Task/A+B/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Accumulator-factory b/Lang/Erlang/Accumulator-factory new file mode 120000 index 0000000000..2ba2b26093 --- /dev/null +++ b/Lang/Erlang/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Align-columns b/Lang/Erlang/Align-columns new file mode 120000 index 0000000000..19897518c2 --- /dev/null +++ b/Lang/Erlang/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Apply-a-callback-to-an-array b/Lang/Erlang/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..a0d77b7e57 --- /dev/null +++ b/Lang/Erlang/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Arbitrary-precision-integers-(included) b/Lang/Erlang/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..5f91c4abcd --- /dev/null +++ b/Lang/Erlang/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Arithmetic-Complex b/Lang/Erlang/Arithmetic-Complex new file mode 120000 index 0000000000..dbbd3f41be --- /dev/null +++ b/Lang/Erlang/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Arithmetic-geometric-mean b/Lang/Erlang/Arithmetic-geometric-mean new file mode 120000 index 0000000000..f18242fe7a --- /dev/null +++ b/Lang/Erlang/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Array-concatenation b/Lang/Erlang/Array-concatenation new file mode 120000 index 0000000000..2be2132216 --- /dev/null +++ b/Lang/Erlang/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Associative-array-Creation b/Lang/Erlang/Associative-array-Creation new file mode 120000 index 0000000000..86a1834249 --- /dev/null +++ b/Lang/Erlang/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Associative-array-Iteration b/Lang/Erlang/Associative-array-Iteration new file mode 120000 index 0000000000..4bf5828251 --- /dev/null +++ b/Lang/Erlang/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Averages-Arithmetic-mean b/Lang/Erlang/Averages-Arithmetic-mean new file mode 120000 index 0000000000..e073b0d249 --- /dev/null +++ b/Lang/Erlang/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Averages-Median b/Lang/Erlang/Averages-Median new file mode 120000 index 0000000000..f85fc2e793 --- /dev/null +++ b/Lang/Erlang/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Averages-Pythagorean-means b/Lang/Erlang/Averages-Pythagorean-means new file mode 120000 index 0000000000..f6ce90fb1a --- /dev/null +++ b/Lang/Erlang/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Averages-Root-mean-square b/Lang/Erlang/Averages-Root-mean-square new file mode 120000 index 0000000000..9ec7e13fa9 --- /dev/null +++ b/Lang/Erlang/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Averages-Simple-moving-average b/Lang/Erlang/Averages-Simple-moving-average new file mode 120000 index 0000000000..8086d5a3bb --- /dev/null +++ b/Lang/Erlang/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Erlang \ No newline at end of file diff --git a/Lang/Forth/A+B b/Lang/Forth/A+B new file mode 120000 index 0000000000..0ff2533087 --- /dev/null +++ b/Lang/Forth/A+B @@ -0,0 +1 @@ +../../Task/A+B/Forth \ No newline at end of file diff --git a/Lang/Forth/Abstract-type b/Lang/Forth/Abstract-type new file mode 120000 index 0000000000..a2b2f3dde3 --- /dev/null +++ b/Lang/Forth/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Forth \ No newline at end of file diff --git a/Lang/Forth/Accumulator-factory b/Lang/Forth/Accumulator-factory new file mode 120000 index 0000000000..d2f5989d2b --- /dev/null +++ b/Lang/Forth/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Forth \ No newline at end of file diff --git a/Lang/Forth/Align-columns b/Lang/Forth/Align-columns new file mode 120000 index 0000000000..f5864372a3 --- /dev/null +++ b/Lang/Forth/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Forth \ No newline at end of file diff --git a/Lang/Forth/Anonymous-recursion b/Lang/Forth/Anonymous-recursion new file mode 120000 index 0000000000..cf9f1cc70c --- /dev/null +++ b/Lang/Forth/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Forth \ No newline at end of file diff --git a/Lang/Forth/Apply-a-callback-to-an-array b/Lang/Forth/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..781379b05b --- /dev/null +++ b/Lang/Forth/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Forth \ No newline at end of file diff --git a/Lang/Forth/Arithmetic-Complex b/Lang/Forth/Arithmetic-Complex new file mode 120000 index 0000000000..b6789ff0d6 --- /dev/null +++ b/Lang/Forth/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Forth \ No newline at end of file diff --git a/Lang/Forth/Arithmetic-Rational b/Lang/Forth/Arithmetic-Rational new file mode 120000 index 0000000000..f3b8f4aca6 --- /dev/null +++ b/Lang/Forth/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Forth \ No newline at end of file diff --git a/Lang/Forth/Array-concatenation b/Lang/Forth/Array-concatenation new file mode 120000 index 0000000000..7d190bc82f --- /dev/null +++ b/Lang/Forth/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Forth \ No newline at end of file diff --git a/Lang/Forth/Associative-array-Creation b/Lang/Forth/Associative-array-Creation new file mode 120000 index 0000000000..b63d82e7d0 --- /dev/null +++ b/Lang/Forth/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Forth \ No newline at end of file diff --git a/Lang/Forth/Associative-array-Iteration b/Lang/Forth/Associative-array-Iteration new file mode 120000 index 0000000000..6876b064ab --- /dev/null +++ b/Lang/Forth/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Forth \ No newline at end of file diff --git a/Lang/Forth/Averages-Arithmetic-mean b/Lang/Forth/Averages-Arithmetic-mean new file mode 120000 index 0000000000..f34d2d226e --- /dev/null +++ b/Lang/Forth/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Forth \ No newline at end of file diff --git a/Lang/Forth/Averages-Median b/Lang/Forth/Averages-Median new file mode 120000 index 0000000000..dc45a10dc6 --- /dev/null +++ b/Lang/Forth/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Forth \ No newline at end of file diff --git a/Lang/Forth/Averages-Pythagorean-means b/Lang/Forth/Averages-Pythagorean-means new file mode 120000 index 0000000000..dfecd91a5a --- /dev/null +++ b/Lang/Forth/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Forth \ No newline at end of file diff --git a/Lang/Forth/Averages-Root-mean-square b/Lang/Forth/Averages-Root-mean-square new file mode 120000 index 0000000000..b3fcda203b --- /dev/null +++ b/Lang/Forth/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Forth \ No newline at end of file diff --git a/Lang/Forth/Averages-Simple-moving-average b/Lang/Forth/Averages-Simple-moving-average new file mode 120000 index 0000000000..3172ed2903 --- /dev/null +++ b/Lang/Forth/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Forth \ No newline at end of file diff --git a/Lang/Fortran/A+B b/Lang/Fortran/A+B new file mode 120000 index 0000000000..6e842f8105 --- /dev/null +++ b/Lang/Fortran/A+B @@ -0,0 +1 @@ +../../Task/A+B/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Address-of-a-variable b/Lang/Fortran/Address-of-a-variable new file mode 120000 index 0000000000..cb0adc1aad --- /dev/null +++ b/Lang/Fortran/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Anonymous-recursion b/Lang/Fortran/Anonymous-recursion new file mode 120000 index 0000000000..d25f39185b --- /dev/null +++ b/Lang/Fortran/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Apply-a-callback-to-an-array b/Lang/Fortran/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..048b58a73a --- /dev/null +++ b/Lang/Fortran/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Arithmetic-Complex b/Lang/Fortran/Arithmetic-Complex new file mode 120000 index 0000000000..3a4c914340 --- /dev/null +++ b/Lang/Fortran/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Arithmetic-Rational b/Lang/Fortran/Arithmetic-Rational new file mode 120000 index 0000000000..7521cd6d85 --- /dev/null +++ b/Lang/Fortran/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Arithmetic-geometric-mean b/Lang/Fortran/Arithmetic-geometric-mean new file mode 120000 index 0000000000..0c38a807b7 --- /dev/null +++ b/Lang/Fortran/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Array-concatenation b/Lang/Fortran/Array-concatenation new file mode 120000 index 0000000000..807b2bb592 --- /dev/null +++ b/Lang/Fortran/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Averages-Arithmetic-mean b/Lang/Fortran/Averages-Arithmetic-mean new file mode 120000 index 0000000000..7830e0f572 --- /dev/null +++ b/Lang/Fortran/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Averages-Median b/Lang/Fortran/Averages-Median new file mode 120000 index 0000000000..be6afd15e4 --- /dev/null +++ b/Lang/Fortran/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Averages-Pythagorean-means b/Lang/Fortran/Averages-Pythagorean-means new file mode 120000 index 0000000000..ceb24af9e4 --- /dev/null +++ b/Lang/Fortran/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Averages-Root-mean-square b/Lang/Fortran/Averages-Root-mean-square new file mode 120000 index 0000000000..ef91f9d2eb --- /dev/null +++ b/Lang/Fortran/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Averages-Simple-moving-average b/Lang/Fortran/Averages-Simple-moving-average new file mode 120000 index 0000000000..5a6047db03 --- /dev/null +++ b/Lang/Fortran/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Fortran \ No newline at end of file diff --git a/Lang/Go/A+B b/Lang/Go/A+B new file mode 120000 index 0000000000..f50cd5fa8b --- /dev/null +++ b/Lang/Go/A+B @@ -0,0 +1 @@ +../../Task/A+B/Go \ No newline at end of file diff --git a/Lang/Go/Abstract-type b/Lang/Go/Abstract-type new file mode 120000 index 0000000000..35dc807f53 --- /dev/null +++ b/Lang/Go/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Go \ No newline at end of file diff --git a/Lang/Go/Accumulator-factory b/Lang/Go/Accumulator-factory new file mode 120000 index 0000000000..18796abff8 --- /dev/null +++ b/Lang/Go/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Go \ No newline at end of file diff --git a/Lang/Go/Active-object b/Lang/Go/Active-object new file mode 120000 index 0000000000..f0637827c4 --- /dev/null +++ b/Lang/Go/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/Go \ No newline at end of file diff --git a/Lang/Go/Address-of-a-variable b/Lang/Go/Address-of-a-variable new file mode 120000 index 0000000000..9142b07731 --- /dev/null +++ b/Lang/Go/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Go \ No newline at end of file diff --git a/Lang/Go/Align-columns b/Lang/Go/Align-columns new file mode 120000 index 0000000000..ec2c1837ad --- /dev/null +++ b/Lang/Go/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Go \ No newline at end of file diff --git a/Lang/Go/Anagrams-Deranged-anagrams b/Lang/Go/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..d4e014a083 --- /dev/null +++ b/Lang/Go/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Go \ No newline at end of file diff --git a/Lang/Go/Anonymous-recursion b/Lang/Go/Anonymous-recursion new file mode 120000 index 0000000000..193d6971dc --- /dev/null +++ b/Lang/Go/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Go \ No newline at end of file diff --git a/Lang/Go/Apply-a-callback-to-an-array b/Lang/Go/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..8e31365508 --- /dev/null +++ b/Lang/Go/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Go \ No newline at end of file diff --git a/Lang/Go/Arbitrary-precision-integers-(included) b/Lang/Go/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..a05728f01f --- /dev/null +++ b/Lang/Go/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Go \ No newline at end of file diff --git a/Lang/Go/Arithmetic-Complex b/Lang/Go/Arithmetic-Complex new file mode 120000 index 0000000000..2982f87714 --- /dev/null +++ b/Lang/Go/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Go \ No newline at end of file diff --git a/Lang/Go/Arithmetic-Rational b/Lang/Go/Arithmetic-Rational new file mode 120000 index 0000000000..4bfc56a4ea --- /dev/null +++ b/Lang/Go/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Go \ No newline at end of file diff --git a/Lang/Go/Arithmetic-geometric-mean b/Lang/Go/Arithmetic-geometric-mean new file mode 120000 index 0000000000..e48a017c78 --- /dev/null +++ b/Lang/Go/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Go \ No newline at end of file diff --git a/Lang/Go/Array-concatenation b/Lang/Go/Array-concatenation new file mode 120000 index 0000000000..5a00335cb4 --- /dev/null +++ b/Lang/Go/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Go \ No newline at end of file diff --git a/Lang/Go/Associative-array-Creation b/Lang/Go/Associative-array-Creation new file mode 120000 index 0000000000..14142f25bd --- /dev/null +++ b/Lang/Go/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Go \ No newline at end of file diff --git a/Lang/Go/Associative-array-Iteration b/Lang/Go/Associative-array-Iteration new file mode 120000 index 0000000000..24fd7384e4 --- /dev/null +++ b/Lang/Go/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Go \ No newline at end of file diff --git a/Lang/Go/Atomic-updates b/Lang/Go/Atomic-updates new file mode 120000 index 0000000000..ec3c23c76d --- /dev/null +++ b/Lang/Go/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Go \ No newline at end of file diff --git a/Lang/Go/Averages-Arithmetic-mean b/Lang/Go/Averages-Arithmetic-mean new file mode 120000 index 0000000000..9c1496cb50 --- /dev/null +++ b/Lang/Go/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Go \ No newline at end of file diff --git a/Lang/Go/Averages-Mean-angle b/Lang/Go/Averages-Mean-angle new file mode 120000 index 0000000000..53f5034e2c --- /dev/null +++ b/Lang/Go/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Go \ No newline at end of file diff --git a/Lang/Go/Averages-Mean-time-of-day b/Lang/Go/Averages-Mean-time-of-day new file mode 120000 index 0000000000..0233cd4219 --- /dev/null +++ b/Lang/Go/Averages-Mean-time-of-day @@ -0,0 +1 @@ +../../Task/Averages-Mean-time-of-day/Go \ No newline at end of file diff --git a/Lang/Go/Averages-Median b/Lang/Go/Averages-Median new file mode 120000 index 0000000000..db92d2843a --- /dev/null +++ b/Lang/Go/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Go \ No newline at end of file diff --git a/Lang/Go/Averages-Pythagorean-means b/Lang/Go/Averages-Pythagorean-means new file mode 120000 index 0000000000..136aa9c40d --- /dev/null +++ b/Lang/Go/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Go \ No newline at end of file diff --git a/Lang/Go/Averages-Root-mean-square b/Lang/Go/Averages-Root-mean-square new file mode 120000 index 0000000000..d89aad5e64 --- /dev/null +++ b/Lang/Go/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Go \ No newline at end of file diff --git a/Lang/Go/Averages-Simple-moving-average b/Lang/Go/Averages-Simple-moving-average new file mode 120000 index 0000000000..1dcd6e9083 --- /dev/null +++ b/Lang/Go/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Go \ No newline at end of file diff --git a/Lang/Haskell/A+B b/Lang/Haskell/A+B new file mode 120000 index 0000000000..4ef9ea0b30 --- /dev/null +++ b/Lang/Haskell/A+B @@ -0,0 +1 @@ +../../Task/A+B/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Abstract-type b/Lang/Haskell/Abstract-type new file mode 120000 index 0000000000..b004105026 --- /dev/null +++ b/Lang/Haskell/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Accumulator-factory b/Lang/Haskell/Accumulator-factory new file mode 120000 index 0000000000..8bafd17c7a --- /dev/null +++ b/Lang/Haskell/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Active-object b/Lang/Haskell/Active-object new file mode 120000 index 0000000000..a5ceb4e035 --- /dev/null +++ b/Lang/Haskell/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Align-columns b/Lang/Haskell/Align-columns new file mode 120000 index 0000000000..786130092e --- /dev/null +++ b/Lang/Haskell/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Anagrams-Deranged-anagrams b/Lang/Haskell/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..f16d2e850d --- /dev/null +++ b/Lang/Haskell/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Animation b/Lang/Haskell/Animation new file mode 120000 index 0000000000..86ff27774a --- /dev/null +++ b/Lang/Haskell/Animation @@ -0,0 +1 @@ +../../Task/Animation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Anonymous-recursion b/Lang/Haskell/Anonymous-recursion new file mode 120000 index 0000000000..2dee91d64f --- /dev/null +++ b/Lang/Haskell/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Apply-a-callback-to-an-array b/Lang/Haskell/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..2fb7e5e070 --- /dev/null +++ b/Lang/Haskell/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Arbitrary-precision-integers-(included) b/Lang/Haskell/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..3b0b103363 --- /dev/null +++ b/Lang/Haskell/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Arithmetic-Complex b/Lang/Haskell/Arithmetic-Complex new file mode 120000 index 0000000000..4320bb3437 --- /dev/null +++ b/Lang/Haskell/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Arithmetic-Rational b/Lang/Haskell/Arithmetic-Rational new file mode 120000 index 0000000000..292b942337 --- /dev/null +++ b/Lang/Haskell/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Arithmetic-evaluation b/Lang/Haskell/Arithmetic-evaluation new file mode 120000 index 0000000000..d20f20aad4 --- /dev/null +++ b/Lang/Haskell/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Arithmetic-geometric-mean b/Lang/Haskell/Arithmetic-geometric-mean new file mode 120000 index 0000000000..2a3c52118e --- /dev/null +++ b/Lang/Haskell/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Array-concatenation b/Lang/Haskell/Array-concatenation new file mode 120000 index 0000000000..9217936871 --- /dev/null +++ b/Lang/Haskell/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Associative-array-Creation b/Lang/Haskell/Associative-array-Creation new file mode 120000 index 0000000000..b69466f0e3 --- /dev/null +++ b/Lang/Haskell/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Associative-array-Iteration b/Lang/Haskell/Associative-array-Iteration new file mode 120000 index 0000000000..623a77ccda --- /dev/null +++ b/Lang/Haskell/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Atomic-updates b/Lang/Haskell/Atomic-updates new file mode 120000 index 0000000000..670fcd5c8d --- /dev/null +++ b/Lang/Haskell/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Averages-Arithmetic-mean b/Lang/Haskell/Averages-Arithmetic-mean new file mode 120000 index 0000000000..879c35aafa --- /dev/null +++ b/Lang/Haskell/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Averages-Mean-angle b/Lang/Haskell/Averages-Mean-angle new file mode 120000 index 0000000000..4aa04517cb --- /dev/null +++ b/Lang/Haskell/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Averages-Median b/Lang/Haskell/Averages-Median new file mode 120000 index 0000000000..106da7089d --- /dev/null +++ b/Lang/Haskell/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Averages-Pythagorean-means b/Lang/Haskell/Averages-Pythagorean-means new file mode 120000 index 0000000000..a1176c7e55 --- /dev/null +++ b/Lang/Haskell/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Averages-Root-mean-square b/Lang/Haskell/Averages-Root-mean-square new file mode 120000 index 0000000000..68f049caad --- /dev/null +++ b/Lang/Haskell/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Averages-Simple-moving-average b/Lang/Haskell/Averages-Simple-moving-average new file mode 120000 index 0000000000..4fc38a0a9a --- /dev/null +++ b/Lang/Haskell/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Haskell \ No newline at end of file diff --git a/Lang/Java/A+B b/Lang/Java/A+B new file mode 120000 index 0000000000..99be2f5987 --- /dev/null +++ b/Lang/Java/A+B @@ -0,0 +1 @@ +../../Task/A+B/Java \ No newline at end of file diff --git a/Lang/Java/Abstract-type b/Lang/Java/Abstract-type new file mode 120000 index 0000000000..db0a530906 --- /dev/null +++ b/Lang/Java/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Java \ No newline at end of file diff --git a/Lang/Java/Accumulator-factory b/Lang/Java/Accumulator-factory new file mode 120000 index 0000000000..445e1942ee --- /dev/null +++ b/Lang/Java/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Java \ No newline at end of file diff --git a/Lang/Java/Active-Directory-Connect b/Lang/Java/Active-Directory-Connect new file mode 120000 index 0000000000..fe92739773 --- /dev/null +++ b/Lang/Java/Active-Directory-Connect @@ -0,0 +1 @@ +../../Task/Active-Directory-Connect/Java \ No newline at end of file diff --git a/Lang/Java/Active-Directory-Search-for-a-user b/Lang/Java/Active-Directory-Search-for-a-user new file mode 120000 index 0000000000..4c6e38900c --- /dev/null +++ b/Lang/Java/Active-Directory-Search-for-a-user @@ -0,0 +1 @@ +../../Task/Active-Directory-Search-for-a-user/Java \ No newline at end of file diff --git a/Lang/Java/Anagrams-Deranged-anagrams b/Lang/Java/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..5f191291a6 --- /dev/null +++ b/Lang/Java/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Java \ No newline at end of file diff --git a/Lang/Java/Animation b/Lang/Java/Animation new file mode 120000 index 0000000000..209f91cc83 --- /dev/null +++ b/Lang/Java/Animation @@ -0,0 +1 @@ +../../Task/Animation/Java \ No newline at end of file diff --git a/Lang/Java/Anonymous-recursion b/Lang/Java/Anonymous-recursion new file mode 120000 index 0000000000..c192f6db56 --- /dev/null +++ b/Lang/Java/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Java \ No newline at end of file diff --git a/Lang/Java/Apply-a-callback-to-an-array b/Lang/Java/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..4f53680b0d --- /dev/null +++ b/Lang/Java/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Java \ No newline at end of file diff --git a/Lang/Java/Arbitrary-precision-integers-(included) b/Lang/Java/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..2f66d23776 --- /dev/null +++ b/Lang/Java/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Java \ No newline at end of file diff --git a/Lang/Java/Arithmetic-Complex b/Lang/Java/Arithmetic-Complex new file mode 120000 index 0000000000..264c358291 --- /dev/null +++ b/Lang/Java/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Java \ No newline at end of file diff --git a/Lang/Java/Arithmetic-Rational b/Lang/Java/Arithmetic-Rational new file mode 120000 index 0000000000..aaa48e8d9a --- /dev/null +++ b/Lang/Java/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Java \ No newline at end of file diff --git a/Lang/Java/Arithmetic-evaluation b/Lang/Java/Arithmetic-evaluation new file mode 120000 index 0000000000..38a0a7b93a --- /dev/null +++ b/Lang/Java/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Java \ No newline at end of file diff --git a/Lang/Java/Arithmetic-geometric-mean b/Lang/Java/Arithmetic-geometric-mean new file mode 120000 index 0000000000..d07b667d51 --- /dev/null +++ b/Lang/Java/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Java \ No newline at end of file diff --git a/Lang/Java/Array-concatenation b/Lang/Java/Array-concatenation new file mode 120000 index 0000000000..35df6d22c0 --- /dev/null +++ b/Lang/Java/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Java \ No newline at end of file diff --git a/Lang/Java/Associative-array-Creation b/Lang/Java/Associative-array-Creation new file mode 120000 index 0000000000..215346a0b0 --- /dev/null +++ b/Lang/Java/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Java \ No newline at end of file diff --git a/Lang/Java/Associative-array-Iteration b/Lang/Java/Associative-array-Iteration new file mode 120000 index 0000000000..2a72ef9a59 --- /dev/null +++ b/Lang/Java/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Java \ No newline at end of file diff --git a/Lang/Java/Atomic-updates b/Lang/Java/Atomic-updates new file mode 120000 index 0000000000..43aa9c2a26 --- /dev/null +++ b/Lang/Java/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Java \ No newline at end of file diff --git a/Lang/Java/Averages-Arithmetic-mean b/Lang/Java/Averages-Arithmetic-mean new file mode 120000 index 0000000000..fea91ead72 --- /dev/null +++ b/Lang/Java/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Java \ No newline at end of file diff --git a/Lang/Java/Averages-Median b/Lang/Java/Averages-Median new file mode 120000 index 0000000000..429143dc1d --- /dev/null +++ b/Lang/Java/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Java \ No newline at end of file diff --git a/Lang/Java/Averages-Pythagorean-means b/Lang/Java/Averages-Pythagorean-means new file mode 120000 index 0000000000..7c7872e383 --- /dev/null +++ b/Lang/Java/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Java \ No newline at end of file diff --git a/Lang/Java/Averages-Root-mean-square b/Lang/Java/Averages-Root-mean-square new file mode 120000 index 0000000000..b06792dbd7 --- /dev/null +++ b/Lang/Java/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Java \ No newline at end of file diff --git a/Lang/Java/Averages-Simple-moving-average b/Lang/Java/Averages-Simple-moving-average new file mode 120000 index 0000000000..c9818887b6 --- /dev/null +++ b/Lang/Java/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Java \ No newline at end of file diff --git a/Lang/JavaScript/A+B b/Lang/JavaScript/A+B new file mode 120000 index 0000000000..34924358ef --- /dev/null +++ b/Lang/JavaScript/A+B @@ -0,0 +1 @@ +../../Task/A+B/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Accumulator-factory b/Lang/JavaScript/Accumulator-factory new file mode 120000 index 0000000000..f27a648e2c --- /dev/null +++ b/Lang/JavaScript/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Active-object b/Lang/JavaScript/Active-object new file mode 120000 index 0000000000..fc0ebec758 --- /dev/null +++ b/Lang/JavaScript/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Add-a-variable-to-a-class-instance-at-runtime b/Lang/JavaScript/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..0365ad4369 --- /dev/null +++ b/Lang/JavaScript/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Align-columns b/Lang/JavaScript/Align-columns new file mode 120000 index 0000000000..a79f249841 --- /dev/null +++ b/Lang/JavaScript/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Anagrams-Deranged-anagrams b/Lang/JavaScript/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..896f10eb78 --- /dev/null +++ b/Lang/JavaScript/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Animation b/Lang/JavaScript/Animation new file mode 120000 index 0000000000..c4e6d16e74 --- /dev/null +++ b/Lang/JavaScript/Animation @@ -0,0 +1 @@ +../../Task/Animation/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Anonymous-recursion b/Lang/JavaScript/Anonymous-recursion new file mode 120000 index 0000000000..4161a5ad0a --- /dev/null +++ b/Lang/JavaScript/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Apply-a-callback-to-an-array b/Lang/JavaScript/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..b61b614b34 --- /dev/null +++ b/Lang/JavaScript/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Arithmetic-Complex b/Lang/JavaScript/Arithmetic-Complex new file mode 120000 index 0000000000..b124932b19 --- /dev/null +++ b/Lang/JavaScript/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Arithmetic-evaluation b/Lang/JavaScript/Arithmetic-evaluation new file mode 120000 index 0000000000..6a4263b5c2 --- /dev/null +++ b/Lang/JavaScript/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Array-concatenation b/Lang/JavaScript/Array-concatenation new file mode 120000 index 0000000000..fd6829201d --- /dev/null +++ b/Lang/JavaScript/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Associative-array-Creation b/Lang/JavaScript/Associative-array-Creation new file mode 120000 index 0000000000..9a576fc8a4 --- /dev/null +++ b/Lang/JavaScript/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Associative-array-Iteration b/Lang/JavaScript/Associative-array-Iteration new file mode 120000 index 0000000000..2362596f56 --- /dev/null +++ b/Lang/JavaScript/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Averages-Arithmetic-mean b/Lang/JavaScript/Averages-Arithmetic-mean new file mode 120000 index 0000000000..b37f14259c --- /dev/null +++ b/Lang/JavaScript/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Averages-Median b/Lang/JavaScript/Averages-Median new file mode 120000 index 0000000000..4eaa3526dc --- /dev/null +++ b/Lang/JavaScript/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Averages-Pythagorean-means b/Lang/JavaScript/Averages-Pythagorean-means new file mode 120000 index 0000000000..e43bd4d627 --- /dev/null +++ b/Lang/JavaScript/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Averages-Root-mean-square b/Lang/JavaScript/Averages-Root-mean-square new file mode 120000 index 0000000000..dd5b9073f8 --- /dev/null +++ b/Lang/JavaScript/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Averages-Simple-moving-average b/Lang/JavaScript/Averages-Simple-moving-average new file mode 120000 index 0000000000..d978c0aec8 --- /dev/null +++ b/Lang/JavaScript/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/JavaScript \ No newline at end of file diff --git a/Lang/Lua/A+B b/Lang/Lua/A+B new file mode 120000 index 0000000000..eaa06bef4d --- /dev/null +++ b/Lang/Lua/A+B @@ -0,0 +1 @@ +../../Task/A+B/Lua \ No newline at end of file diff --git a/Lang/Lua/Abstract-type b/Lang/Lua/Abstract-type new file mode 120000 index 0000000000..ce9d4a4d8f --- /dev/null +++ b/Lang/Lua/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Lua \ No newline at end of file diff --git a/Lang/Lua/Accumulator-factory b/Lang/Lua/Accumulator-factory new file mode 120000 index 0000000000..3d005f7a22 --- /dev/null +++ b/Lang/Lua/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Lua \ No newline at end of file diff --git a/Lang/Lua/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Lua/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..2c42c0800d --- /dev/null +++ b/Lang/Lua/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Lua \ No newline at end of file diff --git a/Lang/Lua/Align-columns b/Lang/Lua/Align-columns new file mode 120000 index 0000000000..7c394c2578 --- /dev/null +++ b/Lang/Lua/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Lua \ No newline at end of file diff --git a/Lang/Lua/Anonymous-recursion b/Lang/Lua/Anonymous-recursion new file mode 120000 index 0000000000..1b8b60022e --- /dev/null +++ b/Lang/Lua/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Lua \ No newline at end of file diff --git a/Lang/Lua/Apply-a-callback-to-an-array b/Lang/Lua/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..dae51c67d0 --- /dev/null +++ b/Lang/Lua/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Lua \ No newline at end of file diff --git a/Lang/Lua/Arithmetic-Complex b/Lang/Lua/Arithmetic-Complex new file mode 120000 index 0000000000..6c3070e84a --- /dev/null +++ b/Lang/Lua/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Lua \ No newline at end of file diff --git a/Lang/Lua/Arithmetic-Rational b/Lang/Lua/Arithmetic-Rational new file mode 120000 index 0000000000..85f18f36ea --- /dev/null +++ b/Lang/Lua/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Lua \ No newline at end of file diff --git a/Lang/Lua/Arithmetic-evaluation b/Lang/Lua/Arithmetic-evaluation new file mode 120000 index 0000000000..a97adc6541 --- /dev/null +++ b/Lang/Lua/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Lua \ No newline at end of file diff --git a/Lang/Lua/Array-concatenation b/Lang/Lua/Array-concatenation new file mode 120000 index 0000000000..d2959e470b --- /dev/null +++ b/Lang/Lua/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Lua \ No newline at end of file diff --git a/Lang/Lua/Associative-array-Creation b/Lang/Lua/Associative-array-Creation new file mode 120000 index 0000000000..ac45de77f4 --- /dev/null +++ b/Lang/Lua/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Lua \ No newline at end of file diff --git a/Lang/Lua/Associative-array-Iteration b/Lang/Lua/Associative-array-Iteration new file mode 120000 index 0000000000..0fa63ae6c5 --- /dev/null +++ b/Lang/Lua/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Lua \ No newline at end of file diff --git a/Lang/Lua/Averages-Arithmetic-mean b/Lang/Lua/Averages-Arithmetic-mean new file mode 120000 index 0000000000..4bf9710d62 --- /dev/null +++ b/Lang/Lua/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Lua \ No newline at end of file diff --git a/Lang/Lua/Averages-Median b/Lang/Lua/Averages-Median new file mode 120000 index 0000000000..58f61b80ac --- /dev/null +++ b/Lang/Lua/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Lua \ No newline at end of file diff --git a/Lang/Lua/Averages-Pythagorean-means b/Lang/Lua/Averages-Pythagorean-means new file mode 120000 index 0000000000..245c082294 --- /dev/null +++ b/Lang/Lua/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Lua \ No newline at end of file diff --git a/Lang/Lua/Averages-Root-mean-square b/Lang/Lua/Averages-Root-mean-square new file mode 120000 index 0000000000..8fd355f5af --- /dev/null +++ b/Lang/Lua/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Lua \ No newline at end of file diff --git a/Lang/Lua/Averages-Simple-moving-average b/Lang/Lua/Averages-Simple-moving-average new file mode 120000 index 0000000000..10f28f067b --- /dev/null +++ b/Lang/Lua/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Lua \ No newline at end of file diff --git a/Lang/PHP/A+B b/Lang/PHP/A+B new file mode 120000 index 0000000000..6eaa4f0a15 --- /dev/null +++ b/Lang/PHP/A+B @@ -0,0 +1 @@ +../../Task/A+B/PHP \ No newline at end of file diff --git a/Lang/PHP/Abstract-type b/Lang/PHP/Abstract-type new file mode 120000 index 0000000000..dfc491bdc9 --- /dev/null +++ b/Lang/PHP/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/PHP \ No newline at end of file diff --git a/Lang/PHP/Accumulator-factory b/Lang/PHP/Accumulator-factory new file mode 120000 index 0000000000..752d37f12c --- /dev/null +++ b/Lang/PHP/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/PHP \ No newline at end of file diff --git a/Lang/PHP/Active-Directory-Connect b/Lang/PHP/Active-Directory-Connect new file mode 120000 index 0000000000..2e1d86f1c8 --- /dev/null +++ b/Lang/PHP/Active-Directory-Connect @@ -0,0 +1 @@ +../../Task/Active-Directory-Connect/PHP \ No newline at end of file diff --git a/Lang/PHP/Active-Directory-Search-for-a-user b/Lang/PHP/Active-Directory-Search-for-a-user new file mode 120000 index 0000000000..e2cc6cceb4 --- /dev/null +++ b/Lang/PHP/Active-Directory-Search-for-a-user @@ -0,0 +1 @@ +../../Task/Active-Directory-Search-for-a-user/PHP \ No newline at end of file diff --git a/Lang/PHP/Add-a-variable-to-a-class-instance-at-runtime b/Lang/PHP/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..b4d856d627 --- /dev/null +++ b/Lang/PHP/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/PHP \ No newline at end of file diff --git a/Lang/PHP/Align-columns b/Lang/PHP/Align-columns new file mode 120000 index 0000000000..6b0ba4f7c8 --- /dev/null +++ b/Lang/PHP/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/PHP \ No newline at end of file diff --git a/Lang/PHP/Anagrams-Deranged-anagrams b/Lang/PHP/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..6a83a1dd7f --- /dev/null +++ b/Lang/PHP/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/PHP \ No newline at end of file diff --git a/Lang/PHP/Anonymous-recursion b/Lang/PHP/Anonymous-recursion new file mode 120000 index 0000000000..19f04e7fe9 --- /dev/null +++ b/Lang/PHP/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/PHP \ No newline at end of file diff --git a/Lang/PHP/Apply-a-callback-to-an-array b/Lang/PHP/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..4b59cbd07d --- /dev/null +++ b/Lang/PHP/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/PHP \ No newline at end of file diff --git a/Lang/PHP/Arbitrary-precision-integers-(included) b/Lang/PHP/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..349602ec2b --- /dev/null +++ b/Lang/PHP/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/PHP \ No newline at end of file diff --git a/Lang/PHP/Arithmetic-geometric-mean b/Lang/PHP/Arithmetic-geometric-mean new file mode 120000 index 0000000000..c8847d05b2 --- /dev/null +++ b/Lang/PHP/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/PHP \ No newline at end of file diff --git a/Lang/PHP/Array-concatenation b/Lang/PHP/Array-concatenation new file mode 120000 index 0000000000..570cd43d7c --- /dev/null +++ b/Lang/PHP/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/PHP \ No newline at end of file diff --git a/Lang/PHP/Associative-array-Creation b/Lang/PHP/Associative-array-Creation new file mode 120000 index 0000000000..d16887b167 --- /dev/null +++ b/Lang/PHP/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/PHP \ No newline at end of file diff --git a/Lang/PHP/Associative-array-Iteration b/Lang/PHP/Associative-array-Iteration new file mode 120000 index 0000000000..1ab97c4256 --- /dev/null +++ b/Lang/PHP/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/PHP \ No newline at end of file diff --git a/Lang/PHP/Averages-Arithmetic-mean b/Lang/PHP/Averages-Arithmetic-mean new file mode 120000 index 0000000000..6ba06d783a --- /dev/null +++ b/Lang/PHP/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/PHP \ No newline at end of file diff --git a/Lang/PHP/Averages-Median b/Lang/PHP/Averages-Median new file mode 120000 index 0000000000..a191eb4ac3 --- /dev/null +++ b/Lang/PHP/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/PHP \ No newline at end of file diff --git a/Lang/Perl/A+B b/Lang/Perl/A+B new file mode 120000 index 0000000000..8e3adcb6c3 --- /dev/null +++ b/Lang/Perl/A+B @@ -0,0 +1 @@ +../../Task/A+B/Perl \ No newline at end of file diff --git a/Lang/Perl/Abstract-type b/Lang/Perl/Abstract-type new file mode 120000 index 0000000000..ad54287e90 --- /dev/null +++ b/Lang/Perl/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Perl \ No newline at end of file diff --git a/Lang/Perl/Accumulator-factory b/Lang/Perl/Accumulator-factory new file mode 120000 index 0000000000..340179f3e0 --- /dev/null +++ b/Lang/Perl/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Perl \ No newline at end of file diff --git a/Lang/Perl/Active-Directory-Connect b/Lang/Perl/Active-Directory-Connect new file mode 120000 index 0000000000..6bbe3b8f94 --- /dev/null +++ b/Lang/Perl/Active-Directory-Connect @@ -0,0 +1 @@ +../../Task/Active-Directory-Connect/Perl \ No newline at end of file diff --git a/Lang/Perl/Active-object b/Lang/Perl/Active-object new file mode 120000 index 0000000000..57892b8abc --- /dev/null +++ b/Lang/Perl/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/Perl \ No newline at end of file diff --git a/Lang/Perl/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Perl/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..7d3854f1cb --- /dev/null +++ b/Lang/Perl/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Perl \ No newline at end of file diff --git a/Lang/Perl/Address-of-a-variable b/Lang/Perl/Address-of-a-variable new file mode 120000 index 0000000000..f7b7788f06 --- /dev/null +++ b/Lang/Perl/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Perl \ No newline at end of file diff --git a/Lang/Perl/Align-columns b/Lang/Perl/Align-columns new file mode 120000 index 0000000000..ae7018b94a --- /dev/null +++ b/Lang/Perl/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Perl \ No newline at end of file diff --git a/Lang/Perl/Anagrams-Deranged-anagrams b/Lang/Perl/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..1ad86d89a4 --- /dev/null +++ b/Lang/Perl/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Perl \ No newline at end of file diff --git a/Lang/Perl/Animation b/Lang/Perl/Animation new file mode 120000 index 0000000000..5b01dcb1dd --- /dev/null +++ b/Lang/Perl/Animation @@ -0,0 +1 @@ +../../Task/Animation/Perl \ No newline at end of file diff --git a/Lang/Perl/Anonymous-recursion b/Lang/Perl/Anonymous-recursion new file mode 120000 index 0000000000..0156f940ed --- /dev/null +++ b/Lang/Perl/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Perl \ No newline at end of file diff --git a/Lang/Perl/Apply-a-callback-to-an-array b/Lang/Perl/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..61ed270cf7 --- /dev/null +++ b/Lang/Perl/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Perl \ No newline at end of file diff --git a/Lang/Perl/Arbitrary-precision-integers-(included) b/Lang/Perl/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..02d6c446d0 --- /dev/null +++ b/Lang/Perl/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Perl \ No newline at end of file diff --git a/Lang/Perl/Arithmetic-Complex b/Lang/Perl/Arithmetic-Complex new file mode 120000 index 0000000000..e693c726e8 --- /dev/null +++ b/Lang/Perl/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Perl \ No newline at end of file diff --git a/Lang/Perl/Arithmetic-Rational b/Lang/Perl/Arithmetic-Rational new file mode 120000 index 0000000000..aa6df9def4 --- /dev/null +++ b/Lang/Perl/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Perl \ No newline at end of file diff --git a/Lang/Perl/Arithmetic-evaluation b/Lang/Perl/Arithmetic-evaluation new file mode 120000 index 0000000000..20a459fa52 --- /dev/null +++ b/Lang/Perl/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Perl \ No newline at end of file diff --git a/Lang/Perl/Arithmetic-geometric-mean b/Lang/Perl/Arithmetic-geometric-mean new file mode 120000 index 0000000000..62fd17da9e --- /dev/null +++ b/Lang/Perl/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Perl \ No newline at end of file diff --git a/Lang/Perl/Array-concatenation b/Lang/Perl/Array-concatenation new file mode 120000 index 0000000000..85d05d15ed --- /dev/null +++ b/Lang/Perl/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Perl \ No newline at end of file diff --git a/Lang/Perl/Associative-array-Creation b/Lang/Perl/Associative-array-Creation new file mode 120000 index 0000000000..f58726bb94 --- /dev/null +++ b/Lang/Perl/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Perl \ No newline at end of file diff --git a/Lang/Perl/Associative-array-Iteration b/Lang/Perl/Associative-array-Iteration new file mode 120000 index 0000000000..faea751760 --- /dev/null +++ b/Lang/Perl/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Perl \ No newline at end of file diff --git a/Lang/Perl/Atomic-updates b/Lang/Perl/Atomic-updates new file mode 120000 index 0000000000..d3fea6e5d4 --- /dev/null +++ b/Lang/Perl/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Perl \ No newline at end of file diff --git a/Lang/Perl/Averages-Arithmetic-mean b/Lang/Perl/Averages-Arithmetic-mean new file mode 120000 index 0000000000..5d84f5ead9 --- /dev/null +++ b/Lang/Perl/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Perl \ No newline at end of file diff --git a/Lang/Perl/Averages-Median b/Lang/Perl/Averages-Median new file mode 120000 index 0000000000..75a8f709b3 --- /dev/null +++ b/Lang/Perl/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Perl \ No newline at end of file diff --git a/Lang/Perl/Averages-Pythagorean-means b/Lang/Perl/Averages-Pythagorean-means new file mode 120000 index 0000000000..0c6cf5229f --- /dev/null +++ b/Lang/Perl/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Perl \ No newline at end of file diff --git a/Lang/Perl/Averages-Root-mean-square b/Lang/Perl/Averages-Root-mean-square new file mode 120000 index 0000000000..ce578451be --- /dev/null +++ b/Lang/Perl/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Perl \ No newline at end of file diff --git a/Lang/Perl/Averages-Simple-moving-average b/Lang/Perl/Averages-Simple-moving-average new file mode 120000 index 0000000000..832a406da9 --- /dev/null +++ b/Lang/Perl/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Perl \ No newline at end of file diff --git a/Lang/PicoLisp/A+B b/Lang/PicoLisp/A+B new file mode 120000 index 0000000000..185b77a649 --- /dev/null +++ b/Lang/PicoLisp/A+B @@ -0,0 +1 @@ +../../Task/A+B/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Abstract-type b/Lang/PicoLisp/Abstract-type new file mode 120000 index 0000000000..6d67f53c9b --- /dev/null +++ b/Lang/PicoLisp/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Accumulator-factory b/Lang/PicoLisp/Accumulator-factory new file mode 120000 index 0000000000..dd215c559e --- /dev/null +++ b/Lang/PicoLisp/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Active-Directory-Connect b/Lang/PicoLisp/Active-Directory-Connect new file mode 120000 index 0000000000..8a3da3c91f --- /dev/null +++ b/Lang/PicoLisp/Active-Directory-Connect @@ -0,0 +1 @@ +../../Task/Active-Directory-Connect/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Active-Directory-Search-for-a-user b/Lang/PicoLisp/Active-Directory-Search-for-a-user new file mode 120000 index 0000000000..b98ba00157 --- /dev/null +++ b/Lang/PicoLisp/Active-Directory-Search-for-a-user @@ -0,0 +1 @@ +../../Task/Active-Directory-Search-for-a-user/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Active-object b/Lang/PicoLisp/Active-object new file mode 120000 index 0000000000..096c26985b --- /dev/null +++ b/Lang/PicoLisp/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Add-a-variable-to-a-class-instance-at-runtime b/Lang/PicoLisp/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..b9041d6a39 --- /dev/null +++ b/Lang/PicoLisp/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Address-of-a-variable b/Lang/PicoLisp/Address-of-a-variable new file mode 120000 index 0000000000..e2615816be --- /dev/null +++ b/Lang/PicoLisp/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Align-columns b/Lang/PicoLisp/Align-columns new file mode 120000 index 0000000000..a4d37cdc26 --- /dev/null +++ b/Lang/PicoLisp/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Anagrams-Deranged-anagrams b/Lang/PicoLisp/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..9be682afd4 --- /dev/null +++ b/Lang/PicoLisp/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Animation b/Lang/PicoLisp/Animation new file mode 120000 index 0000000000..493f41ac67 --- /dev/null +++ b/Lang/PicoLisp/Animation @@ -0,0 +1 @@ +../../Task/Animation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Anonymous-recursion b/Lang/PicoLisp/Anonymous-recursion new file mode 120000 index 0000000000..0904744147 --- /dev/null +++ b/Lang/PicoLisp/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Apply-a-callback-to-an-array b/Lang/PicoLisp/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..7fd233e2d9 --- /dev/null +++ b/Lang/PicoLisp/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Arbitrary-precision-integers-(included) b/Lang/PicoLisp/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..1c4a84fcba --- /dev/null +++ b/Lang/PicoLisp/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Arithmetic-Complex b/Lang/PicoLisp/Arithmetic-Complex new file mode 120000 index 0000000000..0eb57ac928 --- /dev/null +++ b/Lang/PicoLisp/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Arithmetic-Rational b/Lang/PicoLisp/Arithmetic-Rational new file mode 120000 index 0000000000..8b8534ac52 --- /dev/null +++ b/Lang/PicoLisp/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Arithmetic-evaluation b/Lang/PicoLisp/Arithmetic-evaluation new file mode 120000 index 0000000000..38d15bcb94 --- /dev/null +++ b/Lang/PicoLisp/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Arithmetic-geometric-mean b/Lang/PicoLisp/Arithmetic-geometric-mean new file mode 120000 index 0000000000..042039bac6 --- /dev/null +++ b/Lang/PicoLisp/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Array-concatenation b/Lang/PicoLisp/Array-concatenation new file mode 120000 index 0000000000..cc938a98a6 --- /dev/null +++ b/Lang/PicoLisp/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Associative-array-Creation b/Lang/PicoLisp/Associative-array-Creation new file mode 120000 index 0000000000..132e09f624 --- /dev/null +++ b/Lang/PicoLisp/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Associative-array-Iteration b/Lang/PicoLisp/Associative-array-Iteration new file mode 120000 index 0000000000..6fed599542 --- /dev/null +++ b/Lang/PicoLisp/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Atomic-updates b/Lang/PicoLisp/Atomic-updates new file mode 120000 index 0000000000..ba15037ed0 --- /dev/null +++ b/Lang/PicoLisp/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Averages-Arithmetic-mean b/Lang/PicoLisp/Averages-Arithmetic-mean new file mode 120000 index 0000000000..f82e95466b --- /dev/null +++ b/Lang/PicoLisp/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Averages-Mean-angle b/Lang/PicoLisp/Averages-Mean-angle new file mode 120000 index 0000000000..2e92d18eef --- /dev/null +++ b/Lang/PicoLisp/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Averages-Mean-time-of-day b/Lang/PicoLisp/Averages-Mean-time-of-day new file mode 120000 index 0000000000..9555b95333 --- /dev/null +++ b/Lang/PicoLisp/Averages-Mean-time-of-day @@ -0,0 +1 @@ +../../Task/Averages-Mean-time-of-day/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Averages-Median b/Lang/PicoLisp/Averages-Median new file mode 120000 index 0000000000..60008dd07f --- /dev/null +++ b/Lang/PicoLisp/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Averages-Pythagorean-means b/Lang/PicoLisp/Averages-Pythagorean-means new file mode 120000 index 0000000000..82c872d75e --- /dev/null +++ b/Lang/PicoLisp/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Averages-Root-mean-square b/Lang/PicoLisp/Averages-Root-mean-square new file mode 120000 index 0000000000..a9b7e4ae07 --- /dev/null +++ b/Lang/PicoLisp/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Averages-Simple-moving-average b/Lang/PicoLisp/Averages-Simple-moving-average new file mode 120000 index 0000000000..53141280f4 --- /dev/null +++ b/Lang/PicoLisp/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/PicoLisp \ No newline at end of file diff --git a/Lang/Prolog/A+B b/Lang/Prolog/A+B new file mode 120000 index 0000000000..765df9edab --- /dev/null +++ b/Lang/Prolog/A+B @@ -0,0 +1 @@ +../../Task/A+B/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Accumulator-factory b/Lang/Prolog/Accumulator-factory new file mode 120000 index 0000000000..d01cb08e8d --- /dev/null +++ b/Lang/Prolog/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Align-columns b/Lang/Prolog/Align-columns new file mode 120000 index 0000000000..28214abf30 --- /dev/null +++ b/Lang/Prolog/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Anagrams-Deranged-anagrams b/Lang/Prolog/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..030e87147b --- /dev/null +++ b/Lang/Prolog/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Animation b/Lang/Prolog/Animation new file mode 120000 index 0000000000..dd2f032186 --- /dev/null +++ b/Lang/Prolog/Animation @@ -0,0 +1 @@ +../../Task/Animation/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Anonymous-recursion b/Lang/Prolog/Anonymous-recursion new file mode 120000 index 0000000000..284cf50b71 --- /dev/null +++ b/Lang/Prolog/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Apply-a-callback-to-an-array b/Lang/Prolog/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..9e92cb19a3 --- /dev/null +++ b/Lang/Prolog/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Arithmetic-evaluation b/Lang/Prolog/Arithmetic-evaluation new file mode 120000 index 0000000000..610f08fa55 --- /dev/null +++ b/Lang/Prolog/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Array-concatenation b/Lang/Prolog/Array-concatenation new file mode 120000 index 0000000000..63d48154b5 --- /dev/null +++ b/Lang/Prolog/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Associative-array-Creation b/Lang/Prolog/Associative-array-Creation new file mode 120000 index 0000000000..8acad1a9a8 --- /dev/null +++ b/Lang/Prolog/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Averages-Median b/Lang/Prolog/Averages-Median new file mode 120000 index 0000000000..f49baf75e4 --- /dev/null +++ b/Lang/Prolog/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Prolog \ No newline at end of file diff --git a/Lang/Python/A+B b/Lang/Python/A+B new file mode 120000 index 0000000000..630f5910fc --- /dev/null +++ b/Lang/Python/A+B @@ -0,0 +1 @@ +../../Task/A+B/Python \ No newline at end of file diff --git a/Lang/Python/Abstract-type b/Lang/Python/Abstract-type new file mode 120000 index 0000000000..70ddc197b2 --- /dev/null +++ b/Lang/Python/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Python \ No newline at end of file diff --git a/Lang/Python/Accumulator-factory b/Lang/Python/Accumulator-factory new file mode 120000 index 0000000000..62d639c796 --- /dev/null +++ b/Lang/Python/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Python \ No newline at end of file diff --git a/Lang/Python/Active-Directory-Connect b/Lang/Python/Active-Directory-Connect new file mode 120000 index 0000000000..94ae6de417 --- /dev/null +++ b/Lang/Python/Active-Directory-Connect @@ -0,0 +1 @@ +../../Task/Active-Directory-Connect/Python \ No newline at end of file diff --git a/Lang/Python/Active-Directory-Search-for-a-user b/Lang/Python/Active-Directory-Search-for-a-user new file mode 120000 index 0000000000..beb8395536 --- /dev/null +++ b/Lang/Python/Active-Directory-Search-for-a-user @@ -0,0 +1 @@ +../../Task/Active-Directory-Search-for-a-user/Python \ No newline at end of file diff --git a/Lang/Python/Active-object b/Lang/Python/Active-object new file mode 120000 index 0000000000..00fe907adb --- /dev/null +++ b/Lang/Python/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/Python \ No newline at end of file diff --git a/Lang/Python/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Python/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..ba10395cfa --- /dev/null +++ b/Lang/Python/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Python \ No newline at end of file diff --git a/Lang/Python/Address-of-a-variable b/Lang/Python/Address-of-a-variable new file mode 120000 index 0000000000..f417851f0d --- /dev/null +++ b/Lang/Python/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Python \ No newline at end of file diff --git a/Lang/Python/Align-columns b/Lang/Python/Align-columns new file mode 120000 index 0000000000..721fad00ca --- /dev/null +++ b/Lang/Python/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Python \ No newline at end of file diff --git a/Lang/Python/Anagrams-Deranged-anagrams b/Lang/Python/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..0456523ddc --- /dev/null +++ b/Lang/Python/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Python \ No newline at end of file diff --git a/Lang/Python/Animation b/Lang/Python/Animation new file mode 120000 index 0000000000..ac39f54c85 --- /dev/null +++ b/Lang/Python/Animation @@ -0,0 +1 @@ +../../Task/Animation/Python \ No newline at end of file diff --git a/Lang/Python/Anonymous-recursion b/Lang/Python/Anonymous-recursion new file mode 120000 index 0000000000..7b0e9b35e9 --- /dev/null +++ b/Lang/Python/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Python \ No newline at end of file diff --git a/Lang/Python/Apply-a-callback-to-an-array b/Lang/Python/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..075fd1f329 --- /dev/null +++ b/Lang/Python/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Python \ No newline at end of file diff --git a/Lang/Python/Arbitrary-precision-integers-(included) b/Lang/Python/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..b7e3217bd5 --- /dev/null +++ b/Lang/Python/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Python \ No newline at end of file diff --git a/Lang/Python/Arithmetic-Complex b/Lang/Python/Arithmetic-Complex new file mode 120000 index 0000000000..767be7077d --- /dev/null +++ b/Lang/Python/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Python \ No newline at end of file diff --git a/Lang/Python/Arithmetic-Rational b/Lang/Python/Arithmetic-Rational new file mode 120000 index 0000000000..da59e6b036 --- /dev/null +++ b/Lang/Python/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Python \ No newline at end of file diff --git a/Lang/Python/Arithmetic-evaluation b/Lang/Python/Arithmetic-evaluation new file mode 120000 index 0000000000..cb93f47f21 --- /dev/null +++ b/Lang/Python/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Python \ No newline at end of file diff --git a/Lang/Python/Arithmetic-geometric-mean b/Lang/Python/Arithmetic-geometric-mean new file mode 120000 index 0000000000..fed74594c5 --- /dev/null +++ b/Lang/Python/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Python \ No newline at end of file diff --git a/Lang/Python/Array-concatenation b/Lang/Python/Array-concatenation new file mode 120000 index 0000000000..b8dac3c262 --- /dev/null +++ b/Lang/Python/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Python \ No newline at end of file diff --git a/Lang/Python/Associative-array-Creation b/Lang/Python/Associative-array-Creation new file mode 120000 index 0000000000..aa7a5efc29 --- /dev/null +++ b/Lang/Python/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Python \ No newline at end of file diff --git a/Lang/Python/Associative-array-Iteration b/Lang/Python/Associative-array-Iteration new file mode 120000 index 0000000000..816e0cef17 --- /dev/null +++ b/Lang/Python/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Python \ No newline at end of file diff --git a/Lang/Python/Atomic-updates b/Lang/Python/Atomic-updates new file mode 120000 index 0000000000..f5e3b9ca2c --- /dev/null +++ b/Lang/Python/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Python \ No newline at end of file diff --git a/Lang/Python/Average-loop-length b/Lang/Python/Average-loop-length new file mode 120000 index 0000000000..91ba4c7072 --- /dev/null +++ b/Lang/Python/Average-loop-length @@ -0,0 +1 @@ +../../Task/Average-loop-length/Python \ No newline at end of file diff --git a/Lang/Python/Averages-Arithmetic-mean b/Lang/Python/Averages-Arithmetic-mean new file mode 120000 index 0000000000..86c465c3ec --- /dev/null +++ b/Lang/Python/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Python \ No newline at end of file diff --git a/Lang/Python/Averages-Mean-angle b/Lang/Python/Averages-Mean-angle new file mode 120000 index 0000000000..0b846ad5d7 --- /dev/null +++ b/Lang/Python/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Python \ No newline at end of file diff --git a/Lang/Python/Averages-Mean-time-of-day b/Lang/Python/Averages-Mean-time-of-day new file mode 120000 index 0000000000..1251d7dfd6 --- /dev/null +++ b/Lang/Python/Averages-Mean-time-of-day @@ -0,0 +1 @@ +../../Task/Averages-Mean-time-of-day/Python \ No newline at end of file diff --git a/Lang/Python/Averages-Median b/Lang/Python/Averages-Median new file mode 120000 index 0000000000..31455e0828 --- /dev/null +++ b/Lang/Python/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Python \ No newline at end of file diff --git a/Lang/Python/Averages-Pythagorean-means b/Lang/Python/Averages-Pythagorean-means new file mode 120000 index 0000000000..fcc47eb3cf --- /dev/null +++ b/Lang/Python/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Python \ No newline at end of file diff --git a/Lang/Python/Averages-Root-mean-square b/Lang/Python/Averages-Root-mean-square new file mode 120000 index 0000000000..1ca6802484 --- /dev/null +++ b/Lang/Python/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Python \ No newline at end of file diff --git a/Lang/Python/Averages-Simple-moving-average b/Lang/Python/Averages-Simple-moving-average new file mode 120000 index 0000000000..392668752d --- /dev/null +++ b/Lang/Python/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Python \ No newline at end of file diff --git a/Lang/R/A+B b/Lang/R/A+B new file mode 120000 index 0000000000..e3ca776a80 --- /dev/null +++ b/Lang/R/A+B @@ -0,0 +1 @@ +../../Task/A+B/R \ No newline at end of file diff --git a/Lang/R/Accumulator-factory b/Lang/R/Accumulator-factory new file mode 120000 index 0000000000..dba68a61e7 --- /dev/null +++ b/Lang/R/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/R \ No newline at end of file diff --git a/Lang/R/Align-columns b/Lang/R/Align-columns new file mode 120000 index 0000000000..b332e7bdd8 --- /dev/null +++ b/Lang/R/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/R \ No newline at end of file diff --git a/Lang/R/Anagrams-Deranged-anagrams b/Lang/R/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..438e1b14c7 --- /dev/null +++ b/Lang/R/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/R \ No newline at end of file diff --git a/Lang/R/Animation b/Lang/R/Animation new file mode 120000 index 0000000000..6d99c1dcef --- /dev/null +++ b/Lang/R/Animation @@ -0,0 +1 @@ +../../Task/Animation/R \ No newline at end of file diff --git a/Lang/R/Anonymous-recursion b/Lang/R/Anonymous-recursion new file mode 120000 index 0000000000..0b7bc400ca --- /dev/null +++ b/Lang/R/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/R \ No newline at end of file diff --git a/Lang/R/Apply-a-callback-to-an-array b/Lang/R/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..2b8c68230d --- /dev/null +++ b/Lang/R/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/R \ No newline at end of file diff --git a/Lang/R/Arbitrary-precision-integers-(included) b/Lang/R/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..e0676cbbd9 --- /dev/null +++ b/Lang/R/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/R \ No newline at end of file diff --git a/Lang/R/Arithmetic-Complex b/Lang/R/Arithmetic-Complex new file mode 120000 index 0000000000..fd7c89e18c --- /dev/null +++ b/Lang/R/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/R \ No newline at end of file diff --git a/Lang/R/Arithmetic-geometric-mean b/Lang/R/Arithmetic-geometric-mean new file mode 120000 index 0000000000..07a953d8b1 --- /dev/null +++ b/Lang/R/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/R \ No newline at end of file diff --git a/Lang/R/Array-concatenation b/Lang/R/Array-concatenation new file mode 120000 index 0000000000..80ee1af530 --- /dev/null +++ b/Lang/R/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/R \ No newline at end of file diff --git a/Lang/R/Associative-array-Creation b/Lang/R/Associative-array-Creation new file mode 120000 index 0000000000..87c30c4fa3 --- /dev/null +++ b/Lang/R/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/R \ No newline at end of file diff --git a/Lang/R/Associative-array-Iteration b/Lang/R/Associative-array-Iteration new file mode 120000 index 0000000000..d8fe593ca1 --- /dev/null +++ b/Lang/R/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/R \ No newline at end of file diff --git a/Lang/R/Averages-Arithmetic-mean b/Lang/R/Averages-Arithmetic-mean new file mode 120000 index 0000000000..90336b20be --- /dev/null +++ b/Lang/R/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/R \ No newline at end of file diff --git a/Lang/R/Averages-Median b/Lang/R/Averages-Median new file mode 120000 index 0000000000..87e56c9d61 --- /dev/null +++ b/Lang/R/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/R \ No newline at end of file diff --git a/Lang/R/Averages-Pythagorean-means b/Lang/R/Averages-Pythagorean-means new file mode 120000 index 0000000000..16ecb8aa92 --- /dev/null +++ b/Lang/R/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/R \ No newline at end of file diff --git a/Lang/R/Averages-Root-mean-square b/Lang/R/Averages-Root-mean-square new file mode 120000 index 0000000000..744f5de58e --- /dev/null +++ b/Lang/R/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/R \ No newline at end of file diff --git a/Lang/R/Averages-Simple-moving-average b/Lang/R/Averages-Simple-moving-average new file mode 120000 index 0000000000..7d816252bc --- /dev/null +++ b/Lang/R/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/R \ No newline at end of file diff --git a/Lang/REXX/A+B b/Lang/REXX/A+B new file mode 120000 index 0000000000..b569e4fba3 --- /dev/null +++ b/Lang/REXX/A+B @@ -0,0 +1 @@ +../../Task/A+B/REXX \ No newline at end of file diff --git a/Lang/REXX/Accumulator-factory b/Lang/REXX/Accumulator-factory new file mode 120000 index 0000000000..abdc586cf5 --- /dev/null +++ b/Lang/REXX/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/REXX \ No newline at end of file diff --git a/Lang/REXX/Active-Directory-Search-for-a-user b/Lang/REXX/Active-Directory-Search-for-a-user new file mode 120000 index 0000000000..c076d1f6b8 --- /dev/null +++ b/Lang/REXX/Active-Directory-Search-for-a-user @@ -0,0 +1 @@ +../../Task/Active-Directory-Search-for-a-user/REXX \ No newline at end of file diff --git a/Lang/REXX/Address-of-a-variable b/Lang/REXX/Address-of-a-variable new file mode 120000 index 0000000000..868c01d0e1 --- /dev/null +++ b/Lang/REXX/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/REXX \ No newline at end of file diff --git a/Lang/REXX/Align-columns b/Lang/REXX/Align-columns new file mode 120000 index 0000000000..a5b289d361 --- /dev/null +++ b/Lang/REXX/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/REXX \ No newline at end of file diff --git a/Lang/REXX/Anagrams-Deranged-anagrams b/Lang/REXX/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..8401dbd4fc --- /dev/null +++ b/Lang/REXX/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/REXX \ No newline at end of file diff --git a/Lang/REXX/Anonymous-recursion b/Lang/REXX/Anonymous-recursion new file mode 120000 index 0000000000..b0a56a281a --- /dev/null +++ b/Lang/REXX/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/REXX \ No newline at end of file diff --git a/Lang/REXX/Apply-a-callback-to-an-array b/Lang/REXX/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..f2e68fb811 --- /dev/null +++ b/Lang/REXX/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/REXX \ No newline at end of file diff --git a/Lang/REXX/Arbitrary-precision-integers-(included) b/Lang/REXX/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..dd68e3d6a6 --- /dev/null +++ b/Lang/REXX/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/REXX \ No newline at end of file diff --git a/Lang/REXX/Arena-storage-pool b/Lang/REXX/Arena-storage-pool new file mode 120000 index 0000000000..044c877b63 --- /dev/null +++ b/Lang/REXX/Arena-storage-pool @@ -0,0 +1 @@ +../../Task/Arena-storage-pool/REXX \ No newline at end of file diff --git a/Lang/REXX/Arithmetic-Complex b/Lang/REXX/Arithmetic-Complex new file mode 120000 index 0000000000..bd12f82371 --- /dev/null +++ b/Lang/REXX/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/REXX \ No newline at end of file diff --git a/Lang/REXX/Arithmetic-Rational b/Lang/REXX/Arithmetic-Rational new file mode 120000 index 0000000000..391d174ba8 --- /dev/null +++ b/Lang/REXX/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/REXX \ No newline at end of file diff --git a/Lang/REXX/Arithmetic-evaluation b/Lang/REXX/Arithmetic-evaluation new file mode 120000 index 0000000000..9e3cb80e25 --- /dev/null +++ b/Lang/REXX/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/REXX \ No newline at end of file diff --git a/Lang/REXX/Arithmetic-geometric-mean b/Lang/REXX/Arithmetic-geometric-mean new file mode 120000 index 0000000000..634b2ee85c --- /dev/null +++ b/Lang/REXX/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/REXX \ No newline at end of file diff --git a/Lang/REXX/Array-concatenation b/Lang/REXX/Array-concatenation new file mode 120000 index 0000000000..78e2b1f467 --- /dev/null +++ b/Lang/REXX/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/REXX \ No newline at end of file diff --git a/Lang/REXX/Associative-array-Creation b/Lang/REXX/Associative-array-Creation new file mode 120000 index 0000000000..47c0adac48 --- /dev/null +++ b/Lang/REXX/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/REXX \ No newline at end of file diff --git a/Lang/REXX/Associative-array-Iteration b/Lang/REXX/Associative-array-Iteration new file mode 120000 index 0000000000..a1361053ad --- /dev/null +++ b/Lang/REXX/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/REXX \ No newline at end of file diff --git a/Lang/REXX/Average-loop-length b/Lang/REXX/Average-loop-length new file mode 120000 index 0000000000..c832d384f4 --- /dev/null +++ b/Lang/REXX/Average-loop-length @@ -0,0 +1 @@ +../../Task/Average-loop-length/REXX \ No newline at end of file diff --git a/Lang/REXX/Averages-Arithmetic-mean b/Lang/REXX/Averages-Arithmetic-mean new file mode 120000 index 0000000000..7d2d859146 --- /dev/null +++ b/Lang/REXX/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/REXX \ No newline at end of file diff --git a/Lang/REXX/Averages-Mean-angle b/Lang/REXX/Averages-Mean-angle new file mode 120000 index 0000000000..84345e85b9 --- /dev/null +++ b/Lang/REXX/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/REXX \ No newline at end of file diff --git a/Lang/REXX/Averages-Median b/Lang/REXX/Averages-Median new file mode 120000 index 0000000000..dbd09b0056 --- /dev/null +++ b/Lang/REXX/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/REXX \ No newline at end of file diff --git a/Lang/REXX/Averages-Pythagorean-means b/Lang/REXX/Averages-Pythagorean-means new file mode 120000 index 0000000000..426343e423 --- /dev/null +++ b/Lang/REXX/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/REXX \ No newline at end of file diff --git a/Lang/REXX/Averages-Root-mean-square b/Lang/REXX/Averages-Root-mean-square new file mode 120000 index 0000000000..b773693e16 --- /dev/null +++ b/Lang/REXX/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/REXX \ No newline at end of file diff --git a/Lang/REXX/Averages-Simple-moving-average b/Lang/REXX/Averages-Simple-moving-average new file mode 120000 index 0000000000..51c23d0f0d --- /dev/null +++ b/Lang/REXX/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/REXX \ No newline at end of file diff --git a/Lang/Racket/A+B b/Lang/Racket/A+B new file mode 120000 index 0000000000..4650d843bf --- /dev/null +++ b/Lang/Racket/A+B @@ -0,0 +1 @@ +../../Task/A+B/Racket \ No newline at end of file diff --git a/Lang/Racket/Abstract-type b/Lang/Racket/Abstract-type new file mode 120000 index 0000000000..e92c252d12 --- /dev/null +++ b/Lang/Racket/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Racket \ No newline at end of file diff --git a/Lang/Racket/Accumulator-factory b/Lang/Racket/Accumulator-factory new file mode 120000 index 0000000000..3bd54ae698 --- /dev/null +++ b/Lang/Racket/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Racket \ No newline at end of file diff --git a/Lang/Racket/Active-object b/Lang/Racket/Active-object new file mode 120000 index 0000000000..b49be0474f --- /dev/null +++ b/Lang/Racket/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/Racket \ No newline at end of file diff --git a/Lang/Racket/Address-of-a-variable b/Lang/Racket/Address-of-a-variable new file mode 120000 index 0000000000..88582de11c --- /dev/null +++ b/Lang/Racket/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Racket \ No newline at end of file diff --git a/Lang/Racket/Align-columns b/Lang/Racket/Align-columns new file mode 120000 index 0000000000..654dbb642e --- /dev/null +++ b/Lang/Racket/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Racket \ No newline at end of file diff --git a/Lang/Racket/Animation b/Lang/Racket/Animation new file mode 120000 index 0000000000..cc5069dcbf --- /dev/null +++ b/Lang/Racket/Animation @@ -0,0 +1 @@ +../../Task/Animation/Racket \ No newline at end of file diff --git a/Lang/Racket/Anonymous-recursion b/Lang/Racket/Anonymous-recursion new file mode 120000 index 0000000000..e148b7945c --- /dev/null +++ b/Lang/Racket/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Racket \ No newline at end of file diff --git a/Lang/Racket/Apply-a-callback-to-an-array b/Lang/Racket/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..8bba44b669 --- /dev/null +++ b/Lang/Racket/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Racket \ No newline at end of file diff --git a/Lang/Racket/Arbitrary-precision-integers-(included) b/Lang/Racket/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..345e5d6de9 --- /dev/null +++ b/Lang/Racket/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Racket \ No newline at end of file diff --git a/Lang/Racket/Arithmetic-Complex b/Lang/Racket/Arithmetic-Complex new file mode 120000 index 0000000000..fd0ed15adc --- /dev/null +++ b/Lang/Racket/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Racket \ No newline at end of file diff --git a/Lang/Racket/Arithmetic-geometric-mean b/Lang/Racket/Arithmetic-geometric-mean new file mode 120000 index 0000000000..24eb6e4d14 --- /dev/null +++ b/Lang/Racket/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Racket \ No newline at end of file diff --git a/Lang/Racket/Array-concatenation b/Lang/Racket/Array-concatenation new file mode 120000 index 0000000000..45ec8782c5 --- /dev/null +++ b/Lang/Racket/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Racket \ No newline at end of file diff --git a/Lang/Racket/Associative-array-Creation b/Lang/Racket/Associative-array-Creation new file mode 120000 index 0000000000..9eb259a769 --- /dev/null +++ b/Lang/Racket/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Racket \ No newline at end of file diff --git a/Lang/Racket/Associative-array-Iteration b/Lang/Racket/Associative-array-Iteration new file mode 120000 index 0000000000..7573ce5e8d --- /dev/null +++ b/Lang/Racket/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Racket \ No newline at end of file diff --git a/Lang/Racket/Averages-Arithmetic-mean b/Lang/Racket/Averages-Arithmetic-mean new file mode 120000 index 0000000000..61a64ad17e --- /dev/null +++ b/Lang/Racket/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Racket \ No newline at end of file diff --git a/Lang/Racket/Averages-Mean-angle b/Lang/Racket/Averages-Mean-angle new file mode 120000 index 0000000000..8842733109 --- /dev/null +++ b/Lang/Racket/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Racket \ No newline at end of file diff --git a/Lang/Racket/Averages-Median b/Lang/Racket/Averages-Median new file mode 120000 index 0000000000..a3fe8188cf --- /dev/null +++ b/Lang/Racket/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Racket \ No newline at end of file diff --git a/Lang/Racket/Averages-Pythagorean-means b/Lang/Racket/Averages-Pythagorean-means new file mode 120000 index 0000000000..c7fc622b05 --- /dev/null +++ b/Lang/Racket/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Racket \ No newline at end of file diff --git a/Lang/Ruby/A+B b/Lang/Ruby/A+B new file mode 120000 index 0000000000..1d3c009edb --- /dev/null +++ b/Lang/Ruby/A+B @@ -0,0 +1 @@ +../../Task/A+B/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Abstract-type b/Lang/Ruby/Abstract-type new file mode 120000 index 0000000000..e0fad8c08d --- /dev/null +++ b/Lang/Ruby/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Accumulator-factory b/Lang/Ruby/Accumulator-factory new file mode 120000 index 0000000000..ca22d9a047 --- /dev/null +++ b/Lang/Ruby/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Active-Directory-Connect b/Lang/Ruby/Active-Directory-Connect new file mode 120000 index 0000000000..fb2e06d88f --- /dev/null +++ b/Lang/Ruby/Active-Directory-Connect @@ -0,0 +1 @@ +../../Task/Active-Directory-Connect/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Active-Directory-Search-for-a-user b/Lang/Ruby/Active-Directory-Search-for-a-user new file mode 120000 index 0000000000..42dc662508 --- /dev/null +++ b/Lang/Ruby/Active-Directory-Search-for-a-user @@ -0,0 +1 @@ +../../Task/Active-Directory-Search-for-a-user/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Ruby/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..51f497219e --- /dev/null +++ b/Lang/Ruby/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Address-of-a-variable b/Lang/Ruby/Address-of-a-variable new file mode 120000 index 0000000000..abd5fa293c --- /dev/null +++ b/Lang/Ruby/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Align-columns b/Lang/Ruby/Align-columns new file mode 120000 index 0000000000..99e9fd5a76 --- /dev/null +++ b/Lang/Ruby/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Anagrams-Deranged-anagrams b/Lang/Ruby/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..750aaa8909 --- /dev/null +++ b/Lang/Ruby/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Animation b/Lang/Ruby/Animation new file mode 120000 index 0000000000..b870788de0 --- /dev/null +++ b/Lang/Ruby/Animation @@ -0,0 +1 @@ +../../Task/Animation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Anonymous-recursion b/Lang/Ruby/Anonymous-recursion new file mode 120000 index 0000000000..3434c55048 --- /dev/null +++ b/Lang/Ruby/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Apply-a-callback-to-an-array b/Lang/Ruby/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..b8aa59bd54 --- /dev/null +++ b/Lang/Ruby/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Arbitrary-precision-integers-(included) b/Lang/Ruby/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..e9718d891c --- /dev/null +++ b/Lang/Ruby/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Arithmetic-Complex b/Lang/Ruby/Arithmetic-Complex new file mode 120000 index 0000000000..a2a6e8d38a --- /dev/null +++ b/Lang/Ruby/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Arithmetic-Rational b/Lang/Ruby/Arithmetic-Rational new file mode 120000 index 0000000000..8d2c4749ac --- /dev/null +++ b/Lang/Ruby/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Arithmetic-evaluation b/Lang/Ruby/Arithmetic-evaluation new file mode 120000 index 0000000000..20f4da1897 --- /dev/null +++ b/Lang/Ruby/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Arithmetic-geometric-mean b/Lang/Ruby/Arithmetic-geometric-mean new file mode 120000 index 0000000000..f2344e7f91 --- /dev/null +++ b/Lang/Ruby/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Array-concatenation b/Lang/Ruby/Array-concatenation new file mode 120000 index 0000000000..b3b6d2dda1 --- /dev/null +++ b/Lang/Ruby/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Associative-array-Creation b/Lang/Ruby/Associative-array-Creation new file mode 120000 index 0000000000..8f728c16ff --- /dev/null +++ b/Lang/Ruby/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Associative-array-Iteration b/Lang/Ruby/Associative-array-Iteration new file mode 120000 index 0000000000..a526211aeb --- /dev/null +++ b/Lang/Ruby/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Atomic-updates b/Lang/Ruby/Atomic-updates new file mode 120000 index 0000000000..2e269e0ac4 --- /dev/null +++ b/Lang/Ruby/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Averages-Arithmetic-mean b/Lang/Ruby/Averages-Arithmetic-mean new file mode 120000 index 0000000000..3894008cad --- /dev/null +++ b/Lang/Ruby/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Averages-Mean-angle b/Lang/Ruby/Averages-Mean-angle new file mode 120000 index 0000000000..8dba807adc --- /dev/null +++ b/Lang/Ruby/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Averages-Median b/Lang/Ruby/Averages-Median new file mode 120000 index 0000000000..1cc076ff55 --- /dev/null +++ b/Lang/Ruby/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Averages-Pythagorean-means b/Lang/Ruby/Averages-Pythagorean-means new file mode 120000 index 0000000000..533c9ecf24 --- /dev/null +++ b/Lang/Ruby/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Averages-Root-mean-square b/Lang/Ruby/Averages-Root-mean-square new file mode 120000 index 0000000000..df5b9a8bb4 --- /dev/null +++ b/Lang/Ruby/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Averages-Simple-moving-average b/Lang/Ruby/Averages-Simple-moving-average new file mode 120000 index 0000000000..9b4fc76e1f --- /dev/null +++ b/Lang/Ruby/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Ruby \ No newline at end of file diff --git a/Lang/Sather/Apply-a-callback-to-an-array b/Lang/Sather/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..1bbbd602a9 --- /dev/null +++ b/Lang/Sather/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Sather \ No newline at end of file diff --git a/Lang/Sather/Arbitrary-precision-integers-(included) b/Lang/Sather/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..073407923a --- /dev/null +++ b/Lang/Sather/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Sather \ No newline at end of file diff --git a/Lang/Sather/Associative-array-Creation b/Lang/Sather/Associative-array-Creation new file mode 120000 index 0000000000..aefa403bb8 --- /dev/null +++ b/Lang/Sather/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Sather \ No newline at end of file diff --git a/Lang/Sather/Averages-Arithmetic-mean b/Lang/Sather/Averages-Arithmetic-mean new file mode 120000 index 0000000000..912c645da9 --- /dev/null +++ b/Lang/Sather/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Sather \ No newline at end of file diff --git a/Lang/Sather/Averages-Root-mean-square b/Lang/Sather/Averages-Root-mean-square new file mode 120000 index 0000000000..29383ade0d --- /dev/null +++ b/Lang/Sather/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Sather \ No newline at end of file diff --git a/Lang/Scala/A+B b/Lang/Scala/A+B new file mode 120000 index 0000000000..398bcfd173 --- /dev/null +++ b/Lang/Scala/A+B @@ -0,0 +1 @@ +../../Task/A+B/Scala \ No newline at end of file diff --git a/Lang/Scala/Abstract-type b/Lang/Scala/Abstract-type new file mode 120000 index 0000000000..d684901038 --- /dev/null +++ b/Lang/Scala/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Scala \ No newline at end of file diff --git a/Lang/Scala/Accumulator-factory b/Lang/Scala/Accumulator-factory new file mode 120000 index 0000000000..825820e0e1 --- /dev/null +++ b/Lang/Scala/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Scala \ No newline at end of file diff --git a/Lang/Scala/Active-object b/Lang/Scala/Active-object new file mode 120000 index 0000000000..89183d80e0 --- /dev/null +++ b/Lang/Scala/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/Scala \ No newline at end of file diff --git a/Lang/Scala/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Scala/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..0bcff19202 --- /dev/null +++ b/Lang/Scala/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Scala \ No newline at end of file diff --git a/Lang/Scala/Align-columns b/Lang/Scala/Align-columns new file mode 120000 index 0000000000..2757bd603c --- /dev/null +++ b/Lang/Scala/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Scala \ No newline at end of file diff --git a/Lang/Scala/Anagrams-Deranged-anagrams b/Lang/Scala/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..d9489fd618 --- /dev/null +++ b/Lang/Scala/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Scala \ No newline at end of file diff --git a/Lang/Scala/Animation b/Lang/Scala/Animation new file mode 120000 index 0000000000..8c96cd66bc --- /dev/null +++ b/Lang/Scala/Animation @@ -0,0 +1 @@ +../../Task/Animation/Scala \ No newline at end of file diff --git a/Lang/Scala/Anonymous-recursion b/Lang/Scala/Anonymous-recursion new file mode 120000 index 0000000000..73fae28df6 --- /dev/null +++ b/Lang/Scala/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Scala \ No newline at end of file diff --git a/Lang/Scala/Apply-a-callback-to-an-array b/Lang/Scala/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..d1b036383d --- /dev/null +++ b/Lang/Scala/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Scala \ No newline at end of file diff --git a/Lang/Scala/Arbitrary-precision-integers-(included) b/Lang/Scala/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..fba506188d --- /dev/null +++ b/Lang/Scala/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Scala \ No newline at end of file diff --git a/Lang/Scala/Arithmetic-Complex b/Lang/Scala/Arithmetic-Complex new file mode 120000 index 0000000000..f28d4f3fbc --- /dev/null +++ b/Lang/Scala/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Scala \ No newline at end of file diff --git a/Lang/Scala/Arithmetic-Rational b/Lang/Scala/Arithmetic-Rational new file mode 120000 index 0000000000..b2512ec845 --- /dev/null +++ b/Lang/Scala/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Scala \ No newline at end of file diff --git a/Lang/Scala/Arithmetic-evaluation b/Lang/Scala/Arithmetic-evaluation new file mode 120000 index 0000000000..0726211d38 --- /dev/null +++ b/Lang/Scala/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Scala \ No newline at end of file diff --git a/Lang/Scala/Arithmetic-geometric-mean b/Lang/Scala/Arithmetic-geometric-mean new file mode 120000 index 0000000000..7a5522759d --- /dev/null +++ b/Lang/Scala/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Scala \ No newline at end of file diff --git a/Lang/Scala/Array-concatenation b/Lang/Scala/Array-concatenation new file mode 120000 index 0000000000..f040df9360 --- /dev/null +++ b/Lang/Scala/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Scala \ No newline at end of file diff --git a/Lang/Scala/Associative-array-Creation b/Lang/Scala/Associative-array-Creation new file mode 120000 index 0000000000..6a5b07b603 --- /dev/null +++ b/Lang/Scala/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Scala \ No newline at end of file diff --git a/Lang/Scala/Associative-array-Iteration b/Lang/Scala/Associative-array-Iteration new file mode 120000 index 0000000000..31ed6b621f --- /dev/null +++ b/Lang/Scala/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Scala \ No newline at end of file diff --git a/Lang/Scala/Atomic-updates b/Lang/Scala/Atomic-updates new file mode 120000 index 0000000000..5b86281f85 --- /dev/null +++ b/Lang/Scala/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Scala \ No newline at end of file diff --git a/Lang/Scala/Averages-Arithmetic-mean b/Lang/Scala/Averages-Arithmetic-mean new file mode 120000 index 0000000000..26f0a280e6 --- /dev/null +++ b/Lang/Scala/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Scala \ No newline at end of file diff --git a/Lang/Scala/Averages-Median b/Lang/Scala/Averages-Median new file mode 120000 index 0000000000..04385b404c --- /dev/null +++ b/Lang/Scala/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Scala \ No newline at end of file diff --git a/Lang/Scala/Averages-Pythagorean-means b/Lang/Scala/Averages-Pythagorean-means new file mode 120000 index 0000000000..c4d2459c35 --- /dev/null +++ b/Lang/Scala/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Scala \ No newline at end of file diff --git a/Lang/Scala/Averages-Root-mean-square b/Lang/Scala/Averages-Root-mean-square new file mode 120000 index 0000000000..8008c8e244 --- /dev/null +++ b/Lang/Scala/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Scala \ No newline at end of file diff --git a/Lang/Scala/Averages-Simple-moving-average b/Lang/Scala/Averages-Simple-moving-average new file mode 120000 index 0000000000..30cdd8b516 --- /dev/null +++ b/Lang/Scala/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Scala \ No newline at end of file diff --git a/Lang/Scheme/A+B b/Lang/Scheme/A+B new file mode 120000 index 0000000000..ed88571cdf --- /dev/null +++ b/Lang/Scheme/A+B @@ -0,0 +1 @@ +../../Task/A+B/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Accumulator-factory b/Lang/Scheme/Accumulator-factory new file mode 120000 index 0000000000..83c00cafe1 --- /dev/null +++ b/Lang/Scheme/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Anonymous-recursion b/Lang/Scheme/Anonymous-recursion new file mode 120000 index 0000000000..13a0d5dc18 --- /dev/null +++ b/Lang/Scheme/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Apply-a-callback-to-an-array b/Lang/Scheme/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..57e50c101b --- /dev/null +++ b/Lang/Scheme/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Arbitrary-precision-integers-(included) b/Lang/Scheme/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..853ed76c0e --- /dev/null +++ b/Lang/Scheme/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Arithmetic-Complex b/Lang/Scheme/Arithmetic-Complex new file mode 120000 index 0000000000..a6aad1b3ed --- /dev/null +++ b/Lang/Scheme/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Arithmetic-Rational b/Lang/Scheme/Arithmetic-Rational new file mode 120000 index 0000000000..f2c275057d --- /dev/null +++ b/Lang/Scheme/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Array-concatenation b/Lang/Scheme/Array-concatenation new file mode 120000 index 0000000000..2ced2718d4 --- /dev/null +++ b/Lang/Scheme/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Associative-array-Creation b/Lang/Scheme/Associative-array-Creation new file mode 120000 index 0000000000..1c3e9d0e40 --- /dev/null +++ b/Lang/Scheme/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Averages-Arithmetic-mean b/Lang/Scheme/Averages-Arithmetic-mean new file mode 120000 index 0000000000..6b22243387 --- /dev/null +++ b/Lang/Scheme/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Averages-Median b/Lang/Scheme/Averages-Median new file mode 120000 index 0000000000..a28dff785a --- /dev/null +++ b/Lang/Scheme/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Averages-Pythagorean-means b/Lang/Scheme/Averages-Pythagorean-means new file mode 120000 index 0000000000..abf215cf65 --- /dev/null +++ b/Lang/Scheme/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Averages-Root-mean-square b/Lang/Scheme/Averages-Root-mean-square new file mode 120000 index 0000000000..5c956d2afe --- /dev/null +++ b/Lang/Scheme/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Averages-Simple-moving-average b/Lang/Scheme/Averages-Simple-moving-average new file mode 120000 index 0000000000..5d86a1ff1b --- /dev/null +++ b/Lang/Scheme/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Scheme \ No newline at end of file diff --git a/Lang/Smalltalk/A+B b/Lang/Smalltalk/A+B new file mode 120000 index 0000000000..47e82325b1 --- /dev/null +++ b/Lang/Smalltalk/A+B @@ -0,0 +1 @@ +../../Task/A+B/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Accumulator-factory b/Lang/Smalltalk/Accumulator-factory new file mode 120000 index 0000000000..56c1754ca2 --- /dev/null +++ b/Lang/Smalltalk/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Smalltalk/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..7b94f11c4d --- /dev/null +++ b/Lang/Smalltalk/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Address-of-a-variable b/Lang/Smalltalk/Address-of-a-variable new file mode 120000 index 0000000000..12a2b5cbb6 --- /dev/null +++ b/Lang/Smalltalk/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Apply-a-callback-to-an-array b/Lang/Smalltalk/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..5e7c4baef8 --- /dev/null +++ b/Lang/Smalltalk/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Arbitrary-precision-integers-(included) b/Lang/Smalltalk/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..78954d80d6 --- /dev/null +++ b/Lang/Smalltalk/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Arithmetic-Complex b/Lang/Smalltalk/Arithmetic-Complex new file mode 120000 index 0000000000..a4ca0f9ce5 --- /dev/null +++ b/Lang/Smalltalk/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Arithmetic-Rational b/Lang/Smalltalk/Arithmetic-Rational new file mode 120000 index 0000000000..9981405406 --- /dev/null +++ b/Lang/Smalltalk/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Array-concatenation b/Lang/Smalltalk/Array-concatenation new file mode 120000 index 0000000000..f81ae51b92 --- /dev/null +++ b/Lang/Smalltalk/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Associative-array-Creation b/Lang/Smalltalk/Associative-array-Creation new file mode 120000 index 0000000000..9b286ecfc1 --- /dev/null +++ b/Lang/Smalltalk/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Associative-array-Iteration b/Lang/Smalltalk/Associative-array-Iteration new file mode 120000 index 0000000000..bba3c89ebc --- /dev/null +++ b/Lang/Smalltalk/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Averages-Arithmetic-mean b/Lang/Smalltalk/Averages-Arithmetic-mean new file mode 120000 index 0000000000..6a800b911c --- /dev/null +++ b/Lang/Smalltalk/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Averages-Median b/Lang/Smalltalk/Averages-Median new file mode 120000 index 0000000000..036e082c82 --- /dev/null +++ b/Lang/Smalltalk/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Averages-Pythagorean-means b/Lang/Smalltalk/Averages-Pythagorean-means new file mode 120000 index 0000000000..51eb2d5cec --- /dev/null +++ b/Lang/Smalltalk/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Averages-Root-mean-square b/Lang/Smalltalk/Averages-Root-mean-square new file mode 120000 index 0000000000..6f7c1915f8 --- /dev/null +++ b/Lang/Smalltalk/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Averages-Simple-moving-average b/Lang/Smalltalk/Averages-Simple-moving-average new file mode 120000 index 0000000000..5f4f0cd7e8 --- /dev/null +++ b/Lang/Smalltalk/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Smalltalk \ No newline at end of file diff --git a/Lang/Tcl/A+B b/Lang/Tcl/A+B new file mode 120000 index 0000000000..d7f7dcf82d --- /dev/null +++ b/Lang/Tcl/A+B @@ -0,0 +1 @@ +../../Task/A+B/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Abstract-type b/Lang/Tcl/Abstract-type new file mode 120000 index 0000000000..ebf89bdc39 --- /dev/null +++ b/Lang/Tcl/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Accumulator-factory b/Lang/Tcl/Accumulator-factory new file mode 120000 index 0000000000..bc38e56a4b --- /dev/null +++ b/Lang/Tcl/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Active-Directory-Connect b/Lang/Tcl/Active-Directory-Connect new file mode 120000 index 0000000000..45fda5c6c9 --- /dev/null +++ b/Lang/Tcl/Active-Directory-Connect @@ -0,0 +1 @@ +../../Task/Active-Directory-Connect/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Active-Directory-Search-for-a-user b/Lang/Tcl/Active-Directory-Search-for-a-user new file mode 120000 index 0000000000..d4b3744cf2 --- /dev/null +++ b/Lang/Tcl/Active-Directory-Search-for-a-user @@ -0,0 +1 @@ +../../Task/Active-Directory-Search-for-a-user/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Active-object b/Lang/Tcl/Active-object new file mode 120000 index 0000000000..2f1d9eb444 --- /dev/null +++ b/Lang/Tcl/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Tcl/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..5797227331 --- /dev/null +++ b/Lang/Tcl/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Address-of-a-variable b/Lang/Tcl/Address-of-a-variable new file mode 120000 index 0000000000..d9ca151930 --- /dev/null +++ b/Lang/Tcl/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Align-columns b/Lang/Tcl/Align-columns new file mode 120000 index 0000000000..45c16545c4 --- /dev/null +++ b/Lang/Tcl/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Anagrams-Deranged-anagrams b/Lang/Tcl/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..e2e39592e7 --- /dev/null +++ b/Lang/Tcl/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Animation b/Lang/Tcl/Animation new file mode 120000 index 0000000000..eb3901df09 --- /dev/null +++ b/Lang/Tcl/Animation @@ -0,0 +1 @@ +../../Task/Animation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Anonymous-recursion b/Lang/Tcl/Anonymous-recursion new file mode 120000 index 0000000000..48358be646 --- /dev/null +++ b/Lang/Tcl/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Apply-a-callback-to-an-array b/Lang/Tcl/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..632c3e9d15 --- /dev/null +++ b/Lang/Tcl/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Arbitrary-precision-integers-(included) b/Lang/Tcl/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..5c3b5394f3 --- /dev/null +++ b/Lang/Tcl/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Arena-storage-pool b/Lang/Tcl/Arena-storage-pool new file mode 120000 index 0000000000..b3909c2d19 --- /dev/null +++ b/Lang/Tcl/Arena-storage-pool @@ -0,0 +1 @@ +../../Task/Arena-storage-pool/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Arithmetic-Complex b/Lang/Tcl/Arithmetic-Complex new file mode 120000 index 0000000000..b8c8494818 --- /dev/null +++ b/Lang/Tcl/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Arithmetic-evaluation b/Lang/Tcl/Arithmetic-evaluation new file mode 120000 index 0000000000..aff9963f40 --- /dev/null +++ b/Lang/Tcl/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Arithmetic-geometric-mean b/Lang/Tcl/Arithmetic-geometric-mean new file mode 120000 index 0000000000..12e90692c2 --- /dev/null +++ b/Lang/Tcl/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Array-concatenation b/Lang/Tcl/Array-concatenation new file mode 120000 index 0000000000..59e41d7837 --- /dev/null +++ b/Lang/Tcl/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Associative-array-Creation b/Lang/Tcl/Associative-array-Creation new file mode 120000 index 0000000000..8687031234 --- /dev/null +++ b/Lang/Tcl/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Associative-array-Iteration b/Lang/Tcl/Associative-array-Iteration new file mode 120000 index 0000000000..80ae4c0123 --- /dev/null +++ b/Lang/Tcl/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Atomic-updates b/Lang/Tcl/Atomic-updates new file mode 120000 index 0000000000..f8cd30ea74 --- /dev/null +++ b/Lang/Tcl/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Average-loop-length b/Lang/Tcl/Average-loop-length new file mode 120000 index 0000000000..16e686c5da --- /dev/null +++ b/Lang/Tcl/Average-loop-length @@ -0,0 +1 @@ +../../Task/Average-loop-length/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Averages-Arithmetic-mean b/Lang/Tcl/Averages-Arithmetic-mean new file mode 120000 index 0000000000..955443d90f --- /dev/null +++ b/Lang/Tcl/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Averages-Mean-angle b/Lang/Tcl/Averages-Mean-angle new file mode 120000 index 0000000000..b964d6fa91 --- /dev/null +++ b/Lang/Tcl/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Averages-Mean-time-of-day b/Lang/Tcl/Averages-Mean-time-of-day new file mode 120000 index 0000000000..18112ae0e8 --- /dev/null +++ b/Lang/Tcl/Averages-Mean-time-of-day @@ -0,0 +1 @@ +../../Task/Averages-Mean-time-of-day/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Averages-Median b/Lang/Tcl/Averages-Median new file mode 120000 index 0000000000..729b4325ef --- /dev/null +++ b/Lang/Tcl/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Averages-Pythagorean-means b/Lang/Tcl/Averages-Pythagorean-means new file mode 120000 index 0000000000..0a7b08cdd0 --- /dev/null +++ b/Lang/Tcl/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Averages-Root-mean-square b/Lang/Tcl/Averages-Root-mean-square new file mode 120000 index 0000000000..878a537989 --- /dev/null +++ b/Lang/Tcl/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Averages-Simple-moving-average b/Lang/Tcl/Averages-Simple-moving-average new file mode 120000 index 0000000000..4f926ca7f8 --- /dev/null +++ b/Lang/Tcl/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Tcl \ No newline at end of file diff --git a/Meta/00Tasks.yaml b/Meta/00Tasks.yaml index 3cc58f06fc..c432ca2484 100644 --- a/Meta/00Tasks.yaml +++ b/Meta/00Tasks.yaml @@ -11,14 +11,94 @@ name: 99 Bottles of Beer path: 99-Bottles-of-Beer url: 99_Bottles_of_Beer +A+B: + name: A+B + path: A+B + url: A+B +Abstract type: + name: Abstract type + path: Abstract-type + url: Abstract_type +Accumulator factory: + name: Accumulator factory + path: Accumulator-factory + url: Accumulator_factory Ackermann function: name: Ackermann function path: Ackermann-function url: Ackermann_function +Active Directory/Connect: + name: Active Directory/Connect + path: Active-Directory-Connect + url: Active_Directory/Connect +Active Directory/Search for a user: + name: Active Directory/Search for a user + path: Active-Directory-Search-for-a-user + url: Active_Directory/Search_for_a_user +Active object: + name: Active object + path: Active-object + url: Active_object +Add a variable to a class instance at runtime: + name: Add a variable to a class instance at runtime + path: Add-a-variable-to-a-class-instance-at-runtime + url: Add_a_variable_to_a_class_instance_at_runtime +Address of a variable: + name: Address of a variable + path: Address-of-a-variable + url: Address_of_a_variable +Align columns: + name: Align columns + path: Align-columns + url: Align_columns Anagrams: name: Anagrams path: Anagrams url: Anagrams +Anagrams/Deranged anagrams: + name: Anagrams/Deranged anagrams + path: Anagrams-Deranged-anagrams + url: Anagrams/Deranged_anagrams +Animation: + name: Animation + path: Animation + url: Animation +Anonymous recursion: + name: Anonymous recursion + path: Anonymous-recursion + url: Anonymous_recursion +Apply a callback to an array: + name: Apply a callback to an array + path: Apply-a-callback-to-an-array + url: Apply_a_callback_to_an_array +Arbitrary-precision integers (included): + name: Arbitrary-precision integers (included) + path: Arbitrary-precision-integers-(included) + url: Arbitrary-precision_integers_(included) +Arena storage pool: + name: Arena storage pool + path: Arena-storage-pool + url: Arena_storage_pool +Arithmetic evaluation: + name: Arithmetic evaluation + path: Arithmetic-evaluation + url: Arithmetic_evaluation +Arithmetic-geometric mean: + name: Arithmetic-geometric mean + path: Arithmetic-geometric-mean + url: Arithmetic-geometric_mean +Arithmetic/Complex: + name: Arithmetic/Complex + path: Arithmetic-Complex + url: Arithmetic/Complex +Arithmetic/Rational: + name: Arithmetic/Rational + path: Arithmetic-Rational + url: Arithmetic/Rational +Array concatenation: + name: Array concatenation + path: Array-concatenation + url: Array_concatenation Arrays: name: Arrays path: Arrays @@ -27,6 +107,50 @@ Assertions: name: Assertions path: Assertions url: Assertions +Associative array/Creation: + name: Associative array/Creation + path: Associative-array-Creation + url: Associative_array/Creation +Associative array/Iteration: + name: Associative array/Iteration + path: Associative-array-Iteration + url: Associative_array/Iteration +Atomic updates: + name: Atomic updates + path: Atomic-updates + url: Atomic_updates +Average loop length: + name: Average loop length + path: Average-loop-length + url: Average_loop_length +Averages/Arithmetic mean: + name: Averages/Arithmetic mean + path: Averages-Arithmetic-mean + url: Averages/Arithmetic_mean +Averages/Mean angle: + name: Averages/Mean angle + path: Averages-Mean-angle + url: Averages/Mean_angle +Averages/Mean time of day: + name: Averages/Mean time of day + path: Averages-Mean-time-of-day + url: Averages/Mean_time_of_day +Averages/Median: + name: Averages/Median + path: Averages-Median + url: Averages/Median +Averages/Pythagorean means: + name: Averages/Pythagorean means + path: Averages-Pythagorean-means + url: Averages/Pythagorean_means +Averages/Root mean square: + name: Averages/Root mean square + path: Averages-Root-mean-square + url: Averages/Root_mean_square +Averages/Simple moving average: + name: Averages/Simple moving average + path: Averages-Simple-moving-average + url: Averages/Simple_moving_average Balanced brackets: name: Balanced brackets path: Balanced-brackets diff --git a/Task/A+B/0815/a+b.0815 b/Task/A+B/0815/a+b.0815 new file mode 100644 index 0000000000..895c17864e --- /dev/null +++ b/Task/A+B/0815/a+b.0815 @@ -0,0 +1 @@ +|x|+% diff --git a/Task/A+B/0DESCRIPTION b/Task/A+B/0DESCRIPTION new file mode 100644 index 0000000000..704ca6dc95 --- /dev/null +++ b/Task/A+B/0DESCRIPTION @@ -0,0 +1,23 @@ +'''A+B''' - in programming contests, classic problem, which is given so contestants can gain familiarity with online judging system being used. + +'''Problem statement'''
+Given 2 integer numbers, A and B. One needs to find their sum. + +:'''Input data'''
+:Two integer numbers are written in the input stream, separated by space. +:(-1000 \le A,B \le +1000) + +:'''Output data'''
+:The required output is one integer: the sum of A and B. + +:'''Example:'''
+::{|class="standard" + ! Input + ! Output + |- + |2 2 + |4 + |- + |3 2 + |5 + |} diff --git a/Task/A+B/ABAP/a+b.abap b/Task/A+B/ABAP/a+b.abap new file mode 100644 index 0000000000..0cb470aac6 --- /dev/null +++ b/Task/A+B/ABAP/a+b.abap @@ -0,0 +1,15 @@ +report z_sum_a_b. +data: lv_output type i. +selection-screen begin of block input. + parameters: + p_first type i, + p_second type i. +selection-screen end of block input. + +at selection-screen output. + %_p_first_%_app_%-text = 'First Number: '. + %_p_second_%_app_%-text = 'Second Number: '. + +start-of-selection. + lv_output = p_first + p_second. + write : / lv_output. diff --git a/Task/A+B/ALGOL-68/a+b-1.alg b/Task/A+B/ALGOL-68/a+b-1.alg new file mode 100644 index 0000000000..87836c1801 --- /dev/null +++ b/Task/A+B/ALGOL-68/a+b-1.alg @@ -0,0 +1 @@ +print((read int + read int)) diff --git a/Task/A+B/ALGOL-68/a+b-2.alg b/Task/A+B/ALGOL-68/a+b-2.alg new file mode 100644 index 0000000000..0b027a7a1d --- /dev/null +++ b/Task/A+B/ALGOL-68/a+b-2.alg @@ -0,0 +1,3 @@ +open(stand in, "input.txt", stand in channel); +open(stand out, "output.txt", stand out channel); +print((read int + read int)) diff --git a/Task/A+B/ANTLR/a+b.antlr b/Task/A+B/ANTLR/a+b.antlr new file mode 100644 index 0000000000..aaebb7623e --- /dev/null +++ b/Task/A+B/ANTLR/a+b.antlr @@ -0,0 +1,14 @@ +grammar aplusb ; + +options { + language = Java; +} + +aplusb : (WS* e1=Num WS+ e2=Num NEWLINE {System.out.println($e1.text + " + " + $e2.text + " = " + (Integer.parseInt($e1.text) + Integer.parseInt($e2.text)));})+ + ; +Num : '-'?('0'..'9')+ + ; +WS : (' ' | '\t') + ; +NEWLINE : WS* '\r'? '\n' + ; diff --git a/Task/A+B/AWK/a+b.awk b/Task/A+B/AWK/a+b.awk new file mode 100644 index 0000000000..f00ab8d02f --- /dev/null +++ b/Task/A+B/AWK/a+b.awk @@ -0,0 +1 @@ +{print $1 + $2} diff --git a/Task/A+B/Ada/a+b-1.ada b/Task/A+B/Ada/a+b-1.ada new file mode 100644 index 0000000000..e3b3a1d3b7 --- /dev/null +++ b/Task/A+B/Ada/a+b-1.ada @@ -0,0 +1,10 @@ +-- Standard I/O Streams + +with Ada.Integer_Text_Io; +procedure APlusB is + A, B : Integer; +begin + Ada.Integer_Text_Io.Get (Item => A); + Ada.Integer_Text_Io.Get (Item => B); + Ada.Integer_Text_Io.Put (A+B); +end APlusB; diff --git a/Task/A+B/Ada/a+b-2.ada b/Task/A+B/Ada/a+b-2.ada new file mode 100644 index 0000000000..b38ce0b316 --- /dev/null +++ b/Task/A+B/Ada/a+b-2.ada @@ -0,0 +1,12 @@ +with Ada.Text_IO; + +procedure A_Plus_B is + type Small_Integers is range -2_000 .. +2_000; + subtype Input_Values is Small_Integers range -1_000 .. +1_000; + package IO is new Ada.Text_IO.Integer_IO (Num => Small_Integers); + A, B : Input_Values; +begin + IO.Get (A); + IO.Get (B); + IO.Put (A + B, Width => 4, Base => 10); +end A_Plus_B; diff --git a/Task/A+B/Argile/a+b-1.argile b/Task/A+B/Argile/a+b-1.argile new file mode 100644 index 0000000000..846c763d8c --- /dev/null +++ b/Task/A+B/Argile/a+b-1.argile @@ -0,0 +1,4 @@ +(: Standard input-output streams :) +use std, array +Cfunc scanf "%d%d" (&val int a) (&val int b) +printf "%d\n" (a + b) diff --git a/Task/A+B/Argile/a+b-2.argile b/Task/A+B/Argile/a+b-2.argile new file mode 100644 index 0000000000..32fb59abea --- /dev/null +++ b/Task/A+B/Argile/a+b-2.argile @@ -0,0 +1,10 @@ +(: Input file : input.txt :) +(: Output file: output.txt :) +use std, array +let in = fopen "input.txt" "r" +let out = fopen "output.txt" "w" +let int x, y. +Cfunc fscanf in "%d%d" (&x) (&y) (:fscanf not yet defined in std.arg:) +fprintf out "%d\n" (x+y) +fclose in +fclose out diff --git a/Task/A+B/AutoHotkey/a+b.ahk b/Task/A+B/AutoHotkey/a+b.ahk new file mode 100644 index 0000000000..c0a57b6ed2 --- /dev/null +++ b/Task/A+B/AutoHotkey/a+b.ahk @@ -0,0 +1,3 @@ +InputBox, input , A+B, Two integer numbers`, separated by space. +StringSplit, output, input, %A_Space% +msgbox, % output1 . "+" . output2 "=" output1+output2 diff --git a/Task/A+B/AutoIt/a+b.autoit b/Task/A+B/AutoIt/a+b.autoit new file mode 100644 index 0000000000..120e568c0a --- /dev/null +++ b/Task/A+B/AutoIt/a+b.autoit @@ -0,0 +1,7 @@ +;AutoIt Version: 3.2.10.0 +$num = "45 54" +consolewrite ("Sum of " & $num & " is: " & sum($num)) +Func sum($numbers) + $numm = StringSplit($numbers," ") + Return $numm[1]+$numm[$numm[0]] +EndFunc diff --git a/Task/A+B/BASIC/a+b.bas b/Task/A+B/BASIC/a+b.bas new file mode 100644 index 0000000000..78fb4b4926 --- /dev/null +++ b/Task/A+B/BASIC/a+b.bas @@ -0,0 +1,16 @@ +DEFINT A-Z + +tryagain: +backhere = CSRLIN +INPUT "", i$ +i$ = LTRIM$(RTRIM$(i$)) +where = INSTR(i$, " ") +IF where THEN + a = VAL(LEFT$(i$, where - 1)) + b = VAL(MID$(i$, where + 1)) + c = a + b + LOCATE backhere, LEN(i$) + 1 + PRINT c +ELSE + GOTO tryagain +END IF diff --git a/Task/A+B/Befunge/a+b.bf b/Task/A+B/Befunge/a+b.bf new file mode 100644 index 0000000000..4db44e3076 --- /dev/null +++ b/Task/A+B/Befunge/a+b.bf @@ -0,0 +1 @@ +&&+.@ diff --git a/Task/A+B/C/a+b-1.c b/Task/A+B/C/a+b-1.c new file mode 100644 index 0000000000..b5e0778b0f --- /dev/null +++ b/Task/A+B/C/a+b-1.c @@ -0,0 +1,9 @@ +// Standard input-output streams +#include +int main() +{ + int a, b; + scanf("%d%d", &a, &b); + printf("%d\n", a + b); + return 0; +} diff --git a/Task/A+B/C/a+b-2.c b/Task/A+B/C/a+b-2.c new file mode 100644 index 0000000000..d64c0c6a86 --- /dev/null +++ b/Task/A+B/C/a+b-2.c @@ -0,0 +1,12 @@ +// Input file: input.txt +// Output file: output.txt +#include +int main() +{ + freopen("input.txt", "rt", stdin); + freopen("output.txt", "wt", stdout); + int a, b; + scanf("%d%d", &a, &b); + printf("%d\n", a + b); + return 0; +} diff --git a/Task/A+B/Clojure/a+b-1.clj b/Task/A+B/Clojure/a+b-1.clj new file mode 100644 index 0000000000..eef9a283fa --- /dev/null +++ b/Task/A+B/Clojure/a+b-1.clj @@ -0,0 +1,4 @@ +(println (+ (Integer/parseInt (read-line)) (Integer/parseInt (read-line)))) +3 +4 +=>7 diff --git a/Task/A+B/Clojure/a+b-2.clj b/Task/A+B/Clojure/a+b-2.clj new file mode 100644 index 0000000000..4506d67da3 --- /dev/null +++ b/Task/A+B/Clojure/a+b-2.clj @@ -0,0 +1,3 @@ +(eval (read-string (str "(+ " (read-line) " )") )) +3 3 +6 diff --git a/Task/A+B/CoffeeScript/a+b.coffee b/Task/A+B/CoffeeScript/a+b.coffee new file mode 100644 index 0000000000..6a5ab62a7c --- /dev/null +++ b/Task/A+B/CoffeeScript/a+b.coffee @@ -0,0 +1,14 @@ + + + + +
+
+ + diff --git a/Task/A+B/Eiffel/a+b.e b/Task/A+B/Eiffel/a+b.e new file mode 100644 index 0000000000..ea642b3080 --- /dev/null +++ b/Task/A+B/Eiffel/a+b.e @@ -0,0 +1,13 @@ +class + APPLICATION +inherit + ARGUMENTS +create + make +feature {NONE} -- Initialization + make + -- Run application. + do + print(argument(1).to_integer + argument(2).to_integer) + end +end diff --git a/Task/A+B/Erlang/a+b.erl b/Task/A+B/Erlang/a+b.erl new file mode 100644 index 0000000000..7e68611ca7 --- /dev/null +++ b/Task/A+B/Erlang/a+b.erl @@ -0,0 +1,10 @@ +-module(aplusb). +-export([start/0]). + +start() -> + case io:fread("","~d~d") of + eof -> ok; + {ok, [A,B]} -> + io:format("~w~n",[A+B]), + start() + end. diff --git a/Task/A+B/Forth/a+b.fth b/Task/A+B/Forth/a+b.fth new file mode 100644 index 0000000000..eb4fd11822 --- /dev/null +++ b/Task/A+B/Forth/a+b.fth @@ -0,0 +1 @@ +pad dup 80 accept evaluate + . diff --git a/Task/A+B/Fortran/a+b.f b/Task/A+B/Fortran/a+b.f new file mode 100644 index 0000000000..d4cf0c2c61 --- /dev/null +++ b/Task/A+B/Fortran/a+b.f @@ -0,0 +1,10 @@ +program a_plus_b + + implicit none + integer :: a + integer :: b + + read (*, *) a, b + write (*, '(i0)') a + b + +end program a_plus_b diff --git a/Task/A+B/Go/a+b.go b/Task/A+B/Go/a+b.go new file mode 100644 index 0000000000..64511a0712 --- /dev/null +++ b/Task/A+B/Go/a+b.go @@ -0,0 +1,9 @@ +package main + +import "fmt" + +func main() { + var a, b int + fmt.Scanf("%d %d", &a, &b) + fmt.Printf("%d\n", a+b) +} diff --git a/Task/A+B/Haskell/a+b.hs b/Task/A+B/Haskell/a+b.hs new file mode 100644 index 0000000000..e6a8348f58 --- /dev/null +++ b/Task/A+B/Haskell/a+b.hs @@ -0,0 +1 @@ +main = getLine >>= print . sum . map read . words diff --git a/Task/A+B/Java/a+b-1.java b/Task/A+B/Java/a+b-1.java new file mode 100644 index 0000000000..61762511c2 --- /dev/null +++ b/Task/A+B/Java/a+b-1.java @@ -0,0 +1,8 @@ +import java.util.*; + +public class Sum2 { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); // Standard input + System.out.println(in.nextInt() + in.nextInt()); // Standard output + } +} diff --git a/Task/A+B/Java/a+b-2.java b/Task/A+B/Java/a+b-2.java new file mode 100644 index 0000000000..c59ec4a2ae --- /dev/null +++ b/Task/A+B/Java/a+b-2.java @@ -0,0 +1,27 @@ +import java.io.*; +import java.util.*; + +public class SumDif { + StreamTokenizer in; + PrintWriter out; + + public static void main(String[] args) throws IOException { + new SumDif().run(); + } + + private int nextInt() throws IOException { + in.nextToken(); + return (int)in.nval; + } + + public void run() throws IOException { + in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); // Standard input + out = new PrintWriter(new OutputStreamWriter(System.out)); // Standard output + solve(); + out.flush(); + } + + private void solve() throws IOException { + out.println(nextInt() + nextInt()); + } +} diff --git a/Task/A+B/Java/a+b-3.java b/Task/A+B/Java/a+b-3.java new file mode 100644 index 0000000000..546ca2d56f --- /dev/null +++ b/Task/A+B/Java/a+b-3.java @@ -0,0 +1,19 @@ +import java.io.*; + +public class AplusB { + public static void main(String[] args) { + try { + StreamTokenizer in = new StreamTokenizer(new FileReader("input.txt")); + in.nextToken(); + int a = (int) in.nval; + in.nextToken(); + int b = (int) in.nval; + FileWriter outFile = new FileWriter("output.txt"); + outFile.write(Integer.toString(a + b)); + outFile.close(); + } + catch (IOException e) { + System.out.println("IO error"); + } + } +} diff --git a/Task/A+B/JavaScript/a+b-1.js b/Task/A+B/JavaScript/a+b-1.js new file mode 100644 index 0000000000..3bd360326a --- /dev/null +++ b/Task/A+B/JavaScript/a+b-1.js @@ -0,0 +1,14 @@ + + +
+
+ + + diff --git a/Task/A+B/JavaScript/a+b-2.js b/Task/A+B/JavaScript/a+b-2.js new file mode 100644 index 0000000000..5003b51b91 --- /dev/null +++ b/Task/A+B/JavaScript/a+b-2.js @@ -0,0 +1,10 @@ +process.openStdin().on ( + 'data', + function (line) { + var xs = String(line).match(/^\s*(\d+)\s+(\d+)\s*/) + console.log ( + xs ? Number(xs[1]) + Number(xs[2]) : 'usage: ' + ) + process.exit() + } +) diff --git a/Task/A+B/Lua/a+b.lua b/Task/A+B/Lua/a+b.lua new file mode 100644 index 0000000000..af37534f27 --- /dev/null +++ b/Task/A+B/Lua/a+b.lua @@ -0,0 +1,2 @@ +a,b = io.read("*number", "*number") +print(a+b) diff --git a/Task/A+B/PHP/a+b-1.php b/Task/A+B/PHP/a+b-1.php new file mode 100644 index 0000000000..4548649db4 --- /dev/null +++ b/Task/A+B/PHP/a+b-1.php @@ -0,0 +1,2 @@ +fscanf(STDIN, "%d %d\n", $a, $b); //Reads 2 numbers from STDIN +echo ($a + $b) . "\n"; diff --git a/Task/A+B/PHP/a+b-2.php b/Task/A+B/PHP/a+b-2.php new file mode 100644 index 0000000000..9c2f580986 --- /dev/null +++ b/Task/A+B/PHP/a+b-2.php @@ -0,0 +1,7 @@ +$in = fopen("input.dat", "r"); +fscanf($in, "%d %d\n", $a, $b); //Reads 2 numbers from file $in +fclose($in); + +$out = fopen("output.dat", "w"); +fwrite($out, ($a + $b) . "\n"); +fclose($out); diff --git a/Task/A+B/Perl/a+b.pl b/Task/A+B/Perl/a+b.pl new file mode 100644 index 0000000000..86f4e16943 --- /dev/null +++ b/Task/A+B/Perl/a+b.pl @@ -0,0 +1,2 @@ +my ($a,$b) = split(/\D+/,); +print "$a $b " . ($a + $b) . "\n"; diff --git a/Task/A+B/PicoLisp/a+b.l b/Task/A+B/PicoLisp/a+b.l new file mode 100644 index 0000000000..93b5054f2a --- /dev/null +++ b/Task/A+B/PicoLisp/a+b.l @@ -0,0 +1,3 @@ +(+ (read) (read)) +3 4 +-> 7 diff --git a/Task/A+B/Prolog/a+b-1.pro b/Task/A+B/Prolog/a+b-1.pro new file mode 100644 index 0000000000..a0612f82fd --- /dev/null +++ b/Task/A+B/Prolog/a+b-1.pro @@ -0,0 +1,7 @@ +plus :- + read_line_to_codes(user_input,X), + atom_codes(A, X), + atomic_list_concat(L, ' ', A), + maplist(atom_number, L, LN), + sumlist(LN, N), + write(N). diff --git a/Task/A+B/Prolog/a+b-2.pro b/Task/A+B/Prolog/a+b-2.pro new file mode 100644 index 0000000000..6f0acf7706 --- /dev/null +++ b/Task/A+B/Prolog/a+b-2.pro @@ -0,0 +1,4 @@ +?- plus. +|: 4 5 +9 +true. diff --git a/Task/A+B/Python/a+b-1.py b/Task/A+B/Python/a+b-1.py new file mode 100644 index 0000000000..db1a94e67a --- /dev/null +++ b/Task/A+B/Python/a+b-1.py @@ -0,0 +1,4 @@ +try: raw_input +except: raw_input = input + +print(sum(int(x) for x in raw_input().split())) diff --git a/Task/A+B/Python/a+b-2.py b/Task/A+B/Python/a+b-2.py new file mode 100644 index 0000000000..b30c99664a --- /dev/null +++ b/Task/A+B/Python/a+b-2.py @@ -0,0 +1,4 @@ +a = int(raw_input("Enter integer 1: ")) +b = int(raw_input("Enter integer 2: ")) + +print a + b diff --git a/Task/A+B/R/a+b.r b/Task/A+B/R/a+b.r new file mode 100644 index 0000000000..cfe661c41d --- /dev/null +++ b/Task/A+B/R/a+b.r @@ -0,0 +1 @@ +sum(scan("", numeric(0), 2)) diff --git a/Task/A+B/REXX/a+b-1.rexx b/Task/A+B/REXX/a+b-1.rexx new file mode 100644 index 0000000000..dbc7c1e614 --- /dev/null +++ b/Task/A+B/REXX/a+b-1.rexx @@ -0,0 +1,2 @@ +parse pull a b +say a+b diff --git a/Task/A+B/REXX/a+b-2.rexx b/Task/A+B/REXX/a+b-2.rexx new file mode 100644 index 0000000000..5c6592790f --- /dev/null +++ b/Task/A+B/REXX/a+b-2.rexx @@ -0,0 +1,2 @@ +parse pull a b +say (a+b)/1 /*dividing by 1 normalizes the REXX number.*/ diff --git a/Task/A+B/REXX/a+b-3.rexx b/Task/A+B/REXX/a+b-3.rexx new file mode 100644 index 0000000000..2104c6391a --- /dev/null +++ b/Task/A+B/REXX/a+b-3.rexx @@ -0,0 +1,4 @@ +numeric digits 300 +parse pull a b +z=(a+b)/1 +say z diff --git a/Task/A+B/REXX/a+b-4.rexx b/Task/A+B/REXX/a+b-4.rexx new file mode 100644 index 0000000000..99c303ec95 --- /dev/null +++ b/Task/A+B/REXX/a+b-4.rexx @@ -0,0 +1,9 @@ +numeric digits 1000 /*just in case the user gets ka-razy. */ +say 'enter some numbers to be summed:' +parse pull y +many=words(y) +sum=0 + do j=1 for many + sum=sum+word(y,j) + end +say 'sum of' many "numbers = " sum/1 diff --git a/Task/A+B/Racket/a+b-1.rkt b/Task/A+B/Racket/a+b-1.rkt new file mode 100644 index 0000000000..7ecae0ec3e --- /dev/null +++ b/Task/A+B/Racket/a+b-1.rkt @@ -0,0 +1,2 @@ +#lang racket +(+ (read) (read)) diff --git a/Task/A+B/Racket/a+b-2.rkt b/Task/A+B/Racket/a+b-2.rkt new file mode 100644 index 0000000000..884f42bf7d --- /dev/null +++ b/Task/A+B/Racket/a+b-2.rkt @@ -0,0 +1,6 @@ +#lang racket +(define a (read)) +(unless (number? a) (error 'a+b "number" a)) +(define b (read)) +(unless (number? b) (error 'a+b "number" b)) +(displayln (+ a b)) diff --git a/Task/A+B/Ruby/a+b-1.rb b/Task/A+B/Ruby/a+b-1.rb new file mode 100644 index 0000000000..019307f1ca --- /dev/null +++ b/Task/A+B/Ruby/a+b-1.rb @@ -0,0 +1 @@ +puts gets.split.map{|x| x.to_i}.inject{|sum, x| sum + x} diff --git a/Task/A+B/Ruby/a+b-2.rb b/Task/A+B/Ruby/a+b-2.rb new file mode 100644 index 0000000000..afdd82e3f8 --- /dev/null +++ b/Task/A+B/Ruby/a+b-2.rb @@ -0,0 +1 @@ +puts gets.split.map(&:to_i).inject(&:+) diff --git a/Task/A+B/Scala/a+b.scala b/Task/A+B/Scala/a+b.scala new file mode 100644 index 0000000000..b089a95983 --- /dev/null +++ b/Task/A+B/Scala/a+b.scala @@ -0,0 +1 @@ +println(readLine() split " " take 2 map (_.toInt) sum) diff --git a/Task/A+B/Scheme/a+b.ss b/Task/A+B/Scheme/a+b.ss new file mode 100644 index 0000000000..3c80727a5a --- /dev/null +++ b/Task/A+B/Scheme/a+b.ss @@ -0,0 +1,3 @@ +(let* ((x (read)) + (y (read))) + (write (+ x y))) diff --git a/Task/A+B/Smalltalk/a+b-1.st b/Task/A+B/Smalltalk/a+b-1.st new file mode 100644 index 0000000000..aee4762526 --- /dev/null +++ b/Task/A+B/Smalltalk/a+b-1.st @@ -0,0 +1,30 @@ +'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 8 August 2011 at 3:50:55 pm'! +Object subclass: #ABTask + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'rosettacode'! + +"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! + +ABTask class + instanceVariableNames: ''! + +!ABTask class methodsFor: 'demo'! +parseInteger: inputStream + ^ Integer readFrom: inputStream skipSeparators! ! + +!ABTask class methodsFor: 'demo'! +sum: inputStream + ^ (self parseInteger: inputStream) + + (self parseInteger: inputStream)! ! + +!ABTask class methodsFor: 'demo'! +test2Plus2 + ^ self + sum: (ReadStream on: '2 2')! ! + +!ABTask class methodsFor: 'demo'! +test3Plus2 + ^ self + sum: (ReadStream on: '3 2')! ! diff --git a/Task/A+B/Smalltalk/a+b-2.st b/Task/A+B/Smalltalk/a+b-2.st new file mode 100644 index 0000000000..05cb728013 --- /dev/null +++ b/Task/A+B/Smalltalk/a+b-2.st @@ -0,0 +1,19 @@ +|task| +task := [:inStream :outStream | + |processLine| + + processLine := + [ + |a b| + a := Integer readFrom: inStream. + b := Integer readFrom: inStream. + "is validation part of the task?" + self assert:( a between:-1000 and: 1000). + self assert:( b between:-1000 and: 1000). + outStream print (a+b); cr. + ]. + + [ inStream atEnd ] whileFalse:processLine. +]. + +task value: ( 'dataIn.txt' asFilename readStream) value:Transcript. diff --git a/Task/A+B/Smalltalk/a+b-3.st b/Task/A+B/Smalltalk/a+b-3.st new file mode 100644 index 0000000000..1468a1acc7 --- /dev/null +++ b/Task/A+B/Smalltalk/a+b-3.st @@ -0,0 +1 @@ +task value: Stdin value: Stdout. diff --git a/Task/A+B/Tcl/a+b-1.tcl b/Task/A+B/Tcl/a+b-1.tcl new file mode 100644 index 0000000000..a960179132 --- /dev/null +++ b/Task/A+B/Tcl/a+b-1.tcl @@ -0,0 +1,2 @@ +scan [gets stdin] "%d %d" x y +puts [expr {$x + $y}] diff --git a/Task/A+B/Tcl/a+b-2.tcl b/Task/A+B/Tcl/a+b-2.tcl new file mode 100644 index 0000000000..895125c5ea --- /dev/null +++ b/Task/A+B/Tcl/a+b-2.tcl @@ -0,0 +1 @@ +puts [tcl::mathop::+ {*}[gets stdin]] diff --git a/Task/A+B/Tcl/a+b-3.tcl b/Task/A+B/Tcl/a+b-3.tcl new file mode 100644 index 0000000000..34f1ec01b2 --- /dev/null +++ b/Task/A+B/Tcl/a+b-3.tcl @@ -0,0 +1,6 @@ +set in [open "input.txt"] +set out [open "output.txt" w] +scan [gets $in] "%d %d" x y +puts $out [expr {$x + $y}] +close $in +close $out diff --git a/Task/Abstract-type/0DESCRIPTION b/Task/Abstract-type/0DESCRIPTION new file mode 100644 index 0000000000..4c49cc7690 --- /dev/null +++ b/Task/Abstract-type/0DESCRIPTION @@ -0,0 +1,11 @@ +'''Abstract type''' is a type without instances or without definition. + +For example in [[object-oriented programming]] using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract types without any implementation are called '''interfaces'''. In the languages that do not support multiple [[inheritance]] ([[Ada]], [[Java]]), classes can, nonetheless, inherit from multiple interfaces. The languages with multiple inheritance (like [[C++]]) usually make no distinction between partially implementable abstract types and interfaces. Because the abstract type's implementation is incomplete, [[object-oriented programming | OO]] languages normally prevent instantiation from them (instantiation must derived from one of their descendant classes). + +The term '''abstract datatype''' also may denote a type, with an implementation provided by the programmer rather than directly by the language (a '''built-in''' or an inferred type). Here the word ''abstract'' means that the implementation is abstracted away, irrelevant for the user of the type. Such implementation can and should be hidden if the language supports separation of implementation and specification. This hides complexity while allowing the implementation to change without repercussions on the usage. The corresponding software design practice is said to follow the [[wp:Information_hiding|information hiding principle]]. + +It is important not to confuse this ''abstractness'' (of implementation) with one of the '''abstract type'''. The latter is abstract in the sense that the set of its values is empty. In the sense of implementation abstracted away, all user-defined types are abstract. + +In some languages, like for example in Objective Caml which is strongly statically typed, it is also possible to have '''abstract types''' that are not OO related and are not an abstractness too. These are ''pure abstract types'' without any definition even in the implementation and can be used for example for the type algebra, or for some consistence of the type inference. For example in this area, an abstract type can be used as a phantom type to augment another type as its parameter. + +'''Task''': show how an abstract type can be declared in the language. If the language makes a distinction between interfaces and partially implemented types illustrate both. diff --git a/Task/Abstract-type/1META.yaml b/Task/Abstract-type/1META.yaml new file mode 100644 index 0000000000..cafc296b64 --- /dev/null +++ b/Task/Abstract-type/1META.yaml @@ -0,0 +1,5 @@ +--- +category: +- Object oriented +- Type System +note: Basic language learning diff --git a/Task/Abstract-type/ABAP/abstract-type-1.abap b/Task/Abstract-type/ABAP/abstract-type-1.abap new file mode 100644 index 0000000000..26f99d1d07 --- /dev/null +++ b/Task/Abstract-type/ABAP/abstract-type-1.abap @@ -0,0 +1,13 @@ +class abs definition abstract. + public section. + methods method1 abstract importing iv_value type f exporting ev_ret type i. + protected section. + methods method2 abstract importing iv_name type string exporting ev_ret type i. + methods add importing iv_a type i iv_b type i exporting ev_ret type i. +endclass. + +class abs implementation. + method add. + ev_ret = iv_a + iv_b. + endmethod. +endclass. diff --git a/Task/Abstract-type/ABAP/abstract-type-2.abap b/Task/Abstract-type/ABAP/abstract-type-2.abap new file mode 100644 index 0000000000..517da60fb2 --- /dev/null +++ b/Task/Abstract-type/ABAP/abstract-type-2.abap @@ -0,0 +1,5 @@ +interface inter. + methods: method1 importing iv_value type f exporting ev_ret type i, + method2 importing iv_name type string exporting ev_ret type i, + add importing iv_a type i iv_b type i exporting ev_ret type i. +endinterface. diff --git a/Task/Abstract-type/ActionScript/abstract-type.as b/Task/Abstract-type/ActionScript/abstract-type.as new file mode 100644 index 0000000000..f8125aa8ec --- /dev/null +++ b/Task/Abstract-type/ActionScript/abstract-type.as @@ -0,0 +1,8 @@ +package +{ + public interface IInterface + { + function method1():void; + function method2(arg1:Array, arg2:Boolean):uint; + } +} diff --git a/Task/Abstract-type/Ada/abstract-type-1.ada b/Task/Abstract-type/Ada/abstract-type-1.ada new file mode 100644 index 0000000000..ec6e7dfe56 --- /dev/null +++ b/Task/Abstract-type/Ada/abstract-type-1.ada @@ -0,0 +1,3 @@ +type Queue is limited interface; +procedure Enqueue (Lounge : in out Queue; Item : in out Element) is abstract; +procedure Dequeue (Lounge : in out Queue; Item : in out Element) is abstract; diff --git a/Task/Abstract-type/Ada/abstract-type-2.ada b/Task/Abstract-type/Ada/abstract-type-2.ada new file mode 100644 index 0000000000..09512a4fd8 --- /dev/null +++ b/Task/Abstract-type/Ada/abstract-type-2.ada @@ -0,0 +1,2 @@ +type Scheduler is task interface; +procedure Plan (Manager : in out Scheduler; Activity : in out Job) is abstract; diff --git a/Task/Abstract-type/Ada/abstract-type-3.ada b/Task/Abstract-type/Ada/abstract-type-3.ada new file mode 100644 index 0000000000..712648f9b7 --- /dev/null +++ b/Task/Abstract-type/Ada/abstract-type-3.ada @@ -0,0 +1,10 @@ +with Ada.Finalization; +... +type Node is abstract new Ada.Finalization.Limited_Controlled and Queue with record + Previous : not null access Node'Class := Node'Unchecked_Access; + Next : not null access Node'Class := Node'Unchecked_Access; +end record; +overriding procedure Finalize (X : in out Node); -- Removes the node from its list if any +overriding procedure Dequeue (Lounge : in out Node; Item : in out Element); +overriding procedure Enqueue (Lounge : in out Node; Item : in out Element); +procedure Process (X : in out Node) is abstract; -- To be implemented diff --git a/Task/Abstract-type/Agda/abstract-type.agda b/Task/Abstract-type/Agda/abstract-type.agda new file mode 100644 index 0000000000..f4870b2f17 --- /dev/null +++ b/Task/Abstract-type/Agda/abstract-type.agda @@ -0,0 +1,53 @@ +module AbstractInterfaceExample where + +open import Function +open import Data.Bool +open import Data.String + +-- * One-parameter interface for the type `a' with only one method. + +record VoiceInterface (a : Set) : Set where + constructor voice-interface + field say-method-of : a β†’ String + +open VoiceInterface + +-- * An overloaded method. + +say : {a : Set} β†’ ⦃ _ : VoiceInterface a ⦄ β†’ a β†’ String +say ⦃ instance ⦄ = say-method-of instance + +-- * Some data types. + +data Cat : Set where + cat : Bool β†’ Cat + +crazy! = true +plain-cat = false + +-- | This cat is crazy? +crazy? : Cat β†’ Bool +crazy? (cat x) = x + +-- | A 'plain' dog. +data Dog : Set where + dog : Dog + +-- * Implementation of the interface (and method). + +instance-for-cat : VoiceInterface Cat +instance-for-cat = voice-interface case where + case : Cat β†’ String + case x with crazy? x + ... | true = "meeeoooowwwww!!!" + ... | false = "meow!" + +instance-for-dog : VoiceInterface Dog +instance-for-dog = voice-interface $ const "woof!" + +-- * and then: +-- +-- say dog => "woof!" +-- say (cat crazy!) => "meeeoooowwwww!!!" +-- say (cat plain-cat) => "meow!" +-- diff --git a/Task/Abstract-type/Aikido/abstract-type-1.aikido b/Task/Abstract-type/Aikido/abstract-type-1.aikido new file mode 100644 index 0000000000..c5bf13c2d5 --- /dev/null +++ b/Task/Abstract-type/Aikido/abstract-type-1.aikido @@ -0,0 +1,5 @@ +class Abs { + public function method1... + public function method2... + +} diff --git a/Task/Abstract-type/Aikido/abstract-type-2.aikido b/Task/Abstract-type/Aikido/abstract-type-2.aikido new file mode 100644 index 0000000000..4ce398b259 --- /dev/null +++ b/Task/Abstract-type/Aikido/abstract-type-2.aikido @@ -0,0 +1,5 @@ +interface Inter { + function isFatal : integer + function operate (para : integer = 0) + operator -> (stream, isout) +} diff --git a/Task/Abstract-type/Argile/abstract-type.argile b/Task/Abstract-type/Argile/abstract-type.argile new file mode 100644 index 0000000000..0ddb713920 --- /dev/null +++ b/Task/Abstract-type/Argile/abstract-type.argile @@ -0,0 +1,38 @@ +use std + +(: abstract class :) + +class Abs + text name + AbsIface iface + +class AbsIface + function(Abs)(int)->int method + +let Abs_Iface = Cdata AbsIface@ {.method = nil} + +.: new Abs :. -> Abs {let a = new(Abs); a.iface = Abs_Iface; a} + +=: .method := -> int + (self.iface.method is nil) ? 0 , (call self.iface.method with self i) + +(: implementation :) + +class Sub <- Abs { int value } + +let Sub_Iface = Cdata AbsIface@ {.method = (code of (nil the Sub).method 0)} + +.: new Sub () :. -> Sub + let s = new (Sub) + s.iface = Sub_Iface + s.value = value + s + +.: .method :. -> int {this.value + i} + +(: example use :) + +.:foobar:. {print a.method 12 ; del a} +foobar (new Sub 34) (: prints 46 :) +foobar (new Sub) (: prints 11 :) +foobar (new Abs) (: prints 0 :) diff --git a/Task/Abstract-type/AutoHotkey/abstract-type.ahk b/Task/Abstract-type/AutoHotkey/abstract-type.ahk new file mode 100644 index 0000000000..a5de431e4d --- /dev/null +++ b/Task/Abstract-type/AutoHotkey/abstract-type.ahk @@ -0,0 +1,28 @@ +color(r, g, b){ + static color + If !color + color := Object("base", Object("R", r, "G", g, "B", b + ,"GetRGB", "Color_GetRGB")) + return Object("base", Color) +} +Color_GetRGB(clr) { + return "not implemented" +} + +waterColor(r, g, b){ + static waterColor + If !waterColor + waterColor := Object("base", color(r, g, b),"GetRGB", "WaterColor_GetRGB") + return Object("base", WaterColor) +} + +WaterColor_GetRGB(clr){ +return clr.R << 16 | clr.G << 8 | clr.B +} + +test: +blue := color(0, 0, 255) +msgbox % blue.GetRGB() ; displays "not implemented" +blue := waterColor(0, 0, 255) +msgbox % blue.GetRGB() ; displays 255 +return diff --git a/Task/Abstract-type/C/abstract-type-1.c b/Task/Abstract-type/C/abstract-type-1.c new file mode 100644 index 0000000000..2e0aeed10e --- /dev/null +++ b/Task/Abstract-type/C/abstract-type-1.c @@ -0,0 +1,33 @@ +#ifndef INTERFACE_ABS +#define INTERFACE_ABS + +typedef struct sAbstractCls *AbsCls; + +typedef struct sAbstractMethods { + int (*method1)(AbsCls c, int a); + const char *(*method2)(AbsCls c, int b); + void (*method3)(AbsCls c, double d); +} *AbstractMethods, sAbsMethods; + +struct sAbstractCls { + AbstractMethods klass; + void *instData; +}; + +#define ABSTRACT_METHODS( cName, m1, m2, m3 ) \ + static sAbsMethods cName ## _Iface = { &m1, &m2, &m3 }; \ + AbsCls cName ## _Instance( void *clInst) { \ + AbsCls ac = malloc(sizeof(struct sAbstractCls)); \ + if (ac) { \ + ac->klass = &cName ## _Iface; \ + ac->instData = clInst; \ + }\ + return ac; } + +#define Abs_Method1( c, a) (c)->klass->method1(c, a) +#define Abs_Method2( c, b) (c)->klass->method2(c, b) +#define Abs_Method3( c, d) (c)->klass->method3(c, d) +#define Abs_Free(c) \ + do { if (c) { free((c)->instData); free(c); } } while(0); + +#endif diff --git a/Task/Abstract-type/C/abstract-type-2.c b/Task/Abstract-type/C/abstract-type-2.c new file mode 100644 index 0000000000..4354d95cec --- /dev/null +++ b/Task/Abstract-type/C/abstract-type-2.c @@ -0,0 +1,9 @@ +#ifndef SILLY_H +#define SILLY_H +#include intefaceAbs.h + +typedef struct sillyStruct *Silly; +extern Silly NewSilly( double, const char *); +extern AbsCls Silly_Instance(void *); + +#endif diff --git a/Task/Abstract-type/C/abstract-type-3.c b/Task/Abstract-type/C/abstract-type-3.c new file mode 100644 index 0000000000..d53c69665d --- /dev/null +++ b/Task/Abstract-type/C/abstract-type-3.c @@ -0,0 +1,42 @@ +#include "silly.h" +#include +#include +#include + +struct sillyStruct { + double v1; + char str[32]; +}; + +Silly NewSilly(double vInit, const char *strInit) +{ + Silly sily = malloc(sizeof( struct sillyStruct )); + sily->v1 = vInit; + sily->str[0] = '\0'; + strncat(sily->str, strInit, 31); + return sily; +} + +static +int MyMethod1( AbsCls c, int a) +{ + Silly s = (Silly)(c->instData); + return a+strlen(s->str); +} + +static +const char *MyMethod2(AbsCls c, int b) +{ + Silly s = (Silly)(c->instData); + sprintf(s->str, "%d", b); + return s->str; +} + +static +void MyMethod3(AbsCls c, double d) +{ + Silly s = (Silly)(c->instData); + printf("InMyMethod3, %f\n",s->v1 * d); +} + +ABSTRACT_METHODS( Silly, MyMethod1, MyMethod2, MyMethod3) diff --git a/Task/Abstract-type/C/abstract-type-4.c b/Task/Abstract-type/C/abstract-type-4.c new file mode 100644 index 0000000000..4862b9b2e1 --- /dev/null +++ b/Task/Abstract-type/C/abstract-type-4.c @@ -0,0 +1,13 @@ +#include +#include "silly.h" + +int main() +{ + AbsCls abster = Silly_Instance(NewSilly( 10.1, "Green Tomato")); + + printf("AbsMethod1: %d\n", Abs_Method1(abster, 5)); + printf("AbsMethod2: %s\n", Abs_Method2(abster, 4)); + Abs_Method3(abster, 21.55); + Abs_Free(abster); + return 0; +} diff --git a/Task/Abstract-type/Clojure/abstract-type.clj b/Task/Abstract-type/Clojure/abstract-type.clj new file mode 100644 index 0000000000..a442b2bd0d --- /dev/null +++ b/Task/Abstract-type/Clojure/abstract-type.clj @@ -0,0 +1 @@ +(defprotocol Foo (foo [this])) diff --git a/Task/Abstract-type/Eiffel/abstract-type.e b/Task/Abstract-type/Eiffel/abstract-type.e new file mode 100644 index 0000000000..4bf6e811d3 --- /dev/null +++ b/Task/Abstract-type/Eiffel/abstract-type.e @@ -0,0 +1,17 @@ +deferred class + AN_ABSTRACT_CLASS + +feature + + a_deferred_feature + -- a feature whose implementation is left to a descendent + deferred + end + + an_effective_feature: STRING + -- deferred (abstract) classes may still include effective features + do + Result := "I am implemented!" + end + +end diff --git a/Task/Abstract-type/Forth/abstract-type.fth b/Task/Abstract-type/Forth/abstract-type.fth new file mode 100644 index 0000000000..79ea6a5b75 --- /dev/null +++ b/Task/Abstract-type/Forth/abstract-type.fth @@ -0,0 +1,25 @@ +include 4pp/lib/foos.4pp + +:: X() + class + method: method1 + method: method2 + end-class { + :method { ." Method 1 in X" cr } ; defines method1 + } +; + +:: Y() + extends X() + end-extends { + :method { ." Method 2 in Y" cr } ; defines method2 + } +; + +: Main + static Y() y + y => method1 + y => method2 +; + +Main diff --git a/Task/Abstract-type/Go/abstract-type.go b/Task/Abstract-type/Go/abstract-type.go new file mode 100644 index 0000000000..7c4600d45d --- /dev/null +++ b/Task/Abstract-type/Go/abstract-type.go @@ -0,0 +1,5 @@ +interface { + Method1(value float64) int + SetName(name string) + GetName() string +} diff --git a/Task/Abstract-type/Haskell/abstract-type-1.hs b/Task/Abstract-type/Haskell/abstract-type-1.hs new file mode 100644 index 0000000000..d223408e49 --- /dev/null +++ b/Task/Abstract-type/Haskell/abstract-type-1.hs @@ -0,0 +1,3 @@ +class Eq a where + (==) :: a -> a -> Bool + (/=) :: a -> a -> Bool diff --git a/Task/Abstract-type/Haskell/abstract-type-2.hs b/Task/Abstract-type/Haskell/abstract-type-2.hs new file mode 100644 index 0000000000..db53784ccf --- /dev/null +++ b/Task/Abstract-type/Haskell/abstract-type-2.hs @@ -0,0 +1,5 @@ +class Eq a where + (==) :: a -> a -> Bool + (/=) :: a -> a -> Bool + x /= y = not (x == y) + x == y = not (x /= y) diff --git a/Task/Abstract-type/Haskell/abstract-type-3.hs b/Task/Abstract-type/Haskell/abstract-type-3.hs new file mode 100644 index 0000000000..ceb41e0cb5 --- /dev/null +++ b/Task/Abstract-type/Haskell/abstract-type-3.hs @@ -0,0 +1,2 @@ +func :: (Eq a) => a -> Bool +func x = x == x diff --git a/Task/Abstract-type/Haskell/abstract-type-4.hs b/Task/Abstract-type/Haskell/abstract-type-4.hs new file mode 100644 index 0000000000..b08f0b6a5d --- /dev/null +++ b/Task/Abstract-type/Haskell/abstract-type-4.hs @@ -0,0 +1 @@ +data Foo = Foo {x :: Integer, str :: String} diff --git a/Task/Abstract-type/Haskell/abstract-type-5.hs b/Task/Abstract-type/Haskell/abstract-type-5.hs new file mode 100644 index 0000000000..dfc96a1159 --- /dev/null +++ b/Task/Abstract-type/Haskell/abstract-type-5.hs @@ -0,0 +1,3 @@ +instance Eq Foo where + (Foo x1 str1) == (Foo x2 str2) = + (x1 == x2) && (str1 == str2) diff --git a/Task/Abstract-type/Haskell/abstract-type-6.hs b/Task/Abstract-type/Haskell/abstract-type-6.hs new file mode 100644 index 0000000000..7745ff6089 --- /dev/null +++ b/Task/Abstract-type/Haskell/abstract-type-6.hs @@ -0,0 +1,3 @@ +class abstraction() + abstract method compare(l,r) # generates runerr(700, "method compare()") +end diff --git a/Task/Abstract-type/Java/abstract-type-1.java b/Task/Abstract-type/Java/abstract-type-1.java new file mode 100644 index 0000000000..5d5c054699 --- /dev/null +++ b/Task/Abstract-type/Java/abstract-type-1.java @@ -0,0 +1,7 @@ +public abstract class Abs { + abstract public int method1(double value); + abstract protected int method2(String name); + int add(int a, int b){ + return a+b; + } +} diff --git a/Task/Abstract-type/Java/abstract-type-2.java b/Task/Abstract-type/Java/abstract-type-2.java new file mode 100644 index 0000000000..15776316d9 --- /dev/null +++ b/Task/Abstract-type/Java/abstract-type-2.java @@ -0,0 +1,5 @@ +public interface Inter { + int method1(double value); + int method2(String name); + int add(int a, int b); +} diff --git a/Task/Abstract-type/Lua/abstract-type-1.lua b/Task/Abstract-type/Lua/abstract-type-1.lua new file mode 100644 index 0000000000..af65e9ea7b --- /dev/null +++ b/Task/Abstract-type/Lua/abstract-type-1.lua @@ -0,0 +1,34 @@ +BaseClass = {} + +function class ( baseClass ) + local new_class = {} + local class_mt = { __index = new_class } + + function new_class:new() + local newinst = {} + setmetatable( newinst, class_mt ) + return newinst + end + + if not baseClass then baseClass = BaseClass end + setmetatable( new_class, { __index = baseClass } ) + + return new_class +end + +function abstractClass ( self ) + local new_class = {} + local class_mt = { __index = new_class } + + function new_class:new() + error("Abstract classes cannot be instantiated") + end + + if not baseClass then baseClass = BaseClass end + setmetatable( new_class, { __index = baseClass } ) + + return new_class +end + +BaseClass.class = class +BaseClass.abstractClass = abstractClass diff --git a/Task/Abstract-type/Lua/abstract-type-2.lua b/Task/Abstract-type/Lua/abstract-type-2.lua new file mode 100644 index 0000000000..c83b074c4d --- /dev/null +++ b/Task/Abstract-type/Lua/abstract-type-2.lua @@ -0,0 +1,8 @@ +A = class() -- New class A inherits BaseClass by default +AA = A:class() -- New class AA inherits from existing class A +B = abstractClass() -- New abstract class B +BB = B:class() -- BB is not abstract +A:new() -- Okay: New class instance +AA:new() -- Okay: New class instance +B:new() -- Error: B is abstract +BB:new() -- Okay: BB is not abstract diff --git a/Task/Abstract-type/PHP/abstract-type-1.php b/Task/Abstract-type/PHP/abstract-type-1.php new file mode 100644 index 0000000000..b24537c14c --- /dev/null +++ b/Task/Abstract-type/PHP/abstract-type-1.php @@ -0,0 +1,7 @@ +abstract class Abs { + abstract public function method1($value); + abstract protected function method2($name); + function add($a, $b){ + return a + b; + } +} diff --git a/Task/Abstract-type/PHP/abstract-type-2.php b/Task/Abstract-type/PHP/abstract-type-2.php new file mode 100644 index 0000000000..f61b1b95c6 --- /dev/null +++ b/Task/Abstract-type/PHP/abstract-type-2.php @@ -0,0 +1,5 @@ +interface Inter { + public function method1($value); + public function method2($name); + public function add($a, $b); +} diff --git a/Task/Abstract-type/Perl/abstract-type-1.pl b/Task/Abstract-type/Perl/abstract-type-1.pl new file mode 100644 index 0000000000..e7436bd08e --- /dev/null +++ b/Task/Abstract-type/Perl/abstract-type-1.pl @@ -0,0 +1,14 @@ +package AbstractFoo; + +use strict; + +sub frob { die "abstract" } +sub baz { die "abstract" } + +sub frob_the_baz { + my $self = shift; + $self->frob($self->baz()); +} + + +1; diff --git a/Task/Abstract-type/Perl/abstract-type-2.pl b/Task/Abstract-type/Perl/abstract-type-2.pl new file mode 100644 index 0000000000..f1f4464d9c --- /dev/null +++ b/Task/Abstract-type/Perl/abstract-type-2.pl @@ -0,0 +1,13 @@ +package AbstractFoo; + +use strict; + +sub frob { ... } +sub baz { ... } + +sub frob_the_baz { + my $self = shift; + $self->frob($self->baz()); +} + +1; diff --git a/Task/Abstract-type/Perl/abstract-type-3.pl b/Task/Abstract-type/Perl/abstract-type-3.pl new file mode 100644 index 0000000000..aa042518de --- /dev/null +++ b/Task/Abstract-type/Perl/abstract-type-3.pl @@ -0,0 +1,12 @@ +package AbstractFoo; + +use Moose::Role; + +requires qw/frob baz/; + +sub frob_the_baz { + my $self = shift; + $self->frob($self->baz()); +} + +1; diff --git a/Task/Abstract-type/Perl/abstract-type-4.pl b/Task/Abstract-type/Perl/abstract-type-4.pl new file mode 100644 index 0000000000..d09c8eac61 --- /dev/null +++ b/Task/Abstract-type/Perl/abstract-type-4.pl @@ -0,0 +1,12 @@ +package AbstractFoo; + +use Role::Tiny; + +requires qw/frob baz/; + +sub frob_the_baz { + my $self = shift; + $self->frob($self->baz()); +} + +1; diff --git a/Task/Abstract-type/PicoLisp/abstract-type.l b/Task/Abstract-type/PicoLisp/abstract-type.l new file mode 100644 index 0000000000..58964e0648 --- /dev/null +++ b/Task/Abstract-type/PicoLisp/abstract-type.l @@ -0,0 +1,11 @@ +# In PicoLisp there is no formal difference between abstract and concrete classes. +# There is just a naming convention where abstract classes start with a +# lower-case character after the '+' (the naming convention for classes). +# This tells the programmer that this class has not enough methods +# defined to survive on its own. + +(class +abstractClass) + +(dm someMethod> () + (foo) + (bar) ) diff --git a/Task/Abstract-type/Python/abstract-type-1.py b/Task/Abstract-type/Python/abstract-type-1.py new file mode 100644 index 0000000000..97bcd27dd4 --- /dev/null +++ b/Task/Abstract-type/Python/abstract-type-1.py @@ -0,0 +1,13 @@ +class BaseQueue(object): + """Abstract/Virtual Class + """ + def __init__(self): + self.contents = list() + raise NotImplementedError + def Enqueue(self, item): + raise NotImplementedError + def Dequeue(self): + raise NotImplementedError + def Print_Contents(self): + for i in self.contents: + print i, diff --git a/Task/Abstract-type/Python/abstract-type-2.py b/Task/Abstract-type/Python/abstract-type-2.py new file mode 100644 index 0000000000..d7e1b0f7eb --- /dev/null +++ b/Task/Abstract-type/Python/abstract-type-2.py @@ -0,0 +1,21 @@ +from abc import ABCMeta, abstractmethod + +class BaseQueue(): + """Abstract Class + """ + __metaclass__ = ABCMeta + + def __init__(self): + self.contents = list() + + @abstractmethod + def Enqueue(self, item): + pass + + @abstractmethod + def Dequeue(self): + pass + + def Print_Contents(self): + for i in self.contents: + print i, diff --git a/Task/Abstract-type/Racket/abstract-type.rkt b/Task/Abstract-type/Racket/abstract-type.rkt new file mode 100644 index 0000000000..5d0974a097 --- /dev/null +++ b/Task/Abstract-type/Racket/abstract-type.rkt @@ -0,0 +1,13 @@ +#lang racket + +(define animal-interface (interface () say)) + +(define cat% (class* object% (animal-interface) (super-new))) ;; error + +(define cat% (class* object% (animal-interface) + (super-new) + (define/public (say) + (display "meeeeew!")))) + +(define tom (new cat%)) +(send tom say) diff --git a/Task/Abstract-type/Ruby/abstract-type.rb b/Task/Abstract-type/Ruby/abstract-type.rb new file mode 100644 index 0000000000..b2c5cd0f41 --- /dev/null +++ b/Task/Abstract-type/Ruby/abstract-type.rb @@ -0,0 +1,17 @@ +require 'abstraction' + +class AbstractQueue + abstract + def enqueue(object) + raise NotImplementedError + end + def dequeue + raise NotImplementedError + end +end + +class ConcreteQueue < AbstractQueue + def enqueue(object) + puts "enqueue #{object.inspect}" + end +end diff --git a/Task/Abstract-type/Scala/abstract-type.scala b/Task/Abstract-type/Scala/abstract-type.scala new file mode 100644 index 0000000000..2475f9ec40 --- /dev/null +++ b/Task/Abstract-type/Scala/abstract-type.scala @@ -0,0 +1,10 @@ +abstract class X { + type A + var B: A + val C: A + def D(a: A): A +} + +trait Y { + val x: X +} diff --git a/Task/Abstract-type/Tcl/abstract-type.tcl b/Task/Abstract-type/Tcl/abstract-type.tcl new file mode 100644 index 0000000000..cf8ef987d5 --- /dev/null +++ b/Task/Abstract-type/Tcl/abstract-type.tcl @@ -0,0 +1,9 @@ +oo::class create AbstractQueue { + method enqueue item { + error "not implemented" + } + method dequeue {} { + error "not implemented" + } + self unexport create new +} diff --git a/Task/Accumulator-factory/0DESCRIPTION b/Task/Accumulator-factory/0DESCRIPTION new file mode 100644 index 0000000000..109491ef80 --- /dev/null +++ b/Task/Accumulator-factory/0DESCRIPTION @@ -0,0 +1,20 @@ +A problem posed by [[wp:Paul Graham|Paul Graham]] is that of creating a function that takes a single (numeric) argument and which returns another function that is an accumulator. The returned accumulator function in turn also takes a single numeric argument, and returns the sum of all the numeric values passed in so far to that accumulator (including the initial value passed when the accumulator was created). + +The detailed rules are at http://paulgraham.com/accgensub.html and are reproduced here for simplicity (with additions in ''small italic text''). +:Before you submit an example, make sure the function + +:# Takes a number n and returns a function (lets call it g), that takes a number i, and returns n incremented by the accumulation of i from every call of function g(i).
Although these exact function and parameter names need not be used +:# Works for any numeric type-- i.e. can take both ints and floats and returns functions that can take both ints and floats. (It is not enough simply to convert all input to floats. An accumulator that has only seen integers must return integers.) ''(i.e., if the language doesn't allow for numeric polymorphism, you have to use overloading or something like that)'' +:# Generates functions that return the sum of every number ever passed to them, not just the most recent. ''(This requires a piece of state to hold the accumulated value, which in turn means that pure functional languages can't be used for this task.)'' +:# Returns a real function, meaning something that you can use wherever you could use a function you had defined in the ordinary way in the text of your program. ''(Follow your language's conventions here.)'' +:# Doesn't store the accumulated value or the returned functions in a way that could cause them to be inadvertently modified by other code. ''(No global variables or other such things.)'' +: E.g. if after the example, you added the following code (in a made-up language) ''where the factory function is called foo'': +:: x = foo(1); +x(5); +foo(3); +print x(2.3); +: It should print 8.3. ''(There is no need to print the form of the accumulator function returned by foo(3); it's not part of the task at all.)'' +The purpose of this task is to create a function that implements the described rules. It need not handle any special error cases not described above. The simplest way to implement the task as described is typically to use a [[Closures|closure]], providing the language supports them. + +Where it is not possible to hold exactly to the constraints above, describe the deviations. +{{Omit from|MUMPS|Creating a function implies that there is routine somewhere that has the function stored, and that function could be modified}} diff --git a/Task/Accumulator-factory/1META.yaml b/Task/Accumulator-factory/1META.yaml new file mode 100644 index 0000000000..f16d1f37aa --- /dev/null +++ b/Task/Accumulator-factory/1META.yaml @@ -0,0 +1,3 @@ +--- +requires: +- Mutable State diff --git a/Task/Accumulator-factory/ABAP/accumulator-factory-1.abap b/Task/Accumulator-factory/ABAP/accumulator-factory-1.abap new file mode 100644 index 0000000000..198add3937 --- /dev/null +++ b/Task/Accumulator-factory/ABAP/accumulator-factory-1.abap @@ -0,0 +1,27 @@ +report z_accumulator +class acc definition. + public section. + methods: + call importing iv_i type any default 0 exporting ev_r type any, + constructor importing iv_d type f. + private section. + data a_sum type f. +endclass. + +class acc implementation. + method call. + add iv_i to a_sum. + ev_r = a_sum. + endmethod. + +start-of-selection. + +data: cl_acc type ref to acc, + lv_ret2 type f, + lv_ret1 type i. + +create object cl_acc exporting iv_d = 1. +cl_acc->call( exporting iv_i = 5 ). +cl_acc->call( exporting iv_i = '2.3' importing ev_r = lv_ret2 ). +cl_acc->call( exporting iv_i = 2 importing ev_r = lv_ret1 ). +write : / lv_ret2 decimals 2 exponent 0 left-justified, / lv_ret1 left-justified. diff --git a/Task/Accumulator-factory/ABAP/accumulator-factory-2.abap b/Task/Accumulator-factory/ABAP/accumulator-factory-2.abap new file mode 100644 index 0000000000..496ed90db6 --- /dev/null +++ b/Task/Accumulator-factory/ABAP/accumulator-factory-2.abap @@ -0,0 +1,24 @@ +data: lv_source type string, + cl_processor type ref to cl_java_script, + lv_ret type string. + +cl_processor = cl_java_script=>create( ). +concatenate +'function acc(sum) { ' +' return function(n) { ' +' return sum += n;' +' }; ' +' }; ' +' var x = acc(1); ' +' x(5);' +' var ret = acc(3).toString();' +' ret = ret + x(2.3);' + into lv_source. +lv_ret = cl_processor->evaluate( lv_source ). + +if cl_processor->last_condition_code <> cl_java_script=>cc_ok. + write cl_processor->last_error_message. +else. + write lv_ret. + write / 'Done'. +endif. diff --git a/Task/Accumulator-factory/ALGOL-68/accumulator-factory.alg b/Task/Accumulator-factory/ALGOL-68/accumulator-factory.alg new file mode 100644 index 0000000000..daef37452b --- /dev/null +++ b/Task/Accumulator-factory/ALGOL-68/accumulator-factory.alg @@ -0,0 +1,33 @@ +MODE NUMBER = UNION(INT,REAL,COMPL); + +PROC plus = (NUMBER in a, in b)NUMBER: ( + CASE in a IN + (INT a): CASE in b IN (INT b): a+b, (REAL b): a+b, (COMPL b): a+b ESAC, + (REAL a): CASE in b IN (INT b): a+b, (REAL b): a+b, (COMPL b): a+b ESAC, + (COMPL a): CASE in b IN (INT b): a+b, (REAL b): a+b, (COMPL b): a+b ESAC + ESAC +); + +main: ( + +# now override the + and +:= OPerators # + OP + = (NUMBER a, b)NUMBER: plus(a,b); + + OP +:= = (REF NUMBER lhs, NUMBER rhs)NUMBER: + lhs := lhs + rhs; + + PROC accumulator = (REF NUMBER sum)PROC(NUMBER)NUMBER: + (NUMBER n)NUMBER: + sum +:= n; + + PROC (NUMBER)NUMBER x = accumulator(LOC NUMBER := 1); + x(5); + print(("x:",x(2.3), new line)); + + PROC (NUMBER)NUMBER y = accumulator(LOC NUMBER := 100); + y(500); + print(("y:",y(230), new line)); + + print(("x:",x(0), new line)) + +) diff --git a/Task/Accumulator-factory/ActionScript/accumulator-factory.as b/Task/Accumulator-factory/ActionScript/accumulator-factory.as new file mode 100644 index 0000000000..4624975e8b --- /dev/null +++ b/Task/Accumulator-factory/ActionScript/accumulator-factory.as @@ -0,0 +1,14 @@ +//Throw an error if a non-number argument is used. (typeof evaluates to +// "number" for both integers and reals) +function checkType(obj:Object):void { + if(typeof obj != "number") + throw new ArgumentError("Expected integer or float argument. Recieved " + typeof obj); +} +function accumulator(sum:Object):Function { + checkType(sum); + return function(n:Object):Object {checkType(n); return sum += n}; +} +var acc:Function=accumulator(2); +trace(acc(10)); +trace(acc(4)); +trace(acc("123")); //This causes an ArgumentError to be thrown. diff --git a/Task/Accumulator-factory/Ada/accumulator-factory-1.ada b/Task/Accumulator-factory/Ada/accumulator-factory-1.ada new file mode 100644 index 0000000000..7a2d4fde69 --- /dev/null +++ b/Task/Accumulator-factory/Ada/accumulator-factory-1.ada @@ -0,0 +1,11 @@ +with Accumulator; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Example is + package A is new Accumulator; + package B is new Accumulator; +begin + Put_Line (Integer'Image (A.The_Function (5))); + Put_Line (Integer'Image (B.The_Function (3))); + Put_Line (Float'Image (A.The_Function (2.3))); +end; diff --git a/Task/Accumulator-factory/Ada/accumulator-factory-2.ada b/Task/Accumulator-factory/Ada/accumulator-factory-2.ada new file mode 100644 index 0000000000..90f6fbbec0 --- /dev/null +++ b/Task/Accumulator-factory/Ada/accumulator-factory-2.ada @@ -0,0 +1,11 @@ +generic package Accumulator is + +-- This Ada generic package represents an accumulator factory. +-- The required function is provided as The_Function. +-- The first call to The_Function sets the initial value. +-- (Marius Amado-Alves) + + function The_Function (X : Integer) return Integer; + function The_Function (X : Integer) return Float; + function The_Function (X : Float) return Float; +end; diff --git a/Task/Accumulator-factory/Ada/accumulator-factory-3.ada b/Task/Accumulator-factory/Ada/accumulator-factory-3.ada new file mode 100644 index 0000000000..4d3ccb7a5f --- /dev/null +++ b/Task/Accumulator-factory/Ada/accumulator-factory-3.ada @@ -0,0 +1,64 @@ +package body Accumulator is + +-- The accumulator lives through three states. It is in Virgin_State +-- before any use of The_Function. It changes to Integer_State or +-- Float_State, according to the input type used. The accumulation is +-- memorized in variable I or F, according to the state. Float_State, +-- once reached, is never left. A Float output on an Integer_State is +-- simply a conversion, sans effect on state. (Marius Amado-Alves) + + type State_T is (Virgin_State, Integer_State, Float_State); + State : State_T := Virgin_State; + I : Integer; + F : Float; + + function The_Function (X : Float) return Float is + begin + case State is + when Virgin_State => + State := Float_State; + F := X; + return F; + when Integer_State => + State := Float_State; + F := Float (I) + X; + return F; + when Float_State => + F := F + X; + return F; + end case; + end; + + function The_Function (X : Integer) return Float is + begin + case State is + when Virgin_State => + State := Integer_State; + I := X; + return Float (I); + when Integer_State => + I := I + X; + return Float (I); + when Float_State => + F := F + Float (X); + return F; + end case; + end; + + function The_Function (X : Integer) return Integer is + begin + case State is + when Virgin_State => + State := Integer_State; + I := X; + return I; + when Integer_State => + I := I + X; + return I; + when Float_State => + F := F + Float (X); + return Integer (F); + end case; + end; + +end; diff --git a/Task/Accumulator-factory/Aikido/accumulator-factory.aikido b/Task/Accumulator-factory/Aikido/accumulator-factory.aikido new file mode 100644 index 0000000000..2d2000a2fc --- /dev/null +++ b/Task/Accumulator-factory/Aikido/accumulator-factory.aikido @@ -0,0 +1,8 @@ +function accumulator (sum:real) { + return function(n:real) { return sum += n } +} + +var x = accumulator(1) +x(5) +println (accumulator) +println (x(2.3)) diff --git a/Task/Accumulator-factory/Argile/accumulator-factory.argile b/Task/Accumulator-factory/Argile/accumulator-factory.argile new file mode 100644 index 0000000000..9927a19767 --- /dev/null +++ b/Task/Accumulator-factory/Argile/accumulator-factory.argile @@ -0,0 +1,53 @@ +use std, array + +let A = accumulator 42 +print(A 0) +print(A 1) +print(A 10) +print(A 100) + +let B = accumulator 4.2 +print(B 0) +print(B 1) +print(B 10.0) +print(B 100.4) + +~A ; ~B +(: use dbg; check mem leak :) + +(: accumulator call :) +=: := -> (a.t) + call ((a.func) as function(any)(a.t)->(a.t)) with (a.data) ((Cgen x) as a.t) + +(: accumulator constructors :) +.: accumulator :. -> int accumulator + (val (int accumulator) A).init(x) + (A as Accumulator).func = ( .::. ->int {accu += x; accu} ) + A + +.: accumulator :. -> real accumulator + (val (real accumulator) A).init(x) + (A as Accumulator).func = ( .::. ->real{accu += x; accu} ) + A + +=: .init := + a = new (Accumulator) + a.data = (new array of 1 a.t) + *(a.data as (a.t*)) = Cgen x + +(: accumulator destructor :) +.: del Accumulator :. + free a.data + free a +=: ~ := {del Accumulator a} + +(: accumulator type :) +class Accumulator + function func + any data + +=: [] accumulator := -> type + Accumulator.prefix + Accumulator.suffix + +autocast accumulator<->Accumulator diff --git a/Task/Accumulator-factory/C/accumulator-factory.c b/Task/Accumulator-factory/C/accumulator-factory.c new file mode 100644 index 0000000000..1abf86c3d6 --- /dev/null +++ b/Task/Accumulator-factory/C/accumulator-factory.c @@ -0,0 +1,18 @@ +#include +//~ Take a number n and return a function that takes a number i +#define ACCUMULATOR(name,n) __typeof__(n) name (__typeof__(n) i) { \ + static __typeof__(n) _n=n; LOGIC; } +//~ have it return n incremented by the accumulation of i +#define LOGIC return _n+=i +ACCUMULATOR(x,1.0) +ACCUMULATOR(y,3) +ACCUMULATOR(z,'a') +#undef LOGIC +int main (void) { + printf ("%f\n", x(5)); /* 6.000000 */ + printf ("%f\n", x(2.3)); /* 8.300000 */ + printf ("%i\n", y(5.0)); /* 8 */ + printf ("%i\n", y(3.3)); /* 11 */ + printf ("%c\n", z(5)); /* f */ + return 0; +} diff --git a/Task/Accumulator-factory/Clojure/accumulator-factory-1.clj b/Task/Accumulator-factory/Clojure/accumulator-factory-1.clj new file mode 100644 index 0000000000..6a7a7241e9 --- /dev/null +++ b/Task/Accumulator-factory/Clojure/accumulator-factory-1.clj @@ -0,0 +1,3 @@ +(defn accum [n] + (let [acc (atom n)] + (fn [m] (swap! acc + m)))) diff --git a/Task/Accumulator-factory/Clojure/accumulator-factory-2.clj b/Task/Accumulator-factory/Clojure/accumulator-factory-2.clj new file mode 100644 index 0000000000..ff5bf59a1d --- /dev/null +++ b/Task/Accumulator-factory/Clojure/accumulator-factory-2.clj @@ -0,0 +1,3 @@ +(defn accum [n] + (let [acc (ref n)] + #(dosync (alter acc + %)))) diff --git a/Task/Accumulator-factory/CoffeeScript/accumulator-factory.coffee b/Task/Accumulator-factory/CoffeeScript/accumulator-factory.coffee new file mode 100644 index 0000000000..fae7f40e8a --- /dev/null +++ b/Task/Accumulator-factory/CoffeeScript/accumulator-factory.coffee @@ -0,0 +1,6 @@ +accumulator = (sum) -> + (n) -> sum += n + +f = accumulator(1) +console.log f(5) +console.log f(2.3) diff --git a/Task/Accumulator-factory/Erlang/accumulator-factory.erl b/Task/Accumulator-factory/Erlang/accumulator-factory.erl new file mode 100644 index 0000000000..cdef2af8c9 --- /dev/null +++ b/Task/Accumulator-factory/Erlang/accumulator-factory.erl @@ -0,0 +1,17 @@ +-module(acc_factory). +-export([loop/1,new/1]). + +loop(N)-> + receive + {P,I}-> + S =N+I, P!S, loop(S) + end. + +new(N)-> + P=spawn(acc_factory,loop,[N]), + fun(I)-> + P!{self(),I}, + receive + V-> V + end + end. diff --git a/Task/Accumulator-factory/Forth/accumulator-factory.fth b/Task/Accumulator-factory/Forth/accumulator-factory.fth new file mode 100644 index 0000000000..f12f138625 --- /dev/null +++ b/Task/Accumulator-factory/Forth/accumulator-factory.fth @@ -0,0 +1,9 @@ +: accumulator + create ( n -- ) , + does> ( n -- acc+n ) tuck +! @ ; + +0 accumulator foo + +1 foo . \ 1 +2 foo . \ 3 +3 foo . \ 6 diff --git a/Task/Accumulator-factory/Go/accumulator-factory.go b/Task/Accumulator-factory/Go/accumulator-factory.go new file mode 100644 index 0000000000..509b52a99e --- /dev/null +++ b/Task/Accumulator-factory/Go/accumulator-factory.go @@ -0,0 +1,34 @@ +package main + +import "fmt" + +func accumulator(sum interface{}) func(interface{}) interface{} { + return func(nv interface{}) interface{} { + switch s := sum.(type) { + case int: + switch n := nv.(type) { + case int: + sum = s + n + case float64: + sum = float64(s) + n + } + case float64: + switch n := nv.(type) { + case int: + sum = s + float64(n) + case float64: + sum = s + n + } + default: + sum = nv + } + return sum + } +} + +func main() { + x := accumulator(1) + x(5) + accumulator(3) + fmt.Println(x(2.3)) +} diff --git a/Task/Accumulator-factory/Haskell/accumulator-factory.hs b/Task/Accumulator-factory/Haskell/accumulator-factory.hs new file mode 100644 index 0000000000..9ef056766a --- /dev/null +++ b/Task/Accumulator-factory/Haskell/accumulator-factory.hs @@ -0,0 +1,17 @@ +import Control.Monad.ST +import Data.STRef + +accumulator :: (Num a) => a -> ST s (a -> ST s a) +accumulator sum0 = do + sum <- newSTRef sum0 + return $ \n -> do + modifySTRef sum (+ n) + readSTRef sum + +main :: IO () +main = print foo + where foo = runST $ do + x <- accumulator 1 + x 5 + accumulator 3 + x 2.3 diff --git a/Task/Accumulator-factory/Java/accumulator-factory-1.java b/Task/Accumulator-factory/Java/accumulator-factory-1.java new file mode 100644 index 0000000000..408e9f5b40 --- /dev/null +++ b/Task/Accumulator-factory/Java/accumulator-factory-1.java @@ -0,0 +1,16 @@ +public class Accumulator { + private double sum; + public Accumulator(double sum0) { + sum = sum0; + } + public double call(double n) { + return sum += n; + } + + public static void main(String[] args) { + Accumulator x = new Accumulator(1); + x.call(5); + System.out.println(new Accumulator(3)); + System.out.println(x.call(2.3)); + } +} diff --git a/Task/Accumulator-factory/Java/accumulator-factory-2.java b/Task/Accumulator-factory/Java/accumulator-factory-2.java new file mode 100644 index 0000000000..5831d32b7d --- /dev/null +++ b/Task/Accumulator-factory/Java/accumulator-factory-2.java @@ -0,0 +1,19 @@ +import com.google.common.base.Function; + +public class AccumulatorFactory { + private static Function accumulator(final Double elem) { + return new Function() { + Double sum = elem; + @Override public Double apply(Double val) { + return sum += val; + } + }; + } + + public static void main(String[] args) { + Function x = accumulator(1d); + x.apply(5d); + System.out.println(accumulator(3d)); + System.out.println(x.apply(2.3)); + } +} diff --git a/Task/Accumulator-factory/Java/accumulator-factory-3.java b/Task/Accumulator-factory/Java/accumulator-factory-3.java new file mode 100644 index 0000000000..99c7f67e49 --- /dev/null +++ b/Task/Accumulator-factory/Java/accumulator-factory-3.java @@ -0,0 +1,30 @@ +public class Accumulator { + private Long sumA; // non-null if we're working in the integer domain + private double sumB; + public Accumulator(Number sum0) { + if (sum0 instanceof Double) { + sumB = sum0.doubleValue(); + } else { + sumA = sum0.longValue(); + } + } + public Number call(Number n) { + if (sumA != null) { + if (n instanceof Double) { + sumB = n.doubleValue() + sumA; + sumA = null; + return sumB; + } + return sumA += n.longValue(); + } + return sumB += n.doubleValue(); + } + + public static void main(String[] args) { + Accumulator x = new Accumulator(1); + x.call(5); + Accumulator y = new Accumulator(3); + System.out.println(y+" has value "+y.call(0)); + System.out.println(x.call(2.3)); + } +} diff --git a/Task/Accumulator-factory/JavaScript/accumulator-factory-1.js b/Task/Accumulator-factory/JavaScript/accumulator-factory-1.js new file mode 100644 index 0000000000..cda963ad42 --- /dev/null +++ b/Task/Accumulator-factory/JavaScript/accumulator-factory-1.js @@ -0,0 +1,9 @@ +function accumulator(sum) { + return function(n) { + return sum += n; + } +} +var x = accumulator(1); +x(5); +document.write(accumulator(3).toString() + '
'); +document.write(x(2.3)); diff --git a/Task/Accumulator-factory/JavaScript/accumulator-factory-2.js b/Task/Accumulator-factory/JavaScript/accumulator-factory-2.js new file mode 100644 index 0000000000..59ab2114e3 --- /dev/null +++ b/Task/Accumulator-factory/JavaScript/accumulator-factory-2.js @@ -0,0 +1,5 @@ +function accumulator(sum) function(n) sum += n; +var x = accumulator(1); +x(5); +console.log(accumulator(3).toSource()); +console.log(x(2.3)); diff --git a/Task/Accumulator-factory/Lua/accumulator-factory-1.lua b/Task/Accumulator-factory/Lua/accumulator-factory-1.lua new file mode 100644 index 0000000000..8091e4f8b9 --- /dev/null +++ b/Task/Accumulator-factory/Lua/accumulator-factory-1.lua @@ -0,0 +1,7 @@ +function acc(init) + init = init or 0 + return function(delta) + init = init + (delta or 0) + return init + end +end diff --git a/Task/Accumulator-factory/Lua/accumulator-factory-2.lua b/Task/Accumulator-factory/Lua/accumulator-factory-2.lua new file mode 100644 index 0000000000..212c48890b --- /dev/null +++ b/Task/Accumulator-factory/Lua/accumulator-factory-2.lua @@ -0,0 +1,13 @@ +do + local accSum = 0; -- accumulator factory 'upvalue' + function acc(v) -- the accumulator factory + accSum = accSum + (v or 0) -- increment factory sum + + local closuredSum = accSum; -- new 'upvalue' at each factory call + return function (w) -- the produced accumulator function + closuredSum = closuredSum + (w or 0) -- increment product 'upvalue' + return closuredSum -- return 'upvalue' + end, accSum -- end of product closure + + end--acc +end--end of factory closure diff --git a/Task/Accumulator-factory/Lua/accumulator-factory-3.lua b/Task/Accumulator-factory/Lua/accumulator-factory-3.lua new file mode 100644 index 0000000000..c4336f9b8f --- /dev/null +++ b/Task/Accumulator-factory/Lua/accumulator-factory-3.lua @@ -0,0 +1,6 @@ +x = acc(1) -- x stores the product with initial value = 1 +x(5) -- add 5 to x's sum +acc(3) -- add 3 to factory's sum +print (x(2.3)) --> 8.3 -- add 2.3 to x's sum then print the result +y = acc() -- create new function with factory's sum as initial value +print (y()) --> 4 -- print the accumulated value inside the product y diff --git a/Task/Accumulator-factory/PHP/accumulator-factory-1.php b/Task/Accumulator-factory/PHP/accumulator-factory-1.php new file mode 100644 index 0000000000..05343146ee --- /dev/null +++ b/Task/Accumulator-factory/PHP/accumulator-factory-1.php @@ -0,0 +1,8 @@ + diff --git a/Task/Accumulator-factory/PHP/accumulator-factory-2.php b/Task/Accumulator-factory/PHP/accumulator-factory-2.php new file mode 100644 index 0000000000..ca8e5e5d74 --- /dev/null +++ b/Task/Accumulator-factory/PHP/accumulator-factory-2.php @@ -0,0 +1,8 @@ + diff --git a/Task/Accumulator-factory/Perl/accumulator-factory.pl b/Task/Accumulator-factory/Perl/accumulator-factory.pl new file mode 100644 index 0000000000..b217520dc2 --- /dev/null +++ b/Task/Accumulator-factory/Perl/accumulator-factory.pl @@ -0,0 +1,9 @@ +sub accumulator { + my $sum = shift; + sub { $sum += shift } +} + +my $x = accumulator(1); +$x->(5); +print accumulator(3), "\n"; +print $x->(2.3), "\n"; diff --git a/Task/Accumulator-factory/PicoLisp/accumulator-factory.l b/Task/Accumulator-factory/PicoLisp/accumulator-factory.l new file mode 100644 index 0000000000..a9f697d57b --- /dev/null +++ b/Task/Accumulator-factory/PicoLisp/accumulator-factory.l @@ -0,0 +1,8 @@ +(de accumulator (Sum) + (curry (Sum) (N) + (inc 'Sum N) ) ) + +(def 'a (accumulator 7)) +(a 1) # Output: -> 8 +(a 2) # Output: -> 10 +(a -5) # Output: -> 5 diff --git a/Task/Accumulator-factory/Prolog/accumulator-factory.pro b/Task/Accumulator-factory/Prolog/accumulator-factory.pro new file mode 100644 index 0000000000..1b8c1791ac --- /dev/null +++ b/Task/Accumulator-factory/Prolog/accumulator-factory.pro @@ -0,0 +1,15 @@ +:- use_module(library(lambda)). + +define_g(N, G) :- + put_attr(V, user, N), + G = V +\X^Y^(get_attr(V, user, N1), + Y is X + N1, + put_attr(V, user, Y)). + +accumulator :- + define_g(1, G), + format('Code of g : ~w~n', [G]), + call(G, 5, S), + writeln(S), + call(G, 2.3, R1), + writeln(R1). diff --git a/Task/Accumulator-factory/Python/accumulator-factory-1.py b/Task/Accumulator-factory/Python/accumulator-factory-1.py new file mode 100644 index 0000000000..e615e3756b --- /dev/null +++ b/Task/Accumulator-factory/Python/accumulator-factory-1.py @@ -0,0 +1,26 @@ +>>> def accumulator(sum): + def f(n): + f.sum += n + return f.sum + f.sum = sum + return f + +>>> x = accumulator(1) +>>> x(5) +6 +>>> x(2.3) +8.3000000000000007 +>>> x = accumulator(1) +>>> x(5) +6 +>>> x(2.3) +8.3000000000000007 +>>> x2 = accumulator(3) +>>> x2(5) +8 +>>> x2(3.3) +11.300000000000001 +>>> x(0) +8.3000000000000007 +>>> x2(0) +11.300000000000001 diff --git a/Task/Accumulator-factory/Python/accumulator-factory-2.py b/Task/Accumulator-factory/Python/accumulator-factory-2.py new file mode 100644 index 0000000000..1fbcb6bc2c --- /dev/null +++ b/Task/Accumulator-factory/Python/accumulator-factory-2.py @@ -0,0 +1,11 @@ +def accumulator(sum): + def f(n): + nonlocal sum + sum += n + return sum + return f + +x = accumulator(1) +x(5) +print(accumulator(3)) +print(x(2.3)) diff --git a/Task/Accumulator-factory/Python/accumulator-factory-3.py b/Task/Accumulator-factory/Python/accumulator-factory-3.py new file mode 100644 index 0000000000..3ea2a2e7a3 --- /dev/null +++ b/Task/Accumulator-factory/Python/accumulator-factory-3.py @@ -0,0 +1,9 @@ +def accumulator(sum): + while True: + sum += yield sum + +x = accumulator(1) +x.send(None) +x.send(5) +print(accumulator(3)) +print(x.send(2.3)) diff --git a/Task/Accumulator-factory/R/accumulator-factory.r b/Task/Accumulator-factory/R/accumulator-factory.r new file mode 100644 index 0000000000..e8ef5411d1 --- /dev/null +++ b/Task/Accumulator-factory/R/accumulator-factory.r @@ -0,0 +1,7 @@ +accumulatorFactory <- function(init) { + currentSum <- init + function(add) { + currentSum <<- currentSum + add + currentSum + } +} diff --git a/Task/Accumulator-factory/REXX/accumulator-factory.rexx b/Task/Accumulator-factory/REXX/accumulator-factory.rexx new file mode 100644 index 0000000000..4256c1ca7a --- /dev/null +++ b/Task/Accumulator-factory/REXX/accumulator-factory.rexx @@ -0,0 +1,13 @@ +/*REXX pgm: acculation factory copied/modeled after the ooRexx program. */ +x=.accumulator(new(1)) /*set accumulater with init val 1*/ +x=call(5) +x=call(2.3) +say " X value is now" x /*displays current value of X. */ +say "Accumulator value is now" sum /*displays current value of accum*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────subroutines─────────────────────────*/ +.accumulator: procedure expose sum + if symbol('SUM')=='LIT' then sum=0; sum=sum+arg(1) + return sum +call: procedure expose sum; sum=sum+arg(1); return sum /*adds arg1──►sum*/ +new: procedure; return arg(1) /*long way 'round of using one. */ diff --git a/Task/Accumulator-factory/Racket/accumulator-factory.rkt b/Task/Accumulator-factory/Racket/accumulator-factory.rkt new file mode 100644 index 0000000000..9786773767 --- /dev/null +++ b/Task/Accumulator-factory/Racket/accumulator-factory.rkt @@ -0,0 +1,6 @@ +#lang racket + +(define (accumulator n) + (lambda (i) + (set! n (+ n i)) + n)) diff --git a/Task/Accumulator-factory/Ruby/accumulator-factory.rb b/Task/Accumulator-factory/Ruby/accumulator-factory.rb new file mode 100644 index 0000000000..c72af7eaa6 --- /dev/null +++ b/Task/Accumulator-factory/Ruby/accumulator-factory.rb @@ -0,0 +1,30 @@ +def accumulator(sum) + lambda {|n| sum += n} +end + +# mixing Integer and Float +x = accumulator(1) +x.call(5) +p accumulator(3) # add some output to show what it returns +puts x.call(2.3) # prints 8.3 + +# mixing Rational and Complex +require 'rational' +require 'complex' +y = accumulator(Rational(2, 3)) +y.call(Rational(1, 2)) +puts y.call(4) +puts y.call(Complex(0, 1)) +puts y.call(Complex.polar(6, 5 * Math::PI / 4)) +puts x.call(0) # again prints 8.3 + +# using other things that have a + method +t = accumulator(Time.utc(1999, 8, 7, 6, 5)) +puts t.call(4) # prints 1999-08-07 06:05:04 UTC + +require 'matrix' +m = accumulator(Matrix[[1, 2], [3, 4]]) +puts m.call(Matrix[[5, 6], [7, 8]]) +puts t.call(-12 * 60 * 60) # subtracts 12 hours +puts y.call(1e200) +puts x.call(0) # again prints 8.3 diff --git a/Task/Accumulator-factory/Scala/accumulator-factory.scala b/Task/Accumulator-factory/Scala/accumulator-factory.scala new file mode 100644 index 0000000000..a0607545ee --- /dev/null +++ b/Task/Accumulator-factory/Scala/accumulator-factory.scala @@ -0,0 +1,8 @@ +def AccumulatorFactory[N](n: N)(implicit num: Numeric[N]) = { + import num._ + var acc = n + (inc: N) => { + acc = acc + inc + acc + } +} diff --git a/Task/Accumulator-factory/Scheme/accumulator-factory.ss b/Task/Accumulator-factory/Scheme/accumulator-factory.ss new file mode 100644 index 0000000000..e35ab6a49a --- /dev/null +++ b/Task/Accumulator-factory/Scheme/accumulator-factory.ss @@ -0,0 +1,15 @@ +(define (accumulator sum) + (lambda (n) + (set! sum (+ sum n)) + sum)) + +;; or: + +(define ((accumulator sum) n) + (set! sum (+ sum n)) + sum) + +(define x (accumulator 1)) +(x 5) +(display (accumulator 3)) (newline) +(display (x 2.3)) (newline) diff --git a/Task/Accumulator-factory/Smalltalk/accumulator-factory-1.st b/Task/Accumulator-factory/Smalltalk/accumulator-factory-1.st new file mode 100644 index 0000000000..411a63e1fb --- /dev/null +++ b/Task/Accumulator-factory/Smalltalk/accumulator-factory-1.st @@ -0,0 +1,19 @@ +Object subclass: AccumulatorFactory [ + AccumulatorFactory class >> new: aNumber [ + |r sum| + sum := aNumber. + r := [ :a | + sum := sum + a. + sum + ]. + ^r + ] +] + +|x y| +x := AccumulatorFactory new: 1. +x value: 5. +y := AccumulatorFactory new: 3. +(x value: 2.3) displayNl. +"x inspect." +"de-comment the previous line to show that x is a block closure" diff --git a/Task/Accumulator-factory/Smalltalk/accumulator-factory-2.st b/Task/Accumulator-factory/Smalltalk/accumulator-factory-2.st new file mode 100644 index 0000000000..793ecac770 --- /dev/null +++ b/Task/Accumulator-factory/Smalltalk/accumulator-factory-2.st @@ -0,0 +1,15 @@ +|factory a| + +factory := [:initial | + [ + |sum| + + sum := initial. + [:addend | sum := sum + addend]. + ] value. +]. + +a := factory value:1. +a value:5. +factory value:3. +(a value:2.3) printCR "-> 8.3 " diff --git a/Task/Accumulator-factory/Tcl/accumulator-factory-1.tcl b/Task/Accumulator-factory/Tcl/accumulator-factory-1.tcl new file mode 100644 index 0000000000..7df4b1ef38 --- /dev/null +++ b/Task/Accumulator-factory/Tcl/accumulator-factory-1.tcl @@ -0,0 +1,28 @@ +package require Tcl 8.6 + +# make the creation of coroutines without procedures simpler +proc coro {name arguments body args} { + coroutine $name apply [list $arguments $body] {*}$args +} +# Wrap the feeding of values in and out of a generator +proc coloop {var body} { + set val [info coroutine] + upvar 1 $var v + while 1 { + set v [yield $val] + if {$v eq "stop"} break + set val [uplevel 1 $body] + } +} + +# The outer coroutine is the accumulator factory +# The inner coroutine is the particular accumulator +coro accumulator {} { + coloop n { + coro accumulator.[incr counter] n { + coloop i { + set n [expr {$n + $i}] + } + } $n + } +} diff --git a/Task/Accumulator-factory/Tcl/accumulator-factory-2.tcl b/Task/Accumulator-factory/Tcl/accumulator-factory-2.tcl new file mode 100644 index 0000000000..dd540c84cb --- /dev/null +++ b/Task/Accumulator-factory/Tcl/accumulator-factory-2.tcl @@ -0,0 +1,8 @@ +% set x [accumulator 1] +::accumulator.1 +% $x 5 +6 +% accumulator 3 +::accumulator.2 +% puts ">>[$x 2.3]<<" +>>8.3<< diff --git a/Task/Active-Directory-Connect/0DESCRIPTION b/Task/Active-Directory-Connect/0DESCRIPTION new file mode 100644 index 0000000000..6a8a406640 --- /dev/null +++ b/Task/Active-Directory-Connect/0DESCRIPTION @@ -0,0 +1 @@ +The task is to establish a connection to an Active Directory or Lightweight Directory Access Protocol server. diff --git a/Task/Active-Directory-Connect/1META.yaml b/Task/Active-Directory-Connect/1META.yaml new file mode 100644 index 0000000000..f6d82c59ad --- /dev/null +++ b/Task/Active-Directory-Connect/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming environment operations diff --git a/Task/Active-Directory-Connect/AutoHotkey/active-directory-connect.ahk b/Task/Active-Directory-Connect/AutoHotkey/active-directory-connect.ahk new file mode 100644 index 0000000000..a866cf0f96 --- /dev/null +++ b/Task/Active-Directory-Connect/AutoHotkey/active-directory-connect.ahk @@ -0,0 +1,4 @@ +objConn := CreateObject("ADODB.Connection") +objCmd := CreateObject("ADODB.Command") +objConn.Provider := "ADsDSOObject" +objConn.Open() diff --git a/Task/Active-Directory-Connect/AutoIt/active-directory-connect.autoit b/Task/Active-Directory-Connect/AutoIt/active-directory-connect.autoit new file mode 100644 index 0000000000..21c0bf11dc --- /dev/null +++ b/Task/Active-Directory-Connect/AutoIt/active-directory-connect.autoit @@ -0,0 +1,2 @@ + #include +_AD_Open() diff --git a/Task/Active-Directory-Connect/C/active-directory-connect.c b/Task/Active-Directory-Connect/C/active-directory-connect.c new file mode 100644 index 0000000000..1cc29b4f38 --- /dev/null +++ b/Task/Active-Directory-Connect/C/active-directory-connect.c @@ -0,0 +1,8 @@ +#include +... +char *name, *password; +... +LDAP *ld = ldap_init("ldap.somewhere.com", 389); +ldap_simple_bind_s(ld, name, password); +... after done with it... +ldap_unbind(ld); diff --git a/Task/Active-Directory-Connect/Java/active-directory-connect.java b/Task/Active-Directory-Connect/Java/active-directory-connect.java new file mode 100644 index 0000000000..64f3b0bea7 --- /dev/null +++ b/Task/Active-Directory-Connect/Java/active-directory-connect.java @@ -0,0 +1,59 @@ +import java.io.IOException; + +import org.apache.directory.ldap.client.api.LdapConnection; +import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.shared.ldap.model.cursor.EntryCursor; +import org.apache.directory.shared.ldap.model.entry.Entry; +import org.apache.directory.shared.ldap.model.exception.LdapException; +import org.apache.directory.shared.ldap.model.message.SearchScope; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RDirectoryLDAP { + + static final Logger log_; + private static final String ldapHostName; + private static final int ldapPort; + private static LdapConnection connection; + + static { + log_ = LoggerFactory.getLogger(RDirectoryLDAP.class); + connection = null; + ldapHostName = "localhost"; + ldapPort = 10389; + } + + public static void main(String[] args) { + try { + if (log_.isInfoEnabled()) { log_.info("LDAP Connection to " + ldapHostName + " on port " + ldapPort); } + connection = new LdapNetworkConnection(ldapHostName, ldapPort); + + try { + if (log_.isTraceEnabled()) { log_.trace("LDAP bind"); } + connection.bind(); + + if (log_.isTraceEnabled()) { log_.trace("LDAP unbind"); } + connection.unBind(); + } + catch (LdapException lex) { + log_.error("LDAP Error", lex); + } + catch (IOException ex) { + log_.error("I/O Error", ex); + } + } + finally { + if (log_.isTraceEnabled()) { log_.trace("LDAP close connection"); } + try { + if (connection != null) { + connection.close(); + } + } + catch (IOException ex) { + log_.error("I/O Error on connection.close()", ex); + } + } + + return; + } +} diff --git a/Task/Active-Directory-Connect/PHP/active-directory-connect.php b/Task/Active-Directory-Connect/PHP/active-directory-connect.php new file mode 100644 index 0000000000..262c507a8e --- /dev/null +++ b/Task/Active-Directory-Connect/PHP/active-directory-connect.php @@ -0,0 +1,3 @@ +new('ldap://ldap.example.com') or die $@; +my $mesg = $ldap->bind( $bind_dn, password => $bind_pass ); diff --git a/Task/Active-Directory-Connect/PicoLisp/active-directory-connect.l b/Task/Active-Directory-Connect/PicoLisp/active-directory-connect.l new file mode 100644 index 0000000000..d54ff16611 --- /dev/null +++ b/Task/Active-Directory-Connect/PicoLisp/active-directory-connect.l @@ -0,0 +1,4 @@ +(unless (=0 (setq Ldap (native "libldap.so" "ldap_open" 'N "example.com" 389))) + (quit "Can't open LDAP") ) + +(native "libldap.so" "ldap_simple_bind_s" 'I Ldap "user" "password") diff --git a/Task/Active-Directory-Connect/Python/active-directory-connect.py b/Task/Active-Directory-Connect/Python/active-directory-connect.py new file mode 100644 index 0000000000..e9dd90d322 --- /dev/null +++ b/Task/Active-Directory-Connect/Python/active-directory-connect.py @@ -0,0 +1,10 @@ +import ldap + +l = ldap.initialize("ldap://ldap.example.com") +try: + l.protocol_version = ldap.VERSION3 + l.set_option(ldap.OPT_REFERRALS, 0) + + bind = l.simple_bind_s("me@example.com", "password") +finally: + l.unbind() diff --git a/Task/Active-Directory-Connect/Ruby/active-directory-connect.rb b/Task/Active-Directory-Connect/Ruby/active-directory-connect.rb new file mode 100644 index 0000000000..cc95a72e16 --- /dev/null +++ b/Task/Active-Directory-Connect/Ruby/active-directory-connect.rb @@ -0,0 +1,4 @@ +require 'rubygems' +require 'net/ldap' +ldap = Net::LDAP.new(:host => 'ldap.example.com', :base => 'o=companyname') +ldap.authenticate('bind_dn', 'bind_pass') diff --git a/Task/Active-Directory-Connect/Tcl/active-directory-connect.tcl b/Task/Active-Directory-Connect/Tcl/active-directory-connect.tcl new file mode 100644 index 0000000000..fb00383228 --- /dev/null +++ b/Task/Active-Directory-Connect/Tcl/active-directory-connect.tcl @@ -0,0 +1,3 @@ +package require ldap +set conn [ldap::connect $host $port] +ldap::bind $conn $user $password diff --git a/Task/Active-Directory-Search-for-a-user/0DESCRIPTION b/Task/Active-Directory-Search-for-a-user/0DESCRIPTION new file mode 100644 index 0000000000..54cd357d39 --- /dev/null +++ b/Task/Active-Directory-Search-for-a-user/0DESCRIPTION @@ -0,0 +1 @@ +Make sure you [[Connect to Active Directory]] diff --git a/Task/Active-Directory-Search-for-a-user/1META.yaml b/Task/Active-Directory-Search-for-a-user/1META.yaml new file mode 100644 index 0000000000..f6d82c59ad --- /dev/null +++ b/Task/Active-Directory-Search-for-a-user/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming environment operations diff --git a/Task/Active-Directory-Search-for-a-user/C/active-directory-search-for-a-user.c b/Task/Active-Directory-Search-for-a-user/C/active-directory-search-for-a-user.c new file mode 100644 index 0000000000..6734a6c57a --- /dev/null +++ b/Task/Active-Directory-Search-for-a-user/C/active-directory-search-for-a-user.c @@ -0,0 +1,21 @@ +#include + +char *name, *password; +... + +LDAP *ld = ldap_init("ldap.somewhere.com", 389); +ldap_simple_bind_s(ld, name, password); + +LDAPMessage **result; +ldap_search_s(ld, "dc=somewhere,dc=com", LDAP_SCOPE_SUBTREE, + /* search for all persons whose names start with joe or shmoe */ + "(&(objectclass=person)(|(cn=joe*)(cn=shmoe*)))", + NULL, /* return all attributes */ + 0, /* want both types and values of attrs */ + result); /* ldap will allocate room for return messages */ + +/* arduously do stuff here to result, with ldap_first_message(), + ldap_parse_result(), etc. */ + +ldap_msgfree(*result); /* free messages */ +ldap_unbind(ld); /* disconnect */ diff --git a/Task/Active-Directory-Search-for-a-user/Java/active-directory-search-for-a-user.java b/Task/Active-Directory-Search-for-a-user/Java/active-directory-search-for-a-user.java new file mode 100644 index 0000000000..42097890fe --- /dev/null +++ b/Task/Active-Directory-Search-for-a-user/Java/active-directory-search-for-a-user.java @@ -0,0 +1,153 @@ +import java.io.IOException; +import java.util.Arrays; + +import org.apache.directory.ldap.client.api.LdapConnection; +import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.shared.ldap.model.cursor.EntryCursor; +import org.apache.directory.shared.ldap.model.entry.Entry; +import org.apache.directory.shared.ldap.model.exception.LdapException; +import org.apache.directory.shared.ldap.model.message.SearchScope; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class RDirectorySearchLDAP { + + protected static final Logger log_; + private static LdapConnection connection; + private static final String ldapHostName; + private static final int ldapPort; + private static final String ldapDnStr; + private static final String ldapCreds; + + static { + + log_ = LoggerFactory.getLogger(RDirectorySearchLDAP.class); + + ldapHostName = "localhost"; + ldapPort = 11389; + ldapDnStr="uid=admin,ou=system"; + ldapCreds="********"; + } + + public static void main(String[] args) { + + boolean connected = false; + + try { + connected = setUp(); + if (connected) { + search("*mil*"); + } + } + finally { + if (connected) { + tearDown(); + } + } + + return; + } + + private static boolean search(String uid) { + + boolean state; + EntryCursor cursor; + Entry ev; + String baseDn; + String filter; + SearchScope scope; + String attributes[]; + int ksearch = 0; + + state = true; + + baseDn = "ou=users,o=mojo"; + filter = "(&(objectClass=person)(&(uid=" + uid + ")))"; + scope = SearchScope.SUBTREE; + attributes = new java.lang.String[] { "dn", "cn", "sn", "uid" }; + + try { + if (log_.isTraceEnabled()) { log_.trace("LDAP search"); } + if (log_.isInfoEnabled()) { + log_.info("Begin search"); + log_.info(" search base distinguished name: " + baseDn); + log_.info(" search filter: " + filter); + log_.info(" search attributes: " + (Arrays.asList(attributes).toString())); + } + cursor = connection.search(baseDn, filter, scope, attributes); + while (cursor.next()) { + ksearch++; + ev = cursor.get(); + if (log_.isInfoEnabled()) { log_.info("Search cursor entry count: " + ksearch); } + if (log_.isInfoEnabled()) { log_.info(ev.toString()); } + } + } + catch (LdapException lex) { + state = false; + log_.error("LDAP Error in cursor loop: Iteration " + ksearch, lex); + } + catch (Exception ex) { + state = false; + log_.error("I/O Error in cursor loop: Iteration " + ksearch, ex); + } + + return state; + } + + private static boolean search() { + + return search("*"); + } + + private static boolean setUp() { + + boolean state = false; + + try { + if (log_.isInfoEnabled()) { log_.info("LDAP Connection to " + ldapHostName + " on port " + ldapPort); } + connection = new LdapNetworkConnection(ldapHostName, ldapPort); + + if (log_.isTraceEnabled()) { log_.trace("LDAP bind"); } + connection.bind(ldapDnStr, ldapCreds); + + state = true; + } + catch (LdapException lex) { + state = false; + log_.error("LDAP Error", lex); + } + catch (IOException iox) { + state = false; + log_.error("I/O Error", iox); + } + + return state; + } + + private static boolean tearDown() { + + boolean state = false; + + try { + if (log_.isTraceEnabled()) { log_.trace("LDAP unbind"); } + connection.unBind(); + state = true; + } + catch (LdapException lex) { + state = false; + log_.error("LDAP Error", lex); + } + finally { + try { + connection.close(); + } + catch (IOException iox) { + state = false; + log_.error("I/O Error on connection.close()", iox); + } + } + + return state; + } +} diff --git a/Task/Active-Directory-Search-for-a-user/PHP/active-directory-search-for-a-user.php b/Task/Active-Directory-Search-for-a-user/PHP/active-directory-search-for-a-user.php new file mode 100644 index 0000000000..639cf7ca89 --- /dev/null +++ b/Task/Active-Directory-Search-for-a-user/PHP/active-directory-search-for-a-user.php @@ -0,0 +1,16 @@ + 'hostname', :base => 'base') +ldap.authenticate('bind_dn', 'bind_pass') + +filter = Net::LDAP::Filter.pres('objectclass') +filter &= Net::LDAP::Filter.eq('sn','Jackman') +# or +filter = Net::LDAP::Filter.construct('(&(objectclass=*)(sn=Jackman))') + +results = ldap.search(:filter => filter) # returns an array of Net::LDAP::Entry objects + +puts results[0][:sn] # ==> "Jackman" diff --git a/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-1.tcl b/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-1.tcl new file mode 100644 index 0000000000..ed8e7aa8d2 --- /dev/null +++ b/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-1.tcl @@ -0,0 +1,4 @@ +set Username "TestUser" +set Filter "((&objectClass=*)(sAMAccountName=$Username))" +set Base "dc=skycityauckland,dc=sceg,dc=com" +set Attrs distinguishedName diff --git a/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-2.tcl b/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-2.tcl new file mode 100644 index 0000000000..a4b6ccdf9a --- /dev/null +++ b/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-2.tcl @@ -0,0 +1 @@ +set result [ldap::search $conn $Base $Filter $Attrs -scope subtree] diff --git a/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-3.tcl b/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-3.tcl new file mode 100644 index 0000000000..a96a01e803 --- /dev/null +++ b/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-3.tcl @@ -0,0 +1,3 @@ +if {[llength $result] == 1} { + puts [dict get [lindex $result 0 1] distinguishedName] +} diff --git a/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-4.tcl b/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-4.tcl new file mode 100644 index 0000000000..5773eb436c --- /dev/null +++ b/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-4.tcl @@ -0,0 +1,4 @@ +foreach pair $result { + lassign $pair cn attributes + puts [dict get $attributes distinguishedName] +} diff --git a/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-5.tcl b/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-5.tcl new file mode 100644 index 0000000000..45c466b9de --- /dev/null +++ b/Task/Active-Directory-Search-for-a-user/Tcl/active-directory-search-for-a-user-5.tcl @@ -0,0 +1,5 @@ +package require ldapx +set conn [ldapx::connect $BindDN $Password] +$conn traverse $Base $Filter $Attrs e { + puts [$e get distinguishedName] +} diff --git a/Task/Active-object/0DESCRIPTION b/Task/Active-object/0DESCRIPTION new file mode 100644 index 0000000000..e791de2798 --- /dev/null +++ b/Task/Active-object/0DESCRIPTION @@ -0,0 +1,17 @@ +In [[object-oriented programming]] an object is active when its state depends on clock. Usually an active object encapsulates a [[task]] that updates the object's state. To the outer world the object looks like a normal object with methods that can be called from outside. Implementation of such methods must have a certain synchronization mechanism with the encapsulated task in order to prevent object's state corruption. + +A typical instance of an active object is an animation widget. The widget state changes with the time, while as an object it has all properties of a normal widget. + +'''The task''' + +Implement an active integrator object. The object has an input and output. The input can be set using the method ''Input''. The input is a function of time. The output can be queried using the method ''Output''. The object integrates its input over the time and the result becomes the object's output. So if the input is ''K''(''t'') and the output is ''S'', the object state ''S'' is changed to ''S'' + (''K''(''t''1) + ''K''(''t''0)) * (''t''1 - ''t''0) / 2, i.e. it integrates ''K'' using the trapeze method. Initially ''K'' is constant 0 and ''S'' is 0. + +In order to test the object: +# set its input to sin (2Ο€ ''f t''), where the frequency ''f''=0.5Hz. The phase is irrelevant. +# wait 2s +# set the input to constant 0 +# wait 0.5s + +Verify that now the object's output is approximately 0 (the sine has the period of 2s). The accuracy of the result will depend on the [[OS]] scheduler time slicing and the accuracy of the clock. + +{{omit from|VBScript}} diff --git a/Task/Active-object/1META.yaml b/Task/Active-object/1META.yaml new file mode 100644 index 0000000000..60fc34b137 --- /dev/null +++ b/Task/Active-object/1META.yaml @@ -0,0 +1,8 @@ +--- +category: +- Object oriented +note: Concurrency +requires: +- Concurrency +- Objects +- Mutable State diff --git a/Task/Active-object/Ada/active-object.ada b/Task/Active-object/Ada/active-object.ada new file mode 100644 index 0000000000..c8410cb4d4 --- /dev/null +++ b/Task/Active-object/Ada/active-object.ada @@ -0,0 +1,65 @@ +with Ada.Calendar; use Ada.Calendar; +with Ada.Numerics; use Ada.Numerics; +with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Integrator is + type Func is access function (T : Time) return Float; + + function Zero (T : Time) return Float is + begin + return 0.0; + end Zero; + + Epoch : constant Time := Clock; + + function Sine (T : Time) return Float is + begin + return Sin (Pi * Float (T - Epoch)); + end Sine; + + task type Integrator is + entry Input (Value : Func); + entry Output (Value : out Float); + entry Shut_Down; + end Integrator; + + task body Integrator is + K : Func := Zero'Access; + S : Float := 0.0; + F0 : Float := 0.0; + F1 : Float; + T0 : Time := Clock; + T1 : Time; + begin + loop + select + accept Input (Value : Func) do + K := Value; + end Input; + or accept Output (Value : out Float) do + Value := S; + end Output; + or accept Shut_Down; + exit; + else + T1 := Clock; + F1 := K (T1); + S := S + 0.5 * (F1 + F0) * Float (T1 - T0); + T0 := T1; + F0 := F1; + end select; + end loop; + end Integrator; + + I : Integrator; + S : Float; +begin + I.Input (Sine'Access); + delay 2.0; + I.Input (Zero'Access); + delay 0.5; + I.Output (S); + Put_Line ("Integrated" & Float'Image (S) & "s"); + I.Shut_Down; +end Test_Integrator; diff --git a/Task/Active-object/C/active-object.c b/Task/Active-object/C/active-object.c new file mode 100644 index 0000000000..8954540096 --- /dev/null +++ b/Task/Active-object/C/active-object.c @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include +#include + +/* no need to lock the object: at worst the readout would be 1 tick off, + which is no worse than integrator's inate inaccuracy */ +typedef struct { + double (*func)(double); + struct timeval start; + double v, last_v, last_t; + pthread_t id; +} integ_t, *integ; + +void update(integ x) +{ + struct timeval tv; + double t, v, (*f)(double); + + f = x->func; + gettimeofday(&tv, 0); + t = ((tv.tv_sec - x->start.tv_sec) * 1000000 + + tv.tv_usec - x->start.tv_usec) * 1e-6; + v = f ? f(t) : 0; + x->v += (x->last_v + v) * (t - x->last_t) / 2; + x->last_t = t; +} + +void* tick(void *a) +{ + integ x = a; + while (1) { + usleep(100000); /* update every .1 sec */ + update(x); + } +} + +void set_input(integ x, double (*func)(double)) +{ + update(x); + x->func = func; + x->last_t = 0; + x->last_v = func ? func(0) : 0; +} + +integ new_integ(double (*func)(double)) +{ + integ x = malloc(sizeof(integ_t)); + x->v = x->last_v = 0; + x->func = 0; + gettimeofday(&x->start, 0); + set_input(x, func); + pthread_create(&x->id, 0, tick, x); + return x; +} + +double sine(double t) { return sin(4 * atan2(1, 1) * t); } + +int main() +{ + integ x = new_integ(sine); + sleep(2); + set_input(x, 0); + usleep(500000); + printf("%g\n", x->v); + + return 0; +} diff --git a/Task/Active-object/Clojure/active-object.clj b/Task/Active-object/Clojure/active-object.clj new file mode 100644 index 0000000000..acbd88bc54 --- /dev/null +++ b/Task/Active-object/Clojure/active-object.clj @@ -0,0 +1,36 @@ +(ns active-object + (:import (java.util Timer TimerTask))) + +(defn input [integrator k] + (send integrator assoc :k k)) + +(defn output [integrator] + (:s @integrator)) + +(defn tick [integrator t1] + (send integrator + (fn [{:keys [k s t0] :as m}] + (assoc m :s (+ s (/ (* (+ (k t1) (k t0)) (- t1 t0)) 2.0)) :t0 t1)))) + +(defn start-timer [integrator interval] + (let [timer (Timer. true) + start (System/currentTimeMillis)] + (.scheduleAtFixedRate timer + (proxy [TimerTask] [] + (run [] (tick integrator (double (/ (- (System/currentTimeMillis) start) 1000))))) + (long 0) + (long interval)) + #(.cancel timer))) + +(defn test-integrator [] + (let [integrator (agent {:k (constantly 0.0) :s 0.0 :t0 0.0}) + stop-timer (start-timer integrator 10)] + (input integrator #(Math/sin (* 2.0 Math/PI 0.5 %))) + (Thread/sleep 2000) + (input integrator (constantly 0.0)) + (Thread/sleep 500) + (println (output integrator)) + (stop-timer))) + +user> (test-integrator) +1.414065859052494E-5 diff --git a/Task/Active-object/Go/active-object.go b/Task/Active-object/Go/active-object.go new file mode 100644 index 0000000000..3673973aa6 --- /dev/null +++ b/Task/Active-object/Go/active-object.go @@ -0,0 +1,80 @@ +package main + +import ( + "fmt" + "math" + "time" +) + +// type for input function, k. +// input is duration since an arbitrary start time t0. +type tFunc func(time.Duration) float64 + +// active integrator object. state variables are not here, but in +// function aif, started as a goroutine in the constructor. +type aio struct { + iCh chan tFunc // channel for setting input function + oCh chan chan float64 // channel for requesting output +} + +// constructor +func newAio() *aio { + var a aio + a.iCh = make(chan tFunc) + a.oCh = make(chan chan float64) + go aif(&a) + return &a +} + +// input method required by task description. in practice, this method is +// unnecessary; you would just put that single channel send statement in +// your code wherever you wanted to set the input function. +func (a aio) input(f tFunc) { + a.iCh <- f +} + +// output method required by task description. in practice, this method too +// would not likely be best. instead any client interested in the value would +// likely make a return channel sCh once, and then reuse it as needed. +func (a aio) output() float64 { + sCh := make(chan float64) + a.oCh <- sCh + return <-sCh +} + +// integration function that returns constant 0 +func zeroFunc(time.Duration) float64 { return 0 } + +// goroutine serializes access to integrated function k and state variable s +func aif(a *aio) { + var k tFunc = zeroFunc // integration function + s := 0. // "object state" initialized to 0 + t0 := time.Now() // initial time + k0 := k(0) // initial sample value + t1 := t0 // t1, k1 used for trapezoid formula + k1 := k0 + + tk := time.Tick(10 * time.Millisecond) // 10 ms -> 100 Hz + for { + select { + case t2 := <-tk: // timer tick event + k2 := k(t2.Sub(t0)) // new sample value + s += (k1 + k2) * .5 * t2.Sub(t1).Seconds() // trapezoid formula + t1, k1 = t2, k2 // save time and value + case k = <-a.iCh: // input method event: function change + case sCh := <-a.oCh: // output method event: sample object state + sCh <- s + } + } +} + +func main() { + a := newAio() // create object + a.input(func(t time.Duration) float64 { // 1. set input to sin function + return math.Sin(t.Seconds() * math.Pi) + }) + time.Sleep(2 * time.Second) // 2. sleep 2 sec + a.input(zeroFunc) // 3. set input to zero function + time.Sleep(time.Second / 2) // 4. sleep .5 sec + fmt.Println(a.output()) // output should be near zero +} diff --git a/Task/Active-object/Haskell/active-object.hs b/Task/Active-object/Haskell/active-object.hs new file mode 100644 index 0000000000..88cea31612 --- /dev/null +++ b/Task/Active-object/Haskell/active-object.hs @@ -0,0 +1,77 @@ +module Integrator ( + newIntegrator, input, output, stop, + Time, timeInterval +) where +import Control.Concurrent (forkIO, threadDelay) +import Control.Concurrent.MVar (MVar, newMVar, modifyMVar_, modifyMVar, readMVar) +import Control.Exception (evaluate) +import Data.Time (UTCTime) +import Data.Time.Clock (getCurrentTime, diffUTCTime) + +-- RC task +main = do let f = 0.5 {- Hz -} + t0 <- getCurrentTime + i <- newIntegrator + input i (\t -> sin(2*pi * f * timeInterval t0 t)) -- task step 1 + threadDelay 2000000 {- Β΅s -} -- task step 2 + input i (const 0) -- task step 3 + threadDelay 500000 {- Β΅s -} -- task step 4 + result <- output i + stop i + print result + +---- Implementation ------------------------------------------------------ + +-- Utilities for working with the time type +type Time = UTCTime +type Func a = Time -> a +timeInterval t0 t1 = realToFrac $ diffUTCTime t1 t0 + +-- Type signatures of the module's interface +newIntegrator :: Fractional a => IO (Integrator a) -- Create an integrator +input :: Integrator a -> Func a -> IO () -- Set the input function +output :: Integrator a -> IO a -- Get the current value +stop :: Integrator a -> IO () -- Stop integration, don't waste CPU + +-- Data structures +data Integrator a = Integrator (MVar (IntState a)) -- MVar is a thread-safe mutable cell + deriving Eq +data IntState a = IntState { func :: Func a, -- The current function + run :: Bool, -- Whether to keep going + value :: a, -- The current accumulated value + time :: Time } -- The time of the previous update + +newIntegrator = do + now <- getCurrentTime + state <- newMVar $ IntState { func = const 0, + run = True, + value = 0, + time = now } + thread <- forkIO (intThread state) -- The state variable is shared between the thread + return (Integrator state) -- and the client interface object. + +input (Integrator stv) f = modifyMVar_ stv (\st -> return st { func = f }) +output (Integrator stv) = fmap value $ readMVar stv +stop (Integrator stv) = modifyMVar_ stv (\st -> return st { run = False }) + -- modifyMVar_ takes an MVar and replaces its contents according to the provided function. + -- a { b = c } is record-update syntax: "the record a, except with field b changed to c" + +-- Integration thread +intThread :: Fractional a => MVar (IntState a) -> IO () +intThread stv = whileM $ modifyMVar stv updateAndCheckRun + -- modifyMVar is like modifyMVar_ but the function returns a tuple of the new value + -- and an arbitrary extra value, which in this case ends up telling whileM whether + -- to keep looping. + where updateAndCheckRun st = do + now <- getCurrentTime + let value' = integrate (func st) (value st) (time st) now + evaluate value' -- avoid undesired laziness + return (st { value = value', time = now }, -- updated state + run st) -- whether to continue + +integrate :: Fractional a => Func a -> a -> Time -> Time -> a +integrate f value t0 t1 = value + (f t0 + f t1)/2 * dt + where dt = timeInterval t0 t1 + +-- Execute 'action' until it returns false. +whileM action = do b <- action; if b then whileM action else return () diff --git a/Task/Active-object/JavaScript/active-object-1.js b/Task/Active-object/JavaScript/active-object-1.js new file mode 100644 index 0000000000..a29a35c28d --- /dev/null +++ b/Task/Active-object/JavaScript/active-object-1.js @@ -0,0 +1,26 @@ +function Integrator(sampleIntervalMS) { + var inputF = function () { return 0.0 }; + var sum = 0.0; + + var t1 = new Date().getTime(); + var input1 = inputF(t1 / 1000); + + function update() { + var t2 = new Date().getTime(); + var input2 = inputF(t2 / 1000); + var dt = (t2 - t1) / 1000; + + sum += (input1 + input2) * dt / 2; + + t1 = t2; + input1 = input2; + } + + var updater = setInterval(update, sampleIntervalMS); + + return ({ + input: function (newF) { inputF = newF }, + output: function () { return sum }, + shutdown: function () { clearInterval(updater) }, + }); +} diff --git a/Task/Active-object/JavaScript/active-object-2.js b/Task/Active-object/JavaScript/active-object-2.js new file mode 100644 index 0000000000..a0cade9633 --- /dev/null +++ b/Task/Active-object/JavaScript/active-object-2.js @@ -0,0 +1,20 @@ +

Test running... -

+ + diff --git a/Task/Active-object/Perl/active-object.pl b/Task/Active-object/Perl/active-object.pl new file mode 100644 index 0000000000..6b03d0d505 --- /dev/null +++ b/Task/Active-object/Perl/active-object.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl + +use strict; +use 5.10.0; + +package Integrator; +use threads; +use threads::shared; + +sub new { + my $cls = shift; + my $obj = bless { t => 0, + sum => 0, + ref $cls ? %$cls : (), + stop => 0, + tid => 0, + func => shift, + }, ref $cls || $cls; + + share($obj->{sum}); + share($obj->{stop}); + + $obj->{tid} = async { + my $upd = 0.1; # update every 0.1 second + while (!$obj->{stop}) { + { + my $f = $obj->{func}; + my $t = $obj->{t}; + + $obj->{sum} += ($f->($t) + $f->($t + $upd))* $upd/ 2; + $obj->{t} += $upd; + } + select(undef, undef, undef, $upd); + } + # say "stopping $obj"; + }; + $obj +} + +sub output { shift->{sum} } + +sub delete { + my $obj = shift; + $obj->{stop} = 1; + $obj->{tid}->join; +} + +sub setinput { + # This is surprisingly difficult because of the perl sharing model. + # Func refs can't be shared, thus can't be replaced by another thread. + # Have to create a whole new object... there must be a better way. + my $obj = shift; + $obj->delete; + $obj->new(shift); +} + +package main; + +my $x = Integrator->new(sub { sin(atan2(1, 1) * 8 * .5 * shift) }); + +sleep(2); +say "sin after 2 seconds: ", $x->output; + +$x = $x->setinput(sub {0}); + +select(undef, undef, undef, .5); +say "0 after .5 seconds: ", $x->output; + +$x->delete; diff --git a/Task/Active-object/PicoLisp/active-object.l b/Task/Active-object/PicoLisp/active-object.l new file mode 100644 index 0000000000..01cbb262c1 --- /dev/null +++ b/Task/Active-object/PicoLisp/active-object.l @@ -0,0 +1,44 @@ +(load "@lib/math.l") + +(class +Active) +# inp val sum usec + +(dm T () + (unless (assoc -100 *Run) # Install timer task + (task -100 100 # Update objects every 0.1 sec + (mapc 'update> *Actives) ) ) + (=: inp '((U) 0)) # Set zero input function + (=: val 0) # Initialize last value + (=: sum 0) # Initialize sum + (=: usec (usec)) # and time + (push '*Actives This) ) # Install in notification list + +(dm input> (Fun) + (=: inp Fun) ) + +(dm update> () + (let (U (usec) V ((: inp) U)) # Get current time, calculate value + (inc (:: sum) + (*/ + (+ V (: val)) # (K(t[1]) + K(t[0])) * + (- U (: usec)) # (t[1] - t[0]) / + 2.0 ) ) # 2.0 + (=: val V) + (=: usec U) ) ) + +(dm output> () + (format (: sum) *Scl) ) # Get result + +(dm stop> () + (unless (del This '*Actives) # Removing the last active object? + (task -100) ) ) # Yes: Uninstall timer task + +(de integrate () # Test it + (let Obj (new '(+Active)) # Create an active object + (input> Obj # Set input function + '((U) (sin (*/ pi U 1.0))) ) # to sin(Ο€ * t) + (wait 2000) # Wait 2 sec + (input> Obj '((U) 0)) # Reset input function + (wait 500) # Wait 0.5 sec + (prinl "Output: " (output> Obj)) # Print return value + (stop> Obj) ) ) # Stop active object diff --git a/Task/Active-object/Python/active-object.py b/Task/Active-object/Python/active-object.py new file mode 100644 index 0000000000..ee2751e0a6 --- /dev/null +++ b/Task/Active-object/Python/active-object.py @@ -0,0 +1,38 @@ +from time import time, sleep +from threading import Thread + +class Integrator(Thread): + 'continuously integrate a function `K`, at each `interval` seconds' + def __init__(self, K=lambda t:0, interval=1e-4): + Thread.__init__(self) + self.interval = interval + self.K = K + self.S = 0.0 + self.__run = True + self.start() + + def run(self): + "entry point for the thread" + interval = self.interval + start = time() + t0, k0 = 0, self.K(0) + while self.__run: + sleep(interval) + t1 = time() - start + k1 = self.K(t1) + self.S += (k1 + k0)*(t1 - t0)/2.0 + t0, k0 = t1, k1 + + def join(self): + self.__run = False + Thread.join(self) + +if __name__ == "__main__": + from math import sin, pi + + ai = Integrator(lambda t: sin(pi*t)) + sleep(2) + print ai.S + ai.K = lambda t: 0 + sleep(0.5) + print ai.S diff --git a/Task/Active-object/Racket/active-object.rkt b/Task/Active-object/Racket/active-object.rkt new file mode 100644 index 0000000000..00450fa1de --- /dev/null +++ b/Task/Active-object/Racket/active-object.rkt @@ -0,0 +1,30 @@ +#lang racket + +(require (only-in racket/gui sleep/yield timer%)) + +(define active% + (class object% + (super-new) + (init-field k) ; input function + (field [s 0]) ; state + (define t_0 0) + + (define/public (input new-k) (set! k new-k)) + (define/public (output) s) + + (define (callback) + (define t_1 (/ (- (current-inexact-milliseconds) start) 1000)) + (set! s (+ s (* (+ (k t_0) (k t_1)) + (/ (- t_1 t_0) 2)))) + (set! t_0 t_1)) + + (define start (current-inexact-milliseconds)) + (new timer% + [interval 1000] + [notify-callback callback]))) + +(define active (new active% [k (Ξ» (t) (sin (* 2 pi 0.5 t)))])) +(sleep/yield 2) +(send active input (Ξ» _ 0)) +(sleep/yield 0.5) +(displayln (send active output)) diff --git a/Task/Active-object/Scala/active-object.scala b/Task/Active-object/Scala/active-object.scala new file mode 100644 index 0000000000..eaa1874f28 --- /dev/null +++ b/Task/Active-object/Scala/active-object.scala @@ -0,0 +1,48 @@ +object ActiveObject { + + class Integrator { + + import java.util._ + import scala.actors.Actor._ + + case class Pulse(t: Double) + case class Input(k: Double => Double) + case object Output + case object Bye + + val timer = new Timer(true) + var k: Double => Double = (_ => 0.0) + var s: Double = 0.0 + var t0: Double = 0.0 + + val handler = actor { + loop { + react { + case Pulse(t1) => s += (k(t1) + k(t0)) * (t1 - t0) / 2.0; t0 = t1 + case Input(k) => this.k = k + case Output => reply(s) + case Bye => timer.cancel; exit + } + } + } + + timer.scheduleAtFixedRate(new TimerTask { + val start = System.currentTimeMillis + def run { handler ! Pulse((System.currentTimeMillis - start) / 1000.0) } + }, 0, 10) // send Pulse every 10 ms + + def input(k: Double => Double) = handler ! Input(k) + def output = handler !? Output + def bye = handler ! Bye + } + + def main(args: Array[String]) { + val integrator = new Integrator + integrator.input(t => Math.sin(2.0 * Math.Pi * 0.5 * t)) + Thread.sleep(2000) + integrator.input(_ => 0.0) + Thread.sleep(500) + println(integrator.output) + integrator.bye + } +} diff --git a/Task/Active-object/Tcl/active-object.tcl b/Task/Active-object/Tcl/active-object.tcl new file mode 100644 index 0000000000..f814fb3c2e --- /dev/null +++ b/Task/Active-object/Tcl/active-object.tcl @@ -0,0 +1,50 @@ +package require Tcl 8.6 +oo::class create integrator { + variable e sum delay tBase t0 k0 aid + constructor {{interval 1}} { + set delay $interval + set tBase [clock microseconds] + set t0 0 + set e { 0.0 } + set k0 0.0 + set sum 0.0 + set aid [after $delay [namespace code {my Step}]] + } + destructor { + after cancel $aid + } + method input expression { + set e $expression + } + method output {} { + return $sum + } + method Eval t { + expr $e + } + method Step {} { + set aid [after $delay [namespace code {my Step}]] + set t [expr {([clock microseconds] - $tBase) / 1e6}] + set k1 [my Eval $t] + set sum [expr {$sum + ($k1 + $k0) * ($t - $t0) / 2.}] + set t0 $t + set k0 $k1 + } +} + +set pi 3.14159265 +proc pause {time} { + yield [after [expr {int($time * 1000)}] [info coroutine]] +} +proc task {script} { + coroutine task_ apply [list {} "$script;set ::done ok"] + vwait done +} +task { + integrator create i + i input {sin(2*$::pi * 0.5 * $t)} + pause 2 + i input { 0.0 } + pause 0.5 + puts [format %.15f [i output]] +} diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/0DESCRIPTION b/Task/Add-a-variable-to-a-class-instance-at-runtime/0DESCRIPTION new file mode 100644 index 0000000000..9bf8e67c64 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/0DESCRIPTION @@ -0,0 +1,3 @@ +Demonstrate how to dynamically add variables to an object (a class instance) at runtime. + +This is useful when the methods/variables of an instance are based on a data file that isn't available until runtime. Hal Fulton gives an example of creating an OO CSV parser at [http://www.devsource.com/article2/0,1759,1928562,00.asp An Exercise in Metaprogramming with Ruby]. This is referred to as "monkeypatching" by Pythonistas and some others. diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/1META.yaml b/Task/Add-a-variable-to-a-class-instance-at-runtime/1META.yaml new file mode 100644 index 0000000000..43afe9a8b6 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Object oriented diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-1.as b/Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-1.as new file mode 100644 index 0000000000..4c279da8ad --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-1.as @@ -0,0 +1,2 @@ +var object:Object = new Object(); +object.foo = "bar"; diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-2.as b/Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-2.as new file mode 100644 index 0000000000..90a6423df7 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-2.as @@ -0,0 +1,7 @@ +package +{ + public dynamic class Foo + { + // ... + } +} diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-3.as b/Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-3.as new file mode 100644 index 0000000000..2a5ac21065 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/ActionScript/add-a-variable-to-a-class-instance-at-runtime-3.as @@ -0,0 +1,2 @@ +var foo:Foo = new Foo(); +foo.bar = "zap"; diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Ada/add-a-variable-to-a-class-instance-at-runtime.ada b/Task/Add-a-variable-to-a-class-instance-at-runtime/Ada/add-a-variable-to-a-class-instance-at-runtime.ada new file mode 100644 index 0000000000..599852f288 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Ada/add-a-variable-to-a-class-instance-at-runtime.ada @@ -0,0 +1,40 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Dynamic is + package Abstract_Class is + type Class is limited interface; + function Boo (X : Class) return String is abstract; + end Abstract_Class; + use Abstract_Class; + + package Base_Class is + type Base is new Class with null record; + overriding function Boo (X : Base) return String; + end Base_Class; + + package body Base_Class is + function Boo (X : Base) return String is + begin + return "I am Class"; + end Boo; + end Base_Class; + use Base_Class; + + E : aliased Base; -- An instance of Base + +begin + -- Gone run-time + declare + type Monkey_Patch (Root : access Base) is new Class with record + Foo : Integer := 1; + end record; + overriding function Boo (X : Monkey_Patch) return String; + function Boo (X : Monkey_Patch) return String is + begin -- Delegation to the base + return X.Root.Boo; + end Boo; + EE : Monkey_Patch (E'Access); -- Extend E + begin + Put_Line (EE.Boo & " with" & Integer'Image (EE.Foo)); + end; +end Dynamic; diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/AutoHotkey/add-a-variable-to-a-class-instance-at-runtime.ahk b/Task/Add-a-variable-to-a-class-instance-at-runtime/AutoHotkey/add-a-variable-to-a-class-instance-at-runtime.ahk new file mode 100644 index 0000000000..9bf090e3f9 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/AutoHotkey/add-a-variable-to-a-class-instance-at-runtime.ahk @@ -0,0 +1,2 @@ +e := {} +e.foo := 1 diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/CoffeeScript/add-a-variable-to-a-class-instance-at-runtime.coffee b/Task/Add-a-variable-to-a-class-instance-at-runtime/CoffeeScript/add-a-variable-to-a-class-instance-at-runtime.coffee new file mode 100644 index 0000000000..83ff4ce928 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/CoffeeScript/add-a-variable-to-a-class-instance-at-runtime.coffee @@ -0,0 +1,18 @@ +# CoffeeScript is dynamic, just like the Javascript it compiles to. +# You can dynamically add attributes to objects. + +# First create an object very simply. +e = {} +e.foo = "bar" +e.yo = -> "baz" +console.log e.foo, e.yo() + +# CS also has class syntax to instantiate objects, the details of which +# aren't shown here. The mechanism to add members is the same, though. +class Empty + # empty class + +e = new Empty() +e.foo = "bar" +e.yo = -> "baz" +console.log e.foo, e.yo() diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/JavaScript/add-a-variable-to-a-class-instance-at-runtime.js b/Task/Add-a-variable-to-a-class-instance-at-runtime/JavaScript/add-a-variable-to-a-class-instance-at-runtime.js new file mode 100644 index 0000000000..f429476f97 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/JavaScript/add-a-variable-to-a-class-instance-at-runtime.js @@ -0,0 +1,3 @@ +e = {} // generic object +e.foo = 1 +e["bar"] = 2 // name specified at runtime diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Lua/add-a-variable-to-a-class-instance-at-runtime.lua b/Task/Add-a-variable-to-a-class-instance-at-runtime/Lua/add-a-variable-to-a-class-instance-at-runtime.lua new file mode 100644 index 0000000000..cc2e3d1377 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Lua/add-a-variable-to-a-class-instance-at-runtime.lua @@ -0,0 +1,2 @@ +empty = {} +empty.foo = 1 diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/PHP/add-a-variable-to-a-class-instance-at-runtime.php b/Task/Add-a-variable-to-a-class-instance-at-runtime/PHP/add-a-variable-to-a-class-instance-at-runtime.php new file mode 100644 index 0000000000..e43488e051 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/PHP/add-a-variable-to-a-class-instance-at-runtime.php @@ -0,0 +1,9 @@ +class E {}; + +$e=new E(); + +$e->foo=1; + +$e->{"foo"} = 1; // using a runtime name +$x = "foo"; +$e->$x = 1; // using a runtime name in a variable diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Perl/add-a-variable-to-a-class-instance-at-runtime.pl b/Task/Add-a-variable-to-a-class-instance-at-runtime/Perl/add-a-variable-to-a-class-instance-at-runtime.pl new file mode 100644 index 0000000000..52934bd910 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Perl/add-a-variable-to-a-class-instance-at-runtime.pl @@ -0,0 +1,12 @@ +package Empty; + +# Constructor. Object is hash. +sub new { return bless {}, shift; } + +package main; + +# Object. +my $o = Empty->new; + +# Set runtime variable (key => value). +$o->{'foo'} = 1; diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/PicoLisp/add-a-variable-to-a-class-instance-at-runtime.l b/Task/Add-a-variable-to-a-class-instance-at-runtime/PicoLisp/add-a-variable-to-a-class-instance-at-runtime.l new file mode 100644 index 0000000000..d8673185f9 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/PicoLisp/add-a-variable-to-a-class-instance-at-runtime.l @@ -0,0 +1,8 @@ +: (setq MyObject (new '(+MyClass))) # Create some object +-> $385605941 +: (put MyObject 'newvar '(some value)) # Set variable +-> (some value) +: (show MyObject) # Show the object +$385605941 (+MyClass) + newvar (some value) +-> $385605941 diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-1.py b/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-1.py new file mode 100644 index 0000000000..6ab867d8ee --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-1.py @@ -0,0 +1,3 @@ +class empty(object): + pass +e = empty() diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-2.py b/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-2.py new file mode 100644 index 0000000000..10c6825167 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-2.py @@ -0,0 +1 @@ + e.foo = 1 diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-3.py b/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-3.py new file mode 100644 index 0000000000..6871c2afd3 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-3.py @@ -0,0 +1 @@ + setattr(e, name, value) diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-4.py b/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-4.py new file mode 100644 index 0000000000..5e219703e5 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Python/add-a-variable-to-a-class-instance-at-runtime-4.py @@ -0,0 +1,13 @@ +class empty(object): + def __init__(this): + this.foo = "whatever" + +def patch_empty(obj): + def fn(self=obj): + print self.foo + obj.print_output = fn + +e = empty() +patch_empty(e) +e.print_output() +# >>> whatever diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Ruby/add-a-variable-to-a-class-instance-at-runtime.rb b/Task/Add-a-variable-to-a-class-instance-at-runtime/Ruby/add-a-variable-to-a-class-instance-at-runtime.rb new file mode 100644 index 0000000000..e2f9dd38f7 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Ruby/add-a-variable-to-a-class-instance-at-runtime.rb @@ -0,0 +1,12 @@ +class Empty +end + +e = Empty.new +class << e + attr_accessor :foo +end +e.foo = 1 +puts e.foo # output: "1" + +f = Empty.new +f.foo = 1 # raises NoMethodError diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Scala/add-a-variable-to-a-class-instance-at-runtime-1.scala b/Task/Add-a-variable-to-a-class-instance-at-runtime/Scala/add-a-variable-to-a-class-instance-at-runtime-1.scala new file mode 100644 index 0000000000..2d07a31c3a --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Scala/add-a-variable-to-a-class-instance-at-runtime-1.scala @@ -0,0 +1,12 @@ +import language.dynamics +import scala.collection.mutable.HashMap + +class A extends Dynamic { + private val map = new HashMap[String, Any] + def selectDynamic(name: String): Any = { + return map(name) + } + def updateDynamic(name:String)(value: Any) = { + map(name) = value + } +} diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Scala/add-a-variable-to-a-class-instance-at-runtime-2.scala b/Task/Add-a-variable-to-a-class-instance-at-runtime/Scala/add-a-variable-to-a-class-instance-at-runtime-2.scala new file mode 100644 index 0000000000..53a6361d01 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Scala/add-a-variable-to-a-class-instance-at-runtime-2.scala @@ -0,0 +1,8 @@ +scala> val a = new A +a: A = A@7b20f29d + +scala> a.foo = 42 +a.foo: Any = 42 + +scala> a.foo +res10: Any = 42 diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-1.st b/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-1.st new file mode 100644 index 0000000000..fb58a9dc93 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-1.st @@ -0,0 +1,16 @@ +|addSlot p| + +addSlot := + [:obj :slotName | + |anonCls newObj| + anonCls := obj class + subclass:(obj class name,'+') asSymbol + instanceVariableNames:slotName + classVariableNames:'' + poolDictionaries:'' category:nil + inEnvironment:nil. + anonCls compile:('%1 ^ %1' bindWith:slotName). + anonCls compile:('%1:v %1 := v' bindWith:slotName). + newObj := anonCls cloneFrom:obj. + obj become:newObj. + ]. diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-2.st b/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-2.st new file mode 100644 index 0000000000..c4ae729fee --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-2.st @@ -0,0 +1,6 @@ +p := Point x:10 y:20. +addSlot value:p value:'z'. +p z:30. +p z. +p z:40. +p inspect diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-3.st b/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-3.st new file mode 100644 index 0000000000..d59befdfca --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-3.st @@ -0,0 +1,15 @@ +!Object methodsFor:'adding slots'! + +addSlot: slotName + |anonCls newObj| + + anonCls := self class + subclass:(self class name,'+') asSymbol + instanceVariableNames:slotName + classVariableNames:'' + poolDictionaries:'' category:nil + inEnvironment:nil. + anonCls compile:('%1 ^ %1' bindWith:slotName). + anonCls compile:('%1:v %1 := v' bindWith:slotName). + newObj := anonCls cloneFrom:self. + self become:newObj. diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-4.st b/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-4.st new file mode 100644 index 0000000000..84c4e007db --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-4.st @@ -0,0 +1,6 @@ +p := Point x:10 y:20. +p addSlot:'z'. +p z:30. +p z. +p z:40. +p inspect diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-5.st b/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-5.st new file mode 100644 index 0000000000..8204a0d2ab --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Smalltalk/add-a-variable-to-a-class-instance-at-runtime-5.st @@ -0,0 +1,58 @@ +Object subclass: #Monkey + instanceVariableNames: 'aVar' + classVariableNames: '' + poolDictionaries: '' + category: nil ! + +!Monkey class methodsFor: 'new instance'! +new + | o | + o := super new. + o init. + ^o +!! + +!Monkey methodsFor: 'init instance'! +init + aVar := 0 +! +initWith: value + aVar := value +!! + +!Monkey methodsFor: 'set/get the inst var(s)'! +setVar: var + aVar := var +! +getVar + ^aVar +!! + + +"Create a new instance" +Smalltalk at: #aMonkey put: (Monkey new) ! + +"set the 'original' instance var to 12" +aMonkey setVar: 12 . + +"let's see what's inside" +aMonkey inspect . + +"add a new instance var" +Monkey addInstVarName: 'x'. + +"let's see what's inside now" +aMonkey inspect . + +"let us create a new method for x" +!Monkey methodsFor: 'about x'! +setX: val + x := val +! +x + ^x +!! + +aMonkey setX: 10 . +aMonkey inspect . +(aMonkey x) printNl . diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Tcl/add-a-variable-to-a-class-instance-at-runtime-1.tcl b/Task/Add-a-variable-to-a-class-instance-at-runtime/Tcl/add-a-variable-to-a-class-instance-at-runtime-1.tcl new file mode 100644 index 0000000000..843efe50a8 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Tcl/add-a-variable-to-a-class-instance-at-runtime-1.tcl @@ -0,0 +1,27 @@ +% package require TclOO +% oo::class create summation { + constructor {} { + variable v 0 + } + method add x { + variable v + incr v $x + } + method value {{var v}} { + variable $var + return [set $var] + } + destructor { + variable v + puts "Ended with value $v" + } +} +::summation +% set s [summation new] +% # Do the monkey patch! +% set [info object namespace $s]::time now +now +% # Prove it's really part of the object... +% $s value time +now +% diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Tcl/add-a-variable-to-a-class-instance-at-runtime-2.tcl b/Task/Add-a-variable-to-a-class-instance-at-runtime/Tcl/add-a-variable-to-a-class-instance-at-runtime-2.tcl new file mode 100644 index 0000000000..95c41b9630 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Tcl/add-a-variable-to-a-class-instance-at-runtime-2.tcl @@ -0,0 +1,28 @@ +% oo::class create summation { + constructor {} { + variable v 0 + } + method add x { + variable v + incr v $x + } + method value {{var v}} { + variable $var + return [set $var] + } + destructor { + variable v + puts "Ended with value $v" + } +} +::summation +% set s [summation new] +% set s2 [summation new] +% oo::objdefine $s export varname +% # Do the monkey patch... +% set [$s varname time] "now" +% $s value time +now +% # Show that it is only in one object... +% $s2 value time +can't read "time": no such variable diff --git a/Task/Address-of-a-variable/0DESCRIPTION b/Task/Address-of-a-variable/0DESCRIPTION new file mode 100644 index 0000000000..4007bb7aca --- /dev/null +++ b/Task/Address-of-a-variable/0DESCRIPTION @@ -0,0 +1 @@ +{{basic data operation}}Demonstrate how to get the address of a variable and how to set the address of a variable. diff --git a/Task/Address-of-a-variable/1META.yaml b/Task/Address-of-a-variable/1META.yaml new file mode 100644 index 0000000000..a16ddc894f --- /dev/null +++ b/Task/Address-of-a-variable/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic Data Operations diff --git a/Task/Address-of-a-variable/ALGOL-68/address-of-a-variable-1.alg b/Task/Address-of-a-variable/ALGOL-68/address-of-a-variable-1.alg new file mode 100644 index 0000000000..85b91ae111 --- /dev/null +++ b/Task/Address-of-a-variable/ALGOL-68/address-of-a-variable-1.alg @@ -0,0 +1,4 @@ +[4]INT test := (222,444,666,888); +REF INT reference := test[3]; +REF INT(reference) := reference + 111; +print(("test value is now: ",test)) diff --git a/Task/Address-of-a-variable/ALGOL-68/address-of-a-variable-2.alg b/Task/Address-of-a-variable/ALGOL-68/address-of-a-variable-2.alg new file mode 100644 index 0000000000..6d185623ed --- /dev/null +++ b/Task/Address-of-a-variable/ALGOL-68/address-of-a-variable-2.alg @@ -0,0 +1 @@ +PROC establish = (REF FILE file, STRING idf, CHANNEL chan, INT p, l, c) INT: ~ diff --git a/Task/Address-of-a-variable/Ada/address-of-a-variable-1.ada b/Task/Address-of-a-variable/Ada/address-of-a-variable-1.ada new file mode 100644 index 0000000000..b4b3d87235 --- /dev/null +++ b/Task/Address-of-a-variable/Ada/address-of-a-variable-1.ada @@ -0,0 +1,3 @@ +The_Address : System.Address; +I : Integer; +The_Address := I'Address; diff --git a/Task/Address-of-a-variable/Ada/address-of-a-variable-2.ada b/Task/Address-of-a-variable/Ada/address-of-a-variable-2.ada new file mode 100644 index 0000000000..665d4b3960 --- /dev/null +++ b/Task/Address-of-a-variable/Ada/address-of-a-variable-2.ada @@ -0,0 +1,2 @@ +I : Integer; +for I'Address use 16#A100#; diff --git a/Task/Address-of-a-variable/Ada/address-of-a-variable-3.ada b/Task/Address-of-a-variable/Ada/address-of-a-variable-3.ada new file mode 100644 index 0000000000..f903d446b9 --- /dev/null +++ b/Task/Address-of-a-variable/Ada/address-of-a-variable-3.ada @@ -0,0 +1,3 @@ +I : Integer; +J : Integer; +for I'Address use J'Address; diff --git a/Task/Address-of-a-variable/Argile/address-of-a-variable-1.argile b/Task/Address-of-a-variable/Argile/address-of-a-variable-1.argile new file mode 100644 index 0000000000..1a44d6de19 --- /dev/null +++ b/Task/Address-of-a-variable/Argile/address-of-a-variable-1.argile @@ -0,0 +1,6 @@ +use std, array (: array.arg also defines pointer operators :) +let var = 42 +let ptr = &var (: value of ptr is address of var :) +print var (: prints 42 :) +(*ptr)++ (: increments value pointed by ptr :) +print var (: prints 43 :) diff --git a/Task/Address-of-a-variable/Argile/address-of-a-variable-2.argile b/Task/Address-of-a-variable/Argile/address-of-a-variable-2.argile new file mode 100644 index 0000000000..3fad6e8cca --- /dev/null +++ b/Task/Address-of-a-variable/Argile/address-of-a-variable-2.argile @@ -0,0 +1,3 @@ +use std, array +=:mac:= -> int& { * (0x400000 as int*) } +printf "%x\n" mac (: may crash depending on operating system :) diff --git a/Task/Address-of-a-variable/AutoHotkey/address-of-a-variable.ahk b/Task/Address-of-a-variable/AutoHotkey/address-of-a-variable.ahk new file mode 100644 index 0000000000..996566e1a5 --- /dev/null +++ b/Task/Address-of-a-variable/AutoHotkey/address-of-a-variable.ahk @@ -0,0 +1 @@ +msgbox % &var diff --git a/Task/Address-of-a-variable/BASIC/address-of-a-variable.bas b/Task/Address-of-a-variable/BASIC/address-of-a-variable.bas new file mode 100644 index 0000000000..1f273c7c69 --- /dev/null +++ b/Task/Address-of-a-variable/BASIC/address-of-a-variable.bas @@ -0,0 +1,8 @@ +'get a variable's address: +DIM x AS INTEGER, y AS LONG +y = VARPTR(x) + +'can't set the address, but can access a given memory location... 1 byte at a time +DIM z AS INTEGER +z = PEEK(y) +z = z + (PEEK(y) * 256) diff --git a/Task/Address-of-a-variable/Fortran/address-of-a-variable.f b/Task/Address-of-a-variable/Fortran/address-of-a-variable.f new file mode 100644 index 0000000000..9c79642fd3 --- /dev/null +++ b/Task/Address-of-a-variable/Fortran/address-of-a-variable.f @@ -0,0 +1,10 @@ +program test_loc + + implicit none + integer :: i + real :: r + + i = loc (r) + write (*, '(i0)') i + +end program test_loc diff --git a/Task/Address-of-a-variable/Go/address-of-a-variable-1.go b/Task/Address-of-a-variable/Go/address-of-a-variable-1.go new file mode 100644 index 0000000000..37c46c441b --- /dev/null +++ b/Task/Address-of-a-variable/Go/address-of-a-variable-1.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "unsafe" +) + +func main() { + myVar := 3.14 + myPointer := &myVar + fmt.Println(myPointer) + fmt.Printf("%p\n", myPointer) + + addr := int64(uintptr(unsafe.Pointer(myPointer))) + fmt.Printf("0x%x\n", addr) +} diff --git a/Task/Address-of-a-variable/Go/address-of-a-variable-2.go b/Task/Address-of-a-variable/Go/address-of-a-variable-2.go new file mode 100644 index 0000000000..efc75365e1 --- /dev/null +++ b/Task/Address-of-a-variable/Go/address-of-a-variable-2.go @@ -0,0 +1,29 @@ +== Get == + +There are at least three ways to get the address of a variable in IWBASIC. The first is to use the address of operator: + +DEF X:INT +PRINT &X +'This will print in the console window (after OPENCONSOLE is issued.) +'To Print in an open window the appropriate Window variable is specified, e.g., PRINT Win,&X. + +The second is to use a pointer: + +DEF X:INT +DEF pPointer:POINTER +pPointer=X + +The third is to use the Windows API function Lstrcpy. That is done in the same way as the Creative Basic example; +however, the function would be declared as follows: DECLARE IMPORT,Lstrcpy(P1:POINTER,P2:POINTER),INT. + +== Set == + +It appears to the author that the closest one can come to being able to assign an address to a variable is to set +which bytes will be used to store a variable in a block of reserved memory: + +DEF pMem as POINTER +pMem = NEW(CHAR,1000) : 'Get 1000 bytes to play with +#pMem = "Copy a string into memory" +pMem += 100 +#pMem = 34234: 'Use bytes 100-103 to store a UINT +DELETE pMem diff --git a/Task/Address-of-a-variable/Go/address-of-a-variable-3.go b/Task/Address-of-a-variable/Go/address-of-a-variable-3.go new file mode 100644 index 0000000000..e99f68a6d1 --- /dev/null +++ b/Task/Address-of-a-variable/Go/address-of-a-variable-3.go @@ -0,0 +1,3 @@ + var =: 52 NB. Any variable (including data, functions, operators etc) + var_addr =: 15!:6<'var' NB. Get address + new_var =: 15!:7 var_addr NB. Set address diff --git a/Task/Address-of-a-variable/Perl/address-of-a-variable-1.pl b/Task/Address-of-a-variable/Perl/address-of-a-variable-1.pl new file mode 100644 index 0000000000..8ae7e23582 --- /dev/null +++ b/Task/Address-of-a-variable/Perl/address-of-a-variable-1.pl @@ -0,0 +1,2 @@ +use Scalar::Util qw(refaddr); +print refaddr(\my $v), "\n"; # 135691508 diff --git a/Task/Address-of-a-variable/Perl/address-of-a-variable-2.pl b/Task/Address-of-a-variable/Perl/address-of-a-variable-2.pl new file mode 100644 index 0000000000..85557b3156 --- /dev/null +++ b/Task/Address-of-a-variable/Perl/address-of-a-variable-2.pl @@ -0,0 +1,4 @@ +my $a = 12; +my $b = \$a; # get reference +$$b = $$b + 30; # access referenced value +print $a; # prints 42 diff --git a/Task/Address-of-a-variable/Perl/address-of-a-variable-3.pl b/Task/Address-of-a-variable/Perl/address-of-a-variable-3.pl new file mode 100644 index 0000000000..ca3818d25a --- /dev/null +++ b/Task/Address-of-a-variable/Perl/address-of-a-variable-3.pl @@ -0,0 +1,6 @@ +my $a = 12; +our $b; # you can overlay only global variables (this line is only for strictness) +*b = \$a; +print $b; # prints 12 +$b++; +print $a; # prints 13 diff --git a/Task/Address-of-a-variable/PicoLisp/address-of-a-variable.l b/Task/Address-of-a-variable/PicoLisp/address-of-a-variable.l new file mode 100644 index 0000000000..0e600c2c0e --- /dev/null +++ b/Task/Address-of-a-variable/PicoLisp/address-of-a-variable.l @@ -0,0 +1,14 @@ +: (setq X 7) +-> 7 + +: (adr 'X) +-> -2985527269106 + +: (val (adr -2985527269106)) +-> 7 + +: (set (adr -2985527269106) '(a b c)) +-> (a b c) + +: X +-> (a b c) diff --git a/Task/Address-of-a-variable/Python/address-of-a-variable.py b/Task/Address-of-a-variable/Python/address-of-a-variable.py new file mode 100644 index 0000000000..2ad5c38568 --- /dev/null +++ b/Task/Address-of-a-variable/Python/address-of-a-variable.py @@ -0,0 +1,2 @@ +foo = object() # Create (instantiate) an empty object +address = id(foo) diff --git a/Task/Address-of-a-variable/REXX/address-of-a-variable.rexx b/Task/Address-of-a-variable/REXX/address-of-a-variable.rexx new file mode 100644 index 0000000000..334ae4d6db --- /dev/null +++ b/Task/Address-of-a-variable/REXX/address-of-a-variable.rexx @@ -0,0 +1 @@ +zzz=storage(xxx) diff --git a/Task/Address-of-a-variable/Racket/address-of-a-variable-1.rkt b/Task/Address-of-a-variable/Racket/address-of-a-variable-1.rkt new file mode 100644 index 0000000000..3971668594 --- /dev/null +++ b/Task/Address-of-a-variable/Racket/address-of-a-variable-1.rkt @@ -0,0 +1,6 @@ +#lang racket + +(require ffi/unsafe) + +(define (madness v) ; i'm so sorry + (cast v _racket _gcpointer)) diff --git a/Task/Address-of-a-variable/Racket/address-of-a-variable-2.rkt b/Task/Address-of-a-variable/Racket/address-of-a-variable-2.rkt new file mode 100644 index 0000000000..26ebfad6bb --- /dev/null +++ b/Task/Address-of-a-variable/Racket/address-of-a-variable-2.rkt @@ -0,0 +1,6 @@ +(ptr-ref (madness +) _short) +(ptr-ref (madness (/ 4 3)) _short) +(ptr-ref (madness 3.2) _short) +(ptr-ref (madness (sqrt -2)) _short) +(ptr-ref (madness #\a) _short) +(ptr-ref (madness 'foo) _short) diff --git a/Task/Address-of-a-variable/Ruby/address-of-a-variable.rb b/Task/Address-of-a-variable/Ruby/address-of-a-variable.rb new file mode 100644 index 0000000000..9d7cd315f4 --- /dev/null +++ b/Task/Address-of-a-variable/Ruby/address-of-a-variable.rb @@ -0,0 +1,3 @@ +>foo = Object.new # => # +>id = foo.object_id # => 2238812160 +>"%x" % (id << 1) # => "10ae32000" diff --git a/Task/Address-of-a-variable/Smalltalk/address-of-a-variable-1.st b/Task/Address-of-a-variable/Smalltalk/address-of-a-variable-1.st new file mode 100644 index 0000000000..76b8284a99 --- /dev/null +++ b/Task/Address-of-a-variable/Smalltalk/address-of-a-variable-1.st @@ -0,0 +1,5 @@ +|p| +p := Point x:10 y:20. +ObjectMemory addressOf:p. +ObjectMemory collectGarbage. +ObjectMemory addressOf:p diff --git a/Task/Address-of-a-variable/Smalltalk/address-of-a-variable-2.st b/Task/Address-of-a-variable/Smalltalk/address-of-a-variable-2.st new file mode 100644 index 0000000000..46e30d5bbe --- /dev/null +++ b/Task/Address-of-a-variable/Smalltalk/address-of-a-variable-2.st @@ -0,0 +1,4 @@ +|ptr| +ptr := ExternalBytes new:10. +ptr address. +ptr byteAt:1 put: 16rFF. diff --git a/Task/Address-of-a-variable/Tcl/address-of-a-variable-1.tcl b/Task/Address-of-a-variable/Tcl/address-of-a-variable-1.tcl new file mode 100644 index 0000000000..aaa94a560d --- /dev/null +++ b/Task/Address-of-a-variable/Tcl/address-of-a-variable-1.tcl @@ -0,0 +1,21 @@ +package require critcl +# This code assumes an ILP32 architecture, like classic x86 or VAX. +critcl::cproc peek {int addr} int { + union { + int i; + int *a; + } u; + + u.i = addr; + return *u.a; +} +critcl::cproc poke {int addr int value} void { + union { + int i; + int *a; + } u; + + u.i = addr; + *u.a = value; +} +package provide poker 1.0 diff --git a/Task/Address-of-a-variable/Tcl/address-of-a-variable-2.tcl b/Task/Address-of-a-variable/Tcl/address-of-a-variable-2.tcl new file mode 100644 index 0000000000..1679e8cbc4 --- /dev/null +++ b/Task/Address-of-a-variable/Tcl/address-of-a-variable-2.tcl @@ -0,0 +1,7 @@ +package require poker + +# Increment a memory location; this will probably crash if you try for real. +# We don't define how to get a good address, but it's not usually a problem +# for embedded programming... +set where 0x12340 +poke $where [expr {[peek $where] + 1}] diff --git a/Task/Align-columns/0DESCRIPTION b/Task/Align-columns/0DESCRIPTION new file mode 100644 index 0000000000..9fb3f5a107 --- /dev/null +++ b/Task/Align-columns/0DESCRIPTION @@ -0,0 +1,22 @@ +Given a text file of many lines, where fields within a line +are delineated by a single 'dollar' character, write a program +that aligns each column of fields by ensuring that words in each +column are separated by at least one space. +Further, allow for each word in a column to be either left +justified, right justified, or center justified within its column. + +
Use the following text to test your programs: +
Given$a$text$file$of$many$lines,$where$fields$within$a$line$
+are$delineated$by$a$single$'dollar'$character,$write$a$program
+that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$
+column$are$separated$by$at$least$one$space.
+Further,$allow$for$each$word$in$a$column$to$be$either$left$
+justified,$right$justified,$or$center$justified$within$its$column.
+ +Note that: +# The example input texts lines may, or may not, have trailing dollar characters. +# All columns should share the same alignment. +# Consecutive space characters produced adjacent to the end of lines are insignificant for the purposes of the task. +# Output text will be viewed in a mono-spaced font on a plain text editor or basic terminal. +# The minimum space between columns should be computed from the text and not hard-coded. +# It is ''not'' a requirement to add separating characters between or around columns. diff --git a/Task/Align-columns/1META.yaml b/Task/Align-columns/1META.yaml new file mode 100644 index 0000000000..88eb5468ca --- /dev/null +++ b/Task/Align-columns/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Text processing diff --git a/Task/Align-columns/ABAP/align-columns.abap b/Task/Align-columns/ABAP/align-columns.abap new file mode 100644 index 0000000000..adf9f1ba0d --- /dev/null +++ b/Task/Align-columns/ABAP/align-columns.abap @@ -0,0 +1,77 @@ +report z_align no standard page header. +start-of-selection. + +data: lt_strings type standard table of string, + lv_strings type string. +append: 'Given$a$text$file$of$many$lines,$where$fields$within$a$line$' to lt_strings, + 'are$delineated$by$a$single$''dollar''$character,$write$a$program' to lt_strings, + 'that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$' to lt_strings, + 'column$are$separated$by$at$least$one$space.' to lt_strings, + 'Further,$allow$for$each$word$in$a$column$to$be$either$left$' to lt_strings, + 'justified,$right$justified,$or$center$justified$within$its$column.' to lt_strings. +types ty_strings type standard table of string. + +perform align_col using 'LEFT' lt_strings. +skip. +perform align_col using 'RIGHT' lt_strings. +skip. +perform align_col using 'CENTER' lt_strings. + + +form align_col using iv_just type string iv_strings type ty_strings. + constants: c_del value '$'. + data: lv_string type string, + lt_strings type table of string, + lt_tables like table of lt_strings, + lv_first type string, + lv_second type string, + lv_longest type i value 0, + lv_off type i value 0, + lv_len type i. + " Loop through the supplied text. It is expected at the input is a table of strings, with each + " entry in the table representing a new line of the input. + loop at iv_strings into lv_string. + " Split the current line at the delimiter. + split lv_string at c_del into lv_first lv_second. + " Loop through the line splitting at every delimiter. + do. + append lv_first to lt_strings. + lv_len = strlen( lv_first ). + " Check if the length of the new string is greater than the currently stored length. + if lv_len > lv_longest. + lv_longest = lv_len. + endif. + if lv_second na c_del. + " Check if the string is longer than the recorded maximum. + lv_len = strlen( lv_second ). + if lv_len > lv_longest. + lv_longest = lv_len. + endif. + append lv_second to lt_strings. + exit. + endif. + split lv_second at c_del into lv_first lv_second. + enddo. + + append lt_strings to lt_tables. + clear lt_strings. + endloop. + + " Loop through each line of input. + loop at lt_tables into lt_strings. + " Loop through each word in the line (Separated by specified delimiter). + loop at lt_strings into lv_string. + lv_off = ( sy-tabix - 1 ) * ( lv_longest + 2 ). + case iv_just. + when 'LEFT'. + write : at (lv_longest) lv_string left-justified. + when 'RIGHT'. + write at (lv_longest) lv_string right-justified. + when 'CENTER'. + write at (lv_longest) lv_string centered. + endcase. + endloop. + skip. + sy-linno = sy-linno - 1. + endloop. +endform. diff --git a/Task/Align-columns/ALGOL-68/align-columns.alg b/Task/Align-columns/ALGOL-68/align-columns.alg new file mode 100644 index 0000000000..ae3186556c --- /dev/null +++ b/Task/Align-columns/ALGOL-68/align-columns.alg @@ -0,0 +1,66 @@ +STRING nl = REPR 10; +STRING text in list := "Given$a$text$file$of$many$lines,$where$fields$within$a$line$"+nl+ + "are$delineated$by$a$single$'dollar'$character,$write$a$program"+nl+ + "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$"+nl+ + "column$are$separated$by$at$least$one$space."+nl+ + "Further,$allow$for$each$word$in$a$column$to$be$either$left$"+nl+ + "justified,$right$justified,$or$center$justified$within$its$column."; + +MODE PAGE = FLEX[0,0]STRING; +PAGE page; + +PROC flex page = (PAGE in page, INT row, col)PAGE:( + HEAP FLEX[row, col]STRING out page; + out page[:1 UPB in page, :2 UPB in page] := in page; + FOR r TO row DO + FOR c FROM 2 UPB in page + 1 TO col DO out page[r,c]:="" OD + OD; + FOR r FROM 1 UPB in page + 1 TO row DO + FOR c FROM 1 TO col DO out page[r,c]:="" OD + OD; + out page +); + +FILE text in file; +associate(text in file, text in list); +make term(text in file, "$"); + +on physical file end(text in file, (REF FILE skip)BOOL: stop iteration); +on logical file end(text in file, (REF FILE skip)BOOL: stop iteration); +FOR row DO + on line end(text in file, (REF FILE skip)BOOL: stop iteration); + FOR col DO + STRING tok; + getf(text in file, ($gx$,tok)); + IF row > 1 UPB page THEN page := flex page(page, row, 2 UPB page) FI; + IF col > 2 UPB page THEN page := flex page(page, 1 UPB page, col) FI; + page[row,col]:=tok + OD; + stop iteration: + SKIP +OD; +stop iteration: + SKIP; + +BEGIN + PROC aligner = (PAGE in page, PROC (STRING,INT)STRING aligner)VOID:( + PAGE page := in page; + [2 UPB page]INT max width; + FOR col TO 2 UPB page DO + INT max len:=0; FOR row TO UPB page DO IF UPB page[row,col]>max len THEN max len:=UPB page[row,col] FI OD; + FOR row TO UPB page DO page[row,col] := aligner(page[row,col], maxlen) OD + OD; + printf(($n(UPB page)(n(2 UPB page -1)(gx)gl)$,page)) + ); + + PROC left = (STRING in, INT len)STRING: in + " "*(len - UPB in), + right = (STRING in, INT len)STRING: " "*(len - UPB in) + in, + centre = (STRING in, INT len)STRING: ( INT pad=len-UPB in; pad%2*" "+ in + (pad-pad%2)*" " ); + + []STRUCT(STRING name, PROC(STRING,INT)STRING align) aligners = (("Left",left), ("Left",right), ("Centre",centre)); + + FOR index TO UPB aligners DO + print((new line, "# ",name OF aligners[index]," Column-aligned output:",new line)); + aligner(page, align OF aligners[index]) + OD +END diff --git a/Task/Align-columns/AWK/align-columns.awk b/Task/Align-columns/AWK/align-columns.awk new file mode 100644 index 0000000000..22cc49256c --- /dev/null +++ b/Task/Align-columns/AWK/align-columns.awk @@ -0,0 +1,34 @@ +BEGIN { + FS="$" + lcounter = 1 + maxfield = 0 + # justistification; pick up one + #justify = "left" + justify = "center" + #justify = "right" +} +{ + if ( NF > maxfield ) maxfield = NF; + for(i=1; i <= NF; i++) { + line[lcounter,i] = $i + if ( longest[i] == "" ) longest[i] = 0; + if ( length($i) > longest[i] ) longest[i] = length($i); + } + lcounter++ +} +END { + just = (justify == "left") ? "-" : "" + for(i=1; i <= NR; i++) { + for(j=1; j <= maxfield; j++) { + if ( justify != "center" ) { + template = "%" just longest[j] "s " + } else { + v = int((longest[j] - length(line[i,j]))/2) + rt = "%" v+1 "s%%-%ds" + template = sprintf(rt, "", longest[j] - v) + } + printf(template, line[i,j]) + } + print "" + } +} diff --git a/Task/Align-columns/Ada/align-columns.ada b/Task/Align-columns/Ada/align-columns.ada new file mode 100644 index 0000000000..16c857d27a --- /dev/null +++ b/Task/Align-columns/Ada/align-columns.ada @@ -0,0 +1,65 @@ +with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; +with Ada.Text_IO; use Ada.Text_IO; +with Strings_Edit; use Strings_Edit; + +procedure Column_Aligner is + Text : constant String := + "Given$a$text$file$of$many$lines,$where$fields$within$a$line$" & NUL & + "are$delineated$by$a$single$'dollar'$character,$write$a$program" & NUL & + "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$" & NUL & + "column$are$separated$by$at$least$one$space." & NUL & + "Further,$allow$for$each$word$in$a$column$to$be$either$left$" & NUL & + "justified,$right$justified,$or$center$justified$within$its$column." & NUL; + File : File_Type; + Width : array (1..1_000) of Natural := (others => 0); + Line : String (1..200); + Column : Positive := 1; + Start : Positive := 1; + Pointer : Positive; +begin + Create (File, Out_File, "columned.txt"); + -- Determining the widths of columns + for I in Text'Range loop + case Text (I) is + when '$' | NUL => + Width (Column) := Natural'Max (Width (Column), I - Start + 1); + Start := I + 1; + if Text (I) = NUL then + Column := 1; + else + Column := Column + 1; + end if; + when others => + null; + end case; + end loop; + -- Formatting + for Align in Alignment loop + Column := 1; + Start := 1; + Pointer := 1; + for I in Text'Range loop + case Text (I) is + when '$' | NUL => + Put -- Formatted output of a word + ( Destination => Line, + Pointer => Pointer, + Value => Text (Start..I - 1), + Field => Width (Column), + Justify => Align + ); + Start := I + 1; + if Text (I) = NUL then + Put_Line (File, Line (1..Pointer - 1)); + Pointer := 1; + Column := 1; + else + Column := Column + 1; + end if; + when others => + null; + end case; + end loop; + end loop; + Close (File); +end Column_Aligner; diff --git a/Task/Align-columns/AutoHotkey/align-columns.ahk b/Task/Align-columns/AutoHotkey/align-columns.ahk new file mode 100644 index 0000000000..cd312098a6 --- /dev/null +++ b/Task/Align-columns/AutoHotkey/align-columns.ahk @@ -0,0 +1,50 @@ +lines = +( +|$|$|$|$|$|$|$|$|$|$|$| +Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column. +) + +Clipboard := ColumnJustify(lines, "l") + +MsgBox, , Column Justify, The clipboard now contains the justified text. Paste it into a text editor to see it. + +ColumnJustify(lines, lcr = "l", del="$") +{ + Loop, Parse, lines, `n, `r + Loop, Parse, A_LoopField, %del% + { + If ((t := StrLen(A_LoopField)) > c%A_Index% ) + c%A_Index% := t + If (t > max) + max := t + } + blank := Fill( " ", max ) + If (lcr = "l") ;left-justify + Loop, Parse, lines, `n, `r + Loop, Parse, A_LoopField, %del% + out .= (A_Index = 1 ? "`n" : " ") SubStr(A_LoopField blank, 1, c%A_Index%) + Else If (lcr = "r") ;right-justify + Loop, Parse, lines, `n, `r + Loop, Parse, A_LoopField, %del% + out .= (A_Index = 1 ? "`n" : " ") SubStr(blank A_LoopField, -c%A_Index%+1) + Else If (lcr = "c") ;center-justify + Loop, Parse, lines, `n, `r + Loop, Parse, A_LoopField, %del% + out .= (A_Index = 1 ? "`n" : " ") SubStr(blank A_LoopField blank + , (Ceil((max * 2 + StrLen(A_LoopField))/2) - Ceil(c%A_Index%/2) + 1) + , c%A_Index%) + return SubStr(out, 2) +} + +Fill(chr, len) +{ + static y + if !y + VarSetCapacity(x, 64), VarSetCapacity(x, 0), y := True + return x, VarSetCapacity(x, len, Asc(chr)) +} diff --git a/Task/Align-columns/Clojure/align-columns.clj b/Task/Align-columns/Clojure/align-columns.clj new file mode 100644 index 0000000000..aee314da28 --- /dev/null +++ b/Task/Align-columns/Clojure/align-columns.clj @@ -0,0 +1,41 @@ +(ns rosettacode.align-columns + (:require [clojure.contrib.string :as str])) + +(def data "Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column.") + +(def table (map #(str/split #"\$" %) (str/split-lines data))) + +(defn col-width [n table] (reduce max (map #(try (count (nth % n)) + (catch Exception _ 0)) + table))) +(defn spaces [n] (str/repeat n " ")) +(defn add-padding + "if the string is too big turncate it, else return a string with padding" + [string width justification] + (if (>= (count string) width) (str/take width string) + (let [pad-len (int (- width (count string))) ;we don't want rationals + half-pad-len (int (/ pad-len 2))] + (case justification + :right (str (spaces pad-len) string) + :left (str string (spaces pad-len)) + :center (str (spaces half-pad-len) string (spaces (- pad-len half-pad-len))))))) + +(defn aligned-table + "get the width of each column, then generate a new table with propper padding for eath item" + ([table justification] + (let [col-widths (map #(+ 2 (col-width % table)) (range (count(first table))))] + (map + (fn [row] (map #(add-padding %1 %2 justification) row col-widths)) + table)))) + +(defn print-table + [table] + (do (println) + (print (str/join "" (flatten (interleave table (repeat "\n"))))))) + +(print-table (aligned-table table :center)) diff --git a/Task/Align-columns/CoffeeScript/align-columns-1.coffee b/Task/Align-columns/CoffeeScript/align-columns-1.coffee new file mode 100644 index 0000000000..8be05f1487 --- /dev/null +++ b/Task/Align-columns/CoffeeScript/align-columns-1.coffee @@ -0,0 +1,48 @@ +pad = (n) -> + s = '' + while n > 0 + s += ' ' + n -= 1 + s + +align = (input, alignment = 'center') -> + tokenized_lines = (line.split '$' for line in input) + col_widths = {} + for line in tokenized_lines + for token, i in line + if !col_widths[i]? or token.length > col_widths[i] + col_widths[i] = token.length + padders = + center: (s, width) -> + excess = width - s.length + left = Math.floor excess / 2 + right = excess - left + pad(left) + s + pad(right) + + right: (s, width) -> + excess = width - s.length + pad(excess) + s + + left: (s, width) -> + excess = width - s.length + s + pad(excess) + + padder = padders[alignment] + + for line in tokenized_lines + padded_tokens = (padder(token, col_widths[i]) for token, i in line) + console.log padded_tokens.join ' ' + + +input = [ + "Given$a$text$file$of$many$lines,$where$fields$within$a$line$" + "are$delineated$by$a$single$'dollar'$character,$write$a$program" + "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$" + "column$are$separated$by$at$least$one$space." + "Further,$allow$for$each$word$in$a$column$to$be$either$left$" + "justified,$right$justified,$or$center$justified$within$its$column." +] + +for alignment in ['center', 'right', 'left'] + console.log "\n----- #{alignment}" + align input, alignment diff --git a/Task/Align-columns/CoffeeScript/align-columns-2.coffee b/Task/Align-columns/CoffeeScript/align-columns-2.coffee new file mode 100644 index 0000000000..1f38a18416 --- /dev/null +++ b/Task/Align-columns/CoffeeScript/align-columns-2.coffee @@ -0,0 +1,25 @@ +> coffee align_columns.coffee + +----- center + Given a text file of many lines, where fields within a line + are delineated by a single 'dollar' character, write a program + that aligns each column of fields by ensuring that words in each + column are separated by at least one space. + Further, allow for each word in a column to be either left +justified, right justified, or center justified within its column. + +----- right + Given a text file of many lines, where fields within a line + are delineated by a single 'dollar' character, write a program + that aligns each column of fields by ensuring that words in each + column are separated by at least one space. + Further, allow for each word in a column to be either left +justified, right justified, or center justified within its column. + +----- left +Given a text file of many lines, where fields within a line +are delineated by a single 'dollar' character, write a program +that aligns each column of fields by ensuring that words in each +column are separated by at least one space. +Further, allow for each word in a column to be either left +justified, right justified, or center justified within its column. diff --git a/Task/Align-columns/Erlang/align-columns.erl b/Task/Align-columns/Erlang/align-columns.erl new file mode 100644 index 0000000000..aebb153caa --- /dev/null +++ b/Task/Align-columns/Erlang/align-columns.erl @@ -0,0 +1,68 @@ +-module (align_columns). + +-export([align_left/0, align_right/0, align_center/0]). +-define (Lines, + ["Given\$a\$text\$file\$of\$many\$lines\$where\$fields\$within\$a\$line\$", + "are\$delineated\$by\$a\$single\$'dollar'\$character,\$write\$a\$program", + "that\$aligns\$each\$column\$of\$fields\$by\$ensuring\$that\$words\$in\$each\$", + "column\$are\$separated\$by\$at\$least\$one\$space.", + "Further,\$allow\$for\$each\$word\$in\$a\$column\$to\$be\$either\$left\$", + "justified,\$right\$justified,\$or\$center\$justified\$within\$its\$column."]. + +align_left()-> align_columns(left). +align_right()-> align_columns(right). +align_center()-> align_columns(centre). +align_columns(Alignment) -> + Words = [ string:tokens(Line, "\$") || Line <- ?Lines ], + Words_length = lists:foldl( fun max_length/2, [], Words), + Result = [prepare_line(Words_line, Words_length, Alignment) + || Words_line <- Words], + + [ io:fwrite("~s~n", [lists:flatten(Line)]) || Line <- Result], + ok. + +max_length(Words_of_a_line, Acc_maxlength) -> + Line_lengths = [length(W) || W <- Words_of_a_line ], + Max_nb_of_length = lists:max([length(Acc_maxlength), length(Line_lengths)]), + Line_lengths_prepared = adjust_list (Line_lengths, Max_nb_of_length, 0), + Acc_maxlength_prepared = adjust_list(Acc_maxlength, Max_nb_of_length, 0), + Two_lengths =lists:zip(Line_lengths_prepared, Acc_maxlength_prepared), + [ lists:max([A, B]) || {A, B} <- Two_lengths]. +adjust_list(L, Desired_length, Elem) -> + L++lists:duplicate(Desired_length - length(L), Elem). + +prepare_line(Words_line, Words_length, Alignment) -> + All_words = adjust_list(Words_line, length(Words_length), ""), + Zipped = lists:zip (All_words, Words_length), + [ apply(string, Alignment, [Word, Length + 1, $\s]) + || {Word, Length} <- Zipped]. + +=== Output + + +1> c(align_columns). +{ok,align_columns} +2> align_columns:align_center(). + Given a text file of many lines where fields within a line + are delineated by a single 'dollar' character, write a program + that aligns each column of fields by ensuring that words in each + column are separated by at least one space. + Further, allow for each word in a column to be either left +justified, right justified, or center justified within its column. +ok +3> align_columns:align_left(). +Given a text file of many lines where fields within a line +are delineated by a single 'dollar' character, write a program +that aligns each column of fields by ensuring that words in each +column are separated by at least one space. +Further, allow for each word in a column to be either left +justified, right justified, or center justified within its column. +ok +4> align_columns:align_right(). + Given a text file of many lines where fields within a line + are delineated by a single 'dollar' character, write a program + that aligns each column of fields by ensuring that words in each + column are separated by at least one space. + Further, allow for each word in a column to be either left + justified, right justified, or center justified within its column. +ok diff --git a/Task/Align-columns/Forth/align-columns.fth b/Task/Align-columns/Forth/align-columns.fth new file mode 100644 index 0000000000..cd588bfc36 --- /dev/null +++ b/Task/Align-columns/Forth/align-columns.fth @@ -0,0 +1,70 @@ +\ align columns + +: split ( addr len char -- addr len1 addr len-len1 ) + >r 2dup r> scan 2swap 2 pick - ; + +variable column + +: for-each-line ( file len xt -- ) + >r begin #lf split r@ execute 1 /string dup 0<= until 2drop rdrop ; + +: for-each-field ( line len xt -- ) + 0 column ! + >r begin '$ split r@ execute 1 column +! 1 /string dup 0<= until 2drop rdrop ; + +0 value num-columns + +: count-columns ( line len -- ) + ['] 2drop for-each-field + num-columns column @ max to num-columns ; +: find-num-columns ( file len -- ) + 0 to num-columns + ['] count-columns for-each-line ; + +0 value column-widths + +: column-width ( field len -- ) + column-widths column @ + c@ + max + column-widths column @ + c! + drop ; +: measure-widths ( line len -- ) + ['] column-width for-each-field ; +: find-column-widths ( file len -- ) + num-columns allocate throw to column-widths + column-widths num-columns erase + ['] measure-widths for-each-line ; + +\ type aligned, same naming convention as standard numeric U.R, .R +: type.l ( addr len width -- ) + over - >r type r> spaces ; +: type.c ( addr len width -- ) + over - dup 2/ spaces >r type r> 1+ 2/ spaces ; +: type.r ( addr len width -- ) + over - spaces type ; + +defer type.aligned + +: print-field ( field len -- ) + column-widths column @ + c@ type.aligned space ; +: print-line ( line len -- ) cr ['] print-field for-each-field ; +: print-fields ( file len -- ) ['] print-line for-each-line ; + + +\ read file +s" columns.txt" slurp-file ( file len ) + +\ scan once to determine num-columns +2dup find-num-columns + +\ scan again to determine column-widths +2dup find-column-widths + +\ print columns, once for each alignment type +' type.l is type.aligned 2dup print-fields cr +' type.c is type.aligned 2dup print-fields cr +' type.r is type.aligned 2dup print-fields cr + +\ cleanup +nip free throw +column-widths free throw diff --git a/Task/Align-columns/Go/align-columns.go b/Task/Align-columns/Go/align-columns.go new file mode 100644 index 0000000000..638c6d51a7 --- /dev/null +++ b/Task/Align-columns/Go/align-columns.go @@ -0,0 +1,61 @@ +package main + +import ( + "fmt" + "strings" +) + +const text = `Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column.` + +type formatter struct { + text [][]string + width []int +} + +func newFormatter(text string) *formatter { + var f formatter + for _, line := range strings.Split(text, "\n") { + words := strings.Split(line, "$") + for words[len(words)-1] == "" { + words = words[:len(words)-1] + } + f.text = append(f.text, words) + for i, word := range words { + if i == len(f.width) { + f.width = append(f.width, len(word)) + } else if len(word) > f.width[i] { + f.width[i] = len(word) + } + } + } + return &f +} + +const ( + left = iota + middle + right +) + +func (f formatter) print(j int) { + for _, line := range f.text { + for i, word := range line { + fmt.Printf("%-*s ", f.width[i], fmt.Sprintf("%*s", + len(word)+(f.width[i]-len(word))*j/2, word)) + } + fmt.Println("") + } + fmt.Println("") +} + +func main() { + f := newFormatter(text) + f.print(left) + f.print(middle) + f.print(right) +} diff --git a/Task/Align-columns/Haskell/align-columns.hs b/Task/Align-columns/Haskell/align-columns.hs new file mode 100644 index 0000000000..b57888c269 --- /dev/null +++ b/Task/Align-columns/Haskell/align-columns.hs @@ -0,0 +1,25 @@ +import Data.List +import Control.Monad +import Control.Arrow + +dat = "Given$a$text$file$of$many$lines,$where$fields$within$a$line$\n" ++ + "are$delineated$by$a$single$'dollar'$character,$write$a$program\n" ++ + "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$\n" ++ + "column$are$separated$by$at$least$one$space.\n" ++ + "Further,$allow$for$each$word$in$a$column$to$be$either$left$\n" ++ + "justified,$right$justified,$or$center$justified$within$its$column.\n" + +brkdwn = takeWhile (not.null) . unfoldr (Just . second (drop 1) . span ('$'/=)) + +format j ls = map (unwords. zipWith align colw) rows + where + rows = map brkdwn $ lines ls + colw = map (maximum. map length) . transpose $ rows + align cw w = + case j of + 'c' -> (replicate l ' ') ++ w ++ (replicate r ' ') + 'r' -> (replicate dl ' ') ++ w + 'l' -> w ++ (replicate dl ' ') + where + dl = cw-length w + (l,r) = (dl `div` 2, dl-l) diff --git a/Task/Align-columns/JavaScript/align-columns.js b/Task/Align-columns/JavaScript/align-columns.js new file mode 100644 index 0000000000..70ddeccec3 --- /dev/null +++ b/Task/Align-columns/JavaScript/align-columns.js @@ -0,0 +1,31 @@ +var justification="center", +input=["Given$a$text$file$of$many$lines,$where$fields$within$a$line$", +"are$delineated$by$a$single$'dollar'$character,$write$a$program", +"that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$", +"column$are$separated$by$at$least$one$space.", +"Further,$allow$for$each$word$in$a$column$to$be$either$left$", +"justified,$right$justified,$or$center$justified$within$its$column."], +x,y,cols,max,cols=0,diff,left,right + +String.prototype.repeat=function(n){return new Array(1 + parseInt(n)).join(this);} + +for(x=0;xcols) cols=input[x].length; +} +for(x=0;x STR_PAD_RIGHT, + 'R' => STR_PAD_LEFT, + 'C' => STR_PAD_BOTH); + +/** + Justify columns of textual tabular input where the record separator is the newline + and the field separator is a 'dollar' character. + justification can be L, R, or C; (Left, Right, or Centered). + + Return the justified output as a string +*/ +function aligner($str, $justification = 'L') { + global $j2justtype; + assert(array_key_exists($justification, $j2justtype)); + $justtype = $j2justtype[$justification]; + + $fieldsbyrow = array(); + foreach (explode("\n", $str) as $line) + $fieldsbyrow[] = explode('$', $line); + $maxfields = max(array_map('count', $fieldsbyrow)); + + foreach (range(0, $maxfields-1) as $col) { + $maxwidth = 0; + foreach ($fieldsbyrow as $fields) + $maxwidth = max($maxwidth, strlen($fields[$col])); + foreach ($fieldsbyrow as &$fields) + $fields[$col] = str_pad($fields[$col], $maxwidth, ' ', $justtype); + unset($fields); // see http://bugs.php.net/29992 + } + $result = ''; + foreach ($fieldsbyrow as $fields) + $result .= implode(' ', $fields) . "\n"; + return $result; +} + +$textinfile = 'Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$\'dollar\'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column.'; + +foreach (array('L', 'R', 'C') as $j) + echo aligner($textinfile, $j); + +?> diff --git a/Task/Align-columns/Perl/align-columns-1.pl b/Task/Align-columns/Perl/align-columns-1.pl new file mode 100644 index 0000000000..0ab55f15a0 --- /dev/null +++ b/Task/Align-columns/Perl/align-columns-1.pl @@ -0,0 +1,56 @@ +#/usr/bin/perl -w +use strict ; + +die "Call : perl columnaligner.pl !\n" unless + @ARGV == 2 ; #$ARGV[ 0 ] contains example file , $ARGV[1] any of 'left' , 'right' or 'center' +die "last argument must be one of center, left or right!\n" unless + $ARGV[ 1 ] =~ /center|left|right/ ; +sub printLines( $$$ ) ; +open INFILE , "<" , "$ARGV[ 0 ]" or die "Can't open $ARGV[ 0 ]!\n" ; +my @lines = ; +close INFILE ; +chomp @lines ; +my @fieldwidths = map length, split /\$/ , $lines[ 0 ] ; +foreach my $i ( 1..$#lines ) { + my @words = split /\$/ , $lines[ $i ] ; + foreach my $j ( 0..$#words ) { + if ( $j <= $#fieldwidths ) { + if ( length $words[ $j ] > $fieldwidths[ $j ] ) { + $fieldwidths[ $j ] = length $words[ $j ] ; + } + } + else { + push @fieldwidths, length $words[ $j ] ; + } + } +} +printLine( $_ , $ARGV[ 1 ] , \@fieldwidths ) foreach @lines ; +################################################################## #### +sub printLine { + my $line = shift ; + my $orientation = shift ; + my $widthref = shift ; + my @words = split /\$/, $line ; + foreach my $k ( 0..$#words ) { + my $printwidth = $widthref->[ $k ] + 1 ; + if ( $orientation eq 'center' ) { + $printwidth++ ; + } + if ( $orientation eq 'left' ) { + print $words[ $k ] ; + print " " x ( $printwidth - length $words[ $k ] ) ; + } + elsif ( $orientation eq 'right' ) { + print " " x ( $printwidth - length $words[ $k ] ) ; + print $words[ $k ] ; + } + elsif ( $orientation eq 'center' ) { + my $left = int( ( $printwidth - length $words[ $k ] ) / 2 ) ; + my $right = $printwidth - length( $words[ $k ] ) - $left ; + print " " x $left ; + print $words[ $k ] ; + print " " x $right ; + } + } + print "\n" ; +} diff --git a/Task/Align-columns/Perl/align-columns-2.pl b/Task/Align-columns/Perl/align-columns-2.pl new file mode 100644 index 0000000000..6d8928fb54 --- /dev/null +++ b/Task/Align-columns/Perl/align-columns-2.pl @@ -0,0 +1,24 @@ +use List::Util qw(max); + +sub columns { + my @lines = map [split /\$/] => split /\n/ => shift; + my $pos = {qw/left 0 center 1 right 2/}->{+shift}; + for my $col (0 .. max map {$#$_} @lines) { + my $max = max my @widths = map {length $_->[$col]} @lines; + for my $row (0 .. $#lines) { + my @pad = map {' ' x $_, ' ' x ($_ + 0.5)} ($max - $widths[$row]) / 2; + for ($lines[$row][$col]) + {$_ = join '' => @pad[0 .. $pos-1], $_, @pad[$pos .. $#pad]} + } + } + join '' => map {"@$_\n"} @lines +} + +print columns <<'END', $_ for qw(left right center); +Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column. +END diff --git a/Task/Align-columns/PicoLisp/align-columns.l b/Task/Align-columns/PicoLisp/align-columns.l new file mode 100644 index 0000000000..92257b5855 --- /dev/null +++ b/Task/Align-columns/PicoLisp/align-columns.l @@ -0,0 +1,21 @@ +(let Sizes NIL # Build a list of sizes + (let Lines # and of lines + (make + (in "input.txt" # Reading input file + (while (split (line) "$") # delimited by '$' + (let (L (link (mapcar pack @)) S Sizes) + (setq Sizes # Maintain sizes + (make + (while (or L S) + (link + (max + (inc (length (pop 'L))) + (pop 'S) ) ) ) ) ) ) ) ) ) + (for L Lines # Print lines + (prinl (apply align L (mapcar - Sizes))) ) # left aligned + (prinl) + (for L Lines + (prinl (apply align L Sizes)) ) # right aligned + (prinl) + (for L Lines + (prinl (apply center L Sizes)) ) ) ) # and centered diff --git a/Task/Align-columns/Prolog/align-columns.pro b/Task/Align-columns/Prolog/align-columns.pro new file mode 100644 index 0000000000..ae16766b87 --- /dev/null +++ b/Task/Align-columns/Prolog/align-columns.pro @@ -0,0 +1,79 @@ +aligner :- + L ="Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column.", + + % read the lines and the words + % compute the length of the longuest word. + % LP is the list of lines, + % each line is a list of words + parse(L, 0, N, LP, []), + + % we need to add 1 to aligned + N1 is N+1, + % words will be left aligned + sformat(AL, '~~w~~t~~~w|', [N1]), + % words will be centered + sformat(AC, '~~t~~w~~t~~~w|', [N1]), + % words will be right aligned + sformat(AR, '~~t~~w~~~w|', [N1]), + + write('Left justified :'), nl, + maplist(affiche(AL), LP), nl, + write('Centered justified :'), nl, + maplist(affiche(AC), LP), nl, + write('Right justified :'), nl, + maplist(affiche(AR), LP), nl. + +affiche(F, L) :- + maplist(my_format(F), L), + nl. + +my_format(_F, [13]) :- + nl. + +my_format(F, W) :- + string_to_atom(W,AW), + sformat(AF, F, [AW]), + write(AF). + + +parse([], Max, Max) --> []. + +parse(T, N, Max) --> + { parse_line(T, 0, N1, T1, L, []), + ( N1 > N -> N2 = N1; N2 = N)}, + [L], + parse(T1, N2, Max). + +parse_line([], NF, NF, []) --> []. + +parse_line([H|TF], NF, NF, TF) --> + {code_type(H, end_of_line), !}, + []. + + +parse_line(T, N, NF, TF) --> + { parse_word(T, 0, N1, T1, W, []), + ( N1 > N -> N2 = N1; N2 = N)}, + [W], + parse_line(T1, N2, NF, TF). + +% 36 is the code of '$' +parse_word([36|T], N, N, T) --> + {!}, + []. + +parse_word([H|T], N, N, [H|T]) --> + {code_type(H, end_of_line), !}, + []. + +parse_word([], N, N, []) --> []. + +parse_word([H|T], N1, NF, TF) --> + [H], + {N2 is N1 + 1}, + parse_word(T, N2, NF, TF). diff --git a/Task/Align-columns/Python/align-columns-1.py b/Task/Align-columns/Python/align-columns-1.py new file mode 100644 index 0000000000..b6ae3b9a42 --- /dev/null +++ b/Task/Align-columns/Python/align-columns-1.py @@ -0,0 +1,45 @@ +from StringIO import StringIO + +textinfile = '''Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column.''' + +j2justifier = dict(L=str.ljust, R=str.rjust, C=str.center) + +def aligner(infile, justification = 'L'): + ''' \ + Justify columns of textual tabular input where the row separator is the newline + and the field separator is a 'dollar' character. + justification can be L, R, or C; (Left, Right, or Centered). + + Return the justified output as a string + ''' + assert justification in j2justifier, "justification can be L, R, or C; (Left, Right, or Centered)." + justifier = j2justifier[justification] + + fieldsbyrow= [line.strip().split('$') for line in infile] + # pad to same number of fields per row + maxfields = max(len(row) for row in fieldsbyrow) + fieldsbyrow = [fields + ['']*(maxfields - len(fields)) + for fields in fieldsbyrow] + # rotate + fieldsbycolumn = zip(*fieldsbyrow) + # calculate max fieldwidth per column + colwidths = [max(len(field) for field in column) + for column in fieldsbycolumn] + # pad fields in columns to colwidth with spaces + fieldsbycolumn = [ [justifier(field, width) for field in column] + for width, column in zip(colwidths, fieldsbycolumn) ] + # rotate again + fieldsbyrow = zip(*fieldsbycolumn) + + return "\n".join( " ".join(row) for row in fieldsbyrow) + + +for align in 'Left Right Center'.split(): + infile = StringIO(textinfile) + print "\n# %s Column-aligned output:" % align + print aligner(infile, align[0]) diff --git a/Task/Align-columns/Python/align-columns-2.py b/Task/Align-columns/Python/align-columns-2.py new file mode 100644 index 0000000000..6f409cc691 --- /dev/null +++ b/Task/Align-columns/Python/align-columns-2.py @@ -0,0 +1,21 @@ +txt = """Given$a$txt$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column.""" + +parts = [line.rstrip("$").split("$") for line in txt.splitlines()] + +max_widths = {} +for line in parts: + for i, word in enumerate(line): + max_widths[i] = max(max_widths.get(i, 0), len(word)) + +for i, justify in enumerate([str.ljust, str.center, str.rjust]): + print ["Left", "Center", "Right"][i], " column-aligned output:\n" + for line in parts: + for j, word in enumerate(line): + print justify(word, max_widths[j]), + print + print "- " * 52 diff --git a/Task/Align-columns/R/align-columns.r b/Task/Align-columns/R/align-columns.r new file mode 100644 index 0000000000..951cf3c8b3 --- /dev/null +++ b/Task/Align-columns/R/align-columns.r @@ -0,0 +1,25 @@ +# Read in text +lines <- readLines(tc <- textConnection("Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column.")); close(tc) + +#Split words by the dollar +words <- strsplit(lines, "\\$") + +#Reformat +maxlen <- max(sapply(words, length)) +words <- lapply(words, function(x) {length(x) <- maxlen; x}) +block <- matrix(unlist(words), byrow=TRUE, ncol=maxlen) +block[is.na(block)] <- "" +leftjust <- format(block) +rightjust <- format(block, justify="right") +centrejust <- format(block, justify="centre") + +# Print +print0 <- function(x) invisible(apply(x, 1, function(x) cat(x, "\n"))) +print0(leftjust) +print0(rightjust) +print0(centrejust) diff --git a/Task/Align-columns/REXX/align-columns-1.rexx b/Task/Align-columns/REXX/align-columns-1.rexx new file mode 100644 index 0000000000..3feec83ca1 --- /dev/null +++ b/Task/Align-columns/REXX/align-columns-1.rexx @@ -0,0 +1,49 @@ +/*REXX*/ +z.1 = "Given$a$text$file$of$many$lines,$where$fields$within$a$line$" +z.2 = "are$delineated$by$a$single$'dollar'$character,$write$a$program" +z.3 = "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$" +z.4 = "column$are$separated$by$at$least$one$space." +z.5 = "Further,$allow$for$each$word$in$a$column$to$be$either$left$" +z.6 = "justified,$right$justified,$or$center$justified$within$its$column." + +word. = "" +width. = 0 +maxcol = 0 +do row = 1 to 6 + line = z.row + do col = 1 by 1 until length(line) = 0 + parse var line word.row.col "$" line + if length(word.row.col) > width.col then width.col = length(word.row.col) + end + if col > maxcol then maxcol = col +end + +say "align left:" +say +do row = 1 to 6 + out = "" + do col = 1 to maxcol + out = out || left(word.row.col,width.col+1) + end + say out +end +say +say "align right:" +say +do row = 1 to 6 + out = "" + do col = 1 to maxcol + out = out || right(word.row.col,width.col+1) + end + say out +end +say +say "align center:" +say +do row = 1 to 6 + out = "" + do col = 1 to maxcol + out = out || center(word.row.col,width.col+1) + end + say out +end diff --git a/Task/Align-columns/REXX/align-columns-2.rexx b/Task/Align-columns/REXX/align-columns-2.rexx new file mode 100644 index 0000000000..4f32eaa738 --- /dev/null +++ b/Task/Align-columns/REXX/align-columns-2.rexx @@ -0,0 +1,35 @@ +/*REXX program to display various alignments. */ +cols=0; size=0; wid.=0; t.=; @.= + +t.1 = "Given$a$text$file$of$many$lines,$where$fields$within$a$line$" +t.2 = "are$delineated$by$a$single$'dollar'$character,$write$a$program" +t.3 = "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$" +t.4 = "column$are$separated$by$at$least$one$space." +t.5 = "Further,$allow$for$each$word$in$a$column$to$be$either$left$" +t.6 = "justified,$right$justified,$or$center$justified$within$its$column." + + do r=1 while t.r\=='' + _=strip(t.r,,'$') + do c=1 until _=='' + parse var _ @.r.c '$' _ + wid.c=max(wid.c,length(@.r.c)) + end /*c*/ + cols=max(cols,c) + end /*r*/ + +rows=r-1 /*adjust ROWS, it's 1 too big*/ + do k=1 for cols; size=size+wid.k; end /*find width of biggest line.*/ + + do j=1 for 3; say + say center(word('left right center',j) "aligned",size+cols-1,"=") + + do r=1 for rows; _= + do c=1 for cols; x=@.r.c + if j==1 then _=_ left(x,wid.c) + if j==2 then _=_ right(x,wid.c) + if j==3 then _=_ centre(x,wid.c) + end /*c*/ + say substr(_,2) + end /*r*/ + say + end /*j*/ diff --git a/Task/Align-columns/REXX/align-columns-3.rexx b/Task/Align-columns/REXX/align-columns-3.rexx new file mode 100644 index 0000000000..5d9ca65f6d --- /dev/null +++ b/Task/Align-columns/REXX/align-columns-3.rexx @@ -0,0 +1,43 @@ +/*REXX program to display various alignments. */ +cols=0; parse var cols size 1 wid. t. /*initializations.*/ + +t.1 = "Given$a$text$file$of$many$lines,$where$fields$within$a$line$" +t.2 = "are$delineated$by$a$single$'dollar'$character,$write$a$program" +t.3 = "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$" +t.4 = "column$are$separated$by$at$least$one$space." +t.5 = "Further,$allow$for$each$word$in$a$column$to$be$either$left$" +t.6 = "justified,$right$justified,$or$center$justified$within$its$column." + + do r=1 while t.r\=='' + t.r=translate(t.r,,'$') + do c=1 until word(t.r,c)=='' + wid.c=max(wid.c,length(word(t.r,c))) + end /*c*/ + cols=max(cols,c) + end /*r*/ + +rows=r-1 /*adjust ROWS, it's 1 too big*/ + + do k=1 for cols; size=size+wid.k; end /*find width of biggest line.*/ + + do j=1 for 3; say + say center(word('left right center',j) "aligned",size+cols,"="); say + + do r=0 to rows; _=; !='β”‚'; if r==0 then !='┬' + + do c=1 for cols; x=word(t.r,c) + if r==0 then x=copies("─",wid.c+1) + else x=word(t.r,c) + if j==1 then _=_ || ! || left(x,wid.c) + if j==2 then _=_ || ! || right(x,wid.c) + if j==3 then _=_ || ! || centre(x,wid.c) + end /*c*/ + + if r==0 then do; _='β”Œ'substr(_,2,length(_)-2)"┐" + bot='β””'substr(_,2,length(_)-2)"β”˜" + end + say _ + end /*r*/ + + say translate(bot,'β”΄',"┬"); say; say + end /*j*/ diff --git a/Task/Align-columns/Racket/align-columns.rkt b/Task/Align-columns/Racket/align-columns.rkt new file mode 100644 index 0000000000..92a4e38e11 --- /dev/null +++ b/Task/Align-columns/Racket/align-columns.rkt @@ -0,0 +1,34 @@ +#lang racket + +(define (display-aligned text #:justify [justify 'left]) + (define lines + (for/list ([line (regexp-split #rx"\n" text)]) + (regexp-split #rx"\\$" line))) + (define width + (add1 (for*/fold ([m 0]) ([line lines] [word line]) + (max m (string-length word))))) + (define spaces (make-string width #\space)) + (for ([line lines]) + (for* ([word line] + [strs (let ([spc (substring spaces (string-length word))]) + (case justify + [(left) (list word spc)] + [(right) (list spc word)] + [(center) (let ([i (quotient (string-length spc) 2)]) + (list (substring spc i) + word + (substring spc 0 i)))]))]) + (display strs)) + (newline))) + +(define text + "Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column.") + +(display-aligned text) +(display-aligned #:justify 'right text) +(display-aligned #:justify 'center text) diff --git a/Task/Align-columns/Ruby/align-columns.rb b/Task/Align-columns/Ruby/align-columns.rb new file mode 100644 index 0000000000..ae42acdf65 --- /dev/null +++ b/Task/Align-columns/Ruby/align-columns.rb @@ -0,0 +1,50 @@ +require 'stringio' + +textinfile = < String.instance_method(:ljust), + 'R' => String.instance_method(:rjust), + 'C' => String.instance_method(:center)} + +=begin +Justify columns of textual tabular input where the record separator is the newline +and the field separator is a 'dollar' character. +justification can be L, R, or C; (Left, Right, or Centered). + +Return the justified output as a string +=end +def aligner(infile, justification = 'L') + justifier = J2justifier[justification] + + fieldsbyrow = infile.map {|line| line.strip.split('$')} + # pad to same number of fields per record + maxfields = fieldsbyrow.map {|row| row.length}.max + fieldsbyrow.map! {|row| + row + ['']*(maxfields - row.length) + } + # calculate max fieldwidth per column + colwidths = fieldsbyrow.transpose.map {|column| + column.map {|field| field.length}.max + } + # pad fields in columns to colwidth with spaces + fieldsbyrow.map! {|row| + row.zip(colwidths).map {|field, width| + justifier.bind(field)[width] + } + } + + fieldsbyrow.map {|row| row.join(" ")}.join("\n") +end + +for align in %w{Left Right Center} + infile = StringIO.new(textinfile) + puts "\n# %s Column-aligned output:" % align + puts aligner(infile, align[0..0]) +end diff --git a/Task/Align-columns/Scala/align-columns-1.scala b/Task/Align-columns/Scala/align-columns-1.scala new file mode 100644 index 0000000000..51b8967cb9 --- /dev/null +++ b/Task/Align-columns/Scala/align-columns-1.scala @@ -0,0 +1,28 @@ +object ColumnAligner { + val eol = System.getProperty("line.separator") + def getLines(filename: String) = scala.io.Source.fromPath(filename).getLines(eol) + def splitter(line: String) = line split '$' + def getTable(filename: String) = getLines(filename) map splitter + def fieldWidths(fields: Array[String]) = fields map (_ length) + def columnWidths(txt: Iterator[Array[String]]) = (txt map fieldWidths).toList.transpose map (_ max) + + def alignField(alignment: Char)(width: Int)(field: String) = alignment match { + case 'l' | 'L' => "%-"+width+"s" format field + case 'r' | 'R' => "%"+width+"s" format field + case 'c' | 'C' => val padding = (width - field.length) / 2; " "*padding+"%-"+(width-padding)+"s" format field + case _ => throw new IllegalArgumentException + } + + def align(aligners: List[String => String])(fields: Array[String]) = + aligners zip fields map Function.tupled(_ apply _) + + def alignFile(filename: String, alignment: Char) = { + def table = getTable(filename) + val aligners = columnWidths(table) map alignField(alignment) + table map align(aligners) map (_ mkString " ") + } + + def printAlignedFile(filename: String, alignment: Char) { + alignFile(filename, alignment) foreach println + } +} diff --git a/Task/Align-columns/Scala/align-columns-2.scala b/Task/Align-columns/Scala/align-columns-2.scala new file mode 100644 index 0000000000..754c522abb --- /dev/null +++ b/Task/Align-columns/Scala/align-columns-2.scala @@ -0,0 +1,22 @@ +def pad(s:String, i:Int, d:String) = { + val padsize = (i-s.length).max(0) + d match { + case "left" => s+" "*padsize + case "right" => " "*padsize+s + case "center" => " "*(padsize/2) + s + " "*(padsize-padsize/2) + } +} + +val lines = scala.io.Source.fromFile("c:\\text.txt").getLines.map(_.trim()) +val words = lines.map(_.split("\\$").toList).toList +val lens = words.map(l => l.map(_.length)).toList + +var maxlens = Map[Int,Int]() withDefaultValue 0 +lens foreach (l => + for(i <- (0 until l.length)){ + maxlens += i -> l(i).max(maxlens(i)) + } +) + +val padded = words map ( _.zipWithIndex.map{case(s,i)=>pad(s,maxlens(i),"center")+" "} ) +padded map (_.reduceLeft(_ + _)) foreach println diff --git a/Task/Align-columns/Tcl/align-columns.tcl b/Task/Align-columns/Tcl/align-columns.tcl new file mode 100644 index 0000000000..13409f87fd --- /dev/null +++ b/Task/Align-columns/Tcl/align-columns.tcl @@ -0,0 +1,48 @@ +package require Tcl 8.5 + +set text {Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column.} + +array set max {} +foreach line [split $text \n] { + set col 0 + set thisline [split $line \$] + lappend words $thisline + foreach word $thisline { + set max([incr col]) [expr {[info exists max($col)] + ? max($max($col), [string length $word]) + : [string length $word] + }] + } +} + +proc justify {word position width} { + switch -exact -- $position { + left { + return [format "%-*s" $width $word] + } + center { + set lpadw [expr {($width - [string length $word])/2}] + return [format "%s%-*s" [string repeat " " $lpadw] [incr width -$lpadw] $word] + } + right { + return [format "%*s" $width $word] + } + } +} + +foreach position {left center right} { + foreach thisline $words { + set col 0 + set line "" + foreach word $thisline { + append line [justify $word $position $max([incr col])] " " + } + puts [string trimright $line] + } + puts "" +} diff --git a/Task/Anagrams-Deranged-anagrams/0DESCRIPTION b/Task/Anagrams-Deranged-anagrams/0DESCRIPTION new file mode 100644 index 0000000000..f330f90653 --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/0DESCRIPTION @@ -0,0 +1,7 @@ +Two or more words are said to be [[Anagrams|anagrams]] if they have the same characters, but in a different order. By analogy with [[Permutations/Derangements|derangements]] we define a deranged anagram as two words with the same characters, but in which the same character does ''not'' appear in the same position in both words. + +The task is to use the word list at http://www.puzzlers.org/pub/wordlists/unixdict.txt to find and ''show'' the longest deranged anagram. + +;Cf. +* [[Permutations/Derangements]] +* [[Best shuffle]] diff --git a/Task/Anagrams-Deranged-anagrams/Ada/anagrams-deranged-anagrams.ada b/Task/Anagrams-Deranged-anagrams/Ada/anagrams-deranged-anagrams.ada new file mode 100644 index 0000000000..57c4ea906c --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/Ada/anagrams-deranged-anagrams.ada @@ -0,0 +1,45 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Containers.Generic_Array_Sort; +with Ada.Containers.Indefinite_Vectors; +procedure Danagrams is + package StringVector is new Ada.Containers.Indefinite_Vectors + (Positive, String); + procedure StrSort is new Ada.Containers.Generic_Array_Sort + (Index_Type => Positive, + Element_Type => Character, + Array_Type => String); + function Derange (s1 : String; s2 : String) return Boolean is begin + for i in s1'Range loop + if (s1 (i) = s2 (i)) then return False; end if; + end loop; + return True; + end Derange; + File : File_Type; + len, foundlen : Positive := 1; + Vect, SVect : StringVector.Vector; + index, p1, p2 : StringVector.Extended_Index := 0; +begin + Open (File, In_File, "unixdict.txt"); + while not End_Of_File (File) loop + declare str : String := Get_Line (File); + begin + len := str'Length; + if len > foundlen then + Vect.Append (str); + StrSort (str); + index := 0; + loop -- Loop through anagrams by index in vector of sorted strings + index := SVect.Find_Index (str, index + 1); + exit when index = StringVector.No_Index; + if Derange (Vect.Last_Element, Vect.Element (index)) then + p1 := Vect.Last_Index; p2 := index; + foundlen := len; + end if; + end loop; + SVect.Append (str); + end if; + end; + end loop; + Close (File); + Put_Line (Vect.Element (p1) & " " & Vect.Element (p2)); +end Danagrams; diff --git a/Task/Anagrams-Deranged-anagrams/C/anagrams-deranged-anagrams.c b/Task/Anagrams-Deranged-anagrams/C/anagrams-deranged-anagrams.c new file mode 100644 index 0000000000..1a2efbf58e --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/C/anagrams-deranged-anagrams.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include +#include +#include +#include + +// Letter lookup by frequency. This is to reduce word insertion time. +const char *freq = "zqxjkvbpygfwmucldrhsnioate"; +int char_to_idx[128]; + +// Trie structure of sorts +struct word { + const char *w; + struct word *next; +}; + +union node { + union node *down[10]; + struct word *list[10]; +}; + +int deranged(const char *s1, const char *s2) +{ + int i; + for (i = 0; s1[i]; i++) + if (s1[i] == s2[i]) return 0; + return 1; +} + +int count_letters(const char *s, unsigned char *c) +{ + int i, len; + memset(c, 0, 26); + for (len = i = 0; s[i]; i++) { + if (s[i] < 'a' || s[i] > 'z') + return 0; + len++, c[char_to_idx[(unsigned char)s[i]]]++; + } + return len; +} + +const char * insert(union node *root, const char *s, unsigned char *cnt) +{ + int i; + union node *n; + struct word *v, *w = 0; + + for (i = 0; i < 25; i++, root = n) { + if (!(n = root->down[cnt[i]])) + root->down[cnt[i]] = n = calloc(1, sizeof(union node)); + } + + w = malloc(sizeof(struct word)); + w->w = s; + w->next = root->list[cnt[25]]; + root->list[cnt[25]] = w; + + for (v = w->next; v; v = v->next) { + if (deranged(w->w, v->w)) + return v->w; + } + return 0; +} + +int main(int c, char **v) +{ + int i, j = 0; + char *words; + struct stat st; + + int fd = open(c < 2 ? "unixdict.txt" : v[1], O_RDONLY); + if (fstat(fd, &st) < 0) return 1; + + words = malloc(st.st_size); + read(fd, words, st.st_size); + close(fd); + + union node root = {{0}}; + unsigned char cnt[26]; + int best_len = 0; + const char *b1, *b2; + + for (i = 0; freq[i]; i++) + char_to_idx[(unsigned char)freq[i]] = i; + + /* count words, change newline to null */ + for (i = j = 0; i < st.st_size; i++) { + if (words[i] != '\n') continue; + words[i] = '\0'; + + if (i - j > best_len) { + count_letters(words + j, cnt); + const char *match = insert(&root, words + j, cnt); + + if (match) { + best_len = i - j; + b1 = words + j; + b2 = match; + } + } + + j = ++i; + } + + if (best_len) printf("longest derangement: %s %s\n", b1, b2); + + return 0; +} diff --git a/Task/Anagrams-Deranged-anagrams/Clojure/anagrams-deranged-anagrams.clj b/Task/Anagrams-Deranged-anagrams/Clojure/anagrams-deranged-anagrams.clj new file mode 100644 index 0000000000..6b01637d5d --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/Clojure/anagrams-deranged-anagrams.clj @@ -0,0 +1,5 @@ +(let + [words (re-seq #"\w+" (slurp "unixdict.txt")) + anagrams (filter second (vals (group-by sort words))) + deranged (remove #(some true? (apply map = %)) anagrams)] + (prn (last (sort-by #(count (first %)) deranged)))) diff --git a/Task/Anagrams-Deranged-anagrams/CoffeeScript/anagrams-deranged-anagrams.coffee b/Task/Anagrams-Deranged-anagrams/CoffeeScript/anagrams-deranged-anagrams.coffee new file mode 100644 index 0000000000..332670c4ce --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/CoffeeScript/anagrams-deranged-anagrams.coffee @@ -0,0 +1,39 @@ +http = require 'http' + +is_derangement = (word1, word2) -> + for c, i in word1 + return false if c == word2[i] + true + +show_longest_derangement = (word_lst) -> + anagrams = {} + max_len = 0 + + for word in word_lst + continue if word.length < max_len + key = word.split('').sort().join('') + if anagrams[key] + for prior in anagrams[key] + if is_derangement(prior, word) + max_len = word.length + result = [prior, word] + else + anagrams[key] = [] + anagrams[key].push word + + console.log "Longest derangement: #{result.join ' '}" + +get_word_list = (process) -> + options = + host: "www.puzzlers.org" + path: "/pub/wordlists/unixdict.txt" + + req = http.request options, (res) -> + s = '' + res.on 'data', (chunk) -> + s += chunk + res.on 'end', -> + process s.split '\n' + req.end() + +get_word_list show_longest_derangement diff --git a/Task/Anagrams-Deranged-anagrams/Go/anagrams-deranged-anagrams.go b/Task/Anagrams-Deranged-anagrams/Go/anagrams-deranged-anagrams.go new file mode 100644 index 0000000000..85ccac3936 --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/Go/anagrams-deranged-anagrams.go @@ -0,0 +1,52 @@ +package main +import ( + "fmt" + "io/ioutil" + "strings" + "sort" +) + +func deranged(a, b string) bool { + if len(a) != len(b) { + return false + } + for i := range(a) { + if a[i] == b[i] { return false } + } + return true +} + +func main() { + /* read the whole thing in. how big can it be? */ + buf, _ := ioutil.ReadFile("unixdict.txt") + words := strings.Split(string(buf), "\n") + + m := make(map[string] []string) + best_len, w1, w2 := 0, "", "" + + for _, w := range(words) { + // don't bother: too short to beat current record + if len(w) <= best_len { continue } + + // save strings in map, with sorted string as key + letters := strings.Split(w, "") + sort.Strings(letters) + k := strings.Join(letters, "") + + if _, ok := m[k]; !ok { + m[k] = []string { w } + continue + } + + for _, c := range(m[k]) { + if deranged(w, c) { + best_len, w1, w2 = len(w), c, w + break + } + } + + m[k] = append(m[k], w) + } + + fmt.Println(w1, w2, ": Length", best_len) +} diff --git a/Task/Anagrams-Deranged-anagrams/Haskell/anagrams-deranged-anagrams.hs b/Task/Anagrams-Deranged-anagrams/Haskell/anagrams-deranged-anagrams.hs new file mode 100644 index 0000000000..373ed074a4 --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/Haskell/anagrams-deranged-anagrams.hs @@ -0,0 +1,35 @@ +import Control.Arrow +import Data.List +import Data.Ord +import qualified Data.Map as M +import qualified Data.Set as S + +-- Group lists of words based on their "signatures". A signature is a sorted +-- list of characters. Handle duplicate input words by storing them in sets. +groupBySig = map (sort &&& S.singleton) + +-- Convert groups to lists of equivalent words. +equivs = map (S.toList . snd) . M.toList . M.fromListWith S.union + +-- Indicate whether the pair of words differ in all character positions. +isDerangement (a, b) = and $ zipWith (/=) a b + +-- Return all pairs of elements, ignoring order. +pairs = concat . unfoldr step + where step (x:xs) = Just (map ((,) x) xs, xs) + step [] = Nothing + +-- Return all anagram pairs in the input string. +anagrams = concatMap pairs . equivs . groupBySig + +-- Return the pair of words making the longest deranged anagram. +maxDerangedAnagram = maxByLen . filter isDerangement . anagrams + where maxByLen [] = Nothing + maxByLen xs = Just $ maximumBy (comparing (length . fst)) xs + +main :: IO () +main = do + input <- getContents + case maxDerangedAnagram $ words input of + Nothing -> putStrLn "No deranged anagrams were found." + Just (a, b) -> putStrLn $ "Longest deranged anagrams: " ++ a ++ " and " ++ b diff --git a/Task/Anagrams-Deranged-anagrams/Java/anagrams-deranged-anagrams.java b/Task/Anagrams-Deranged-anagrams/Java/anagrams-deranged-anagrams.java new file mode 100644 index 0000000000..870a8ac461 --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/Java/anagrams-deranged-anagrams.java @@ -0,0 +1,62 @@ +import java.io.*; +import java.util.*; + +public class DerangedAnagrams { + + public static void main(final String[] args) throws IOException { + if (!findAnagrams(readLines("unixdict.txt"))) + System.out.println("no result"); + } + + private static boolean isDeranged(final String w, final List lst) { + for (String w2 : lst) { + int k = w.length() - 1; + while (k >= 0 && w.charAt(k) != w2.charAt(k)) { + k--; + } + if (k == -1) { + System.out.println(w + ", " + w2); + return true; + } + } + return false; + } + + private static boolean findAnagrams(final List words) { + Collections.sort(words, new Comparator() { + public int compare(String a, String b) { + return b.length() - a.length(); + } + }); + Map> map = new HashMap<>(); + for (String w : words) { + char[] srt = w.toCharArray(); + Arrays.sort(srt); + String key = String.valueOf(srt); + ArrayList lst; + if (map.containsKey(key)) { + lst = map.get(key); + if (isDeranged(w, lst)) { + return true; + } + lst.add(w); + } else { + lst = new ArrayList<>(); + lst.add(w); + map.put(key, lst); + } + } + return false; + } + + private static List readLines(final String fn) throws IOException { + List lines; + try (BufferedReader br = new BufferedReader(new FileReader(fn))) { + lines = new ArrayList<>(); + String line = null; + while ((line = br.readLine()) != null) + lines.add(line); + } + return lines; + } +} diff --git a/Task/Anagrams-Deranged-anagrams/JavaScript/anagrams-deranged-anagrams-1.js b/Task/Anagrams-Deranged-anagrams/JavaScript/anagrams-deranged-anagrams-1.js new file mode 100644 index 0000000000..dd7e20c3a7 --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/JavaScript/anagrams-deranged-anagrams-1.js @@ -0,0 +1,75 @@ +#!/usr/bin/env js + +function main() { + var wordList = read('unixdict.txt').split(/\s+/); + var anagrams = findAnagrams(wordList); + var derangedAnagrams = findDerangedAnagrams(anagrams); + var longestPair = findLongestDerangedPair(derangedAnagrams); + print(longestPair.join(' ')); + +} + +function findLongestDerangedPair(danas) { + var longestLen = danas[0][0].length; + var longestPair = danas[0]; + for (var i in danas) { + if (danas[i][0].length > longestLen) { + longestLen = danas[i][0].length; + longestPair = danas[i]; + } + } + return longestPair; +} + +function findDerangedAnagrams(anagrams) { + var deranged = []; + + function isDeranged(w1, w2) { + for (var c = 0; c < w1.length; c++) { + if (w1[c] == w2[c]) { + return false; + } + } + return true; + } + + function findDeranged(anas) { + for (var a = 0; a < anas.length; a++) { + for (var b = a + 1; b < anas.length; b++) { + if (isDeranged(anas[a], anas[b])) { + deranged.push([anas[a], anas[b]]); + } + } + } + } + + for (var a in anagrams) { + var anas = anagrams[a]; + findDeranged(anas); + } + + return deranged; +} + +function findAnagrams(wordList) { + var anagrams = {}; + + for (var wordNum in wordList) { + var word = wordList[wordNum]; + var key = word.split('').sort().join(''); + if (!(key in anagrams)) { + anagrams[key] = []; + } + anagrams[key].push(word); + } + + for (var a in anagrams) { + if (anagrams[a].length < 2) { + delete(anagrams[a]); + } + } + + return anagrams; +} + +main(); diff --git a/Task/Anagrams-Deranged-anagrams/JavaScript/anagrams-deranged-anagrams-2.js b/Task/Anagrams-Deranged-anagrams/JavaScript/anagrams-deranged-anagrams-2.js new file mode 100644 index 0000000000..3cbc26a769 --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/JavaScript/anagrams-deranged-anagrams-2.js @@ -0,0 +1,45 @@ +Intoxication +

+
diff --git a/Task/Anagrams-Deranged-anagrams/PHP/anagrams-deranged-anagrams.php b/Task/Anagrams-Deranged-anagrams/PHP/anagrams-deranged-anagrams.php
new file mode 100644
index 0000000000..463e5d3c4b
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/PHP/anagrams-deranged-anagrams.php
@@ -0,0 +1,51 @@
+= 2) {
+            $counts = array();
+            foreach ($words as $word) {
+                $counts[$word] = array($word);
+                foreach ($words as $second_word) {
+                    for ($i = 0, $length = strlen($word); $i < $length; $i++) {
+                        if ($word[$i] === $second_word[$i]) continue 2;
+                    }
+                    $counts[$word][] = $second_word;
+                }
+            }
+            $max = 0;
+            $max_key = '';
+            foreach ($counts as $name => $count) {
+                if (count($count) > $max) {
+                    $max = count($count);
+                    $max_key = $name;
+                }
+            }
+            if ($max > 1) {
+                $final_words[] = $counts[$max_key];
+            }
+        }
+    }
+    if ($final_words) break;
+}
+
+foreach ($final_words as $final_word) {
+    echo implode(" ", $final_word), "\n";
+}
+?>
diff --git a/Task/Anagrams-Deranged-anagrams/Perl/anagrams-deranged-anagrams.pl b/Task/Anagrams-Deranged-anagrams/Perl/anagrams-deranged-anagrams.pl
new file mode 100644
index 0000000000..975dd527cf
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/Perl/anagrams-deranged-anagrams.pl
@@ -0,0 +1,37 @@
+sub deranged {                          # only anagrams ever get here
+        my @a = split('', shift);       # split word into letters
+        my @b = split('', shift);
+        for (0 .. $#a) {
+                $a[$_] eq $b[$_] and return;
+        }
+        return 1
+}
+
+sub find_deranged {
+        for my $i ( 0 .. $#_ ) {
+                for my $j ( $i+1 .. $#_ ) {
+                        next unless deranged $_[$i], $_[$j];
+
+                        print "length ", length($_[$i]), ": $_[$i] => $_[$j]\n";
+                        return 1;
+                }
+        }
+}
+
+my %letter_list;
+open my $in, 'unixdict.txt';
+
+local $/ = undef;
+
+for (split(' ', <$in>)) {
+        # store anagrams in hash table by letters they contain
+        push @{ $letter_list{ join('', sort split('', $_)) } }, $_
+}
+
+for (   sort { length($b) <=> length($a) }      # sort by length, descending
+        grep { @{ $letter_list{$_} } > 1 }      # take only ones with anagrams
+        keys %letter_list               )
+{
+        # if we find a pair, they are the longested due to the sort before
+        last if find_deranged(@{ $letter_list{$_} });
+}
diff --git a/Task/Anagrams-Deranged-anagrams/PicoLisp/anagrams-deranged-anagrams.l b/Task/Anagrams-Deranged-anagrams/PicoLisp/anagrams-deranged-anagrams.l
new file mode 100644
index 0000000000..abe4b534d9
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/PicoLisp/anagrams-deranged-anagrams.l
@@ -0,0 +1,19 @@
+(let Words NIL
+   (in "unixdict.txt"
+      (while (line)
+         (let (Word @  Key (pack (sort (copy @))))
+            (if (idx 'Words Key T)
+               (push (car @) Word)
+               (set Key (list Word)) ) ) ) )
+   (maxi '((X) (length (car X)))
+      (extract
+         '((Key)
+            (pick
+               '((Lst)
+                  (and
+                     (find
+                        '((L) (not (find = L Lst)))
+                        (val Key) )
+                     (cons (pack @) (pack Lst)) ) )
+               (val Key) ) )
+         (idx 'Words) ) ) )
diff --git a/Task/Anagrams-Deranged-anagrams/Prolog/anagrams-deranged-anagrams.pro b/Task/Anagrams-Deranged-anagrams/Prolog/anagrams-deranged-anagrams.pro
new file mode 100644
index 0000000000..8b63bedaf7
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/Prolog/anagrams-deranged-anagrams.pro
@@ -0,0 +1,58 @@
+longest_deranged_anagram :-
+	http_open('http://www.puzzlers.org/pub/wordlists/unixdict.txt',In,[]),
+	read_file(In, [], Out),
+	close(In),
+	msort(Out, MOut),
+	group_pairs_by_key(MOut, GPL),
+	map_list_to_pairs(compute_len, GPL, NGPL),
+	predsort(my_compare, NGPL, GPLSort),
+	search_derangement(GPLSort).
+
+
+% order tuples to have longest words first
+my_compare(R, N1-(K1-E1), N2-(K2-E2)) :-
+	(   N1 < N2 -> R = > ; N1 > N2 -> R = <;
+	length(E1, L1),
+	length(E2, L2),
+	(   L1 < L2 -> R = <; L1 > L2 -> R = >; compare(R, K1, K2))).
+
+
+compute_len(_-[H|_], Len) :-
+	length(H, Len).
+
+
+% check derangement of anagrams
+derangement([], []).
+derangement([H1|T1], [H2 | T2]) :-
+	H1 \= H2,
+	derangement(T1, T2).
+
+
+search_derangement([_-(_-L) | T]) :-
+	length(L, 1), !,
+	search_derangement(T).
+
+
+search_derangement([_-(_-L) | T]) :-
+	(   search(L) -> true; search_derangement(T)).
+
+search([]) :- fail.
+search([H | T]) :-
+	(   search_one(H, T) -> true; search(T)).
+
+
+search_one(Word, L) :-
+	include(derangement(Word), L, [H|_]),
+	atom_codes(W, Word),
+	atom_codes(W1, H),
+	format('Longest deranged anagrams : ~w ~w ~n', [W, W1]).
+
+
+read_file(In, L, L1) :-
+	read_line_to_codes(In, W),
+	(   W == end_of_file ->
+	       L1 = L
+	       ;
+	       msort(W, W1),
+	       atom_codes(A, W1),
+	       read_file(In, [A-W | L], L1)).
diff --git a/Task/Anagrams-Deranged-anagrams/Python/anagrams-deranged-anagrams-1.py b/Task/Anagrams-Deranged-anagrams/Python/anagrams-deranged-anagrams-1.py
new file mode 100644
index 0000000000..41dfc7c0fb
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/Python/anagrams-deranged-anagrams-1.py
@@ -0,0 +1,39 @@
+import urllib.request
+from collections import defaultdict
+from itertools import combinations
+
+def getwords(url='http://www.puzzlers.org/pub/wordlists/unixdict.txt'):
+    return list(set(urllib.request.urlopen(url).read().decode().split()))
+
+def find_anagrams(words):
+    anagram = defaultdict(list) # map sorted chars to anagrams
+    for word in words:
+        anagram[tuple(sorted(word))].append( word )
+    return dict((key, words) for key, words in anagram.items()
+                if len(words) > 1)
+
+def is_deranged(words):
+    'returns pairs of words that have no character in the same position'
+    return [ (word1, word2)
+             for word1,word2 in combinations(words, 2)
+             if all(ch1 != ch2 for ch1, ch2 in zip(word1, word2)) ]
+
+def largest_deranged_ana(anagrams):
+    ordered_anagrams = sorted(anagrams.items(),
+                              key=lambda x:(-len(x[0]), x[0]))
+    for _, words in ordered_anagrams:
+        deranged_pairs = is_deranged(words)
+        if deranged_pairs:
+            return deranged_pairs
+    return []
+
+if __name__ == '__main__':
+    words = getwords('http://www.puzzlers.org/pub/wordlists/unixdict.txt')
+    print("Word count:", len(words))
+
+    anagrams = find_anagrams(words)
+    print("Anagram count:", len(anagrams),"\n")
+
+    print("Longest anagrams with no characters in the same position:")
+    print('  ' + '\n  '.join(', '.join(pairs)
+                             for pairs in largest_deranged_ana(anagrams)))
diff --git a/Task/Anagrams-Deranged-anagrams/Python/anagrams-deranged-anagrams-2.py b/Task/Anagrams-Deranged-anagrams/Python/anagrams-deranged-anagrams-2.py
new file mode 100644
index 0000000000..76822ab9db
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/Python/anagrams-deranged-anagrams-2.py
@@ -0,0 +1,27 @@
+from itertools import izip, ifilter
+from collections import defaultdict
+
+def find_deranged(words):
+    result = []
+    for i, w1 in enumerate(words):
+        for w2 in words[i+1:]:
+            if all(a != b for a,b in izip(w1, w2)):
+                result.append((w1, w2))
+    return result
+
+def main():
+    wclasses = [[] for _ in xrange(30)]
+    for word in open("unixdict.txt").read().split():
+        wclasses[-len(word)].append(word)
+    print "Longest deranged anagrams:"
+    for words in ifilter(None, wclasses):
+        anags = defaultdict(list)
+        for w in words:
+            anags["".join(sorted(w))].append(w)
+        anas = (find_deranged(a) for a in anags.itervalues() if len(a)>1)
+        pairs = filter(None, anas)
+        if pairs:
+            print "  %s, %s" % (pairs[0][0])
+            break
+
+main()
diff --git a/Task/Anagrams-Deranged-anagrams/R/anagrams-deranged-anagrams-1.r b/Task/Anagrams-Deranged-anagrams/R/anagrams-deranged-anagrams-1.r
new file mode 100644
index 0000000000..a2ae018b5e
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/R/anagrams-deranged-anagrams-1.r
@@ -0,0 +1,25 @@
+puzzlers.dict <- readLines("http://www.puzzlers.org/pub/wordlists/unixdict.txt")
+
+longest.deranged.anagram <- function(dict=puzzlers.dict) {
+  anagram.groups <- function(word.group) {
+    sorted <- sapply(lapply(strsplit(word.group,""),sort),paste, collapse="")
+    grouped <- tapply(word.group, sorted, force, simplify=FALSE)
+    grouped <- grouped[sapply(grouped, length) > 1]
+    grouped[order(-nchar(names(grouped)))]
+  }
+
+  derangements <- function(anagram.group) {
+    pairs <- expand.grid(a = anagram.group, b = anagram.group,
+                         stringsAsFactors=FALSE)
+    pairs <- subset(pairs, a < b)
+    deranged <- with(pairs, mapply(function(a,b) all(a!=b),
+                                   strsplit(a,""), strsplit(b,"")))
+    pairs[which(deranged),]
+  }
+
+  for (anagram.group in anagram.groups(dict)) {
+    if (nrow(d <- derangements(anagram.group)) > 0) {
+      return(d[1,])
+    }
+  }
+}
diff --git a/Task/Anagrams-Deranged-anagrams/R/anagrams-deranged-anagrams-2.r b/Task/Anagrams-Deranged-anagrams/R/anagrams-deranged-anagrams-2.r
new file mode 100644
index 0000000000..ef9ec942ab
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/R/anagrams-deranged-anagrams-2.r
@@ -0,0 +1,3 @@
+> longest.deranged.anagram()
+           a          b
+3 excitation intoxicate
diff --git a/Task/Anagrams-Deranged-anagrams/REXX/anagrams-deranged-anagrams.rexx b/Task/Anagrams-Deranged-anagrams/REXX/anagrams-deranged-anagrams.rexx
new file mode 100644
index 0000000000..2ef25a48ed
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/REXX/anagrams-deranged-anagrams.rexx
@@ -0,0 +1,40 @@
+/*REXX program finds the  largest  deranged word  (within a dictionary).*/
+ifid='unixdict.txt';    words=0        /*input file identifier, # words.*/
+wL.=0                                  /*number of words of length  L.  */
+      do j=1  while lines(ifid)\==0    /*read each word in file (word=X)*/
+      x=space(linein(ifid),0)          /*pick off a word from the input.*/
+      L=length(x); if L<3 then iterate /*onesies and twosies can't win. */
+      words=words+1                    /*count of (useable) words.      */
+      #.words=L                        /*the length of the word found.  */
+      @.words=x                        /*save the word in an array.     */
+      wL.L=wL.L+1;        _=wL.L       /*counter of words of length  L. */
+      @@.L._=x                         /*array   of words of length  L. */
+         /*sort the letters*/   do ja=1 for L;   !.ja=substr(x,ja,1);  end
+      !.0=L; call esort;z=;     do jb=1 for L;   z=z || !.jb;          end
+      @@s.L._=z                        /*store the sorted word (letters)*/
+      @s.words=@@s.L._                 /*and also, sorted length L vers.*/
+      end   /*j*/
+a.=                                    /*all the anagrams for word  X.  */
+say copies('─',30) words 'words in the dictionary file: ' ifid
+m=0; n.=0                              /*# anagrams for word X; m=max L.*/
+       do j=1  for words               /*process the usable words found.*/
+       x=@.j;     Lx=#.j;   xs=@s.j    /*get some vital statistics for X*/
+       if m\==0 & Lx@.k   then say @.k a.k
+  end   /*k*/                          /*above:REXX has no shortcircuits*/
+exit                                   /*stick a fork in it, we're done.*/
+/*──────────────────────────────────ESORT───────────────────────────────*/
+esort:procedure expose !.;h=!.0;do while h>1;h=h%2;do i=1 for !.0-h;j=i;k=h+i
+do while !.k=j then leave;j=j-h;k=k-h;end;end;end;return
diff --git a/Task/Anagrams-Deranged-anagrams/Ruby/anagrams-deranged-anagrams.rb b/Task/Anagrams-Deranged-anagrams/Ruby/anagrams-deranged-anagrams.rb
new file mode 100644
index 0000000000..5fbaef1e49
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/Ruby/anagrams-deranged-anagrams.rb
@@ -0,0 +1,46 @@
+require 'open-uri'
+anagram = nil
+open('http://www.puzzlers.org/pub/wordlists/unixdict.txt') do |f|
+  anagram = f.read.split.group_by {|s| s.each_char.sort}
+end
+
+def deranged?(a, b)
+  a.chars.zip(b.chars).all? {|char_a, char_b| char_a != char_b}
+end
+
+def remove_non_derangements(val)
+  list = val.dup
+  for i in 0 ... list.length
+    j = i + 1
+    while j < list.length
+      if deranged?(list[i], list[j])
+        j += 1
+      else
+        list.delete_at(j)
+      end
+    end
+  end
+  list
+end
+
+max_word_length = anagram.each_value .
+                          select {|list| list.length > 1} .
+                          map {|list| list[0].length} .
+                          max
+
+derangements = []
+
+until derangements.length > 1
+  puts "looking for deranged anagrams with word length #{max_word_length}"
+
+  anagram.each_value .
+          select {|list| list.length > 1 and list[0].length == max_word_length} .
+          each do |list|
+            derangements = remove_non_derangements(list)
+            break if derangements.length > 1
+          end
+
+  max_word_length -= 1
+end
+
+puts "derangement with longest word length: #{derangements}"
diff --git a/Task/Anagrams-Deranged-anagrams/Scala/anagrams-deranged-anagrams.scala b/Task/Anagrams-Deranged-anagrams/Scala/anagrams-deranged-anagrams.scala
new file mode 100644
index 0000000000..5dd33fbf3d
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/Scala/anagrams-deranged-anagrams.scala
@@ -0,0 +1,34 @@
+object DerangedAnagrams {
+
+  /** Returns a map of anagrams keyed by the sorted characters */
+  def groupAnagrams(words: Iterable[String]): Map[String, Set[String]] =
+    words.foldLeft (Map[String, Set[String]]()) { (map, word) =>
+      val sorted = word.sorted
+      val entry = map.getOrElse(sorted, Set.empty)
+      map + (sorted -> (entry + word))
+    }
+
+  /* Returns true if the pair of strings has no positions with the same
+   * characters */
+  def isDeranged(ss: (String, String)): Boolean =
+    ss._1 zip ss._2 forall { case (c1, c2) => c1 != c2 }
+
+  /* Returns pairwise combination of all Strings in the argument Iterable */
+  def pairWords(as: Iterable[String]): Iterable[(String, String)] =
+    if (as.size < 2) Seq() else (as.tail map (as.head -> _)) ++ pairWords(as.tail)
+
+  /* Returns the contents of the argument URL as an Iterable[String], each
+   * String is one line in the file */
+  def readLines(url: String): Iterable[String] =
+    io.Source.fromURL(url).getLines().toIterable
+
+  val wordsURL = "http://www.puzzlers.org/pub/wordlists/unixdict.txt"
+
+  def main(args: Array[String]): Unit = {
+    val anagramMap = groupAnagrams(readLines(wordsURL))
+    val derangedPairs = anagramMap.values flatMap (pairWords) filter (isDeranged)
+    val (w1, w2) = derangedPairs maxBy (pair => pair._1.length)
+    println("Longest deranged pair: "+w1+" and "+w2)
+  }
+
+}
diff --git a/Task/Anagrams-Deranged-anagrams/Tcl/anagrams-deranged-anagrams.tcl b/Task/Anagrams-Deranged-anagrams/Tcl/anagrams-deranged-anagrams.tcl
new file mode 100644
index 0000000000..79aa5f87de
--- /dev/null
+++ b/Task/Anagrams-Deranged-anagrams/Tcl/anagrams-deranged-anagrams.tcl
@@ -0,0 +1,53 @@
+package require Tcl 8.5
+package require http
+
+# Fetch the words
+set t [http::geturl "http://www.puzzlers.org/pub/wordlists/unixdict.txt"]
+set wordlist [split [http::data $t] \n]
+http::cleanup $t
+
+# Group by characters in word
+foreach word $wordlist {
+    dict lappend w [lsort [split $word ""]] [split $word ""]
+}
+
+# Deranged test
+proc deranged? {l1 l2} {
+    foreach c1 $l1 c2 $l2 {
+	if {$c1 eq $c2} {return 0}
+    }
+    return 1
+}
+
+# Get a deranged pair from an anagram set, if one exists
+proc getDeranged {words} {
+    foreach l1 [lrange $words 0 end-1] {
+	foreach l2 [lrange $words 1 end] {
+	    if {[deranged? $l1 $l2]} {
+		return [list $l1 $l2 1]
+	    }
+	}
+    }
+    return {{} {} 0}
+}
+
+# Find the max-length deranged anagram
+set count 0
+set candidates {}
+set max 0
+dict for {k words} $w {
+    incr count [expr {[llength $words] > 1}]
+    if {[llength $k] > $max && [lassign [getDeranged $words] l1 l2]} {
+	set max [llength $l1]
+	lappend candidates [join $l1 ""],[join $l2 ""]
+    }
+}
+
+# Print out what we found
+puts "[llength $wordlist] words"
+puts "[dict size $w] potential anagram-groups"
+puts "$count real anagram-groups"
+foreach pair $candidates {
+    puts "considered candidate pairing: $pair"
+}
+puts "MAXIMAL DERANGED ANAGRAM: LENGTH $max\n\t[lindex $candidates end]"
diff --git a/Task/Animation/0DESCRIPTION b/Task/Animation/0DESCRIPTION
new file mode 100644
index 0000000000..732d4e8cea
--- /dev/null
+++ b/Task/Animation/0DESCRIPTION
@@ -0,0 +1,3 @@
+Animation is the foundation of a great many parts of graphical user interfaces, including both the fancy effects when things change used in window managers, and of course games. The core of any animation system is a scheme for periodically changing the display while still remaining responsive to the user. This task demonstrates this.
+
+Create a window containing the string "Hello World! " (the trailing space is significant). Make the text appear to be rotating right by periodically removing one letter from the end of the string and attaching it to the front. When the user clicks on the text, it should reverse its direction.
diff --git a/Task/Animation/1META.yaml b/Task/Animation/1META.yaml
new file mode 100644
index 0000000000..8dad8e0c9d
--- /dev/null
+++ b/Task/Animation/1META.yaml
@@ -0,0 +1,6 @@
+---
+category:
+- GUI
+note: Temporal media
+requires:
+- Graphics
diff --git a/Task/Animation/ActionScript/animation.as b/Task/Animation/ActionScript/animation.as
new file mode 100644
index 0000000000..ed77dc07d0
--- /dev/null
+++ b/Task/Animation/ActionScript/animation.as
@@ -0,0 +1,21 @@
+//create the text box
+var textBox:TextField = new TextField();
+addChild(textBox);
+
+var text = "Hello, World! ";
+var goingRight = true;
+
+//modify the string and update it in the text box
+function animate(e:Event)
+{
+	if(goingRight)
+		text = text.slice(text.length-1,text.length) + text.slice(0, text.length - 1);
+	else
+		text = text.slice(1) + text.slice(0,1);
+	textBox.text = text;
+}
+
+//event handler to perform the animation
+textBox.addEventListener(Event.ENTER_FRAME, animate);
+//event handler to register clicks
+textBox.addEventListener(MouseEvent.MOUSE_DOWN, function(){goingRight = !goingRight;});
diff --git a/Task/Animation/Ada/animation.ada b/Task/Animation/Ada/animation.ada
new file mode 100644
index 0000000000..f3886257ec
--- /dev/null
+++ b/Task/Animation/Ada/animation.ada
@@ -0,0 +1,92 @@
+with Gtk.Main;
+with Gtk.Handlers;
+with Gtk.Label;
+with Gtk.Button;
+with Gtk.Window;
+with Glib.Main;
+
+procedure Animation is
+   Scroll_Forwards : Boolean := True;
+
+   package Button_Callbacks is new Gtk.Handlers.Callback
+     (Gtk.Button.Gtk_Button_Record);
+
+   package Label_Timeout is new Glib.Main.Generic_Sources
+     (Gtk.Label.Gtk_Label);
+
+   package Window_Callbacks is new Gtk.Handlers.Return_Callback
+     (Gtk.Window.Gtk_Window_Record, Boolean);
+
+   --  Callback for click event
+   procedure On_Button_Click
+     (Object : access Gtk.Button.Gtk_Button_Record'Class);
+
+   --  Callback for delete event
+   function On_Main_Window_Delete
+     (Object : access Gtk.Window.Gtk_Window_Record'Class)
+      return   Boolean;
+
+   function Scroll_Text (Data : Gtk.Label.Gtk_Label) return Boolean;
+
+   procedure On_Button_Click
+     (Object : access Gtk.Button.Gtk_Button_Record'Class)
+   is
+      pragma Unreferenced (Object);
+   begin
+      Scroll_Forwards := not Scroll_Forwards;
+   end On_Button_Click;
+
+   function On_Main_Window_Delete
+     (Object : access Gtk.Window.Gtk_Window_Record'Class)
+      return   Boolean
+   is
+      pragma Unreferenced (Object);
+   begin
+      Gtk.Main.Main_Quit;
+      return True;
+   end On_Main_Window_Delete;
+
+   function Scroll_Text (Data : Gtk.Label.Gtk_Label) return Boolean is
+      Text : constant String := Gtk.Label.Get_Text (Data);
+   begin
+      if Scroll_Forwards then
+         Gtk.Label.Set_Text
+           (Label => Data,
+            Str   => Text (Text'First + 1 .. Text'Last) & Text (Text'First));
+      else
+         Gtk.Label.Set_Text
+           (Label => Data,
+            Str   => Text (Text'Last) & Text (Text'First .. Text'Last - 1));
+      end if;
+      return True;
+   end Scroll_Text;
+
+   Main_Window     : Gtk.Window.Gtk_Window;
+   Text_Button     : Gtk.Button.Gtk_Button;
+   Scrolling_Text  : Gtk.Label.Gtk_Label;
+   Timeout_ID      : Glib.Main.G_Source_Id;
+   pragma Unreferenced (Timeout_ID);
+
+begin
+   Gtk.Main.Init;
+   Gtk.Window.Gtk_New (Window => Main_Window);
+   Gtk.Label.Gtk_New (Label => Scrolling_Text, Str => "Hello World! ");
+   Gtk.Button.Gtk_New (Button => Text_Button);
+   Gtk.Button.Add (Container => Text_Button, Widget => Scrolling_Text);
+   Button_Callbacks.Connect
+     (Widget => Text_Button,
+      Name   => "clicked",
+      Marsh  => Button_Callbacks.To_Marshaller (On_Button_Click'Access));
+   Timeout_ID :=
+     Label_Timeout.Timeout_Add
+       (Interval => 125,
+        Func     => Scroll_Text'Access,
+        Data     => Scrolling_Text);
+   Gtk.Window.Add (Container => Main_Window, Widget => Text_Button);
+   Window_Callbacks.Connect
+     (Widget => Main_Window,
+      Name   => "delete_event",
+      Marsh  => Window_Callbacks.To_Marshaller (On_Main_Window_Delete'Access));
+   Gtk.Window.Show_All (Widget => Main_Window);
+   Gtk.Main.Main;
+end Animation;
diff --git a/Task/Animation/AutoHotkey/animation.ahk b/Task/Animation/AutoHotkey/animation.ahk
new file mode 100644
index 0000000000..9841aaed84
--- /dev/null
+++ b/Task/Animation/AutoHotkey/animation.ahk
@@ -0,0 +1,15 @@
+SetTimer, Animate ; Timer runs every 250 ms.
+String := "Hello World "
+Gui, Add, Text, vS gRev, %String%
+Gui, +AlwaysOnTop -SysMenu
+Gui, Show
+Return
+
+Animate:
+	String := (!Reverse) ? (SubStr(String, 0) . Substr(String, 1, StrLen(String)-1)) : (SubStr(String, 2) . SubStr(String, 1, 1))
+	GuiControl,,S, %String%
+return
+
+Rev: ; Runs whenever user clicks on the text control
+	Reverse := !Reverse
+return
diff --git a/Task/Animation/C/animation.c b/Task/Animation/C/animation.c
new file mode 100644
index 0000000000..e9c03423bc
--- /dev/null
+++ b/Task/Animation/C/animation.c
@@ -0,0 +1,72 @@
+#include 
+#include 
+#include 
+
+const gchar *hello = "Hello World! ";
+gint direction = -1;
+gint cx=0;
+gint slen=0;
+
+GtkLabel *label;
+
+void change_dir(GtkLayout *o, gpointer d)
+{
+  direction = -direction;
+}
+
+gchar *rotateby(const gchar *t, gint q, gint l)
+{
+  gint i, cl = l, j;
+  gchar *r = malloc(l+1);
+  for(i=q, j=0; cl > 0; cl--, i = (i + 1)%l, j++)
+    r[j] = t[i];
+  r[l] = 0;
+  return r;
+}
+
+gboolean scroll_it(gpointer data)
+{
+  if ( direction > 0 )
+    cx = (cx + 1) % slen;
+  else
+    cx = (cx + slen - 1 ) % slen;
+  gchar *scrolled = rotateby(hello, cx, slen);
+  gtk_label_set_text(label, scrolled);
+  free(scrolled);
+  return TRUE;
+}
+
+
+int main(int argc, char **argv)
+{
+  GtkWidget *win;
+  GtkButton *button;
+  PangoFontDescription *pd;
+
+  gtk_init(&argc, &argv);
+  win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title(GTK_WINDOW(win), "Basic Animation");
+  g_signal_connect(G_OBJECT(win), "delete-event", gtk_main_quit, NULL);
+
+  label = (GtkLabel *)gtk_label_new(hello);
+
+  // since we shift a whole character per time, it's better to use
+  // a monospace font, so that the shifting seems done at the same pace
+  pd = pango_font_description_new();
+  pango_font_description_set_family(pd, "monospace");
+  gtk_widget_modify_font(GTK_WIDGET(label), pd);
+
+  button = (GtkButton *)gtk_button_new();
+  gtk_container_add(GTK_CONTAINER(button), GTK_WIDGET(label));
+
+  gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(button));
+  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(change_dir), NULL);
+
+  slen = strlen(hello);
+
+  g_timeout_add(125, scroll_it, NULL);
+
+  gtk_widget_show_all(GTK_WIDGET(win));
+  gtk_main();
+  return 0;
+}
diff --git a/Task/Animation/Clojure/animation.clj b/Task/Animation/Clojure/animation.clj
new file mode 100644
index 0000000000..4cdb47a9b6
--- /dev/null
+++ b/Task/Animation/Clojure/animation.clj
@@ -0,0 +1,33 @@
+(import '[javax.swing JFrame JLabel])
+(import '[java.awt.event MouseAdapter])
+
+(def text "Hello World! ")
+(def text-ct (count text))
+(def rotations
+  (vec
+    (take text-ct
+      (map #(apply str %)
+        (partition text-ct 1 (cycle text))))))
+
+(def pos (atom 0))  ;position in rotations vector being displayed
+(def dir (atom 1))  ;direction of next position (-1 or 1)
+
+(def label (JLabel. text))
+
+(.addMouseListener label
+  (proxy [MouseAdapter] []
+    (mouseClicked [evt] (swap! dir -))))
+
+(defn animator []
+  (while true
+    (Thread/sleep 100)
+    (swap! pos #(-> % (+ @dir) (mod text-ct)))
+    (.setText label (rotations @pos))))
+
+(doto (JFrame.)
+  (.add label)
+  (.pack)
+  (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
+  (.setVisible true))
+
+(future-call animator)  ;simple way to run animator on a separate thread
diff --git a/Task/Animation/Haskell/animation-1.hs b/Task/Animation/Haskell/animation-1.hs
new file mode 100644
index 0000000000..40b45c2c1b
--- /dev/null
+++ b/Task/Animation/Haskell/animation-1.hs
@@ -0,0 +1,26 @@
+import Graphics.HGL.Units (Time, Point, Size, )
+import Graphics.HGL.Draw.Monad (Graphic, )
+import Graphics.HGL.Draw.Text
+import Graphics.HGL.Draw.Font
+import Graphics.HGL.Window
+import Graphics.HGL.Run
+import Graphics.HGL.Utils
+
+import Control.Exception (bracket, )
+
+runAnim = runGraphics $
+ bracket
+  (openWindowEx "Basic animation task" Nothing (250,50) DoubleBuffered (Just 110))
+  closeWindow
+  (\w -> do
+    f <- createFont (64,28) 0 False False "courier"
+    let loop t dir = do
+	  e <- maybeGetWindowEvent w
+	  let d = case e of
+		  Just (Button _ True False)  -> -dir
+		  _ -> dir
+	      t' = if d == 1 then last t : init t else tail t ++ [head t]
+	  setGraphic w (withFont f $ text (5,10) t') >> getWindowTick w
+	  loop  t' d
+	
+    loop "Hello world ! " 1  )
diff --git a/Task/Animation/Haskell/animation-2.hs b/Task/Animation/Haskell/animation-2.hs
new file mode 100644
index 0000000000..26b21fed32
--- /dev/null
+++ b/Task/Animation/Haskell/animation-2.hs
@@ -0,0 +1 @@
+*Main> runAnim
diff --git a/Task/Animation/Java/animation.java b/Task/Animation/Java/animation.java
new file mode 100644
index 0000000000..23d0674a04
--- /dev/null
+++ b/Task/Animation/Java/animation.java
@@ -0,0 +1,59 @@
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.Timer;
+import java.util.TimerTask;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+
+public class Rotate extends JFrame {
+  String text = "Hello World! ";
+  JLabel label = new JLabel(text);
+  boolean rotRight = true;
+  int startIdx = 0;
+
+  public Rotate() {
+    label.addMouseListener(new MouseAdapter() {
+      @Override
+      public void mouseClicked(MouseEvent evt) {
+        rotRight = !rotRight;
+      }
+    });
+    add(label);
+    pack();
+    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+    setVisible(true);
+  }
+
+  public static void main(String[] args) {
+    final Rotate rot = new Rotate();
+    TimerTask task = new TimerTask() {
+      public void run() {
+        if (rot.rotRight) {
+          rot.startIdx++;
+          if (rot.startIdx >= rot.text.length()) {
+            rot.startIdx -= rot.text.length();
+          }
+        } else {
+          rot.startIdx--;
+          if (rot.startIdx < 0) {
+            rot.startIdx += rot.text.length();
+          }
+        }
+        rot.label.setText(getRotatedText(rot.text, rot.startIdx));
+      }
+    };
+    Timer timer = new Timer(false);
+    timer.schedule(task, 0, 500);
+  }
+
+  public static String getRotatedText(String text, int startIdx) {
+    String ret = "";
+    int i = startIdx;
+    do {
+      ret += text.charAt(i) + "";
+      i++;
+      i = i % text.length();
+    } while (i != startIdx);
+    return ret;
+  }
+}
diff --git a/Task/Animation/JavaScript/animation.js b/Task/Animation/JavaScript/animation.js
new file mode 100644
index 0000000000..5fa2ce8f9f
--- /dev/null
+++ b/Task/Animation/JavaScript/animation.js
@@ -0,0 +1,23 @@
+
+    
+
+    
+    Hello World! 
+
diff --git a/Task/Animation/Perl/animation.pl b/Task/Animation/Perl/animation.pl
new file mode 100644
index 0000000000..533912f4d0
--- /dev/null
+++ b/Task/Animation/Perl/animation.pl
@@ -0,0 +1,11 @@
+use XUL::Gui;
+
+my $dir = '(.+)(.)';
+interval {
+    ID(lbl)->value =~ s/$dir/$2$1/;
+} 75;
+
+display Label
+    id    => 'lbl',
+    value => "Hello World! ",
+    onclick => sub {toggle $dir => '(.+)(.)', '(.)(.+)'};
diff --git a/Task/Animation/PicoLisp/animation-1.l b/Task/Animation/PicoLisp/animation-1.l
new file mode 100644
index 0000000000..9b0a3029d1
--- /dev/null
+++ b/Task/Animation/PicoLisp/animation-1.l
@@ -0,0 +1,14 @@
+#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
+
+(prin "^[[?9h")  # Mouse reporting on
+
+(setq Dir 1  Text (chop "Hello World! "))
+
+(loop
+   (prin (do Dir (rot Text)))
+   (when (= "^[" (key 200))
+      (key) (key)
+      (when (= " " (key))  # Left button
+         (setq Dir (if (= 1 Dir) 12 1)) )
+      (key) (key) )
+   (do (length Text) (prin "^H")) )
diff --git a/Task/Animation/PicoLisp/animation-2.l b/Task/Animation/PicoLisp/animation-2.l
new file mode 100644
index 0000000000..8ba222cccc
--- /dev/null
+++ b/Task/Animation/PicoLisp/animation-2.l
@@ -0,0 +1,18 @@
+#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
+
+(load "@ext.l" "@lib/http.l" "@lib/xhtml.l" "@lib/form.l")
+
+(one *Dir)
+
+(de start ()
+   (app)
+   (action
+      (html 0 "Animation" "@lib.css" NIL
+         (form NIL
+            (gui '(+Button)
+               '(pack (do *Dir (rot '`(chop "Hello World! "))))
+               '(setq *Dir (if (= 1 *Dir) 12 1)) )
+            (gui '(+Click +Auto +Button) 400 'This 1000 "Start") ) ) ) )
+
+(server 8080 "!start")
+(wait)
diff --git a/Task/Animation/PicoLisp/animation-3.l b/Task/Animation/PicoLisp/animation-3.l
new file mode 100644
index 0000000000..24d54dd776
--- /dev/null
+++ b/Task/Animation/PicoLisp/animation-3.l
@@ -0,0 +1,22 @@
+#!ersatz/pil
+
+(setq
+   Dir 1
+   Text (chop "Hello World! ")
+   Frame (java "javax.swing.JFrame" T "Animation")
+   Label (java "javax.swing.JLabel" T (pack Text)) )
+
+(java Label 'addMouseListener
+   (interface "java.awt.event.MouseListener"
+      'mouseClicked '((Ev) (setq Dir (if (= 1 Dir) 12 1)))
+      'mouseEntered nil
+      'mouseExited nil
+      'mousePressed nil
+      'mouseReleased nil ) )
+
+(java Frame 'add Label)
+(java Frame 'pack)
+(java Frame 'setVisible T)
+(loop
+   (wait 200)
+   (java Label 'setText (pack (do Dir (rot Text)))) )
diff --git a/Task/Animation/Prolog/animation.pro b/Task/Animation/Prolog/animation.pro
new file mode 100644
index 0000000000..03eb021adf
--- /dev/null
+++ b/Task/Animation/Prolog/animation.pro
@@ -0,0 +1,74 @@
+:- use_module(library(pce)).
+
+animation :-
+    new(D, window('Animation')),
+    new(Label, label(hello, 'Hello world ! ')),
+    send(D, display, Label, point(1,10)),
+    new(@animation, animation(Label)),
+    send(D, recogniser,
+         new(_G, my_click_gesture(left, ''))),
+
+    send(D, done_message, and(message(@animation, free),
+                  message(@receiver, destroy))),
+    send(D, open),
+    send(@animation?mytimer, start).
+
+
+:- pce_begin_class(animation(label), object).
+variable(label, object,  both, "Display window").
+variable(delta,    object, both,  "increment of the angle").
+variable(mytimer, timer, both, "timer of the animation").
+
+initialise(P, W:object) :->
+        "Creation of the object"::
+        send(P, label, W),
+        send(P, delta, to_left),
+    send(P, mytimer, new(_, timer(0.5,message(P, anim_message)))).
+
+% method called when the object is destroyed
+% first the timer is stopped
+% then all the resources are freed
+unlink(P) :->
+    send(P?mytimer, stop),
+    send(P, send_super, unlink).
+
+
+% message processed by the timer
+anim_message(P) :->
+    get(P, label, L),
+    get(L, selection, S),
+    get(P, delta, Delta),
+    compute(Delta, S, S1),
+    new(A, name(S1)),
+    send(L, selection, A).
+
+
+:- pce_end_class.
+
+:- pce_begin_class(my_click_gesture, click_gesture,
+           "Click in a window").
+
+class_variable(button, button_name, left,
+           "By default click with left button").
+
+terminate(G, Ev:event) :->
+    send(G, send_super, terminate, Ev),
+    get(@animation, delta, D),
+    (   D = to_left -> D1 = to_right; D1 = to_left),
+    send(@animation, delta, D1).
+
+:- pce_end_class.
+
+
+% compute next text to be dispalyed
+compute(to_right, S, S1) :-
+    get(S, size, Len),
+    Len1 is Len - 1,
+    get(S, sub, Len1, Str),
+    get(S, delete_suffix, Str, V),
+    get(Str, append, V, S1).
+
+compute(to_left, S, S1) :-
+    get(S, sub, 0, 1, Str),
+    get(S, delete_prefix, Str, V),
+    get(V, append, Str, S1).
diff --git a/Task/Animation/Python/animation-1.py b/Task/Animation/Python/animation-1.py
new file mode 100644
index 0000000000..a72cbad5d2
--- /dev/null
+++ b/Task/Animation/Python/animation-1.py
@@ -0,0 +1,55 @@
+import pygame, sys
+from pygame.locals import *
+pygame.init()
+
+YSIZE = 40
+XSIZE = 150
+
+TEXT = "Hello World! "
+FONTSIZE = 32
+
+LEFT = False
+RIGHT = True
+
+DIR = RIGHT
+
+TIMETICK = 180
+TICK = USEREVENT + 2
+
+TEXTBOX = pygame.Rect(10,10,XSIZE,YSIZE)
+
+pygame.time.set_timer(TICK, TIMETICK)
+
+window = pygame.display.set_mode((XSIZE, YSIZE))
+pygame.display.set_caption("Animation")
+
+font = pygame.font.SysFont(None, FONTSIZE)
+screen = pygame.display.get_surface()
+
+def rotate():
+    index = DIR and -1 or 1
+    global TEXT
+    TEXT = TEXT[index:]+TEXT[:index]
+
+def click(position):
+    if TEXTBOX.collidepoint(position):
+        global DIR
+        DIR = not DIR
+
+def draw():
+    surface = font.render(TEXT, True, (255,255,255), (0,0,0))
+    global TEXTBOX
+    TEXTBOX = screen.blit(surface, TEXTBOX)
+
+def input(event):
+    if event.type == QUIT:
+        sys.exit(0)
+    elif event.type == MOUSEBUTTONDOWN:
+        click(event.pos)
+    elif event.type == TICK:
+        draw()
+        rotate()
+
+while True:
+    input(pygame.event.wait())
+    pygame.display.flip()
diff --git a/Task/Animation/Python/animation-2.py b/Task/Animation/Python/animation-2.py
new file mode 100644
index 0000000000..5668db0373
--- /dev/null
+++ b/Task/Animation/Python/animation-2.py
@@ -0,0 +1,23 @@
+import Tkinter as tki
+
+def scroll_text(s, how_many):
+    return s[how_many:] + s[:how_many]
+
+direction = 1
+tk = tki.Tk()
+var = tki.Variable(tk)
+
+def mouse_handler(point):
+    global direction
+    direction *= -1
+
+def timer_handler():
+    var.set(scroll_text(var.get(),direction))
+    tk.after(125, timer_handler)
+
+var.set('Hello, World! ')
+tki.Label(tk, textvariable=var).pack()
+tk.bind("", mouse_handler)
+tk.after(125, timer_handler)
+tk.title('Python Animation')
+tki.mainloop()
diff --git a/Task/Animation/R/animation.r b/Task/Animation/R/animation.r
new file mode 100644
index 0000000000..c7af664d7a
--- /dev/null
+++ b/Task/Animation/R/animation.r
@@ -0,0 +1,39 @@
+rotate_string <- function(x, forwards)
+{
+Β  Β nchx <- nchar(x)
+Β  Β if(forwards)
+Β  Β { Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+Β  Β  Β  paste(substr(x, nchx, nchx), substr(x, 1, nchx - 1), sep = "")
+Β  Β } else
+Β  Β { Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+Β  Β  Β  paste(substr(x, 2, nchx), substr(x, 1, 1), sep = "")
+Β  Β }
+}
+
+handle_rotate_label <- function(obj, interval = 100)
+{
+Β  addHandlerIdle(obj,
+Β Β Β  handler = function(h, ...)
+Β Β Β  {
+Β Β Β Β Β Β  svalue(obj) <- rotate_string(svalue(obj), tag(obj, "forwards"))
+Β Β Β  },
+Β Β Β  interval = interval
+Β  )
+}
+
+handle_change_direction_on_click <- function(obj)
+{
+Β  addHandlerClicked(obj,
+Β Β Β  handler = function(h, ...)
+Β Β Β  {
+Β Β Β Β Β  tag(h$obj, "forwards") <- !tag(h$obj, "forwards")
+Β Β Β  }
+Β  )
+}
+
+library(gWidgets)
+library(gWidgetstcltk) #or library(gWidgetsRGtk2)Β or library(gWidgetsrJava)Β  Β  Β  Β  Β  Β  Β 
+lab <- glabel("Hello World! ", container = gwindow()) Β 
+tag(lab, "forwards") <- TRUE
+handle_rotate_label(lab)
+handle_change_direction_on_click(lab)
diff --git a/Task/Animation/Racket/animation.rkt b/Task/Animation/Racket/animation.rkt
new file mode 100644
index 0000000000..d86e6315ba
--- /dev/null
+++ b/Task/Animation/Racket/animation.rkt
@@ -0,0 +1,40 @@
+#lang racket/gui
+
+;; One of 'left or 'right
+(define direction 'left)
+
+;; Set up the GUI
+(define animation-frame%
+  (class frame%
+    (super-new [label "Animation"])
+    ;; reverse direction on a click
+    (define/override (on-subwindow-event win evt)
+      (when (send evt button-down?)
+        (set! direction
+              (if (eq? direction 'left)
+                  'right
+                  'left))))))
+
+(define frame (new animation-frame%))
+(define msg (new message%
+                 [label "Hello World! "]
+                 [parent frame]))
+
+;; Timer callback to adjust the message
+(define (callback)
+  (define old-label (send msg get-label))
+  (define len (string-length old-label))
+  (if (eq? direction 'left)
+      (send msg set-label
+            (string-append (substring old-label 1)
+                           (substring old-label 0 1)))
+      (send msg set-label
+            (string-append (substring old-label (- len 1) len)
+                           (substring old-label 0 (- len 1))))))
+
+;; Set a timer and go
+(define timer (new timer%
+                   [notify-callback callback]
+                   [interval 500]))
+
+(send frame show #t)
diff --git a/Task/Animation/Ruby/animation-1.rb b/Task/Animation/Ruby/animation-1.rb
new file mode 100644
index 0000000000..e87a06bfb4
--- /dev/null
+++ b/Task/Animation/Ruby/animation-1.rb
@@ -0,0 +1,27 @@
+require 'tk'
+$str = TkVariable.new("Hello World! ")
+$dir = :right
+
+def animate
+  $str.value = shift_char($str.value, $dir)
+  $root.after(125) {animate}
+end
+
+def shift_char(str, dir)
+  case dir
+  when :right then str[-1,1] + str[0..-2]
+  when :left  then str[1..-1] + str[0,1]
+  end
+end
+
+$root = TkRoot.new("title" => "Basic Animation")
+
+TkLabel.new($root) do
+  textvariable $str
+  font "Courier 14"
+  pack {side 'top'}
+  bind("ButtonPress-1") {$dir = {:right=>:left,:left=>:right}[$dir]}
+end
+
+animate
+Tk.mainloop
diff --git a/Task/Animation/Ruby/animation-2.rb b/Task/Animation/Ruby/animation-2.rb
new file mode 100644
index 0000000000..d32dcda708
--- /dev/null
+++ b/Task/Animation/Ruby/animation-2.rb
@@ -0,0 +1,11 @@
+Shoes.app do
+  @direction = 1
+  @label = para "Hello World! ", :family => 'monospace'
+
+  click {|button, left, top| @direction *= -1 if button == 1}
+
+  animate(8) do |f|
+    t = @label.text
+    @label.text = @direction > 0 ? t[-1] + t[0..-2] : t[1..-1] + t[0]
+  end
+end
diff --git a/Task/Animation/Scala/animation.scala b/Task/Animation/Scala/animation.scala
new file mode 100644
index 0000000000..23d3e4239d
--- /dev/null
+++ b/Task/Animation/Scala/animation.scala
@@ -0,0 +1,32 @@
+import scala.actors.Actor.{actor, loop, reactWithin, exit}
+import scala.actors.TIMEOUT
+import scala.swing.{SimpleSwingApplication, MainFrame, Label}
+import scala.swing.event.MouseClicked
+
+case object Revert
+
+object BasicAnimation extends SimpleSwingApplication {
+  val label = new Label("Hello World! ")
+  val rotator = actor {
+    var goingRight = true
+    loop {
+      reactWithin(250 /*ms*/) {
+        case Revert => goingRight = !goingRight
+        case TIMEOUT =>
+          if (goingRight)
+            label.text = label.text.last + label.text.init
+          else
+            label.text = label.text.tail + label.text.head
+        case unknown => println("Unknown message "+unknown); exit()
+      }
+    }
+  }
+  def top = new MainFrame {
+    title = "Basic Animation"
+    contents = label
+  }
+  listenTo(label.mouse.clicks) // use "Mouse" instead of "mouse" on Scala 2.7
+  reactions += {
+    case _ : MouseClicked => rotator ! Revert
+  }
+}
diff --git a/Task/Animation/Tcl/animation.tcl b/Task/Animation/Tcl/animation.tcl
new file mode 100644
index 0000000000..561f24be08
--- /dev/null
+++ b/Task/Animation/Tcl/animation.tcl
@@ -0,0 +1,20 @@
+package require Tk
+set s "Hello World! "
+set dir 0
+# Periodic animation callback
+proc animate {} {
+    global dir s
+    if {$dir} {
+        set s [string range $s 1 end][string index $s 0]
+    } else {
+        set s [string index $s end][string range $s 0 end-1]
+    }
+    # We will run this code ~8 times a second (== 125ms delay)
+    after 125 animate
+}
+# Make the label (constant width font looks better)
+pack [label .l -textvariable s -font {Courier 14}]
+# Make a mouse click reverse the direction
+bind .l  {set dir [expr {!$dir}]}
+# Start the animation
+animate
diff --git a/Task/Anonymous-recursion/0DESCRIPTION b/Task/Anonymous-recursion/0DESCRIPTION
new file mode 100644
index 0000000000..59f9003a1e
--- /dev/null
+++ b/Task/Anonymous-recursion/0DESCRIPTION
@@ -0,0 +1,15 @@
+While implementing a recursive function, it often happens that we must resort to a separate "helper function" to handle the actual recursion.
+
+This is usually the case when directly calling the current function would waste too many resources (stack space, execution time), cause unwanted side-effects, and/or the function doesn't have the right arguments and/and return values.
+
+So we end up inventing some silly name like "foo2" or "foo_helper". I have always found it painful to come up with a proper name, and see a quite some disadvantages:
+
+* You have to think up a name, which then pollutes the namespace
+* A function is created which is called from nowhere else
+* The program flow in the source code is interrupted
+
+Some languages allow you to embed recursion directly in-place. This might work via a label, a local ''gosub'' instruction, or some special keyword.
+
+Anonymous recursion can also be accomplished using the [[Y combinator]].
+
+If possible, demonstrate this by writing the recursive version of the fibonacci function (see [[Fibonacci sequence]]) which checks for a negative argument before doing the actual recursion.
diff --git a/Task/Anonymous-recursion/1META.yaml b/Task/Anonymous-recursion/1META.yaml
new file mode 100644
index 0000000000..5bb2604b9d
--- /dev/null
+++ b/Task/Anonymous-recursion/1META.yaml
@@ -0,0 +1,2 @@
+---
+note: Recursion
diff --git a/Task/Anonymous-recursion/Ada/anonymous-recursion.ada b/Task/Anonymous-recursion/Ada/anonymous-recursion.ada
new file mode 100644
index 0000000000..b45d05ffb1
--- /dev/null
+++ b/Task/Anonymous-recursion/Ada/anonymous-recursion.ada
@@ -0,0 +1,16 @@
+   function Fib (X: in Integer) return Integer is
+      function Actual_Fib (N: in Integer) return Integer is
+      begin
+         if N < 2 then
+            return N;
+         else
+            return Actual_Fib (N-1) + Actual_Fib (N-2);
+         end if;
+      end Actual_Fib;
+   begin
+      if X < 0 then
+         raise Constraint_Error;
+      else
+         return Actual_Fib (X);
+      end if;
+   end Fib;
diff --git a/Task/Anonymous-recursion/AutoHotkey/anonymous-recursion-1.ahk b/Task/Anonymous-recursion/AutoHotkey/anonymous-recursion-1.ahk
new file mode 100644
index 0000000000..73afd29be2
--- /dev/null
+++ b/Task/Anonymous-recursion/AutoHotkey/anonymous-recursion-1.ahk
@@ -0,0 +1,8 @@
+fib(n)
+{       if(n < 0)
+                return error
+        else if(n < 2)
+                return 1
+        else
+                return n * fib(n-1)
+}
diff --git a/Task/Anonymous-recursion/AutoHotkey/anonymous-recursion-2.ahk b/Task/Anonymous-recursion/AutoHotkey/anonymous-recursion-2.ahk
new file mode 100644
index 0000000000..83e3951faa
--- /dev/null
+++ b/Task/Anonymous-recursion/AutoHotkey/anonymous-recursion-2.ahk
@@ -0,0 +1,3 @@
+fib(n)
+{       return n < 0 ? "error" : n < 2 ? 1 : n * fib(n-1)
+}
diff --git a/Task/Anonymous-recursion/Axiom/anonymous-recursion-1.axiom b/Task/Anonymous-recursion/Axiom/anonymous-recursion-1.axiom
new file mode 100644
index 0000000000..947b80986f
--- /dev/null
+++ b/Task/Anonymous-recursion/Axiom/anonymous-recursion-1.axiom
@@ -0,0 +1,10 @@
+)abbrev package TESTP TestPackage
+Z ==> Integer
+TestPackage : with
+    fib : Z -> Z
+  == add
+    fib x ==
+      x <= 0 => error "argument outside of range"
+      f : Reference((Z,Z,Z) -> Z) := ref((n, v1, v2) +-> 0)
+      f() := (n, v1, v2) +-> if n<2 then v2 else f()(n-1,v2,v1+v2)
+      f()(x,1,1)
diff --git a/Task/Anonymous-recursion/Axiom/anonymous-recursion-2.axiom b/Task/Anonymous-recursion/Axiom/anonymous-recursion-2.axiom
new file mode 100644
index 0000000000..c12d66b649
--- /dev/null
+++ b/Task/Anonymous-recursion/Axiom/anonymous-recursion-2.axiom
@@ -0,0 +1,10 @@
+#include "aldor";
+#include "aldorio";
+import from Integer;
+Z ==> Integer;
+fib(x:Z):Z == {
+	x <= 0 => throw SyntaxException;
+	f(n:Z,v1:Z,v2:Z):Z == if n<2 then v2 else f(n-1,v2,v1+v2);
+	f(x,1,1);
+}
+stdout << fib(10000);
diff --git a/Task/Anonymous-recursion/C/anonymous-recursion.c b/Task/Anonymous-recursion/C/anonymous-recursion.c
new file mode 100644
index 0000000000..e430991c36
--- /dev/null
+++ b/Task/Anonymous-recursion/C/anonymous-recursion.c
@@ -0,0 +1,29 @@
+#include 
+
+long fib(long x)
+{
+        long fib_i(long n) { return n < 2 ? n : fib_i(n - 2) + fib_i(n - 1); };
+        if (x < 0) {
+                printf("Bad argument: fib(%ld)\n", x);
+                return -1;
+        }
+        return fib_i(x);
+}
+
+long fib_i(long n) /* just to show the fib_i() inside fib() has no bearing outside it */
+{
+        printf("This is not the fib you are looking for\n");
+        return -1;
+}
+
+int main()
+{
+        long x;
+        for (x = -1; x < 4; x ++)
+                printf("fib %ld = %ld\n", x, fib(x));
+
+        printf("calling fib_i from outside fib:\n");
+        fib_i(3);
+
+        return 0;
+}
diff --git a/Task/Anonymous-recursion/Clojure/anonymous-recursion.clj b/Task/Anonymous-recursion/Clojure/anonymous-recursion.clj
new file mode 100644
index 0000000000..f903f11b42
--- /dev/null
+++ b/Task/Anonymous-recursion/Clojure/anonymous-recursion.clj
@@ -0,0 +1,7 @@
+(defn fib [n]
+  (when (neg? n)
+    (throw (new IllegalArgumentException "n should be > 0")))
+  (loop [n n, v1 1, v2 1]
+    (if (< n 2)
+      v2
+      (recur (dec n) v2 (+ v1 v2)))))
diff --git a/Task/Anonymous-recursion/CoffeeScript/anonymous-recursion.coffee b/Task/Anonymous-recursion/CoffeeScript/anonymous-recursion.coffee
new file mode 100644
index 0000000000..3e7975e86e
--- /dev/null
+++ b/Task/Anonymous-recursion/CoffeeScript/anonymous-recursion.coffee
@@ -0,0 +1,17 @@
+# This is a rather obscure technique to have an anonymous
+# function call itself.
+fibonacci = (n) ->
+  throw "Argument cannot be negative" if n < 0
+  do (n) ->
+      return n if n <= 1
+      arguments.callee(n-2) + arguments.callee(n-1)
+
+# Since it's pretty lightweight to assign an anonymous
+# function to a local variable, the idiom below might be
+# more preferred.
+fibonacci2 = (n) ->
+  throw "Argument cannot be negative" if n < 0
+  recurse = (n) ->
+      return n if n <= 1
+      recurse(n-2) + recurse(n-1)
+  recurse(n)
diff --git a/Task/Anonymous-recursion/Dylan/anonymous-recursion.dylan b/Task/Anonymous-recursion/Dylan/anonymous-recursion.dylan
new file mode 100644
index 0000000000..5f1f3d5de5
--- /dev/null
+++ b/Task/Anonymous-recursion/Dylan/anonymous-recursion.dylan
@@ -0,0 +1,13 @@
+define function fib (n)
+  when (n < 0)
+    error("Can't take fibonacci of negative integer: %d\n", n)
+  end;
+  local method fib1 (n, a, b)
+    if (n = 0)
+      a
+    else
+      fib1(n - 1, b, a + b)
+    end
+  end;
+  fib1(n, 0, 1)
+end
diff --git a/Task/Anonymous-recursion/Forth/anonymous-recursion-1.fth b/Task/Anonymous-recursion/Forth/anonymous-recursion-1.fth
new file mode 100644
index 0000000000..c024f046af
--- /dev/null
+++ b/Task/Anonymous-recursion/Forth/anonymous-recursion-1.fth
@@ -0,0 +1,7 @@
+:noname ( n -- n' )
+  dup 2 < ?exit
+  1- dup recurse swap 1- recurse + ; ( xt )
+
+: fib ( +n -- n' )
+  dup 0< abort" Negative numbers don't exist."
+  [ ( xt from the :NONAME above ) compile, ] ;
diff --git a/Task/Anonymous-recursion/Forth/anonymous-recursion-2.fth b/Task/Anonymous-recursion/Forth/anonymous-recursion-2.fth
new file mode 100644
index 0000000000..3320b83bce
--- /dev/null
+++ b/Task/Anonymous-recursion/Forth/anonymous-recursion-2.fth
@@ -0,0 +1,5 @@
+( xt from :noname in the previous example )
+variable pocket  pocket !
+: fib ( +n -- n' )
+  dup 0< abort" Negative numbers don't exist."
+  [ pocket @ compile, ] ;
diff --git a/Task/Anonymous-recursion/Fortran/anonymous-recursion.f b/Task/Anonymous-recursion/Fortran/anonymous-recursion.f
new file mode 100644
index 0000000000..a89251c9f4
--- /dev/null
+++ b/Task/Anonymous-recursion/Fortran/anonymous-recursion.f
@@ -0,0 +1,18 @@
+integer function fib(n)
+  integer, intent(in) :: n
+  if (n < 0 ) then
+    write (*,*) 'Bad argument: fib(',n,')'
+    stop
+  else
+    fib = purefib(n)
+  end if
+contains
+  recursive pure integer function purefib(n) result(f)
+    integer, intent(in) :: n
+    if (n < 2 ) then
+      f = n
+    else
+      f = purefib(n-1) + purefib(n-2)
+    end if
+  end function purefib
+end function fib
diff --git a/Task/Anonymous-recursion/Go/anonymous-recursion.go b/Task/Anonymous-recursion/Go/anonymous-recursion.go
new file mode 100644
index 0000000000..e5e4355f1e
--- /dev/null
+++ b/Task/Anonymous-recursion/Go/anonymous-recursion.go
@@ -0,0 +1,47 @@
+package main
+
+import "fmt"
+
+func main() {
+    for _, n := range []int{0, 1, 2, 3, 4, 5, 10, 40, -1} {
+        f, ok := arFib(n)
+        if ok {
+            fmt.Printf("fib %d = %d\n", n, f)
+        } else {
+            fmt.Println("fib undefined for negative numbers")
+        }
+    }
+}
+
+func arFib(n int) (int, bool) {
+    switch {
+    case n < 0:
+        return 0, false
+    case n < 2:
+        return n, true
+    }
+    return yc(func(recurse fn) fn {
+        return func(left, term1, term2 int) int {
+            if left == 0 {
+                return term1+term2
+            }
+            return recurse(left-1, term1+term2, term1)
+        }
+    })(n-2, 1, 0), true
+}
+
+type fn func(int, int, int) int
+type ff func(fn) fn
+type fx func(fx) fn
+
+func yc(f ff) fn {
+    return func(x fx) fn {
+        return f(func(a1, a2, a3 int) int {
+            return x(x)(a1, a2, a3)
+        })
+    }(func(x fx) fn {
+        return f(func(a1, a2, a3 int) int {
+            return x(x)(a1, a2, a3)
+        })
+    })
+}
diff --git a/Task/Anonymous-recursion/Haskell/anonymous-recursion-1.hs b/Task/Anonymous-recursion/Haskell/anonymous-recursion-1.hs
new file mode 100644
index 0000000000..9a0189fb95
--- /dev/null
+++ b/Task/Anonymous-recursion/Haskell/anonymous-recursion-1.hs
@@ -0,0 +1,7 @@
+fib :: Integer -> Maybe Integer
+fib n
+  | n < 0 = Nothing
+  | otherwise = Just $ real n
+              where real 0 = 1
+                    real 1 = 1
+                    real n = real (n-1) + real (n-2)
diff --git a/Task/Anonymous-recursion/Haskell/anonymous-recursion-2.hs b/Task/Anonymous-recursion/Haskell/anonymous-recursion-2.hs
new file mode 100644
index 0000000000..f874d10cb0
--- /dev/null
+++ b/Task/Anonymous-recursion/Haskell/anonymous-recursion-2.hs
@@ -0,0 +1,6 @@
+import Data.Function (fix)
+
+fib :: Integer -> Maybe Integer
+fib n
+  | n < 0 = Nothing
+  | otherwise = Just $ fix (\f -> (\n -> if n > 1 then f (n-1) + f (n-2) else 1)) n
diff --git a/Task/Anonymous-recursion/Haskell/anonymous-recursion-3.hs b/Task/Anonymous-recursion/Haskell/anonymous-recursion-3.hs
new file mode 100644
index 0000000000..e6427c745c
--- /dev/null
+++ b/Task/Anonymous-recursion/Haskell/anonymous-recursion-3.hs
@@ -0,0 +1,2 @@
+ghci> map fib [-4..10]
+[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 2,Just 3,Just 5,Just 8,Just 13,Just 21,Just 34,Just 55,Just 89]
diff --git a/Task/Anonymous-recursion/Java/anonymous-recursion-1.java b/Task/Anonymous-recursion/Java/anonymous-recursion-1.java
new file mode 100644
index 0000000000..6027c471bb
--- /dev/null
+++ b/Task/Anonymous-recursion/Java/anonymous-recursion-1.java
@@ -0,0 +1,9 @@
+public static long fib(int n)
+{
+  if (n < 0)
+    throw new IllegalArgumentException("n can not be a negative number");
+  return new Object() {
+    private long fibInner(int n)
+    {  return (n < 2) ? n : (fibInner(n - 1) + fibInner(n - 2));  }
+  }.fibInner(n);
+}
diff --git a/Task/Anonymous-recursion/Java/anonymous-recursion-2.java b/Task/Anonymous-recursion/Java/anonymous-recursion-2.java
new file mode 100644
index 0000000000..1e517400d1
--- /dev/null
+++ b/Task/Anonymous-recursion/Java/anonymous-recursion-2.java
@@ -0,0 +1,24 @@
+import java.util.function.Function;
+
+@FunctionalInterface
+interface SelfApplicable {
+  OUTPUT apply(SelfApplicable input);
+}
+
+class Utils {
+  public static  SelfApplicable, Function>, Function>> y(Class input, Class output) {
+    return y -> f -> x -> f.apply(y.apply(y).apply(f)).apply(x);
+  }
+
+  public static  Function, Function>, Function> fix(Class input, Class output) {
+    return y(input, output).apply(y(input, output));
+  }
+
+  public static long fib(int m) {
+    if (m < 0)
+      throw new IllegalArgumentException("n can not be a negative number");
+    return fix(Integer.class, Long.class).apply(
+      f -> n -> (n < 2) ? n : (f.apply(n - 1) + f.apply(n - 2))
+    ).apply(m);
+  }
+}
diff --git a/Task/Anonymous-recursion/JavaScript/anonymous-recursion-1.js b/Task/Anonymous-recursion/JavaScript/anonymous-recursion-1.js
new file mode 100644
index 0000000000..b0d573f6f9
--- /dev/null
+++ b/Task/Anonymous-recursion/JavaScript/anonymous-recursion-1.js
@@ -0,0 +1,11 @@
+function fibo(n) {
+  if (n < 0)
+    throw "Argument cannot be negative";
+  else
+    return (function(n) {
+      if (n < 2)
+        return 1;
+      else
+        return arguments.callee(n-1) + arguments.callee(n-2);
+    })(n);
+}
diff --git a/Task/Anonymous-recursion/JavaScript/anonymous-recursion-2.js b/Task/Anonymous-recursion/JavaScript/anonymous-recursion-2.js
new file mode 100644
index 0000000000..5686788567
--- /dev/null
+++ b/Task/Anonymous-recursion/JavaScript/anonymous-recursion-2.js
@@ -0,0 +1,11 @@
+function fibo(n) {
+  if (n < 0)
+    throw "Argument cannot be negative";
+  else
+    return (function fib(n) {
+      if (n < 2)
+        return 1;
+      else
+        return fib(n-1) + fib(n-2);
+    })(n);
+}
diff --git a/Task/Anonymous-recursion/Lua/anonymous-recursion-1.lua b/Task/Anonymous-recursion/Lua/anonymous-recursion-1.lua
new file mode 100644
index 0000000000..2fb7fcca0a
--- /dev/null
+++ b/Task/Anonymous-recursion/Lua/anonymous-recursion-1.lua
@@ -0,0 +1,7 @@
+local function Y(x) return (function (f) return f(f) end)(function(y) return x(function(z) return y(y)(z) end) end) end
+
+return Y(function(fibs)
+  return function(n)
+    return n < 2 and 1 or fibs(n - 1) + fibs(n - 2)
+  end
+end)
diff --git a/Task/Anonymous-recursion/Lua/anonymous-recursion-2.lua b/Task/Anonymous-recursion/Lua/anonymous-recursion-2.lua
new file mode 100644
index 0000000000..f8f5fc2e01
--- /dev/null
+++ b/Task/Anonymous-recursion/Lua/anonymous-recursion-2.lua
@@ -0,0 +1,4 @@
+return setmetatable({1,1},{__index = function(self, n)
+  self[n] = self[n-1] + self[n-2]
+  return self[n]
+end})
diff --git a/Task/Anonymous-recursion/PHP/anonymous-recursion-1.php b/Task/Anonymous-recursion/PHP/anonymous-recursion-1.php
new file mode 100644
index 0000000000..43246dc489
--- /dev/null
+++ b/Task/Anonymous-recursion/PHP/anonymous-recursion-1.php
@@ -0,0 +1,13 @@
+
diff --git a/Task/Anonymous-recursion/PHP/anonymous-recursion-2.php b/Task/Anonymous-recursion/PHP/anonymous-recursion-2.php
new file mode 100644
index 0000000000..cf312a7bef
--- /dev/null
+++ b/Task/Anonymous-recursion/PHP/anonymous-recursion-2.php
@@ -0,0 +1,14 @@
+
diff --git a/Task/Anonymous-recursion/Perl/anonymous-recursion-1.pl b/Task/Anonymous-recursion/Perl/anonymous-recursion-1.pl
new file mode 100644
index 0000000000..10afc17007
--- /dev/null
+++ b/Task/Anonymous-recursion/Perl/anonymous-recursion-1.pl
@@ -0,0 +1,14 @@
+sub recur (&@) {
+    my $f = shift;
+    local *recurse = $f;
+    $f->(@_);
+}
+
+sub fibo {
+    my $n = shift;
+    $n < 0 and die 'Negative argument';
+    recur {
+        my $m = shift;
+        $m < 3 ? 1 : recurse($m - 1) + recurse($m - 2);
+    } $n;
+}
diff --git a/Task/Anonymous-recursion/Perl/anonymous-recursion-2.pl b/Task/Anonymous-recursion/Perl/anonymous-recursion-2.pl
new file mode 100644
index 0000000000..f5e7b05a39
--- /dev/null
+++ b/Task/Anonymous-recursion/Perl/anonymous-recursion-2.pl
@@ -0,0 +1,13 @@
+sub fib {
+	my ($n) = @_;
+	die "negative arg $n" if $n < 0;
+	# put anon sub on stack and do a magic goto to it
+	@_ = ($n, sub {
+		my ($n, $f) = @_;
+		# anon sub recurs with the sub ref on stack
+		$n < 2 ? $n : $f->($n - 1, $f) + $f->($n - 2, $f)
+	});
+	goto $_[1];
+}
+
+print(fib($_), " ") for (0 .. 10);
diff --git a/Task/Anonymous-recursion/Perl/anonymous-recursion-3.pl b/Task/Anonymous-recursion/Perl/anonymous-recursion-3.pl
new file mode 100644
index 0000000000..b6fbbd9457
--- /dev/null
+++ b/Task/Anonymous-recursion/Perl/anonymous-recursion-3.pl
@@ -0,0 +1,6 @@
+sub fibo {
+    my $n = shift;
+    $n < 0 and die 'Negative argument';
+    no strict 'refs';
+    $n < 3 ? 1 : (caller(0))[3]->($n - 1) + (caller(0))[3]->($n - 2);
+}
diff --git a/Task/Anonymous-recursion/Perl/anonymous-recursion-4.pl b/Task/Anonymous-recursion/Perl/anonymous-recursion-4.pl
new file mode 100644
index 0000000000..a7968b3eb1
--- /dev/null
+++ b/Task/Anonymous-recursion/Perl/anonymous-recursion-4.pl
@@ -0,0 +1,5 @@
+use v5.16;
+say sub {
+  my $n = shift;
+  $n < 2 ? $n : __SUB__->($n-2) + __SUB__->($n-1)
+}->($_) for 0..10
diff --git a/Task/Anonymous-recursion/PicoLisp/anonymous-recursion-1.l b/Task/Anonymous-recursion/PicoLisp/anonymous-recursion-1.l
new file mode 100644
index 0000000000..c1e2bfa602
--- /dev/null
+++ b/Task/Anonymous-recursion/PicoLisp/anonymous-recursion-1.l
@@ -0,0 +1,7 @@
+(de fibo (N)
+   (if (lt0 N)
+      (quit "Illegal argument" N) )
+   (recur (N)
+      (if (> 2 N)
+         1
+         (+ (recurse (dec N)) (recurse (- N 2))) ) ) )
diff --git a/Task/Anonymous-recursion/PicoLisp/anonymous-recursion-2.l b/Task/Anonymous-recursion/PicoLisp/anonymous-recursion-2.l
new file mode 100644
index 0000000000..90bd2ba342
--- /dev/null
+++ b/Task/Anonymous-recursion/PicoLisp/anonymous-recursion-2.l
@@ -0,0 +1,2 @@
+(de recur recurse
+   (run (cdr recurse)) )
diff --git a/Task/Anonymous-recursion/Prolog/anonymous-recursion.pro b/Task/Anonymous-recursion/Prolog/anonymous-recursion.pro
new file mode 100644
index 0000000000..b7ca24ba0c
--- /dev/null
+++ b/Task/Anonymous-recursion/Prolog/anonymous-recursion.pro
@@ -0,0 +1,23 @@
+:- use_module(lambda).
+
+fib(N, _F) :-
+	N < 0, !,
+	write('fib is undefined for negative numbers.'), nl.
+
+fib(N, F) :-
+    % code of Fibonacci
+    PF     = \Nb^R^Rr1^(Nb < 2 ->
+			  R = Nb
+                        ;
+			  N1 is Nb - 1,
+			  N2 is Nb - 2,
+			  call(Rr1,N1,R1,Rr1),
+			  call(Rr1,N2,R2,Rr1),
+			  R is R1 + R2
+			),
+
+    % The Y combinator.
+
+    Pred = PF +\Nb2^F2^call(PF,Nb2,F2,PF),
+
+    call(Pred,N,F).
diff --git a/Task/Anonymous-recursion/Python/anonymous-recursion-1.py b/Task/Anonymous-recursion/Python/anonymous-recursion-1.py
new file mode 100644
index 0000000000..5d27ea06cf
--- /dev/null
+++ b/Task/Anonymous-recursion/Python/anonymous-recursion-1.py
@@ -0,0 +1,4 @@
+>>> Y = lambda f: (lambda x: x(x))(lambda y: f(lambda *args: y(y)(*args)))
+>>> fib = lambda f: lambda n: None if n < 0 else (0 if n == 0 else (1 if n == 1 else f(n-1) + f(n-2)))
+>>> [ Y(fib)(i) for i in range(-2, 10) ]
+[None, None, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
diff --git a/Task/Anonymous-recursion/Python/anonymous-recursion-2.py b/Task/Anonymous-recursion/Python/anonymous-recursion-2.py
new file mode 100644
index 0000000000..a484e767df
--- /dev/null
+++ b/Task/Anonymous-recursion/Python/anonymous-recursion-2.py
@@ -0,0 +1,4 @@
+>>> Y = lambda f: (lambda x: x(x))(lambda y: lambda *args: f(y(y), *args))
+>>> fib = lambda f, n: None if n < 0 else (0 if n == 0 else (1 if n == 1 else f(n-1) + f(n-2)))
+>>> [ Y(fib)(i) for i in range(-2, 10) ]
+[None, None, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
diff --git a/Task/Anonymous-recursion/Python/anonymous-recursion-3.py b/Task/Anonymous-recursion/Python/anonymous-recursion-3.py
new file mode 100644
index 0000000000..79c0702ebc
--- /dev/null
+++ b/Task/Anonymous-recursion/Python/anonymous-recursion-3.py
@@ -0,0 +1,5 @@
+>>> from functools import partial
+>>> Y = lambda f: partial(f, f)
+>>> fib = lambda f, n: None if n < 0 else (0 if n == 0 else (1 if n == 1 else f(f, n-1) + f(f, n-2)))
+>>> [ Y(fib)(i) for i in range(-2, 10) ]
+[None, None, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
diff --git a/Task/Anonymous-recursion/R/anonymous-recursion.r b/Task/Anonymous-recursion/R/anonymous-recursion.r
new file mode 100644
index 0000000000..c2db95bcb3
--- /dev/null
+++ b/Task/Anonymous-recursion/R/anonymous-recursion.r
@@ -0,0 +1,4 @@
+fib2 <- function(n) {
+  (n >= 0) || stop("bad argument")
+  ( function(n) if (n <= 1) 1 else Recall(n-1)+Recall(n-2) )(n)
+}
diff --git a/Task/Anonymous-recursion/REXX/anonymous-recursion.rexx b/Task/Anonymous-recursion/REXX/anonymous-recursion.rexx
new file mode 100644
index 0000000000..2d77316544
--- /dev/null
+++ b/Task/Anonymous-recursion/REXX/anonymous-recursion.rexx
@@ -0,0 +1,11 @@
+/*REXX program to show anonymous recursion  (of a function/subroutine). */
+numeric digits 1e6                     /*in case the user goes kaa-razy.*/
+
+       do j=0  to word(arg(1) 12, 1)   /*use argument or the default: 12*/
+       say 'fibonacci('j") =" fib(j)   /*show Fibonacci sequence: 0──►x */
+       end  /*j*/
+exit                                   /*stick a fork in it, we're done.*/
+/*──────────────────────────────────subroutines─────────────────────────*/
+fib: procedure;  if arg(1)>=0  then return .(arg(1))
+     say "***error!*** argument can't be negative.";   exit
+.:procedure;  arg _;   if _<2 then return _;   return .(_-1)+.(_-2)
diff --git a/Task/Anonymous-recursion/Racket/anonymous-recursion-1.rkt b/Task/Anonymous-recursion/Racket/anonymous-recursion-1.rkt
new file mode 100644
index 0000000000..ed08ee7f25
--- /dev/null
+++ b/Task/Anonymous-recursion/Racket/anonymous-recursion-1.rkt
@@ -0,0 +1,18 @@
+#lang racket
+
+;; Natural -> Natural
+;; Calculate factorial
+(define (fact n)
+  (define (fact-helper n acc)
+    (if (= n 0)
+        acc
+        (fact-helper (sub1 n) (* n acc))))
+  (unless (exact-nonnegative-integer? n)
+    (raise-argument-error 'fact "natural" n))
+  (fact-helper n 1))
+
+;; Unit tests, works in v5.3 and newer
+(module+ test
+  (require rackunit)
+  (check-equal? (fact 0) 1)
+  (check-equal? (fact 5) 120))
diff --git a/Task/Anonymous-recursion/Racket/anonymous-recursion-2.rkt b/Task/Anonymous-recursion/Racket/anonymous-recursion-2.rkt
new file mode 100644
index 0000000000..c23a27f7d2
--- /dev/null
+++ b/Task/Anonymous-recursion/Racket/anonymous-recursion-2.rkt
@@ -0,0 +1,20 @@
+#lang racket
+;; Natural -> Natural
+;; Calculate fibonacci
+(define (fibb n)
+  (define (fibb-helper n fibb_n-1 fibb_n-2)
+    (if (= 1 n)
+        fibb_n-1
+        (fibb-helper (sub1 n) (+ fibb_n-1 fibb_n-2) fibb_n-1)))
+  (unless (exact-nonnegative-integer? n)
+    (raise-argument-error 'fibb "natural" n))
+  (if (zero? n) 0 (fibb-helper n 1 0)))
+
+;; Unit tests, works in v5.3 and newer
+(module+ test
+  (require rackunit)
+  (check-exn exn:fail? (lambda () (fibb -2)))
+  (check-equal?
+   (for/list ([i (in-range 21)]) (fibb i))
+   '(0 1 1 2 3 5 8 13 21 34 55 89 144 233
+       377 610 987 1597 2584 4181 6765)))
diff --git a/Task/Anonymous-recursion/Ruby/anonymous-recursion-1.rb b/Task/Anonymous-recursion/Ruby/anonymous-recursion-1.rb
new file mode 100644
index 0000000000..7dcfc0895f
--- /dev/null
+++ b/Task/Anonymous-recursion/Ruby/anonymous-recursion-1.rb
@@ -0,0 +1,4 @@
+def fib(n)
+  raise RangeError, "fib of negative" if n < 0
+  (fib2 = proc { |m| m < 2 ? m : fib2[m - 1] + fib2[m - 2] })[n]
+end
diff --git a/Task/Anonymous-recursion/Ruby/anonymous-recursion-2.rb b/Task/Anonymous-recursion/Ruby/anonymous-recursion-2.rb
new file mode 100644
index 0000000000..94785db95c
--- /dev/null
+++ b/Task/Anonymous-recursion/Ruby/anonymous-recursion-2.rb
@@ -0,0 +1,2 @@
+(-2..12).map { |i| fib i rescue :error }
+=> [:error, :error, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
diff --git a/Task/Anonymous-recursion/Ruby/anonymous-recursion-3.rb b/Task/Anonymous-recursion/Ruby/anonymous-recursion-3.rb
new file mode 100644
index 0000000000..c332ef70df
--- /dev/null
+++ b/Task/Anonymous-recursion/Ruby/anonymous-recursion-3.rb
@@ -0,0 +1,4 @@
+def fib(n)
+  raise RangeError, "fib of negative" if n < 0
+  (fib2 = proc { |n| n < 2 ? n : fib2[n - 1] + fib2[n - 2] })[n]
+end
diff --git a/Task/Anonymous-recursion/Ruby/anonymous-recursion-4.rb b/Task/Anonymous-recursion/Ruby/anonymous-recursion-4.rb
new file mode 100644
index 0000000000..225704fafd
--- /dev/null
+++ b/Task/Anonymous-recursion/Ruby/anonymous-recursion-4.rb
@@ -0,0 +1,7 @@
+# Ruby 1.9
+(-2..12).map { |i| fib i rescue :error }
+=> [:error, :error, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
+
+# Ruby 1.8
+(-2..12).map { |i| fib i rescue :error }
+=> [:error, :error, 0, 1, 0, -3, -8, -15, -24, -35, -48, -63, -80, -99, -120]
diff --git a/Task/Anonymous-recursion/Ruby/anonymous-recursion-5.rb b/Task/Anonymous-recursion/Ruby/anonymous-recursion-5.rb
new file mode 100644
index 0000000000..aa5dcbdccc
--- /dev/null
+++ b/Task/Anonymous-recursion/Ruby/anonymous-recursion-5.rb
@@ -0,0 +1,5 @@
+def fib(n)
+  raise RangeError, "fib of negative" if n < 0
+  Hash.new { |fib2, m|
+    fib2[m] = (m < 2 ? m : fib2[m - 1] + fib2[m - 2]) }[n]
+end
diff --git a/Task/Anonymous-recursion/Ruby/anonymous-recursion-6.rb b/Task/Anonymous-recursion/Ruby/anonymous-recursion-6.rb
new file mode 100644
index 0000000000..5b500499ea
--- /dev/null
+++ b/Task/Anonymous-recursion/Ruby/anonymous-recursion-6.rb
@@ -0,0 +1,20 @@
+require 'continuation' unless defined? Continuation
+
+module Kernel
+  module_function
+
+  def recur(*args, &block)
+    cont = catch(:recur) { return block[*args] }
+    cont[block]
+  end
+
+  def recurse(*args)
+    block = callcc { |cont| throw(:recur, cont) }
+    block[*args]
+  end
+end
+
+def fib(n)
+  raise RangeError, "fib of negative" if n < 0
+  recur(n) { |m| m < 2 ? m : (recurse m - 1) + (recurse m - 2) }
+end
diff --git a/Task/Anonymous-recursion/Ruby/anonymous-recursion-7.rb b/Task/Anonymous-recursion/Ruby/anonymous-recursion-7.rb
new file mode 100644
index 0000000000..123e2c9847
--- /dev/null
+++ b/Task/Anonymous-recursion/Ruby/anonymous-recursion-7.rb
@@ -0,0 +1,32 @@
+require 'continuation' unless defined? Continuation
+
+module Kernel
+  module_function
+
+  def function(&block)
+    f = (proc do |*args|
+           (class << args; self; end).class_eval do
+             define_method(:callee) { f }
+           end
+           ret = nil
+           cont = catch(:function) { ret = block.call(*args); nil }
+           cont[args] if cont
+           ret
+         end)
+  end
+
+  def arguments
+    callcc { |cont| throw(:function, cont) }
+  end
+end
+
+def fib(n)
+  raise RangeError, "fib of negative" if n < 0
+  function { |m|
+    if m < 2
+      m
+    else
+      arguments.callee[m - 1] + arguments.callee[m - 2]
+    end
+  }[n]
+end
diff --git a/Task/Anonymous-recursion/Scala/anonymous-recursion.scala b/Task/Anonymous-recursion/Scala/anonymous-recursion.scala
new file mode 100644
index 0000000000..666e185e9b
--- /dev/null
+++ b/Task/Anonymous-recursion/Scala/anonymous-recursion.scala
@@ -0,0 +1,9 @@
+def Y[A, B](f: (A β‡’ B) β‡’ (A β‡’ B)): A β‡’ B = f(Y(f))(_)
+
+def fib(n: Int): Option[Int] =
+  if (n < 0) None
+  else Some(Y[Int, Int](f β‡’ i β‡’
+    if (i < 2) 1
+    else f(i - 1) + f(i - 2))(n))
+
+-2 to 5 map (n β‡’ (n, fib(n))) foreach println
diff --git a/Task/Anonymous-recursion/Scheme/anonymous-recursion.ss b/Task/Anonymous-recursion/Scheme/anonymous-recursion.ss
new file mode 100644
index 0000000000..1f77b7e642
--- /dev/null
+++ b/Task/Anonymous-recursion/Scheme/anonymous-recursion.ss
@@ -0,0 +1,9 @@
+(define (fibonacci n)
+  (if (> 0 n)
+      "Error: argument must not be negative."
+      (let aux ((a 1) (b 0) (count n))
+        (if (= count 0)
+            b
+            (aux (+ a b) a (- count 1))))))
+
+(map fibonacci '(1 2 3 4 5 6 7 8 9 10))
diff --git a/Task/Anonymous-recursion/Tcl/anonymous-recursion-1.tcl b/Task/Anonymous-recursion/Tcl/anonymous-recursion-1.tcl
new file mode 100644
index 0000000000..fe4d906c82
--- /dev/null
+++ b/Task/Anonymous-recursion/Tcl/anonymous-recursion-1.tcl
@@ -0,0 +1,10 @@
+proc fib n {
+    # sanity checks
+    if {[incr n 0] < 0} {error "argument may not be negative"}
+    apply {x {
+	if {$x < 2} {return $x}
+	# Extract the lambda term from the stack introspector for brevity
+	set f [lindex [info level 0] 1]
+	expr {[apply $f [incr x -1]] + [apply $f [incr x -1]]}
+    }} $n
+}
diff --git a/Task/Anonymous-recursion/Tcl/anonymous-recursion-2.tcl b/Task/Anonymous-recursion/Tcl/anonymous-recursion-2.tcl
new file mode 100644
index 0000000000..47b647233f
--- /dev/null
+++ b/Task/Anonymous-recursion/Tcl/anonymous-recursion-2.tcl
@@ -0,0 +1 @@
+puts [fib 12]
diff --git a/Task/Anonymous-recursion/Tcl/anonymous-recursion-3.tcl b/Task/Anonymous-recursion/Tcl/anonymous-recursion-3.tcl
new file mode 100644
index 0000000000..696168babe
--- /dev/null
+++ b/Task/Anonymous-recursion/Tcl/anonymous-recursion-3.tcl
@@ -0,0 +1,9 @@
+proc fib n {
+    if {[incr n 0] < 0} {error "argument may not be negative"}
+    apply {x {expr {
+        $x < 2
+          ? $x
+          : [apply [lindex [info level 0] 1] [incr x -1]]
+            + [apply [lindex [info level 0] 1] [incr x -1]]
+    }}} $n
+}
diff --git a/Task/Anonymous-recursion/Tcl/anonymous-recursion-4.tcl b/Task/Anonymous-recursion/Tcl/anonymous-recursion-4.tcl
new file mode 100644
index 0000000000..5827c46e6b
--- /dev/null
+++ b/Task/Anonymous-recursion/Tcl/anonymous-recursion-4.tcl
@@ -0,0 +1,8 @@
+# Pick the lambda term out of the introspected caller's stack frame
+proc tcl::mathfunc::recurse args {apply [lindex [info level -1] 1] {*}$args}
+proc fib n {
+    if {[incr n 0] < 0} {error "argument may not be negative"}
+    apply {x {expr {
+        $x < 2 ? $x : recurse([incr x -1]) + recurse([incr x -1])
+    }}} $n
+}
diff --git a/Task/Apply-a-callback-to-an-array/0DESCRIPTION b/Task/Apply-a-callback-to-an-array/0DESCRIPTION
new file mode 100644
index 0000000000..46105c5628
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/0DESCRIPTION
@@ -0,0 +1 @@
+In this task, the goal is to take a combined set of elements and apply a function to each element.
diff --git a/Task/Apply-a-callback-to-an-array/1META.yaml b/Task/Apply-a-callback-to-an-array/1META.yaml
new file mode 100644
index 0000000000..ee6dd6cc2e
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/1META.yaml
@@ -0,0 +1,4 @@
+---
+category:
+- Iteration
+note: Basic language learning
diff --git a/Task/Apply-a-callback-to-an-array/ACL2/apply-a-callback-to-an-array.acl2 b/Task/Apply-a-callback-to-an-array/ACL2/apply-a-callback-to-an-array.acl2
new file mode 100644
index 0000000000..67dc40ae3a
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/ACL2/apply-a-callback-to-an-array.acl2
@@ -0,0 +1,5 @@
+(defun sq-each (xs)
+   (if (endp xs)
+       nil
+       (cons (* (first xs) (first xs))
+             (sq-each (rest xs)))))
diff --git a/Task/Apply-a-callback-to-an-array/ALGOL-68/apply-a-callback-to-an-array.alg b/Task/Apply-a-callback-to-an-array/ALGOL-68/apply-a-callback-to-an-array.alg
new file mode 100644
index 0000000000..b37b2c3301
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/ALGOL-68/apply-a-callback-to-an-array.alg
@@ -0,0 +1,17 @@
+ PROC call back proc = (INT location, INT value)VOID:
+ (
+   printf(($"array["g"] = "gl$, location, value))
+ );
+
+ PROC map = (REF[]INT array, PROC (INT,INT)VOID call back)VOID:
+ (
+   FOR i FROM LWB array TO UPB array DO
+      call back(i, array[i])
+   OD
+ );
+
+ main:
+ (
+   [4]INT array := ( 1, 4, 9, 16 );
+   map(array, call back proc)
+ )
diff --git a/Task/Apply-a-callback-to-an-array/AWK/apply-a-callback-to-an-array.awk b/Task/Apply-a-callback-to-an-array/AWK/apply-a-callback-to-an-array.awk
new file mode 100644
index 0000000000..b481e4b86f
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/AWK/apply-a-callback-to-an-array.awk
@@ -0,0 +1,6 @@
+$ awk 'func psqr(x){print x,x*x}BEGIN{split("1 2 3 4 5",a);for(i in a)psqr(a[i])}'
+4 16
+5 25
+1 1
+2 4
+3 9
diff --git a/Task/Apply-a-callback-to-an-array/ActionScript/apply-a-callback-to-an-array.as b/Task/Apply-a-callback-to-an-array/ActionScript/apply-a-callback-to-an-array.as
new file mode 100644
index 0000000000..8e19214c20
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/ActionScript/apply-a-callback-to-an-array.as
@@ -0,0 +1,19 @@
+package
+{
+    public class ArrayCallback
+    {
+        public function main():void
+        {
+            var nums:Array = new Array(1, 2, 3);
+            nums.map(function(n:Number, index:int, arr:Array):void { trace(n * n * n); });
+
+            // You can also pass a function reference
+            nums.map(cube);
+        }
+
+        private function cube(n:Number, index:int, arr:Array):void
+        {
+            trace(n * n * n);
+        }
+    }
+}
diff --git a/Task/Apply-a-callback-to-an-array/Ada/apply-a-callback-to-an-array.ada b/Task/Apply-a-callback-to-an-array/Ada/apply-a-callback-to-an-array.ada
new file mode 100644
index 0000000000..6708e131a6
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Ada/apply-a-callback-to-an-array.ada
@@ -0,0 +1,37 @@
+with Ada.Text_Io;
+ with Ada.Integer_text_IO;
+
+ procedure Call_Back_Example is
+    -- Purpose: Apply a callback to an array
+    -- Output: Prints the squares of an integer array to the console
+
+    -- Define the callback procedure
+    procedure Display(Location : Positive; Value : Integer) is
+    begin
+       Ada.Text_Io.Put("array(");
+       Ada.Integer_Text_Io.Put(Item => Location, Width => 1);
+       Ada.Text_Io.Put(") = ");
+       Ada.Integer_Text_Io.Put(Item => Value * Value, Width => 1);
+       Ada.Text_Io.New_Line;
+    end Display;
+
+    -- Define an access type matching the signature of the callback procedure
+    type Call_Back_Access is access procedure(L : Positive; V : Integer);
+
+    -- Define an unconstrained array type
+    type Value_Array is array(Positive range <>) of Integer;
+
+    -- Define the procedure performing the callback
+    procedure Map(Values : Value_Array; Worker : Call_Back_Access) is
+    begin
+       for I in Values'range loop
+          Worker(I, Values(I));
+       end loop;
+    end Map;
+
+    -- Define and initialize the actual array
+    Sample : Value_Array := (5,4,3,2,1);
+
+ begin
+    Map(Sample, Display'access);
+ end Call_Back_Example;
diff --git a/Task/Apply-a-callback-to-an-array/Aime/apply-a-callback-to-an-array.aime b/Task/Apply-a-callback-to-an-array/Aime/apply-a-callback-to-an-array.aime
new file mode 100644
index 0000000000..2c2299ebcb
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Aime/apply-a-callback-to-an-array.aime
@@ -0,0 +1,35 @@
+void
+map(list l, void (*fp) (object))
+{
+    integer i;
+
+    i = 0;
+    while (i < l_length(l)) {
+	fp(l_query(l, i));
+	i += 1;
+    }
+}
+
+
+void
+out(object o)
+{
+    o_integer(o);
+    o_byte(10);
+}
+
+
+integer
+main(void)
+{
+    list l;
+
+    l_append(l, 0);
+    l_append(l, 1);
+    l_append(l, 2);
+    l_append(l, 3);
+
+    map(l, out);
+
+    return 0;
+}
diff --git a/Task/Apply-a-callback-to-an-array/AutoHotkey/apply-a-callback-to-an-array.ahk b/Task/Apply-a-callback-to-an-array/AutoHotkey/apply-a-callback-to-an-array.ahk
new file mode 100644
index 0000000000..55fb31ae5c
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/AutoHotkey/apply-a-callback-to-an-array.ahk
@@ -0,0 +1,10 @@
+map("callback", "3,4,5")
+
+callback(array){
+  Loop, Parse, array, `,
+    MsgBox % (2 * A_LoopField)
+}
+
+map(callback, array){
+  %callback%(array)
+}
diff --git a/Task/Apply-a-callback-to-an-array/C/apply-a-callback-to-an-array-1.c b/Task/Apply-a-callback-to-an-array/C/apply-a-callback-to-an-array-1.c
new file mode 100644
index 0000000000..89d557f07a
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/C/apply-a-callback-to-an-array-1.c
@@ -0,0 +1,16 @@
+#ifndef CALLBACK_H
+#define CALLBACK_H
+
+/*
+ * By declaring the function in a separate file, we allow
+ * it to be used by other source files.
+ *
+ * It also stops ICC from complaining.
+ *
+ * If you don't want to use it outside of callback.c, this
+ * file can be removed, provided the static keyword is prepended
+ * to the definition.
+ */
+void map(int* array, int len, void(*callback)(int,int));
+
+#endif
diff --git a/Task/Apply-a-callback-to-an-array/C/apply-a-callback-to-an-array-2.c b/Task/Apply-a-callback-to-an-array/C/apply-a-callback-to-an-array-2.c
new file mode 100644
index 0000000000..0eb92ae30b
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/C/apply-a-callback-to-an-array-2.c
@@ -0,0 +1,27 @@
+#include 
+#include "callback.h"
+
+/*
+ * We don't need this function outside of this file, so
+ * we declare it static.
+ */
+static void callbackFunction(int location, int value)
+{
+  printf("array[%d] = %d\n", location, value);
+}
+
+void map(int* array, int len, void(*callback)(int,int))
+{
+  int i;
+  for(i = 0; i < len; i++)
+  {
+     callback(i, array[i]);
+  }
+}
+
+int main()
+{
+  int array[] = { 1, 2, 3, 4 };
+  map(array, 4, callbackFunction);
+  return 0;
+}
diff --git a/Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-1.clj b/Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-1.clj
new file mode 100644
index 0000000000..daf56ad7a0
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-1.clj
@@ -0,0 +1,2 @@
+;; apply a named function, inc
+(map inc [1 2 3 4])
diff --git a/Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-2.clj b/Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-2.clj
new file mode 100644
index 0000000000..93317efa56
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-2.clj
@@ -0,0 +1,2 @@
+;; apply a function
+(map (fn [x] (* x x)) [1 2 3 4])
diff --git a/Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-3.clj b/Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-3.clj
new file mode 100644
index 0000000000..7deafd3653
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Clojure/apply-a-callback-to-an-array-3.clj
@@ -0,0 +1,2 @@
+;; shortcut syntax for a function
+(map #(* % %) [1 2 3 4])
diff --git a/Task/Apply-a-callback-to-an-array/CoffeeScript/apply-a-callback-to-an-array.coffee b/Task/Apply-a-callback-to-an-array/CoffeeScript/apply-a-callback-to-an-array.coffee
new file mode 100644
index 0000000000..aa0ffc1266
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/CoffeeScript/apply-a-callback-to-an-array.coffee
@@ -0,0 +1,4 @@
+map = (arr, f) -> (f(e) for e in arr)
+arr = [1, 2, 3, 4, 5]
+f = (x) -> x * x
+console.log map arr, f # prints [1, 4, 9, 16, 25]
diff --git a/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-1.erl b/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-1.erl
new file mode 100644
index 0000000000..cdb1e8c517
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-1.erl
@@ -0,0 +1,2 @@
+1> L = [1,2,3].
+[1,2,3]
diff --git a/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-2.erl b/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-2.erl
new file mode 100644
index 0000000000..0b95ccbf80
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-2.erl
@@ -0,0 +1,2 @@
+2> lists:foreach(fun(X) -> io:format("~w ",[X]) end, L).
+1 2 3 ok
diff --git a/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-3.erl b/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-3.erl
new file mode 100644
index 0000000000..b073bf113e
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-3.erl
@@ -0,0 +1,2 @@
+3> lists:map(fun(X) -> X + 1 end, L).
+[2,3,4]
diff --git a/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-4.erl b/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-4.erl
new file mode 100644
index 0000000000..e863034824
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Erlang/apply-a-callback-to-an-array-4.erl
@@ -0,0 +1,2 @@
+4> lists:foldl(fun(X, Sum) -> X + Sum end, 0, L).
+6
diff --git a/Task/Apply-a-callback-to-an-array/Forth/apply-a-callback-to-an-array-1.fth b/Task/Apply-a-callback-to-an-array/Forth/apply-a-callback-to-an-array-1.fth
new file mode 100644
index 0000000000..50c8aa1210
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Forth/apply-a-callback-to-an-array-1.fth
@@ -0,0 +1,2 @@
+: map ( addr n fn -- )
+   -rot cells bounds do  i @ over execute i !  cell +loop ;
diff --git a/Task/Apply-a-callback-to-an-array/Forth/apply-a-callback-to-an-array-2.fth b/Task/Apply-a-callback-to-an-array/Forth/apply-a-callback-to-an-array-2.fth
new file mode 100644
index 0000000000..67cb4ca4c1
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Forth/apply-a-callback-to-an-array-2.fth
@@ -0,0 +1,2 @@
+create data 1 , 2 , 3 , 4 , 5 ,
+data 5 ' 1+ map  \ adds one to each element of data
diff --git a/Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-1.f b/Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-1.f
new file mode 100644
index 0000000000..77112c2b2b
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-1.f
@@ -0,0 +1,9 @@
+module arrCallback
+contains
+    elemental function cube( x )
+        implicit none
+        real :: cube
+        real, intent(in) :: x
+        cube = x * x * x
+    end function cube
+end module arrCallback
diff --git a/Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-2.f b/Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-2.f
new file mode 100644
index 0000000000..0b8d5efcd2
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-2.f
@@ -0,0 +1,17 @@
+program testAC
+    use arrCallback
+    implicit none
+    integer :: i, j
+    real, dimension(3,4) :: b, &
+        a = reshape( (/ ((10 * i + j, i = 1, 3), j = 1, 4) /), (/ 3,4 /) )
+
+    do i = 1, 3
+        write(*,*) a(i,:)
+    end do
+
+    b = cube( a )  ! Applies CUBE to every member of a,
+                   ! and stores each result in the equivalent element of b
+    do i = 1, 3
+        write(*,*) b(i,:)
+    end do
+end program testAC
diff --git a/Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-3.f b/Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-3.f
new file mode 100644
index 0000000000..20826bcd6c
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Fortran/apply-a-callback-to-an-array-3.f
@@ -0,0 +1,14 @@
+      program test
+C
+C--   Declare array:
+      integer a(5)
+C
+C--   Fill it with Data
+      data a /45,22,67,87,98/
+C
+C--   Do something with all elements (in this case: print their squares)
+      do i=1,5
+        print *,a(i)*a(i)
+      end do
+C
+      end
diff --git a/Task/Apply-a-callback-to-an-array/Go/apply-a-callback-to-an-array-1.go b/Task/Apply-a-callback-to-an-array/Go/apply-a-callback-to-an-array-1.go
new file mode 100644
index 0000000000..c7ab366f4b
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Go/apply-a-callback-to-an-array-1.go
@@ -0,0 +1,9 @@
+package main
+
+import "fmt"
+
+func main() {
+    for _, i := range []int{1, 2, 3, 4, 5} {
+        fmt.Println(i * i)
+    }
+}
diff --git a/Task/Apply-a-callback-to-an-array/Go/apply-a-callback-to-an-array-2.go b/Task/Apply-a-callback-to-an-array/Go/apply-a-callback-to-an-array-2.go
new file mode 100644
index 0000000000..73069a6874
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Go/apply-a-callback-to-an-array-2.go
@@ -0,0 +1,31 @@
+package main
+
+import "fmt"
+
+type intSlice []int
+
+func (s intSlice) each(f func(int)) {
+    for _, i := range s {
+        f(i)
+    }
+}
+
+func (s intSlice) Map(f func(int) int) intSlice {
+    r := make(intSlice, len(s))
+    for j, i := range s {
+        r[j] = f(i)
+    }
+    return r
+}
+
+func main() {
+    s := intSlice{1, 2, 3, 4, 5}
+
+    s.each(func(i int) {
+        fmt.Println(i * i)
+    })
+
+    fmt.Println(s.Map(func(i int) int {
+        return i * i
+    }))
+}
diff --git a/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-1.hs b/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-1.hs
new file mode 100644
index 0000000000..701e9e8451
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-1.hs
@@ -0,0 +1,3 @@
+let square x = x*x
+let values = [1..10]
+map square values
diff --git a/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-2.hs b/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-2.hs
new file mode 100644
index 0000000000..a01dd03ce4
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-2.hs
@@ -0,0 +1 @@
+[square x | x <- values]
diff --git a/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-3.hs b/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-3.hs
new file mode 100644
index 0000000000..2950d3f7ab
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-3.hs
@@ -0,0 +1,2 @@
+let printSquares = mapM_ (print.square)
+printSquares values
diff --git a/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-4.hs b/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-4.hs
new file mode 100644
index 0000000000..e0cb25c5fc
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Haskell/apply-a-callback-to-an-array-4.hs
@@ -0,0 +1,4 @@
+import Data.Array.IArray
+let square x = x*x
+let values = array (1,10) [(i,i)|i <- [1..10]] :: Array Int Int
+amap square values
diff --git a/Task/Apply-a-callback-to-an-array/Java/apply-a-callback-to-an-array-1.java b/Task/Apply-a-callback-to-an-array/Java/apply-a-callback-to-an-array-1.java
new file mode 100644
index 0000000000..d1689ff5b6
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Java/apply-a-callback-to-an-array-1.java
@@ -0,0 +1,11 @@
+interface IntToVoid {
+    void run(int x);
+}
+
+for (int z : myIntArray) {
+    new IntToVoid() {
+        public void run(int x) {
+            System.out.println(x);
+        }
+    }.run(z);
+}
diff --git a/Task/Apply-a-callback-to-an-array/Java/apply-a-callback-to-an-array-2.java b/Task/Apply-a-callback-to-an-array/Java/apply-a-callback-to-an-array-2.java
new file mode 100644
index 0000000000..8e05ef64f0
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Java/apply-a-callback-to-an-array-2.java
@@ -0,0 +1,13 @@
+interface IntToInt {
+    int run(int x);
+}
+
+int[] result = new int[myIntArray.length];
+for (int i = 0; i < myIntArray.length; i++) {
+    result[i] =
+        new IntToInt() {
+            public int run(int x) {
+                return x * x;
+            }
+        }.run(myIntArray[i]);
+}
diff --git a/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-1.js b/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-1.js
new file mode 100644
index 0000000000..c6717bfa0a
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-1.js
@@ -0,0 +1,7 @@
+function map(a, func) {
+  for (var i in a)
+    a[i] = func(a[i]);
+}
+
+var a = [1, 2, 3, 4, 5];
+map(a, function(v) { return v * v; });
diff --git a/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-2.js b/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-2.js
new file mode 100644
index 0000000000..883198c3b9
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-2.js
@@ -0,0 +1 @@
+var a = (1).to(10).collect(Math.pow.curry(undefined,2));
diff --git a/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-3.js b/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-3.js
new file mode 100644
index 0000000000..2f638315d0
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-3.js
@@ -0,0 +1,15 @@
+function cube(num) {
+  return Math.pow(num, 3);
+}
+
+var numbers = [1, 2, 3, 4, 5];
+
+// get results of calling cube on every element
+var cubes1 = numbers.map(cube);
+
+// display each result in a separate dialog
+cubes1.forEach(alert);
+
+// array comprehension
+var cubes2 = [cube(n) for each (n in numbers)];
+var cubes3 = [n * n * n for each (n in numbers)];
diff --git a/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-4.js b/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-4.js
new file mode 100644
index 0000000000..b474d2b7e3
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/JavaScript/apply-a-callback-to-an-array-4.js
@@ -0,0 +1 @@
+Functional.map('x*x*x', [1,2,3,4,5])
diff --git a/Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-1.lua b/Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-1.lua
new file mode 100644
index 0000000000..5972ed0d75
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-1.lua
@@ -0,0 +1 @@
+myArray = {1, 2, 3, 4, 5}
diff --git a/Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-2.lua b/Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-2.lua
new file mode 100644
index 0000000000..6bae8879f9
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-2.lua
@@ -0,0 +1,7 @@
+map = function(f, data)
+   local result = {}
+   for k,v in ipairs(data) do
+      result[k] = f(v)
+   end
+   return result
+end
diff --git a/Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-3.lua b/Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-3.lua
new file mode 100644
index 0000000000..a4f201d2ea
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Lua/apply-a-callback-to-an-array-3.lua
@@ -0,0 +1,4 @@
+myFunc = function(x) return x*x end
+
+print(unpack( map(myFunc, myArray) ))
+--> 1   4   9   16  25
diff --git a/Task/Apply-a-callback-to-an-array/PHP/apply-a-callback-to-an-array.php b/Task/Apply-a-callback-to-an-array/PHP/apply-a-callback-to-an-array.php
new file mode 100644
index 0000000000..2266ca5602
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/PHP/apply-a-callback-to-an-array.php
@@ -0,0 +1,8 @@
+function cube($n)
+{
+   return($n * $n * $n);
+}
+
+$a = array(1, 2, 3, 4, 5);
+$b = array_map("cube", $a);
+print_r($b);
diff --git a/Task/Apply-a-callback-to-an-array/Perl/apply-a-callback-to-an-array.pl b/Task/Apply-a-callback-to-an-array/Perl/apply-a-callback-to-an-array.pl
new file mode 100644
index 0000000000..e9a2cdf954
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Perl/apply-a-callback-to-an-array.pl
@@ -0,0 +1,30 @@
+# create array
+my @a = (1, 2, 3, 4, 5);
+
+# create callback function
+sub mycallback {
+  return 2 * shift;
+}
+
+# use array indexing
+for (my $i = 0; $i < scalar @a; $i++) {
+  print "mycallback($a[$i]) = ", mycallback($a[$i]), "\n";
+}
+
+# using foreach
+foreach my $x (@a) {
+  print "mycallback($x) = ", mycallback($x), "\n";
+}
+
+# using map (useful for transforming an array)
+my @b = map mycallback($_), @a;                # @b is now (2, 4, 6, 8, 10)
+
+# and the same using an anonymous function
+my @c = map { $_ * 2 } @a;                     # @c is now (2, 4, 6, 8, 10)
+
+# use a callback stored in a variable
+my $func = \&mycallback;
+my @d = map $func->($_), @a;                  # @d is now (2, 4, 6, 8, 10)
+
+# filter an array
+my @e = grep { $_ % 2 == 0 } @a;               # @e is now (2, 4)
diff --git a/Task/Apply-a-callback-to-an-array/PicoLisp/apply-a-callback-to-an-array.l b/Task/Apply-a-callback-to-an-array/PicoLisp/apply-a-callback-to-an-array.l
new file mode 100644
index 0000000000..c1abe58171
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/PicoLisp/apply-a-callback-to-an-array.l
@@ -0,0 +1,16 @@
+: (mapc println (1 2 3 4 5))  # Print numbers
+1
+2
+3
+4
+5
+-> 5
+
+: (mapcar '((N) (* N N)) (1 2 3 4 5))  # Calculate squares
+-> (1 4 9 16 25)
+
+: (mapcar ** (1 2 3 4 5) (2 .))  # Same, using a circular list
+-> (1 4 9 16 25)
+
+: (mapcar if '(T NIL T NIL) '(1 2 3 4) '(5 6 7 8))  # Conditional function
+-> (1 6 3 8)
diff --git a/Task/Apply-a-callback-to-an-array/Prolog/apply-a-callback-to-an-array.pro b/Task/Apply-a-callback-to-an-array/Prolog/apply-a-callback-to-an-array.pro
new file mode 100644
index 0000000000..5e0b983634
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Prolog/apply-a-callback-to-an-array.pro
@@ -0,0 +1,5 @@
+ ?- assert((fun(X, Y) :- Y is 2 * X)).
+true.
+
+?- maplist(fun, [1,2,3,4,5], L).
+L = [2,4,6,8,10].
diff --git a/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-1.py b/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-1.py
new file mode 100644
index 0000000000..a3cf9dcbd3
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-1.py
@@ -0,0 +1,18 @@
+def square(n):
+    return n * n
+
+numbers = [1, 3, 5, 7]
+
+squares1 = [square(n) for n in numbers]     # list comprehension
+
+squares2a = map(square, numbers)            # functional form
+
+squares2b = map(lambda x: x*x, numbers)     # functional form with `lambda`
+
+squares3 = [n * n for n in numbers]         # no need for a function,
+                                            # anonymous or otherwise
+
+isquares1 = (n * n for n in numbers)        # iterator, lazy
+
+import itertools
+isquares2 = itertools.imap(square, numbers) # iterator, lazy
diff --git a/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-2.py b/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-2.py
new file mode 100644
index 0000000000..787f6b9b69
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-2.py
@@ -0,0 +1 @@
+print " ".join(str(n * n) for n in range(10))
diff --git a/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-3.py b/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-3.py
new file mode 100644
index 0000000000..8d456a7db1
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-3.py
@@ -0,0 +1 @@
+print " ".join(map(str, map(square, range(10))))
diff --git a/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-4.py b/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-4.py
new file mode 100644
index 0000000000..f05ed5d824
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Python/apply-a-callback-to-an-array-4.py
@@ -0,0 +1 @@
+0 1 4 9 16 25 36 49 64 81
diff --git a/Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-1.r b/Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-1.r
new file mode 100644
index 0000000000..2a005b49a0
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-1.r
@@ -0,0 +1,3 @@
+cube <- function(x) x*x*x
+elements <- 1:5
+cubes <- cube(elements)
diff --git a/Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-2.r b/Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-2.r
new file mode 100644
index 0000000000..1a3584ae21
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-2.r
@@ -0,0 +1,5 @@
+cubes <- numeric(5)
+for(i in seq_along(cubes))
+{
+   cubes[i] <- cube(elements[i])
+}
diff --git a/Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-3.r b/Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-3.r
new file mode 100644
index 0000000000..88dfab3f3c
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/R/apply-a-callback-to-an-array-3.r
@@ -0,0 +1,2 @@
+elements2 <- list(1,2,3,4,5)
+cubes <- sapply(elements2, cube)
diff --git a/Task/Apply-a-callback-to-an-array/REXX/apply-a-callback-to-an-array.rexx b/Task/Apply-a-callback-to-an-array/REXX/apply-a-callback-to-an-array.rexx
new file mode 100644
index 0000000000..3c812a7402
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/REXX/apply-a-callback-to-an-array.rexx
@@ -0,0 +1,29 @@
+/*REXX program to apply a  callback  to a  stemmed  (REXX)  array.      */
+        a.=;   b.=
+ a.0= 0
+ a.1= 1
+ a.2= 2
+ a.3= 3
+ a.4= 4
+ a.5= 5
+ a.6= 6
+ a.7= 7
+ a.8= 8
+ a.9= 9
+a.10=10
+
+call listab 'before'
+call bangit 'a','b'      /*factorialize the A array, store results in B */
+call listab ' after'
+exit                                   /*stick a fork in it, we're done.*/
+/*──────────────────────────────────BANGIT subroutine───────────────────*/
+bangit:   do i=0
+          _=value(arg(1)'.'i);    if _=='' then return
+          call value arg(2)'.'i,fact(_)
+          end    /*i*/
+/*──────────────────────────────────FACT subroutine─────────────────────*/
+fact: procedure; !=1; do j=2 to arg(1); !=!*j; end; return !
+/*──────────────────────────────────LISTAB subroutine───────────────────*/
+listab: do j=0  while a.j\=='';     say arg(1) 'a.'j"="a.j;     end  /*j*/
+say;    do k=0  while b.k\=='';     say arg(1) 'b.'k"="b.k;     end  /*k*/
+return
diff --git a/Task/Apply-a-callback-to-an-array/Racket/apply-a-callback-to-an-array.rkt b/Task/Apply-a-callback-to-an-array/Racket/apply-a-callback-to-an-array.rkt
new file mode 100644
index 0000000000..14d0d0b3b4
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Racket/apply-a-callback-to-an-array.rkt
@@ -0,0 +1,7 @@
+#lang racket
+
+;; using the `for/vector` comprehension form
+(for/vector ([i #(1 2 3 4 5)]) (sqr i))
+
+;; the usual functional `map`
+(vector-map sqr #(1 2 3 4 5))
diff --git a/Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-1.rb b/Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-1.rb
new file mode 100644
index 0000000000..44a85d8b08
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-1.rb
@@ -0,0 +1,3 @@
+for i in [1,2,3,4,5] do
+   puts i**2
+end
diff --git a/Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-2.rb b/Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-2.rb
new file mode 100644
index 0000000000..ccbe8b300e
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-2.rb
@@ -0,0 +1 @@
+[1,2,3,4,5].each{ |i| puts i**2 }
diff --git a/Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-3.rb b/Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-3.rb
new file mode 100644
index 0000000000..f523a835f7
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Ruby/apply-a-callback-to-an-array-3.rb
@@ -0,0 +1 @@
+[1,2,3,4,5].map{ |i| i**2 }
diff --git a/Task/Apply-a-callback-to-an-array/Sather/apply-a-callback-to-an-array.sa b/Task/Apply-a-callback-to-an-array/Sather/apply-a-callback-to-an-array.sa
new file mode 100644
index 0000000000..e814d7535d
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Sather/apply-a-callback-to-an-array.sa
@@ -0,0 +1,12 @@
+class MAIN is
+  do_something(i:INT):INT is
+    return i * i;
+  end;
+
+  main is
+    a:ARRAY{INT} := |1, 2, 3, 4, 5|;
+    -- we use an anonymous closure to apply our do_something "callback"
+    a.map(bind(do_something(_)));
+    loop #OUT + a.elt! + "\n"; end;
+  end;
+end;
diff --git a/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-1.scala b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-1.scala
new file mode 100644
index 0000000000..25438142f9
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-1.scala
@@ -0,0 +1,2 @@
+val l = List(1,2,3,4)
+l.foreach {i => println(i)}
diff --git a/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-2.scala b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-2.scala
new file mode 100644
index 0000000000..39ce8de034
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-2.scala
@@ -0,0 +1 @@
+l.foreach(println(_))
diff --git a/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-3.scala b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-3.scala
new file mode 100644
index 0000000000..826bdbce29
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-3.scala
@@ -0,0 +1,3 @@
+val a = Array(1,2,3,4)
+a.foreach {i => println(i)}
+a.foreach(println(_))  '' // same as previous line''
diff --git a/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-4.scala b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-4.scala
new file mode 100644
index 0000000000..b21f95af29
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-4.scala
@@ -0,0 +1,2 @@
+def doSomething(in: int) = {println("Doing something with "+in)}
+l.foreach(doSomething)
diff --git a/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-5.scala b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-5.scala
new file mode 100644
index 0000000000..b86b4f1801
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-5.scala
@@ -0,0 +1 @@
+for(val i <- a) println(i)
diff --git a/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-6.scala b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-6.scala
new file mode 100644
index 0000000000..370ca0b7a8
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-6.scala
@@ -0,0 +1 @@
+val squares = l.map{i => i * i} ''//squares is''  List(1,4,9,16)
diff --git a/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-7.scala b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-7.scala
new file mode 100644
index 0000000000..7e58c45a41
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Scala/apply-a-callback-to-an-array-7.scala
@@ -0,0 +1 @@
+val squares = for (val i <- l) yield i * i
diff --git a/Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-1.ss b/Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-1.ss
new file mode 100644
index 0000000000..0004adcb86
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-1.ss
@@ -0,0 +1,3 @@
+(define (square n) (* n n))
+(define x #(1 2 3 4 5))
+(map square (vector->list x))
diff --git a/Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-2.ss b/Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-2.ss
new file mode 100644
index 0000000000..7a17b093a9
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-2.ss
@@ -0,0 +1 @@
+(map (lambda (n) (* n n)) '(1 2 3 4 5))
diff --git a/Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-3.ss b/Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-3.ss
new file mode 100644
index 0000000000..03fcad8ed9
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Scheme/apply-a-callback-to-an-array-3.ss
@@ -0,0 +1,4 @@
+(define (map f L)
+  (if (null? L)
+      L
+      (cons (f (car L)) (map f (cdr L)))))
diff --git a/Task/Apply-a-callback-to-an-array/Smalltalk/apply-a-callback-to-an-array.st b/Task/Apply-a-callback-to-an-array/Smalltalk/apply-a-callback-to-an-array.st
new file mode 100644
index 0000000000..2192ae1703
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Smalltalk/apply-a-callback-to-an-array.st
@@ -0,0 +1 @@
+#( 1 2 3 4 5 ) collect: [:n | n * n].
diff --git a/Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-1.tcl b/Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-1.tcl
new file mode 100644
index 0000000000..8b091b4a47
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-1.tcl
@@ -0,0 +1,3 @@
+foreach var $dat {
+    myfunc $var
+}
diff --git a/Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-2.tcl b/Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-2.tcl
new file mode 100644
index 0000000000..96342dcc5f
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-2.tcl
@@ -0,0 +1,3 @@
+foreach name [array names dat] {
+    myfunc $dat($name)
+}
diff --git a/Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-3.tcl b/Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-3.tcl
new file mode 100644
index 0000000000..f4825046db
--- /dev/null
+++ b/Task/Apply-a-callback-to-an-array/Tcl/apply-a-callback-to-an-array-3.tcl
@@ -0,0 +1,9 @@
+proc map {f list} {
+   set res {}
+   foreach e $list {lappend res [$f $e]}
+   return $res
+}
+proc square x {expr {$x*$x}}
+
+% map square {1 2 3 4 5}
+1 4 9 16 25
diff --git a/Task/Arbitrary-precision-integers-(included)/0DESCRIPTION b/Task/Arbitrary-precision-integers-(included)/0DESCRIPTION
new file mode 100644
index 0000000000..917612b3f6
--- /dev/null
+++ b/Task/Arbitrary-precision-integers-(included)/0DESCRIPTION
@@ -0,0 +1,11 @@
+Using the in-built capabilities of your language, calculate the integer value of:
+
+::5^{4^{3^2}}
+
+*  Confirm that the first and last twenty digits of the answer are: 62060698786608744707...92256259918212890625
+*  Find and show the number of decimal digits in the answer.
+
+C.F. [[Long multiplication]]
+
+Note: 
  • Do not submit an ''implementation'' of [[wp:arbitrary precision arithmetic|arbitrary precision arithmetic]]. The intention is to show the capabilities of the language as supplied. If a language has a [[Talk:Arbitrary-precision integers (included)#Use of external libraries|single, overwhelming, library]] of varied modules that is endorsed by its home site – such as [[CPAN]] for Perl or [[Boost]] for C++ – then that ''may'' be used instead. +
  • Strictly speaking, this should not be solved by fixed-precision numeric libraries where the precision has to be manually set to a large value; although if this is the '''only''' recourse then it may be used with a note explaining that the precision must be set manually to a large enough value.
diff --git a/Task/Arbitrary-precision-integers-(included)/1META.yaml b/Task/Arbitrary-precision-integers-(included)/1META.yaml new file mode 100644 index 0000000000..a34a05e951 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arbitrary precision diff --git a/Task/Arbitrary-precision-integers-(included)/ACL2/arbitrary-precision-integers-(included).acl2 b/Task/Arbitrary-precision-integers-(included)/ACL2/arbitrary-precision-integers-(included).acl2 new file mode 100644 index 0000000000..b337fa9520 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/ACL2/arbitrary-precision-integers-(included).acl2 @@ -0,0 +1,19 @@ +(in-package "ACL2") + +(include-book "arithmetic-3/floor-mod/floor-mod" :dir :system) + +(set-print-length 0 state) + +(defun arbitrary-precision () + (declare (xargs :mode :program)) + (let* ((x (expt 5 (expt 4 (expt 3 2)))) + (s (mv-let (col str) + (fmt1-to-string "~xx" + (list (cons #\x x)) + 0) + (declare (ignore col)) + str))) + (cw "~s0 ... ~x1 (~x2 digits)~%" + (subseq s 1 21) + (mod x (expt 10 20)) + (1- (length s))))) diff --git a/Task/Arbitrary-precision-integers-(included)/Ada/arbitrary-precision-integers-(included).ada b/Task/Arbitrary-precision-integers-(included)/Ada/arbitrary-precision-integers-(included).ada new file mode 100644 index 0000000000..838bfb5fec --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Ada/arbitrary-precision-integers-(included).ada @@ -0,0 +1,16 @@ +with Ada.Text_IO; use Ada.Text_IO; +with GNATCOLL.GMP; use GNATCOLL.GMP; +with GNATCOLL.GMP.Integers; use GNATCOLL.GMP.Integers; +procedure ArbitraryInt is + type stracc is access String; + BigInt : Big_Integer; + len : Natural; + str : stracc; +begin + Set (BigInt, 5); + Raise_To_N (BigInt, Unsigned_Long (4**(3**2))); + str := new String'(Image (BigInt)); + len := str'Length; + Put_Line ("Size is:"& Natural'Image (len)); + Put_Line (str (1 .. 20) & "....." & str (len - 19 .. len)); +end ArbitraryInt; diff --git a/Task/Arbitrary-precision-integers-(included)/Alore/arbitrary-precision-integers-(included).alore b/Task/Arbitrary-precision-integers-(included)/Alore/arbitrary-precision-integers-(included).alore new file mode 100644 index 0000000000..ff113918e1 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Alore/arbitrary-precision-integers-(included).alore @@ -0,0 +1,9 @@ +def Main() + var len as Int + var result as Str + result = Str(5**4**3**2) + len = result.length() + Print(len) + Print(result[:20]) + Print(result[len-20:]) +end diff --git a/Task/Arbitrary-precision-integers-(included)/C/arbitrary-precision-integers-(included)-1.c b/Task/Arbitrary-precision-integers-(included)/C/arbitrary-precision-integers-(included)-1.c new file mode 100644 index 0000000000..9473b610d5 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/C/arbitrary-precision-integers-(included)-1.c @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + mpz_t a; + mpz_init_set_ui(a, 5); + mpz_pow_ui(a, a, 1 << 18); /* 2**18 == 4**9 */ + + int len = mpz_sizeinbase(a, 10); + printf("GMP says size is: %d\n", len); + + /* because GMP may report size 1 too big; see doc */ + char *s = mpz_get_str(0, 10, a); + printf("size really is %d\n", len = strlen(s)); + printf("Digits: %.20s...%s\n", s, s + len - 20); + + // free(s); /* we could, but we won't. we are exiting anyway */ + return 0; +} diff --git a/Task/Arbitrary-precision-integers-(included)/C/arbitrary-precision-integers-(included)-2.c b/Task/Arbitrary-precision-integers-(included)/C/arbitrary-precision-integers-(included)-2.c new file mode 100644 index 0000000000..64af6a5d8d --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/C/arbitrary-precision-integers-(included)-2.c @@ -0,0 +1,65 @@ +/* 5432.c */ + +#include /* BN_*() */ +#include /* ERR_*() */ +#include /* exit() */ +#include /* fprintf() */ +#include /* strlen() */ + +void +fail(const char *message) +{ + fprintf(stderr, "%s: error 0x%08lx\n", ERR_get_error()); + exit(1); +} + +int +main() +{ + BIGNUM two, three, four, five; + BIGNUM answer; + BN_CTX *context; + size_t length; + char *string; + + context = BN_CTX_new(); + if (context == NULL) + fail("BN_CTX_new"); + + /* answer = 5 ** 4 ** 3 ** 2 */ + BN_init(&two); + BN_init(&three); + BN_init(&four); + BN_init(&five); + if (BN_set_word(&two, 2) == 0 || + BN_set_word(&three, 3) == 0 || + BN_set_word(&four, 4) == 0 || + BN_set_word(&five, 5) == 0) + fail("BN_set_word"); + BN_init(&answer); + if (BN_exp(&answer, &three, &two, context) == 0 || + BN_exp(&answer, &four, &answer, context) == 0 || + BN_exp(&answer, &five, &answer, context) == 0) + fail("BN_exp"); + + /* string = decimal answer */ + string = BN_bn2dec(&answer); + if (string == NULL) + fail("BN_bn2dec"); + + length = strlen(string); + printf(" First 20 digits: %.20s\n", string); + if (length >= 20) + printf(" Last 20 digits: %.20s\n", string + length - 20); + printf("Number of digits: %zd\n", length); + + OPENSSL_free(string); + BN_free(&answer); + BN_free(&five); + BN_free(&four); + BN_free(&three); + BN_free(&two); + BN_CTX_free(context); + + return 0; +} diff --git a/Task/Arbitrary-precision-integers-(included)/Clojure/arbitrary-precision-integers-(included)-1.clj b/Task/Arbitrary-precision-integers-(included)/Clojure/arbitrary-precision-integers-(included)-1.clj new file mode 100644 index 0000000000..fb911a500b --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Clojure/arbitrary-precision-integers-(included)-1.clj @@ -0,0 +1,12 @@ +(defn exp [n k] (reduce * (repeat k n))) + +(def big (->> 2 (exp 3) (exp 4) (exp 5))) +(def sbig (str big)) + +(assert (= "62060698786608744707" (.substring sbig 0 20))) +(assert (= "92256259918212890625" (.substring sbig (- (count sbig) 20)))) +(println (count sbig) "digits") + +(println (str (.substring sbig 0 20) ".." + (.substring sbig (- (count sbig) 20))) + (str "(" (count sbig) " digits)")) diff --git a/Task/Arbitrary-precision-integers-(included)/Clojure/arbitrary-precision-integers-(included)-2.clj b/Task/Arbitrary-precision-integers-(included)/Clojure/arbitrary-precision-integers-(included)-2.clj new file mode 100644 index 0000000000..70c00fc896 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Clojure/arbitrary-precision-integers-(included)-2.clj @@ -0,0 +1,5 @@ +(defn exp [n k] + (cond + (zero? (mod k 2)) (recur (* n n) (/ k 2)) + (zero? (mod k 3)) (recur (* n n n) (/ k 3)) + :else (reduce * (repeat k n)))) diff --git a/Task/Arbitrary-precision-integers-(included)/Erlang/arbitrary-precision-integers-(included).erl b/Task/Arbitrary-precision-integers-(included)/Erlang/arbitrary-precision-integers-(included).erl new file mode 100644 index 0000000000..706332b1bd --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Erlang/arbitrary-precision-integers-(included).erl @@ -0,0 +1,20 @@ +-module(arbitrary). +-compile([export_all]). + +pow(B,E) when E > 0 -> + pow(B,E,1). + +pow(_,0,_) -> 0; +pow(B,1,Acc) -> Acc * B; +pow(B,P,Acc) when P rem 2 == 0 -> + pow(B*B,P div 2, Acc); +pow(B,P,Acc) -> + pow(B,P-1,Acc*B). + +test() -> + I = pow(5,pow(4,pow(3,2))), + [S] = io_lib:format("~b",[I]), + L = length(S), + Prefix = lists:sublist(S,20), + Suffix = lists:sublist(S,L-19,20), + io:format("Length: ~b~nPrefix:~s~nSuffix:~s~n",[L,Prefix,Suffix]). diff --git a/Task/Arbitrary-precision-integers-(included)/Go/arbitrary-precision-integers-(included).go b/Task/Arbitrary-precision-integers-(included)/Go/arbitrary-precision-integers-(included).go new file mode 100644 index 0000000000..91527a94ce --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Go/arbitrary-precision-integers-(included).go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "math/big" +) + +func main() { + answer := big.NewInt(42) + answer.Exp(big.NewInt(5), answer.Exp(big.NewInt(4), + answer.Exp(big.NewInt(3), big.NewInt(2), nil), nil), nil) + answer_string := answer.String() + length := len(answer_string) + fmt.Printf("has %d digits: %s ... %s\n", + length, + answer_string[0:20], + answer_string[length-20:]) +} diff --git a/Task/Arbitrary-precision-integers-(included)/Haskell/arbitrary-precision-integers-(included).hs b/Task/Arbitrary-precision-integers-(included)/Haskell/arbitrary-precision-integers-(included).hs new file mode 100644 index 0000000000..e5f6738b4d --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Haskell/arbitrary-precision-integers-(included).hs @@ -0,0 +1,4 @@ +main = do + let y = show ( 5^4^3^2 ) + let l = length y + putStrLn ("5**4**3**2 = " ++ take 20 y ++ "..." ++ drop (l-20) y ++ " and has " ++ show l ++ " digits") diff --git a/Task/Arbitrary-precision-integers-(included)/Java/arbitrary-precision-integers-(included).java b/Task/Arbitrary-precision-integers-(included)/Java/arbitrary-precision-integers-(included).java new file mode 100644 index 0000000000..6d9f1d5c70 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Java/arbitrary-precision-integers-(included).java @@ -0,0 +1,11 @@ +import java.math.BigInteger; + +class Program { + public static void main(String[] args) { + BigInteger x = BigInteger.valueOf(5).pow(BigInteger.valueOf(4).pow(BigInteger.valueOf(3).pow(2).intValue()).intValue()); + String y = x.toString(); + int l = y.length(); + System.out.printf("5**4**3**2 = %s...%s and has %d digits\n", + y.substring(0,20), y.substring(l-20), l); + } +} diff --git a/Task/Arbitrary-precision-integers-(included)/PHP/arbitrary-precision-integers-(included).php b/Task/Arbitrary-precision-integers-(included)/PHP/arbitrary-precision-integers-(included).php new file mode 100644 index 0000000000..5b9940bd32 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/PHP/arbitrary-precision-integers-(included).php @@ -0,0 +1,4 @@ + diff --git a/Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-1.pl b/Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-1.pl new file mode 100644 index 0000000000..16f8bb144f --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-1.pl @@ -0,0 +1,4 @@ +use Math::BigInt; +my $x = Math::BigInt->new('5') ** Math::BigInt->new('4') ** Math::BigInt->new('3') ** Math::BigInt->new('2'); +my $y = "$x"; +printf("5**4**3**2 = %s...%s and has %i digits\n", substr($y,0,20), substr($y,-20), length($y)); diff --git a/Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-2.pl b/Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-2.pl new file mode 100644 index 0000000000..0ac8cb28d6 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-2.pl @@ -0,0 +1,4 @@ +use bigint; +my $x = 5**4**3**2; +my $y = "$x"; +printf("5**4**3**2 = %s...%s and has %i digits\n", substr($y,0,20), substr($y,-20), length($y)); diff --git a/Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-3.pl b/Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-3.pl new file mode 100644 index 0000000000..2a2c2692b8 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Perl/arbitrary-precision-integers-(included)-3.pl @@ -0,0 +1,3 @@ +$ time perl transparent-bigint.pl +5**4**3**2 = 62060698786608744707...92256259918212890625 and has 183231 digits + 1m4.28s real 1m4.30s user 0m0.00s system diff --git a/Task/Arbitrary-precision-integers-(included)/PicoLisp/arbitrary-precision-integers-(included).l b/Task/Arbitrary-precision-integers-(included)/PicoLisp/arbitrary-precision-integers-(included).l new file mode 100644 index 0000000000..f8d0095c14 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/PicoLisp/arbitrary-precision-integers-(included).l @@ -0,0 +1,3 @@ +(let L (chop (** 5 (** 4 (** 3 2)))) + (prinl (head 20 L) "..." (tail 20 L)) + (length L) ) diff --git a/Task/Arbitrary-precision-integers-(included)/Python/arbitrary-precision-integers-(included).py b/Task/Arbitrary-precision-integers-(included)/Python/arbitrary-precision-integers-(included).py new file mode 100644 index 0000000000..9c73f44c8e --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Python/arbitrary-precision-integers-(included).py @@ -0,0 +1,3 @@ +>>> y = str( 5**4**3**2 ) +>>> print ("5**4**3**2 = %s...%s and has %i digits" % (y[:20], y[-20:], len(y))) +5**4**3**2 = 62060698786608744707...92256259918212890625 and has 183231 digits diff --git a/Task/Arbitrary-precision-integers-(included)/R/arbitrary-precision-integers-(included).r b/Task/Arbitrary-precision-integers-(included)/R/arbitrary-precision-integers-(included).r new file mode 100644 index 0000000000..7c3443d92f --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/R/arbitrary-precision-integers-(included).r @@ -0,0 +1,6 @@ +library(gmp) +large=pow.bigz(5,pow.bigz(4,pow.bigz(3,2))) +largestr=as.character(large) +cat("first 20 digits:",substr(largestr,1,20),"\n", + "last 20 digits:",substr(largestr,nchar(largestr)-19,nchar(largestr)),"\n", + "number of digits: ",nchar(largestr),"\n") diff --git a/Task/Arbitrary-precision-integers-(included)/REXX/arbitrary-precision-integers-(included)-1.rexx b/Task/Arbitrary-precision-integers-(included)/REXX/arbitrary-precision-integers-(included)-1.rexx new file mode 100644 index 0000000000..c708819f2c --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/REXX/arbitrary-precision-integers-(included)-1.rexx @@ -0,0 +1,12 @@ +/*REXX program to calculate and demonstrate arbitrary precision numbers.*/ +numeric digits 200000 +check = 62060698786608744707...92256259918212890625 + n = 5 ** (4 ** (3 ** 2)) /*calc. multiple exponentations. */ +sampl = left(n, 20)'...'right(n, 20) +say ' check:' check +say 'sample:' sampl +say 'digits:' length(n) +say +if check==sampl then say 'passed!' + else say 'failed!' + /*stick a fork in it, we're done.*/ diff --git a/Task/Arbitrary-precision-integers-(included)/REXX/arbitrary-precision-integers-(included)-2.rexx b/Task/Arbitrary-precision-integers-(included)/REXX/arbitrary-precision-integers-(included)-2.rexx new file mode 100644 index 0000000000..4753dbe0da --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/REXX/arbitrary-precision-integers-(included)-2.rexx @@ -0,0 +1,21 @@ +/*REXX program to calculate and demonstrate arbitrary precision numbers.*/ +numeric digits 5 /*set to low precision for speed.*/ +check = 62060698786608744707...92256259918212890625 + + n=5** (4** (3** 2)) /*calc. multiple exponentations. */ + +parse var n 'E' pow . /*POW might be null, so N is OK.*/ + +if pow\=='' then do /*general case: POW might be < 0*/ + numeric digits abs(pow)+9 /*recalc. with more digits.*/ + n=5** (4** (3** 2)) /*calc. multiple exponentations. */ + end + +sampl = left(n, 20)'...'right(n, 20) +say ' check:' check +say 'sample:' sampl +say 'digits:' length(n) +say +if check==sampl then say 'passed!' + else say 'failed!' + /*stick a fork in it, we're done.*/ diff --git a/Task/Arbitrary-precision-integers-(included)/Racket/arbitrary-precision-integers-(included).rkt b/Task/Arbitrary-precision-integers-(included)/Racket/arbitrary-precision-integers-(included).rkt new file mode 100644 index 0000000000..f9150a2615 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Racket/arbitrary-precision-integers-(included).rkt @@ -0,0 +1,9 @@ +#lang racket + +(define answer (number->string (foldr expt 1 '(5 4 3 2)))) +(define len (string-length answer)) + +(printf "Got ~a digits~n" len) +(printf "~a ... ~a~n" + (substring answer 0 20) + (substring answer (- len 20) len)) diff --git a/Task/Arbitrary-precision-integers-(included)/Ruby/arbitrary-precision-integers-(included).rb b/Task/Arbitrary-precision-integers-(included)/Ruby/arbitrary-precision-integers-(included).rb new file mode 100644 index 0000000000..ff50bf1764 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Ruby/arbitrary-precision-integers-(included).rb @@ -0,0 +1,2 @@ +irb(main):001:0> y = ( 5**4**3**2 ).to_s; puts "5**4**3**2 = #{y[0..19]}...#{y[-20..-1]} and has #{y.length} digits" +5**4**3**2 = 62060698786608744707...92256259918212890625 and has 183231 digits diff --git a/Task/Arbitrary-precision-integers-(included)/Sather/arbitrary-precision-integers-(included).sa b/Task/Arbitrary-precision-integers-(included)/Sather/arbitrary-precision-integers-(included).sa new file mode 100644 index 0000000000..9b96acc2ed --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Sather/arbitrary-precision-integers-(included).sa @@ -0,0 +1,22 @@ +class MAIN is + main is + r:INTI; + p1 ::= "62060698786608744707"; + p2 ::= "92256259918212890625"; + + -- computing 5^(4^(3^2)), it could be written + -- also e.g. (5.inti)^((4.inti)^((3.inti)^(2.inti))) + r := (3.pow(2)).inti; + r := (4.inti).pow(r); + r := (5.inti).pow(r); + + sr ::= r.str; -- string rappr. of the number + if sr.head(p1.size) = p1 + and sr.tail(p2.size) = p2 then + #OUT + "result is ok..\n"; + else + #OUT + "oops\n"; + end; + #OUT + "# of digits: " + sr.size + "\n"; + end; +end; diff --git a/Task/Arbitrary-precision-integers-(included)/Scala/arbitrary-precision-integers-(included).scala b/Task/Arbitrary-precision-integers-(included)/Scala/arbitrary-precision-integers-(included).scala new file mode 100644 index 0000000000..5c23ab93a4 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Scala/arbitrary-precision-integers-(included).scala @@ -0,0 +1,21 @@ +scala> BigInt(5) modPow (BigInt(4) pow (BigInt(3) pow 2).toInt, BigInt(10) pow 20) +res21: scala.math.BigInt = 92256259918212890625 + +scala> (BigInt(5) pow (BigInt(4) pow (BigInt(3) pow 2).toInt).toInt).toString +res22: String = 6206069878660874470748320557284679309194219265199117173177383244 +78446890420544620839553285931321349485035253770303663683982841794590287939217907 +89641300156281305613064874236198955114921296922487632406742326659692228562195387 +46210423235340883954495598715281862895110697243759768434501295076608139350684049 +01191160699929926568099301259938271975526587719565309995276438998093283175080241 +55833224724855977970015112594128926594587205662421861723789001208275184293399910 +13912158886504596553858675842231519094813553261073608575593794241686443569888058 +92732524316323249492420512640962691673104618378381545202638771401061171968052873 +21414945463925055899307933774904078819911387324217976311238875802878310483037255 +33789567769926391314746986316354035923183981697660495275234703657750678459919... +scala> res22 take 20 +res23: String = 62060698786608744707 + +scala> res22 length +res24: Int = 183231 + +scala> diff --git a/Task/Arbitrary-precision-integers-(included)/Scheme/arbitrary-precision-integers-(included).ss b/Task/Arbitrary-precision-integers-(included)/Scheme/arbitrary-precision-integers-(included).ss new file mode 100644 index 0000000000..eb4a9716cb --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Scheme/arbitrary-precision-integers-(included).ss @@ -0,0 +1,5 @@ +(define x (expt 5 (expt 4 (expt 3 2)))) +(define y (number->string x)) +(define l (string-length y)) +(display (string-append "5**4**3**2 = " (substring y 0 20) "..." (substring y (- l 20) l) " and has " (number->string l) " digits")) +(newline) diff --git a/Task/Arbitrary-precision-integers-(included)/Smalltalk/arbitrary-precision-integers-(included)-1.st b/Task/Arbitrary-precision-integers-(included)/Smalltalk/arbitrary-precision-integers-(included)-1.st new file mode 100644 index 0000000000..bc43ca6f12 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Smalltalk/arbitrary-precision-integers-(included)-1.st @@ -0,0 +1,5 @@ +|num| +num := (5 raisedTo: (4 raisedTo: (3 raisedTo: 2))) asString. +Transcript + show: (num first: 20), '...', (num last: 20); cr; + show: 'digits: ', num size asString. diff --git a/Task/Arbitrary-precision-integers-(included)/Smalltalk/arbitrary-precision-integers-(included)-2.st b/Task/Arbitrary-precision-integers-(included)/Smalltalk/arbitrary-precision-integers-(included)-2.st new file mode 100644 index 0000000000..0174b99ebf --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Smalltalk/arbitrary-precision-integers-(included)-2.st @@ -0,0 +1,7 @@ +|num numstr| +num := (2 to: 5) fold: [:exp :base| base raisedTo: exp]. +numstr := num asString. +'<1s>...<2s> digits:<3p>' + expandMacrosWith: (numstr first: 20) + with: (numstr last: 20) + with: numstr size. diff --git a/Task/Arbitrary-precision-integers-(included)/Tcl/arbitrary-precision-integers-(included).tcl b/Task/Arbitrary-precision-integers-(included)/Tcl/arbitrary-precision-integers-(included).tcl new file mode 100644 index 0000000000..71fdc22752 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Tcl/arbitrary-precision-integers-(included).tcl @@ -0,0 +1,7 @@ +set bigValue [expr {5**4**3**2}] +puts "5**4**3**2 has [string length $bigValue] digits" +if {[string match "62060698786608744707*92256259918212890625" $bigValue]} { + puts "Value starts with 62060698786608744707, ends with 92256259918212890625" +} else { + puts "Value does not match 62060698786608744707...92256259918212890625" +} diff --git a/Task/Arena-storage-pool/0DESCRIPTION b/Task/Arena-storage-pool/0DESCRIPTION new file mode 100644 index 0000000000..9aaf1bb20f --- /dev/null +++ b/Task/Arena-storage-pool/0DESCRIPTION @@ -0,0 +1,16 @@ +Dynamically allocated objects take their memory from a [[heap]]. The memory for an object is provided by an '''allocator''' which maintains the storage pool used for the [[heap]]. Often a call to allocator is denoted as + +P := new T + +where T is the type of an allocated object and P is a [[reference]] to the object. + +The storage pool chosen by the allocator can be determined by either: +* the object type T; +* the type of pointer P. +In the former case objects can be allocated only in one storage pool. In the latter case objects of the type can be allocated in any storage pool or on the [[stack]]. + +'''Task description'''
+The task is to show how allocators and user-defined storage pools are supported by the language. In particular: +# define an arena storage pool. An arena is a pool in which objects are allocated individually, but freed by groups. +# allocate some objects (e.g., integers) in the pool. +Explain what controls the storage pool choice in the language. diff --git a/Task/Arena-storage-pool/1META.yaml b/Task/Arena-storage-pool/1META.yaml new file mode 100644 index 0000000000..f0582f8055 --- /dev/null +++ b/Task/Arena-storage-pool/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Encyclopedia diff --git a/Task/Arena-storage-pool/Ada/arena-storage-pool-1.ada b/Task/Arena-storage-pool/Ada/arena-storage-pool-1.ada new file mode 100644 index 0000000000..9f1210e1f4 --- /dev/null +++ b/Task/Arena-storage-pool/Ada/arena-storage-pool-1.ada @@ -0,0 +1,2 @@ +type My_Pointer is access My_Object; +for My_Pointer'Storage_Pool use My_Pool; diff --git a/Task/Arena-storage-pool/Ada/arena-storage-pool-2.ada b/Task/Arena-storage-pool/Ada/arena-storage-pool-2.ada new file mode 100644 index 0000000000..d63b12b564 --- /dev/null +++ b/Task/Arena-storage-pool/Ada/arena-storage-pool-2.ada @@ -0,0 +1,27 @@ +with System.Storage_Elements; use System.Storage_Elements; +with System.Storage_Pools; use System.Storage_Pools; + +package Arena_Pools is + type Arena (Size : Storage_Count) is new Root_Storage_Pool with private; + overriding + procedure Allocate + ( Pool : in out Arena; + Address : out System.Address; + Size : Storage_Count; + Alignment : Storage_Count + ); + overriding + procedure Deallocate + ( Pool : in out Arena; + Address : System.Address; + Size : Storage_Count; + Alignment : Storage_Count + ) is null; + overriding + function Storage_Size (Pool : Arena) return Storage_Count; +private + type Arena (Size : Storage_Count) is new Root_Storage_Pool with record + Free : Storage_Offset := 1; + Core : Storage_Array (1..Size); + end record; +end Arena_Pools; diff --git a/Task/Arena-storage-pool/Ada/arena-storage-pool-3.ada b/Task/Arena-storage-pool/Ada/arena-storage-pool-3.ada new file mode 100644 index 0000000000..d53b54d02a --- /dev/null +++ b/Task/Arena-storage-pool/Ada/arena-storage-pool-3.ada @@ -0,0 +1,22 @@ +package body Arena_Pools is + procedure Allocate + ( Pool : in out Arena; + Address : out System.Address; + Size : Storage_Count; + Alignment : Storage_Count + ) is + Free : constant Storage_Offset := + Pool.Free + Alignment - Pool.Core (Pool.Free)'Address mod Alignment + Size; + begin + if Free - 1 > Pool.Size then + raise Storage_Error; + end if; + Pool.Free := Free; + Address := Pool.Core (Pool.Free - Size)'Address; + end Allocate; + + function Storage_Size (Pool : Arena) return Storage_Count is + begin + return Pool.Size; + end Storage_Size; +end Arena_Pools; diff --git a/Task/Arena-storage-pool/Ada/arena-storage-pool-4.ada b/Task/Arena-storage-pool/Ada/arena-storage-pool-4.ada new file mode 100644 index 0000000000..3b86cec89b --- /dev/null +++ b/Task/Arena-storage-pool/Ada/arena-storage-pool-4.ada @@ -0,0 +1,15 @@ +with Arena_Pools; +use Arena_Pools; + +procedure Test_Allocator is + Pool : Arena_Pools.Arena (1024); + type Integer_Ptr is access Integer; + for Integer_Ptr'Storage_Pool use Pool; + + X : Integer_Ptr := new Integer'(1); + Y : Integer_Ptr := new Integer'(2); + Z : Integer_Ptr; +begin + Z := new Integer; + Z.all := X.all + Y.all; +end Test_Allocator; diff --git a/Task/Arena-storage-pool/C/arena-storage-pool-1.c b/Task/Arena-storage-pool/C/arena-storage-pool-1.c new file mode 100644 index 0000000000..c8b49f26d1 --- /dev/null +++ b/Task/Arena-storage-pool/C/arena-storage-pool-1.c @@ -0,0 +1 @@ +#include diff --git a/Task/Arena-storage-pool/C/arena-storage-pool-2.c b/Task/Arena-storage-pool/C/arena-storage-pool-2.c new file mode 100644 index 0000000000..cff4489fde --- /dev/null +++ b/Task/Arena-storage-pool/C/arena-storage-pool-2.c @@ -0,0 +1,3 @@ +int *var = malloc(n*sizeof(int)); +Typename *var = malloc(sizeof(Typename)); +Typename *var = malloc(sizeof var[0]); diff --git a/Task/Arena-storage-pool/C/arena-storage-pool-3.c b/Task/Arena-storage-pool/C/arena-storage-pool-3.c new file mode 100644 index 0000000000..a822ade5dc --- /dev/null +++ b/Task/Arena-storage-pool/C/arena-storage-pool-3.c @@ -0,0 +1,3 @@ +typedef struct mytypeStruct { .... } sMyType, *MyType; + +MyType var = malloc(sizeof(sMyType)); diff --git a/Task/Arena-storage-pool/C/arena-storage-pool-4.c b/Task/Arena-storage-pool/C/arena-storage-pool-4.c new file mode 100644 index 0000000000..96b68c6e51 --- /dev/null +++ b/Task/Arena-storage-pool/C/arena-storage-pool-4.c @@ -0,0 +1,6 @@ +/* allocate an array of n MyTypes */ +MyType var = calloc(n, sizeof(sMyType)); + +MyType third = var+3; /* a reference to the 3rd item allocated */ + +MyType fourth = &var[4]; /* another way, getting the fourth item */ diff --git a/Task/Arena-storage-pool/C/arena-storage-pool-5.c b/Task/Arena-storage-pool/C/arena-storage-pool-5.c new file mode 100644 index 0000000000..aedff777bd --- /dev/null +++ b/Task/Arena-storage-pool/C/arena-storage-pool-5.c @@ -0,0 +1 @@ +free(var); diff --git a/Task/Arena-storage-pool/C/arena-storage-pool-6.c b/Task/Arena-storage-pool/C/arena-storage-pool-6.c new file mode 100644 index 0000000000..aa8b1c4392 --- /dev/null +++ b/Task/Arena-storage-pool/C/arena-storage-pool-6.c @@ -0,0 +1 @@ +Typename *var = alloca(sizeof(Typename)); diff --git a/Task/Arena-storage-pool/REXX/arena-storage-pool.rexx b/Task/Arena-storage-pool/REXX/arena-storage-pool.rexx new file mode 100644 index 0000000000..47db215418 --- /dev/null +++ b/Task/Arena-storage-pool/REXX/arena-storage-pool.rexx @@ -0,0 +1,11 @@ +/*REXX doesn't have declarations/allocations of variables, */ +/* but this is the closest to an allocation: */ + +stemmed_array.= 0 /*any undefined element will have this value. */ + +stemmed_array.1 = '1st entry' +stemmed_array.2 = '2nd entry' +stemmed_array.6000 = 12 ** 2 +stemmed_array.dog = stemmed_array.6000 / 2 + +drop stemmed_array. diff --git a/Task/Arena-storage-pool/Tcl/arena-storage-pool-1.tcl b/Task/Arena-storage-pool/Tcl/arena-storage-pool-1.tcl new file mode 100644 index 0000000000..c925ee9384 --- /dev/null +++ b/Task/Arena-storage-pool/Tcl/arena-storage-pool-1.tcl @@ -0,0 +1,81 @@ +package require Tcl 8.6 +oo::class create Pool { + superclass oo::class + variable capacity pool busy + unexport create + constructor args { + next {*}$args + set capacity 100 + set pool [set busy {}] + } + method new {args} { + if {[llength $pool]} { + set pool [lassign $pool obj] + } else { + if {[llength $busy] >= $capacity} { + throw {POOL CAPACITY} "exceeded capacity: $capacity" + } + set obj [next] + set newobj [namespace current]::[namespace tail $obj] + rename $obj $newobj + set obj $newobj + } + try { + [info object namespace $obj]::my Init {*}$args + } on error {msg opt} { + lappend pool $obj + return -options $opt $msg + } + lappend busy $obj + return $obj + } + method ReturnToPool obj { + try { + if {"Finalize" in [info object methods $obj -all -private]} { + [info object namespace $obj]::my Finalize + } + } on error {msg opt} { + after 0 [list return -options $opt $msg] + return false + } + set idx [lsearch -exact $busy $obj] + set busy [lreplace $busy $idx $idx] + if {[llength $pool] + [llength $busy] + 1 <= $capacity} { + lappend pool $obj + return true + } else { + return false + } + } + method capacity {{value {}}} { + if {[llength [info level 0]] == 3} { + if {$value < $capacity} { + while {[llength $pool] > 0 && [llength $pool] + [llength $busy] > $value} { + set pool [lassign $pool obj] + rename $obj {} + } + } + set capacity [expr {$value >> 0}] + } else { + return $capacity + } + } + method clearPool {} { + foreach obj $busy { + $obj destroy + } + } + method destroy {} { + my clearPool + next + } + self method create {class {definition {}}} { + set cls [next $class $definition] + oo::define $cls method destroy {} { + if {![[info object namespace [self class]]::my ReturnToPool [self]]} { + next + } + } + return $cls + } +} diff --git a/Task/Arena-storage-pool/Tcl/arena-storage-pool-2.tcl b/Task/Arena-storage-pool/Tcl/arena-storage-pool-2.tcl new file mode 100644 index 0000000000..713722532e --- /dev/null +++ b/Task/Arena-storage-pool/Tcl/arena-storage-pool-2.tcl @@ -0,0 +1,53 @@ +Pool create PoolExample { + variable int + + method Init value { + puts stderr "Initializing [self] with $value" + set int $value + incr int 0 + } + method Finalize {} { + puts stderr "Finalizing [self] which held $int" + } + + method value {{newValue {}}} { + if {[llength [info level 0]] == 3} { + set int [incr newValue 0] + } else { + return $int + } + } +} + +PoolExample capacity 10 +set objs {} +try { + for {set i 0} {$i < 20} {incr i} { + lappend objs [PoolExample new $i] + } +} trap {POOL CAPACITY} msg { + puts "trapped: $msg" +} +puts -nonewline "number of objects: [llength $objs]\n\t" +foreach o $objs { + puts -nonewline "[$o value] " +} +puts "" +set objs [lassign $objs a b c] +$a destroy +$b destroy +$c destroy +PoolExample capacity 9 +try { + for {} {$i < 20} {incr i} { + lappend objs [PoolExample new $i] + } +} trap {POOL CAPACITY} msg { + puts "trapped: $msg" +} +puts -nonewline "number of objects: [llength $objs]\n\t" +foreach o $objs { + puts -nonewline "[$o value] " +} +puts "" +PoolExample clearPool diff --git a/Task/Arithmetic-Complex/0DESCRIPTION b/Task/Arithmetic-Complex/0DESCRIPTION new file mode 100644 index 0000000000..8451e12ddd --- /dev/null +++ b/Task/Arithmetic-Complex/0DESCRIPTION @@ -0,0 +1,6 @@ +A '''[[wp:Complex number|complex number]]''' is a number which can be written as "a + b \times i" (sometimes shown as "b + a \times i") where a and b are real numbers and [[wp:Imaginary_unit|i is the square root of -1]]. Typically, complex numbers are represented as a pair of real numbers called the "imaginary part" and "real part", where the imaginary part is the number to be multiplied by i. + +* Show addition, multiplication, negation, and inversion of complex numbers in separate functions. (Subtraction and division operations can be made with pairs of these operations.) Print the results for each operation tested. +* ''Optional:'' Show complex conjugation. By definition, the [[wp:complex conjugate|complex conjugate]] of a + bi is a - bi. + +Some languages have complex number libraries available. If your language does, show the operations. If your language does not, also show the definition of this type. diff --git a/Task/Arithmetic-Complex/1META.yaml b/Task/Arithmetic-Complex/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Arithmetic-Complex/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Arithmetic-Complex/ALGOL-68/arithmetic-complex.alg b/Task/Arithmetic-Complex/ALGOL-68/arithmetic-complex.alg new file mode 100644 index 0000000000..0e4466402d --- /dev/null +++ b/Task/Arithmetic-Complex/ALGOL-68/arithmetic-complex.alg @@ -0,0 +1,27 @@ +main:( + FORMAT compl fmt = $g(-7,5)"βŠ₯"g(-7,5)$; + + PROC compl operations = VOID: ( + LONG COMPL a = 1.0 βŠ₯ 1.0; + LONG COMPL b = 3.14159 βŠ₯ 1.2; + + LONG COMPL c; + + printf(($x"a="f(compl fmt)l$,a)); + printf(($x"b="f(compl fmt)l$,b)); + + # addition # + c := a + b; + printf(($x"a+b="f(compl fmt)l$,c)); + # multiplication # + c := a * b; + printf(($x"a*b="f(compl fmt)l$,c)); + # inversion # + c := 1.0 / a; + printf(($x"1/c="f(compl fmt)l$,c)); + # negation # + c := -a; + printf(($x"-a="f(compl fmt)l$,c)) + ); + compl operations +) diff --git a/Task/Arithmetic-Complex/APL/arithmetic-complex.apl b/Task/Arithmetic-Complex/APL/arithmetic-complex.apl new file mode 100644 index 0000000000..d7c8e36778 --- /dev/null +++ b/Task/Arithmetic-Complex/APL/arithmetic-complex.apl @@ -0,0 +1,10 @@ + x←1j1 ⍝assignment + y←5.25j1.5 + x+y ⍝addition +6.25J2.5 + xΓ—y ⍝multiplication +3.75J6.75 + ⌹x ⍝inversion +0.5j_0.5 + -x ⍝negation +Β―1JΒ―1 diff --git a/Task/Arithmetic-Complex/Ada/arithmetic-complex.ada b/Task/Arithmetic-Complex/Ada/arithmetic-complex.ada new file mode 100644 index 0000000000..f33ba0fc5d --- /dev/null +++ b/Task/Arithmetic-Complex/Ada/arithmetic-complex.ada @@ -0,0 +1,46 @@ +with Ada.Numerics.Generic_Complex_Types; +with Ada.Text_IO.Complex_IO; + +procedure Complex_Operations is + -- Ada provides a pre-defined generic package for complex types + -- That package contains definitions for composition, + -- negation, addition, subtraction, multiplication, division, + -- conjugation, exponentiation, and absolute value, as well as + -- basic comparison operations. + -- Ada provides a second pre-defined package for sin, cos, tan, cot, + -- arcsin, arccos, arctan, arccot, and the hyperbolic versions of + -- those trigonometric functions. + + -- The package Ada.Numerics.Generic_Complex_Types requires definition + -- with the real type to be used in the complex type definition. + + package Complex_Types is new Ada.Numerics.Generic_Complex_Types (Long_Float); + use Complex_Types; + package Complex_IO is new Ada.Text_IO.Complex_IO (Complex_Types); + use Complex_IO; + use Ada.Text_IO; + + A : Complex := Compose_From_Cartesian (Re => 1.0, Im => 1.0); + B : Complex := Compose_From_Polar (Modulus => 1.0, Argument => 3.14159); + C : Complex; + +begin + -- Addition + C := A + B; + Put("A + B = "); Put(C); + New_Line; + -- Multiplication + C := A * B; + Put("A * B = "); Put(C); + New_Line; + -- Inversion + C := 1.0 / A; + Put("1.0 / A = "); Put(C); + New_Line; + -- Negation + C := -A; + Put("-A = "); Put(C); + New_Line; + -- Conjugation + C := Conjugate (C); +end Complex_Operations; diff --git a/Task/Arithmetic-Complex/AutoHotkey/arithmetic-complex.ahk b/Task/Arithmetic-Complex/AutoHotkey/arithmetic-complex.ahk new file mode 100644 index 0000000000..0469896597 --- /dev/null +++ b/Task/Arithmetic-Complex/AutoHotkey/arithmetic-complex.ahk @@ -0,0 +1,47 @@ +Cset(C,1,1) +MsgBox % Cstr(C) ; 1 + i*1 +Cneg(C,C) +MsgBox % Cstr(C) ; -1 - i*1 +Cadd(C,C,C) +MsgBox % Cstr(C) ; -2 - i*2 +Cinv(D,C) +MsgBox % Cstr(D) ; -0.25 + 0.25*i +Cmul(C,C,D) +MsgBox % Cstr(C) ; 1 + i*0 + +Cset(ByRef C, re, im) { + VarSetCapacity(C,16) + NumPut(re,C,0,"double") + NumPut(im,C,8,"double") +} +Cre(ByRef C) { + Return NumGet(C,0,"double") +} +Cim(ByRef C) { + Return NumGet(C,8,"double") +} +Cstr(ByRef C) { + Return Cre(C) ((i:=Cim(C))<0 ? " - i*" . -i : " + i*" . i) +} +Cadd(ByRef C, ByRef A, ByRef B) { + VarSetCapacity(C,16) + NumPut(Cre(A)+Cre(B),C,0,"double") + NumPut(Cim(A)+Cim(B),C,8,"double") +} +Cmul(ByRef C, ByRef A, ByRef B) { + VarSetCapacity(C,16) + t := Cre(A)*Cim(B)+Cim(A)*Cre(B) + NumPut(Cre(A)*Cre(B)-Cim(A)*Cim(B),C,0,"double") + NumPut(t,C,8,"double") ; A or B can be C! +} +Cneg(ByRef C, ByRef A) { + VarSetCapacity(C,16) + NumPut(-Cre(A),C,0,"double") + NumPut(-Cim(A),C,8,"double") +} +Cinv(ByRef C, ByRef A) { + VarSetCapacity(C,16) + d := Cre(A)**2 + Cim(A)**2 + NumPut( Cre(A)/d,C,0,"double") + NumPut(-Cim(A)/d,C,8,"double") +} diff --git a/Task/Arithmetic-Complex/BASIC/arithmetic-complex.bas b/Task/Arithmetic-Complex/BASIC/arithmetic-complex.bas new file mode 100644 index 0000000000..3910a37f6f --- /dev/null +++ b/Task/Arithmetic-Complex/BASIC/arithmetic-complex.bas @@ -0,0 +1,46 @@ +TYPE complex + real AS DOUBLE + imag AS DOUBLE +END TYPE +DECLARE SUB add (a AS complex, b AS complex, c AS complex) +DECLARE SUB mult (a AS complex, b AS complex, c AS complex) +DECLARE SUB inv (a AS complex, b AS complex) +DECLARE SUB neg (a AS complex, b AS complex) +CLS +DIM x AS complex +DIM y AS complex +DIM z AS complex +x.real = 1 +x.imag = 1 +y.real = 2 +y.imag = 2 +CALL add(x, y, z) +PRINT z.real; "+"; z.imag; "i" +CALL mult(x, y, z) +PRINT z.real; "+"; z.imag; "i" +CALL inv(x, z) +PRINT z.real; "+"; z.imag; "i" +CALL neg(x, z) +PRINT z.real; "+"; z.imag; "i" + + +SUB add (a AS complex, b AS complex, c AS complex) + c.real = a.real + b.real + c.imag = a.imag + b.imag +END SUB + +SUB inv (a AS complex, b AS complex) + denom = a.real ^ 2 + a.imag ^ 2 + b.real = a.real / denom + b.imag = -a.imag / denom +END SUB + +SUB mult (a AS complex, b AS complex, c AS complex) + c.real = a.real * b.real - a.imag * b.imag + c.imag = a.real * b.imag + a.imag * b.real +END SUB + +SUB neg (a AS complex, b AS complex) + b.real = -a.real + b.imag = -a.imag +END SUB diff --git a/Task/Arithmetic-Complex/C/arithmetic-complex-1.c b/Task/Arithmetic-Complex/C/arithmetic-complex-1.c new file mode 100644 index 0000000000..f50051a82d --- /dev/null +++ b/Task/Arithmetic-Complex/C/arithmetic-complex-1.c @@ -0,0 +1,32 @@ +#include +#include + +void cprint(double complex c) +{ + printf("%f%+fI", creal(c), cimag(c)); +} +void complex_operations() { + double complex a = 1.0 + 1.0I; + double complex b = 3.14159 + 1.2I; + + double complex c; + + printf("\na="); cprint(a); + printf("\nb="); cprint(b); + + // addition + c = a + b; + printf("\na+b="); cprint(c); + // multiplication + c = a * b; + printf("\na*b="); cprint(c); + // inversion + c = 1.0 / a; + printf("\n1/c="); cprint(c); + // negation + c = -a; + printf("\n-a="); cprint(c); + // conjugate + c = conj(a); + printf("\nconj a="); cprint(c); printf("\n"); +} diff --git a/Task/Arithmetic-Complex/C/arithmetic-complex-2.c b/Task/Arithmetic-Complex/C/arithmetic-complex-2.c new file mode 100644 index 0000000000..38d643648f --- /dev/null +++ b/Task/Arithmetic-Complex/C/arithmetic-complex-2.c @@ -0,0 +1,61 @@ +typedef struct{ + double real; + double imag; +} Complex; + +Complex add(Complex a, Complex b){ + Complex ans; + ans.real = a.real + b.real; + ans.imag = a.imag + b.imag; + return ans; +} + +Complex mult(Complex a, Complex b){ + Complex ans; + ans.real = a.real * b.real - a.imag * b.imag; + ans.imag = a.real * b.imag + a.imag * b.real; + return ans; +} + +/* it's arguable that things could be better handled if either + a.real or a.imag is +/-inf, but that's much work */ +Complex inv(Complex a){ + Complex ans; + double denom = a.real * a.real + a.imag * a.imag; + ans.real = a.real / denom; + ans.imag = -a.imag / denom; + return ans; +} + +Complex neg(Complex a){ + Complex ans; + ans.real = -a.real; + ans.imag = -a.imag; + return ans; +} + +Complex conj(Complex a){ + Complex ans; + ans.real = a.real; + ans.imag = -a.imag; + return ans; +} + +void put(Complex c) +{ + printf("%lf%+lfI", c.real, c.imag); +} + +void complex_ops(void) +{ + Complex a = { 1.0, 1.0 }; + Complex b = { 3.14159, 1.2 }; + + printf("\na="); put(a); + printf("\nb="); put(b); + printf("\na+b="); put(add(a,b)); + printf("\na*b="); put(mult(a,b)); + printf("\n1/a="); put(inv(a)); + printf("\n-a="); put(neg(a)); + printf("\nconj a="); put(conj(a)); printf("\n"); +} diff --git a/Task/Arithmetic-Complex/CoffeeScript/arithmetic-complex-1.coffee b/Task/Arithmetic-Complex/CoffeeScript/arithmetic-complex-1.coffee new file mode 100644 index 0000000000..66c7b3b817 --- /dev/null +++ b/Task/Arithmetic-Complex/CoffeeScript/arithmetic-complex-1.coffee @@ -0,0 +1,60 @@ +# create an immutable Complex type +class Complex + constructor: (@r=0, @i=0) -> + @magnitude = @r*@r + @i*@i + + plus: (c2) -> + new Complex( + @r + c2.r, + @i + c2.i + ) + + times: (c2) -> + new Complex( + @r*c2.r - @i*c2.i, + @r*c2.i + @i*c2.r + ) + + negation: -> + new Complex( + -1 * @r, + -1 * @i + ) + + inverse: -> + throw Error "no inverse" if @magnitude is 0 + new Complex( + @r / @magnitude, + -1 * @i / @magnitude + ) + + toString: -> + return "#{@r}" if @i == 0 + return "#{@i}i" if @r == 0 + if @i > 0 + "#{@r} + #{@i}i" + else + "#{@r} - #{-1 * @i}i" + +# test +do -> + a = new Complex(5, 3) + b = new Complex(4, -3) + + sum = a.plus b + console.log "(#{a}) + (#{b}) = #{sum}" + + product = a.times b + console.log "(#{a}) * (#{b}) = #{product}" + + negation = b.negation() + console.log "-1 * (#{b}) = #{negation}" + + diff = a.plus negation + console.log "(#{a}) - (#{b}) = #{diff}" + + inverse = b.inverse() + console.log "1 / (#{b}) = #{inverse}" + + quotient = product.times inverse + console.log "(#{product}) / (#{b}) = #{quotient}" diff --git a/Task/Arithmetic-Complex/CoffeeScript/arithmetic-complex-2.coffee b/Task/Arithmetic-Complex/CoffeeScript/arithmetic-complex-2.coffee new file mode 100644 index 0000000000..513321f60e --- /dev/null +++ b/Task/Arithmetic-Complex/CoffeeScript/arithmetic-complex-2.coffee @@ -0,0 +1,7 @@ +> coffee complex.coffee +(5 + 3i) + (4 - 3i) = 9 +(5 + 3i) * (4 - 3i) = 29 - 3i +-1 * (4 - 3i) = -4 + 3i +(5 + 3i) - (4 - 3i) = 1 + 6i +1 / (4 - 3i) = 0.16 + 0.12i +(29 - 3i) / (4 - 3i) = 5 + 3i diff --git a/Task/Arithmetic-Complex/Erlang/arithmetic-complex-1.erl b/Task/Arithmetic-Complex/Erlang/arithmetic-complex-1.erl new file mode 100644 index 0000000000..ec32e5972d --- /dev/null +++ b/Task/Arithmetic-Complex/Erlang/arithmetic-complex-1.erl @@ -0,0 +1,58 @@ +%% Task: Complex Arithmetic +%% Author: Abhay Jain + +-module(complex_number). +-export([calculate/0]). + +-record(complex, {real, img}). + +calculate() -> + A = #complex{real=1, img=3}, + B = #complex{real=5, img=2}, + + Sum = add (A, B), + print (Sum), + + Product = multiply (A, B), + print (Product), + + Negation = negation (A), + print (Negation), + + Inversion = inverse (A), + print (Inversion), + + Conjugate = conjugate (A), + print (Conjugate). + +add (A, B) -> + RealPart = A#complex.real + B#complex.real, + ImgPart = A#complex.img + B#complex.img, + #complex{real=RealPart, img=ImgPart}. + +multiply (A, B) -> + RealPart = (A#complex.real * B#complex.real) - (A#complex.img * B#complex.img), + ImgPart = (A#complex.real * B#complex.img) + (B#complex.real * A#complex.img), + #complex{real=RealPart, img=ImgPart}. + +negation (A) -> + #complex{real=-A#complex.real, img=-A#complex.img}. + +inverse (A) -> + C = conjugate (A), + Mod = (A#complex.real * A#complex.real) + (A#complex.img * A#complex.img), + RealPart = C#complex.real / Mod, + ImgPart = C#complex.img / Mod, + #complex{real=RealPart, img=ImgPart}. + +conjugate (A) -> + RealPart = A#complex.real, + ImgPart = -A#complex.img, + #complex{real=RealPart, img=ImgPart}. + +print (A) -> + if A#complex.img < 0 -> + io:format("Ans = ~p~pi~n", [A#complex.real, A#complex.img]); + true -> + io:format("Ans = ~p+~pi~n", [A#complex.real, A#complex.img]) + end. diff --git a/Task/Arithmetic-Complex/Erlang/arithmetic-complex-2.erl b/Task/Arithmetic-Complex/Erlang/arithmetic-complex-2.erl new file mode 100644 index 0000000000..f66671bb19 --- /dev/null +++ b/Task/Arithmetic-Complex/Erlang/arithmetic-complex-2.erl @@ -0,0 +1,5 @@ +Ans = 6+5i +Ans = -1+17i +Ans = -1-3i +Ans = 0.1-0.3i +Ans = 1-3i diff --git a/Task/Arithmetic-Complex/Forth/arithmetic-complex.fth b/Task/Arithmetic-Complex/Forth/arithmetic-complex.fth new file mode 100644 index 0000000000..b798ef6d83 --- /dev/null +++ b/Task/Arithmetic-Complex/Forth/arithmetic-complex.fth @@ -0,0 +1,13 @@ +include complex.seq + +: ZNEGATE ( r i -- -r -i ) fswap fnegate fswap fnegate ; + +zvariable x +zvariable y +1e 1e x z! +pi 1.2e y z! + +x z@ y z@ z+ z. +x z@ y z@ z* z. +1+0i x z@ z/ z. +x z@ znegate z. diff --git a/Task/Arithmetic-Complex/Fortran/arithmetic-complex-1.f b/Task/Arithmetic-Complex/Fortran/arithmetic-complex-1.f new file mode 100644 index 0000000000..e68c4f3fdd --- /dev/null +++ b/Task/Arithmetic-Complex/Fortran/arithmetic-complex-1.f @@ -0,0 +1,9 @@ +program cdemo + complex :: a = (5,3), b = (0.5, 6.0) ! complex initializer + complex :: absum, abprod, aneg, ainv + + absum = a + b + abprod = a * b + aneg = -a + ainv = 1.0 / a +end program cdemo diff --git a/Task/Arithmetic-Complex/Fortran/arithmetic-complex-2.f b/Task/Arithmetic-Complex/Fortran/arithmetic-complex-2.f new file mode 100644 index 0000000000..c4dd1a6208 --- /dev/null +++ b/Task/Arithmetic-Complex/Fortran/arithmetic-complex-2.f @@ -0,0 +1,28 @@ +program cdemo2 + complex :: a = (5,3), b = (0.5, 6) ! complex initializer + real, parameter :: pi = 3.141592653589793 ! The constant "pi" + complex, parameter :: i = (0, 1) ! the imaginary unit "i" (sqrt(-1)) + complex :: abdiff, abquot, abpow, aconj, p2cart, newc + real :: areal, aimag, anorm, rho = 10, theta = pi / 3.0, x = 2.3, y = 3.0 + integer, parameter :: n = 50 + integer :: j + complex, dimension(0:n-1) :: unit_circle + + abdiff = a - b + abquot = a / b + abpow = a ** b + areal = real(a) ! Real part + aimag = imag(a) ! Imaginary part + newc = cmplx(x,y) ! Creating a complex on the fly from two reals intrinsically + ! (initializer only works in declarations) + newc = x + y*i ! Creating a complex on the fly from two reals arithmetically + anorm = abs(a) ! Complex norm (or "modulus" or "absolute value") + ! (use CABS before Fortran 90) + aconj = conjg(a) ! Complex conjugate (same as real(a) - i*imag(a)) + p2cart = rho * exp(i * theta) ! Euler's polar complex notation to cartesian complex notation + ! conversion (use CEXP before Fortran 90) + + ! The following creates an array of N evenly spaced points around the complex unit circle + ! useful for FFT calculations, among other things + unit_circle = exp(2*i*pi/n * (/ (j, j=0, n-1) /) ) +end program cdemo2 diff --git a/Task/Arithmetic-Complex/Go/arithmetic-complex.go b/Task/Arithmetic-Complex/Go/arithmetic-complex.go new file mode 100644 index 0000000000..74a675f962 --- /dev/null +++ b/Task/Arithmetic-Complex/Go/arithmetic-complex.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "math/cmplx" +) + +func main() { + a := 1 + 1i + b := 3.14159 + 1.25i + fmt.Println("a: ", a) + fmt.Println("b: ", b) + fmt.Println("a + b: ", a+b) + fmt.Println("a * b: ", a*b) + fmt.Println("-a: ", -a) + fmt.Println("1 / a: ", 1/a) + fmt.Println("aΜ…: ", cmplx.Conj(a)) +} diff --git a/Task/Arithmetic-Complex/Haskell/arithmetic-complex-1.hs b/Task/Arithmetic-Complex/Haskell/arithmetic-complex-1.hs new file mode 100644 index 0000000000..3bcc29321b --- /dev/null +++ b/Task/Arithmetic-Complex/Haskell/arithmetic-complex-1.hs @@ -0,0 +1,14 @@ +import Data.Complex + +main = do + let a = 1.0 :+ 2.0 -- complex number 1+2i + let b = 4 -- complex number 4+0i + -- 'b' is inferred to be complex because it's used in + -- arithmetic with 'a' below. + putStrLn $ "Add: " ++ show (a + b) + putStrLn $ "Subtract: " ++ show (a - b) + putStrLn $ "Multiply: " ++ show (a * b) + putStrLn $ "Divide: " ++ show (a / b) + putStrLn $ "Negate: " ++ show (-a) + putStrLn $ "Inverse: " ++ show (recip a) + putStrLn $ "Conjugate:" ++ show (conjugate a) diff --git a/Task/Arithmetic-Complex/Haskell/arithmetic-complex-2.hs b/Task/Arithmetic-Complex/Haskell/arithmetic-complex-2.hs new file mode 100644 index 0000000000..5884ede83b --- /dev/null +++ b/Task/Arithmetic-Complex/Haskell/arithmetic-complex-2.hs @@ -0,0 +1,8 @@ +*Main> main +Add: 5.0 :+ 2.0 +Subtract: (-3.0) :+ 2.0 +Multiply: 4.0 :+ 8.0 +Divide: 0.25 :+ 0.5 +Negate: (-1.0) :+ (-2.0) +Inverse: 0.2 :+ (-0.4) +Conjugate:1.0 :+ (-2.0) diff --git a/Task/Arithmetic-Complex/Java/arithmetic-complex.java b/Task/Arithmetic-Complex/Java/arithmetic-complex.java new file mode 100644 index 0000000000..c2a2c925a6 --- /dev/null +++ b/Task/Arithmetic-Complex/Java/arithmetic-complex.java @@ -0,0 +1,44 @@ +public class Complex{ + public final double real; + public final double imag; + + public Complex(){this(0,0)}//default values to 0...force of habit + public Complex(double r, double i){real = r; imag = i;} + + public Complex add(Complex b){ + return new Complex(this.real + b.real, this.imag + b.imag); + } + + public Complex mult(Complex b){ + //FOIL of (a+bi)(c+di) with i*i = -1 + return new Complex(this.real * b.real - this.imag * b.imag, this.real * b.imag + this.imag * b.real); + } + + public Complex inv(){ + //1/(a+bi) * (a-bi)/(a-bi) = 1/(a+bi) but it's more workable + double denom = real * real + imag * imag; + return new Complex(real/denom,-imag/denom); + } + + public Complex neg(){ + return new Complex(-real, -imag); + } + + public Complex conj(){ + return new Complex(real, -imag); + } + + public String toString(){ //override Object's toString + return real + " + " + imag + " * i"; + } + + public static void main(String[] args){ + Complex a = new Complex(Math.PI, -5) //just some numbers + Complex b = new Complex(-1, 2.5); + System.out.println(a.neg()); + System.out.println(a.add(b)); + System.out.println(a.inv()); + System.out.println(a.mult(b)); + System.out.println(a.conj()); + } +} diff --git a/Task/Arithmetic-Complex/JavaScript/arithmetic-complex.js b/Task/Arithmetic-Complex/JavaScript/arithmetic-complex.js new file mode 100644 index 0000000000..2abcf2e642 --- /dev/null +++ b/Task/Arithmetic-Complex/JavaScript/arithmetic-complex.js @@ -0,0 +1,55 @@ +function Complex(r, i) { + this.r = r; + this.i = i; +} + +Complex.add = function() { + var num = arguments[0]; + + for(var i = 1, ilim = arguments.length; i < ilim; i += 1){ + num.r += arguments[i].r; + num.i += arguments[i].i; + } + + return num; +} + +Complex.multiply = function() { + var num = arguments[0]; + + for(var i = 1, ilim = arguments.length; i < ilim; i += 1){ + num.r = (num.r * arguments[i].r) - (num.i * arguments[i].i); + num.i = (num.i * arguments[i].r) - (num.r * arguments[i].i); + } + + return num; +} + +Complex.negate = function (z) { + return new Complex(-1*z.r, -1*z.i); +} + +Complex.invert = function(z) { + var denom = Math.pow(z.r,2) + Math.pow(z.i,2); + return new Complex(z.r/denom, -1*z.i/denom); +} + +Complex.conjugate = function(z) { + return new Complex(z.r, -1*z.i); +} + +// BONUSES! + + +Complex.prototype.toString = function() { + return this.r === 0 && this.i === 0 + ? "0" + : (this.r !== 0 ? this.r : "") + + ((this.r !== 0 || this.i < 0) && this.i !== 0 + ? (this.i > 0 ? "+" : "-") + : "" ) + ( this.i !== 0 ? Math.abs(this.i) + "i" : "" ); +} + +Complex.prototype.getMod = function() { + return Math.sqrt( Math.pow(this.r,2) , Math.pow(this.i,2) ) +} diff --git a/Task/Arithmetic-Complex/Lua/arithmetic-complex.lua b/Task/Arithmetic-Complex/Lua/arithmetic-complex.lua new file mode 100644 index 0000000000..8e359ace27 --- /dev/null +++ b/Task/Arithmetic-Complex/Lua/arithmetic-complex.lua @@ -0,0 +1,31 @@ +--defines addition, subtraction, negation, multiplication, division, conjugation, norms, and a conversion to strgs. +complex = setmetatable({ +__add = function(u, v) return complex(u.real + v.real, u.imag + v.imag) end, +__sub = function(u, v) return complex(u.real - v.real, u.imag - v.imag) end, +__mul = function(u, v) return complex(u.real * v.real - u.imag * v.imag, u.real * v.imag + u.imag * v.real) end, +__div = function(u, v) return u * complex(v.real / v.norm, -v.imag / v.norm) end, +__unm = function(u) return complex(-u.real, -u.imag) end, +__concat = function(u, v) + if type(u) == "table" then return u.real .. " + " .. u.imag .. "i" .. v + elseif type(u) == "string" or type(u) == "number" then return u .. v.real .. " + " .. v.imag .. "i" + end end, +__index = function(u, index) + local operations = { + norm = function(u) return u.real ^ 2 + u.imag ^ 2 end, + conj = function(u) return complex(u.real, -u.imag) end, + } + return operations[index] and operations[index](u) +end, +__newindex = function() error() end +}, { +__call = function(z, realpart, imagpart) return setmetatable({real = realpart, imag = imagpart}, complex) end +} ) + +local i, j = complex(2, 3), complex(1, 1) + +print(i .. " + " .. j .. " = " .. (i+j)) +print(i .. " - " .. j .. " = " .. (i-j)) +print(i .. " * " .. j .. " = " .. (i*j)) +print(i .. " / " .. j .. " = " .. (i/j)) +print("|" .. i .. "| = " .. math.sqrt(i.norm)) +print(i .. "* = " .. i.conj) diff --git a/Task/Arithmetic-Complex/Perl/arithmetic-complex.pl b/Task/Arithmetic-Complex/Perl/arithmetic-complex.pl new file mode 100644 index 0000000000..f5dc6f55e3 --- /dev/null +++ b/Task/Arithmetic-Complex/Perl/arithmetic-complex.pl @@ -0,0 +1,10 @@ +use Math::Complex; +my $a = 1 + 1*i; +my $b = 3.14159 + 1.25*i; + +print "$_\n" foreach + $a + $b, # addition + $a * $b, # multiplication + -$a, # negation + 1 / $a, # multiplicative inverse + ~$a; # complex conjugate diff --git a/Task/Arithmetic-Complex/PicoLisp/arithmetic-complex.l b/Task/Arithmetic-Complex/PicoLisp/arithmetic-complex.l new file mode 100644 index 0000000000..0f487f130a --- /dev/null +++ b/Task/Arithmetic-Complex/PicoLisp/arithmetic-complex.l @@ -0,0 +1,42 @@ +(load "@lib/math.l") + +(de addComplex (A B) + (cons + (+ (car A) (car B)) # Real + (+ (cdr A) (cdr B)) ) ) # Imag + +(de mulComplex (A B) + (cons + (- + (*/ (car A) (car B) 1.0) + (*/ (cdr A) (cdr B) 1.0) ) + (+ + (*/ (car A) (cdr B) 1.0) + (*/ (cdr A) (car B) 1.0) ) ) ) + +(de invComplex (A) + (let Denom + (+ + (*/ (car A) (car A) 1.0) + (*/ (cdr A) (cdr A) 1.0) ) + (cons + (*/ (car A) 1.0 Denom) + (- (*/ (cdr A) 1.0 Denom)) ) ) ) + +(de negComplex (A) + (cons (- (car A)) (- (cdr A))) ) + +(de fmtComplex (A) + (pack + (round (car A) (dec *Scl)) + (and (gt0 (cdr A)) "+") + (round (cdr A) (dec *Scl)) + "i" ) ) + +(let (A (1.0 . 1.0) B (cons pi 1.2)) + (prinl "A = " (fmtComplex A)) + (prinl "B = " (fmtComplex B)) + (prinl "A+B = " (fmtComplex (addComplex A B))) + (prinl "A*B = " (fmtComplex (mulComplex A B))) + (prinl "1/A = " (fmtComplex (invComplex A))) + (prinl "-A = " (fmtComplex (negComplex A))) ) diff --git a/Task/Arithmetic-Complex/Python/arithmetic-complex.py b/Task/Arithmetic-Complex/Python/arithmetic-complex.py new file mode 100644 index 0000000000..2ba9bf118f --- /dev/null +++ b/Task/Arithmetic-Complex/Python/arithmetic-complex.py @@ -0,0 +1,23 @@ +>>> z1 = 1.5 + 3j +>>> z2 = 1.5 + 1.5j +>>> z1 + z2 +(3+4.5j) +>>> z1 - z2 +1.5j +>>> z1 * z2 +(-2.25+6.75j) +>>> z1 / z2 +(1.5+0.5j) +>>> - z1 +(-1.5-3j) +>>> z1.conjugate() +(1.5-3j) +>>> abs(z1) +3.3541019662496847 +>>> z1 ** z2 +(-1.1024829553277784-0.38306415117199333j) +>>> z1.real +1.5 +>>> z1.imag +3.0 +>>> diff --git a/Task/Arithmetic-Complex/R/arithmetic-complex.r b/Task/Arithmetic-Complex/R/arithmetic-complex.r new file mode 100644 index 0000000000..daca9a3ee3 --- /dev/null +++ b/Task/Arithmetic-Complex/R/arithmetic-complex.r @@ -0,0 +1,13 @@ +z1 <- 1.5 + 3i +z2 <- 1.5 + 1.5i +print(z1 + z2) # 3+4.5i +print(z1 - z2) # 0+1.5i +print(z1 * z2) # -2.25+6.75i +print(z1 / z2) # 1.5+0.5i +print(-z1) # -1.5-3i +print(Conj(z1)) # 1.5-3i +print(abs(z1)) # 3.354102 +print(z1^z2) # -1.102483-0.383064i +print(exp(z1)) # -4.436839+0.632456i +print(Re(z1)) # 1.5 +print(Im(z1)) # 3 diff --git a/Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx b/Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx new file mode 100644 index 0000000000..1a58d71a92 --- /dev/null +++ b/Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx @@ -0,0 +1,25 @@ +/*REXX program to show how to support math functions for complex numbers*/ + +x = '(5,3i)' /*this little piggy uses "I" (or "i") ... */ +y = '( .5, 6j)' /*this little piggy uses "J" (or "j") ... */ + +sum = Cadd(x,y); say ' addition: ' x " + " y ' = ' sum +dif = Csub(x,y); say ' subtration: ' x " + " y ' = ' dif +prod = Cmul(x,y); say 'multiplication: ' x " * " y ' = ' prod +quot = Cdiv(x,y); say ' division: ' x " Γ· " y ' = ' quot +inv = Cinv(x); say ' inverse: ' x " = " inv +cnjX = Ccnj(x); say ' conjugate of: ' x " = " cnjX +negX = Cneg(x); say ' negation of: ' x " = " negX +exit /*stick a fork in it, we're done.*/ + +/*─────────────────────────────────────one─liners───────────────────────*/ +Ccnj: procedure;arg a ',' b,c ',' d;call Cg;r1=a;r2=-b;return Cr() +Cadd: procedure;arg a ',' b,c ',' d;call Cg;r1=a+c;r2=b+d;return Cr() +Csub: procedure;arg a ',' b,c ',' d;call Cg;r1=a-c;r2=b-d;return Cr() +Cmul: procedure;arg a ',' b,c ',' d;call Cg;r1=a*c-b*d; r2=b*c+a*d;return Cr() +Cdiv: procedure;arg a ',' b,c ',' d;call Cg;_=c*c+d*d;r1=(a*c+b*d)/_;r2=(b*c-a*d)/_;return Cr() +Cg: a=Cdej(a); b=Cdej(b); c=Cdej(c); d=Cdej(d); return +Cr: _='['r1; if r2\=0 then _=_','r2"j"; return _']' +Cdej: return word(translate(arg(1),,'{[(JI)]}') 0,1) +Cneg: return Cmul(arg(1),-1) +Cinv: return Cdiv(1,arg(1)) diff --git a/Task/Arithmetic-Complex/Racket/arithmetic-complex.rkt b/Task/Arithmetic-Complex/Racket/arithmetic-complex.rkt new file mode 100644 index 0000000000..66ef2d6ddc --- /dev/null +++ b/Task/Arithmetic-Complex/Racket/arithmetic-complex.rkt @@ -0,0 +1,12 @@ +#lang racket + +(define a 3+4i) +(define b 8+0i) + +(+ a b) ; addition +(- a b) ; subtraction +(/ a b) ; division +(* a b) ; multiplication +(- a) ; negation +(/ 1 a) ; reciprocal +(conjugate a) ; conjugation diff --git a/Task/Arithmetic-Complex/Ruby/arithmetic-complex-1.rb b/Task/Arithmetic-Complex/Ruby/arithmetic-complex-1.rb new file mode 100644 index 0000000000..a93f2e026f --- /dev/null +++ b/Task/Arithmetic-Complex/Ruby/arithmetic-complex-1.rb @@ -0,0 +1,14 @@ +require 'complex' # With Ruby 1.9, this line is optional. + +# Two ways to write complex numbers: +a = Complex(1, 1) # 1. call Kernel#Complex +i = Complex::I # 2. use Complex::I +b = 3.14159 + 1.25 * i + +# Operations: +puts a + b # addition +puts a * b # multiplication +puts -a # negation +puts 1.quo a # multiplicative inverse +puts a.conjugate # complex conjugate +puts a.conj # alias for complex conjugate diff --git a/Task/Arithmetic-Complex/Ruby/arithmetic-complex-2.rb b/Task/Arithmetic-Complex/Ruby/arithmetic-complex-2.rb new file mode 100644 index 0000000000..da7ff00567 --- /dev/null +++ b/Task/Arithmetic-Complex/Ruby/arithmetic-complex-2.rb @@ -0,0 +1,4 @@ +# Other ways to find the multiplicative inverse: +puts 1.quo a # always works +puts 1.0 / a # works, but forces floating-point math +puts 1 / a # might truncate to integer diff --git a/Task/Arithmetic-Complex/Scala/arithmetic-complex-1.scala b/Task/Arithmetic-Complex/Scala/arithmetic-complex-1.scala new file mode 100644 index 0000000000..4c2696e678 --- /dev/null +++ b/Task/Arithmetic-Complex/Scala/arithmetic-complex-1.scala @@ -0,0 +1,35 @@ +package org.rosettacode + +package object ArithmeticComplex { + val i = Complex(0, 1) + + implicit def fromDouble(d: Double) = Complex(d) + implicit def fromInt(i: Int) = Complex(i.toDouble) +} + +package ArithmeticComplex { + case class Complex(real: Double = 0.0, imag: Double = 0.0) { + def this(s: String) = + this("[\\d.]+(?!i)".r findFirstIn s getOrElse "0" toDouble, + "[\\d.]+(?=i)".r findFirstIn s getOrElse "0" toDouble) + + def +(b: Complex) = Complex(real + b.real, imag + b.imag) + def -(b: Complex) = Complex(real - b.real, imag - b.imag) + def *(b: Complex) = Complex(real * b.real - imag * b.imag, real * b.imag + imag * b.real) + def inverse = { + val denom = real * real + imag * imag + Complex(real / denom, -imag / denom) + } + def /(b: Complex) = this * b.inverse + def unary_- = Complex(-real, -imag) + lazy val abs = math.hypot(real, imag) + override def toString = real + " + " + imag + "i" + + def i = { require(imag == 0.0); Complex(imag = real) } + } + + object Complex { + def apply(s: String) = new Complex(s) + def fromPolar(rho:Double, theta:Double) = Complex(rho*math.cos(theta), rho*math.sin(theta)) + } +} diff --git a/Task/Arithmetic-Complex/Scala/arithmetic-complex-2.scala b/Task/Arithmetic-Complex/Scala/arithmetic-complex-2.scala new file mode 100644 index 0000000000..35a89a1eeb --- /dev/null +++ b/Task/Arithmetic-Complex/Scala/arithmetic-complex-2.scala @@ -0,0 +1,26 @@ +scala> import org.rosettacode.ArithmeticComplex._ +import org.rosettacode.ArithmeticComplex._ + +scala> 1 + i +res0: org.rosettacode.ArithmeticComplex.Complex = 1.0 + 1.0i + +scala> 1 + 2 * i +res1: org.rosettacode.ArithmeticComplex.Complex = 1.0 + 2.0i + +scala> 2 + 1.i +res2: org.rosettacode.ArithmeticComplex.Complex = 2.0 + 1.0i + +scala> res0 + res1 +res3: org.rosettacode.ArithmeticComplex.Complex = 2.0 + 3.0i + +scala> res1 * res2 +res4: org.rosettacode.ArithmeticComplex.Complex = 0.0 + 5.0i + +scala> res2 / res0 +res5: org.rosettacode.ArithmeticComplex.Complex = 1.5 + -0.5i + +scala> res1.inverse +res6: org.rosettacode.ArithmeticComplex.Complex = 0.2 + -0.4i + +scala> -res6 +res7: org.rosettacode.ArithmeticComplex.Complex = -0.2 + 0.4i diff --git a/Task/Arithmetic-Complex/Scheme/arithmetic-complex.ss b/Task/Arithmetic-Complex/Scheme/arithmetic-complex.ss new file mode 100644 index 0000000000..3a8dcfb600 --- /dev/null +++ b/Task/Arithmetic-Complex/Scheme/arithmetic-complex.ss @@ -0,0 +1,7 @@ +(define a 1+i) +(define b 3.14159+1.25i) + +(define c (+ a b)) +(define c (* a b)) +(define c (/ 1 a)) +(define c (- a)) diff --git a/Task/Arithmetic-Complex/Smalltalk/arithmetic-complex.st b/Task/Arithmetic-Complex/Smalltalk/arithmetic-complex.st new file mode 100644 index 0000000000..0252a9aa54 --- /dev/null +++ b/Task/Arithmetic-Complex/Smalltalk/arithmetic-complex.st @@ -0,0 +1,13 @@ +PackageLoader fileInPackage: 'Complex'. +|a b| +a := 1 + 1 i. +b := 3.14159 + 1.2 i. +(a + b) displayNl. +(a * b) displayNl. +(a / b) displayNl. +a reciprocal displayNl. +a conjugate displayNl. +a abs displayNl. +a real displayNl. +a imaginary displayNl. +a negated displayNl. diff --git a/Task/Arithmetic-Complex/Tcl/arithmetic-complex.tcl b/Task/Arithmetic-Complex/Tcl/arithmetic-complex.tcl new file mode 100644 index 0000000000..5beba1defd --- /dev/null +++ b/Task/Arithmetic-Complex/Tcl/arithmetic-complex.tcl @@ -0,0 +1,9 @@ +package require math::complexnumbers +namespace import math::complexnumbers::* + +set a [complex 1 1] +set b [complex 3.14159 1.2] +puts [tostring [+ $a $b]] ;# ==> 4.14159+2.2i +puts [tostring [* $a $b]] ;# ==> 1.94159+4.34159i +puts [tostring [pow $a [complex -1 0]]] ;# ==> 0.5-0.4999999999999999i +puts [tostring [- $a]] ;# ==> -1.0-i diff --git a/Task/Arithmetic-Rational/0DESCRIPTION b/Task/Arithmetic-Rational/0DESCRIPTION new file mode 100644 index 0000000000..8937bfbe2e --- /dev/null +++ b/Task/Arithmetic-Rational/0DESCRIPTION @@ -0,0 +1,16 @@ +The objective of this task is to create a reasonably complete implementation of rational arithmetic in the particular language using the idioms of the language. + +For example: +Define a new type called '''frac''' with binary operator "//" of two integers that returns a '''structure''' made up of the numerator and the denominator (as per a rational number). + +Further define the appropriate rational unary '''operators''' '''abs''' and '-', with the binary '''operators''' for addition '+', subtraction '-', multiplication '×', division '/', integer division '÷', modulo division, the comparison operators (e.g. '<', '≤', '>', & '≥') and equality operators (e.g. '=' & '≠'). + +Define standard coercion '''operators''' for casting '''int''' to '''frac''' etc. + +If space allows, define standard increment and decrement '''operators''' (e.g. '+:=' & '-:=' etc.). + +Finally test the operators: +Use the new type '''frac''' to find all [[Perfect Numbers|perfect numbers]] less than 219 by summing the reciprocal of the factors. + +'''See also''' +* [[Perfect Numbers]] diff --git a/Task/Arithmetic-Rational/1META.yaml b/Task/Arithmetic-Rational/1META.yaml new file mode 100644 index 0000000000..15104c6b92 --- /dev/null +++ b/Task/Arithmetic-Rational/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Arithmetic +note: Arithmetic operations diff --git a/Task/Arithmetic-Rational/ALGOL-68/arithmetic-rational.alg b/Task/Arithmetic-Rational/ALGOL-68/arithmetic-rational.alg new file mode 100644 index 0000000000..6574f1f2e5 --- /dev/null +++ b/Task/Arithmetic-Rational/ALGOL-68/arithmetic-rational.alg @@ -0,0 +1,131 @@ + MODE FRAC = STRUCT( INT num #erator#, den #ominator#); + FORMAT frac repr = $g(-0)"//"g(-0)$; + + PROC gcd = (INT a, b) INT: # greatest common divisor # + (a = 0 | b |: b = 0 | a |: ABS a > ABS b | gcd(b, a MOD b) | gcd(a, b MOD a)); + + PROC lcm = (INT a, b)INT: # least common multiple # + a OVER gcd(a, b) * b; + + PROC raise not implemented error = ([]STRING args)VOID: ( + put(stand error, ("Not implemented error: ",args, newline)); + stop + ); + + PRIO // = 9; # higher then the ** operator # + OP // = (INT num, den)FRAC: ( # initialise and normalise # + INT common = gcd(num, den); + IF den < 0 THEN + ( -num OVER common, -den OVER common) + ELSE + ( num OVER common, den OVER common) + FI + ); + + OP + = (FRAC a, b)FRAC: ( + INT common = lcm(den OF a, den OF b); + FRAC result := ( common OVER den OF a * num OF a + common OVER den OF b * num OF b, common ); + num OF result//den OF result + ); + + OP - = (FRAC a, b)FRAC: a + -b, + * = (FRAC a, b)FRAC: ( + INT num = num OF a * num OF b, + den = den OF a * den OF b; + INT common = gcd(num, den); + (num OVER common) // (den OVER common) + ); + + OP / = (FRAC a, b)FRAC: a * FRAC(den OF b, num OF b),# real division # + % = (FRAC a, b)INT: ENTIER (a / b), # integer divison # + %* = (FRAC a, b)FRAC: a/b - FRACINIT ENTIER (a/b), # modulo division # + ** = (FRAC a, INT exponent)FRAC: + IF exponent >= 0 THEN + (num OF a ** exponent, den OF a ** exponent ) + ELSE + (den OF a ** exponent, num OF a ** exponent ) + FI; + + OP REALINIT = (FRAC frac)REAL: num OF frac / den OF frac, + FRACINIT = (INT num)FRAC: num // 1, + FRACINIT = (REAL num)FRAC: ( + # express real number as a fraction # # a future execise! # + raise not implemented error(("Convert a REAL to a FRAC","!")); + SKIP + ); + + OP < = (FRAC a, b)BOOL: num OF (a - b) < 0, + > = (FRAC a, b)BOOL: num OF (a - b) > 0, + <= = (FRAC a, b)BOOL: NOT ( a > b ), + >= = (FRAC a, b)BOOL: NOT ( a < b ), + = = (FRAC a, b)BOOL: (num OF a, den OF a) = (num OF b, den OF b), + /= = (FRAC a, b)BOOL: (num OF a, den OF a) /= (num OF b, den OF b); + + # Unary operators # + OP - = (FRAC frac)FRAC: (-num OF frac, den OF frac), + ABS = (FRAC frac)FRAC: (ABS num OF frac, ABS den OF frac), + ENTIER = (FRAC frac)INT: (num OF frac OVER den OF frac) * den OF frac; + + COMMENT Operators for extended characters set, and increment/decrement: + OP +:= = (REF FRAC a, FRAC b)REF FRAC: ( a := a + b ), + +=: = (FRAC a, REF FRAC b)REF FRAC: ( b := a + b ), + -:= = (REF FRAC a, FRAC b)REF FRAC: ( a := a - b ), + *:= = (REF FRAC a, FRAC b)REF FRAC: ( a := a * b ), + /:= = (REF FRAC a, FRAC b)REF FRAC: ( a := a / b ), + %:= = (REF FRAC a, FRAC b)REF FRAC: ( a := FRACINIT (a % b) ), + %*:= = (REF FRAC a, FRAC b)REF FRAC: ( a := a %* b ); + + # OP aliases for extended character sets (eg: Unicode, APL, ALCOR and GOST 10859) # + OP Γ— = (FRAC a, b)FRAC: a * b, + Γ· = (FRAC a, b)INT: a OVER b, + Γ·Γ— = (FRAC a, b)FRAC: a MOD b, + Γ·* = (FRAC a, b)FRAC: a MOD b, + %Γ— = (FRAC a, b)FRAC: a MOD b, + ≀ = (FRAC a, b)FRAC: a <= b, + β‰₯ = (FRAC a, b)FRAC: a >= b, + β‰  = (FRAC a, b)BOOL: a /= b, + ↑ = (FRAC frac, INT exponent)FRAC: frac ** exponent, + + Γ·Γ—:= = (REF FRAC a, FRAC b)REF FRAC: ( a := a MOD b ), + %Γ—:= = (REF FRAC a, FRAC b)REF FRAC: ( a := a MOD b ), + Γ·*:= = (REF FRAC a, FRAC b)REF FRAC: ( a := a MOD b ); + + # BOLD aliases for CPU that only support uppercase for 6-bit bytes - wrist watches # + OP OVER = (FRAC a, b)INT: a % b, + MOD = (FRAC a, b)FRAC: a %*b, + LT = (FRAC a, b)BOOL: a < b, + GT = (FRAC a, b)BOOL: a > b, + LE = (FRAC a, b)BOOL: a <= b, + GE = (FRAC a, b)BOOL: a >= b, + EQ = (FRAC a, b)BOOL: a = b, + NE = (FRAC a, b)BOOL: a /= b, + UP = (FRAC frac, INT exponent)FRAC: frac**exponent; + + # the required standard assignment operators # + OP PLUSAB = (REF FRAC a, FRAC b)REF FRAC: ( a +:= b ), # PLUS # + PLUSTO = (FRAC a, REF FRAC b)REF FRAC: ( a +=: b ), # PRUS # + MINUSAB = (REF FRAC a, FRAC b)REF FRAC: ( a *:= b ), + DIVAB = (REF FRAC a, FRAC b)REF FRAC: ( a /:= b ), + OVERAB = (REF FRAC a, FRAC b)REF FRAC: ( a %:= b ), + MODAB = (REF FRAC a, FRAC b)REF FRAC: ( a %*:= b ); + +END COMMENT +Example: searching for Perfect Numbers. + FRAC sum:= FRACINIT 0; + FORMAT perfect = $b(" perfect!","")$; + + FOR i FROM 2 TO 2**19 DO + INT candidate := i; + FRAC sum := 1 // candidate; + REAL real sum := 1 / candidate; + FOR factor FROM 2 TO ENTIER sqrt(candidate) DO + IF candidate MOD factor = 0 THEN + sum := sum + 1 // factor + 1 // ( candidate OVER factor); + real sum +:= 1 / factor + 1 / ( candidate OVER factor) + FI + OD; + IF den OF sum = 1 THEN + printf(($"Sum of reciprocal factors of "g(-0)" = "g(-0)" exactly, about "g(0,real width) f(perfect)l$, + candidate, ENTIER sum, real sum, ENTIER sum = 1)) + FI + OD diff --git a/Task/Arithmetic-Rational/C/arithmetic-rational.c b/Task/Arithmetic-Rational/C/arithmetic-rational.c new file mode 100644 index 0000000000..742cc06284 --- /dev/null +++ b/Task/Arithmetic-Rational/C/arithmetic-rational.c @@ -0,0 +1,69 @@ +#include +#include +#define FMT "%lld" +typedef long long int fr_int_t; +typedef struct { fr_int_t num, den; } frac; + +fr_int_t gcd(fr_int_t m, fr_int_t n) +{ + fr_int_t t; + while (n) { t = n; n = m % n; m = t; } + return m; +} + +frac frac_new(fr_int_t num, fr_int_t den) +{ + frac a; + if (!den) { + printf("divide by zero: "FMT"/"FMT"\n", num, den); + abort(); + } + + int g = gcd(num, den); + + if (g) { num /= g; den /= g; } + else { num = 0; den = 1; } + + if (den < 0) { + den = -den; + num = -num; + } + a.num = num; a.den = den; + return a; +} + +#define BINOP(op, n, d) frac frac_##op(frac a, frac b) { return frac_new(n,d); } +BINOP(add, a.num * b.den + b.num * a.den, a.den * b.den); +BINOP(sub, a.num * b.den - b.num + a.den, a.den * b.den); +BINOP(mul, a.num * b.num, a.den * b.den); +BINOP(div, a.num * b.den, a.den * b.num); + +int frac_cmp(frac a, frac b) { + int l = a.num * b.den, r = a.den * b.num; + return l < r ? -1 : l > r; +} +#define frac_cmp_int(a, b) frac_cmp(a, frac_new(b, 1)) +int frtoi(frac a) { return a.den / a.num; } +double frtod(frac a) { return (double)a.den / a.num; } + +int main() +{ + int n, k; + frac sum, kf; + + for (n = 2; n < 1<<19; n++) { + sum = frac_new(1, n); + + for (k = 2; k * k < n; k++) { + if (n % k) continue; + kf = frac_new(1, k); + sum = frac_add(sum, kf); + + kf = frac_new(1, n / k); + sum = frac_add(sum, kf); + } + if (frac_cmp_int(sum, 1) == 0) printf("%d\n", n); + } + + return 0; +} diff --git a/Task/Arithmetic-Rational/Clojure/arithmetic-rational.clj b/Task/Arithmetic-Rational/Clojure/arithmetic-rational.clj new file mode 100644 index 0000000000..32a2578541 --- /dev/null +++ b/Task/Arithmetic-Rational/Clojure/arithmetic-rational.clj @@ -0,0 +1,6 @@ +user> 22/7 +22/7 +user> 34/2 +17 +user> (+ 37/5 42/9) +181/15 diff --git a/Task/Arithmetic-Rational/Forth/arithmetic-rational.fth b/Task/Arithmetic-Rational/Forth/arithmetic-rational.fth new file mode 100644 index 0000000000..65b461f2a5 --- /dev/null +++ b/Task/Arithmetic-Rational/Forth/arithmetic-rational.fth @@ -0,0 +1,38 @@ +\ Rationals can use any double cell operations: 2!, 2@, 2dup, 2swap, etc. +\ Uses the stack convention of the built-in "*/" for int * frac -> int + +: numerator drop ; +: denominator nip ; + +: s>rat 1 ; \ integer to rational (n/1) +: rat>s / ; \ integer +: rat>frac mod ; \ fractional part +: rat>float swap s>f s>f f/ ; + +: rat. swap 1 .r [char] / emit . ; + +\ normalize: factors out gcd and puts sign into numerator +: gcd ( a b -- gcd ) begin ?dup while tuck mod repeat ; +: rat-normalize ( rat -- rat ) 2dup gcd tuck / >r / r> ; + +: rat-abs swap abs swap ; +: rat-negate swap negate swap ; +: 1/rat over 0< if negate swap negate else swap then ; + +: rat+ ( a b c d -- ad+bc bd ) + rot 2dup * >r + rot * >r * r> + + r> rat-normalize ; +: rat- rat-negate rat+ ; + +: rat* ( a b c d -- ac bd ) + rot * >r * r> rat-normalize ; +: rat/ swap rat* ; + +: rat-equal d= ; +: rat-less ( a b c d -- adr * r> < ; +: rat-more 2swap rat-less ; + +: rat-inc tuck + swap ; +: rat-dec tuck - swap ; diff --git a/Task/Arithmetic-Rational/Fortran/arithmetic-rational-1.f b/Task/Arithmetic-Rational/Fortran/arithmetic-rational-1.f new file mode 100644 index 0000000000..6d825d7bba --- /dev/null +++ b/Task/Arithmetic-Rational/Fortran/arithmetic-rational-1.f @@ -0,0 +1,236 @@ +module module_rational + + implicit none + private + public :: rational + public :: rational_simplify + public :: assignment (=) + public :: operator (//) + public :: operator (+) + public :: operator (-) + public :: operator (*) + public :: operator (/) + public :: operator (<) + public :: operator (<=) + public :: operator (>) + public :: operator (>=) + public :: operator (==) + public :: operator (/=) + public :: abs + public :: int + public :: modulo + type rational + integer :: numerator + integer :: denominator + end type rational + interface assignment (=) + module procedure assign_rational_int, assign_rational_real + end interface + interface operator (//) + module procedure make_rational + end interface + interface operator (+) + module procedure rational_add + end interface + interface operator (-) + module procedure rational_minus, rational_subtract + end interface + interface operator (*) + module procedure rational_multiply + end interface + interface operator (/) + module procedure rational_divide + end interface + interface operator (<) + module procedure rational_lt + end interface + interface operator (<=) + module procedure rational_le + end interface + interface operator (>) + module procedure rational_gt + end interface + interface operator (>=) + module procedure rational_ge + end interface + interface operator (==) + module procedure rational_eq + end interface + interface operator (/=) + module procedure rational_ne + end interface + interface abs + module procedure rational_abs + end interface + interface int + module procedure rational_int + end interface + interface modulo + module procedure rational_modulo + end interface + +contains + + recursive function gcd (i, j) result (res) + integer, intent (in) :: i + integer, intent (in) :: j + integer :: res + if (j == 0) then + res = i + else + res = gcd (j, modulo (i, j)) + end if + end function gcd + + function rational_simplify (r) result (res) + type (rational), intent (in) :: r + type (rational) :: res + integer :: g + g = gcd (r % numerator, r % denominator) + res = r % numerator / g // r % denominator / g + end function rational_simplify + + function make_rational (numerator, denominator) result (res) + integer, intent (in) :: numerator + integer, intent (in) :: denominator + type (rational) :: res + res = rational (numerator, denominator) + end function make_rational + + subroutine assign_rational_int (res, i) + type (rational), intent (out), volatile :: res + integer, intent (in) :: i + res = i // 1 + end subroutine assign_rational_int + + subroutine assign_rational_real (res, x) + type (rational), intent(out), volatile :: res + real, intent (in) :: x + integer :: x_floor + real :: x_frac + x_floor = floor (x) + x_frac = x - x_floor + if (x_frac == 0) then + res = x_floor // 1 + else + res = (x_floor // 1) + (1 // floor (1 / x_frac)) + end if + end subroutine assign_rational_real + + function rational_add (r, s) result (res) + type (rational), intent (in) :: r + type (rational), intent (in) :: s + type (rational) :: res + res = r % numerator * s % denominator + r % denominator * s % numerator // & + & r % denominator * s % denominator + end function rational_add + + function rational_minus (r) result (res) + type (rational), intent (in) :: r + type (rational) :: res + res = - r % numerator // r % denominator + end function rational_minus + + function rational_subtract (r, s) result (res) + type (rational), intent (in) :: r + type (rational), intent (in) :: s + type (rational) :: res + res = r % numerator * s % denominator - r % denominator * s % numerator // & + & r % denominator * s % denominator + end function rational_subtract + + function rational_multiply (r, s) result (res) + type (rational), intent (in) :: r + type (rational), intent (in) :: s + type (rational) :: res + res = r % numerator * s % numerator // r % denominator * s % denominator + end function rational_multiply + + function rational_divide (r, s) result (res) + type (rational), intent (in) :: r + type (rational), intent (in) :: s + type (rational) :: res + res = r % numerator * s % denominator // r % denominator * s % numerator + end function rational_divide + + function rational_lt (r, s) result (res) + type (rational), intent (in) :: r + type (rational), intent (in) :: s + type (rational) :: r_simple + type (rational) :: s_simple + logical :: res + r_simple = rational_simplify (r) + s_simple = rational_simplify (s) + res = r_simple % numerator * s_simple % denominator < & + & s_simple % numerator * r_simple % denominator + end function rational_lt + + function rational_le (r, s) result (res) + type (rational), intent (in) :: r + type (rational), intent (in) :: s + type (rational) :: r_simple + type (rational) :: s_simple + logical :: res + r_simple = rational_simplify (r) + s_simple = rational_simplify (s) + res = r_simple % numerator * s_simple % denominator <= & + & s_simple % numerator * r_simple % denominator + end function rational_le + + function rational_gt (r, s) result (res) + type (rational), intent (in) :: r + type (rational), intent (in) :: s + type (rational) :: r_simple + type (rational) :: s_simple + logical :: res + r_simple = rational_simplify (r) + s_simple = rational_simplify (s) + res = r_simple % numerator * s_simple % denominator > & + & s_simple % numerator * r_simple % denominator + end function rational_gt + + function rational_ge (r, s) result (res) + type (rational), intent (in) :: r + type (rational), intent (in) :: s + type (rational) :: r_simple + type (rational) :: s_simple + logical :: res + r_simple = rational_simplify (r) + s_simple = rational_simplify (s) + res = r_simple % numerator * s_simple % denominator >= & + & s_simple % numerator * r_simple % denominator + end function rational_ge + + function rational_eq (r, s) result (res) + type (rational), intent (in) :: r + type (rational), intent (in) :: s + logical :: res + res = r % numerator * s % denominator == s % numerator * r % denominator + end function rational_eq + + function rational_ne (r, s) result (res) + type (rational), intent (in) :: r + type (rational), intent (in) :: s + logical :: res + res = r % numerator * s % denominator /= s % numerator * r % denominator + end function rational_ne + + function rational_abs (r) result (res) + type (rational), intent (in) :: r + type (rational) :: res + res = sign (r % numerator, r % denominator) // r % denominator + end function rational_abs + + function rational_int (r) result (res) + type (rational), intent (in) :: r + integer :: res + res = r % numerator / r % denominator + end function rational_int + + function rational_modulo (r) result (res) + type (rational), intent (in) :: r + integer :: res + res = modulo (r % numerator, r % denominator) + end function rational_modulo + +end module module_rational diff --git a/Task/Arithmetic-Rational/Fortran/arithmetic-rational-2.f b/Task/Arithmetic-Rational/Fortran/arithmetic-rational-2.f new file mode 100644 index 0000000000..a88c7830a9 --- /dev/null +++ b/Task/Arithmetic-Rational/Fortran/arithmetic-rational-2.f @@ -0,0 +1,28 @@ +program perfect_numbers + + use module_rational + implicit none + integer, parameter :: n_min = 2 + integer, parameter :: n_max = 2 ** 19 - 1 + integer :: n + integer :: factor + type (rational) :: sum + + do n = n_min, n_max + sum = 1 // n + factor = 2 + do + if (factor * factor >= n) then + exit + end if + if (modulo (n, factor) == 0) then + sum = rational_simplify (sum + (1 // factor) + (factor // n)) + end if + factor = factor + 1 + end do + if (sum % numerator == 1 .and. sum % denominator == 1) then + write (*, '(i0)') n + end if + end do + +end program perfect_numbers diff --git a/Task/Arithmetic-Rational/Go/arithmetic-rational.go b/Task/Arithmetic-Rational/Go/arithmetic-rational.go new file mode 100644 index 0000000000..bdd51e881e --- /dev/null +++ b/Task/Arithmetic-Rational/Go/arithmetic-rational.go @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "math" + "math/big" +) + +func main() { + var recip big.Rat + max := int64(1 << 19) + for candidate := int64(2); candidate < max; candidate++ { + sum := big.NewRat(1, candidate) + max2 := int64(math.Sqrt(float64(candidate))) + for factor := int64(2); factor <= max2; factor++ { + if candidate%factor == 0 { + sum.Add(sum, recip.SetFrac64(1, factor)) + if f2 := candidate / factor; f2 != factor { + sum.Add(sum, recip.SetFrac64(1, f2)) + } + } + } + if sum.Denom().Int64() == 1 { + perfectstring := "" + if sum.Num().Int64() == 1 { + perfectstring = "perfect!" + } + fmt.Printf("Sum of recipr. factors of %d = %d exactly %s\n", + candidate, sum.Num().Int64(), perfectstring) + } + } +} diff --git a/Task/Arithmetic-Rational/Haskell/arithmetic-rational.hs b/Task/Arithmetic-Rational/Haskell/arithmetic-rational.hs new file mode 100644 index 0000000000..480c161c7e --- /dev/null +++ b/Task/Arithmetic-Rational/Haskell/arithmetic-rational.hs @@ -0,0 +1,10 @@ +import Data.Ratio + +-- simply prints all the perfect numbers +main = mapM_ print [candidate + | candidate <- [2 .. 2^19], + getSum candidate == 1] + where getSum candidate = 1 % candidate + + sum [1 % factor + 1 % (candidate `div` factor) + | factor <- [2 .. floor(sqrt(fromIntegral(candidate)))], + candidate `mod` factor == 0] diff --git a/Task/Arithmetic-Rational/Java/arithmetic-rational.java b/Task/Arithmetic-Rational/Java/arithmetic-rational.java new file mode 100644 index 0000000000..20d96a68a8 --- /dev/null +++ b/Task/Arithmetic-Rational/Java/arithmetic-rational.java @@ -0,0 +1,30 @@ +class BigRationalFindPerfectNumbers { + public static void main(String[] args) { + System.out.println("Running BigRational built-in tests"); + if (BigRational.testFeatures()) { + int MAX_NUM = (1 << 19); + System.out.println(); + System.out.println("Searching for perfect numbers in the range [1, " + (MAX_NUM - 1) + "]"); + BigRational TWO = BigRational.valueOf(2); + for (int i = 1; i < MAX_NUM; i++) { + BigRational reciprocalSum = BigRational.ONE; + if (i > 1) + reciprocalSum = reciprocalSum.add(BigRational.valueOf(i).reciprocal()); + int maxDivisor = (int)Math.sqrt(i); + if (maxDivisor >= i) + maxDivisor--; + for (int divisor = 2; divisor <= maxDivisor; divisor++) { + if ((i % divisor) == 0) { + reciprocalSum = reciprocalSum.add(BigRational.valueOf(divisor).reciprocal()); + int dividend = i / divisor; + if (divisor != dividend) + reciprocalSum = reciprocalSum.add(BigRational.valueOf(dividend).reciprocal()); + } + } + if (reciprocalSum.equals(TWO)) + System.out.println(String.valueOf(i) + " is a perfect number"); + } + } + return; + } +} diff --git a/Task/Arithmetic-Rational/Lua/arithmetic-rational.lua b/Task/Arithmetic-Rational/Lua/arithmetic-rational.lua new file mode 100644 index 0000000000..6068c82546 --- /dev/null +++ b/Task/Arithmetic-Rational/Lua/arithmetic-rational.lua @@ -0,0 +1,58 @@ +function gcd(a,b) return a == 0 and b or gcd(b % a, a) end + +do + local function coerce(a, b) + if type(a) == "number" then return rational(a, 1), b end + if type(b) == "number" then return a, rational(b, 1) end + return a, b + end + rational = setmetatable({ + __add = function(a, b) + local a, b = coerce(a, b) + return rational(a.num * b.den + a.den * b.num, a.den * b.den) + end, + __sub = function(a, b) + local a, b = coerce(a, b) + return rational(a.num * b.den - a.den * b.num, a.den * b.den) + end, + __mul = function(a, b) + local a, b = coerce(a, b) + return rational(a.num * b.num, a.den * b.den) + end, + __div = function(a, b) + local a, b = coerce(a, b) + return rational(a.num * b.den, a.den * b.num) + end, + __pow = function(a, b) + if type(a) == "number" then return a ^ (b.num / b.den) end + return rational(a.num ^ b, a.den ^ b) --runs into a problem if these aren't integers + end, + __concat = function(a, b) + if getmetatable(a) == rational then return a.num .. "/" .. a.den .. b end + return a .. b.num .. "/" .. b.den + end, + __unm = function(a) return rational(-a.num, -a.den) end}, { + __call = function(z, a, b) return setmetatable({num = a / gcd(a, b),den = b / gcd(a, b)}, z) end} ) +end + +print(rational(2, 3) + rational(3, 5) - rational(1, 10) .. "") --> 7/6 +print((rational(4, 5) * rational(5, 9)) ^ rational(1, 2) .. "") --> 2/3 +print(rational(45, 60) / rational(5, 2) .. "") --> 3/10 +print(5 + rational(1, 3) .. "") --> 16/3 + +function findperfs(n) + local ret = {} + for i = 1, n do + sum = rational(1, i) + for fac = 2, i^.5 do + if i % fac == 0 then + sum = sum + rational(1, fac) + rational(fac, i) + end + end + if sum.den == sum.num then + ret[#ret + 1] = i + end + end + return table.concat(ret, '\n') +end +print(findperfs(2^19)) diff --git a/Task/Arithmetic-Rational/Perl/arithmetic-rational.pl b/Task/Arithmetic-Rational/Perl/arithmetic-rational.pl new file mode 100644 index 0000000000..5067539204 --- /dev/null +++ b/Task/Arithmetic-Rational/Perl/arithmetic-rational.pl @@ -0,0 +1,13 @@ +use bigrat; + +foreach my $candidate (2 .. 2**19) { + my $sum = 1 / $candidate; + foreach my $factor (2 .. sqrt($candidate)+1) { + if ($candidate % $factor == 0) { + $sum += 1 / $factor + 1 / ($candidate / $factor); + } + } + if ($sum->denominator() == 1) { + print "Sum of recipr. factors of $candidate = $sum exactly ", ($sum == 1 ? "perfect!" : ""), "\n"; + } +} diff --git a/Task/Arithmetic-Rational/PicoLisp/arithmetic-rational.l b/Task/Arithmetic-Rational/PicoLisp/arithmetic-rational.l new file mode 100644 index 0000000000..71dd556d3a --- /dev/null +++ b/Task/Arithmetic-Rational/PicoLisp/arithmetic-rational.l @@ -0,0 +1,14 @@ +(load "@lib/frac.l") + +(for (N 2 (> (** 2 19) N) (inc N)) + (let (Sum (frac 1 N) Lim (sqrt N)) + (for (F 2 (>= Lim F) (inc F)) + (when (=0 (% N F)) + (setq Sum + (f+ Sum + (f+ (frac 1 F) (frac 1 (/ N F))) ) ) ) ) + (when (= 1 (cdr Sum)) + (prinl + "Perfect " N + ", sum is " (car Sum) + (and (= 1 (car Sum)) ": perfect") ) ) ) ) diff --git a/Task/Arithmetic-Rational/Python/arithmetic-rational-1.py b/Task/Arithmetic-Rational/Python/arithmetic-rational-1.py new file mode 100644 index 0000000000..c561a6afe6 --- /dev/null +++ b/Task/Arithmetic-Rational/Python/arithmetic-rational-1.py @@ -0,0 +1,10 @@ +from fractions import Fraction + +for candidate in range(2, 2**19): + sum = Fraction(1, candidate) + for factor in range(2, int(candidate**0.5)+1): + if candidate % factor == 0: + sum += Fraction(1, factor) + Fraction(1, candidate // factor) + if sum.denominator == 1: + print("Sum of recipr. factors of %d = %d exactly %s" % + (candidate, int(sum), "perfect!" if sum == 1 else "")) diff --git a/Task/Arithmetic-Rational/Python/arithmetic-rational-2.py b/Task/Arithmetic-Rational/Python/arithmetic-rational-2.py new file mode 100644 index 0000000000..a7bdace8e0 --- /dev/null +++ b/Task/Arithmetic-Rational/Python/arithmetic-rational-2.py @@ -0,0 +1,33 @@ +def lcm(a, b): + return a // gcd(a,b) * b + +def gcd(u, v): + return gcd(v, u%v) if v else abs(u) + +class Fraction: + def __init__(self, numerator, denominator): + common = gcd(numerator, denominator) + self.numerator = numerator//common + self.denominator = denominator//common + def __add__(self, frac): + common = lcm(self.denominator, frac.denominator) + n = common // self.denominator * self.numerator + common // frac.denominator * frac.numerator + return Fraction(n, common) + def __sub__(self, frac): + return self.__add__(-frac) + def __neg__(self): + return Fraction(-self.numerator, self.denominator) + def __abs__(self): + return Fraction(abs(self.numerator), abs(self.denominator)) + def __mul__(self, frac): + return Fraction(self.numerator * frac.numerator, self.denominator * frac.denominator) + def __div__(self, frac): + return self.__mul__(frac.reciprocal()) + def reciprocal(self): + return Fraction(self.denominator, self.numerator) + def __cmp__(self, n): + return int(float(self) - float(n)) + def __float__(self): + return float(self.numerator / self.denominator) + def __int__(self): + return (self.numerator // self.denominator) diff --git a/Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx b/Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx new file mode 100644 index 0000000000..8fa2ac7b0e --- /dev/null +++ b/Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx @@ -0,0 +1,92 @@ +/*REXX pgm implements a reasonably complete rational arithmetic (fract.)*/ +L=length(2**19-1) /*saves time by checking even #s.*/ + do j=2 to 2**19-1 by 2 /*ignore unity (can't be perfect)*/ + $=divisors(j); s=0; @= /*get divisors, zero sum, null @.*/ + do k=2 to words($) /*ignore unity.*/ + r='1/'word($,k); @=@ r; s=fractFun(r,,s) + end /*k*/ + if s\==1 then iterate + say 'perfect number:' right(j,L) ' fractions:' @ + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────FRACTDIV subroutine─────────────────*/ +fractDiv: procedure; parse arg x; x=space(x,0); f='FractDiv' +parse var x n '/' d; d=p(d 1) +if d=0 then call err 'division by zero:' x +if \isNum(n) then call err 'a not numeric numerator:' x +if \isNum(d) then call err 'a not numeric denominator:' x +return n/d +/*──────────────────────────────────FRACTFUN subroutine─────────────────*/ +fractFun: procedure; parse arg z.1,,z.2 1 zz.2,f; arg ,op; op=p(op '+') +f='FractFun'; do j=1 for 2; z.j=translate(z.j,'/',"_"); end /*j*/ +if abbrev('ADD' ,op) then op='+' +if abbrev('DIVIDE' ,op) then op='/' +if abbrev('INTDIVIDE' ,op,4) then op='Γ·' +if abbrev('MODULO' ,op,3) | abbrev('MODULUS' ,op,3) then op='//' +if abbrev('MULTIPLY' ,op) then op='*' +if abbrev('POWER' ,op) then op='^' +if abbrev('SUBTRACT' ,op) then op='-' +if z.1=='' then z.1=(op\=="+" & op\=='-') /*unary +,-*/ +if z.2=='' then z.2=(op\=="+" & op\=='-') +z_=z.2 + + do j=1 for 2 /*verification of both fractions.*/ + if pos('/',z.j)==0 then z.j=z.j"/1"; parse var z.j n.j '/' d.j + if \isNum(n.j) then call err 'a not numeric numerator:' n.j + if \isNum(d.j) then call err 'a not numeric denominator:' d.j + n.j=n.j/1; d.j=d.j/1 + do while \isInt(n.j); n.j=(n.j*10)/1; d.j=(d.j*10)/1 + end /*while*/ /* [↑] normalize both numbers. */ + if d.j=0 then call err 'a denominator of zero:' d.j + g=gcd(n.j,d.j); if g=0 then iterate; n.j=n.j/g; d.j=d.j/g + end /*j*/ + + select + when op=='**' | op=='↑' |, + op=='^' then do; if \isInt(z_) then call err 'a not integer power:' z_ + t=1; u=1; do j=1 for abs(z_); t=t*n.1; u=u*d.1 + end /*j*/ + if z_<0 then parse value t u with u t + end + when op=='/' then do; if n.2=0 then call err 'a zero divisor:' zz.2 + t=n.1*d.2; u=n.2*d.1 + end + when op=='Γ·' then do; if n.2=0 then call err 'a zero divisor:' zz.2 + t=trunc(fractDiv(n.1 '/' d.1)); u=1 + end /* [↑] integer division. */ + when op=='//' then do; if n.2=0 then call err 'a zero divisor:' zz.2 + _=trunc(fractDiv(n.1 '/' d.1)); t=_-trunc(_)*d.1; u=1 + end /* [↑] modulus division. */ + when op=='+' |, + op=='-' then do; l=lcm(d.1 d.2); do j=1 for 2; n.j=l*n.j/d.j; d.j=l + end /*j*/ + if op=='-' then n.2=-n.2; t=n.1+n.2; u=l + end + when op=='ABS' then do; t=abs(n.1); u=abs(d.1); end + when op=='*' then do; t=n.1*n.2; u=d.1*d.2; end + when op=='EQ' |, + op=='=' then return fractDiv(n.1 '/' d.1) = fractDiv(n.2 '/' d.2) + when op=='NE' | op=='\=' | op=='β•ͺ' |, + op=='Β¬=' then return fractDiv(n.1 '/' d.1) \= fractDiv(n.2 '/' d.2) + when op=='GT' |, + op=='>' then return fractDiv(n.1 '/' d.1) > fractDiv(n.2 '/' d.2) + when op=='LT' |, + op=='<' then return fractDiv(n.1 '/' d.1) < fractDiv(n.2 '/' d.2) + when op=='GE' | op=='β‰₯' |, + op=='>=' then return fractDiv(n.1 '/' d.1) >= fractDiv(n.2 '/' d.2) + when op=='LE' | op=='≀' |, + op=='<=' then return fractDiv(n.1 '/' d.1) <= fractDiv(n.2 '/' d.2) + otherwise call err 'an illegal function:' op + end /*select*/ + +if t==0 then return 0; g=gcd(t,u); t=t/g; u=u/g +if u==1 then return t + return t'/'u +/*─────────────────────────────general 1─line subs─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────*/ +divisors: procedure; parse arg x 1 b; if x=1 then return 1; a=1; o=x//2; do j=2+o by 1+o while j*j= candidate (expt 2 19))) + (let ((sum (/ 1 candidate))) + (do ((factor 2 (+ factor 1))) ((>= factor (sqrt candidate))) + (if (= 0 (modulo candidate factor)) + (set! sum (+ sum (/ 1 factor) (/ factor candidate))))) + (if (= 1 (denominator sum)) + (begin (display candidate) (newline))))) diff --git a/Task/Arithmetic-Rational/Smalltalk/arithmetic-rational.st b/Task/Arithmetic-Rational/Smalltalk/arithmetic-rational.st new file mode 100644 index 0000000000..b903227020 --- /dev/null +++ b/Task/Arithmetic-Rational/Smalltalk/arithmetic-rational.st @@ -0,0 +1,18 @@ +| sum | +2 to: (2 raisedTo: 19) do: [ :candidate | + sum := candidate reciprocal. + 2 to: (candidate sqrt) do: [ :factor | + ( (candidate \\ factor) = 0 ) + ifTrue: [ + sum := sum + (factor reciprocal) + ((candidate / factor) reciprocal) + ] + ]. + ( (sum denominator) = 1 ) + ifTrue: [ + ('Sum of recipr. factors of %1 = %2 exactly %3' % + { candidate printString . + (sum asInteger) printString . + ( sum = 1 ) ifTrue: [ 'perfect!' ] + ifFalse: [ ' ' ] }) displayNl + ] +]. diff --git a/Task/Arithmetic-evaluation/0DESCRIPTION b/Task/Arithmetic-evaluation/0DESCRIPTION new file mode 100644 index 0000000000..608fa66217 --- /dev/null +++ b/Task/Arithmetic-evaluation/0DESCRIPTION @@ -0,0 +1,20 @@ +Create a program which parses and evaluates arithmetic expressions. + +;Requirements: +* An [[wp:Abstract_syntax_tree|abstract-syntax tree]] (AST) for the expression must be created from parsing the input. +* The AST must be used in evaluation, also, so the input may not be directly evaluated (e.g. by calling eval or a similar language feature.) +* The expression will be a string or list of symbols like "(1+3)*7". +* The four symbols + - * / must be supported as binary operators with conventional precedence rules. +* Precedence-control parentheses must also be supported. + +;Note: +For those who don't remember, mathematical precedence is as follows: +* Parentheses +* Multiplication/Division (left to right) +* Addition/Subtraction (left to right) + + +;C.f: +* [[24 game Player]]. +* [[Parsing/RPN calculator algorithm]]. +* [[Parsing/RPN to infix conversion]]. diff --git a/Task/Arithmetic-evaluation/1META.yaml b/Task/Arithmetic-evaluation/1META.yaml new file mode 100644 index 0000000000..7e6120d2a6 --- /dev/null +++ b/Task/Arithmetic-evaluation/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Recursion diff --git a/Task/Arithmetic-evaluation/ALGOL-68/arithmetic-evaluation.alg b/Task/Arithmetic-evaluation/ALGOL-68/arithmetic-evaluation.alg new file mode 100644 index 0000000000..ae53f4faf3 --- /dev/null +++ b/Task/Arithmetic-evaluation/ALGOL-68/arithmetic-evaluation.alg @@ -0,0 +1,142 @@ +INT base=10; +MODE FIXED = LONG REAL; # numbers in the format 9,999.999 # + +#IF build abstract syntax tree and then EVAL tree # +MODE AST = UNION(NODE, FIXED); +MODE NUM = REF AST; +MODE NODE = STRUCT(NUM a, PROC (FIXED,FIXED)FIXED op, NUM b); + +OP EVAL = (NUM ast)FIXED:( + CASE ast IN + (FIXED num): num, + (NODE fork): (op OF fork)(EVAL( a OF fork), EVAL (b OF fork)) + ESAC +); + +OP + = (NUM a,b)NUM: ( HEAP AST := NODE(a, (FIXED a,b)FIXED:a+b, b) ); +OP - = (NUM a,b)NUM: ( HEAP AST := NODE(a, (FIXED a,b)FIXED:a-b, b) ); +OP * = (NUM a,b)NUM: ( HEAP AST := NODE(a, (FIXED a,b)FIXED:a*b, b) ); +OP / = (NUM a,b)NUM: ( HEAP AST := NODE(a, (FIXED a,b)FIXED:a/b, b) ); +OP **= (NUM a,b)NUM: ( HEAP AST := NODE(a, (FIXED a,b)FIXED:a**b, b) ); + +#ELSE simply use REAL arithmetic with no abstract syntax tree at all # CO +MODE NUM = FIXED, AST = FIXED; +OP EVAL = (FIXED num)FIXED: num; +#FI# END CO + +MODE LEX = PROC (TOK)NUM; +MODE MONADIC =PROC (NUM)NUM; +MODE DIADIC = PROC (NUM,NUM)NUM; + +MODE TOK = CHAR; +MODE ACTION = UNION(STACKACTION, LEX, MONADIC, DIADIC); +MODE OPVAL = STRUCT(INT prio, ACTION action); +MODE OPITEM = STRUCT(TOK token, OPVAL opval); + +[256]STACKITEM stack; +MODE STACKITEM = STRUCT(NUM value, OPVAL op); +MODE STACKACTION = PROC (REF STACKITEM)VOID; + +PROC begin = (REF STACKITEM top)VOID: prio OF op OF top -:= +10; +PROC end = (REF STACKITEM top)VOID: prio OF op OF top -:= -10; + +OP ** = (COMPL a,b)COMPL: complex exp(complex ln(a)*b); + +[8]OPITEM op list :=( +# OP PRIO ACTION # + ("^", (8, (NUM a,b)NUM: a**b)), + ("*", (7, (NUM a,b)NUM: a*b)), + ("/", (7, (NUM a,b)NUM: a/b)), + ("+", (6, (NUM a,b)NUM: a+b)), + ("-", (6, (NUM a,b)NUM: a-b)), + ("(",(+10, begin)), + (")",(-10, end)), + ("?", (9, LEX:SKIP)) +); + +PROC op dict = (TOK op)REF OPVAL:( +# This can be unrolled to increase performance # + REF OPITEM candidate; + FOR i TO UPB op list WHILE + candidate := op list[i]; +# WHILE # op /= token OF candidate DO + SKIP + OD; + opval OF candidate +); + +PROC build ast = (STRING expr)NUM:( + + INT top:=0; + + PROC compress ast stack = (INT prio, NUM in value)NUM:( + NUM out value := in value; + FOR loc FROM top BY -1 TO 1 WHILE + REF STACKITEM stack top := stack[loc]; + # WHILE # ( top >= LWB stack | prio <= prio OF op OF stack top | FALSE ) DO + top := loc - 1; + out value := + CASE action OF op OF stack top IN + (MONADIC op): op(value OF stack top), # not implemented # + (DIADIC op): op(value OF stack top,out value) + ESAC + OD; + out value + ); + + NUM value := NIL; + FIXED num value; + INT decimal places; + + FOR i TO UPB expr DO + TOK token = expr[i]; + REF OPVAL this op := op dict(token); + CASE action OF this op IN + (STACKACTION action):( + IF prio OF thisop = -10 THEN + value := compress ast stack(0, value) + FI; + IF top >= LWB stack THEN + action(stack[top]) + FI + ), + (LEX):( # a crude lexer # + SHORT INT digit = ABS token - ABS "0"; + IF 0<= digit AND digit < base THEN + IF NUM(value) IS NIL THEN # first digit # + decimal places := 0; + value := HEAP AST := num value := digit + ELSE + NUM(value) := num value := IF decimal places = 0 + THEN + num value * base + digit + ELSE + decimal places *:= base; + num value + digit / decimal places + FI + FI + ELIF token = "." THEN + decimal places := 1 + ELSE + SKIP # and ignore spaces and any unrecognised characters # + FI + ), + (MONADIC): SKIP, # not implemented # + (DIADIC):( + value := compress ast stack(prio OF this op, value); + IF top=UPB stack THEN index error FI; + stack[top+:=1]:=STACKITEM(value, this op); + value:=NIL + ) + ESAC + OD; + compress ast stack(-max int, value) +); + +test:( + printf(($" euler's number is about: "g(-long real width,long real width-2)l$, + EVAL build ast("1+1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+1/15)/14)/13)/12)/11)/10)/9)/8)/7)/6)/5)/4)/3)/2"))); + SKIP EXIT + index error: + printf(("Stack over flow")) +) diff --git a/Task/Arithmetic-evaluation/AutoHotkey/arithmetic-evaluation-1.ahk b/Task/Arithmetic-evaluation/AutoHotkey/arithmetic-evaluation-1.ahk new file mode 100644 index 0000000000..d0230a6858 --- /dev/null +++ b/Task/Arithmetic-evaluation/AutoHotkey/arithmetic-evaluation-1.ahk @@ -0,0 +1,150 @@ +/* +hand coded recursive descent parser +expr : term ( ( PLUS | MINUS ) term )* ; +term : factor ( ( MULT | DIV ) factor )* ; +factor : NUMBER | '(' expr ')'; +*/ + +calcLexer := makeCalcLexer() +string := "((3+4)*(7*9)+3)+4" +tokens := tokenize(string, calcLexer) +msgbox % printTokens(tokens) +ast := expr() +msgbox % printTree(ast) +msgbox % expression := evalTree(ast) +filedelete expression.ahk +fileappend, % "msgbox % " expression, expression.ahk +run, expression.ahk +return + + +expr() +{ + global tokens + ast := object(1, "expr") + if node := term() + ast._Insert(node) + loop + { + if peek("PLUS") or peek("MINUS") + { + op := getsym() + newop := object(1, op.type, 2, op.value) + node := term() + ast._Insert(newop) + ast._Insert(node) + } + Else + Break + } + return ast +} + +term() +{ + global tokens + tree := object(1, "term") + if node := factor() + tree._Insert(node) + loop + { + if peek("MULT") or peek("DIV") + { + op := getsym() + newop := object(1, op.type, 2, op.value) + node := factor() + tree._Insert(newop) + tree._Insert(node) + } + else + Break + } + return tree +} + +factor() +{ + global tokens + if peek("NUMBER") + { + token := getsym() + tree := object(1, token.type, 2, token.value) + return tree + } + else if peek("OPEN") + { + getsym() + tree := expr() + if peek("CLOSE") + { + getsym() + return tree + } + else + error("miss closing parentheses ") + } + else + error("no factor found") +} + +peek(type, n=1) +{ +global tokens + if (tokens[n, "type"] == type) + return 1 +} + +getsym(n=1) +{ +global tokens +return token := tokens._Remove(n) +} + +error(msg) +{ +global tokens +msgbox % msg " at:`n" printToken(tokens[1]) +} + + +printTree(ast) +{ +if !ast +return + +n := 0 + loop + { + n += 1 + if !node := ast[n] + break + if !isobject(node) + treeString .= node + else + treeString .= printTree(node) + } + return ("(" treeString ")" ) +} + +evalTree(ast) +{ +if !ast +return + +n := 1 + loop + { + n += 1 + if !node := ast[n] + break + if !isobject(node) + treeString .= node + else + treeString .= evalTree(node) + } +if (n == 3) +return treeString + return ("(" treeString ")" ) +} + +#include calclex.ahk diff --git a/Task/Arithmetic-evaluation/AutoHotkey/arithmetic-evaluation-2.ahk b/Task/Arithmetic-evaluation/AutoHotkey/arithmetic-evaluation-2.ahk new file mode 100644 index 0000000000..36c6308c35 --- /dev/null +++ b/Task/Arithmetic-evaluation/AutoHotkey/arithmetic-evaluation-2.ahk @@ -0,0 +1,67 @@ +tokenize(string, lexer) +{ + stringo := string ; store original string + locationInString := 1 + size := strlen(string) + tokens := object() + +start: + Enum := Lexer._NewEnum() + While Enum[type, value] ; loop through regular expression lexing rules + { + if (1 == regexmatch(string, value, tokenValue)) + { + token := object() + token.pos := locationInString + token.value := tokenValue + token.length := strlen(tokenValue) + token.type := type + tokens._Insert(token) + locationInString += token.length + string := substr(string, token.length + 1) + goto start + } + continue + } + if (locationInString < size) + msgbox % "unrecognized token at " substr(stringo, locationInstring) + return tokens +} + +makeCalcLexer() +{ + calcLexer := object() + PLUS := "\+" + MINUS := "-" + MULT := "\*" + DIV := "/" + OPEN := "\(" + CLOSE := "\)" + NUMBER := "\d+" + WS := "[ \t\n]+" + END := "\." + RULES := "PLUS,MINUS,MULT,DIV,OPEN,CLOSE,NUMBER,WS,END" + loop, parse, rules, `, + { + type := A_LoopField + value := %A_LoopField% + calcLexer._Insert(type, value) + } + return calcLexer +} + +printTokens(tokens) +{ + loop % tokens._MaxIndex() + { + tokenString .= printToken(tokens[A_Index]) "`n`n" + } + return tokenString +} + + +printToken(token) +{ + string := "pos= " token.pos "`nvalue= " token.value "`ntype= " token.type + return string +} diff --git a/Task/Arithmetic-evaluation/Clojure/arithmetic-evaluation.clj b/Task/Arithmetic-evaluation/Clojure/arithmetic-evaluation.clj new file mode 100644 index 0000000000..8851a656e3 --- /dev/null +++ b/Task/Arithmetic-evaluation/Clojure/arithmetic-evaluation.clj @@ -0,0 +1,53 @@ +(def precedence '{* 0, / 0 + + 1, - 1}) + +(defn order-ops + "((A x B) y C) or (A x (B y C)) depending on precedence of x and y" + [[A x B y C & more]] + (let [ret (if (<= (precedence x) + (precedence y)) + (list (list A x B) y C) + (list A x (list B y C)))] + (if more + (recur (concat ret more)) + ret))) + +(defn add-parens + "Tree walk to add parens. All lists are length 3 afterwards." + [s] + (clojure.walk/postwalk + #(if (seq? %) + (let [c (count %)] + (cond (even? c) (throw (Exception. "Must be an odd number of forms")) + (= c 1) (first %) + (= c 3) % + (>= c 5) (order-ops %))) + %) + s)) + +(defn make-ast + "Parse a string into a list of numbers, ops, and lists" + [s] + (-> (format "'(%s)" s) + (.replaceAll , "([*+-/])" " $1 ") + load-string + add-parens)) + +(def ops {'* * + '+ + + '- - + '/ /}) + +(def eval-ast + (partial clojure.walk/postwalk + #(if (seq? %) + (let [[a o b] %] + ((ops o) a b)) + %))) + +(defn evaluate [s] + "Parse and evaluate an infix arithmetic expression" + (eval-ast (make-ast s))) + +user> (evaluate "1 + 2*(3 - 2*(3 - 2)*((2 - 4)*5 - 22/(7 + 2*(3 - 1)) - 1)) + 1") +60 diff --git a/Task/Arithmetic-evaluation/Haskell/arithmetic-evaluation.hs b/Task/Arithmetic-evaluation/Haskell/arithmetic-evaluation.hs new file mode 100644 index 0000000000..c8545adb5b --- /dev/null +++ b/Task/Arithmetic-evaluation/Haskell/arithmetic-evaluation.hs @@ -0,0 +1,29 @@ +import Text.ParserCombinators.Parsec +import Text.ParserCombinators.Parsec.Expr + +data Exp = Num Int + | Add Exp Exp + | Sub Exp Exp + | Mul Exp Exp + | Div Exp Exp + +expr = buildExpressionParser table factor + +table = [[op "*" (Mul) AssocLeft, op "/" (Div) AssocLeft] + ,[op "+" (Add) AssocLeft, op "-" (Sub) AssocLeft]] + where op s f assoc = Infix (do string s; return f) assoc + +factor = do char '(' ; x <- expr ; char ')' + return x + <|> do ds <- many1 digit + return $ Num (read ds) + +evaluate (Num x) = fromIntegral x +evaluate (Add a b) = (evaluate a) + (evaluate b) +evaluate (Sub a b) = (evaluate a) - (evaluate b) +evaluate (Mul a b) = (evaluate a) * (evaluate b) +evaluate (Div a b) = (evaluate a) `div` (evaluate b) + +solution exp = case parse expr [] exp of + Right expr -> evaluate expr + Left _ -> error "Did not parse" diff --git a/Task/Arithmetic-evaluation/Java/arithmetic-evaluation.java b/Task/Arithmetic-evaluation/Java/arithmetic-evaluation.java new file mode 100644 index 0000000000..59abc98a1e --- /dev/null +++ b/Task/Arithmetic-evaluation/Java/arithmetic-evaluation.java @@ -0,0 +1,138 @@ +import java.util.Stack; + +public class ArithmeticEvaluation +{ + public static enum Parentheses { LEFT, RIGHT } + + public static enum BinaryOperator + { + ADD('+', 1) { + public BigRational eval(BigRational leftValue, BigRational rightValue) { return leftValue.add(rightValue); } + }, + SUB('-', 1) { + public BigRational eval(BigRational leftValue, BigRational rightValue) { return leftValue.subtract(rightValue); } + }, + MUL('*', 2) { + public BigRational eval(BigRational leftValue, BigRational rightValue) { return leftValue.multiply(rightValue); } + }, + DIV('/', 2) { + public BigRational eval(BigRational leftValue, BigRational rightValue) { return leftValue.divide(rightValue); } + }; + + public final char symbol; + public final int precedence; + + BinaryOperator(char symbol, int precedence) + { + this.symbol = symbol; + this.precedence = precedence; + } + + public abstract BigRational eval(BigRational leftValue, BigRational rightValue); + } + + public static class BinaryExpression + { + public Object leftOperand = null; + public BinaryOperator operator = null; + public Object rightOperand = null; + + public BinaryExpression(Object leftOperand, BinaryOperator operator, Object rightOperand) + { + this.leftOperand = leftOperand; + this.operator = operator; + this.rightOperand = rightOperand; + } + + public BigRational eval() + { + BigRational leftValue = (leftOperand instanceof BinaryExpression) ? ((BinaryExpression)leftOperand).eval() : (BigRational)leftOperand; + BigRational rightValue = (rightOperand instanceof BinaryExpression) ? ((BinaryExpression)rightOperand).eval() : (BigRational)rightOperand; + return operator.eval(leftValue, rightValue); + } + + public String toString() + { return "(" + leftOperand + " " + operator.symbol + " " + rightOperand + ")"; } + } + + public static void createNewOperand(BinaryOperator operator, Stack operands) + { + Object rightOperand = operands.pop(); + operands.push(new BinaryExpression(operands.pop(), operator, rightOperand)); + return; + } + + public static Object createExpression(String inputString) + { + int curIndex = 0; + boolean afterOperand = false; + Stack operands = new Stack(); + Stack operators = new Stack(); +inputStringLoop: + while (curIndex < inputString.length()) + { + int startIndex = curIndex; + char c = inputString.charAt(curIndex++); + if (Character.isWhitespace(c)) + continue; + if (afterOperand) + { + if (c == ')') + { + Object operator = null; + while (!operators.isEmpty() && ((operator = operators.pop()) != Parentheses.LEFT)) + createNewOperand((BinaryOperator)operator, operands); + continue; + } + afterOperand = false; + for (BinaryOperator operator : BinaryOperator.values()) + { + if (c == operator.symbol) + { + while (!operators.isEmpty() && (operators.peek() != Parentheses.LEFT) && (((BinaryOperator)operators.peek()).precedence >= operator.precedence)) + createNewOperand((BinaryOperator)operators.pop(), operands); + operators.push(operator); + continue inputStringLoop; + } + } + throw new IllegalArgumentException(); + } + if (c == '(') + { + operators.push(Parentheses.LEFT); + continue; + } + afterOperand = true; + while (curIndex < inputString.length()) + { + c = inputString.charAt(curIndex); + if (((c < '0') || (c > '9')) && (c != '.')) + break; + curIndex++; + } + operands.push(BigRational.valueOf(inputString.substring(startIndex, curIndex))); + } + + while (!operators.isEmpty()) + { + Object operator = operators.pop(); + if (operator == Parentheses.LEFT) + throw new IllegalArgumentException(); + createNewOperand((BinaryOperator)operator, operands); + } + Object expression = operands.pop(); + if (!operands.isEmpty()) + throw new IllegalArgumentException(); + return expression; + } + + public static void main(String[] args) + { + String[] testExpressions = { "2+3", "2+3/4", "2*3-4", "2*(3+4)+5/6", "2 * (3 + (4 * 5 + (6 * 7) * 8) - 9) * 10", "2*-3--4+-.25" }; + for (String testExpression : testExpressions) + { + Object expression = createExpression(testExpression); + System.out.println("Input: \"" + testExpression + "\", AST: \"" + expression + "\", eval=" + (expression instanceof BinaryExpression ? ((BinaryExpression)expression).eval() : expression)); + } + } +} diff --git a/Task/Arithmetic-evaluation/JavaScript/arithmetic-evaluation.js b/Task/Arithmetic-evaluation/JavaScript/arithmetic-evaluation.js new file mode 100644 index 0000000000..22d97539d3 --- /dev/null +++ b/Task/Arithmetic-evaluation/JavaScript/arithmetic-evaluation.js @@ -0,0 +1,55 @@ +function evalArithmeticExp(s) { + s = s.replace(/\s/g,'').replace(/^\+/,''); + var rePara = /\([^\(\)]*\)/; + var exp = s.match(rePara); + + while (exp = s.match(rePara)) { + s = s.replace(exp[0], evalExp(exp[0])); + } + return evalExp(s); + + function evalExp(s) { + s = s.replace(/[\(\)]/g,''); + var reMD = /\d+\.?\d*\s*[\*\/]\s*[+-]?\d+\.?\d*/; + var reM = /\*/; + var reAS = /-?\d+\.?\d*\s*[\+-]\s*[+-]?\d+\.?\d*/; + var reA = /\d\+/; + var exp; + + while (exp = s.match(reMD)) { + s = exp[0].match(reM)? s.replace(exp[0], multiply(exp[0])) : s.replace(exp[0], divide(exp[0])); + } + + while (exp = s.match(reAS)) { + s = exp[0].match(reA)? s.replace(exp[0], add(exp[0])) : s.replace(exp[0], subtract(exp[0])); + } + + return '' + s; + + function multiply(s, b) { + b = s.split('*'); + return b[0] * b[1]; + } + + function divide(s, b) { + b = s.split('/'); + return b[0] / b[1]; + } + + function add(s, b) { + s = s.replace(/^\+/,'').replace(/\++/,'+'); + b = s.split('+'); + return Number(b[0]) + Number(b[1]); + } + + function subtract(s, b) { + s = s.replace(/\+-|-\+/g,'-'); + + if (s.match(/--/)) { + return add(s.replace(/--/,'+')); + } + b = s.split('-'); + return b.length == 3? -1 * b[1] - b[2] : b[0] - b[1]; + } + } +} diff --git a/Task/Arithmetic-evaluation/Lua/arithmetic-evaluation.lua b/Task/Arithmetic-evaluation/Lua/arithmetic-evaluation.lua new file mode 100644 index 0000000000..8f01f75d1e --- /dev/null +++ b/Task/Arithmetic-evaluation/Lua/arithmetic-evaluation.lua @@ -0,0 +1,40 @@ +require"lpeg" + +P, R, C, S, V = lpeg.P, lpeg.R, lpeg.C, lpeg.S, lpeg.V + +--matches arithmetic expressions and returns a syntax tree +expression = P{"expr"; +ws = P" "^0, +number = C(R"09"^1) * V"ws", +lp = "(" * V"ws", +rp = ")" * V"ws", +sym = C(S"+-*/") * V"ws", +more = (V"sym" * V"expr")^0, +expr = V"number" * V"more" + V"lp" * lpeg.Ct(V"expr" * V"more") * V"rp" * V"more"} + +--evaluates a tree +function eval(expr) + --empty + if type(expr) == "string" or type(expr) == "number" then return expr + 0 end + + --arithmetic functions + tb = {["+"] = function(a,b) return eval(a) + eval(b) end, + ["-"] = function(a,b) return eval(a) - eval(b) end, + ["*"] = function(a,b) return eval(a) * eval(b) end, + ["/"] = function(a,b) return eval(a) / eval(b) end} + + --you could add ^ or other operators to this pretty easily + for i, v in ipairs{"*/", "+-"} do + for s, u in ipairs(expr) do + local k = type(u) == "string" and C(S(v)):match(u) + if k then + expr[s-1] = tb[k](expr[s-1],expr[s+1]) + table.remove(expr, s) + table.remove(expr, s) + end + end + end + return expr[1] +end + +print(eval{expression:match(io.read())}) diff --git a/Task/Arithmetic-evaluation/Perl/arithmetic-evaluation.pl b/Task/Arithmetic-evaluation/Perl/arithmetic-evaluation.pl new file mode 100644 index 0000000000..78469ba18d --- /dev/null +++ b/Task/Arithmetic-evaluation/Perl/arithmetic-evaluation.pl @@ -0,0 +1,61 @@ +sub ev +# Evaluates an arithmetic expression like "(1+3)*7" and returns +# its value. + {my $exp = shift; + # Delete all meaningless characters. (Scientific notation, + # infinity, and not-a-number aren't supported.) + $exp =~ tr {0-9.+-/*()} {}cd; + return ev_ast(astize($exp));} + + {my $balanced_paren_regex; + $balanced_paren_regex = qr + {\( ( [^()]+ | (??{$balanced_paren_regex}) )+ \)}x; + # ??{ ... } interpolates lazily (only when necessary), + # permitting recursion to arbitrary depths. + + sub astize + # Constructs an abstract syntax tree by recursively + # transforming textual arithmetic expressions into array + # references of the form [operator, left oprand, right oprand]. + {my $exp = shift; + # If $exp is just a number, return it as-is. + $exp =~ /[^0-9.]/ or return $exp; + # If parentheses surround the entire expression, get rid of + # them. + $exp = substr($exp, 1, -1) + while $exp =~ /\A($balanced_paren_regex)\z/; + # Replace stuff in parentheses with placeholders. + my @paren_contents; + $exp =~ s {($balanced_paren_regex)} + {push(@paren_contents, $1); + "[p$#paren_contents]"}eg; + # Scan for operators in order of increasing precedence, + # preferring the rightmost. + $exp =~ m{(.+) ([+-]) (.+)}x or + $exp =~ m{(.+) ([*/]) (.+)}x or + # The expression must've been malformed somehow. + # (Note that unary minus isn't supported.) + die "Eh?: [$exp]\n"; + my ($op, $lo, $ro) = ($2, $1, $3); + # Restore the parenthetical expressions. + s {\[p(\d+)\]} {($paren_contents[$1])}eg + foreach $lo, $ro; + # And recurse. + return [$op, astize($lo), astize($ro)];}} + + {my %ops = + ('+' => sub {$_[0] + $_[1]}, + '-' => sub {$_[0] - $_[1]}, + '*' => sub {$_[0] * $_[1]}, + '/' => sub {$_[0] / $_[1]}); + + sub ev_ast + # Evaluates an abstract syntax tree of the form returned by + # &astize. + {my $ast = shift; + # If $ast is just a number, return it as-is. + ref $ast or return $ast; + # Otherwise, recurse. + my ($op, @operands) = @$ast; + $_ = ev_ast($_) foreach @operands; + return $ops{$op}->(@operands);}} diff --git a/Task/Arithmetic-evaluation/PicoLisp/arithmetic-evaluation-1.l b/Task/Arithmetic-evaluation/PicoLisp/arithmetic-evaluation-1.l new file mode 100644 index 0000000000..62143b04b4 --- /dev/null +++ b/Task/Arithmetic-evaluation/PicoLisp/arithmetic-evaluation-1.l @@ -0,0 +1,23 @@ +(de ast (Str) + (let *L (str Str "") + (aggregate) ) ) + +(de aggregate () + (let X (product) + (while (member (car *L) '("+" "-")) + (setq X (list (intern (pop '*L)) X (product))) ) + X ) ) + +(de product () + (let X (term) + (while (member (car *L) '("*" "/")) + (setq X (list (intern (pop '*L)) X (term))) ) + X ) ) + +(de term () + (let X (pop '*L) + (cond + ((num? X) X) + ((= "+" X) (term)) + ((= "-" X) (list '- (term))) + ((= "(" X) (prog1 (aggregate) (pop '*L)))) ) ) ) diff --git a/Task/Arithmetic-evaluation/PicoLisp/arithmetic-evaluation-2.l b/Task/Arithmetic-evaluation/PicoLisp/arithmetic-evaluation-2.l new file mode 100644 index 0000000000..32ae796052 --- /dev/null +++ b/Task/Arithmetic-evaluation/PicoLisp/arithmetic-evaluation-2.l @@ -0,0 +1,5 @@ +: (ast "1+2+3*-4/(1+2)") +-> (+ (+ 1 2) (/ (* 3 (- 4)) (+ 1 2))) + +: (ast "(1+2+3)*-4/(1+2)") +-> (/ (* (+ (+ 1 2) 3) (- 4)) (+ 1 2)) diff --git a/Task/Arithmetic-evaluation/Prolog/arithmetic-evaluation.pro b/Task/Arithmetic-evaluation/Prolog/arithmetic-evaluation.pro new file mode 100644 index 0000000000..dd7bff2ce0 --- /dev/null +++ b/Task/Arithmetic-evaluation/Prolog/arithmetic-evaluation.pro @@ -0,0 +1,50 @@ +% Lexer + numeric(X) :- 48 =< X, X =< 57. + not_numeric(X) :- 48 > X ; X > 57. + + lex1([], []). + lex1([40|Xs], ['('|Ys]) :- lex1(Xs, Ys). + lex1([41|Xs], [')'|Ys]) :- lex1(Xs, Ys). + lex1([43|Xs], ['+'|Ys]) :- lex1(Xs, Ys). + lex1([45|Xs], ['-'|Ys]) :- lex1(Xs, Ys). + lex1([42|Xs], ['*'|Ys]) :- lex1(Xs, Ys). + lex1([47|Xs], ['/'|Ys]) :- lex1(Xs, Ys). + lex1([X|Xs], [N|Ys]) :- numeric(X), N is X - 48, lex1(Xs, Ys). + + lex2([], []). + lex2([X], [X]). + lex2([Xa,Xb|Xs], [Xa|Ys]) :- atom(Xa), lex2([Xb|Xs], Ys). + lex2([Xa,Xb|Xs], [Xa|Ys]) :- number(Xa), atom(Xb), lex2([Xb|Xs], Ys). + lex2([Xa,Xb|Xs], [Y|Ys]) :- number(Xa), number(Xb), N is Xa * 10 + Xb, lex2([N|Xs], [Y|Ys]). + + % Parser + oper(1, *, X, Y, X * Y). oper(1, /, X, Y, X / Y). + oper(2, +, X, Y, X + Y). oper(2, -, X, Y, X - Y). + + num(D) --> [D], {number(D)}. + + expr(0, Z) --> num(Z). + expr(0, Z) --> {Z = (X)}, ['('], expr(2, X), [')']. + + expr(N, Z) --> {succ(N0, N)}, {oper(N, Op, X, Y, Z)}, expr(N0, X), [Op], expr(N, Y). + expr(N, Z) --> {succ(N0, N)}, expr(N0, Z). + + parse(Tokens, Expr) :- expr(2, Expr, Tokens, []). + + + % Evaluator + evaluate(E, E) :- number(E). + evaluate(A + B, E) :- evaluate(A, Ae), evaluate(B, Be), E is Ae + Be. + evaluate(A - B, E) :- evaluate(A, Ae), evaluate(B, Be), E is Ae - Be. + evaluate(A * B, E) :- evaluate(A, Ae), evaluate(B, Be), E is Ae * Be. + evaluate(A / B, E) :- evaluate(A, Ae), evaluate(B, Be), E is Ae / Be. + + % Solution + calculator(String, Value) :- + lex1(String, Tokens1), + lex2(Tokens1, Tokens2), + parse(Tokens2, Expression), + evaluate(Expression, Value). + + % Example use + % calculator("(3+50)*7-9", X). diff --git a/Task/Arithmetic-evaluation/Python/arithmetic-evaluation-1.py b/Task/Arithmetic-evaluation/Python/arithmetic-evaluation-1.py new file mode 100644 index 0000000000..fc56e5e217 --- /dev/null +++ b/Task/Arithmetic-evaluation/Python/arithmetic-evaluation-1.py @@ -0,0 +1,116 @@ +import operator + +class AstNode(object): + def __init__( self, opr, left, right ): + self.opr = opr + self.l = left + self.r = right + + def eval(self): + return self.opr(self.l.eval(), self.r.eval()) + +class LeafNode(object): + def __init__( self, valStrg ): + self.v = int(valStrg) + + def eval(self): + return self.v + +class Yaccer(object): + def __init__(self): + self.operstak = [] + self.nodestak =[] + self.__dict__.update(self.state1) + + def v1( self, valStrg ): + # Value String + self.nodestak.append( LeafNode(valStrg)) + self.__dict__.update(self.state2) + #print 'push', valStrg + + def o2( self, operchar ): + # Operator character or open paren in state1 + def openParen(a,b): + return 0 # function should not be called + + opDict= { '+': ( operator.add, 2, 2 ), + '-': (operator.sub, 2, 2 ), + '*': (operator.mul, 3, 3 ), + '/': (operator.div, 3, 3 ), + '^': ( pow, 4, 5 ), # right associative exponentiation for grins + '(': ( openParen, 0, 8 ) + } + operPrecidence = opDict[operchar][2] + self.redeuce(operPrecidence) + + self.operstak.append(opDict[operchar]) + self.__dict__.update(self.state1) + # print 'pushop', operchar + + def syntaxErr(self, char ): + # Open Parenthesis + print 'parse error - near operator "%s"' %char + + def pc2( self,operchar ): + # Close Parenthesis + # reduce node until matching open paren found + self.redeuce( 1 ) + if len(self.operstak)>0: + self.operstak.pop() # pop off open parenthesis + else: + print 'Error - no open parenthesis matches close parens.' + self.__dict__.update(self.state2) + + def end(self): + self.redeuce(0) + return self.nodestak.pop() + + def redeuce(self, precidence): + while len(self.operstak)>0: + tailOper = self.operstak[-1] + if tailOper[1] < precidence: break + + tailOper = self.operstak.pop() + vrgt = self.nodestak.pop() + vlft= self.nodestak.pop() + self.nodestak.append( AstNode(tailOper[0], vlft, vrgt)) + # print 'reduce' + + state1 = { 'v': v1, 'o':syntaxErr, 'po':o2, 'pc':syntaxErr } + state2 = { 'v': syntaxErr, 'o':o2, 'po':syntaxErr, 'pc':pc2 } + + +def Lex( exprssn, p ): + bgn = None + cp = -1 + for c in exprssn: + cp += 1 + if c in '+-/*^()': # throw in exponentiation (^)for grins + if bgn is not None: + p.v(p, exprssn[bgn:cp]) + bgn = None + if c=='(': p.po(p, c) + elif c==')':p.pc(p, c) + else: p.o(p, c) + elif c in ' \t': + if bgn is not None: + p.v(p, exprssn[bgn:cp]) + bgn = None + elif c in '0123456789': + if bgn is None: + bgn = cp + else: + print 'Invalid character in expression' + if bgn is not None: + p.v(p, exprssn[bgn:cp]) + bgn = None + + if bgn is not None: + p.v(p, exprssn[bgn:cp+1]) + bgn = None + return p.end() + + +expr = raw_input("Expression:") +astTree = Lex( expr, Yaccer()) +print expr, '=',astTree.eval() diff --git a/Task/Arithmetic-evaluation/Python/arithmetic-evaluation-2.py b/Task/Arithmetic-evaluation/Python/arithmetic-evaluation-2.py new file mode 100644 index 0000000000..bfc8578f17 --- /dev/null +++ b/Task/Arithmetic-evaluation/Python/arithmetic-evaluation-2.py @@ -0,0 +1,24 @@ +>>> import ast +>>> +>>> expr="2 * (3 -1) + 2 * 5" +>>> node = ast.parse(expr, mode='eval') +>>> print(ast.dump(node).replace(',', ',\n')) +Expression(body=BinOp(left=BinOp(left=Num(n=2), + op=Mult(), + right=BinOp(left=Num(n=3), + op=Sub(), + right=Num(n=1))), + op=Add(), + right=BinOp(left=Num(n=2), + op=Mult(), + right=Num(n=5)))) +>>> code_object = compile(node, filename='', mode='eval') +>>> eval(code_object) +14 +>>> # lets modify the AST by changing the 5 to a 6 +>>> node.body.right.right.n +5 +>>> node.body.right.right.n = 6 +>>> code_object = compile(node, filename='', mode='eval') +>>> eval(code_object) +16 diff --git a/Task/Arithmetic-evaluation/REXX/arithmetic-evaluation.rexx b/Task/Arithmetic-evaluation/REXX/arithmetic-evaluation.rexx new file mode 100644 index 0000000000..925d8abc9e --- /dev/null +++ b/Task/Arithmetic-evaluation/REXX/arithmetic-evaluation.rexx @@ -0,0 +1,117 @@ +/*REXX pgm evaluates an infix-type arithmetic expression & shows result.*/ +nchars = '0123456789.eEdDqQ' /*possible parts of a #, sans Β± */ +e='***error!***'; $=' '; doubleOps='&|*/'; z= +parse arg x 1 ox1; if x='' then call serr 'no input was specified.' +x=space(x); L=length(x); x=translate(x,'()()',"[]{}") + +j=0; do forever; j=j+1; if j>L then leave; _=substr(x,j,1); _2=getX() + newT=pos(_,' ()[]{}^Γ·')\==0; if newT then do; z=z _ $; iterate; end + possDouble=pos(_,doubleOps)\==0 /*is _ a possible double operator*/ + if possDouble then do /*is this a possible double oper?*/ + if _2==_ then do /*yup, it's one of 'em.*/ + _=_||_ /*use a double operator*/ + x=overlay($,x,Nj) /*blank out the*/ + end /* 2nd symbol.*/ + z=z _ $; iterate + end + if _=='+' | _=="-" then do; p_=word(z,words(z)) /*last Z token*/ + if p_=='(' then z=z 0 /handle unary Β±*/ + z=z _ $; iterate + end + lets=0; sigs=0; #=_ + + do j=j+1 to L; _=substr(x,j,1) /*build a valid number.*/ + if lets==1 & sigs==0 then if _=='+' | _=='-' then do; sigs=1 + #=# || _ + iterate + end /*exp*/ + if pos(_,nchars)==0 then leave + lets=lets+datatype(_,'M') /*keep track of # of exponents. */ + #=# || translate(_,'EEEEE','eDdQq') /*keep buildingthe num.*/ + end /*j*/ + j=j-1 + if \datatype(#,'N') then call serr 'invalid number: ' # + z=z # $ + end /*forever*/ + +_=word(z,1); if _=='+' | _=='-' then z=0 z /*handle unary cases.*/ +x='(' space(z) ') '; tokens=words(x) /*force stacking for expression. */ + do i=1 for tokens; @.i=word(x,i); end /*i*/ /*assign input tokens*/ +L=max(20,length(x)) /*use 20 for the min show width. */ +op=')(-+/*^'; rOp=substr(op,3); p.=; s.=; n=length(op); epr=; stack= + + do i=1 for n; _=substr(op,i,1); s._=(i+1)%2; p._=s._+(i==n); end /*i*/ + /*[↑] assign operator priorities.*/ + do #=1 for tokens; ?=@.# /*process each token from @. list*/ + if ?=='**' then ?="^" /*convert REXX-type exponentation*/ + select /*@.# is: (, operator, ), operand*/ + when ?=='(' then stack='(' stack + when isOp(?) then do /*is token an operator?*/ + !=word(stack,1) /*get token from stack.*/ + do while !\==')' & s.!>=p.?; epr=epr ! /*add*/ + stack=subword(stack,2); /*del token from stack.*/ + !=word(stack,1) /*get token from stack.*/ + end /*while Β·Β·Β·)*/ + stack=? stack /*add token to stack.*/ + end + when ?==')' then do; !=word(stack,1) /*get token from stack.*/ + do while !\=='('; epr=epr ! /*add to epr.*/ + stack=subword(stack,2) /*del token from stack.*/ + !=word(stack,1) /*get token from stack.*/ + end /*while Β·Β·Β·( */ + stack=subword(stack,2) /*del token from stack.*/ + end + otherwise epr=epr ? /*add operand to epr. */ + end /*select*/ + end /*#*/ + +epr=space(epr stack); tokens=words(epr); x=epr; z=; stack= + do i=1 for tokens; @.i=word(epr,i); end /*i*/ /*assign input tokens*/ +dop='/ // % Γ·'; bop='& | &&' /*division ops; binary operands*/ +aop='- + * ^ **' dop bop; lop=aop '||' /*arithmetic ops; legal operands*/ + + do #=1 for tokens; ?=@.#; ??=? /*process each token from @. list*/ + w=words(stack); b=word(stack,max(1,w)) /*stack count; last entry.*/ + a=word(stack,max(1,w-1)) /*stack's "first" operand.*/ + division =wordpos(?,dop)\==0 /*flag: doing a division.*/ + arith =wordpos(?,aop)\==0 /*flag: doing arithmetic.*/ + bitOp =wordpos(?,bop)\==0 /*flag: doing binary math*/ + if datatype(?,'N') then do; stack=stack ?; iterate; end + if wordpos(?,lop)==0 then do; z=e 'illegal operator:' ?; leave; end + if w<2 then do; z=e 'illegal epr expression.'; leave; end + if ?=='^' then ??="**" /*REXXify ^ ──► ** (make legal)*/ + if ?=='Γ·' then ??="/" /*REXXify Γ· ──► / (make legal)*/ + if division & b=0 then do; z=e 'division by zero: ' b; leave; end + if bitOp & \isBit(a) then do; z=e "token isn't logical: " a; leave; end + if bitOp & \isBit(b) then do; z=e "token isn't logical: " b; leave; end + select /*perform arith. operation*/ + when ??=='+' then y = a + b + when ??=='-' then y = a - b + when ??=='*' then y = a * b + when ??=='/' | ??=="Γ·" then y = a / b + when ??=='//' then y = a // b + when ??=='%' then y = a % b + when ??=='^' | ??=="**" then y = a ** b + when ??=='||' then y = a || b + otherwise z=e 'invalid operator:' ?; leave + end /*select*/ + if datatype(y,'W') then y=y/1 /*normalize number with Γ· by 1.*/ + _=subword(stack,1,w-2); stack=_ y /*rebuild the stack with answer. */ + end /*#*/ + +if word(z,1)==e then stack= /*handle special case of errors. */ +z=space(z stack) /*append any residual entries. */ +say 'answer──►' z /*display the answer (result). */ +parse source upper . how . /*invoked via C.L. or REXX pgm?*/ +if how=='COMMAND' | , + \datatype(z,'W') then exit /*stick a fork in it, we're done.*/ +return z /*return Z ──► invoker (RESULT).*/ +/*──────────────────────────────────subroutines─────────────────────────*/ +isBit: return arg(1)==0 | arg(1)==1 /*returns 1 if arg1 is bin bit.*/ +isOp: return pos(arg(1),rOp)\==0 /*is argument1 a "real" operator?*/ +serr: say; say e arg(1); say; exit 13 /*issue an error message with txt*/ +/*──────────────────────────────────GETX subroutine─────────────────────*/ +getX: do Nj=j+1 to length(x); _n=substr(x,Nj,1); if _n==$ then iterate + if _n==$ then iterate; return substr(x,Nj,1) /*ignore blanks*/ + end /*Nj*/ +return $ /*reached end-of-tokens, return $*/ diff --git a/Task/Arithmetic-evaluation/Ruby/arithmetic-evaluation-1.rb b/Task/Arithmetic-evaluation/Ruby/arithmetic-evaluation-1.rb new file mode 100644 index 0000000000..d6901b2f70 --- /dev/null +++ b/Task/Arithmetic-evaluation/Ruby/arithmetic-evaluation-1.rb @@ -0,0 +1,96 @@ +$op_priority = {"+" => 0, "-" => 0, "*" => 1, "/" => 1} +$op_function = { + "+" => lambda {|x, y| x + y}, + "-" => lambda {|x, y| x - y}, + "*" => lambda {|x, y| x * y}, + "/" => lambda {|x, y| x / y}} + +class TreeNode + attr_accessor :info, :left, :right + + def initialize(info) + @info = info + end + + def leaf? + @left.nil? and @right.nil? + end + + def to_s(order) + if leaf? + @info + else + left_s, right_s = @left.to_s(order), @right.to_s(order) + + strs = case order + when :prefix then [@info, left_s, right_s] + when :infix then [left_s, @info, right_s] + when :postfix then [left_s, right_s, @info] + else [] + end + + "(" + strs.join(" ") + ")" + end + end + + def eval + if !leaf? and operator?(@info) + $op_function[@info].call(@left.eval, @right.eval) + else + @info.to_f + end + end +end + +def tokenize(exp) + exp + .gsub('(', ' ( ') + .gsub(')', ' ) ') + .split(' ') +end + +def operator?(token) + $op_priority.has_key?(token) +end + +def pop_connect_push(op_stack, node_stack) + temp = op_stack.pop + temp.right = node_stack.pop + temp.left = node_stack.pop + node_stack.push(temp) +end + +def infix_exp_to_tree(exp) + tokens = tokenize(exp) + op_stack, node_stack = [], [] + + tokens.each do |token| + if operator?(token) + # clear stack of higher priority operators + until (op_stack.empty? or + op_stack.last.info == "(" or + $op_priority[op_stack.last.info] < $op_priority[token]) + pop_connect_push(op_stack, node_stack) + end + + op_stack.push(TreeNode.new(token)) + elsif token == "(" + op_stack.push(TreeNode.new(token)) + elsif token == ")" + while op_stack.last.info != "(" + pop_connect_push(op_stack, node_stack) + end + + # throw away the '(' + op_stack.pop + else + node_stack.push(TreeNode.new(token)) + end + end + + until op_stack.empty? + pop_connect_push(op_stack, node_stack) + end + + node_stack.last +end diff --git a/Task/Arithmetic-evaluation/Ruby/arithmetic-evaluation-2.rb b/Task/Arithmetic-evaluation/Ruby/arithmetic-evaluation-2.rb new file mode 100644 index 0000000000..7aa67acdc6 --- /dev/null +++ b/Task/Arithmetic-evaluation/Ruby/arithmetic-evaluation-2.rb @@ -0,0 +1,8 @@ +exp = "1 + 2 - 3 * (4 / 6)" +puts("Original: " + exp) + +tree = infix_exp_to_tree(exp) +puts("Prefix: " + tree.to_s(:prefix)) +puts("Infix: " + tree.to_s(:infix)) +puts("Postfix: " + tree.to_s(:postfix)) +puts("Result: " + tree.eval.to_s) diff --git a/Task/Arithmetic-evaluation/Scala/arithmetic-evaluation.scala b/Task/Arithmetic-evaluation/Scala/arithmetic-evaluation.scala new file mode 100644 index 0000000000..c15306266a --- /dev/null +++ b/Task/Arithmetic-evaluation/Scala/arithmetic-evaluation.scala @@ -0,0 +1,46 @@ +package org.rosetta.arithmetic_evaluator.scala + +object ArithmeticParser extends scala.util.parsing.combinator.RegexParsers { + + def readExpression(input: String) : Option[()=>Int] = { + parseAll(expr, input) match { + case Success(result, _) => + Some(result) + case other => + println(other) + None + } + } + + private def expr : Parser[()=>Int] = { + (term<~"+")~expr ^^ { case l~r => () => l() + r() } | + (term<~"-")~expr ^^ { case l~r => () => l() - r() } | + term + } + + private def term : Parser[()=>Int] = { + (factor<~"*")~term ^^ { case l~r => () => l() * r() } | + (factor<~"/")~term ^^ { case l~r => () => l() / r() } | + factor + } + + private def factor : Parser[()=>Int] = { + "("~>expr<~")" | + "\\d+".r ^^ { x => () => x.toInt } | + failure("Expected a value") + } +} + +object Main { + def main(args: Array[String]) { + println("""Please input the expressions. Type "q" to quit.""") + var input: String = "" + + do { + input = readLine("> ") + if (input != "q") { + ArithmeticParser.readExpression(input).foreach(f => println(f())) + } + } while (input != "q") + } +} diff --git a/Task/Arithmetic-evaluation/Tcl/arithmetic-evaluation.tcl b/Task/Arithmetic-evaluation/Tcl/arithmetic-evaluation.tcl new file mode 100644 index 0000000000..0e00666992 --- /dev/null +++ b/Task/Arithmetic-evaluation/Tcl/arithmetic-evaluation.tcl @@ -0,0 +1,44 @@ +namespace import tcl::mathop::* + +proc ast str { + # produce abstract syntax tree for an expression + regsub -all {[-+*/()]} $str { & } str ;# "tokenizer" + s $str +} +proc s {args} { + # parse "(a + b) * c + d" to "+ [* [+ a b] c] d" + if {[llength $args] == 1} {set args [lindex $args 0]} + if [regexp {[()]} $args] { + eval s [string map {( "\[s " ) \]} $args] + } elseif {"*" in $args} { + s [s_group $args *] + } elseif {"/" in $args} { + s [s_group $args /] + } elseif {"+" in $args} { + s [s_group $args +] + } elseif {"-" in $args} { + s [s_group $args -] + } else { + string map {\{ \[ \} \]} [join $args] + } +} +proc s_group {list op} { + # turn ".. a op b .." to ".. {op a b} .." + set pos [lsearch -exact $list $op] + set p_1 [- $pos 1] + set p1 [+ $pos 1] + lreplace $list $p_1 $p1 \ + [list $op [lindex $list $p_1] [lindex $list $p1]] +} +#-- Test suite +foreach test [split { + ast 2-2 + ast 1-2-3 + ast (1-2)-3 + ast 1-(2-3) + ast (1+2)*3 + ast (1+2)/3-4*5 + ast ((1+2)/3-4)*5 +} \n] { + puts "$test ..... [eval $test] ..... [eval [eval $test]]" +} diff --git a/Task/Arithmetic-geometric-mean/0DESCRIPTION b/Task/Arithmetic-geometric-mean/0DESCRIPTION new file mode 100644 index 0000000000..3460ed5dae --- /dev/null +++ b/Task/Arithmetic-geometric-mean/0DESCRIPTION @@ -0,0 +1,10 @@ +{{wikipedia|Arithmetic-geometric mean}} +Write a function to compute the [[wp:Arithmetic-geometric mean|arithmetic-geometric mean]] of two numbers. +[http://mathworld.wolfram.com/Arithmetic-GeometricMean.html] +The arithmetic-geometric mean of two numbers can be (usefully) denoted as \mathrm{agm}(a,g), and is equal to the limit of the sequence: +: a_0 = a; \qquad g_0 = g +: a_{n+1} = \tfrac{1}{2}(a_n + g_n); \quad g_{n+1} = \sqrt{a_n g_n}. +Since the limit of a_n-g_n tends (rapidly) to zero with iterations, this is an efficient method. + +Demonstrate the function by calculating: +:\mathrm{agm}(1,1/\sqrt{2}) diff --git a/Task/Arithmetic-geometric-mean/Ada/arithmetic-geometric-mean.ada b/Task/Arithmetic-geometric-mean/Ada/arithmetic-geometric-mean.ada new file mode 100644 index 0000000000..294cd726e0 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Ada/arithmetic-geometric-mean.ada @@ -0,0 +1,26 @@ +with Ada.Text_IO, Ada.Numerics.Generic_Elementary_Functions; + +procedure Arith_Geom_Mean is + + type Num is digits 18; -- the largest value gnat/gcc allows + package N_IO is new Ada.Text_IO.Float_IO(Num); + package Math is new Ada.Numerics.Generic_Elementary_Functions(Num); + + function AGM(A, G: Num) return Num is + Old_G: Num; + New_G: Num := G; + New_A: Num := A; + begin + loop + Old_G := New_G; + New_G := Math.Sqrt(New_A*New_G); + New_A := (Old_G + New_A) * 0.5; + exit when (New_A - New_G) <= Num'Epsilon; + -- Num'Epsilon denotes the relative error when performing arithmetic over Num + end loop; + return New_G; + end AGM; + +begin + N_IO.Put(AGM(1.0, 1.0/Math.Sqrt(2.0)), Fore => 1, Aft => 17, Exp => 0); +end Arith_Geom_Mean; diff --git a/Task/Arithmetic-geometric-mean/AutoHotkey/arithmetic-geometric-mean.ahk b/Task/Arithmetic-geometric-mean/AutoHotkey/arithmetic-geometric-mean.ahk new file mode 100644 index 0000000000..b96d695bc0 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/AutoHotkey/arithmetic-geometric-mean.ahk @@ -0,0 +1,11 @@ +agm(a, g, tolerance=1.0e-15){ + While abs(a-g) > tolerance + { + an := .5 * (a + g) + g := sqrt(a*g) + a := an + } + return a +} +SetFormat, FloatFast, 0.15 +MsgBox % agm(1, 1/sqrt(2)) diff --git a/Task/Arithmetic-geometric-mean/C/arithmetic-geometric-mean.c b/Task/Arithmetic-geometric-mean/C/arithmetic-geometric-mean.c new file mode 100644 index 0000000000..b9df3bf294 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/C/arithmetic-geometric-mean.c @@ -0,0 +1,32 @@ +#include +#include +#include + +double agm( double a, double g ) { + /* arithmetic-geometric mean */ + double iota = 1.0E-16; + double a1, g1; + + if( a*g < 0.0 ) { + printf( "arithmetic-geometric mean undefined when x*y<0\n" ); + exit(1); + } + + while( fabs(a-g)>iota ) { + a1 = (a + g) / 2.0; + g1 = sqrt(a * g); + + a = a1; + g = g1; + } + + return a; +} + +int main( void ) { + double x, y; + printf( "Enter two numbers: " ); + scanf( "%lf%lf", &x, &y ); + printf( "The arithmetic-geometric mean is %lf\n", agm(x, y) ); + return 0; +} diff --git a/Task/Arithmetic-geometric-mean/Erlang/arithmetic-geometric-mean-1.erl b/Task/Arithmetic-geometric-mean/Erlang/arithmetic-geometric-mean-1.erl new file mode 100644 index 0000000000..2057646527 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Erlang/arithmetic-geometric-mean-1.erl @@ -0,0 +1,19 @@ +%% Arithmetic Geometric Mean of 1 and 1 / sqrt(2) +%% Author: Abhay Jain + +-module(agm_calculator). +-export([find_agm/0]). +-define(TOLERANCE, 0.0000000001). + +find_agm() -> + A = 1, + B = 1 / (math:pow(2, 0.5)), + AGM = agm(A, B), + io:format("AGM = ~p", [AGM]). + +agm (A, B) when abs(A-B) =< ?TOLERANCE -> + A; +agm (A, B) -> + A1 = (A+B) / 2, + B1 = math:pow(A*B, 0.5), + agm(A1, B1). diff --git a/Task/Arithmetic-geometric-mean/Erlang/arithmetic-geometric-mean-2.erl b/Task/Arithmetic-geometric-mean/Erlang/arithmetic-geometric-mean-2.erl new file mode 100644 index 0000000000..584fef30c2 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Erlang/arithmetic-geometric-mean-2.erl @@ -0,0 +1 @@ +AGM = 0.8472130848351929 diff --git a/Task/Arithmetic-geometric-mean/Fortran/arithmetic-geometric-mean.f b/Task/Arithmetic-geometric-mean/Fortran/arithmetic-geometric-mean.f new file mode 100644 index 0000000000..f652e2b1ac --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Fortran/arithmetic-geometric-mean.f @@ -0,0 +1,15 @@ + function agm(a,b) + implicit none + double precision agm,a,b,eps,c + parameter(eps=1.0d-15) + 10 c=0.5d0*(a+b) + b=sqrt(a*b) + a=c + if(a-b.gt.eps*a) go to 10 + agm=0.5d0*(a+b) + end + program test + implicit none + double precision agm + print*,agm(1.0d0,1.0d0/sqrt(2.0d0)) + end diff --git a/Task/Arithmetic-geometric-mean/Go/arithmetic-geometric-mean-1.go b/Task/Arithmetic-geometric-mean/Go/arithmetic-geometric-mean-1.go new file mode 100644 index 0000000000..a5c08c09ef --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Go/arithmetic-geometric-mean-1.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "math" +) + +const Ξ΅ = 1e-14 + +func agm(a, g float64) float64 { + for math.Abs(a-g) > math.Abs(a)*Ξ΅ { + a, g = (a+g)*.5, math.Sqrt(a*g) + } + return a +} + +func main() { + fmt.Println(agm(1, 1/math.Sqrt2)) +} diff --git a/Task/Arithmetic-geometric-mean/Go/arithmetic-geometric-mean-2.go b/Task/Arithmetic-geometric-mean/Go/arithmetic-geometric-mean-2.go new file mode 100644 index 0000000000..278cd975a5 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Go/arithmetic-geometric-mean-2.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "math" + "math/cmplx" +) + +const Ξ΅ = 1e-14 + +func agm(a, g complex128) complex128 { + for cmplx.Abs(a-g) > cmplx.Abs(a)*Ξ΅ { + a, g = (a+g)*.5, cmplx.Rect(math.Sqrt(cmplx.Abs(a)*cmplx.Abs(g)), + (cmplx.Phase(a)+cmplx.Phase(g))*.5) + } + return a +} + +func main() { + fmt.Println(agm(1, 1/math.Sqrt2)) +} diff --git a/Task/Arithmetic-geometric-mean/Haskell/arithmetic-geometric-mean.hs b/Task/Arithmetic-geometric-mean/Haskell/arithmetic-geometric-mean.hs new file mode 100644 index 0000000000..ff8964fe45 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Haskell/arithmetic-geometric-mean.hs @@ -0,0 +1,17 @@ +-- Return an approximation to the arithmetic-geometric mean of two numbers. +-- The result is considered accurate when two successive approximations are +-- sufficiently close, as determined by "eq". +agm :: (Floating a) => a -> a -> ((a, a) -> Bool) -> a +agm a g eq = snd . head . dropWhile (not . eq) $ iterate step (a, g) + where step (a, g) = ((a + g) / 2, sqrt (a * g)) + +-- Return the relative difference of the pair. We assume that at least one of +-- the values is far enough from 0 to not cause problems. +relDiff :: (Fractional a) => (a, a) -> a +relDiff (x, y) = let n = abs (x - y) + d = ((abs x) + (abs y)) / 2 + in n / d + +main = do + let equal = (< 0.000000001) . relDiff + print $ agm 1 (1 / sqrt 2) equal diff --git a/Task/Arithmetic-geometric-mean/Java/arithmetic-geometric-mean.java b/Task/Arithmetic-geometric-mean/Java/arithmetic-geometric-mean.java new file mode 100644 index 0000000000..936bf8f186 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Java/arithmetic-geometric-mean.java @@ -0,0 +1,25 @@ +/* + + Arithmetic-Geometric Mean of 1 & 1/sqrt(2) + + Brendan Shaklovitz + 5/29/12 + +*/ + +public class ArithmeticMean { + public static void agm (double a, double g){ + double a1 = a; + double g1 = g; + while (Math.abs(a1-g1) >= Math.pow(10, -14)){ + double aTemp = (a1+g1)/2.0; + g1 = Math.sqrt(a1*g1); + a1 = aTemp; + } + System.out.println(a1); + } + + public static void main(String[] args){ + agm(1,1/Math.sqrt(2)); + } +} diff --git a/Task/Arithmetic-geometric-mean/PHP/arithmetic-geometric-mean.php b/Task/Arithmetic-geometric-mean/PHP/arithmetic-geometric-mean.php new file mode 100644 index 0000000000..8c6cf75179 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/PHP/arithmetic-geometric-mean.php @@ -0,0 +1,22 @@ +define('PRECISION', 13); + +function agm($a0, $g0, $tolerance = 1e-10) +{ + // the bc extension deals in strings and cannot convert + // floats in scientific notation by itself - hence + // this manual conversion to a string + $limit = number_format($tolerance, PRECISION, '.', ''); + $an = $a0; + $gn = $g0; + do { + list($an, $gn) = array( + bcdiv(bcadd($an, $gn), 2), + bcsqrt(bcmul($an, $gn)), + ); + } while (bccomp(bcsub($an, $gn), $limit) > 0); + + return $an; +} + +bcscale(PRECISION); +echo agm(1, 1 / bcsqrt(2)); diff --git a/Task/Arithmetic-geometric-mean/Perl/arithmetic-geometric-mean.pl b/Task/Arithmetic-geometric-mean/Perl/arithmetic-geometric-mean.pl new file mode 100644 index 0000000000..a946d644ed --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Perl/arithmetic-geometric-mean.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl -w + +my ($a0, $g0, $a1, $g1); + +sub agm($$) { + $a0 = shift; + $g0 = shift; + do { + $a1 = ($a0 + $g0)/2; + $g1 = sqrt($a0 * $g0); + $a0 = ($a1 + $g1)/2; + $g0 = sqrt($a1 * $g1); + } while ($a0 != $a1); + return $a0; +} + +print agm(1, 1/sqrt(2))."\n"; diff --git a/Task/Arithmetic-geometric-mean/PicoLisp/arithmetic-geometric-mean.l b/Task/Arithmetic-geometric-mean/PicoLisp/arithmetic-geometric-mean.l new file mode 100644 index 0000000000..d7520a22c2 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/PicoLisp/arithmetic-geometric-mean.l @@ -0,0 +1,10 @@ +(scl 80) + +(de agm (A G) + (do 7 + (prog1 (/ (+ A G) 2) + (setq G (sqrt (* A G)) A @) ) ) ) + +(round + (agm 1.0 (*/ 1.0 1.0 (sqrt (* 2.0 1.0)))) + 70 ) diff --git a/Task/Arithmetic-geometric-mean/Python/arithmetic-geometric-mean-1.py b/Task/Arithmetic-geometric-mean/Python/arithmetic-geometric-mean-1.py new file mode 100644 index 0000000000..11a8d47d54 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Python/arithmetic-geometric-mean-1.py @@ -0,0 +1,16 @@ +from math import sqrt + +def agm(a0, g0, tolerance=1e-10): + """ + Calculating the arithmetic-geometric mean of two numbers a0, g0. + + tolerance the tolerance for the converged + value of the arithmetic-geometric mean + (default value = 1e-10) + """ + [an, gn] = [(a0 + g0) / 2.0, sqrt(a0 * g0)] + while abs(an - gn) > tolerance: + [an, gn] = [(an + gn) / 2.0, sqrt(an * gn)] + return an + +print agm(1, 1 / sqrt(2)) diff --git a/Task/Arithmetic-geometric-mean/Python/arithmetic-geometric-mean-2.py b/Task/Arithmetic-geometric-mean/Python/arithmetic-geometric-mean-2.py new file mode 100644 index 0000000000..8bbc04e1b8 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Python/arithmetic-geometric-mean-2.py @@ -0,0 +1,10 @@ +from decimal import Decimal, getcontext + +def agm(a, g, tolerance=Decimal("1e-65")): + while True: + a, g = ((a + g) / 2, (a * g).sqrt()) + if abs(a - g) < tolerance: + return a + +getcontext().prec = 70 +print agm(Decimal(1), 1 / Decimal(2).sqrt()) diff --git a/Task/Arithmetic-geometric-mean/R/arithmetic-geometric-mean-1.r b/Task/Arithmetic-geometric-mean/R/arithmetic-geometric-mean-1.r new file mode 100644 index 0000000000..dfba6ab740 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/R/arithmetic-geometric-mean-1.r @@ -0,0 +1,14 @@ +arithmeticMean <- function(a, b) { (a + b)/2 } +geometricMean <- function(a, b) { sqrt(a * b) } + +arithmeticGeometricMean <- function(a, b) { + rel_error <- abs(a - b) / pmax(a, b) + if (all(rel_error < .Machine$double.eps, na.rm=TRUE)) { + agm <- a + return(data.frame(agm, rel_error)); + } + Recall(arithmeticMean(a, b), geometricMean(a, b)) +} + +agm <- arithmeticGeometricMean(1, 1/sqrt(2)) +print(format(agm, digits=16)) diff --git a/Task/Arithmetic-geometric-mean/R/arithmetic-geometric-mean-2.r b/Task/Arithmetic-geometric-mean/R/arithmetic-geometric-mean-2.r new file mode 100644 index 0000000000..5519222a9e --- /dev/null +++ b/Task/Arithmetic-geometric-mean/R/arithmetic-geometric-mean-2.r @@ -0,0 +1,4 @@ +a <- c(1, 1, 1) +b <- c(1/sqrt(2), 1/sqrt(3), 1/2) +agm <- arithmeticGeometricMean(a, b) +print(format(agm, digits=16)) diff --git a/Task/Arithmetic-geometric-mean/REXX/arithmetic-geometric-mean.rexx b/Task/Arithmetic-geometric-mean/REXX/arithmetic-geometric-mean.rexx new file mode 100644 index 0000000000..67ae0c5893 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/REXX/arithmetic-geometric-mean.rexx @@ -0,0 +1,29 @@ +/*REXX program calculates AGM (arithmetric-geometric mean) of 2 numbers.*/ +parse arg a b digs . /*obtain numbers from the command line.*/ +if digs=='' then digs=100 /*no DIGS specified? Then use default.*/ +numeric digits digs /*Now, REXX will use lots of digits. */ +if a=='' then a=1 /*no A specified? Then use default. */ +if b=='' then b=1/sqrt(2) /*no B specified? " " " */ +say '1st # =' a +say '2nd # =' b +say ' AGM =' agm(a,b)/1 /*divide by 1; goes from 105──►100 digs*/ +say ' AGM =' agm(a,b)/1 /*dividing by 1 normalizes the REXX num*/ +exit /*stick a fork in it, we're done.*/ +/*────────────────────────────AGM subroutine────────────────────────────*/ +agm: procedure: parse arg x,y; if x=y then return x /*equality case.*/ +if y=0 then return 0; if x=0 then return .5*y /*two "0" cases.*/ +numeric digits digits()+5 /*add 5 more digs to ensure convergence*/ +!='1e-' || (digits()-1); _x=x+1 + + do while _x\=x & abs(_x)>!; _x=x; _y=y; x=(_x+_y)*.5 + y=sqrt(_x*_y) + end /*while*/ +return x +/*────────────────────────────SQRT subroutine───────────────────────────*/ +sqrt: procedure; parse arg x;if x=0 then return 0;d=digits();numeric digits 11 + g=.sqrtGuess(); do j=0 while p>9; m.j=p; p=p%2+1; end + do k=j+5 to 0 by -1; if m.k>11 then numeric digits m.k + g=.5*(g+x/g); end; numeric digits d; return g/1 + +.sqrtGuess: numeric form scientific; m.=11; p=d+d%4+2 + parse value format(x,2,1,,0) 'E0' with g 'E' _ .; return g*.5'E'_%2 diff --git a/Task/Arithmetic-geometric-mean/Racket/arithmetic-geometric-mean-1.rkt b/Task/Arithmetic-geometric-mean/Racket/arithmetic-geometric-mean-1.rkt new file mode 100644 index 0000000000..6eccde3145 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Racket/arithmetic-geometric-mean-1.rkt @@ -0,0 +1,7 @@ +#lang racket +(define (agm a g [Ξ΅ 1e-15]) + (if (<= (- a g) Ξ΅) + a + (agm (/ (+ a g) 2) (sqrt (* a g)) Ξ΅))) + +(agm 1 (/ 1 (sqrt 2))) diff --git a/Task/Arithmetic-geometric-mean/Racket/arithmetic-geometric-mean-2.rkt b/Task/Arithmetic-geometric-mean/Racket/arithmetic-geometric-mean-2.rkt new file mode 100644 index 0000000000..18f6e9a6de --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Racket/arithmetic-geometric-mean-2.rkt @@ -0,0 +1,4 @@ +#lang racket +(require math/bigfloat) +(bf-precision 200) +(bfagm 1.bf (bf/ (bfsqrt 2.bf))) diff --git a/Task/Arithmetic-geometric-mean/Ruby/arithmetic-geometric-mean.rb b/Task/Arithmetic-geometric-mean/Ruby/arithmetic-geometric-mean.rb new file mode 100644 index 0000000000..07efa6f08b --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Ruby/arithmetic-geometric-mean.rb @@ -0,0 +1,22 @@ +# +# The flt package (http://flt.rubyforge.org/) is useful for high-precision floating-point math. +# It lets us control 'context' of numbers, individually or collectively -- including precision +# (which adjusts the context's value of epsilon accordingly). + +require 'flt' +include Flt + +BinNum.Context.precision = 512 # default 53 (bits) + +def AGM(a,g) + new_a = BinNum a + new_g = BinNum g + while new_a - new_g > new_a.class.Context.epsilon do + old_g = new_g + new_g = (new_a * new_g).sqrt + new_a = (old_g + new_a) * 0.5 + end + new_g +end + +puts AGM 1, 1 / BinNum(2).sqrt diff --git a/Task/Arithmetic-geometric-mean/Scala/arithmetic-geometric-mean.scala b/Task/Arithmetic-geometric-mean/Scala/arithmetic-geometric-mean.scala new file mode 100644 index 0000000000..584007f958 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Scala/arithmetic-geometric-mean.scala @@ -0,0 +1,6 @@ + def agm(a: Double, g: Double, eps: Double): Double = { + if (math.abs(a - g) < eps) (a + g) / 2 + else agm((a + g) / 2, math.sqrt(a * g), eps) + } + + agm(1, math.sqrt(2)/2, 1e-15) diff --git a/Task/Arithmetic-geometric-mean/Tcl/arithmetic-geometric-mean.tcl b/Task/Arithmetic-geometric-mean/Tcl/arithmetic-geometric-mean.tcl new file mode 100644 index 0000000000..a343d99851 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Tcl/arithmetic-geometric-mean.tcl @@ -0,0 +1,10 @@ +proc agm {a b} { + set old_b [expr {$b<0?inf:-inf}] + while {$a != $b && $b != $old_b} { + set old_b $b + lassign [list [expr {0.5*($a+$b)}] [expr {sqrt($a*$b)}]] a b + } + return $a +} + +puts [agm 1 [expr 1/sqrt(2)]] diff --git a/Task/Array-concatenation/0DESCRIPTION b/Task/Array-concatenation/0DESCRIPTION new file mode 100644 index 0000000000..7294dcbf0a --- /dev/null +++ b/Task/Array-concatenation/0DESCRIPTION @@ -0,0 +1 @@ +Show how to concatenate two arrays in your language. If this is as simple as array1 + array2, so be it. diff --git a/Task/Array-concatenation/1META.yaml b/Task/Array-concatenation/1META.yaml new file mode 100644 index 0000000000..32d20151af --- /dev/null +++ b/Task/Array-concatenation/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Data Structures diff --git a/Task/Array-concatenation/ACL2/array-concatenation.acl2 b/Task/Array-concatenation/ACL2/array-concatenation.acl2 new file mode 100644 index 0000000000..70c3005b55 --- /dev/null +++ b/Task/Array-concatenation/ACL2/array-concatenation.acl2 @@ -0,0 +1 @@ +(append xs ys) diff --git a/Task/Array-concatenation/ALGOL-68/array-concatenation.alg b/Task/Array-concatenation/ALGOL-68/array-concatenation.alg new file mode 100644 index 0000000000..8608676763 --- /dev/null +++ b/Task/Array-concatenation/ALGOL-68/array-concatenation.alg @@ -0,0 +1,30 @@ +MODE ARGTYPE = INT; +MODE ARGLIST = FLEX[0]ARGTYPE; + +OP + = (ARGLIST a, b)ARGLIST: ( + [LWB a:UPB a - LWB a + 1 + UPB b - LWB b + 1 ]ARGTYPE out; + ( + out[LWB a:UPB a]:=a, + out[UPB a+1:]:=b + ); + out +); + +# Append # +OP +:= = (REF ARGLIST lhs, ARGLIST rhs)ARGLIST: lhs := lhs + rhs; +OP PLUSAB = (REF ARGLIST lhs, ARGLIST rhs)ARGLIST: lhs := lhs + rhs; + +# Prefix # +OP +=: = (ARGLIST lhs, REF ARGLIST rhs)ARGLIST: rhs := lhs + rhs; +OP PLUSTO = (ARGLIST lhs, REF ARGLIST rhs)ARGLIST: rhs := lhs + rhs; + +ARGLIST a := (1,2), + b := (3,4,5); + +print(("a + b",a + b, new line)); + +VOID(a +:= b); +print(("a +:= b", a, new line)); + +VOID(a +=: b); +print(("a +=: b", b, new line)) diff --git a/Task/Array-concatenation/APL/array-concatenation.apl b/Task/Array-concatenation/APL/array-concatenation.apl new file mode 100644 index 0000000000..bc4860cd98 --- /dev/null +++ b/Task/Array-concatenation/APL/array-concatenation.apl @@ -0,0 +1,2 @@ + 1 2 3 , 4 5 6 +1 2 3 4 5 6 diff --git a/Task/Array-concatenation/ActionScript/array-concatenation.as b/Task/Array-concatenation/ActionScript/array-concatenation.as new file mode 100644 index 0000000000..1b71c03399 --- /dev/null +++ b/Task/Array-concatenation/ActionScript/array-concatenation.as @@ -0,0 +1,3 @@ +var array1:Array = new Array(1, 2, 3); +var array2:Array = new Array(4, 5, 6); +var array3:Array = array1.concat(array2); //[1, 2, 3, 4, 5, 6] diff --git a/Task/Array-concatenation/Ada/array-concatenation.ada b/Task/Array-concatenation/Ada/array-concatenation.ada new file mode 100644 index 0000000000..5c99be6aa9 --- /dev/null +++ b/Task/Array-concatenation/Ada/array-concatenation.ada @@ -0,0 +1,3 @@ +type T is array (Positive range <>) of Integer; +X : T := (1, 2, 3); +Y : T := X & (4, 5, 6); -- Concatenate X and (4, 5, 6) diff --git a/Task/Array-concatenation/AutoHotkey/array-concatenation-1.ahk b/Task/Array-concatenation/AutoHotkey/array-concatenation-1.ahk new file mode 100644 index 0000000000..41556b2203 --- /dev/null +++ b/Task/Array-concatenation/AutoHotkey/array-concatenation-1.ahk @@ -0,0 +1,18 @@ +List1 := [1, 2, 3] +List2 := [4, 5, 6] +cList := Arr_concatenate(List1, List2) +MsgBox % Arr_disp(cList) ; [1, 2, 3, 4, 5, 6] + +Arr_concatenate(p*) { + res := Object() + For each, obj in p + For each, value in obj + res.Insert(value) + return res +} + +Arr_disp(arr) { + for each, value in arr + res .= ", " value + return "[" SubStr(res, 3) "]" +} diff --git a/Task/Array-concatenation/AutoHotkey/array-concatenation-2.ahk b/Task/Array-concatenation/AutoHotkey/array-concatenation-2.ahk new file mode 100644 index 0000000000..4461cd0f79 --- /dev/null +++ b/Task/Array-concatenation/AutoHotkey/array-concatenation-2.ahk @@ -0,0 +1,37 @@ +List1 = 1,2,3 +List2 = 4,5,6 + +List2Array(List1 , "Array1_") +List2Array(List2 , "Array2_") + +ConcatArrays("Array1_", "Array2_", "MyArray") +MsgBox, % Array2List("MyArray") + + +;--------------------------------------------------------------------------- +ConcatArrays(A1, A2, A3) { ; concatenates the arrays A1 and A2 to A3 +;--------------------------------------------------------------------------- + local i := 0 + %A3%0 := %A1%0 + %A2%0 + Loop, % %A1%0 + i++, %A3%%i% := %A1%%A_Index% + Loop, % %A2%0 + i++, %A3%%i% := %A2%%A_Index% +} + + +;--------------------------------------------------------------------------- +List2Array(List, Array) { ; creates an array from a comma separated list +;--------------------------------------------------------------------------- + global + StringSplit, %Array%, List, `, +} + + +;--------------------------------------------------------------------------- +Array2List(Array) { ; returns a comma separated list from an array +;--------------------------------------------------------------------------- + Loop, % %Array%0 + List .= (A_Index = 1 ? "" : ",") %Array%%A_Index% + Return, List +} diff --git a/Task/Array-concatenation/AutoIt/array-concatenation.autoit b/Task/Array-concatenation/AutoIt/array-concatenation.autoit new file mode 100644 index 0000000000..c8419888dc --- /dev/null +++ b/Task/Array-concatenation/AutoIt/array-concatenation.autoit @@ -0,0 +1,18 @@ +_ArrayConcatenate($avArray, $avArray2) +Func _ArrayConcatenate(ByRef $avArrayTarget, Const ByRef $avArraySource, $iStart = 0) + If Not IsArray($avArrayTarget) Then Return SetError(1, 0, 0) + If Not IsArray($avArraySource) Then Return SetError(2, 0, 0) + If UBound($avArrayTarget, 0) <> 1 Then + If UBound($avArraySource, 0) <> 1 Then Return SetError(5, 0, 0) + Return SetError(3, 0, 0) + EndIf + If UBound($avArraySource, 0) <> 1 Then Return SetError(4, 0, 0) + + Local $iUBoundTarget = UBound($avArrayTarget) - $iStart, $iUBoundSource = UBound($avArraySource) + ReDim $avArrayTarget[$iUBoundTarget + $iUBoundSource] + For $i = $iStart To $iUBoundSource - 1 + $avArrayTarget[$iUBoundTarget + $i] = $avArraySource[$i] + Next + + Return $iUBoundTarget + $iUBoundSource +EndFunc ;==>_ArrayConcatenate diff --git a/Task/Array-concatenation/Babel/array-concatenation.pb b/Task/Array-concatenation/Babel/array-concatenation.pb new file mode 100644 index 0000000000..770d3d731d --- /dev/null +++ b/Task/Array-concatenation/Babel/array-concatenation.pb @@ -0,0 +1 @@ +main : { [1 2 3] [4 5 6] cat } diff --git a/Task/Array-concatenation/C/array-concatenation.c b/Task/Array-concatenation/C/array-concatenation.c new file mode 100644 index 0000000000..cff7ca8a0c --- /dev/null +++ b/Task/Array-concatenation/C/array-concatenation.c @@ -0,0 +1,32 @@ +#include +#include +#include + +#define ARRAY_CONCAT(TYPE, A, An, B, Bn) \ + (TYPE *)array_concat((const void *)(A), (An), (const void *)(B), (Bn), sizeof(TYPE)); + +void *array_concat(const void *a, size_t an, + const void *b, size_t bn, size_t s) +{ + char *p = malloc(s * (an + bn)); + memcpy(p, a, an*s); + memcpy(p + an*s, b, bn*s); + return p; +} + +// testing +const int a[] = { 1, 2, 3, 4, 5 }; +const int b[] = { 6, 7, 8, 9, 0 }; + +int main(void) +{ + unsigned int i; + + int *c = ARRAY_CONCAT(int, a, 5, b, 5); + + for(i = 0; i < 10; i++) + printf("%d\n", c[i]); + + free(c); + return EXIT_SUCCCESS; +} diff --git a/Task/Array-concatenation/Clojure/array-concatenation.clj b/Task/Array-concatenation/Clojure/array-concatenation.clj new file mode 100644 index 0000000000..21e788a8a4 --- /dev/null +++ b/Task/Array-concatenation/Clojure/array-concatenation.clj @@ -0,0 +1 @@ +(concat [1 2 3] [4 5 6]) diff --git a/Task/Array-concatenation/CoffeeScript/array-concatenation.coffee b/Task/Array-concatenation/CoffeeScript/array-concatenation.coffee new file mode 100644 index 0000000000..d15cea4817 --- /dev/null +++ b/Task/Array-concatenation/CoffeeScript/array-concatenation.coffee @@ -0,0 +1,4 @@ +# like in JavaScript +a = [1, 2, 3] +b = [4, 5, 6] +c = a.concat b diff --git a/Task/Array-concatenation/Erlang/array-concatenation.erl b/Task/Array-concatenation/Erlang/array-concatenation.erl new file mode 100644 index 0000000000..97dd5e6a86 --- /dev/null +++ b/Task/Array-concatenation/Erlang/array-concatenation.erl @@ -0,0 +1,5 @@ +1> [1, 2, 3] ++ [4, 5, 6]. +[1,2,3,4,5,6] +2> lists:append([1, 2, 3], [4, 5, 6]). +[1,2,3,4,5,6] +3> diff --git a/Task/Array-concatenation/Forth/array-concatenation.fth b/Task/Array-concatenation/Forth/array-concatenation.fth new file mode 100644 index 0000000000..37d83f342b --- /dev/null +++ b/Task/Array-concatenation/Forth/array-concatenation.fth @@ -0,0 +1,13 @@ +: $!+ ( a u a' -- a'+u ) + 2dup + >r swap move r> ; +: cat ( a2 u2 a1 u1 -- a3 u1+u2 ) + align here dup >r $!+ $!+ r> tuck - dup allot ; + +\ TEST +create a1 1 , 2 , 3 , +create a2 4 , 5 , +a2 2 cells a1 3 cells cat dump + +8018425F0: 01 00 00 00 00 00 00 00 - 02 00 00 00 00 00 00 00 ................ +801842600: 03 00 00 00 00 00 00 00 - 04 00 00 00 00 00 00 00 ................ +801842610: 05 00 00 00 00 00 00 00 - ........ diff --git a/Task/Array-concatenation/Fortran/array-concatenation.f b/Task/Array-concatenation/Fortran/array-concatenation.f new file mode 100644 index 0000000000..5dfac40c98 --- /dev/null +++ b/Task/Array-concatenation/Fortran/array-concatenation.f @@ -0,0 +1,14 @@ +program Concat_Arrays +implicit none + + integer, dimension(3) :: a = [ 1, 2, 3 ] + integer, dimension(3) :: b = [ 4, 5, 6 ] + integer, dimension(:), allocatable :: c + + allocate(c(size(a)+size(b))) + c(1:size(a)) = a + c(size(a)+1:size(a)+size(b)) = b + + write(*,*) c + +end program Concat_Arrays diff --git a/Task/Array-concatenation/Go/array-concatenation-1.go b/Task/Array-concatenation/Go/array-concatenation-1.go new file mode 100644 index 0000000000..a39cbd928d --- /dev/null +++ b/Task/Array-concatenation/Go/array-concatenation-1.go @@ -0,0 +1,35 @@ +package main + +import "fmt" + +func main() { + // Example 1: Idiomatic in Go is use of the append function. + // Elements must be of identical type. + a := []int{1, 2, 3} + b := []int{7, 12, 60} // these are technically slices, not arrays + c := append(a, b...) + fmt.Println(c) + + // Example 2: Polymorphism. + // interface{} is a type too, one that can reference values of any type. + // This allows a sort of polymorphic list. + i := []interface{}{1, 2, 3} + j := []interface{}{"Crosby", "Stills", "Nash", "Young"} + k := append(i, j...) // append will allocate as needed + fmt.Println(k) + + // Example 3: Arrays, not slices. + // A word like "array" on RC often means "whatever array means in your + // language." In Go, the common role of "array" is usually filled by + // Go slices, as in examples 1 and 2. If by "array" you really mean + // "Go array," then you have to do a little extra work. The best + // technique is almost always to create slices on the arrays and then + // use the copy function. + l := [...]int{1, 2, 3} + m := [...]int{7, 12, 60} // arrays have constant size set at compile time + var n [len(l) + len(m)]int + copy(n[:], l[:]) // [:] creates a slice that references the entire array + copy(n[len(l):], m[:]) + fmt.Println(n) + +} diff --git a/Task/Array-concatenation/Go/array-concatenation-2.go b/Task/Array-concatenation/Go/array-concatenation-2.go new file mode 100644 index 0000000000..a1b703729c --- /dev/null +++ b/Task/Array-concatenation/Go/array-concatenation-2.go @@ -0,0 +1,57 @@ +package main + +import ( + "reflect" + "fmt" +) + +// Generic version +// Easier to make the generic version accept any number of arguments, +// and loop trough them. Otherwise there will be lots of code duplication. +func ArrayConcat(arrays ...interface{}) interface{} { + if len(arrays) == 0 { + panic("Need at least one arguemnt") + } + var vals = make([]*reflect.SliceValue, len(arrays)) + var arrtype *reflect.SliceType + var totalsize int + for i,a := range arrays { + v := reflect.NewValue(a) + switch t := v.Type().(type) { + case *reflect.SliceType: + if arrtype == nil { + arrtype = t + } else if t != arrtype { + panic("Unequal types") + } + vals[i] = v.(*reflect.SliceValue) + totalsize += vals[i].Len() + default: panic("not a slice") + } + } + ret := reflect.MakeSlice(arrtype,totalsize,totalsize) + targ := ret + for _,v := range vals { + reflect.Copy(targ, v) + targ = targ.Slice(v.Len(),targ.Len()) + } + return ret.Interface() +} + +// Type specific version +func ArrayConcatInts(a, b []int) []int { + ret := make([]int, len(a) + len(b)) + copy(ret, a) + copy(ret[len(a):], b) + return ret +} + +func main() { + test1_a, test1_b := []int{1,2,3}, []int{4,5,6} + test1_c := ArrayConcatInts(test1_a, test1_b) + fmt.Println(test1_a, " + ", test1_b, " = ", test1_c) + + test2_a, test2_b := []string{"a","b","c"}, []string{"d","e","f"} + test2_c := ArrayConcat(test2_a, test2_b).([]string) + fmt.Println(test2_a, " + ", test2_b, " = ", test2_c) +} diff --git a/Task/Array-concatenation/Haskell/array-concatenation.hs b/Task/Array-concatenation/Haskell/array-concatenation.hs new file mode 100644 index 0000000000..277ac2efb8 --- /dev/null +++ b/Task/Array-concatenation/Haskell/array-concatenation.hs @@ -0,0 +1 @@ +(++) :: [a] -> [a] -> [a] diff --git a/Task/Array-concatenation/Java/array-concatenation-1.java b/Task/Array-concatenation/Java/array-concatenation-1.java new file mode 100644 index 0000000000..4b3142be3f --- /dev/null +++ b/Task/Array-concatenation/Java/array-concatenation-1.java @@ -0,0 +1,9 @@ +public static Object[] objArrayConcat(Object[] o1, Object[] o2) +{ + Object[] ret = new Object[o1.length + o2.length]; + + System.arraycopy(o1, 0, ret, 0, o1.length); + System.arraycopy(o2, 0, ret, o1.length, o2.length); + + return ret; +} diff --git a/Task/Array-concatenation/Java/array-concatenation-2.java b/Task/Array-concatenation/Java/array-concatenation-2.java new file mode 100644 index 0000000000..75354919cd --- /dev/null +++ b/Task/Array-concatenation/Java/array-concatenation-2.java @@ -0,0 +1,4 @@ +Collection list1, list2, list1And2; +//...list1 and list2 are instantiated... +list1And2 = new ArrayList(list1); //or any other Collection you want +list1And2.addAll(list2); diff --git a/Task/Array-concatenation/JavaScript/array-concatenation.js b/Task/Array-concatenation/JavaScript/array-concatenation.js new file mode 100644 index 0000000000..b6cc4cdcc1 --- /dev/null +++ b/Task/Array-concatenation/JavaScript/array-concatenation.js @@ -0,0 +1,4 @@ +var + a = [1,2,3], + b = [4,5,6], + c = a.concat(b); // [1,2,3,4,5,6] diff --git a/Task/Array-concatenation/Lua/array-concatenation.lua b/Task/Array-concatenation/Lua/array-concatenation.lua new file mode 100644 index 0000000000..dd2cd546a4 --- /dev/null +++ b/Task/Array-concatenation/Lua/array-concatenation.lua @@ -0,0 +1,4 @@ +a = {1,2,3} +b = {4,5,6} +table.foreach(b,function(i,v)table.insert(a,v)end) +for i,v in next,a do io.write (v..' ') end diff --git a/Task/Array-concatenation/PHP/array-concatenation.php b/Task/Array-concatenation/PHP/array-concatenation.php new file mode 100644 index 0000000000..ada959e706 --- /dev/null +++ b/Task/Array-concatenation/PHP/array-concatenation.php @@ -0,0 +1,3 @@ +$arr1 = array(1, 2, 3); +$arr2 = array(4, 5, 6); +$arr3 = array_merge($arr1, $arr2); diff --git a/Task/Array-concatenation/Perl/array-concatenation-1.pl b/Task/Array-concatenation/Perl/array-concatenation-1.pl new file mode 100644 index 0000000000..a4892e3fee --- /dev/null +++ b/Task/Array-concatenation/Perl/array-concatenation-1.pl @@ -0,0 +1,3 @@ +my @arr1 = (1, 2, 3); +my @arr2 = (4, 5, 6); +my @arr3 = (@arr1, @arr2); diff --git a/Task/Array-concatenation/Perl/array-concatenation-2.pl b/Task/Array-concatenation/Perl/array-concatenation-2.pl new file mode 100644 index 0000000000..d237bd2d41 --- /dev/null +++ b/Task/Array-concatenation/Perl/array-concatenation-2.pl @@ -0,0 +1,4 @@ +my @arr1 = (1, 2, 3); +my @arr2 = (4, 5, 6); +push @arr1, @arr2; +print "@arr1\n"; # prints "1 2 3 4 5 6" diff --git a/Task/Array-concatenation/PicoLisp/array-concatenation-1.l b/Task/Array-concatenation/PicoLisp/array-concatenation-1.l new file mode 100644 index 0000000000..e4aeae6b20 --- /dev/null +++ b/Task/Array-concatenation/PicoLisp/array-concatenation-1.l @@ -0,0 +1,6 @@ +: (setq A (1 2 3) B '(a b c)) +-> (a b c) +: (conc A B) # Concatenate lists in 'A' and 'B' +-> (1 2 3 a b c) +: A +-> (1 2 3 a b c) # Side effect: List in 'A' is modified! diff --git a/Task/Array-concatenation/PicoLisp/array-concatenation-2.l b/Task/Array-concatenation/PicoLisp/array-concatenation-2.l new file mode 100644 index 0000000000..b5c6d805d2 --- /dev/null +++ b/Task/Array-concatenation/PicoLisp/array-concatenation-2.l @@ -0,0 +1,8 @@ +: (setq A (1 2 3) B '(a b c)) +-> (a b c) +: (append A B) # Append lists in 'A' and 'B' +-> (1 2 3 a b c) +: A +-> (1 2 3) +: B +-> (a b c) # Arguments are not modified diff --git a/Task/Array-concatenation/Prolog/array-concatenation.pro b/Task/Array-concatenation/Prolog/array-concatenation.pro new file mode 100644 index 0000000000..c47c5f347c --- /dev/null +++ b/Task/Array-concatenation/Prolog/array-concatenation.pro @@ -0,0 +1,2 @@ +?- append([1,2,3],[4,5,6],R). +R = [1, 2, 3, 4, 5, 6]. diff --git a/Task/Array-concatenation/Python/array-concatenation-1.py b/Task/Array-concatenation/Python/array-concatenation-1.py new file mode 100644 index 0000000000..93d4d56eec --- /dev/null +++ b/Task/Array-concatenation/Python/array-concatenation-1.py @@ -0,0 +1,7 @@ +arr1 = [1, 2, 3] +arr2 = [4, 5, 6] +arr3 = [7, 8, 9] +arr4 = arr1 + arr2 +assert arr4 == [1, 2, 3, 4, 5, 6] +arr4.extend(arr3) +assert arr4 == [1, 2, 3, 4, 5, 6, 7, 8, 9] diff --git a/Task/Array-concatenation/Python/array-concatenation-2.py b/Task/Array-concatenation/Python/array-concatenation-2.py new file mode 100644 index 0000000000..49172603b3 --- /dev/null +++ b/Task/Array-concatenation/Python/array-concatenation-2.py @@ -0,0 +1,4 @@ +arr5 = [4, 5, 6] +arr6 = [7, 8, 9] +arr6 += arr5 +assert arr6 == [7, 8, 9, 4, 5, 6] diff --git a/Task/Array-concatenation/R/array-concatenation.r b/Task/Array-concatenation/R/array-concatenation.r new file mode 100644 index 0000000000..1c70653f3c --- /dev/null +++ b/Task/Array-concatenation/R/array-concatenation.r @@ -0,0 +1,3 @@ +a1 <- c(1, 2, 3) +a2 <- c(3, 4, 5) +a3 <- c(a1, a2) diff --git a/Task/Array-concatenation/REXX/array-concatenation-1.rexx b/Task/Array-concatenation/REXX/array-concatenation-1.rexx new file mode 100644 index 0000000000..fe578fd7ad --- /dev/null +++ b/Task/Array-concatenation/REXX/array-concatenation-1.rexx @@ -0,0 +1,3 @@ +a.1 = 10 +a.2 = 22.7 +a.7 = -12 diff --git a/Task/Array-concatenation/REXX/array-concatenation-2.rexx b/Task/Array-concatenation/REXX/array-concatenation-2.rexx new file mode 100644 index 0000000000..c3441e86c0 --- /dev/null +++ b/Task/Array-concatenation/REXX/array-concatenation-2.rexx @@ -0,0 +1,9 @@ +fact.0=8 +fact.1= 1 +fact.2= 2 +fact.3= 6 +fact.4= 24 +fact.5= 120 +fact.6= 720 +fact.7= 5040 +fact.8=40320 diff --git a/Task/Array-concatenation/REXX/array-concatenation-3.rexx b/Task/Array-concatenation/REXX/array-concatenation-3.rexx new file mode 100644 index 0000000000..ebea33a02e --- /dev/null +++ b/Task/Array-concatenation/REXX/array-concatenation-3.rexx @@ -0,0 +1,22 @@ +/*REXX program to demonstrates how to perform array concatenation.*/ + +p.= /*(below) a short list of primes.*/ +p.1=2; p.2=3; p.3=5; p.4=7; p.5=11; p.6=13 +p.7=17; p.8=19; p.9=23; p.10=27; p.11=31; p.12=37 + +f.= /*(below) a list of Fibonacci #s.*/ +f.0=0;f.1=1;f.2=1;f.3=2;f.4=3;f.5=5;f.6=8;f.7=13;f.8=21;f.9=34;f.10=55 + + do j=1 while p.j\=='' + c.j=p.j /*assign C array with some primes*/ + end /*j*/ +n=j-1 + do k=0 while f.k\==''; n=n+1 + c.n=f.k /*assign C array with fib numbers*/ + end /*k*/ +say 'elements=' n +say + do m=1 for n + say 'c.'m"="c.m /*show a "merged" C array nums.*/ + end /*m*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Array-concatenation/Racket/array-concatenation.rkt b/Task/Array-concatenation/Racket/array-concatenation.rkt new file mode 100644 index 0000000000..d35e516abd --- /dev/null +++ b/Task/Array-concatenation/Racket/array-concatenation.rkt @@ -0,0 +1 @@ +(vector-append #(1 2 3 4) #(5 6 7) #(8 9 10)) diff --git a/Task/Array-concatenation/Ruby/array-concatenation.rb b/Task/Array-concatenation/Ruby/array-concatenation.rb new file mode 100644 index 0000000000..a5ac70e305 --- /dev/null +++ b/Task/Array-concatenation/Ruby/array-concatenation.rb @@ -0,0 +1,5 @@ +arr1 = [1, 2, 3] +arr2 = [4, 5, 6] +arr3 = [7, 8, 9] +arr4 = arr1 + arr2 # => [1, 2, 3, 4, 5, 6] +arr4.concat(arr3) # => [1, 2, 3, 4, 5, 6, 7, 8, 9] diff --git a/Task/Array-concatenation/Scala/array-concatenation.scala b/Task/Array-concatenation/Scala/array-concatenation.scala new file mode 100644 index 0000000000..ba2d520c5a --- /dev/null +++ b/Task/Array-concatenation/Scala/array-concatenation.scala @@ -0,0 +1,8 @@ +val arr1 = Array( 1, 2, 3 ) +val arr2 = Array( 4, 5, 6 ) +val arr3 = Array( 7, 8, 9 ) + +arr1 ++ arr2 ++ arr3 +//or: +Array concat ( arr1, arr2, arr3 ) +// res0: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9) diff --git a/Task/Array-concatenation/Scheme/array-concatenation.ss b/Task/Array-concatenation/Scheme/array-concatenation.ss new file mode 100644 index 0000000000..40a77ec76d --- /dev/null +++ b/Task/Array-concatenation/Scheme/array-concatenation.ss @@ -0,0 +1,5 @@ +; in r5rs, there is append for lists, but we'll need to define vector-append +(define (vector-append . arg) (list->vector (apply append (map vector->list arg)))) + +(vector-append #(1 2 3 4) #(5 6 7) #(8 9 10)) +; #(1 2 3 4 5 6 7 8 9 10) diff --git a/Task/Array-concatenation/Smalltalk/array-concatenation.st b/Task/Array-concatenation/Smalltalk/array-concatenation.st new file mode 100644 index 0000000000..3b6b4775dc --- /dev/null +++ b/Task/Array-concatenation/Smalltalk/array-concatenation.st @@ -0,0 +1,5 @@ +|a b c| +a := #(1 2 3 4 5). +b := #(6 7 8 9 10). +c := a,b. +c displayNl. diff --git a/Task/Array-concatenation/Tcl/array-concatenation.tcl b/Task/Array-concatenation/Tcl/array-concatenation.tcl new file mode 100644 index 0000000000..bb45228aab --- /dev/null +++ b/Task/Array-concatenation/Tcl/array-concatenation.tcl @@ -0,0 +1,3 @@ +set a {1 2 3} +set b {4 5 6} +set ab [concat $a $b]; # 1 2 3 4 5 6 diff --git a/Task/Associative-array-Creation/0DESCRIPTION b/Task/Associative-array-Creation/0DESCRIPTION new file mode 100644 index 0000000000..523c41f724 --- /dev/null +++ b/Task/Associative-array-Creation/0DESCRIPTION @@ -0,0 +1,5 @@ +In this task, the goal is to create an [[associative array]] (also known as a dictionary, map, or hash). + +Related tasks: +* [[Associative arrays/Iteration]] +* [[Hash from two arrays]] diff --git a/Task/Associative-array-Creation/1META.yaml b/Task/Associative-array-Creation/1META.yaml new file mode 100644 index 0000000000..cf16804e6f --- /dev/null +++ b/Task/Associative-array-Creation/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Data Structures +note: Basic language learning diff --git a/Task/Associative-array-Creation/ALGOL-68/associative-array-creation.alg b/Task/Associative-array-Creation/ALGOL-68/associative-array-creation.alg new file mode 100644 index 0000000000..76b44ce7fe --- /dev/null +++ b/Task/Associative-array-Creation/ALGOL-68/associative-array-creation.alg @@ -0,0 +1,70 @@ +main:( + + MODE COLOR = BITS; + FORMAT color repr = $"16r"16r6d$; + + # This is an associative array which maps strings to ints # + MODE ITEM = STRUCT(STRING key, COLOR value); + REF[]ITEM color map items := LOC[0]ITEM; + + PROC color map find = (STRING color)REF COLOR:( + REF COLOR out; +# linear search! # + FOR index FROM LWB key OF color map items TO UPB key OF color map items DO + IF color = key OF color map items[index] THEN + out := value OF color map items[index]; GO TO found + FI + OD; + NIL EXIT + found: + out + ); + + PROC color map = (STRING color)REF COLOR:( + REF COLOR out = color map find(color); + IF out :=: REF COLOR(NIL) THEN # extend color map array # + HEAP[UPB key OF color map items + 1]ITEM color map append; + color map append[:UPB key OF color map items] := color map items; + color map items := color map append; + value OF (color map items[UPB value OF color map items] := (color, 16r000000)) # black # + ELSE + out + FI + ); + + # First, populate it with some values # + color map("red") := 16rff0000; + color map("green") := 16r00ff00; + color map("blue") := 16r0000ff; + color map("my favourite color") := 16r00ffff; + + # then, get some values out # + COLOR color := color map("green"); # color gets 16r00ff00 # + color := color map("black"); # accessing unassigned values assigns them to 16r0 # + + # get some value out without accidentally inserting new ones # + REF COLOR value = color map find("green"); + IF value :=: REF COLOR(NIL) THEN + put(stand error, ("color not found!", new line)) + ELSE + printf(($"green: "f(color repr)l$, value)) + FI; + + # Now I changed my mind about my favourite color, so change it # + color map("my favourite color") := 16r337733; + + # print out all defined colors # + FOR index FROM LWB color map items TO UPB color map items DO + ITEM item = color map items[index]; + putf(stand error, ($"color map("""g""") = "f(color repr)l$, item)) + OD; + + FORMAT fmt; + FORMAT comma sep = $"("n(UPB color map items-1)(f(fmt)", ")f(fmt)")"$; + + fmt := $""""g""""$; + printf(($g$,"keys: ", comma sep, key OF color map items, $l$)); + fmt := color repr; + printf(($g$,"values: ", comma sep, value OF color map items, $l$)) + +) diff --git a/Task/Associative-array-Creation/APL/associative-array-creation.apl b/Task/Associative-array-Creation/APL/associative-array-creation.apl new file mode 100644 index 0000000000..8f1d073650 --- /dev/null +++ b/Task/Associative-array-Creation/APL/associative-array-creation.apl @@ -0,0 +1,21 @@ +⍝ Create a namespace ("hash") + Xβ†βŽ•NS ⍬ + + ⍝ Assign some names + X.this←'that' + X.foo←88 + + ⍝ Access the names + X.this +that + + ⍝ Or do it the array way + X.(foo this) +88 that + + ⍝ Namespaces are first class objects + sales ← βŽ•NS ⍬ + sales.(prices quantities) ← (100 98.4 103.4 110.16) (10 12 8 10) + sales.(revenue ← prices +.Γ— quantities) + sales.revenue +4109.6 diff --git a/Task/Associative-array-Creation/AWK/associative-array-creation.awk b/Task/Associative-array-Creation/AWK/associative-array-creation.awk new file mode 100644 index 0000000000..4b325aac12 --- /dev/null +++ b/Task/Associative-array-Creation/AWK/associative-array-creation.awk @@ -0,0 +1,16 @@ +BEGIN { + a["red"] = 0xff0000 + a["green"] = 0x00ff00 + a["blue"] = 0x0000ff + for (i in a) { + printf "%8s %06x\n", i, a[i] + } + # deleting a key/value + delete a["red"] + for (i in a) { + print i + } + # check if a key exists + print ( "red" in a ) # print 0 + print ( "blue" in a ) # print 1 +} diff --git a/Task/Associative-array-Creation/ActionScript/associative-array-creation.as b/Task/Associative-array-Creation/ActionScript/associative-array-creation.as new file mode 100644 index 0000000000..7ec032fb75 --- /dev/null +++ b/Task/Associative-array-Creation/ActionScript/associative-array-creation.as @@ -0,0 +1,9 @@ +var map:Object = {key1: "value1", key2: "value2"}; +trace(map['key1']); // outputs "value1" + +// Dot notation can also be used +trace(map.key2); // outputs "value2" + +// More keys and values can then be added +map['key3'] = "value3"; +trace(map['key3']); // outputs "value3" diff --git a/Task/Associative-array-Creation/Ada/associative-array-creation.ada b/Task/Associative-array-Creation/Ada/associative-array-creation.ada new file mode 100644 index 0000000000..751ad50319 --- /dev/null +++ b/Task/Associative-array-Creation/Ada/associative-array-creation.ada @@ -0,0 +1,33 @@ +with Ada.Containers.Ordered_Maps; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Ada.Text_IO; + +procedure Associative_Array is + + -- Instantiate the generic package Ada.Containers.Ordered_Maps + + package Associative_Int is new Ada.Containers.Ordered_Maps(Unbounded_String, Integer); + use Associative_Int; + + Color_Map : Map; + Color_Cursor : Cursor; + Success : Boolean; + Value : Integer; +begin + + -- Add values to the ordered map + + Color_Map.Insert(To_Unbounded_String("Red"), 10, Color_Cursor, Success); + Color_Map.Insert(To_Unbounded_String("Blue"), 20, Color_Cursor, Success); + Color_Map.Insert(To_Unbounded_String("Yellow"), 5, Color_Cursor, Success); + + -- retrieve values from the ordered map and print the value and key + -- to the screen + + Value := Color_Map.Element(To_Unbounded_String("Red")); + Ada.Text_Io.Put_Line("Red:" & Integer'Image(Value)); + Value := Color_Map.Element(To_Unbounded_String("Blue")); + Ada.Text_IO.Put_Line("Blue:" & Integer'Image(Value)); + Value := Color_Map.Element(To_Unbounded_String("Yellow")); + Ada.Text_IO.Put_Line("Yellow:" & Integer'Image(Value)); +end Associative_Array; diff --git a/Task/Associative-array-Creation/Aikido/associative-array-creation.aikido b/Task/Associative-array-Creation/Aikido/associative-array-creation.aikido new file mode 100644 index 0000000000..d992621f86 --- /dev/null +++ b/Task/Associative-array-Creation/Aikido/associative-array-creation.aikido @@ -0,0 +1,17 @@ +var names = {} // empty map +names["foo"] = "bar" +names[3] = 4 + +// initialized map +var names2 = {"foo": bar, 3:4} + +// lookup map +var name = names["foo"] +if (typeof(name) == "none") { + println ("not found") +} else { + println (name) +} + +// remove from map +delete names["foo"] diff --git a/Task/Associative-array-Creation/AutoHotkey/associative-array-creation-1.ahk b/Task/Associative-array-Creation/AutoHotkey/associative-array-creation-1.ahk new file mode 100644 index 0000000000..b3ab03a6b0 --- /dev/null +++ b/Task/Associative-array-Creation/AutoHotkey/associative-array-creation-1.ahk @@ -0,0 +1,3 @@ +associative_array := {key1: "value 1", "Key with spaces and non-alphanumeric characters !*+": 23} +MsgBox % associative_array["key1"] +. "`n" associative_array["Key with spaces and non-alphanumeric characters !*+"] diff --git a/Task/Associative-array-Creation/AutoHotkey/associative-array-creation-2.ahk b/Task/Associative-array-Creation/AutoHotkey/associative-array-creation-2.ahk new file mode 100644 index 0000000000..acbc2845d5 --- /dev/null +++ b/Task/Associative-array-Creation/AutoHotkey/associative-array-creation-2.ahk @@ -0,0 +1,6 @@ +arrayX1 = first +arrayX2 = second +arrayX3 = foo +arrayX4 = bar +Loop, 4 + Msgbox % arrayX%A_Index% diff --git a/Task/Associative-array-Creation/Clojure/associative-array-creation.clj b/Task/Associative-array-Creation/Clojure/associative-array-creation.clj new file mode 100644 index 0000000000..f23adb56cd --- /dev/null +++ b/Task/Associative-array-Creation/Clojure/associative-array-creation.clj @@ -0,0 +1,3 @@ +{:key "value" + :key2 "value2" + :key3 "value3"} diff --git a/Task/Associative-array-Creation/Erlang/associative-array-creation.erl b/Task/Associative-array-Creation/Erlang/associative-array-creation.erl new file mode 100644 index 0000000000..4bedd4ec7a --- /dev/null +++ b/Task/Associative-array-Creation/Erlang/associative-array-creation.erl @@ -0,0 +1,14 @@ +-module(assoc). +-compile([export_all]). + +test_create() -> + D = dict:new(), + D1 = dict:store(foo,1,D), + D2 = dict:store(bar,2,D1), + print_vals(D2), + print_vals(dict:store(foo,3,D2)). + +print_vals(D) -> + lists:foreach(fun (K) -> + io:format("~p: ~b~n",[K,dict:fetch(K,D)]) + end, dict:fetch_keys(D)). diff --git a/Task/Associative-array-Creation/Forth/associative-array-creation-1.fth b/Task/Associative-array-Creation/Forth/associative-array-creation-1.fth new file mode 100644 index 0000000000..d2173ede05 --- /dev/null +++ b/Task/Associative-array-Creation/Forth/associative-array-creation-1.fth @@ -0,0 +1,21 @@ +: get ( key len table -- data ) \ 0 if not present + search-wordlist if + >body @ + else 0 then ; + +: put ( data key len table -- ) + >r 2dup r@ search-wordlist if + r> drop nip nip + >body ! + else + r> get-current >r set-current \ switch definition word lists + nextname create , + r> set-current + then ; + wordlist constant bar +5 s" alpha" bar put +9 s" beta" bar put +2 s" gamma" bar put +s" alpha" bar get . \ 5 +8 s" Alpha" bar put \ Forth dictionaries are normally case-insensitive +s" alpha" bar get . \ 8 diff --git a/Task/Associative-array-Creation/Forth/associative-array-creation-2.fth b/Task/Associative-array-Creation/Forth/associative-array-creation-2.fth new file mode 100644 index 0000000000..cb97b2a2a7 --- /dev/null +++ b/Task/Associative-array-Creation/Forth/associative-array-creation-2.fth @@ -0,0 +1,19 @@ +include ffl/hct.fs + +\ Create a hash table 'table' in the dictionary with a starting size of 10 + +10 hct-create htable + +\ Insert entries + + 5 s" foo" htable hct-insert +10 s" bar" htable hct-insert +15 s" baz" htable hct-insert + +\ Get entry from the table + +s" bar" htable hct-get [IF] + .( Value:) . cr +[ELSE] + .( Entry not present.) cr +[THEN] diff --git a/Task/Associative-array-Creation/Go/associative-array-creation.go b/Task/Associative-array-Creation/Go/associative-array-creation.go new file mode 100644 index 0000000000..e601819708 --- /dev/null +++ b/Task/Associative-array-Creation/Go/associative-array-creation.go @@ -0,0 +1,16 @@ +// declare a nil map variable, for maps from string to int +var x map[string] int + +// make an empty map +x = make(map[string] int) + +// make an empty map with an initial capacity +x = make(map[string] int, 42) + +// set a value +x["foo"] = 3 + +// make a map with a literal +x = map[string] int { + "foo": 2, "bar": 42, "baz": -1, +} diff --git a/Task/Associative-array-Creation/Haskell/associative-array-creation-1.hs b/Task/Associative-array-Creation/Haskell/associative-array-creation-1.hs new file mode 100644 index 0000000000..722f7709cb --- /dev/null +++ b/Task/Associative-array-Creation/Haskell/associative-array-creation-1.hs @@ -0,0 +1,5 @@ +import Data.Map + +dict = fromList [("key1","val1"), ("key2","val2")] + +ans = Data.Map.lookup "key2" dict -- evaluates to "val2" diff --git a/Task/Associative-array-Creation/Haskell/associative-array-creation-2.hs b/Task/Associative-array-Creation/Haskell/associative-array-creation-2.hs new file mode 100644 index 0000000000..f6204af46c --- /dev/null +++ b/Task/Associative-array-Creation/Haskell/associative-array-creation-2.hs @@ -0,0 +1,3 @@ +dict = [("key1","val1"), ("key2","val2")] + +ans = lookup "key2" dict -- evaluates to Just "val2" diff --git a/Task/Associative-array-Creation/Java/associative-array-creation-1.java b/Task/Associative-array-Creation/Java/associative-array-creation-1.java new file mode 100644 index 0000000000..16719f04f0 --- /dev/null +++ b/Task/Associative-array-Creation/Java/associative-array-creation-1.java @@ -0,0 +1,5 @@ +Map map = new HashMap(); +map.put("foo", 5); +map.put("bar", 10); +map.put("baz", 15); +map.put("foo", 6); diff --git a/Task/Associative-array-Creation/Java/associative-array-creation-2.java b/Task/Associative-array-Creation/Java/associative-array-creation-2.java new file mode 100644 index 0000000000..df0990f161 --- /dev/null +++ b/Task/Associative-array-Creation/Java/associative-array-creation-2.java @@ -0,0 +1,6 @@ +public static Map map = new HashMap(){{ + put("foo", 5); + put("bar", 10); + put("baz", 15); + put("foo", 6); +}}; diff --git a/Task/Associative-array-Creation/Java/associative-array-creation-3.java b/Task/Associative-array-Creation/Java/associative-array-creation-3.java new file mode 100644 index 0000000000..185a2119db --- /dev/null +++ b/Task/Associative-array-Creation/Java/associative-array-creation-3.java @@ -0,0 +1,2 @@ +map.get("foo"); // => 5 +map.get("invalid"); // => null diff --git a/Task/Associative-array-Creation/Java/associative-array-creation-4.java b/Task/Associative-array-Creation/Java/associative-array-creation-4.java new file mode 100644 index 0000000000..c95ea32b1a --- /dev/null +++ b/Task/Associative-array-Creation/Java/associative-array-creation-4.java @@ -0,0 +1,2 @@ +for (String key: map.keySet()) + System.out.println(key); diff --git a/Task/Associative-array-Creation/Java/associative-array-creation-5.java b/Task/Associative-array-Creation/Java/associative-array-creation-5.java new file mode 100644 index 0000000000..891644eaa6 --- /dev/null +++ b/Task/Associative-array-Creation/Java/associative-array-creation-5.java @@ -0,0 +1,2 @@ +for (int value: map.values()) + System.out.println(value); diff --git a/Task/Associative-array-Creation/Java/associative-array-creation-6.java b/Task/Associative-array-Creation/Java/associative-array-creation-6.java new file mode 100644 index 0000000000..a9ca6446b1 --- /dev/null +++ b/Task/Associative-array-Creation/Java/associative-array-creation-6.java @@ -0,0 +1,2 @@ +for (Map.Entry entry: map.entrySet()) + System.out.println(entry.getKey() + " => " + entry.getValue()); diff --git a/Task/Associative-array-Creation/JavaScript/associative-array-creation-1.js b/Task/Associative-array-Creation/JavaScript/associative-array-creation-1.js new file mode 100644 index 0000000000..9841fd5e92 --- /dev/null +++ b/Task/Associative-array-Creation/JavaScript/associative-array-creation-1.js @@ -0,0 +1,14 @@ +var assoc = {}; +assoc['foo'] = 'bar'; +assoc['another-key'] = 3; +assoc.thirdKey = 'we can also do this!'; // dot notation can be used if the property name + // is a valid identifier +assoc[2] = 'the index here is the string "2"'; +assoc[null] = 'this also works'; +assoc[(function(){return 'expr';})()] = 'Can use expressions too'; + +for (var key in assoc) { + if (assoc.hasOwnProperty(key)) { + alert('key:"' + key + '", value:"' + assoc[key] + '"'); + } +} diff --git a/Task/Associative-array-Creation/JavaScript/associative-array-creation-2.js b/Task/Associative-array-Creation/JavaScript/associative-array-creation-2.js new file mode 100644 index 0000000000..1c0a6fcc57 --- /dev/null +++ b/Task/Associative-array-Creation/JavaScript/associative-array-creation-2.js @@ -0,0 +1,4 @@ +var assoc = { + foo: 'bar', + 'another-key': 3 //the key can either be enclosed by quotes or not +}; diff --git a/Task/Associative-array-Creation/JavaScript/associative-array-creation-3.js b/Task/Associative-array-Creation/JavaScript/associative-array-creation-3.js new file mode 100644 index 0000000000..65996e6beb --- /dev/null +++ b/Task/Associative-array-Creation/JavaScript/associative-array-creation-3.js @@ -0,0 +1 @@ +'foo' in assoc // true diff --git a/Task/Associative-array-Creation/Lua/associative-array-creation.lua b/Task/Associative-array-Creation/Lua/associative-array-creation.lua new file mode 100644 index 0000000000..5b4e3c09bf --- /dev/null +++ b/Task/Associative-array-Creation/Lua/associative-array-creation.lua @@ -0,0 +1,4 @@ +hash = {} +hash[ "key-1" ] = "val1" +hash[ "key-2" ] = 1 +hash[ "key-3" ] = {} diff --git a/Task/Associative-array-Creation/PHP/associative-array-creation-1.php b/Task/Associative-array-Creation/PHP/associative-array-creation-1.php new file mode 100644 index 0000000000..e77595cfbf --- /dev/null +++ b/Task/Associative-array-Creation/PHP/associative-array-creation-1.php @@ -0,0 +1,11 @@ +$array = array(); +$array['foo'] = 'bar'; +$array['bar'] = 'foo'; + +echo($array['foo']); // bar +echo($array['moo']); // Undefined index + +//alternative (inline) way +$array2 = array('fruit' => 'apple', + 'price' => 12.96, + 'colour' => 'green'); diff --git a/Task/Associative-array-Creation/PHP/associative-array-creation-2.php b/Task/Associative-array-Creation/PHP/associative-array-creation-2.php new file mode 100644 index 0000000000..531b52722d --- /dev/null +++ b/Task/Associative-array-Creation/PHP/associative-array-creation-2.php @@ -0,0 +1,4 @@ +foreach($array as $key => $value) +{ + echo "Key: $key Value: $value"; +} diff --git a/Task/Associative-array-Creation/Perl/associative-array-creation-1.pl b/Task/Associative-array-Creation/Perl/associative-array-creation-1.pl new file mode 100644 index 0000000000..3936aa4c25 --- /dev/null +++ b/Task/Associative-array-Creation/Perl/associative-array-creation-1.pl @@ -0,0 +1,15 @@ +# using => key does not need to be quoted unless it contains special chars +my %hash = ( + key1 => 'val1', + 'key-2' => 2, + three => -238.83, + 4 => 'val3', +); + +# using , both key and value need to be quoted if containing something non-numeric in nature +my %hash = ( + 'key1', 'val1', + 'key-2', 2, + 'three', -238.83, + 4, 'val3', +); diff --git a/Task/Associative-array-Creation/Perl/associative-array-creation-2.pl b/Task/Associative-array-Creation/Perl/associative-array-creation-2.pl new file mode 100644 index 0000000000..e2bbe568f6 --- /dev/null +++ b/Task/Associative-array-Creation/Perl/associative-array-creation-2.pl @@ -0,0 +1,5 @@ +print $hash{key1}; + +$hash{key1} = 'val1'; + +@hash{'key1', 'three'} = ('val1', -238.83); diff --git a/Task/Associative-array-Creation/Perl/associative-array-creation-3.pl b/Task/Associative-array-Creation/Perl/associative-array-creation-3.pl new file mode 100644 index 0000000000..230ca1a11c --- /dev/null +++ b/Task/Associative-array-Creation/Perl/associative-array-creation-3.pl @@ -0,0 +1,6 @@ +my $hashref = { + key1 => 'val1', + 'key-2' => 2, + three => -238.83, + 4 => 'val3', +} diff --git a/Task/Associative-array-Creation/Perl/associative-array-creation-4.pl b/Task/Associative-array-Creation/Perl/associative-array-creation-4.pl new file mode 100644 index 0000000000..3b001f8baf --- /dev/null +++ b/Task/Associative-array-Creation/Perl/associative-array-creation-4.pl @@ -0,0 +1,5 @@ +print $hash->{key1}; + +$hash->{key1} = 'val1'; + +@hash->{'key1', 'three'} = ('val1', -238.83); diff --git a/Task/Associative-array-Creation/PicoLisp/associative-array-creation.l b/Task/Associative-array-Creation/PicoLisp/associative-array-creation.l new file mode 100644 index 0000000000..dab15cb447 --- /dev/null +++ b/Task/Associative-array-Creation/PicoLisp/associative-array-creation.l @@ -0,0 +1,16 @@ +(put 'A 'foo 5) +(put 'A 'bar 10) +(put 'A 'baz 15) +(put 'A 'foo 20) + +: (get 'A 'bar) +-> 10 + +: (get 'A 'foo) +-> 20 + +: (show 'A) +A NIL + foo 20 + bar 10 + baz 15 diff --git a/Task/Associative-array-Creation/Prolog/associative-array-creation.pro b/Task/Associative-array-Creation/Prolog/associative-array-creation.pro new file mode 100644 index 0000000000..18e7593e65 --- /dev/null +++ b/Task/Associative-array-Creation/Prolog/associative-array-creation.pro @@ -0,0 +1,5 @@ +mymap(key1,value1). +mymap(key2,value2). + +?- mymap(key1,V). + V = value1 diff --git a/Task/Associative-array-Creation/Python/associative-array-creation-1.py b/Task/Associative-array-Creation/Python/associative-array-creation-1.py new file mode 100644 index 0000000000..5b5c715aaf --- /dev/null +++ b/Task/Associative-array-Creation/Python/associative-array-creation-1.py @@ -0,0 +1,4 @@ +hash = dict() # 'dict' is the dictionary type. +hash = dict(red="FF0000", green="00FF00", blue="0000FF") +hash = { 'key1':1, 'key2':2, } +value = hash[key] diff --git a/Task/Associative-array-Creation/Python/associative-array-creation-2.py b/Task/Associative-array-Creation/Python/associative-array-creation-2.py new file mode 100644 index 0000000000..7c7280a4cf --- /dev/null +++ b/Task/Associative-array-Creation/Python/associative-array-creation-2.py @@ -0,0 +1,20 @@ +# empty dictionary +d = {} +d['spam'] = 1 +d['eggs'] = 2 + +# dictionaries with two keys +d1 = {'spam': 1, 'eggs': 2} +d2 = dict(spam=1, eggs=2) + +# dictionaries from tuple list +d1 = dict([('spam', 1), ('eggs', 2)]) +d2 = dict(zip(['spam', 'eggs'], [1, 2])) + +# iterating over keys +for key in d: + print key, d[key] + +# iterating over (key, value) pairs +for key, value in d.iteritems(): + print key, value diff --git a/Task/Associative-array-Creation/Python/associative-array-creation-3.py b/Task/Associative-array-Creation/Python/associative-array-creation-3.py new file mode 100644 index 0000000000..82470a2a2b --- /dev/null +++ b/Task/Associative-array-Creation/Python/associative-array-creation-3.py @@ -0,0 +1 @@ +myDict = { '1': 'a string', 1: 'an integer', 1.0: 'a floating point number', (1,): 'a tuple' } diff --git a/Task/Associative-array-Creation/R/associative-array-creation-1.r b/Task/Associative-array-Creation/R/associative-array-creation-1.r new file mode 100644 index 0000000000..305e5a3117 --- /dev/null +++ b/Task/Associative-array-Creation/R/associative-array-creation-1.r @@ -0,0 +1,3 @@ +> env <- new.env() +> env[["x"]] <- 123 +> env[["x"]] diff --git a/Task/Associative-array-Creation/R/associative-array-creation-10.r b/Task/Associative-array-Creation/R/associative-array-creation-10.r new file mode 100644 index 0000000000..f6ee0d7cba --- /dev/null +++ b/Task/Associative-array-Creation/R/associative-array-creation-10.r @@ -0,0 +1 @@ +> print(names(a)) diff --git a/Task/Associative-array-Creation/R/associative-array-creation-11.r b/Task/Associative-array-Creation/R/associative-array-creation-11.r new file mode 100644 index 0000000000..d60e24765f --- /dev/null +++ b/Task/Associative-array-Creation/R/associative-array-creation-11.r @@ -0,0 +1 @@ +> print(unname(a)) diff --git a/Task/Associative-array-Creation/R/associative-array-creation-2.r b/Task/Associative-array-Creation/R/associative-array-creation-2.r new file mode 100644 index 0000000000..14138302c1 --- /dev/null +++ b/Task/Associative-array-Creation/R/associative-array-creation-2.r @@ -0,0 +1,3 @@ +> index <- "1" +> env[[index]] <- "rainfed hay" +> env[[index]] diff --git a/Task/Associative-array-Creation/R/associative-array-creation-3.r b/Task/Associative-array-Creation/R/associative-array-creation-3.r new file mode 100644 index 0000000000..9d971b893e --- /dev/null +++ b/Task/Associative-array-Creation/R/associative-array-creation-3.r @@ -0,0 +1 @@ +> env[["1"]] diff --git a/Task/Associative-array-Creation/R/associative-array-creation-4.r b/Task/Associative-array-Creation/R/associative-array-creation-4.r new file mode 100644 index 0000000000..94f2b49677 --- /dev/null +++ b/Task/Associative-array-Creation/R/associative-array-creation-4.r @@ -0,0 +1 @@ +> env diff --git a/Task/Associative-array-Creation/R/associative-array-creation-5.r b/Task/Associative-array-Creation/R/associative-array-creation-5.r new file mode 100644 index 0000000000..22ebb2dafd --- /dev/null +++ b/Task/Associative-array-Creation/R/associative-array-creation-5.r @@ -0,0 +1 @@ +> print(env) diff --git a/Task/Associative-array-Creation/R/associative-array-creation-6.r b/Task/Associative-array-Creation/R/associative-array-creation-6.r new file mode 100644 index 0000000000..4ee4dbed2b --- /dev/null +++ b/Task/Associative-array-Creation/R/associative-array-creation-6.r @@ -0,0 +1,2 @@ +> x <- c(hello=1, world=2, "!"=3) +> print(x) diff --git a/Task/Associative-array-Creation/R/associative-array-creation-7.r b/Task/Associative-array-Creation/R/associative-array-creation-7.r new file mode 100644 index 0000000000..df5bd72000 --- /dev/null +++ b/Task/Associative-array-Creation/R/associative-array-creation-7.r @@ -0,0 +1 @@ +> print(names(x)) diff --git a/Task/Associative-array-Creation/R/associative-array-creation-8.r b/Task/Associative-array-Creation/R/associative-array-creation-8.r new file mode 100644 index 0000000000..00322e5ca6 --- /dev/null +++ b/Task/Associative-array-Creation/R/associative-array-creation-8.r @@ -0,0 +1 @@ +print(unname(x)) diff --git a/Task/Associative-array-Creation/R/associative-array-creation-9.r b/Task/Associative-array-Creation/R/associative-array-creation-9.r new file mode 100644 index 0000000000..a9191101fb --- /dev/null +++ b/Task/Associative-array-Creation/R/associative-array-creation-9.r @@ -0,0 +1,2 @@ +> a <- list(a=1, b=2, c=3.14, d="xyz") +> print(a) diff --git a/Task/Associative-array-Creation/REXX/associative-array-creation-1.rexx b/Task/Associative-array-Creation/REXX/associative-array-creation-1.rexx new file mode 100644 index 0000000000..b6684d3977 --- /dev/null +++ b/Task/Associative-array-Creation/REXX/associative-array-creation-1.rexx @@ -0,0 +1,10 @@ +/* Rexx */ + +key0 = '0' +key1 = 'key0' + +stem. = '.' /* Initialize the associative array 'stem' to '.' */ +stem.key1 = 'value0' /* Set a specific key/value pair */ + +Say '' /* Display a value for a key that wasn't set */ +Say '' /* Display a value for a key that was set */ diff --git a/Task/Associative-array-Creation/REXX/associative-array-creation-2.rexx b/Task/Associative-array-Creation/REXX/associative-array-creation-2.rexx new file mode 100644 index 0000000000..85b2f7d7f4 --- /dev/null +++ b/Task/Associative-array-Creation/REXX/associative-array-creation-2.rexx @@ -0,0 +1,27 @@ +/*REXX program shows how to set/display values for an associative array.*/ +/*β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ The (below) two REXX statements aren't really necessary, but it β”‚ + β”‚ shows how to define any and all entries in a associative array so β”‚ + β”‚ that if a "key" is used that isn't defined, it can be displayed to β”‚ + β”‚ indicate such, or its value can be checked to determine if a β”‚ + β”‚ particular associative array element has been set (defined). β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜*/ +stateC.=' [not defined yet] ' /*sets any/all state capitols. */ +stateN.=' [not defined yet] ' /*sets any/all state names. */ +/*β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ In REXX, when a "key" is used, it's normally stored (internally) β”‚ + β”‚ as uppercase characters (as in the examples below). Actually, any β”‚ + β”‚ characters can be used, including blank(s) and non-displayable β”‚ + β”‚ characters (including '00'x, 'ff'x, commas, periods, quotes, ...).β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜*/ +stateC.ca='Sacramento'; stateN.ca='California' +stateC.nd='Bismarck' ; stateN.nd='North Dakota' +stateC.mn='St. Paul' ; stateN.mn='Minnesota' +stateC.dc='Washington'; stateN.dc='District of Columbia' +stateC.ri='Providence'; stateN.ri='Rhode Island and Providence Plantations + +say 'capital of California is' stateC.ca +say 'capital of Oklahoma is' stateC.ok +yyy='RI' +say 'capital of' stateN.yyy "is" stateC.yyy + /*stick a fork in it, we're done.*/ diff --git a/Task/Associative-array-Creation/Racket/associative-array-creation.rkt b/Task/Associative-array-Creation/Racket/associative-array-creation.rkt new file mode 100644 index 0000000000..1eb3f226c8 --- /dev/null +++ b/Task/Associative-array-Creation/Racket/associative-array-creation.rkt @@ -0,0 +1,13 @@ +#lang racket + +;; a-lists +(define a-list '((a . 5) (b . 10))) +(assoc a-list 'a) ; => '(a . 5) + +;; hash tables +(define table #hash((a . 5) (b . 10))) +(hash-ref table 'a) ; => 5 + +;; dictionary interface +(dict-ref a-list 'a) ; => 5 +(dict-ref table 'a) ; => 5 diff --git a/Task/Associative-array-Creation/Ruby/associative-array-creation-1.rb b/Task/Associative-array-Creation/Ruby/associative-array-creation-1.rb new file mode 100644 index 0000000000..9f48d2c3bf --- /dev/null +++ b/Task/Associative-array-Creation/Ruby/associative-array-creation-1.rb @@ -0,0 +1,4 @@ +hash={} +hash[666]='devil' +hash[777] # => nil +hash[666] # => 'devil' diff --git a/Task/Associative-array-Creation/Ruby/associative-array-creation-2.rb b/Task/Associative-array-Creation/Ruby/associative-array-creation-2.rb new file mode 100644 index 0000000000..d5675631b3 --- /dev/null +++ b/Task/Associative-array-Creation/Ruby/associative-array-creation-2.rb @@ -0,0 +1,4 @@ +hash=Hash.new('unknown key') +hash[666]='devil' +hash[777] # => 'unknown key' +hash[666] # => 'devil' diff --git a/Task/Associative-array-Creation/Ruby/associative-array-creation-3.rb b/Task/Associative-array-Creation/Ruby/associative-array-creation-3.rb new file mode 100644 index 0000000000..bfa5209187 --- /dev/null +++ b/Task/Associative-array-Creation/Ruby/associative-array-creation-3.rb @@ -0,0 +1,4 @@ +hash=Hash.new{|h,k| "unknown key #{k}"} +hash[666]='devil' +hash[777] # => 'unknown key 777' +hash[666] # => 'devil' diff --git a/Task/Associative-array-Creation/Ruby/associative-array-creation-4.rb b/Task/Associative-array-Creation/Ruby/associative-array-creation-4.rb new file mode 100644 index 0000000000..04c06c5c84 --- /dev/null +++ b/Task/Associative-array-Creation/Ruby/associative-array-creation-4.rb @@ -0,0 +1,4 @@ +hash=Hash.new{|h,k|h[k]="key #{k} was added at #{Time.now}"} +hash[777] # => 'key 777 was added at Sun Apr 03 13:49:57 -0700 2011' +hash[555] # => 'key 555 was added at Sun Apr 03 13:50:01 -0700 2011' +hash[777] # => 'key 777 was added at Sun Apr 03 13:49:57 -0700 2011' diff --git a/Task/Associative-array-Creation/Sather/associative-array-creation.sa b/Task/Associative-array-Creation/Sather/associative-array-creation.sa new file mode 100644 index 0000000000..42f1dc4ce7 --- /dev/null +++ b/Task/Associative-array-Creation/Sather/associative-array-creation.sa @@ -0,0 +1,20 @@ +class MAIN is + main is + -- creation of a map between strings and integers + map ::= #MAP{STR, INT}; + + -- add some values + map := map.insert("red", 0xff0000); + map := map.insert("green", 0xff00); + map := map.insert("blue", 0xff); + + #OUT + map + "\n"; -- show the map... + + -- test if "indexes" exist + #OUT + map.has_ind("red") + "\n"; + #OUT + map.has_ind("carpet") + "\n"; + + -- retrieve a value by index + #OUT + map["green"] + "\n"; + end; +end; diff --git a/Task/Associative-array-Creation/Scala/associative-array-creation-1.scala b/Task/Associative-array-Creation/Scala/associative-array-creation-1.scala new file mode 100644 index 0000000000..9a9628b1a6 --- /dev/null +++ b/Task/Associative-array-Creation/Scala/associative-array-creation-1.scala @@ -0,0 +1,6 @@ +// immutable maps +var map = Map(1 -> 2, 3 -> 4, 5 -> 6) +map(3) // 4 +map = map + (44 -> 99) // maps are immutable, so we have to assign the result of adding elements +map.isDefinedAt(33) // false +map.isDefinedAt(44) // true diff --git a/Task/Associative-array-Creation/Scala/associative-array-creation-2.scala b/Task/Associative-array-Creation/Scala/associative-array-creation-2.scala new file mode 100644 index 0000000000..338ba44fe7 --- /dev/null +++ b/Task/Associative-array-Creation/Scala/associative-array-creation-2.scala @@ -0,0 +1,10 @@ +// mutable maps (HashSets) +import scala.collection.mutable.HashMap +val hash = new HashMap[int, int] +hash(1) = 2 +hash += (1 -> 2) // same as hash(1) = 2 +hash += (3 -> 4, 5 -> 6, 44 -> 99) +hash(44) // 99 +hash.contains(33) // false +hash.isDefinedAt(33) // same as contains +hash.contains(44) // true diff --git a/Task/Associative-array-Creation/Scala/associative-array-creation-3.scala b/Task/Associative-array-Creation/Scala/associative-array-creation-3.scala new file mode 100644 index 0000000000..116ea4ff99 --- /dev/null +++ b/Task/Associative-array-Creation/Scala/associative-array-creation-3.scala @@ -0,0 +1,4 @@ +// iterate over key/value +hash.foreach {e => println("key "+e._1+" value "+e._2)} // e is a 2 element Tuple +// same with for syntax +for((k,v) <- hash) println("key " + k + " value " + v) diff --git a/Task/Associative-array-Creation/Scala/associative-array-creation-4.scala b/Task/Associative-array-Creation/Scala/associative-array-creation-4.scala new file mode 100644 index 0000000000..ae824156c6 --- /dev/null +++ b/Task/Associative-array-Creation/Scala/associative-array-creation-4.scala @@ -0,0 +1,4 @@ +// items in map where the key is greater than 3 +map.filter {k => k._1 > 3} // Map(5 -> 6, 44 -> 99) +// same with for syntax +for((k, v) <- map; if k > 3) yield (k,v) diff --git a/Task/Associative-array-Creation/Scheme/associative-array-creation-1.ss b/Task/Associative-array-Creation/Scheme/associative-array-creation-1.ss new file mode 100644 index 0000000000..6744346ca3 --- /dev/null +++ b/Task/Associative-array-Creation/Scheme/associative-array-creation-1.ss @@ -0,0 +1,2 @@ +(define my-dict '((a b) (1 hello) ("c" (a b c))) +(assoc 'a my-dict) ; evaluates to '(a b) diff --git a/Task/Associative-array-Creation/Scheme/associative-array-creation-2.ss b/Task/Associative-array-Creation/Scheme/associative-array-creation-2.ss new file mode 100644 index 0000000000..218e920a73 --- /dev/null +++ b/Task/Associative-array-Creation/Scheme/associative-array-creation-2.ss @@ -0,0 +1,2 @@ +(define my-alist '((a b) (1 hello) ("c" (a b c))) +(define my-hash (alist->hash-table my-alist)) diff --git a/Task/Associative-array-Creation/Smalltalk/associative-array-creation.st b/Task/Associative-array-Creation/Smalltalk/associative-array-creation.st new file mode 100644 index 0000000000..a325db3dfd --- /dev/null +++ b/Task/Associative-array-Creation/Smalltalk/associative-array-creation.st @@ -0,0 +1,3 @@ +states := Dictionary new. +states at: 'MI' put: 'Michigan'. +states at: 'MN' put: 'Minnesota'. diff --git a/Task/Associative-array-Creation/Tcl/associative-array-creation-1.tcl b/Task/Associative-array-Creation/Tcl/associative-array-creation-1.tcl new file mode 100644 index 0000000000..a80a632a45 --- /dev/null +++ b/Task/Associative-array-Creation/Tcl/associative-array-creation-1.tcl @@ -0,0 +1,17 @@ +# Create one element at a time: +set hash(foo) 5 + +# Create in bulk: +array set hash { + foo 5 + bar 10 + baz 15 +} + +# Access one element: +set value $hash(foo) + +# Output all values: +foreach key [array names hash] { + puts $hash($key) +} diff --git a/Task/Associative-array-Creation/Tcl/associative-array-creation-2.tcl b/Task/Associative-array-Creation/Tcl/associative-array-creation-2.tcl new file mode 100644 index 0000000000..6f6f273972 --- /dev/null +++ b/Task/Associative-array-Creation/Tcl/associative-array-creation-2.tcl @@ -0,0 +1,20 @@ +# Create in bulk +set d [dict create foo 5 bar 10 baz 15] + +# Create/update one element +dict set d foo 5 + +# Access one value +set value [dict get $d foo] + +# Output all values +dict for {key value} $d { + puts $value +} +# Alternatively... +foreach value [dict values $d] { + puts $value +} + +# Output the whole dictionary (since it is a Tcl value itself) +puts $d diff --git a/Task/Associative-array-Iteration/0DESCRIPTION b/Task/Associative-array-Iteration/0DESCRIPTION new file mode 100644 index 0000000000..d3719df9a0 --- /dev/null +++ b/Task/Associative-array-Iteration/0DESCRIPTION @@ -0,0 +1,3 @@ +Show how to iterate over the key-value pairs of an associative array, and print each pair out. Also show how to iterate just over the keys, or the values, if there is a separate way to do that in your language. + +* Related task: [[Associative arrays/Creation]] diff --git a/Task/Associative-array-Iteration/1META.yaml b/Task/Associative-array-Iteration/1META.yaml new file mode 100644 index 0000000000..d6d17d994e --- /dev/null +++ b/Task/Associative-array-Iteration/1META.yaml @@ -0,0 +1,5 @@ +--- +category: +- Iteration +- Data Structures +note: Basic language learning diff --git a/Task/Associative-array-Iteration/AWK/associative-array-iteration.awk b/Task/Associative-array-Iteration/AWK/associative-array-iteration.awk new file mode 100644 index 0000000000..588a75f0e3 --- /dev/null +++ b/Task/Associative-array-Iteration/AWK/associative-array-iteration.awk @@ -0,0 +1,10 @@ +BEGIN { + a["hello"] = 1 + a["world"] = 2 + a["!"] = 3 + + # iterate over keys + for(key in a) { + print key, a[key] + } +} diff --git a/Task/Associative-array-Iteration/Ada/associative-array-iteration.ada b/Task/Associative-array-Iteration/Ada/associative-array-iteration.ada new file mode 100644 index 0000000000..c5924c49cc --- /dev/null +++ b/Task/Associative-array-Iteration/Ada/associative-array-iteration.ada @@ -0,0 +1,19 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Containers.Indefinite_Ordered_Maps; + +procedure Test_Iteration is + package String_Maps is + new Ada.Containers.Indefinite_Ordered_Maps (String, Integer); + use String_Maps; + A : Map; + Index : Cursor; +begin + A.Insert ("hello", 1); + A.Insert ("world", 2); + A.Insert ("!", 3); + Index := A.First; + while Index /= No_Element loop + Put_Line (Key (Index) & Integer'Image (Element (Index))); + Index := Next (Index); + end loop; +end Test_Iteration; diff --git a/Task/Associative-array-Iteration/AutoHotkey/associative-array-iteration.ahk b/Task/Associative-array-Iteration/AutoHotkey/associative-array-iteration.ahk new file mode 100644 index 0000000000..17425190ff --- /dev/null +++ b/Task/Associative-array-Iteration/AutoHotkey/associative-array-iteration.ahk @@ -0,0 +1,6 @@ +; Create an associative array +obj := Object("red", 0xFF0000, "blue", 0x0000FF, "green", 0x00FF00) +enum := obj._NewEnum() +While enum[key, value] + t .= key "=" value "`n" +MsgBox % t diff --git a/Task/Associative-array-Iteration/Clojure/associative-array-iteration.clj b/Task/Associative-array-Iteration/Clojure/associative-array-iteration.clj new file mode 100644 index 0000000000..112d89a51c --- /dev/null +++ b/Task/Associative-array-Iteration/Clojure/associative-array-iteration.clj @@ -0,0 +1,8 @@ +(doseq [[k v] {:a 1, :b 2, :c 3}] + (println k "=" v)) + +(doseq [k (keys {:a 1, :b 2, :c 3})] + (println k)) + +(doseq [v (vals {:a 1, :b 2, :c 3})] + (println v)) diff --git a/Task/Associative-array-Iteration/CoffeeScript/associative-array-iteration.coffee b/Task/Associative-array-Iteration/CoffeeScript/associative-array-iteration.coffee new file mode 100644 index 0000000000..2fa3cc3764 --- /dev/null +++ b/Task/Associative-array-Iteration/CoffeeScript/associative-array-iteration.coffee @@ -0,0 +1,9 @@ +hash = + a: 'one' + b: 'two' + +for key, value of hash + console.log key, value + +for key of hash + console.log key diff --git a/Task/Associative-array-Iteration/Erlang/associative-array-iteration.erl b/Task/Associative-array-Iteration/Erlang/associative-array-iteration.erl new file mode 100644 index 0000000000..69db458a18 --- /dev/null +++ b/Task/Associative-array-Iteration/Erlang/associative-array-iteration.erl @@ -0,0 +1,13 @@ +-module(assoc). +-compile([export_all]). + +test_create() -> + D = dict:new(), + D1 = dict:store(foo,1,D), + D2 = dict:store(bar,2,D1), + print_vals(D2). + +print_vals(D) -> + lists:foreach(fun (K) -> + io:format("~p: ~b~n",[K,dict:fetch(K,D)]) + end, dict:fetch_keys(D)). diff --git a/Task/Associative-array-Iteration/Forth/associative-array-iteration.fth b/Task/Associative-array-Iteration/Forth/associative-array-iteration.fth new file mode 100644 index 0000000000..92cb4e78fc --- /dev/null +++ b/Task/Associative-array-Iteration/Forth/associative-array-iteration.fth @@ -0,0 +1,22 @@ +include ffl/hct.fs +include ffl/hci.fs + +\ Create hashtable and iterator in dictionary +10 hct-create htable +htable hci-create hiter + +\ Insert entries +1 s" hello" htable hct-insert +2 s" world" htable hct-insert +3 s" !" htable hct-insert + +: iterate + hiter hci-first + BEGIN + WHILE + ." key = " hiter hci-key type ." , value = " . cr + hiter hci-next + REPEAT +; + +iterate diff --git a/Task/Associative-array-Iteration/Go/associative-array-iteration.go b/Task/Associative-array-Iteration/Go/associative-array-iteration.go new file mode 100644 index 0000000000..6ee38dee6e --- /dev/null +++ b/Task/Associative-array-Iteration/Go/associative-array-iteration.go @@ -0,0 +1,19 @@ +myMap := map[string]int { + "hello": 13, + "world": 31, + "!" : 71 } + +// iterating over key-value pairs: +for key, value := range myMap { + fmt.Printf("key = %s, value = %d\n", key, value) +} + +// iterating over keys: +for key := range myMap { + fmt.Printf("key = %s\n", key) +} + +// iterating over values: +for _, value := range myMap { + fmt.Printf("value = %d\n", value) +} diff --git a/Task/Associative-array-Iteration/Haskell/associative-array-iteration.hs b/Task/Associative-array-Iteration/Haskell/associative-array-iteration.hs new file mode 100644 index 0000000000..0fcb893a72 --- /dev/null +++ b/Task/Associative-array-Iteration/Haskell/associative-array-iteration.hs @@ -0,0 +1,10 @@ +import qualified Data.Map as M + +myMap = M.fromList [("hello", 13), ("world", 31), ("!", 71)] + +main = do -- pairs + print $ M.toList myMap + -- keys + print $ M.keys myMap + -- values + print $ M.elems myMap diff --git a/Task/Associative-array-Iteration/Java/associative-array-iteration.java b/Task/Associative-array-Iteration/Java/associative-array-iteration.java new file mode 100644 index 0000000000..f26d7ef0ce --- /dev/null +++ b/Task/Associative-array-Iteration/Java/associative-array-iteration.java @@ -0,0 +1,21 @@ +Map myDict = new HashMap(); +myDict.put("hello", 1); +myDict.put("world", 2); +myDict.put("!", 3); + +// iterating over key-value pairs: +for (Map.Entry e : myDict.entrySet()) { + String key = e.getKey(); + Integer value = e.getValue(); + System.out.println("key = " + key + ", value = " + value); +} + +// iterating over keys: +for (String key : myDict.keySet()) { + System.out.println("key = " + key); +} + +// iterating over values: +for (Integer value : myDict.values()) { + System.out.println("value = " + value); +} diff --git a/Task/Associative-array-Iteration/JavaScript/associative-array-iteration-1.js b/Task/Associative-array-Iteration/JavaScript/associative-array-iteration-1.js new file mode 100644 index 0000000000..dde320f541 --- /dev/null +++ b/Task/Associative-array-Iteration/JavaScript/associative-array-iteration-1.js @@ -0,0 +1,15 @@ +var myhash = {}; // a new, empty object +myhash["hello"] = 3; +myhash.world = 6; // obj.name is equivalent to obj["name"] for certain values of name +myhash["!"] = 9; + +var output = '', // initialise as string + key; +for (key in myhash) { + if (myhash.hasOwnProperty(key)) { + output += "key is: " + key; + output += " => "; + output += "value is: " + myhash[key]; // cannot use myhash.key, that would be myhash["key"] + output += "\n"; + } +} diff --git a/Task/Associative-array-Iteration/JavaScript/associative-array-iteration-2.js b/Task/Associative-array-Iteration/JavaScript/associative-array-iteration-2.js new file mode 100644 index 0000000000..89939bf103 --- /dev/null +++ b/Task/Associative-array-Iteration/JavaScript/associative-array-iteration-2.js @@ -0,0 +1,13 @@ +var myhash = {}; // a new, empty object +myhash["hello"] = 3; +myhash.world = 6; // obj.name is equivalent to obj["name"] for certain values of name +myhash["!"] = 9; + +var output = '', // initialise as string + val; +for (val in myhash) { + if (myhash.hasOwnProperty(val)) { + output += "myhash['" + val + "'] is: " + myhash[val]; + output += "\n"; + } +} diff --git a/Task/Associative-array-Iteration/Lua/associative-array-iteration.lua b/Task/Associative-array-Iteration/Lua/associative-array-iteration.lua new file mode 100644 index 0000000000..9db20748c5 --- /dev/null +++ b/Task/Associative-array-Iteration/Lua/associative-array-iteration.lua @@ -0,0 +1,8 @@ +local table = { + ["foo"] = "bar", + ["baz"] = 6, + 42 = 7, +} +for key,val in pairs(table) do + print(string.format("%s: %s\n", key, val) +end diff --git a/Task/Associative-array-Iteration/PHP/associative-array-iteration.php b/Task/Associative-array-Iteration/PHP/associative-array-iteration.php new file mode 100644 index 0000000000..30162bd883 --- /dev/null +++ b/Task/Associative-array-Iteration/PHP/associative-array-iteration.php @@ -0,0 +1,20 @@ + 1, + "world" => 2, + "!" => 3 ); + +// iterate over key-value pairs +foreach($pairs as $k => $v) { + echo "(k,v) = ($k, $v)\n"; +} + +// iterate over keys +foreach(array_keys($pairs) as $key) { + echo "key = $key, value = $pairs[$key]\n"; +} + +// iterate over values +foreach($pairs as $value) { + echo "values = $value\n"; +} +?> diff --git a/Task/Associative-array-Iteration/Perl/associative-array-iteration.pl b/Task/Associative-array-Iteration/Perl/associative-array-iteration.pl new file mode 100644 index 0000000000..ff8f4e19f9 --- /dev/null +++ b/Task/Associative-array-Iteration/Perl/associative-array-iteration.pl @@ -0,0 +1,32 @@ +#! /usr/bin/perl +use strict; + +my %pairs = ( "hello" => 13, + "world" => 31, + "!" => 71 ); + +# iterate over pairs + +# Be careful when using each(), however, because it uses a global iterator +# associated with the hash. If you call keys() or values() on the hash in the +# middle of the loop, the each() iterator will be reset to the beginning. If +# you call each() on the hash somewhere in the middle of the loop, it will +# skip over elements for the "outer" each(). Only use each() if you are sure +# that the code inside the loop will not call keys(), values(), or each(). +while ( my ($k, $v) = each %pairs) { + print "(k,v) = ($k, $v)\n"; +} + +# iterate over keys +foreach my $key ( keys %pairs ) { + print "key = $key, value = $pairs{$key}\n"; +} +# or (see note about each() above) +while ( my $key = each %pairs) { + print "key = $key, value = $pairs{$key}\n"; +} + +# iterate over values +foreach my $val ( values %pairs ) { + print "value = $val\n"; +} diff --git a/Task/Associative-array-Iteration/PicoLisp/associative-array-iteration-1.l b/Task/Associative-array-Iteration/PicoLisp/associative-array-iteration-1.l new file mode 100644 index 0000000000..0803d8776c --- /dev/null +++ b/Task/Associative-array-Iteration/PicoLisp/associative-array-iteration-1.l @@ -0,0 +1,12 @@ +(put 'A 'foo 5) +(put 'A 'bar 10) +(put 'A 'baz 15) + +: (getl 'A) # Get the whole property list +-> ((15 . baz) (10 . bar) (5 . foo)) + +: (mapcar cdr (getl 'A)) # Get all keys +-> (baz bar foo) + +: (mapcar car (getl 'A)) # Get all values +-> (15 10 5) diff --git a/Task/Associative-array-Iteration/PicoLisp/associative-array-iteration-2.l b/Task/Associative-array-Iteration/PicoLisp/associative-array-iteration-2.l new file mode 100644 index 0000000000..cf067de1a4 --- /dev/null +++ b/Task/Associative-array-Iteration/PicoLisp/associative-array-iteration-2.l @@ -0,0 +1,12 @@ +(idx 'A (def "foo" 5) T) +(idx 'A (def "bar" 10) T) +(idx 'A (def "baz" 15) T) + +: A # Get the whole tree +-> ("foo" ("bar" NIL "baz")) + +: (idx 'A) # Get all keys +-> ("bar" "baz" "foo") + +: (mapcar val (idx 'A)) # Get all values +-> (10 15 5) diff --git a/Task/Associative-array-Iteration/Python/associative-array-iteration.py b/Task/Associative-array-Iteration/Python/associative-array-iteration.py new file mode 100644 index 0000000000..24c9df434b --- /dev/null +++ b/Task/Associative-array-Iteration/Python/associative-array-iteration.py @@ -0,0 +1,18 @@ +myDict = { "hello": 13, + "world": 31, + "!" : 71 } + +# iterating over key-value pairs: +for key, value in myDict.items(): + print ("key = %s, value = %s" % (key, value)) + +# iterating over keys: +for key in myDict: + print ("key = %s" % key) +# (is a shortcut for:) +for key in myDict.keys(): + print ("key = %s" % key) + +# iterating over values: +for value in myDict.values(): + print ("value = %s" % value) diff --git a/Task/Associative-array-Iteration/R/associative-array-iteration-1.r b/Task/Associative-array-Iteration/R/associative-array-iteration-1.r new file mode 100644 index 0000000000..305e5a3117 --- /dev/null +++ b/Task/Associative-array-Iteration/R/associative-array-iteration-1.r @@ -0,0 +1,3 @@ +> env <- new.env() +> env[["x"]] <- 123 +> env[["x"]] diff --git a/Task/Associative-array-Iteration/R/associative-array-iteration-2.r b/Task/Associative-array-Iteration/R/associative-array-iteration-2.r new file mode 100644 index 0000000000..cc85edb5ec --- /dev/null +++ b/Task/Associative-array-Iteration/R/associative-array-iteration-2.r @@ -0,0 +1,5 @@ +> index <- "1" +> env[[index]] <- "rainfed hay" +> for (name in ls(env)) { ++ cat(sprintf('index=%s, value=%s\n', name, env[[name]])) ++ } diff --git a/Task/Associative-array-Iteration/R/associative-array-iteration-3.r b/Task/Associative-array-Iteration/R/associative-array-iteration-3.r new file mode 100644 index 0000000000..d323466dd2 --- /dev/null +++ b/Task/Associative-array-Iteration/R/associative-array-iteration-3.r @@ -0,0 +1,2 @@ +> x <- c(hello=1, world=2, "!"=3) +> print(x["!"]) diff --git a/Task/Associative-array-Iteration/R/associative-array-iteration-4.r b/Task/Associative-array-Iteration/R/associative-array-iteration-4.r new file mode 100644 index 0000000000..209b30121f --- /dev/null +++ b/Task/Associative-array-Iteration/R/associative-array-iteration-4.r @@ -0,0 +1 @@ +> print(unname(x["!"])) diff --git a/Task/Associative-array-Iteration/R/associative-array-iteration-5.r b/Task/Associative-array-Iteration/R/associative-array-iteration-5.r new file mode 100644 index 0000000000..ef7d4df1c8 --- /dev/null +++ b/Task/Associative-array-Iteration/R/associative-array-iteration-5.r @@ -0,0 +1,2 @@ +> a <- list(a=1, b=2, c=3.14, d="xyz") +> print(a$a) diff --git a/Task/Associative-array-Iteration/R/associative-array-iteration-6.r b/Task/Associative-array-Iteration/R/associative-array-iteration-6.r new file mode 100644 index 0000000000..bb3dbdfce3 --- /dev/null +++ b/Task/Associative-array-Iteration/R/associative-array-iteration-6.r @@ -0,0 +1 @@ +> print(a$d) diff --git a/Task/Associative-array-Iteration/REXX/associative-array-iteration.rexx b/Task/Associative-array-Iteration/REXX/associative-array-iteration.rexx new file mode 100644 index 0000000000..7f69e7efcc --- /dev/null +++ b/Task/Associative-array-Iteration/REXX/associative-array-iteration.rexx @@ -0,0 +1,59 @@ +/*REXX program shows how to set/display values for an associative array.*/ +/*β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ The (below) two REXX statements aren't really necessary, but it β”‚ + β”‚ shows how to define any and all entries in a associative array so β”‚ + β”‚ that if a "key" is used that isn't defined, it can be displayed to β”‚ + β”‚ indicate such, or its value can be checked to determine if it has β”‚ + β”‚ been set. β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜*/ +stateF.=' [not defined yet] ' /*sets any/all state former caps.*/ +stateN.=' [not defined yet] ' /*sets any/all state names. */ +/*β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ In REXX, when a "key" is used, it's normally stored (internally) β”‚ + β”‚ as uppercase characters (as in the examples below). Actually, any β”‚ + β”‚ characters can be used, including blank(s) and non-displayable β”‚ + β”‚ characters (including '00'x, 'ff'x, commas, periods, quotes, ...).β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜*/ +stateL='' /*list of states (empty now). */ + /*nice to be in alphabetic order,*/ + /*they'll be listed in this order*/ + /*With a little more code, they */ + /* could be sorted quite easily.*/ + +call setSC 'al', "Alabama" ,'Tuscaloosa' +call setSC 'ca', "California" ,'Benicia' +call setSC 'co', "Colorado" ,'Denver City' +call setSC 'ct', "Connecticut" ,'Hartford and New Haven (joint)' +call setSC 'de', "Delaware" ,'New-Castle' +call setSC 'ga', "Georgia" ,'Milledgeville' +call setSC 'il', "Illinois" ,'Vandalia' +call setSC 'in', "Indiana" ,'Corydon' +call setSC 'ia', "Iowa" ,'Iowa City' +call setSC 'la', "Louisiana" ,'New Orleans' +call setSC 'me', "Maine" ,'Portland' +call setSC 'mi', "Michigan" ,'Detroit' +call setSC 'ms', "Mississippi" ,'Natchez' +call setSC 'mo', "Missoura" ,'Saint Charles' +call setSC 'mt', "Montana" ,'Virginia City' +call setSC 'ne', "Nebraska" ,'Lancaster' +call setSC 'nh', "New Hampshire" ,'Exeter' +call setSC 'ny', "New York" ,'New York' +call setSC 'nc', "North Carolina" ,'Fayetteville' +call setSC 'oh', "Ohio" ,'Chillicothe' +call setSC 'ok', "Oklahoma" ,'Guthrie' +call setSC 'pa', "Pennsylvania" ,'Lancaster' +call setSC 'sc', "South Carolina" ,'Charlestown' +call setSC 'tn', "Tennessee" ,'Murfreesboro' +call setSC 'vt', "Vermont" ,'Windsor' + + do j=1 for words(stateL) /*list all capitals that were set*/ + q=word(stateL,j) + say 'the former capital of ('q")" stateN.q "was" stateC.q + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────setSC subroutine─────────────────*/ +setSC: arg code; parse arg ,name,cap /*get upper code, get name & cap.*/ +stateL=stateL code /*keep a list of all state codes.*/ +stateN.code=name /*set the state's name. */ +stateC.code=cap /*set the state's capital. */ +return diff --git a/Task/Associative-array-Iteration/Racket/associative-array-iteration.rkt b/Task/Associative-array-Iteration/Racket/associative-array-iteration.rkt new file mode 100644 index 0000000000..a3880a30c8 --- /dev/null +++ b/Task/Associative-array-Iteration/Racket/associative-array-iteration.rkt @@ -0,0 +1,10 @@ +#lang racket + +(define dict1 #hash((apple . 5) (orange . 10))) ; hash table +(define dict2 '((apple . 5) (orange . 10))) ; a-list +(define dict3 (vector "a" "b" "c")) ; vector (integer keys) + +(dict-keys dict1) ; => '(orange apple) +(dict-values dict2) ; => '(5 10) +(for/list ([(k v) (in-dict dict3)]) ; => '("0 -> a" "1 -> b" "2 -> c") + (format "~a -> ~a" k v)) diff --git a/Task/Associative-array-Iteration/Ruby/associative-array-iteration.rb b/Task/Associative-array-Iteration/Ruby/associative-array-iteration.rb new file mode 100644 index 0000000000..b834f88bc2 --- /dev/null +++ b/Task/Associative-array-Iteration/Ruby/associative-array-iteration.rb @@ -0,0 +1,14 @@ +myDict = { "hello" => 13, + "world" => 31, + "!" => 71 } + +# iterating over key-value pairs: +myDict.each {|key, value| puts "key = #{key}, value = #{value}"} +# or +myDict.each_pair {|key, value| puts "key = #{key}, value = #{value}"} + +# iterating over keys: +myDict.each_key {|key| puts "key = #{key}"} + +# iterating over values: +myDict.each_value {|value| puts "value =#{value}"} diff --git a/Task/Associative-array-Iteration/Scala/associative-array-iteration.scala b/Task/Associative-array-Iteration/Scala/associative-array-iteration.scala new file mode 100644 index 0000000000..4f0e16724b --- /dev/null +++ b/Task/Associative-array-Iteration/Scala/associative-array-iteration.scala @@ -0,0 +1,13 @@ +val m=Map("Hello"->13, "world"->31, "!"->71) + +println("Keys:") +m.keys foreach println + +println("\nValues:") +m.values foreach println + +println("\nPairs:") +m foreach println + +println("\nKey->Value:") +for((k,v)<-m) println(k+"->"+v) diff --git a/Task/Associative-array-Iteration/Smalltalk/associative-array-iteration-1.st b/Task/Associative-array-Iteration/Smalltalk/associative-array-iteration-1.st new file mode 100644 index 0000000000..6e804b2aac --- /dev/null +++ b/Task/Associative-array-Iteration/Smalltalk/associative-array-iteration-1.st @@ -0,0 +1,18 @@ +|pairs| +pairs := Dictionary + from: { 'hello' -> 1. 'world' -> 2. '!' -> 3. 'another!' -> 3 }. + +"iterate over keys and values" +pairs keysAndValuesDo: [ :k :v | + ('(k, v) = (%1, %2)' % { k. v }) displayNl +]. + +"iterate over keys" +pairs keysDo: [ :key | + ('key = %1, value = %2' % { key. pairs at: key }) displayNl +]. + +"iterate over values" +pairs do: [ :value | + ('value = %1' % { value }) displayNl +]. diff --git a/Task/Associative-array-Iteration/Smalltalk/associative-array-iteration-2.st b/Task/Associative-array-Iteration/Smalltalk/associative-array-iteration-2.st new file mode 100644 index 0000000000..18d0b36443 --- /dev/null +++ b/Task/Associative-array-Iteration/Smalltalk/associative-array-iteration-2.st @@ -0,0 +1,2 @@ +(pairs keys) do: [ :k | "..." ]. +(pairs values) do: [ :v | "..." ]. diff --git a/Task/Associative-array-Iteration/Tcl/associative-array-iteration-1.tcl b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-1.tcl new file mode 100644 index 0000000000..191b6d0205 --- /dev/null +++ b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-1.tcl @@ -0,0 +1,16 @@ +array set myAry { + # list items here... +} + +# Iterate over keys and values +foreach {key value} [array get myAry] { + puts "$key -> $value" +} + +# Iterate over just keys +foreach key [array names myAry] { + puts "key = $key" +} + +# There is nothing for directly iterating over just the values +# Use the keys+values version and ignore the keys diff --git a/Task/Associative-array-Iteration/Tcl/associative-array-iteration-2.tcl b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-2.tcl new file mode 100644 index 0000000000..0c64d363c4 --- /dev/null +++ b/Task/Associative-array-Iteration/Tcl/associative-array-iteration-2.tcl @@ -0,0 +1,16 @@ +set myDict [dict create ...]; # Make the dictionary + +# Iterate over keys and values +dict for {key value} $myDict { + puts "$key -> $value" +} + +# Iterate over keys +foreach key [dict keys $myDict] { + puts "key = $key" +} + +# Iterate over values +foreach value [dict values $myDict] { + puts "value = $value" +} diff --git a/Task/Atomic-updates/0DESCRIPTION b/Task/Atomic-updates/0DESCRIPTION new file mode 100644 index 0000000000..4bbea2d6f8 --- /dev/null +++ b/Task/Atomic-updates/0DESCRIPTION @@ -0,0 +1,16 @@ +Define a data type consisting of a fixed number of 'buckets', each containing a nonnegative integer value, which supports operations to +# get the current value of any bucket +# remove a specified amount from one specified bucket and add it to another, preserving the total of all bucket values, and [[wp:Clamping (graphics)|clamping]] the transferred amount to ensure the values remain nonnegative + +---- + +In order to exercise this data type, create one set of buckets, and start three concurrent tasks: +# As often as possible, pick two buckets and make their values closer to equal. +# As often as possible, pick two buckets and arbitrarily redistribute their values. +# At whatever rate is convenient, display (by any means) the total value and, optionally, the individual values of each bucket. + +The display task need not be explicit; use of e.g. a debugger or trace tool is acceptable provided it is simple to set up to provide the display. + +---- + +This task is intended as an exercise in ''atomic'' operations. The sum of the bucket values must be preserved even if the two tasks attempt to perform transfers simultaneously, and a straightforward solution is to ensure that at any time, only one transfer is actually occurring β€” that the transfer operation is ''atomic''. diff --git a/Task/Atomic-updates/1META.yaml b/Task/Atomic-updates/1META.yaml new file mode 100644 index 0000000000..0ff53e9fd2 --- /dev/null +++ b/Task/Atomic-updates/1META.yaml @@ -0,0 +1,4 @@ +--- +note: Concurrency +requires: +- Concurrency diff --git a/Task/Atomic-updates/Ada/atomic-updates.ada b/Task/Atomic-updates/Ada/atomic-updates.ada new file mode 100644 index 0000000000..f70251bbd0 --- /dev/null +++ b/Task/Atomic-updates/Ada/atomic-updates.ada @@ -0,0 +1,85 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Numerics.Discrete_Random; + +procedure Test_Updates is + + type Bucket_Index is range 1..13; + package Random_Index is new Ada.Numerics.Discrete_Random (Bucket_Index); + use Random_Index; + type Buckets is array (Bucket_Index) of Natural; + + protected type Safe_Buckets is + procedure Initialize (Value : Buckets); + function Get (I : Bucket_Index) return Natural; + procedure Transfer (I, J : Bucket_Index; Amount : Integer); + function Snapshot return Buckets; + private + Data : Buckets := (others => 0); + end Safe_Buckets; + + protected body Safe_Buckets is + procedure Initialize (Value : Buckets) is + begin + Data := Value; + end Initialize; + + function Get (I : Bucket_Index) return Natural is + begin + return Data (I); + end Get; + + procedure Transfer (I, J : Bucket_Index; Amount : Integer) is + Increment : constant Integer := + Integer'Max (-Data (J), Integer'Min (Data (I), Amount)); + begin + Data (I) := Data (I) - Increment; + Data (J) := Data (J) + Increment; + end Transfer; + + function Snapshot return Buckets is + begin + return Data; + end Snapshot; + end Safe_Buckets; + + Data : Safe_Buckets; + + task Equalize; + task Mess_Up; + + task body Equalize is + Dice : Generator; + I, J : Bucket_Index; + begin + loop + I := Random (Dice); + J := Random (Dice); + Data.Transfer (I, J, (Data.Get (I) - Data.Get (J)) / 2); + end loop; + end Equalize; + + task body Mess_Up is + Dice : Generator; + begin + loop + Data.Transfer (Random (Dice), Random (Dice), 100); + end loop; + end Mess_Up; + +begin + Data.Initialize ((1,2,3,4,5,6,7,8,9,10,11,12,13)); + loop + delay 1.0; + declare + State : Buckets := Data.Snapshot; + Sum : Natural := 0; + begin + for Index in State'Range loop + Sum := Sum + State (Index); + Put (Integer'Image (State (Index))); + end loop; + Put (" =" & Integer'Image (Sum)); + New_Line; + end; + end loop; +end Test_Updates; diff --git a/Task/Atomic-updates/C/atomic-updates-1.c b/Task/Atomic-updates/C/atomic-updates-1.c new file mode 100644 index 0000000000..0eb59f730b --- /dev/null +++ b/Task/Atomic-updates/C/atomic-updates-1.c @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include +#include + +#define N_BUCKETS 15 + +pthread_mutex_t bucket_mutex[N_BUCKETS]; +int buckets[N_BUCKETS]; + +pthread_t equalizer; +pthread_t randomizer; + +void transfer_value(int from, int to, int howmuch) +{ + bool swapped = false; + + if ( (from == to) || ( howmuch < 0 ) || + (from < 0 ) || (to < 0) || (from >= N_BUCKETS) || (to >= N_BUCKETS) ) return; + + if ( from > to ) { + int temp1 = from; + from = to; + to = temp1; + swapped = true; + howmuch = -howmuch; + } + + pthread_mutex_lock(&bucket_mutex[from]); + pthread_mutex_lock(&bucket_mutex[to]); + + if ( howmuch > buckets[from] && !swapped ) + howmuch = buckets[from]; + if ( -howmuch > buckets[to] && swapped ) + howmuch = -buckets[to]; + + buckets[from] -= howmuch; + buckets[to] += howmuch; + + pthread_mutex_unlock(&bucket_mutex[from]); + pthread_mutex_unlock(&bucket_mutex[to]); +} + +void print_buckets() +{ + int i; + int sum=0; + + for(i=0; i < N_BUCKETS; i++) pthread_mutex_lock(&bucket_mutex[i]); + for(i=0; i < N_BUCKETS; i++) { + printf("%3d ", buckets[i]); + sum += buckets[i]; + } + printf("= %d\n", sum); + for(i=0; i < N_BUCKETS; i++) pthread_mutex_unlock(&bucket_mutex[i]); +} + +void *equalizer_start(void *t) +{ + for(;;) { + int b1 = rand()%N_BUCKETS; + int b2 = rand()%N_BUCKETS; + int diff = buckets[b1] - buckets[b2]; + if ( diff < 0 ) + transfer_value(b2, b1, -diff/2); + else + transfer_value(b1, b2, diff/2); + } + return NULL; +} + +void *randomizer_start(void *t) +{ + for(;;) { + int b1 = rand()%N_BUCKETS; + int b2 = rand()%N_BUCKETS; + int diff = rand()%(buckets[b1]+1); + transfer_value(b1, b2, diff); + } + return NULL; +} + +int main() +{ + int i, total=0; + + for(i=0; i < N_BUCKETS; i++) pthread_mutex_init(&bucket_mutex[i], NULL); + + for(i=0; i < N_BUCKETS; i++) { + buckets[i] = rand() % 100; + total += buckets[i]; + printf("%3d ", buckets[i]); + } + printf("= %d\n", total); + + // we should check if these succeeded + pthread_create(&equalizer, NULL, equalizer_start, NULL); + pthread_create(&randomizer, NULL, randomizer_start, NULL); + + for(;;) { + sleep(1); + print_buckets(); + } + + // we do not provide a "good" way to stop this run, so the following + // is never reached indeed... + for(i=0; i < N_BUCKETS; i++) pthread_mutex_destroy(bucket_mutex+i); + return EXIT_SUCCESS; +} diff --git a/Task/Atomic-updates/C/atomic-updates-2.c b/Task/Atomic-updates/C/atomic-updates-2.c new file mode 100644 index 0000000000..f324acdf8d --- /dev/null +++ b/Task/Atomic-updates/C/atomic-updates-2.c @@ -0,0 +1,51 @@ +#include +#include +#include + +#define irand(n) (n * (double)rand()/(RAND_MAX + 1.0)) + +int bucket[10]; +int main() +{ + int i; + for (i = 0; i < 10; i++) bucket[i] = 1000; + omp_set_num_threads(3); + + #pragma omp parallel private(i) + for (i = 0; i < 10000; i++) { + int from, to, mode, diff = 0, sum; + + from = irand(10); + do { to = irand(10); } while (from == to); + mode = irand(10); + + switch (mode) { + case 0: + case 1: + case 2: /* equalize */ + diff = (bucket[from] - bucket[to]) / 2; + break; + + case 3: /* report */ + sum = 0; + for (int j = 0; j < 10; j++) { + printf("%d ", bucket[j]); + sum += bucket[j]; + } + printf(" Sum: %d\n", sum); + continue; + + default: /* random transfer */ + diff = irand(bucket[from]); + break; + } + + #pragma omp critical + { + bucket[from] -= diff; + bucket[to] += diff; + } + } + + return 0; +} diff --git a/Task/Atomic-updates/C/atomic-updates-3.c b/Task/Atomic-updates/C/atomic-updates-3.c new file mode 100644 index 0000000000..e17f7eff82 --- /dev/null +++ b/Task/Atomic-updates/C/atomic-updates-3.c @@ -0,0 +1,8 @@ +1000 1000 1000 1798 1000 1000 1000 1000 202 1000 Sum: 10000 +595 800 2508 2750 470 1209 283 314 601 470 Sum: 10000 +5 521 3339 1656 351 1038 1656 54 508 872 Sum: 10000 +. +. +. +752 490 385 2118 1503 508 384 509 1110 2241 Sum: 10000 +752 823 385 2118 1544 508 10 509 1110 2241 Sum: 10000 diff --git a/Task/Atomic-updates/Clojure/atomic-updates-1.clj b/Task/Atomic-updates/Clojure/atomic-updates-1.clj new file mode 100644 index 0000000000..1dcf00641c --- /dev/null +++ b/Task/Atomic-updates/Clojure/atomic-updates-1.clj @@ -0,0 +1,7 @@ +(defn xfer [m from to amt] + (let [{f-bal from t-bal to} m + f-bal (- f-bal amt) + t-bal (+ t-bal amt)] + (if (or (neg? f-bal) (neg? t-bal)) + (throw (IllegalArgumentException. "Call results in negative balance.")) + (assoc m from f-bal to t-bal)))) diff --git a/Task/Atomic-updates/Clojure/atomic-updates-2.clj b/Task/Atomic-updates/Clojure/atomic-updates-2.clj new file mode 100644 index 0000000000..e3ae5d3edb --- /dev/null +++ b/Task/Atomic-updates/Clojure/atomic-updates-2.clj @@ -0,0 +1,2 @@ +(def *data* (atom {:a 100 :b 100})) ;; *data* is an atom holding a map +(swap! *data* xfer :a :b 50) ;; atomically results in *data* holding {:a 50 :b 150} diff --git a/Task/Atomic-updates/Clojure/atomic-updates-3.clj b/Task/Atomic-updates/Clojure/atomic-updates-3.clj new file mode 100644 index 0000000000..05b7bd0667 --- /dev/null +++ b/Task/Atomic-updates/Clojure/atomic-updates-3.clj @@ -0,0 +1,22 @@ +(defn equalize [m a b] + (let [{a-val a b-val b} m + diff (- a-val b-val) + amt (/ diff 2)] + (xfer m a b amt))) + +(defn randomize [m a b] + (let [{a-val a b-val b} m + min-val (min a-val b-val) + amt (rand-int (- min-val) min-val)] + (xfer m a b amt))) + +(defn test-conc [f data a b n name] + (dotimes [i n] + (swap! data f a b) + (println (str "total is " (reduce + (vals @data)) " after " name " iteration " i)))) + +(def thread-eq (Thread. #(test-conc equalize *data* :a :b 1000 "equalize"))) +(def thread-rand (Thread. #(test-conc randomize *data* :a :b 1000 "randomize"))) + +(.start thread-eq) +(.start thread-rand) diff --git a/Task/Atomic-updates/Go/atomic-updates-1.go b/Task/Atomic-updates/Go/atomic-updates-1.go new file mode 100644 index 0000000000..51fb590d98 --- /dev/null +++ b/Task/Atomic-updates/Go/atomic-updates-1.go @@ -0,0 +1,106 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +// Data type required by task. +type bucketList interface { + // Two operations required by task. Updater parameter not specified + // by task, but useful for displaying update counts as an indication + // that transfer operations are happening "as often as possible." + bucketValue(bucket int) int + transfer(b1, b2, ammount, updater int) + + // Operation not specified by task, but needed for synchronization. + snapshot(bucketValues []int, transferCounts []int) + + // Operation not specified by task, but useful. + buckets() int // number of buckets +} + +// Total of all bucket values, declared as a const to demonstrate that +// it doesn't change. +const originalTotal = 1000 + +// Updater ids, used for maintaining transfer counts. +const ( + idOrder = iota + idChaos + nUpdaters +) + +func main() { + // Create a concrete object implementing the bucketList interface. + bl := newChList(10, originalTotal, nUpdaters) + + // Three concurrent tasks. + go order(bl) + go chaos(bl) + buddha(bl) +} + +// The concurrent tasks exercise the data operations by going through +// the bucketList interface. They do no explicit synchronization and +// are not responsible for maintaining invariants. + +// Exercise (1.) required by task: make values more equal. +func order(bl bucketList) { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + nBuckets := bl.buckets() + for { + b1 := r.Intn(nBuckets) + b2 := r.Intn(nBuckets) + v1 := bl.bucketValue(b1) + v2 := bl.bucketValue(b2) + if v1 > v2 { + bl.transfer(b1, b2, (v1-v2)/2, idOrder) + } else { + bl.transfer(b2, b1, (v2-v1)/2, idOrder) + } + } +} + +// Exercise (2.) required by task: redistribute values. +func chaos(bl bucketList) { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + nBuckets := bl.buckets() + for { + b1 := r.Intn(nBuckets) + b2 := r.Intn(nBuckets) + bl.transfer(b1, b2, r.Intn(bl.bucketValue(b1)+1), idChaos) + } +} + +// Exercise (3.) requred by task: display total. +func buddha(bl bucketList) { + nBuckets := bl.buckets() + s := make([]int, nBuckets) + tc := make([]int, nUpdaters) + var total, nTicks int + + fmt.Println("sum ---updates--- mean buckets") + tr := time.Tick(time.Second / 10) + for { + var sum int + <-tr + bl.snapshot(s, tc) + for _, l := range s { + if l < 0 { + panic("sob") // invariant not preserved + } + sum += l + } + // Output number of updates per tick and cummulative mean + // updates per tick to demonstrate "as often as possible" + // of task exercises 1 and 2. + total += tc[0] + tc[1] + nTicks++ + fmt.Printf("%d %6d %6d %7d %v\n", sum, tc[0], tc[1], total/nTicks, s) + if sum != originalTotal { + panic("weep") // invariant not preserved + } + } +} diff --git a/Task/Atomic-updates/Go/atomic-updates-2.go b/Task/Atomic-updates/Go/atomic-updates-2.go new file mode 100644 index 0000000000..d80d7558b1 --- /dev/null +++ b/Task/Atomic-updates/Go/atomic-updates-2.go @@ -0,0 +1,78 @@ +// chList (ch for channel-synchronized) is a concrete type implementing +// the bucketList interface. The bucketList interface declared methods, +// the struct type here declares data. chList methods are repsonsible +// for synchronization so they are goroutine-safe. They are also +// responsible for maintaining the invariants that the sum of all buckets +// stays constant and that no bucket value goes negative. +type chList struct { + b []int // bucket data specified by task + s chan bool // syncronization object + tc []int // a transfer count for each updater +} + +// Constructor. +func newChList(nBuckets, initialSum, nUpdaters int) *chList { + bl := &chList{ + b: make([]int, nBuckets), + s: make(chan bool, 1), + tc: make([]int, nUpdaters), + } + // Distribute initialSum across buckets. + for i, dist := nBuckets, initialSum; i > 0; { + v := dist / i + i-- + bl.b[i] = v + dist -= v + } + // Synchronization is needed to maintain the invariant that the total + // of all bucket values stays the same. This is an implementation of + // the straightforward solution mentioned in the task description, + // ensuring that only one transfer happens at a time. Channel s + // holds a token. All methods must take the token from the channel + // before accessing data and then return the token when they are done. + // it is equivalent to a mutex. The constructor makes data available + // by initially dropping the token in the channel after all data is + // initialized. + bl.s <- true + return bl +} + +// Four methods implementing the bucketList interface. +func (bl *chList) bucketValue(b int) int { + <-bl.s // get token before accessing data + r := bl.b[b] + bl.s <- true // return token + return r +} + +func (bl *chList) transfer(b1, b2, a int, ux int) { + if b1 == b2 { // null operation + return + } + // Get access. + <-bl.s + // Clamping maintains invariant that bucket values remain nonnegative. + if a > bl.b[b1] { + a = bl.b[b1] + } + // Transfer. + bl.b[b1] -= a + bl.b[b2] += a + bl.tc[ux]++ // increment transfer count + // Release "lock". + bl.s <- true +} + +func (bl *chList) snapshot(s []int, tc []int) { + <-bl.s + copy(s, bl.b) + copy(tc, bl.tc) + for i := range bl.tc { + bl.tc[i] = 0 + } + bl.s <- true +} + +func (bl *chList) buckets() int { + return len(bl.b) +} diff --git a/Task/Atomic-updates/Go/atomic-updates-3.go b/Task/Atomic-updates/Go/atomic-updates-3.go new file mode 100644 index 0000000000..43122a777d --- /dev/null +++ b/Task/Atomic-updates/Go/atomic-updates-3.go @@ -0,0 +1,83 @@ +// rwList, rw is for RWMutex-synchronized. +type rwList struct { + b []int // bucket data specified by task + + // Syncronization objects. + m []sync.Mutex // mutex for each bucket + all sync.RWMutex // mutex for entire list, for snapshot operation + + tc []int // a transfer count for each updater +} + +// Constructor. +func newRwList(nBuckets, initialSum, nUpdaters int) *rwList { + bl := &rwList{ + b: make([]int, nBuckets), + m: make([]sync.Mutex, nBuckets), + tc: make([]int, nUpdaters), + } + for i, dist := nBuckets, initialSum; i > 0; { + v := dist / i + i-- + bl.b[i] = v + dist -= v + } + return bl +} + +// Four methods implementing the bucketList interface. +func (bl *rwList) bucketValue(b int) int { + bl.m[b].Lock() // lock on bucket ensures read is atomic + r := bl.b[b] + bl.m[b].Unlock() + return r +} + +func (bl *rwList) transfer(b1, b2, a int, ux int) { + if b1 == b2 { // null operation + return + } + // RLock on list allows other simultaneous transfers. + bl.all.RLock() + // Locking lowest bucket first prevents deadlock + // with multiple tasks working at the same time. + if b1 < b2 { + bl.m[b1].Lock() + bl.m[b2].Lock() + } else { + bl.m[b2].Lock() + bl.m[b1].Lock() + } + // clamp + if a > bl.b[b1] { + a = bl.b[b1] + } + // transfer + bl.b[b1] -= a + bl.b[b2] += a + bl.tc[ux]++ // increment transfer count + // release + bl.m[b1].Unlock() + bl.m[b2].Unlock() + bl.all.RUnlock() + // With current Go, the program can hang without a call to gosched here. + // It seems that functions in the sync package don't touch the scheduler, + // (which is good) but we need to touch it here to give the channel + // operations in buddha a chance to run. (The current Go scheduler + // is basically cooperative rather than preemptive.) + runtime.Gosched() +} + +func (bl *rwList) snapshot(s []int, tc []int) { + bl.all.Lock() // RW lock on list prevents transfers during snap. + copy(s, bl.b) + copy(tc, bl.tc) + for i := range bl.tc { + bl.tc[i] = 0 + } + bl.all.Unlock() +} + +func (bl *rwList) buckets() int { + return len(bl.b) +} diff --git a/Task/Atomic-updates/Go/atomic-updates-4.go b/Task/Atomic-updates/Go/atomic-updates-4.go new file mode 100644 index 0000000000..116370294f --- /dev/null +++ b/Task/Atomic-updates/Go/atomic-updates-4.go @@ -0,0 +1,63 @@ +// lf for lock-free +type lfList struct { + b []int32 + sync.RWMutex + tc []int +} + +// Constructor. +func newLfList(nBuckets, initialSum, nUpdaters int) *lfList { + bl := &lfList{ + b: make([]int32, nBuckets), + tc: make([]int, nUpdaters), + } + for i, dist := int32(nBuckets), int32(initialSum); i > 0; { + v := dist / i + i-- + bl.b[i] = v + dist -= v + } + return bl +} + +// Four methods implementing the bucketList interface. +func (bl *lfList) bucketValue(b int) int { + return int(atomic.LoadInt32(&bl.b[b])) +} + +func (bl *lfList) transfer(b1, b2, a int, ux int) { + if b1 == b2 { + return + } + bl.RLock() + for { + t := int32(a) + v1 := atomic.LoadInt32(&bl.b[b1]) + if t > v1 { + t = v1 + } + if atomic.CompareAndSwapInt32(&bl.b[b1], v1, v1-t) { + atomic.AddInt32(&bl.b[b2], t) + break + } + // else retry + } + bl.tc[ux]++ + bl.RUnlock() + runtime.Gosched() +} + +func (bl *lfList) snapshot(s []int, tc []int) { + bl.Lock() + for i, bv := range bl.b { + s[i] = int(bv) + } + for i := range bl.tc { + tc[i], bl.tc[i] = bl.tc[i], 0 + } + bl.Unlock() +} + +func (bl *lfList) buckets() int { + return len(bl.b) +} diff --git a/Task/Atomic-updates/Go/atomic-updates-5.go b/Task/Atomic-updates/Go/atomic-updates-5.go new file mode 100644 index 0000000000..b50439a4a0 --- /dev/null +++ b/Task/Atomic-updates/Go/atomic-updates-5.go @@ -0,0 +1,109 @@ +// mnList (mn for monitor-synchronized) is a concrete type implementing +// the bucketList interface. The monitor is a goroutine, all communication +// with it is done through channels, which are the members of mnList. +// All data implementing the buckets is encapsulated in the monitor. +type mnList struct { + vrCh chan *valueReq + trCh chan *transferReq + srCh chan *snapReq + nbCh chan chan int +} + +// Constructor makes channels and starts monitor. +func newMnList(nBuckets, initialSum, nUpdaters int) *mnList { + mn := &mnList{ + make(chan *valueReq), + make(chan *transferReq), + make(chan *snapReq), + make(chan chan int), + } + go monitor(mn, nBuckets, initialSum, nUpdaters) + return mn +} + +// Monitor goroutine ecapsulates data and enters a loop to handle requests. +// The loop handles one request at a time, thus serializing all access. +func monitor(mn *mnList, nBuckets, initialSum, nUpdaters int) { + // bucket representation + b := make([]int, nBuckets) + for i, dist := nBuckets, initialSum; i > 0; { + v := dist / i + i-- + b[i] = v + dist -= v + } + // transfer count representation + count := make([]int, nUpdaters) + + // monitor loop + for { + select { + // value request operation + case vr := <-mn.vrCh: + vr.resp <- b[vr.bucket] + + // transfer operation + case tr := <-mn.trCh: + // clamp + if tr.amount > b[tr.from] { + tr.amount = b[tr.from] + } + // transfer + b[tr.from] -= tr.amount + b[tr.to] += tr.amount + count[tr.updaterId]++ + + // snap operation + case sr := <-mn.srCh: + copy(sr.bucketSnap, b) + copy(sr.countSnap, count) + for i := range count { + count[i] = 0 + } + sr.resp <- true + + // number of buckets + case nb := <-mn.nbCh: + nb <- nBuckets + } + } +} + +type valueReq struct { + bucket int + resp chan int +} + +func (mn *mnList) bucketValue(b int) int { + resp := make(chan int) + mn.vrCh <- &valueReq{b, resp} + return <-resp +} + +type transferReq struct { + from, to int + amount int + updaterId int +} + +func (mn *mnList) transfer(b1, b2, a, ux int) { + mn.trCh <- &transferReq{b1, b2, a, ux} +} + +type snapReq struct { + bucketSnap []int + countSnap []int + resp chan bool +} + +func (mn *mnList) snapshot(s []int, tc []int) { + resp := make(chan bool) + mn.srCh <- &snapReq{s, tc, resp} + <-resp +} + +func (mn *mnList) buckets() int { + resp := make(chan int) + mn.nbCh <- resp + return <-resp +} diff --git a/Task/Atomic-updates/Haskell/atomic-updates.hs b/Task/Atomic-updates/Haskell/atomic-updates.hs new file mode 100644 index 0000000000..caf45cad8a --- /dev/null +++ b/Task/Atomic-updates/Haskell/atomic-updates.hs @@ -0,0 +1,69 @@ +module AtomicUpdates (main) where + +import Control.Concurrent (forkIO, threadDelay) +import Control.Concurrent.MVar (MVar, newMVar, readMVar, modifyMVar_) +import Control.Monad (forever, forM_) +import Data.IntMap (IntMap, (!), toAscList, fromList, adjust) +import System.Random (randomRIO) +import Text.Printf (printf) + +------------------------------------------------------------------------------- + +type Index = Int +type Value = Integer +data Buckets = Buckets Index (MVar (IntMap Value)) + +makeBuckets :: Int -> IO Buckets +size :: Buckets -> Index +currentValue :: Buckets -> Index -> IO Value +currentValues :: Buckets -> IO (IntMap Value) +transfer :: Buckets -> Index -> Index -> Value -> IO () + +------------------------------------------------------------------------------- + +makeBuckets n = do v <- newMVar (fromList [(i, 100) | i <- [1..n]]) + return (Buckets n v) + +size (Buckets n _) = n + +currentValue (Buckets _ v) i = fmap (! i) (readMVar v) +currentValues (Buckets _ v) = readMVar v + +transfer b@(Buckets n v) i j amt | amt < 0 = transfer b j i (-amt) + | otherwise = do + modifyMVar_ v $ \map -> let amt' = min amt (map ! i) + in return $ adjust (subtract amt') i + $ adjust (+ amt') j + $ map + +------------------------------------------------------------------------------- + +roughen, smooth, display :: Buckets -> IO () + +pick buckets = randomRIO (1, size buckets) + +roughen buckets = forever loop where + loop = do i <- pick buckets + j <- pick buckets + iv <- currentValue buckets i + transfer buckets i j (iv `div` 3) + +smooth buckets = forever loop where + loop = do i <- pick buckets + j <- pick buckets + iv <- currentValue buckets i + jv <- currentValue buckets j + transfer buckets i j ((iv - jv) `div` 4) + +display buckets = forever loop where + loop = do threadDelay 1000000 + bmap <- currentValues buckets + putStrLn (report $ map snd $ toAscList bmap) + report list = "\nTotal: " ++ show (sum list) ++ "\n" ++ bars + where bars = concatMap row $ map (*40) $ reverse [1..5] + row lim = printf "%3d " lim ++ [if x >= lim then '*' else ' ' | x <- list] ++ "\n" + +main = do buckets <- makeBuckets 100 + forkIO (roughen buckets) + forkIO (smooth buckets) + display buckets diff --git a/Task/Atomic-updates/Java/atomic-updates.java b/Task/Atomic-updates/Java/atomic-updates.java new file mode 100644 index 0000000000..60b0c18c33 --- /dev/null +++ b/Task/Atomic-updates/Java/atomic-updates.java @@ -0,0 +1,119 @@ +import java.util.Arrays; +import java.util.Random; + +public class AtomicUpdates +{ + public static class Buckets + { + private final int[] data; + + public Buckets(int[] data) + { + this.data = data.clone(); + } + + public int getBucket(int index) + { + synchronized (data) + { return data[index]; } + } + + public int transfer(int srcBucketIndex, int destBucketIndex, int amount) + { + if (amount == 0) + return 0; + // Negative transfers will happen in the opposite direction + if (amount < 0) + { + int tempIndex = srcBucketIndex; + srcBucketIndex = destBucketIndex; + destBucketIndex = tempIndex; + amount = -amount; + } + synchronized (data) + { + if (amount > data[srcBucketIndex]) + amount = data[srcBucketIndex]; + if (amount <= 0) + return 0; + data[srcBucketIndex] -= amount; + data[destBucketIndex] += amount; + return amount; + } + } + + public int[] getBuckets() + { + synchronized (data) + { return data.clone(); } + } + } + + public static int getTotal(int[] values) + { + int totalValue = 0; + for (int i = values.length - 1; i >= 0; i--) + totalValue += values[i]; + return totalValue; + } + + public static void main(String[] args) + { + final int NUM_BUCKETS = 10; + Random rnd = new Random(); + final int[] values = new int[NUM_BUCKETS]; + for (int i = 0; i < values.length; i++) + values[i] = rnd.nextInt(10); + System.out.println("Initial Array: " + getTotal(values) + " " + Arrays.toString(values)); + final Buckets buckets = new Buckets(values); + + new Thread(new Runnable() { + public void run() + { + Random r = new Random(); + while (true) + { + int srcBucketIndex = r.nextInt(NUM_BUCKETS); + int destBucketIndex = r.nextInt(NUM_BUCKETS); + int amount = (buckets.getBucket(srcBucketIndex) - buckets.getBucket(destBucketIndex)) >> 1; + if (amount != 0) + buckets.transfer(srcBucketIndex, destBucketIndex, amount); + } + } + } + ).start(); + + new Thread(new Runnable() { + public void run() + { + Random r = new Random(); + while (true) + { + int srcBucketIndex = r.nextInt(NUM_BUCKETS); + int destBucketIndex = r.nextInt(NUM_BUCKETS); + int srcBucketAmount = buckets.getBucket(srcBucketIndex); + int destBucketAmount = buckets.getBucket(destBucketIndex); + int amount = r.nextInt(srcBucketAmount + destBucketAmount + 1) - destBucketAmount; + if (amount != 0) + buckets.transfer(srcBucketIndex, destBucketIndex, amount); + } + } + } + ).start(); + + while (true) + { + long nextPrintTime = System.currentTimeMillis() + 3000; + long curTime; + while ((curTime = System.currentTimeMillis()) < nextPrintTime) + { + try + { Thread.sleep(nextPrintTime - curTime); } + catch (InterruptedException e) + { } + } + int[] bucketValues = buckets.getBuckets(); + System.out.println("Current values: " + getTotal(bucketValues) + " " + Arrays.toString(bucketValues)); + } + } +} diff --git a/Task/Atomic-updates/Perl/atomic-updates.pl b/Task/Atomic-updates/Perl/atomic-updates.pl new file mode 100644 index 0000000000..a87e2e6bbe --- /dev/null +++ b/Task/Atomic-updates/Perl/atomic-updates.pl @@ -0,0 +1,52 @@ +use strict; +use 5.10.0; + +use threads 'yield'; +use threads::shared; + +my @a :shared = (100) x 10; +my $stop :shared = 0; + +sub pick2 { + my $i = int(rand(10)); + my $j; + $j = int(rand(10)) until $j != $i; + ($i, $j) +} + +sub even { + lock @a; + my ($i, $j) = pick2; + my $sum = $a[$i] + $a[$j]; + $a[$i] = int($sum / 2); + $a[$j] = $sum - $a[$i]; +} + +sub rand_move { + lock @a; + my ($i, $j) = pick2; + + my $x = int(rand $a[$i]); + $a[$i] -= $x; + $a[$j] += $x; +} + +sub show { + lock @a; + my $sum = 0; + $sum += $_ for (@a); + printf "%4d", $_ for @a; + print " total $sum\n"; +} + +my $t1 = async { even until $stop } +my $t2 = async { rand_move until $stop } +my $t3 = async { + for (1 .. 10) { + show; + sleep(1); + } + $stop = 1; +}; + +$t1->join; $t2->join; $t3->join; diff --git a/Task/Atomic-updates/PicoLisp/atomic-updates.l b/Task/Atomic-updates/PicoLisp/atomic-updates.l new file mode 100644 index 0000000000..916d3b438d --- /dev/null +++ b/Task/Atomic-updates/PicoLisp/atomic-updates.l @@ -0,0 +1,71 @@ +(de *Buckets . 15) # Number of buckets + +# E/R model +(class +Bucket +Entity) +(rel key (+Key +Number)) # Key 1 .. *Buckets +(rel val (+Number)) # Value 1 .. 999 + + +# Start with an empty DB +(call 'rm "-f" "buckets.db") # Remove old DB (if any) +(pool "buckets.db") # Create new DB file + + +# Create *Buckets buckets with values between 1 and 999 +(for K *Buckets + (new T '(+Bucket) 'key K 'val (rand 1 999)) ) +(commit) + + +# Pick a random bucket +(de pickBucket () + (db 'key '+Bucket (rand 1 *Buckets)) ) + + +# First process +(unless (fork) + (seed *Pid) # Ensure local random sequence + (loop + (let (B1 (pickBucket) B2 (pickBucket)) # Pick two buckets 'B1' and 'B2' + (dbSync) # Atomic DB operation + (let (V1 (; B1 val) V2 (; B2 val)) # Get current values + (cond + ((> V1 V2) + (dec> B1 'val) # Make them closer to equal + (inc> B2 'val) ) + ((> V2 V1) + (dec> B2 'val) + (inc> B1 'val) ) ) ) + (commit 'upd) ) ) ) # Close transaction + +# Second process +(unless (fork) + (seed *Pid) # Ensure local random sequence + (loop + (let (B1 (pickBucket) B2 (pickBucket)) # Pick two buckets 'B1' and 'B2' + (unless (== B1 B2) # Found two different ones? + (dbSync) # Atomic DB operation + (let (V1 (; B1 val) V2 (; B2 val)) # Get current values + (cond + ((> V1 V2 0) + (inc> B1 'val) # Redistribute them + (dec> B2 'val) ) + ((> V2 V1 0) + (inc> B2 'val) + (dec> B1 'val) ) ) ) + (commit 'upd) ) ) ) ) # Close transaction + +# Third process +(unless (fork) + (loop + (dbSync) # Atomic DB operation + (let Lst (collect 'key '+Bucket) # Get all buckets + (for This Lst # Print current values + (printsp (: val)) ) + (prinl # and total sum + "-- Total: " + (sum '((This) (: val)) Lst) ) ) + (rollback) + (wait 2000) ) ) # Sleep two seconds + +(wait) diff --git a/Task/Atomic-updates/Python/atomic-updates.py b/Task/Atomic-updates/Python/atomic-updates.py new file mode 100644 index 0000000000..90d1888c83 --- /dev/null +++ b/Task/Atomic-updates/Python/atomic-updates.py @@ -0,0 +1,74 @@ +from __future__ import with_statement # required for Python 2.5 +import threading +import random +import time + +terminate = threading.Event() + +class Buckets: + def __init__(self, nbuckets): + self.nbuckets = nbuckets + self.values = [random.randrange(10) for i in range(nbuckets)] + self.lock = threading.Lock() + + def __getitem__(self, i): + return self.values[i] + + def transfer(self, src, dst, amount): + with self.lock: + amount = min(amount, self.values[src]) + self.values[src] -= amount + self.values[dst] += amount + + def snapshot(self): + # copy of the current state (synchronized) + with self.lock: + return self.values[:] + +def randomize(buckets): + nbuckets = buckets.nbuckets + while not terminate.isSet(): + src = random.randrange(nbuckets) + dst = random.randrange(nbuckets) + if dst!=src: + amount = random.randrange(20) + buckets.transfer(src, dst, amount) + +def equalize(buckets): + nbuckets = buckets.nbuckets + while not terminate.isSet(): + src = random.randrange(nbuckets) + dst = random.randrange(nbuckets) + if dst!=src: + amount = (buckets[src] - buckets[dst]) // 2 + if amount>=0: buckets.transfer(src, dst, amount) + else: buckets.transfer(dst, src, -amount) + +def print_state(buckets): + snapshot = buckets.snapshot() + for value in snapshot: + print '%2d' % value, + print '=', sum(snapshot) + +# create 15 buckets +buckets = Buckets(15) + +# the randomize thread +t1 = threading.Thread(target=randomize, args=[buckets]) +t1.start() + +# the equalize thread +t2 = threading.Thread(target=equalize, args=[buckets]) +t2.start() + +# main thread, display +try: + while True: + print_state(buckets) + time.sleep(1) +except KeyboardInterrupt: # ^C to finish + terminate.set() + +# wait until all worker threads finish +t1.join() +t2.join() diff --git a/Task/Atomic-updates/Ruby/atomic-updates.rb b/Task/Atomic-updates/Ruby/atomic-updates.rb new file mode 100644 index 0000000000..c0935ed7b7 --- /dev/null +++ b/Task/Atomic-updates/Ruby/atomic-updates.rb @@ -0,0 +1,94 @@ +require 'thread' + +# A collection of buckets, filled with random non-negative integers. +# There are atomic operations to look at the bucket contents, and +# to move amounts between buckets. +class BucketStore + + # Creates a BucketStore with +nbuckets+ buckets. Fills each bucket + # with a random non-negative integer. + def initialize nbuckets + # Create an array for the buckets + @buckets = (0...nbuckets).map { rand(1024) } + + # Mutex used to make operations atomic + @mutex = Mutex.new + end + + # Returns an array with the contents of all buckets. + def buckets + @mutex.synchronize { Array.new(@buckets) } + end + + # Transfers _amount_ to bucket at array index _destination_, + # from bucket at array index _source_. + def transfer destination, source, amount + # Do nothing if both buckets are same + return nil if destination == source + + @mutex.synchronize do + # Clamp amount to prevent negative value in bucket + amount = [amount, @buckets[source]].min + + @buckets[source] -= amount + @buckets[destination] += amount + end + nil + end +end + +# Create bucket store +bucket_store = BucketStore.new 8 + +# Get total amount in the store +TOTAL = bucket_store.buckets.inject { |a, b| a += b } + +# Start a thread to equalize buckets +Thread.new do + loop do + # Pick 2 buckets + buckets = bucket_store.buckets + first = rand buckets.length + second = rand buckets.length + + # Swap buckets so that _first_ has not more than _second_ + first, second = second, first if buckets[first] > buckets[second] + + # Transfer half of the difference, rounded down + bucket_store.transfer first, second, (buckets[second] - buckets[first]) / 2 + end +end + +# Start a thread to distribute values among buckets +Thread.new do + loop do + # Pick 2 buckets + buckets = bucket_store.buckets + first = rand buckets.length + second = rand buckets.length + + # Transfer random amount to _first_ from _second_ + bucket_store.transfer first, second, rand(buckets[second]) + end +end + +# Loop to display buckets +loop do + sleep 1 + + buckets = bucket_store.buckets + + # Compute the total value in all buckets. + # We calculate this outside BucketStore so BucketStore can't cheat by + # always reporting the same value. + n = buckets.inject { |a, b| a += b } + + # Display buckets and total + printf "%s, total %d\n", (buckets.map { |v| sprintf "%4d", v }.join " "), n + + if n != TOTAL + # This should never happen + $stderr.puts "ERROR: Total changed from #{TOTAL} to #{n}" + exit 1 + end +end diff --git a/Task/Atomic-updates/Scala/atomic-updates.scala b/Task/Atomic-updates/Scala/atomic-updates.scala new file mode 100644 index 0000000000..82c2c994fa --- /dev/null +++ b/Task/Atomic-updates/Scala/atomic-updates.scala @@ -0,0 +1,75 @@ +object AtomicUpdates { + + class Buckets(ns: Int*) { + + import scala.actors.Actor._ + + val buckets = ns.toArray + + case class Get(index: Int) + case class Transfer(fromIndex: Int, toIndex: Int, amount: Int) + case object GetAll + + val handler = actor { + loop { + react { + case Get(index) => reply(buckets(index)) + case Transfer(fromIndex, toIndex, amount) => + assert(amount >= 0) + val actualAmount = Math.min(amount, buckets(fromIndex)) + buckets(fromIndex) -= actualAmount + buckets(toIndex) += actualAmount + case GetAll => reply(buckets.toList) + } + } + } + + def get(index: Int): Int = (handler !? Get(index)).asInstanceOf[Int] + def transfer(fromIndex: Int, toIndex: Int, amount: Int) = handler ! Transfer(fromIndex, toIndex, amount) + def getAll: List[Int] = (handler !? GetAll).asInstanceOf[List[Int]] + } + + def randomPair(n: Int): (Int, Int) = { + import scala.util.Random._ + val pair = (nextInt(n), nextInt(n)) + if (pair._1 == pair._2) randomPair(n) else pair + } + + def main(args: Array[String]) { + import scala.actors.Scheduler._ + val buckets = new Buckets(List.range(1, 11): _*) + val stop = new java.util.concurrent.atomic.AtomicBoolean(false) + val latch = new java.util.concurrent.CountDownLatch(3) + execute { + while (!stop.get) { + val (i1, i2) = randomPair(10) + val (n1, n2) = (buckets.get(i1), buckets.get(i2)) + val m = (n1 + n2) / 2 + if (n1 < n2) + buckets.transfer(i2, i1, n2 - m) + else + buckets.transfer(i1, i2, n1 - m) + } + latch.countDown + } + execute { + while (!stop.get) { + val (i1, i2) = randomPair(10) + val n = buckets.get(i1) + buckets.transfer(i1, i2, if (n == 0) 0 else scala.util.Random.nextInt(n)) + } + latch.countDown + } + execute { + for (i <- 1 to 20) { + val all = buckets.getAll + println(all.sum + ":" + all) + Thread.sleep(500) + } + stop.set(true) + latch.countDown + } + latch.await + shutdown + } +} diff --git a/Task/Atomic-updates/Tcl/atomic-updates.tcl b/Task/Atomic-updates/Tcl/atomic-updates.tcl new file mode 100644 index 0000000000..ea76cda088 --- /dev/null +++ b/Task/Atomic-updates/Tcl/atomic-updates.tcl @@ -0,0 +1,102 @@ +package require Thread +package require Tk + +# Make the shared state +canvas .c ;# So we can allocate the display lines in one loop +set m [thread::mutex create] +for {set i 0} {$i<100} {incr i} { + set bucket b$i ;# A handle for every bucket... + tsv::set buckets $bucket 50 + lappend buckets $bucket + lappend lines [.c create line 0 0 0 0] +} +tsv::set still going 1 + +# Make the "make more equal" task +lappend tasks [thread::create { + # Perform an atomic update of two cells + proc transfer {b1 b2 val} { + variable m + thread::mutex lock $m + set v [tsv::get buckets $b1] + if {$val > $v} { + set val $v + } + tsv::incr buckets $b1 [expr {-$val}] + tsv::incr buckets $b2 $val + thread::mutex unlock $m + } + + # The task itself; we loop this round frequently + proc task {mutex buckets} { + variable m $mutex b $buckets i 0 + while {[tsv::get still going]} { + set b1 [lindex $b $i] + if {[incr i] == [llength $b]} {set i 0} + set b2 [lindex $b $i] + + if {[tsv::get buckets $b1] > [tsv::get buckets $b2]} { + transfer $b1 $b2 1 + } else { + transfer $b1 $b2 -1 + } + } + } + thread::wait +}] + +# Make the "mess things up" task +lappend tasks [thread::create { + # Utility to pick a random item from a list + proc pick list { + lindex $list [expr {int(rand() * [llength $list])}] + } + proc transfer {b1 b2 val} { + variable m + thread::mutex lock $m + set v [tsv::get buckets $b1] + if {$val > $v} { + set val $v + } + tsv::incr buckets $b1 [expr {-$val}] + tsv::incr buckets $b2 $val + thread::mutex unlock $m + } + + # The task to move a large amount between two random buckets + proc task {mutex buckets} { + variable m $mutex b $buckets + while {[tsv::get still going]} { + set b1 [pick $b] + set b2 [pick $b] + transfer $b1 $b2 [expr {[tsv::get buckets $b1] / 3}] + } + } + thread::wait +}] + +# The "main" task; we keep GUI operations in the main thread +proc redisplay {} { + global m buckets lines + thread::mutex lock $m + set i 1 + foreach b $buckets l $lines { + .c coords $l $i 0 $i [tsv::get buckets $b] + incr i 2 + } + thread::mutex unlock $m + after 100 redisplay +} + +# Start tasks and display +.c configure -width 201 -height 120 +pack .c +redisplay +foreach t $tasks { + thread::send -async $t [list task $m $buckets] +} + +# Wait for user to close window, then tidy up +tkwait window . +tsv::set still going 0 +thread::broadcast thread::exit diff --git a/Task/Average-loop-length/0DESCRIPTION b/Task/Average-loop-length/0DESCRIPTION new file mode 100644 index 0000000000..e2934f7bde --- /dev/null +++ b/Task/Average-loop-length/0DESCRIPTION @@ -0,0 +1,32 @@ +Let f be a uniformly-randomly chosen mapping from the numbers 1..N to the numbers 1..N (note: not necessarily a permutation of 1..N; the mapping could produce a number in more than one way or not at all). At some point, the sequence 1, f(1), f(f(1))... will contain a repetition, a number that occurring for the second time in the sequence. + +Write a program or a script that estimates, for each N, the average length until the first such repetition. + +Also calculate this expected length using an analytical formula, and optionally compare the simulated result with the theoretical one. + +This problem comes from the end of Donald Knuth's [http://www.youtube.com/watch?v=cI6tt9QfRdo Christmas tree lecture 2011]. + +Example of expected output: + +
 N    average    analytical    (error)
+===  =========  ============  =========
+  1     1.0000        1.0000  (  0.00%)
+  2     1.4992        1.5000  (  0.05%)
+  3     1.8784        1.8889  (  0.56%)
+  4     2.2316        2.2188  (  0.58%)
+  5     2.4982        2.5104  (  0.49%)
+  6     2.7897        2.7747  (  0.54%)
+  7     3.0153        3.0181  (  0.09%)
+  8     3.2429        3.2450  (  0.07%)
+  9     3.4536        3.4583  (  0.14%)
+ 10     3.6649        3.6602  (  0.13%)
+ 11     3.8091        3.8524  (  1.12%)
+ 12     3.9986        4.0361  (  0.93%)
+ 13     4.2074        4.2123  (  0.12%)
+ 14     4.3711        4.3820  (  0.25%)
+ 15     4.5275        4.5458  (  0.40%)
+ 16     4.6755        4.7043  (  0.61%)
+ 17     4.8877        4.8579  (  0.61%)
+ 18     4.9951        5.0071  (  0.24%)
+ 19     5.1312        5.1522  (  0.41%)
+ 20     5.2699        5.2936  (  0.45%)
diff --git a/Task/Average-loop-length/Ada/average-loop-length.ada b/Task/Average-loop-length/Ada/average-loop-length.ada new file mode 100644 index 0000000000..09e9455936 --- /dev/null +++ b/Task/Average-loop-length/Ada/average-loop-length.ada @@ -0,0 +1,53 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Numerics.Generic_Elementary_Functions; +with Ada.Numerics.Discrete_Random; +procedure Avglen is + package IIO is new Ada.Text_IO.Integer_IO (Positive); use IIO; + package LFIO is new Ada.Text_IO.Float_IO (Long_Float); use LFIO; + subtype FactN is Natural range 0..20; + TESTS : constant Natural := 1_000_000; + + function Factorial (N : FactN) return Long_Float is + Result : Long_Float := 1.0; + begin + for I in 2..N loop Result := Result * Long_Float(I); end loop; + return Result; + end Factorial; + + function Analytical (N : FactN) return Long_Float is + Sum : Long_Float := 0.0; + begin + for I in 1..N loop + Sum := Sum + Factorial(N) / Factorial(N - I) / Long_Float(N)**I; + end loop; + return Sum; + end Analytical; + + function Experimental (N : FactN) return Long_Float is + subtype RandInt is Natural range 1..N; + package Random is new Ada.Numerics.Discrete_Random(RandInt); + seed : Random.Generator; + Num : RandInt; + count : Natural := 0; + bits : array(RandInt'Range) of Boolean; + begin + Random.Reset(seed); + for run in 1..TESTS loop + bits := (others => false); + for I in RandInt'Range loop + Num := Random.Random(seed); exit when bits(Num); + bits(Num) := True; count := count + 1; + end loop; + end loop; + return Long_Float(count)/Long_Float(TESTS); + end Experimental; + + A, E, err : Long_Float; +begin + Put_Line(" N avg calc %diff"); + for I in 1..20 loop + A := Analytical(I); E := Experimental(I); err := abs(E-A)/A*100.0; + Put(I, Width=>2); Put(E ,Aft=>4, exp=>0); Put(A, Aft=>4, exp=>0); + Put(err, Fore=>3, Aft=>3, exp=>0); New_line; + end loop; +end Avglen; diff --git a/Task/Average-loop-length/C/average-loop-length.c b/Task/Average-loop-length/C/average-loop-length.c new file mode 100644 index 0000000000..fd9f3a9a1b --- /dev/null +++ b/Task/Average-loop-length/C/average-loop-length.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include + +#define MAX_N 20 +#define TIMES 1000000 + +double factorial(int n) { + double f = 1; + int i; + for (i = 1; i <= n; i++) f *= i; + return f; +} + +double expected(int n) { + double sum = 0; + int i; + for (i = 1; i <= n; i++) + sum += factorial(n) / pow(n, i) / factorial(n - i); + return sum; +} + +int randint(int n) { + int r, rmax = RAND_MAX / n * n; + while ((r = rand()) >= rmax); + return r / (RAND_MAX / n); +} + +int test(int n, int times) { + int i, count = 0; + for (i = 0; i < times; i++) { + int x = 1, bits = 0; + while (!(bits & x)) { + count++; + bits |= x; + x = 1 << randint(n); + } + } + return count; +} + +int main(void) { + srand(time(0)); + puts(" n\tavg\texp.\tdiff\n-------------------------------"); + + int n; + for (n = 1; n <= MAX_N; n++) { + int cnt = test(n, TIMES); + double avg = (double)cnt / TIMES; + double theory = expected(n); + double diff = (avg / theory - 1) * 100; + printf("%2d %8.4f %8.4f %6.3f%%\n", n, avg, theory, diff); + } + return 0; +} diff --git a/Task/Average-loop-length/Python/average-loop-length.py b/Task/Average-loop-length/Python/average-loop-length.py new file mode 100644 index 0000000000..0eaa416b7b --- /dev/null +++ b/Task/Average-loop-length/Python/average-loop-length.py @@ -0,0 +1,27 @@ +from __future__ import division # Only necessary for Python 2.X +from math import factorial +from random import randrange + +MAX_N = 20 +TIMES = 1000000 + +def analytical(n): + return sum(factorial(n) / pow(n, i) / factorial(n -i) for i in range(1, n+1)) + +def test(n, times): + count = 0 + for i in range(times): + x, bits = 1, 0 + while not (bits & x): + count += 1 + bits |= x + x = 1 << randrange(n) + return count / times + +if __name__ == '__main__': + print(" n\tavg\texp.\tdiff\n-------------------------------") + for n in range(1, MAX_N+1): + avg = test(n, TIMES) + theory = analytical(n) + diff = (avg / theory - 1) * 100 + print("%2d %8.4f %8.4f %6.3f%%" % (n, avg, theory, diff)) diff --git a/Task/Average-loop-length/REXX/average-loop-length.rexx b/Task/Average-loop-length/REXX/average-loop-length.rexx new file mode 100644 index 0000000000..407576a203 --- /dev/null +++ b/Task/Average-loop-length/REXX/average-loop-length.rexx @@ -0,0 +1,36 @@ +/*REXX program to read a config file and assign VARs as found within. */ +numeric digits 10000 /*be able to calculate !(runs). */ +parse arg runs tests seed . +if runs ==',' | runs =='' then runs = 40 /*num of runs. */ +if tests ==',' | tests =='' then tests = 1000000 /*num of trials.*/ +if seed\==',' & seed\=='' then call random ,,seed /*repeatability?*/ +numeric digits max(9,length(!(runs))) /*set NUMERIC digits for !(runs).*/ +say right( runs, 24) 'runs' /*display # of runs we're using*/ +say right( tests, 24) 'tests' /* " " " tests " " */ +say right( digits(), 24) 'digits' /* " " " digits " " */ +say +say ' N average exact % error' /*headers & pad.*/ +h= ' ─── ───────── ───────── ─────────'; say h; pad=left('',3) + + do #=1 for runs; ##=right(#,9) /*## is used for indenting output*/ + a= format(exact(#) ,,4) /*use 4 digits past decimal point*/ + e= format(exper(#) ,,4) /* " " " " " " */ + err= format(abs(e-a)*100/a ,,4) /* " " " " " " */ + if err=0 then err=err/1 /*present a clean & concise zero.*/ + say ## pad e pad a pad err /*display a line of statistics. */ + end /*#*/ +say h /*display the final header bar. */ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────! subroutine────────────────────────*/ +!: procedure; !=1; do j=2 to arg(1); !=!*j; end; return ! +/*──────────────────────────────────EXACT subroutine────────────────────*/ +exact: parse arg x; s=0; do j=1 for x; s=s+!(x)/!(x-j)/x**j; end; return s +/*──────────────────────────────────EXPER subroutine────────────────────*/ +exper: parse arg n +k=0; do tests; !.=0 /*repeat TESTS times, reset found*/ + !.=0 /*stemmed array: expected results*/ + do n; r=random(1,n); if !.r then leave + !.r=1; k=k+1 /*bump the ctr. */ + end /*n*/ + end /*tests*/ +return k/tests diff --git a/Task/Average-loop-length/Tcl/average-loop-length.tcl b/Task/Average-loop-length/Tcl/average-loop-length.tcl new file mode 100644 index 0000000000..1af4e7cd90 --- /dev/null +++ b/Task/Average-loop-length/Tcl/average-loop-length.tcl @@ -0,0 +1,40 @@ +# Generate a list of the numbers increasing from $a to $b +proc range {a b} { + for {set result {}} {$a <= $b} {incr a} {lappend result $a} + return $result +} + +# Computing the expected value analytically +proc tcl::mathfunc::factorial n { + ::tcl::mathop::* {*}[range 2 $n] +} +proc Analytical {n} { + set sum 0.0 + foreach x [range 1 $n] { + set sum [expr {$sum + factorial($n) / factorial($n-$x) / double($n)**$x}] + } + return $sum +} + +# Determining an approximation to the value experimentally +proc Experimental {n numTests} { + set count 0 + set u0 [lrepeat $n 1] + foreach run [range 1 $numTests] { + set unseen $u0 + for {set i 0} {[lindex $unseen $i]} {incr count} { + lset unseen $i 0 + set i [expr {int(rand()*$n)}] + } + } + return [expr {$count / double($numTests)}] +} + +# Tabulate the results in exactly the original format +puts " N average analytical (error)" +puts "=== ========= ============ =========" +foreach n [range 1 20] { + set a [Analytical $n] + set e [Experimental $n 100000] + puts [format "%3d %9.4f %12.4f (%6.2f%%)" $n $e $a [expr {abs($e-$a)/$a*100.0}]] +} diff --git a/Task/Averages-Arithmetic-mean/0DESCRIPTION b/Task/Averages-Arithmetic-mean/0DESCRIPTION new file mode 100644 index 0000000000..af27762aef --- /dev/null +++ b/Task/Averages-Arithmetic-mean/0DESCRIPTION @@ -0,0 +1,3 @@ +Write a program to find the [[wp:arithmetic mean|mean]] (arithmetic average) of a numeric vector. In case of a zero-length input, since the mean of an empty set of numbers is ill-defined, the program may choose to behave in any way it deems appropriate, though if the programming language has an established convention for conveying math errors or undefined values, it's preferable to follow it. + +See also: [[Median]], [[Mode]] diff --git a/Task/Averages-Arithmetic-mean/1META.yaml b/Task/Averages-Arithmetic-mean/1META.yaml new file mode 100644 index 0000000000..29aeacfd2a --- /dev/null +++ b/Task/Averages-Arithmetic-mean/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Probability and statistics diff --git a/Task/Averages-Arithmetic-mean/6502-Assembly/averages-arithmetic-mean.6502 b/Task/Averages-Arithmetic-mean/6502-Assembly/averages-arithmetic-mean.6502 new file mode 100644 index 0000000000..e5aa6b5510 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/6502-Assembly/averages-arithmetic-mean.6502 @@ -0,0 +1,40 @@ +ArithmeticMean: PHA + TYA + PHA ;push accumulator and Y register onto stack + + + LDA #0 + STA Temp + STA Temp+1 ;temporary 16-bit storage for total + + LDY NumberInts + BEQ Done ;if NumberInts = 0 then return an average of zero + + DEY ;start with NumberInts-1 +AddLoop: LDA (ArrayPtr),Y + CLC + ADC Temp + STA Temp + LDA Temp+1 + ADC #0 + STA Temp+1 + DEY + CPY #255 + BNE AddLoop + + LDY #-1 +DivideLoop: LDA Temp + SEC + SBC NumberInts + STA Temp + LDA Temp+1 + SBC #0 + STA Temp+1 + INY + BCS DivideLoop + +Done: STY ArithMean ;store result here + PLA ;restore accumulator and Y register from stack + TAY + PLA + RTS ;return from routine diff --git a/Task/Averages-Arithmetic-mean/ACL2/averages-arithmetic-mean.acl2 b/Task/Averages-Arithmetic-mean/ACL2/averages-arithmetic-mean.acl2 new file mode 100644 index 0000000000..c4a791a873 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/ACL2/averages-arithmetic-mean.acl2 @@ -0,0 +1,13 @@ +(defun mean-r (xs) + (if (endp xs) + (mv 0 0) + (mv-let (m j) + (mean-r (rest xs)) + (mv (+ (first xs) m) (+ j 1))))) + +(defun mean (xs) + (if (endp xs) + 0 + (mv-let (n d) + (mean-r xs) + (/ n d)))) diff --git a/Task/Averages-Arithmetic-mean/ALGOL-68/averages-arithmetic-mean.alg b/Task/Averages-Arithmetic-mean/ALGOL-68/averages-arithmetic-mean.alg new file mode 100644 index 0000000000..099c5df590 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/ALGOL-68/averages-arithmetic-mean.alg @@ -0,0 +1,13 @@ +PROC mean = (REF[]REAL p)REAL: +# Calculates the mean of qty REALs beginning at p. # + IF LWB p > UPB p THEN 0.0 + ELSE + REAL total := 0.0; + FOR i FROM LWB p TO UPB p DO total +:= p[i] OD; + total / (UPB p - LWB p + 1) + FI; + +main:( + [6]REAL test := (1.0, 2.0, 5.0, -5.0, 9.5, 3.14159); + print((mean(test),new line)) +) diff --git a/Task/Averages-Arithmetic-mean/APL/averages-arithmetic-mean.apl b/Task/Averages-Arithmetic-mean/APL/averages-arithmetic-mean.apl new file mode 100644 index 0000000000..52288e54f5 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/APL/averages-arithmetic-mean.apl @@ -0,0 +1,3 @@ + X←3 1 4 1 5 9 + (+/X)÷⍴X +3.833333333 diff --git a/Task/Averages-Arithmetic-mean/AWK/averages-arithmetic-mean.awk b/Task/Averages-Arithmetic-mean/AWK/averages-arithmetic-mean.awk new file mode 100644 index 0000000000..f168a07097 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/AWK/averages-arithmetic-mean.awk @@ -0,0 +1,27 @@ +# work around a gawk bug in the length extended use: +# so this is a more non-gawk compliant way to get +# how many elements are in an array +function elength(v) +{ + l=0 + for(el in v) l++ + return l +} + +function mean(v) +{ + if (elength(v) < 1) { return 0 } + sum = 0 + for(i=0; i < elength(v); i++) { + sum += v[i] + } + return sum/elength(v) +} + +BEGIN { + # fill a vector with random numbers + for(i=0; i < 10; i++) { + vett[i] = rand()*10 + } + print mean(vett) +} diff --git a/Task/Averages-Arithmetic-mean/ActionScript/averages-arithmetic-mean.as b/Task/Averages-Arithmetic-mean/ActionScript/averages-arithmetic-mean.as new file mode 100644 index 0000000000..ad1251a01c --- /dev/null +++ b/Task/Averages-Arithmetic-mean/ActionScript/averages-arithmetic-mean.as @@ -0,0 +1,7 @@ +function mean(vector:Vector.):Number +{ + var sum:Number = 0; + for(var i:uint = 0; i < vector.length; i++) + sum += vector[i]; + return vector.length == 0 ? 0 : sum / vector.length; +} diff --git a/Task/Averages-Arithmetic-mean/Ada/averages-arithmetic-mean.ada b/Task/Averages-Arithmetic-mean/Ada/averages-arithmetic-mean.ada new file mode 100644 index 0000000000..cf60e1e6ef --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Ada/averages-arithmetic-mean.ada @@ -0,0 +1,25 @@ +with Ada.Float_Text_Io; use Ada.Float_Text_Io; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Mean_Main is + type Vector is array(Positive range <>) of Float; + function Mean(Item : Vector) return Float is + Sum : Float := 0.0; + Result : Float := 0.0; + begin + for I in Item'range loop + Sum := Sum + Item(I); + end loop; + if Item'Length > 0 then + Result := Sum / Float(Item'Length); + end if; + return Result; + end Mean; + A : Vector := (3.0, 1.0, 4.0, 1.0, 5.0, 9.0); +begin + Put(Item => Mean(A), Fore => 1, Exp => 0); + New_Line; + -- test for zero length vector + Put(Item => Mean(A(1..0)), Fore => 1, Exp => 0); + New_Line; +end Mean_Main; diff --git a/Task/Averages-Arithmetic-mean/AmigaE/averages-arithmetic-mean.amiga b/Task/Averages-Arithmetic-mean/AmigaE/averages-arithmetic-mean.amiga new file mode 100644 index 0000000000..15cf754366 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/AmigaE/averages-arithmetic-mean.amiga @@ -0,0 +1,14 @@ +PROC mean(l:PTR TO LONG) + DEF m, i, ll + ll := ListLen(l) + IF ll = 0 THEN RETURN 0.0 + m := 0.0 + FOR i := 0 TO ll-1 DO m := !m + l[i] + m := !m / (ll!) +ENDPROC m + +PROC main() + DEF s[20] : STRING + WriteF('mean \s\n', + RealF(s,mean([1.0, 2.0, 3.0, 4.0, 5.0]), 2)) +ENDPROC diff --git a/Task/Averages-Arithmetic-mean/AutoHotkey/averages-arithmetic-mean.ahk b/Task/Averages-Arithmetic-mean/AutoHotkey/averages-arithmetic-mean.ahk new file mode 100644 index 0000000000..d08d04ec8f --- /dev/null +++ b/Task/Averages-Arithmetic-mean/AutoHotkey/averages-arithmetic-mean.ahk @@ -0,0 +1,7 @@ +i = 10 +Loop, % i { + Random, v, -3.141592, 3.141592 + list .= v "`n" + sum += v +} +MsgBox, % i ? list "`nmean: " sum/i:0 diff --git a/Task/Averages-Arithmetic-mean/BASIC/averages-arithmetic-mean.bas b/Task/Averages-Arithmetic-mean/BASIC/averages-arithmetic-mean.bas new file mode 100644 index 0000000000..52eafac1bc --- /dev/null +++ b/Task/Averages-Arithmetic-mean/BASIC/averages-arithmetic-mean.bas @@ -0,0 +1,12 @@ +mean = 0 +sum = 0; +FOR i = LBOUND(nums) TO UBOUND(nums) + sum = sum + nums(i); +NEXT i +size = UBOUND(nums) - LBOUND(nums) + 1 +PRINT "The mean is: "; +IF size <> 0 THEN + PRINT (sum / size) +ELSE + PRINT 0 +END IF diff --git a/Task/Averages-Arithmetic-mean/Befunge/averages-arithmetic-mean.bf b/Task/Averages-Arithmetic-mean/Befunge/averages-arithmetic-mean.bf new file mode 100644 index 0000000000..d98e5a5668 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Befunge/averages-arithmetic-mean.bf @@ -0,0 +1,3 @@ +0001>p&: #v_$::01g/.@ + ^10+1g10+< +Enter 0 (zero) to finish. diff --git a/Task/Averages-Arithmetic-mean/C/averages-arithmetic-mean.c b/Task/Averages-Arithmetic-mean/C/averages-arithmetic-mean.c new file mode 100644 index 0000000000..a54da41b00 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/C/averages-arithmetic-mean.c @@ -0,0 +1,24 @@ +#include + +double mean(double *v, int len) +{ + double sum = 0; + int i; + for (i = 0; i < len; i++) + sum += v[i]; + return sum / len; +} + +int main(void) +{ + double v[] = {1, 2, 2.718, 3, 3.142}; + int i, len; + for (len = 5; len >= 0; len--) { + printf("mean["); + for (i = 0; i < len; i++) + printf(i ? ", %g" : "%g", v[i]); + printf("] = %g\n", mean(v, len)); + } + + return 0; +} diff --git a/Task/Averages-Arithmetic-mean/Clojure/averages-arithmetic-mean.clj b/Task/Averages-Arithmetic-mean/Clojure/averages-arithmetic-mean.clj new file mode 100644 index 0000000000..158c58a5b0 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Clojure/averages-arithmetic-mean.clj @@ -0,0 +1,6 @@ +(defn mean [sq] + (let [length (count sq)] + (if (zero? length) + 0 + (/ (reduce + sq) length))) +) diff --git a/Task/Averages-Arithmetic-mean/CoffeeScript/averages-arithmetic-mean.coffee b/Task/Averages-Arithmetic-mean/CoffeeScript/averages-arithmetic-mean.coffee new file mode 100644 index 0000000000..22c22979fb --- /dev/null +++ b/Task/Averages-Arithmetic-mean/CoffeeScript/averages-arithmetic-mean.coffee @@ -0,0 +1,7 @@ +mean = (array) -> + return 0 if array.length is 0 + sum = array.reduce (s,i,0) -> s += i + sum / array.length + + +alert mean [1] diff --git a/Task/Averages-Arithmetic-mean/Erlang/averages-arithmetic-mean.erl b/Task/Averages-Arithmetic-mean/Erlang/averages-arithmetic-mean.erl new file mode 100644 index 0000000000..9f9d472c92 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Erlang/averages-arithmetic-mean.erl @@ -0,0 +1,2 @@ +mean([]) -> 0; +mean(L) -> lists:sum(L)/length(L). diff --git a/Task/Averages-Arithmetic-mean/Forth/averages-arithmetic-mean.fth b/Task/Averages-Arithmetic-mean/Forth/averages-arithmetic-mean.fth new file mode 100644 index 0000000000..a2a0596039 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Forth/averages-arithmetic-mean.fth @@ -0,0 +1,10 @@ +: fmean ( addr n -- f ) + 0e + dup 0= if 2drop exit then + tuck floats bounds do + i f@ f+ + 1 floats +loop + 0 d>f f/ ; + +create test 3e f, 1e f, 4e f, 1e f, 5e f, 9e f, +test 6 fmean f. \ 3.83333333333333 diff --git a/Task/Averages-Arithmetic-mean/Fortran/averages-arithmetic-mean.f b/Task/Averages-Arithmetic-mean/Fortran/averages-arithmetic-mean.f new file mode 100644 index 0000000000..147a0fd426 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Fortran/averages-arithmetic-mean.f @@ -0,0 +1,20 @@ +real, target, dimension(100) :: a = (/ (i, i=1, 100) /) +real, dimension(5,20) :: b = reshape( a, (/ 5,20 /) ) +real, pointer, dimension(:) :: p => a(2:1) ! pointer to zero-length array +real :: mean, zmean, bmean +real, dimension(20) :: colmeans +real, dimension(5) :: rowmeans + +mean = sum(a)/size(a) ! SUM of A's elements divided by SIZE of A +mean = sum(a)/max(size(a),1) ! Same result, but safer code + ! MAX of SIZE and 1 prevents divide by zero if SIZE == 0 (zero-length array) + +zmean = sum(p)/max(size(p),1) ! Here the safety check pays off. Since P is a zero-length array, + ! expression becomes "0 / MAX( 0, 1 ) -> 0 / 1 -> 0", rather than "0 / 0 -> NaN" + +bmean = sum(b)/max(size(b),1) ! multidimensional SUM over multidimensional SIZE + +rowmeans = sum(b,1)/max(size(b,2),1) ! SUM elements in each row (dimension 1) + ! dividing by the length of the row, which is the number of columns (SIZE of dimension 2) +colmeans = sum(b,2)/max(size(b,1),1) ! SUM elements in each column (dimension 2) + ! dividing by the length of the column, which is the number of rows (SIZE of dimension 1) diff --git a/Task/Averages-Arithmetic-mean/Go/averages-arithmetic-mean.go b/Task/Averages-Arithmetic-mean/Go/averages-arithmetic-mean.go new file mode 100644 index 0000000000..0099c22783 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Go/averages-arithmetic-mean.go @@ -0,0 +1,65 @@ +package main + +import ( + "fmt" + "math" +) + +func mean(v []float64) (m float64, ok bool) { + if len(v) == 0 { + return + } + // an algorithm that attempts to retain accuracy + // with widely different values. + var parts []float64 + for _, x := range v { + var i int + for _, p := range parts { + sum := p + x + var err float64 + switch ax, ap := math.Abs(x), math.Abs(p); { + case ax < ap: + err = x - (sum - p) + case ap < ax: + err = p - (sum - x) + } + if err != 0 { + parts[i] = err + i++ + } + x = sum + } + parts = append(parts[:i], x) + } + var sum float64 + for _, x := range parts { + sum += x + } + return sum / float64(len(v)), true +} + +func main() { + for _, v := range [][]float64{ + []float64{}, // mean returns ok = false + []float64{math.Inf(1), math.Inf(1)}, // answer is +Inf + + // answer is NaN, and mean returns ok = true, indicating NaN + // is the correct result + []float64{math.Inf(1), math.Inf(-1)}, + + []float64{3, 1, 4, 1, 5, 9}, + + // large magnitude numbers cancel. answer is mean of small numbers. + []float64{1e20, 3, 1, 4, 1, 5, 9, -1e20}, + + []float64{10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, .11}, + []float64{10, 20, 30, 40, 50, -100, 4.7, -11e2}, + } { + fmt.Println("Vector:", v) + if m, ok := mean(v); ok { + fmt.Printf("Mean of %d numbers is %g\n\n", len(v), m) + } else { + fmt.Println("Mean undefined\n") + } + } +} diff --git a/Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-1.hs b/Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-1.hs new file mode 100644 index 0000000000..1a06e94129 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-1.hs @@ -0,0 +1,3 @@ +mean :: (Fractional a) => [a] -> a +mean [] = 0 +mean xs = sum xs / Data.List.genericLength xs diff --git a/Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-2.hs b/Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-2.hs new file mode 100644 index 0000000000..a4ad86b519 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-2.hs @@ -0,0 +1,2 @@ +meanReals :: (Real a, Fractional b) => [a] -> b +meanReals = mean . map realToFrac diff --git a/Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-3.hs b/Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-3.hs new file mode 100644 index 0000000000..d3bd10bf48 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Haskell/averages-arithmetic-mean-3.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE BangPatterns #-} +import Data.List (foldl') +mean :: (Real n, Fractional m) => [n] -> m +mean xs = let (s,l) = foldl' f (0, 0) xs in realToFrac s / l + where f (!s,!l) x = (s+x,l+1) diff --git a/Task/Averages-Arithmetic-mean/Java/averages-arithmetic-mean.java b/Task/Averages-Arithmetic-mean/Java/averages-arithmetic-mean.java new file mode 100644 index 0000000000..4eb4124892 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Java/averages-arithmetic-mean.java @@ -0,0 +1,7 @@ +... +double sum = 0; +for(double i : nums){ + sum += i; +} +System.out.println("The mean is: " + ((nums.length != 0) ? (sum / nums.length) : 0)); +... diff --git a/Task/Averages-Arithmetic-mean/JavaScript/averages-arithmetic-mean-1.js b/Task/Averages-Arithmetic-mean/JavaScript/averages-arithmetic-mean-1.js new file mode 100644 index 0000000000..c526a731c5 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/JavaScript/averages-arithmetic-mean-1.js @@ -0,0 +1,11 @@ +function mean(array) +{ + var sum = 0, i; + for (i = 0; i < array.length; i++) + { + sum += array[i]; + } + return array.length ? sum / array.length : 0; +} + +alert( mean( [1,2,3,4,5] ) ); // 3 diff --git a/Task/Averages-Arithmetic-mean/JavaScript/averages-arithmetic-mean-2.js b/Task/Averages-Arithmetic-mean/JavaScript/averages-arithmetic-mean-2.js new file mode 100644 index 0000000000..8d7acbc6b3 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/JavaScript/averages-arithmetic-mean-2.js @@ -0,0 +1,4 @@ +function mean(a) +{ + return a.length ? Functional.reduce('+', 0, a) / a.length : 0; +} diff --git a/Task/Averages-Arithmetic-mean/Lua/averages-arithmetic-mean.lua b/Task/Averages-Arithmetic-mean/Lua/averages-arithmetic-mean.lua new file mode 100644 index 0000000000..640faaf9bc --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Lua/averages-arithmetic-mean.lua @@ -0,0 +1,8 @@ +function mean (numlist) + if type(numlist) ~= 'table' then return numlist end + num = 0 + table.foreach(numlist,function(i,v) num=num+v end) + return num / #numlist +end + +print (mean({3,1,4,1,5,9})) diff --git a/Task/Averages-Arithmetic-mean/PHP/averages-arithmetic-mean.php b/Task/Averages-Arithmetic-mean/PHP/averages-arithmetic-mean.php new file mode 100644 index 0000000000..5b1b8dd30e --- /dev/null +++ b/Task/Averages-Arithmetic-mean/PHP/averages-arithmetic-mean.php @@ -0,0 +1,5 @@ +$nums = array(3, 1, 4, 1, 5, 9); +if ($nums) + echo array_sum($nums) / count($nums), "\n"; +else + echo "0\n"; diff --git a/Task/Averages-Arithmetic-mean/Perl/averages-arithmetic-mean-1.pl b/Task/Averages-Arithmetic-mean/Perl/averages-arithmetic-mean-1.pl new file mode 100644 index 0000000000..3dbf35d6ae --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Perl/averages-arithmetic-mean-1.pl @@ -0,0 +1,8 @@ +sub avg { + @_ or return 0; + my $sum = 0; + $sum += $_ foreach @_; + return $sum/@_; +} + +print avg(qw(3 1 4 1 5 9)), "\n"; diff --git a/Task/Averages-Arithmetic-mean/Perl/averages-arithmetic-mean-2.pl b/Task/Averages-Arithmetic-mean/Perl/averages-arithmetic-mean-2.pl new file mode 100644 index 0000000000..5c230da3ae --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Perl/averages-arithmetic-mean-2.pl @@ -0,0 +1,5 @@ +use Data::Average; + +my $d = Data::Average->new; +$d->add($_) foreach qw(3 1 4 1 5 9); +print $d->avg, "\n"; diff --git a/Task/Averages-Arithmetic-mean/PicoLisp/averages-arithmetic-mean.l b/Task/Averages-Arithmetic-mean/PicoLisp/averages-arithmetic-mean.l new file mode 100644 index 0000000000..e627f0c881 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/PicoLisp/averages-arithmetic-mean.l @@ -0,0 +1,4 @@ +(de mean (Lst) + (if (atom Lst) + 0 + (/ (apply + Lst) (length Lst)) ) ) diff --git a/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-1.py b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-1.py new file mode 100644 index 0000000000..f6877682f5 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-1.py @@ -0,0 +1,5 @@ +from math import fsum +def average(x): + return fsum(x)/float(len(x)) if x else 0 +print (average([0,0,3,1,4,1,5,9,0,0])) +print (average([1e20,-1e-20,3,1,4,1,5,9,-1e20,1e-20])) diff --git a/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-2.py b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-2.py new file mode 100644 index 0000000000..712eb68080 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-2.py @@ -0,0 +1,2 @@ +2.3 +2.3 diff --git a/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-3.py b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-3.py new file mode 100644 index 0000000000..feae61ecb4 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-3.py @@ -0,0 +1,4 @@ +def average(x): + return sum(x)/float(len(x)) if x else 0 +print (average([0,0,3,1,4,1,5,9,0,0])) +print (average([1e20,-1e-20,3,1,4,1,5,9,-1e20,1e-20])) diff --git a/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-4.py b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-4.py new file mode 100644 index 0000000000..d4941feef9 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-4.py @@ -0,0 +1,2 @@ +2.3 +1e-21 diff --git a/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-5.py b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-5.py new file mode 100644 index 0000000000..8885b64e6b --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-5.py @@ -0,0 +1,6 @@ +def avg(data): + if len(data)==0: + return 0 + else: + return sum(data)/float(len(data)) +print avg([0,0,3,1,4,1,5,9,0,0]) diff --git a/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-6.py b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-6.py new file mode 100644 index 0000000000..bb576dbde1 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Python/averages-arithmetic-mean-6.py @@ -0,0 +1 @@ +2.3 diff --git a/Task/Averages-Arithmetic-mean/R/averages-arithmetic-mean.r b/Task/Averages-Arithmetic-mean/R/averages-arithmetic-mean.r new file mode 100644 index 0000000000..1dc758b79e --- /dev/null +++ b/Task/Averages-Arithmetic-mean/R/averages-arithmetic-mean.r @@ -0,0 +1,4 @@ +omean <- function(v) { + m <- mean(v) + ifelse(is.na(m), 0, m) +} diff --git a/Task/Averages-Arithmetic-mean/REXX/averages-arithmetic-mean.rexx b/Task/Averages-Arithmetic-mean/REXX/averages-arithmetic-mean.rexx new file mode 100644 index 0000000000..ba4851fe06 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/REXX/averages-arithmetic-mean.rexx @@ -0,0 +1,20 @@ +/*REXX pgm finds the averages/arithmetic mean of several lists (vectors)*/ +@.1 = 10 9 8 7 6 5 4 3 2 1 +@.2 = 10 9 8 7 6 5 4 3 2 1 0 0 0 0 .11 +@.3 = '10 20 30 40 50 -100 4.7 -11e2' +@.4 = '1 2 3 4 five 6 7 8 9 10.1. Β±2' +@.5 = 'World War I & World War II' +@.6 = '' + do j=1 for 6 + say 'numbers = ' @.j; say 'average = ' avg(@.j); say + end /*t*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────AVG subroutine──────────────────────*/ +avg: procedure; parse arg x; w=words(x); s=0; $=left('',20) +if w==0 then return 'N/A: ───[null vector.]' + do k=1 for w; _=word(x,k) + if datatype(_,'N') then do; s=s+_; iterate; end + say $ '***error!*** non-numeric: ' _; w=w-1 /*adjust W*/ + end /*k*/ +if w==0 then return 'N/A: ───[no numeric values.]' +return s/max(1,w) diff --git a/Task/Averages-Arithmetic-mean/Racket/averages-arithmetic-mean.rkt b/Task/Averages-Arithmetic-mean/Racket/averages-arithmetic-mean.rkt new file mode 100644 index 0000000000..6bdb4fd313 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Racket/averages-arithmetic-mean.rkt @@ -0,0 +1,6 @@ +#lang racket +(require math) + +(mean (in-range 0 1000)) ; -> 499 1/2 +(mean '(2 2 4 4)) ; -> 3 +(mean #(3 4 5 8)) ; -> 5 diff --git a/Task/Averages-Arithmetic-mean/Ruby/averages-arithmetic-mean.rb b/Task/Averages-Arithmetic-mean/Ruby/averages-arithmetic-mean.rb new file mode 100644 index 0000000000..7d29191e59 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Ruby/averages-arithmetic-mean.rb @@ -0,0 +1,2 @@ +nums = [3, 1, 4, 1, 5, 9] +nums.empty? ? 0 : nums.inject(:+) / Float(nums.size) diff --git a/Task/Averages-Arithmetic-mean/Sather/averages-arithmetic-mean.sa b/Task/Averages-Arithmetic-mean/Sather/averages-arithmetic-mean.sa new file mode 100644 index 0000000000..ee9ca86926 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Sather/averages-arithmetic-mean.sa @@ -0,0 +1,14 @@ +class VECOPS is + mean(v:VEC):FLT is + m ::= 0.0; + loop m := m + v.aelt!; end; + return m / v.dim.flt; + end; +end; + +class MAIN is + main is + v ::= #VEC(|1.0, 5.0, 7.0|); + #OUT + VECOPS::mean(v) + "\n"; + end; +end; diff --git a/Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-1.scala b/Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-1.scala new file mode 100644 index 0000000000..519cf3155f --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-1.scala @@ -0,0 +1 @@ +def mean(s: Seq[Int]) = s.foldLeft(0)(_+_) / s.size diff --git a/Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-2.scala b/Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-2.scala new file mode 100644 index 0000000000..c87d36772d --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-2.scala @@ -0,0 +1,4 @@ +def mean[T](s: Seq[T])(implicit n: Integral[T]) = { + import n._ + s.foldLeft(zero)(_+_) / fromInt(s.size) +} diff --git a/Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-3.scala b/Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-3.scala new file mode 100644 index 0000000000..71feb14b56 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Scala/averages-arithmetic-mean-3.scala @@ -0,0 +1 @@ +def mean[T](s: Seq[T])(implicit n: Fractional[T]) = n.div(s.sum, n.fromInt(s.size)) diff --git a/Task/Averages-Arithmetic-mean/Scheme/averages-arithmetic-mean.ss b/Task/Averages-Arithmetic-mean/Scheme/averages-arithmetic-mean.ss new file mode 100644 index 0000000000..8d5c944e98 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Scheme/averages-arithmetic-mean.ss @@ -0,0 +1,4 @@ +(define (mean l) + (if (null? l) + 0 + (/ (apply + l) (length l)))) diff --git a/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-1.st b/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-1.st new file mode 100644 index 0000000000..42cd6110f2 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-1.st @@ -0,0 +1,8 @@ +| numbers | + +numbers := #(1 2 3 4 5 6 7 8). +(numbers isEmpty + ifTrue:[0] + ifFalse: [ + (numbers inject: 0 into: [:sumSoFar :eachElement | sumSoFar + eachElement]) / numbers size ] +) displayNl. diff --git a/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-2.st b/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-2.st new file mode 100644 index 0000000000..2df6f3154a --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-2.st @@ -0,0 +1,4 @@ +| numbers | + +numbers := #(1 2 3 4 5 6 7 8). +( numbers inject: 0 into: [:sumSoFar :eachElement | sumSoFar + eachElement]) / numbers size] ) displayNl. diff --git a/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-3.st b/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-3.st new file mode 100644 index 0000000000..be37f91703 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-3.st @@ -0,0 +1,4 @@ +| numbers | + +numbers := #(1 2 3 4 5 6 7 8). +(numbers sum / numbers size) displayNl. diff --git a/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-4.st b/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-4.st new file mode 100644 index 0000000000..673eb14465 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Smalltalk/averages-arithmetic-mean-4.st @@ -0,0 +1,4 @@ +| numbers | + +numbers := #(1 2 3 4 5 6 7 8). +numbers average displayNl. diff --git a/Task/Averages-Arithmetic-mean/Tcl/averages-arithmetic-mean.tcl b/Task/Averages-Arithmetic-mean/Tcl/averages-arithmetic-mean.tcl new file mode 100644 index 0000000000..7f100cc272 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Tcl/averages-arithmetic-mean.tcl @@ -0,0 +1,6 @@ +package require Tcl 8.5 +proc mean args { + if {[set num [llength $args]] == 0} {return 0} + expr {[tcl::mathop::+ {*}$args] / double($num)} +} +mean 3 1 4 1 5 9 ;# ==> 3.8333333333333335 diff --git a/Task/Averages-Mean-angle/0DESCRIPTION b/Task/Averages-Mean-angle/0DESCRIPTION new file mode 100644 index 0000000000..0a01d2fbb2 --- /dev/null +++ b/Task/Averages-Mean-angle/0DESCRIPTION @@ -0,0 +1,23 @@ +When calculating the [[wp:Mean of circular quantities|average or mean of an angle]] one has to take into account how angles wrap around so that any angle in degrees plus any integer multiple of 360 degrees is a measure of the same angle. + +If one wanted an average direction of the wind over two readings where the first reading was of 350 degrees and the second was of 10 degrees then the average of the numbers is 180 degrees, whereas if you can note that 350 degrees is equivalent to -10 degrees and so you have two readings at 10 degrees either side of zero degrees leading to a more fitting mean angle of zero degrees. + +To calculate the mean angle of several angles: +# Assume all angles are on the unit circle and convert them to complex numbers expressed in real and imaginary form. +# Compute the mean of the complex numbers. +# Convert the complex mean to polar coordinates whereupon the phase of the complex mean is the required angular mean. + +(Note that, since the mean is the sum divided by the number of numbers, and division by a positive real number does not affect the angle, you can also simply compute the sum for step 2.) + +You can alternatively use this formula: + +:Given the angles \alpha_1,\dots,\alpha_n the mean is computed by + +::\bar{\alpha} = \operatorname{atan2}\left(\frac{1}{n}\cdot\sum_{j=1}^n \sin\alpha_j, \frac{1}{n}\cdot\sum_{j=1}^n \cos\alpha_j\right) + +The task is to: +# write a function/method/subroutine/... that given a list of angles in degrees returns their mean angle. (You should use a built-in function if you have one that does this for degrees or radians). +# Use the function to compute the means of these lists of angles (in degrees): [350, 10], [90, 180, 270, 360], [10, 20, 30]; and show your output here. + +;See Also +* [[Averages/Mean time of day]] diff --git a/Task/Averages-Mean-angle/Ada/averages-mean-angle.ada b/Task/Averages-Mean-angle/Ada/averages-mean-angle.ada new file mode 100644 index 0000000000..13b4bd91ed --- /dev/null +++ b/Task/Averages-Mean-angle/Ada/averages-mean-angle.ada @@ -0,0 +1,34 @@ +with Ada.Text_IO, Ada.Numerics.Generic_Elementary_Functions; + +procedure Mean_Angles is + + type X_Real is digits 4; -- or more digits for improved precision + subtype Real is X_Real range 0.0 .. 360.0; -- the range of interest + type Angles is array(Positive range <>) of Real; + + procedure Put(R: Real) is + package IO is new Ada.Text_IO.Float_IO(Real); + begin + IO.Put(R, Fore => 3, Aft => 2, Exp => 0); + end Put; + + function Mean_Angle(A: Angles) return Real is + Sin_Sum, Cos_Sum: X_Real := 0.0; -- X_Real since sums might exceed 360.0 + package Math is new Ada.Numerics.Generic_Elementary_Functions(Real); + use Math; + begin + for I in A'Range loop + Sin_Sum := Sin_Sum + Sin(A(I), Cycle => 360.0); + Cos_Sum := Cos_Sum + Cos(A(I), Cycle => 360.0); + end loop; + return Arctan(Sin_Sum / X_Real(A'Length), Cos_Sum / X_Real(A'Length), + Cycle => 360.0); + -- may raise Ada.Numerics.Argument_Error if inputs are + -- numerically instable, e.g., when Cos_Sum is 0.0 + end Mean_Angle; + +begin + Put(Mean_Angle((10.0, 20.0, 30.0))); Ada.Text_IO.New_Line; -- 20.00 + Put(Mean_Angle((10.0, 350.0))); Ada.Text_IO.New_Line; -- 0.00 + Put(Mean_Angle((90.0, 180.0, 270.0, 360.0))); -- Ada.Numerics.Argument_Error! +end Mean_Angles; diff --git a/Task/Averages-Mean-angle/C/averages-mean-angle.c b/Task/Averages-Mean-angle/C/averages-mean-angle.c new file mode 100644 index 0000000000..63a359d7d8 --- /dev/null +++ b/Task/Averages-Mean-angle/C/averages-mean-angle.c @@ -0,0 +1,30 @@ +#include +#include + +double +meanAngle (double *angles, int size) +{ + double y_part = 0, x_part = 0; + int i; + + for (i = 0; i < size; i++) + { + x_part += cos (angles[i] * M_PI / 180); + y_part += sin (angles[i] * M_PI / 180); + } + + return atan2 (y_part / size, x_part / size) * 180 / M_PI; +} + +int +main () +{ + double angleSet1[] = { 350, 10 }; + double angleSet2[] = { 90, 180, 270, 360}; + double angleSet3[] = { 10, 20, 30}; + + printf ("\nMean Angle for 1st set : %lf degrees", meanAngle (angleSet1, 2)); + printf ("\nMean Angle for 2nd set : %lf degrees", meanAngle (angleSet2, 4)); + printf ("\nMean Angle for 3rd set : %lf degrees\n", meanAngle (angleSet3, 3)); + return 0; +} diff --git a/Task/Averages-Mean-angle/Go/averages-mean-angle.go b/Task/Averages-Mean-angle/Go/averages-mean-angle.go new file mode 100644 index 0000000000..d058dd06b0 --- /dev/null +++ b/Task/Averages-Mean-angle/Go/averages-mean-angle.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "math" + "math/cmplx" +) + +func deg2rad(d float64) float64 { return d * math.Pi / 180 } +func rad2deg(r float64) float64 { return r * 180 / math.Pi } + +func mean_angle(deg []float64) float64 { + sum := 0i + for _, x := range deg { sum += cmplx.Rect(1, deg2rad(x)) } + return rad2deg(cmplx.Phase(sum)) +} + +func main() { + for _, angles := range [][]float64 {{350, 10}, {90, 180, 270, 360}, {10, 20, 30}} { + fmt.Printf("The mean angle of %v is: %f degrees\n", angles, mean_angle(angles)) + } +} diff --git a/Task/Averages-Mean-angle/Haskell/averages-mean-angle.hs b/Task/Averages-Mean-angle/Haskell/averages-mean-angle.hs new file mode 100644 index 0000000000..c387b57855 --- /dev/null +++ b/Task/Averages-Mean-angle/Haskell/averages-mean-angle.hs @@ -0,0 +1,6 @@ +import Data.Complex (cis, phase) + +meanAngle = (/ pi) . (* 180) . phase . sum . map (cis . (/ 180) . (* pi)) + +main = mapM_ (\angles -> putStrLn $ "The mean angle of " ++ show angles ++ " is: " ++ show (meanAngle angles) ++ " degrees") + [[350, 10], [90, 180, 270, 360], [10, 20, 30]] diff --git a/Task/Averages-Mean-angle/PicoLisp/averages-mean-angle.l b/Task/Averages-Mean-angle/PicoLisp/averages-mean-angle.l new file mode 100644 index 0000000000..7ff1dd9b04 --- /dev/null +++ b/Task/Averages-Mean-angle/PicoLisp/averages-mean-angle.l @@ -0,0 +1,14 @@ +(load "@lib/math.l") + +(de meanAngle (Lst) + (*/ + (atan2 + (sum '((A) (sin (*/ A pi 180.0))) Lst) + (sum '((A) (cos (*/ A pi 180.0))) Lst) ) + 180.0 pi ) ) + +(for L '((350.0 10.0) (90.0 180.0 270.0 360.0) (10.0 20.0 30.0)) + (prinl + "The mean angle of [" + (glue ", " (mapcar round L '(0 .))) + "] is: " (round (meanAngle L))) ) diff --git a/Task/Averages-Mean-angle/Python/averages-mean-angle.py b/Task/Averages-Mean-angle/Python/averages-mean-angle.py new file mode 100644 index 0000000000..0410897002 --- /dev/null +++ b/Task/Averages-Mean-angle/Python/averages-mean-angle.py @@ -0,0 +1,12 @@ +>>> from cmath import rect, phase +>>> from math import radians, degrees +>>> def mean_angle(deg): +... return degrees(phase(sum(rect(1, radians(d)) for d in deg)/len(deg))) +... +>>> for angles in [[350, 10], [90, 180, 270, 360], [10, 20, 30]]: +... print('The mean angle of', angles, 'is:', round(mean_angle(angles), 12), 'degrees') +... +The mean angle of [350, 10] is: -0.0 degrees +The mean angle of [90, 180, 270, 360] is: -90.0 degrees +The mean angle of [10, 20, 30] is: 20.0 degrees +>>> diff --git a/Task/Averages-Mean-angle/REXX/averages-mean-angle.rexx b/Task/Averages-Mean-angle/REXX/averages-mean-angle.rexx new file mode 100644 index 0000000000..b164c8b536 --- /dev/null +++ b/Task/Averages-Mean-angle/REXX/averages-mean-angle.rexx @@ -0,0 +1,57 @@ +/*REXX program to compute the mean angle (angles expressed in degrees).*/ +numeric digits 50 /*use fifty digits of precision. */ +showDigs=10 /* ... but only show ten digits. */ +#=350 10 ; say showit(#, meanAngleD(#)) +#=90 180 270 360 ; say showit(#, meanAngleD(#)) +#=10 20 30 ; say showit(#, meanAngleD(#)) +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────MEANANGD subroutine─────────────────*/ +meanAngleD: procedure; arg x; _sin=0; _cos=0 +numeric digits $d()+$d()%4 +n=words(x); do j=1 for n + xr = d2r(d2d(word(x,j))) + _sin = _sin + sin(xr) + _cos = _cos + cos(xr) + end /*j*/ +return r2d(atan2(_sin/n, _cos/n)) +/*═════════════════════════════general 1-line subs══════════════════════*/ +/*The 1-line subs were broken up into multiple lines for easier reading.*/ +d2d: return arg(1)//360 +d2r: return r2r(d2d(arg(1))/180*pi()) +r2d: return d2d((r2r(arg(1))/pi())*180) +r2r: return arg(1)//(2*pi()) +p: return word(arg(1),1) +$d: return p(arg(1) digits()) +$fuzz: return min(arg(1),max(1,$d()-arg(2))) +showit: procedure expose showDigs; numeric digits showDigs; arg a,ma + return left('angles='a,30) 'mean angle=' format(ma,,showDigs,0)/1 +acos: procedure; arg x; if x<-1 | x>1 then call $81r -1,1,x,"ACOS" + return .5*pi() - asin(x) /* $81r subroutine not included here.*/ +atan: if abs(arg(1))=1 then return pi()*.25*sign(arg(1)) + return asin(arg(1) / sqrt(1+arg(1)**2)) +asin: procedure; arg x; if x<-1 | x>1 then call $81r -1,1,x,"ASIN" + s=x*x; if abs(x)>=.7 then return sign(x)*acos(sqrt(1-s),'-ASIN') + z=x; o=x; p=z; do j=2 by 2; o=o*s*(j-1)/j; z=z+o/(j+1) + if z=p then leave; p=z; end; return z +atan2: procedure; arg y,x; pi=pi(); s=sign(y) + select; when x=0 then z=s*pi*.5; when x<0 then if y=0 then z=pi + else z=s*(pi-abs(atan(y/x)));otherwise z=s*atan(y/x);end; return z +cos: procedure; arg x; x=r2r(x); a=abs(x); numeric fuzz $fuzz(5,3) + if a=0 then return 1; if a=pi() then return -1 + if a=pi()*.5 | a=pi()*1.5 then return 0;if a=pi()/3 then return .5 + if a=2*pi()/3 then return -.5; return .sincos(1,1,-1) +sin: procedure; arg x; x=r2r(x); numeric fuzz $fuzz(5,3) + if x=pi()*.5 then return 1; if x==pi()*1.5 then return -1 + if abs(x)=pi() | x=0 then return 0; return .sincos(x,x,1) +.sincos: parse arg z,_,i; x=x*x; p=z; do k=2 by 2; _=-_*x/(k*(k+i)); z=z+_ + if z=p then leave; p=z; end; return z +sqrt: procedure; parse arg x; if x=0 then return 0; d=digits() + numeric digits 11; g=.sqrtGuess(); do j=0 while p>9;m.j=p; p=p%2+1 + end; do k=j+5 to 0 by -1; if m.k>11 then numeric digits m.k + g=.5*(g+x/g); end; numeric digits d; return g/1 +.sqrtGuess: if x<0 then call er 02,x p($.ff 'SQRT') "negative" + /*The above IF statement was left here to show checking for x<0.*/ + numeric form; m.=11; p=d+d%4+2 + parse value format(x,2,1,,0) 'E0' with g 'E' _ .;return g*.5'E'_%2 +pi: return , +3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148 diff --git a/Task/Averages-Mean-angle/Racket/averages-mean-angle.rkt b/Task/Averages-Mean-angle/Racket/averages-mean-angle.rkt new file mode 100644 index 0000000000..c155e64ed9 --- /dev/null +++ b/Task/Averages-Mean-angle/Racket/averages-mean-angle.rkt @@ -0,0 +1,15 @@ +#lang racket + +(define (mean-angle Ξ±s) + (radians->degrees + (mean-angle/radians + (map degrees->radians Ξ±s)))) + +(define (mean-angle/radians Ξ±s) + (define n (length Ξ±s)) + (atan (* (/ 1 n) (for/sum ([Ξ±_j Ξ±s]) (sin Ξ±_j))) + (* (/ 1 n) (for/sum ([Ξ±_j Ξ±s]) (cos Ξ±_j))))) + +(mean-angle '(350 0 10)) +(mean-angle '(90 180 270 360)) +(mean-angle '(10 20 30)) diff --git a/Task/Averages-Mean-angle/Ruby/averages-mean-angle.rb b/Task/Averages-Mean-angle/Ruby/averages-mean-angle.rb new file mode 100644 index 0000000000..c434366ae2 --- /dev/null +++ b/Task/Averages-Mean-angle/Ruby/averages-mean-angle.rb @@ -0,0 +1,17 @@ +require 'complex' + +def deg2rad(d) + d * Math::PI / 180 +end + +def rad2deg(r) + r * 180 / Math::PI +end + +def mean_angle(deg) + rad2deg((deg.inject(0) {|z, d| z + Complex.polar(1, deg2rad(d))} / deg.length).arg) +end + +[[350, 10], [90, 180, 270, 360], [10, 20, 30]].each {|angles| + puts "The mean angle of %p is: %f degrees" % [angles, mean_angle(angles)] +} diff --git a/Task/Averages-Mean-angle/Tcl/averages-mean-angle-1.tcl b/Task/Averages-Mean-angle/Tcl/averages-mean-angle-1.tcl new file mode 100644 index 0000000000..e457e4b55e --- /dev/null +++ b/Task/Averages-Mean-angle/Tcl/averages-mean-angle-1.tcl @@ -0,0 +1,10 @@ +proc meanAngle {angles} { + set toRadians [expr {atan2(0,-1) / 180}] + set sumSin [set sumCos 0.0] + foreach a $angles { + set sumSin [expr {$sumSin + sin($a * $toRadians)}] + set sumCos [expr {$sumCos + cos($a * $toRadians)}] + } + # Don't need to divide by counts; atan2() cancels that out + return [expr {atan2($sumSin, $sumCos) / $toRadians}] +} diff --git a/Task/Averages-Mean-angle/Tcl/averages-mean-angle-2.tcl b/Task/Averages-Mean-angle/Tcl/averages-mean-angle-2.tcl new file mode 100644 index 0000000000..db0cf33a72 --- /dev/null +++ b/Task/Averages-Mean-angle/Tcl/averages-mean-angle-2.tcl @@ -0,0 +1,9 @@ +# A little pretty-printer +proc printMeanAngle {angles} { + puts [format "mean angle of \[%s\] = %.2f" \ + [join $angles ", "] [meanAngle $angles]] +} + +printMeanAngle {350 10} +printMeanAngle {90 180 270 360} +printMeanAngle {10 20 30} diff --git a/Task/Averages-Mean-time-of-day/0DESCRIPTION b/Task/Averages-Mean-time-of-day/0DESCRIPTION new file mode 100644 index 0000000000..d8388a8008 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/0DESCRIPTION @@ -0,0 +1,3 @@ +A particular activity of bats occurs at these times of the day: +:23:00:17, 23:40:20, 00:12:45, 00:17:19 +Using the idea that there are twenty-four hours in a day, which is analogous to there being 360 degrees in a circle, map times of day to and from angles; and using the ideas of [[Averages/Mean angle]] compute and show the average time of the nocturnal activity to an accuracy of one second of time. diff --git a/Task/Averages-Mean-time-of-day/1META.yaml b/Task/Averages-Mean-time-of-day/1META.yaml new file mode 100644 index 0000000000..0b8885a678 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Date and time diff --git a/Task/Averages-Mean-time-of-day/C/averages-mean-time-of-day.c b/Task/Averages-Mean-time-of-day/C/averages-mean-time-of-day.c new file mode 100644 index 0000000000..50dcc78f6d --- /dev/null +++ b/Task/Averages-Mean-time-of-day/C/averages-mean-time-of-day.c @@ -0,0 +1,72 @@ +/*29th August, 2012 +Abhishek Ghosh*/ + +#include +#include +#include + +typedef struct +{ + int hour, minute, second; +} digitime; + +double +timeToDegrees (digitime time) +{ + return (360 * time.hour / 24.0 + 360 * time.minute / (24 * 60.0) + + 360 * time.second / (24 * 3600.0)); +} + +digitime +timeFromDegrees (double angle) +{ + digitime d; + double totalSeconds = 24 * 60 * 60 * angle / 360; + + d.second = (int) totalSeconds % 60; + d.minute = ((int) totalSeconds % 3600 - d.second) / 60; + d.hour = (int) totalSeconds / 3600; + + return d; +} + +double +meanAngle (double *angles, int size) +{ + double y_part = 0, x_part = 0; + int i; + + for (i = 0; i < size; i++) + { + x_part += cos (angles[i] * M_PI / 180); + y_part += sin (angles[i] * M_PI / 180); + } + + return atan2 (y_part / size, x_part / size) * 180 / M_PI; +} + +int +main () +{ + digitime *set, meanTime; + int inputs, i; + double *angleSet, angleMean; + + printf ("Enter number of inputs : "); + scanf ("%d", &inputs); + set = malloc (inputs * sizeof (digitime)); + angleSet = malloc (inputs * sizeof (double)); + printf ("\n\nEnter the data separated by a space between each unit : "); + + for (i = 0; i < inputs; i++) + { + scanf ("%d:%d:%d", &set[i].hour, &set[i].minute, &set[i].second); + angleSet[i] = timeToDegrees (set[i]); + } + + meanTime = timeFromDegrees (360 + meanAngle (angleSet, inputs)); + + printf ("\n\nThe mean time is : %d:%d:%d", meanTime.hour, meanTime.minute, + meanTime.second); + return 0; +} diff --git a/Task/Averages-Mean-time-of-day/Go/averages-mean-time-of-day.go b/Task/Averages-Mean-time-of-day/Go/averages-mean-time-of-day.go new file mode 100644 index 0000000000..fe76592ab6 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/Go/averages-mean-time-of-day.go @@ -0,0 +1,50 @@ +package main + +import ( + "errors" + "fmt" + "log" + "math" + "time" +) + +var inputs = []string{"23:00:17", "23:40:20", "00:12:45", "00:17:19"} + +func main() { + tList := make([]time.Time, len(inputs)) + const clockFmt = "15:04:05" + var err error + for i, s := range inputs { + tList[i], err = time.Parse(clockFmt, s) + if err != nil { + log.Fatal(err) + } + } + mean, err := meanTime(tList) + if err != nil { + log.Fatal(err) + } + fmt.Println(mean.Format(clockFmt)) +} + +func meanTime(times []time.Time) (mean time.Time, err error) { + if len(times) == 0 { + err = errors.New("meanTime: no times specified") + return + } + var ssum, csum float64 + for _, t := range times { + h, m, s := t.Clock() + n := t.Nanosecond() + fSec := (float64((h*60+m)*60+s) + float64(n)*1e-9) + sin, cos := math.Sincos(fSec * math.Pi / (12 * 60 * 60)) + ssum += sin + csum += cos + } + if ssum == 0 && csum == 0 { + err = errors.New("meanTime: mean undefined") + return + } + _, dayFrac := math.Modf(1 + math.Atan2(ssum, csum)/(2*math.Pi)) + return mean.Add(time.Duration(dayFrac * 24 * float64(time.Hour))), nil +} diff --git a/Task/Averages-Mean-time-of-day/PicoLisp/averages-mean-time-of-day-1.l b/Task/Averages-Mean-time-of-day/PicoLisp/averages-mean-time-of-day-1.l new file mode 100644 index 0000000000..593c3aaa19 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/PicoLisp/averages-mean-time-of-day-1.l @@ -0,0 +1,10 @@ +(load "@lib/math.l") + +(de meanTime (Lst) + (let Tim + (*/ + (atan2 + (sum '((S) (sin (*/ ($tim S) pi 43200))) Lst) + (sum '((S) (cos (*/ ($tim S) pi 43200))) Lst) ) + 43200 pi ) + (tim$ (% (+ Tim 86400) 86400) T) ) ) diff --git a/Task/Averages-Mean-time-of-day/PicoLisp/averages-mean-time-of-day-2.l b/Task/Averages-Mean-time-of-day/PicoLisp/averages-mean-time-of-day-2.l new file mode 100644 index 0000000000..90e9d37556 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/PicoLisp/averages-mean-time-of-day-2.l @@ -0,0 +1,2 @@ +: (meanTime '("23:00:17" "23:40:20" "00:12:45" "00:17:19")) +-> "23:47:43" diff --git a/Task/Averages-Mean-time-of-day/Python/averages-mean-time-of-day.py b/Task/Averages-Mean-time-of-day/Python/averages-mean-time-of-day.py new file mode 100644 index 0000000000..abcef696ab --- /dev/null +++ b/Task/Averages-Mean-time-of-day/Python/averages-mean-time-of-day.py @@ -0,0 +1,24 @@ +from cmath import rect, phase +from math import radians, degrees + + +def mean_angle(deg): + return degrees(phase(sum(rect(1, radians(d)) for d in deg)/len(deg))) + +def mean_time(times): + t = (time.split(':') for time in times) + seconds = ((float(s) + int(m) * 60 + int(h) * 3600) + for h, m, s in t) + day = 24 * 60 * 60 + to_angles = [s * 360. / day for s in seconds] + mean_as_angle = mean_angle(to_angles) + mean_seconds = mean_as_angle * day / 360. + if mean_seconds < 0: + mean_seconds += day + h, m = divmod(mean_seconds, 3600) + m, s = divmod(m, 60) + return '%02i:%02i:%02i' % (h, m, s) + + +if __name__ == '__main__': + print( mean_time(["23:00:17", "23:40:20", "00:12:45", "00:17:19"]) ) diff --git a/Task/Averages-Mean-time-of-day/Tcl/averages-mean-time-of-day.tcl b/Task/Averages-Mean-time-of-day/Tcl/averages-mean-time-of-day.tcl new file mode 100644 index 0000000000..b6b5afdf86 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/Tcl/averages-mean-time-of-day.tcl @@ -0,0 +1,18 @@ +proc meanTime {times} { + set secsPerRad [expr {60 * 60 * 12 / atan2(0,-1)}] + set sumSin [set sumCos 0.0] + foreach t $times { + # Convert time to count of seconds from midnight + scan $t "%02d:%02d:%02d" h m s + incr s [expr {[incr m [expr {$h * 60}]] * 60}] + # Feed into averaging + set sumSin [expr {$sumSin + sin($s / $secsPerRad)}] + set sumCos [expr {$sumCos + cos($s / $secsPerRad)}] + } + # Don't need to divide by counts; atan2() cancels that out + set a [expr {int(atan2($sumSin, $sumCos) * $secsPerRad)}] + # Convert back to human-readable + format "%02d:%02d:%02d" [expr {$a / 60 / 60 % 24}] [expr {$a / 60 % 60}] [expr {$a % 60}] +} + +puts [meanTime {23:00:17 23:40:20 00:12:45 00:17:19}] diff --git a/Task/Averages-Median/0DESCRIPTION b/Task/Averages-Median/0DESCRIPTION new file mode 100644 index 0000000000..16cca4928f --- /dev/null +++ b/Task/Averages-Median/0DESCRIPTION @@ -0,0 +1,5 @@ +Write a program to find the [[wp:Median|median]] value of a vector of floating-point numbers. The program need not handle the case where the vector is empty, but ''must'' handle the case where there are an even number of elements. + +There are several approaches to this. One is to sort the elements, and then pick the one in the middle. Sorting would take at least O(''n''β€Šlog''n''). Another would be to build a priority queue from the elements, and then extract half of the elements to get to the middle one(s). This would also take O(''n''β€Šlog''n''). The best solution is to use the [[wp:Selection algorithm|selection algorithm]] to find the median in O(''n'') time. + +See also: [[Mean]], [[Mode]] diff --git a/Task/Averages-Median/1META.yaml b/Task/Averages-Median/1META.yaml new file mode 100644 index 0000000000..29aeacfd2a --- /dev/null +++ b/Task/Averages-Median/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Probability and statistics diff --git a/Task/Averages-Median/AWK/averages-median.awk b/Task/Averages-Median/AWK/averages-median.awk new file mode 100644 index 0000000000..d5fda36fb5 --- /dev/null +++ b/Task/Averages-Median/AWK/averages-median.awk @@ -0,0 +1,46 @@ +#!/usr/bin/awk -f + +BEGIN { + d[1] = 3.0 + d[2] = 4.0 + d[3] = 1.0 + d[4] = -8.4 + d[5] = 7.2 + d[6] = 4.0 + d[7] = 1.0 + d[8] = 1.2 + showD("Before: ") + gnomeSortD() + showD("Sorted: ") + printf "Median: %f\n", medianD() + exit +} + +function medianD( len, mid) { + len = length(d) + mid = int(len/2) + 1 + if (len % 2) return d[mid] + else return (d[mid] + d[mid-1]) / 2.0 +} + +function gnomeSortD( i) { + for (i = 2; i <= length(d); i++) { + if (d[i] < d[i-1]) gnomeSortBackD(i) + } +} + +function gnomeSortBackD(i, t) { + for (; i > 1 && d[i] < d[i-1]; i--) { + t = d[i] + d[i] = d[i-1] + d[i-1] = t + } +} + +function showD(p, i) { + printf p + for (i = 1; i <= length(d); i++) { + printf d[i] " " + } + print "" +} diff --git a/Task/Averages-Median/Ada/averages-median.ada b/Task/Averages-Median/Ada/averages-median.ada new file mode 100644 index 0000000000..8d85b80a30 --- /dev/null +++ b/Task/Averages-Median/Ada/averages-median.ada @@ -0,0 +1,31 @@ +with Ada.Text_IO, Ada.Float_Text_IO; + +procedure FindMedian is + + f: array(1..10) of float := ( 4.4, 2.3, -1.7, 7.5, 6.6, 0.0, 1.9, 8.2, 9.3, 4.5 ); + min_idx: integer; + min_val, median_val, swap: float; + +begin + for i in f'range loop + min_idx := i; + min_val := f(i); + for j in i+1 .. f'last loop + if f(j) < min_val then + min_idx := j; + min_val := f(j); + end if; + end loop; + swap := f(i); f(i) := f(min_idx); f(min_idx) := swap; + end loop; + + if f'length mod 2 /= 0 then + median_val := f( f'length/2+1 ); + else + median_val := ( f(f'length/2) + f(f'length/2+1) ) / 2.0; + end if; + + Ada.Text_IO.Put( "Median value: " ); + Ada.Float_Text_IO.Put( median_val ); + Ada.Text_IO.New_line; +end FindMedian; diff --git a/Task/Averages-Median/AppleScript/averages-median.applescript b/Task/Averages-Median/AppleScript/averages-median.applescript new file mode 100644 index 0000000000..94dd4eefee --- /dev/null +++ b/Task/Averages-Median/AppleScript/averages-median.applescript @@ -0,0 +1,44 @@ +set alist to {1,2,3,4,5,6,7,8} +set med to medi(alist) + +on medi(alist) + + set temp to {} + set lcount to count every item of alist + if lcount is equal to 2 then + return (item (random number from 1 to 2) of alist) + else if lcount is less than 2 then + return item 1 of alist + else --if lcount is greater than 2 + set min to findmin(alist) + set max to findmax(alist) + repeat with x from 1 to lcount + if x is not equal to min and x is not equal to max then set end of temp to item x of alist + end repeat + set med to medi(temp) + end if + return med + +end medi + +on findmin(alist) + + set min to 1 + set alength to count every item of alist + repeat with x from 1 to alength + if item x of alist is less than item min of alist then set min to x + end repeat + return min + +end findmin + +on findmax(alist) + + set max to 1 + set alength to count every item of alist + repeat with x from 1 to alength + if item x of alist is greater than item max of alist then set max to x + end repeat + return max + +end findmax diff --git a/Task/Averages-Median/AutoHotkey/averages-median.ahk b/Task/Averages-Median/AutoHotkey/averages-median.ahk new file mode 100644 index 0000000000..3621ab35bb --- /dev/null +++ b/Task/Averages-Median/AutoHotkey/averages-median.ahk @@ -0,0 +1,10 @@ +seq = 4.1, 7.2, 1.7, 9.3, 4.4, 3.2, 5 +MsgBox % median(seq, "`,") ; 4.1 + +median(seq, delimiter) +{ + Sort, seq, ND%delimiter% + StringSplit, seq, seq, % delimiter + median := Floor(seq0 / 2) + Return seq%median% +} diff --git a/Task/Averages-Median/BASIC/averages-median.bas b/Task/Averages-Median/BASIC/averages-median.bas new file mode 100644 index 0000000000..516cc1a3c0 --- /dev/null +++ b/Task/Averages-Median/BASIC/averages-median.bas @@ -0,0 +1,30 @@ +DECLARE FUNCTION median! (vector() AS SINGLE) + +DIM vec1(10) AS SINGLE, vec2(11) AS SINGLE, n AS INTEGER + +RANDOMIZE TIMER + +FOR n = 0 TO 10 + vec1(n) = RND * 100 + vec2(n) = RND * 100 +NEXT +vec2(11) = RND * 100 + +PRINT median(vec1()) +PRINT median(vec2()) + +FUNCTION median! (vector() AS SINGLE) + DIM lb AS INTEGER, ub AS INTEGER, L0 AS INTEGER + lb = LBOUND(vector) + ub = UBOUND(vector) + REDIM v(lb TO ub) AS SINGLE + FOR L0 = lb TO ub + v(L0) = vector(L0) + NEXT + quicksort v(), lb, ub + IF ((ub - lb + 1) MOD 2) THEN + median = v((ub + lb) / 2) + ELSE + median = (v(INT((ub + lb) / 2)) + v(INT((ub + lb) / 2) + 1)) / 2 + END IF +END FUNCTION diff --git a/Task/Averages-Median/C/averages-median-1.c b/Task/Averages-Median/C/averages-median-1.c new file mode 100644 index 0000000000..33840b61d3 --- /dev/null +++ b/Task/Averages-Median/C/averages-median-1.c @@ -0,0 +1,32 @@ +#include +#include + +typedef struct floatList { + float *list; + int size; +} *FloatList; + +int floatcmp( const void *a, const void *b) { + if (*(float *)a > *(float *)b) return 1; + else if (*(float *)a < *(float *)b) return -1; + else return 0; +} + +float median( FloatList fl ) +{ + qsort( fl->list, fl->size, sizeof(float), floatcmp); + return 0.5 * ( fl->list[fl->size/2] + fl->list[(fl->size-1)/2]); +} + +int main() +{ + static float floats1[] = { 5.1, 2.6, 6.2, 8.8, 4.6, 4.1 }; + static struct floatList flist1 = { floats1, sizeof(floats1)/sizeof(float) }; + + static float floats2[] = { 5.1, 2.6, 8.8, 4.6, 4.1 }; + static struct floatList flist2 = { floats2, sizeof(floats2)/sizeof(float) }; + + printf("flist1 median is %7.2f\n", median(&flist1)); /* 4.85 */ + printf("flist2 median is %7.2f\n", median(&flist2)); /* 4.60 */ + return 0; +} diff --git a/Task/Averages-Median/C/averages-median-2.c b/Task/Averages-Median/C/averages-median-2.c new file mode 100644 index 0000000000..5fca1166e5 --- /dev/null +++ b/Task/Averages-Median/C/averages-median-2.c @@ -0,0 +1,63 @@ +#include +#include + +/* select the k-th smallest item in array x of length len */ +int qselect(int *x, int k, int len) +{ + inline void swap(int a, int b) { + int t = x[a]; + x[a] = x[b], x[b] = t; + } + + int left = 0, right = len - 1; + int pivot, pos, i; + + while (left < right) { + pivot = x[k]; + swap(k, right); + for (i = pos = left; i < right; i++) { + if (x[i] < pivot) { + swap(i, pos); + pos++; + } + } + swap(right, pos); + if (pos == k) break; + if (pos < k) left = pos + 1; + else right = pos - 1; + } + return x[k]; +} + +#define N 10000001 + +int icmp(const void *a, const void *b) +{ + return *(int*)a < *(int*)b ? -1 : *(int*)a > *(int*) b; +} + +int main() +{ + int i, med, *x = malloc(sizeof(int) * N); + + /* divide by large value to create many duplicate values */ + for (i = 0; i < N; i++) x[i] = rand()/100000; + + med = qselect(x, N/2, N); + + /* qsort for speed comparison */ + //qsort(x, N, sizeof(int), icmp); med = x[N/2]; + + printf("median is %d\n", med); + + /* just to show it is the median */ + int less = 0, more = 0, eq = 0; + for (i = 0; i < N; i++) { + if (x[i] < med) less ++; + else if (x[i] > med) more ++; + else eq ++; + } + printf("<: %d\n>: %d\n=: %d\n", less, more, eq); + + return 0; +} diff --git a/Task/Averages-Median/Clojure/averages-median.clj b/Task/Averages-Median/Clojure/averages-median.clj new file mode 100644 index 0000000000..ed3768df77 --- /dev/null +++ b/Task/Averages-Median/Clojure/averages-median.clj @@ -0,0 +1,7 @@ +(defn median [ns] + (let [ns (sort ns) + cnt (count ns) + mid (bit-shift-right cnt 1)] + (if (odd? cnt) + (nth ns mid) + (/ (+ (nth ns mid) (nth ns (dec mid))) 2)))) diff --git a/Task/Averages-Median/Erlang/averages-median.erl b/Task/Averages-Median/Erlang/averages-median.erl new file mode 100644 index 0000000000..e29e1bdc8b --- /dev/null +++ b/Task/Averages-Median/Erlang/averages-median.erl @@ -0,0 +1,10 @@ +-module(median). +-import(lists, [nth/2, sort/1]). +-compile(export_all). + +median(Unsorted) -> + Sorted = sort(Unsorted), + Length = length(Sorted), + Mid = Length div 2, + Rem = Length rem 2, + (nth(Mid+Rem, Sorted) + nth(Mid+1, Sorted)) / 2. diff --git a/Task/Averages-Median/Forth/averages-median-1.fth b/Task/Averages-Median/Forth/averages-median-1.fth new file mode 100644 index 0000000000..71e5cb5ad7 --- /dev/null +++ b/Task/Averages-Median/Forth/averages-median-1.fth @@ -0,0 +1,30 @@ +-1 cells constant -cell +: cell- -cell + ; + +defer lessthan ( a@ b@ -- ? ) ' < is lessthan + +: mid ( l r -- mid ) over - 2/ -cell and + ; + +: exch ( addr1 addr2 -- ) dup @ >r over @ swap ! r> swap ! ; + +: part ( l r -- l r r2 l2 ) + 2dup mid @ >r ( r: pivot ) + 2dup begin + swap begin dup @ r@ lessthan while cell+ repeat + swap begin r@ over @ lessthan while cell- repeat + 2dup <= if 2dup exch >r cell+ r> cell- then + 2dup > until r> drop ; + +0 value midpoint + +: select ( l r -- ) + begin 2dup < while + part + dup midpoint >= if nip nip ( l l2 ) else + over midpoint <= if drop rot drop swap ( r2 r ) else + 2drop 2drop exit then then + repeat 2drop ; + +: median ( array len -- m ) + 1- cells over + 2dup mid to midpoint + select midpoint @ ; diff --git a/Task/Averages-Median/Forth/averages-median-2.fth b/Task/Averages-Median/Forth/averages-median-2.fth new file mode 100644 index 0000000000..8c71795ea9 --- /dev/null +++ b/Task/Averages-Median/Forth/averages-median-2.fth @@ -0,0 +1,4 @@ +create test 4 , 2 , 1 , 3 , 5 , + +test 4 median . \ 2 +test 5 median . \ 3 diff --git a/Task/Averages-Median/Fortran/averages-median.f b/Task/Averages-Median/Fortran/averages-median.f new file mode 100644 index 0000000000..849445458f --- /dev/null +++ b/Task/Averages-Median/Fortran/averages-median.f @@ -0,0 +1,43 @@ +program Median_Test + + real :: a(7) = (/ 4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2 /), & + b(6) = (/ 4.1, 7.2, 1.7, 9.3, 4.4, 3.2 /) + + print *, median(a) + print *, median(b) + +contains + + function median(a, found) + real, dimension(:), intent(in) :: a + ! the optional found argument can be used to check + ! if the function returned a valid value; we need this + ! just if we suspect our "vector" can be "empty" + logical, optional, intent(out) :: found + real :: median + + integer :: l + real, dimension(size(a,1)) :: ac + + if ( size(a,1) < 1 ) then + if ( present(found) ) found = .false. + else + ac = a + ! this is not an intrinsic: peek a sort algo from + ! Category:Sorting, fixing it to work with real if + ! it uses integer instead. + call sort(ac) + + l = size(a,1) + if ( mod(l, 2) == 0 ) then + median = (ac(l/2+1) + ac(l/2))/2.0 + else + median = ac(l/2+1) + end if + + if ( present(found) ) found = .true. + end if + + end function median + +end program Median_Test diff --git a/Task/Averages-Median/Go/averages-median.go b/Task/Averages-Median/Go/averages-median.go new file mode 100644 index 0000000000..4731cdbb29 --- /dev/null +++ b/Task/Averages-Median/Go/averages-median.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "sort" +) + +func main() { + fmt.Println(median([]float64{3, 1, 4, 1})) // prints 2 + fmt.Println(median([]float64{3, 1, 4, 1, 5})) // prints 3 +} + +func median(a []float64) float64 { + sort.Float64s(a) + half := len(a) / 2 + m := a[half] + if len(a)%2 == 0 { + m = (m + a[half-1]) / 2 + } + return m +} diff --git a/Task/Averages-Median/Haskell/averages-median-1.hs b/Task/Averages-Median/Haskell/averages-median-1.hs new file mode 100644 index 0000000000..5337c27191 --- /dev/null +++ b/Task/Averages-Median/Haskell/averages-median-1.hs @@ -0,0 +1,8 @@ +nth (x:xs) n + | k == n = x + | k > n = nth ys n + | otherwise = nth zs $ n - k - 1 + where (ys, zs) = partition ( Math.Statistics.median [1,9,2,4] +3.0 diff --git a/Task/Averages-Median/Java/averages-median-1.java b/Task/Averages-Median/Java/averages-median-1.java new file mode 100644 index 0000000000..ca3b0766f3 --- /dev/null +++ b/Task/Averages-Median/Java/averages-median-1.java @@ -0,0 +1,5 @@ +// Note: this function modifies the input list +public static double median(List list){ + Collections.sort(list); + return (list.get(list.size() / 2) + list.get((list.size() - 1) / 2)) / 2; +} diff --git a/Task/Averages-Median/Java/averages-median-2.java b/Task/Averages-Median/Java/averages-median-2.java new file mode 100644 index 0000000000..de43c4fc63 --- /dev/null +++ b/Task/Averages-Median/Java/averages-median-2.java @@ -0,0 +1,10 @@ +public static double median2(List list){ + PriorityQueue pq = new PriorityQueue(list); + int n = list.size(); + for (int i = 0; i < (n-1)/2; i++) + pq.poll(); // discard first half + if (n % 2 != 0) // odd length + return pq.poll(); + else + return (pq.poll() + pq.poll()) / 2.0; +} diff --git a/Task/Averages-Median/JavaScript/averages-median.js b/Task/Averages-Median/JavaScript/averages-median.js new file mode 100644 index 0000000000..6dd39b972d --- /dev/null +++ b/Task/Averages-Median/JavaScript/averages-median.js @@ -0,0 +1,15 @@ +function median(ary) { + if (ary.length == 0) + return null; + ary.sort(function (a,b){return a - b}) + var mid = Math.floor(ary.length / 2); + if ((ary.length % 2) == 1) // length is odd + return ary[mid]; + else + return (ary[mid - 1] + ary[mid]) / 2; +} + +median([]); // null +median([5,3,4]); // 4 +median([5,4,2,3]); // 3.5 +median([3,4,1,-8.4,7.2,4,1,1.2]); // 2.1 diff --git a/Task/Averages-Median/Lua/averages-median.lua b/Task/Averages-Median/Lua/averages-median.lua new file mode 100644 index 0000000000..790a9fd9de --- /dev/null +++ b/Task/Averages-Median/Lua/averages-median.lua @@ -0,0 +1,9 @@ +function median (numlist) + if type(numlist) ~= 'table' then return numlist end + table.sort(numlist) + if #numlist %2 == 0 then return (numlist[#numlist/2] + numlist[#numlist/2+1]) / 2 end + return numlist[math.ceil(#numlist/2)] +end + +print(median({4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2})) +print(median({4.1, 7.2, 1.7, 9.3, 4.4, 3.2})) diff --git a/Task/Averages-Median/PHP/averages-median.php b/Task/Averages-Median/PHP/averages-median.php new file mode 100644 index 0000000000..ca3542a007 --- /dev/null +++ b/Task/Averages-Median/PHP/averages-median.php @@ -0,0 +1,17 @@ +function median($arr) +{ + sort($arr); + $count = count($arr); //count the number of values in array + $middleval = floor(($count-1)/2); // find the middle value, or the lowest middle value + if ($count % 2) { // odd number, middle is the median + $median = $arr[$middleval]; + } else { // even number, calculate avg of 2 medians + $low = $arr[$middleval]; + $high = $arr[$middleval+1]; + $median = (($low+$high)/2); + } + return $median; +} + +echo median(array(4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2)) . "\n"; // 4.4 +echo median(array(4.1, 7.2, 1.7, 9.3, 4.4, 3.2)) . "\n"; // 4.25 diff --git a/Task/Averages-Median/Perl/averages-median.pl b/Task/Averages-Median/Perl/averages-median.pl new file mode 100644 index 0000000000..b5308c9258 --- /dev/null +++ b/Task/Averages-Median/Perl/averages-median.pl @@ -0,0 +1,3 @@ +sub median + {my @a = sort {$a <=> $b} @_; + return ($a[$#a/2] + $a[@a/2]) / 2;} diff --git a/Task/Averages-Median/PicoLisp/averages-median.l b/Task/Averages-Median/PicoLisp/averages-median.l new file mode 100644 index 0000000000..35e53eae08 --- /dev/null +++ b/Task/Averages-Median/PicoLisp/averages-median.l @@ -0,0 +1,12 @@ +(de median (Lst) + (let N (length Lst) + (if (bit? 1 N) + (get (sort Lst) (/ (inc N) 2)) + (setq Lst (nth (sort Lst) (/ N 2))) + (/ (+ (car Lst) (cadr Lst)) 2) ) ) ) + +(scl 2) +(prinl (round (median (1.0 2.0 3.0)))) +(prinl (round (median (1.0 2.0 3.0 4.0)))) +(prinl (round (median (5.1 2.6 6.2 8.8 4.6 4.1)))) +(prinl (round (median (5.1 2.6 8.8 4.6 4.1)))) diff --git a/Task/Averages-Median/Prolog/averages-median.pro b/Task/Averages-Median/Prolog/averages-median.pro new file mode 100644 index 0000000000..0eaf4c117e --- /dev/null +++ b/Task/Averages-Median/Prolog/averages-median.pro @@ -0,0 +1,9 @@ +median(L, Z) :- + length(L, Length), + I is Length div 2, + Rem is Length rem 2, + msort(L, S), + maplist(sumlist, [[I, Rem], [I, 1]], Mid), + maplist(nth1, Mid, [S, S], X), + sumlist(X, Y), + Z is Y/2. diff --git a/Task/Averages-Median/Python/averages-median.py b/Task/Averages-Median/Python/averages-median.py new file mode 100644 index 0000000000..96a01725d9 --- /dev/null +++ b/Task/Averages-Median/Python/averages-median.py @@ -0,0 +1,9 @@ +def median(aray): + srtd = sorted(aray) + alen = len(srtd) + return 0.5*( srtd[(alen-1)//2] + srtd[alen//2]) + +a = (4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2) +print a, median(a) +a = (4.1, 7.2, 1.7, 9.3, 4.4, 3.2) +print a, median(a) diff --git a/Task/Averages-Median/R/averages-median.r b/Task/Averages-Median/R/averages-median.r new file mode 100644 index 0000000000..92d590427b --- /dev/null +++ b/Task/Averages-Median/R/averages-median.r @@ -0,0 +1,20 @@ +omedian <- function(v) { + if ( length(v) < 1 ) + NA + else { + sv <- sort(v) + l <- length(sv) + if ( l %% 2 == 0 ) + (sv[floor(l/2)+1] + sv[floor(l/2)])/2 + else + sv[floor(l/2)+1] + } +} + +a <- c(4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2) +b <- c(4.1, 7.2, 1.7, 9.3, 4.4, 3.2) + +print(median(a)) # 4.4 +print(omedian(a)) +print(median(b)) # 4.25 +print(omedian(b)) diff --git a/Task/Averages-Median/REXX/averages-median.rexx b/Task/Averages-Median/REXX/averages-median.rexx new file mode 100644 index 0000000000..49342cc76b --- /dev/null +++ b/Task/Averages-Median/REXX/averages-median.rexx @@ -0,0 +1,33 @@ +/*REXX program to find the medium of a vector (& displays vector,medium)*/ + +/*────────vector────────── ───show vector─── ───────show result─────────*/ +v='1 9 2 4' ; say 'vector=' v; say 'medium=' medium(v); say +v='3 1 4 1 5 9 7 6' ; say 'vector= 'v; say 'medium=' medium(v); say +v='3 4 1 -8.4 7.2 4 1 1.2'; say 'vector= 'v; say 'medium=' medium(v); say +v='-1.2345678e99 2.3e+700'; say 'vector= 'v; say 'medium=' medium(v); say + +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────MEDIUM subroutine───────────────────*/ +medium: procedure; parse arg x +call makeArray x /*make into scaler array (faster)*/ +call Esort /*(ESORT is an overkill for this)*/ +m=@.0%2 /* % is integer division. */ +n=m+1 +if @.0//2==1 then return @.n /*(odd?) // is modulus.*/ + return (@.m+@.n)/2 /*process an even-element vector.*/ +/*──────────────────────────────────MAKEARRAY subroutine────────────────*/ +makeArray: procedure expose @.; parse arg v; @.0=words(v) /*make array*/ + do j=1 for @.0; @.j=word(v,j); end + return +/*──────────────────────────────────ESORT subroutine────────────────────*/ +Esort: procedure expose @.; h=@.0 /*@.0 = # entries.*/ + do while h>1; h=h%2 /*cut entries by Β½.*/ + do i=1 for @.0-h; j=i; k=h+i + do while @.k<@.j + parse value @.j @.k with @.k @.j /*swap two values. */ + if h>=j then leave + j=j-h; k=k-h + end /*while @.k<@.j*/ + end /*i*/ + end /*while h>l*/ +return /*exchange sort is finished.*/ diff --git a/Task/Averages-Median/Racket/averages-median.rkt b/Task/Averages-Median/Racket/averages-median.rkt new file mode 100644 index 0000000000..7b890c6296 --- /dev/null +++ b/Task/Averages-Median/Racket/averages-median.rkt @@ -0,0 +1,14 @@ +#lang racket +(define (median numbers) + (define sorted (list->vector (sort (vector->list numbers) <))) + (define count (vector-length numbers)) + (if (zero? count) + #f + (/ (+ (vector-ref sorted (floor (/ (sub1 count) 2))) + (vector-ref sorted (floor (/ count 2)))) + 2))) + +(median '#(5 3 4)) ;; 4 +(median '#()) ;; #f +(median '#(5 4 2 3)) ;; 7/2 +(median '#(3 4 1 -8.4 7.2 4 1 1.2)) ;; 2.1 diff --git a/Task/Averages-Median/Ruby/averages-median-1.rb b/Task/Averages-Median/Ruby/averages-median-1.rb new file mode 100644 index 0000000000..466f17eb82 --- /dev/null +++ b/Task/Averages-Median/Ruby/averages-median-1.rb @@ -0,0 +1,14 @@ +def median(ary) + return nil if ary.empty? + mid, rem = ary.length.divmod(2) + if rem == 0 + ary.sort[mid-1,2].inject(:+) / 2.0 + else + ary.sort[mid] + end +end + +p median([]) # => nil +p median([5,3,4]) # => 4 +p median([5,4,2,3]) # => 3.5 +p median([3,4,1,-8.4,7.2,4,1,1.2]) # => 2.1 diff --git a/Task/Averages-Median/Ruby/averages-median-2.rb b/Task/Averages-Median/Ruby/averages-median-2.rb new file mode 100644 index 0000000000..d6d75d8d42 --- /dev/null +++ b/Task/Averages-Median/Ruby/averages-median-2.rb @@ -0,0 +1,5 @@ +def median(aray) + srtd = aray.sort + alen = srtd.length + (srtd[(alen-1)/2] + srtd[alen/2]) / 2.0 +end diff --git a/Task/Averages-Median/Scala/averages-median.scala b/Task/Averages-Median/Scala/averages-median.scala new file mode 100644 index 0000000000..952809ebf2 --- /dev/null +++ b/Task/Averages-Median/Scala/averages-median.scala @@ -0,0 +1,5 @@ +def median[T](s: Seq[T])(implicit n: Fractional[T]) = { + import n._ + val (lower, upper) = s.sortWith(_<_).splitAt(s.size / 2) + if (s.size % 2 == 0) (lower.last + upper.head) / fromInt(2) else upper.head +} diff --git a/Task/Averages-Median/Scheme/averages-median-1.ss b/Task/Averages-Median/Scheme/averages-median-1.ss new file mode 100644 index 0000000000..9165203808 --- /dev/null +++ b/Task/Averages-Median/Scheme/averages-median-1.ss @@ -0,0 +1,3 @@ +(define (median l) + (* (+ (list-ref (bubble-sort l >) (round (/ (- (length l) 1) 2))) + (list-ref (bubble-sort l >) (round (/ (length l) 2)))) 0.5)) diff --git a/Task/Averages-Median/Scheme/averages-median-2.ss b/Task/Averages-Median/Scheme/averages-median-2.ss new file mode 100644 index 0000000000..e28ca458b9 --- /dev/null +++ b/Task/Averages-Median/Scheme/averages-median-2.ss @@ -0,0 +1,3 @@ +(define (median l) + (* (+ (list-ref (sort l less?) (round (/ (- (length l) 1) 2))) + (list-ref (sort l less?) (round (/ (length l) 2)))) 0.5)) diff --git a/Task/Averages-Median/Smalltalk/averages-median-1.st b/Task/Averages-Median/Smalltalk/averages-median-1.st new file mode 100644 index 0000000000..1d902e3108 --- /dev/null +++ b/Task/Averages-Median/Smalltalk/averages-median-1.st @@ -0,0 +1,13 @@ +OrderedCollection extend [ + median [ + self size = 0 + ifFalse: [ |s l| + l := self size. + s := self asSortedCollection. + (l rem: 2) = 0 + ifTrue: [ ^ ((s at: (l//2 + 1)) + (s at: (l//2))) / 2 ] + ifFalse: [ ^ s at: (l//2 + 1) ] + ] + ifTrue: [ ^nil ] + ] +]. diff --git a/Task/Averages-Median/Smalltalk/averages-median-2.st b/Task/Averages-Median/Smalltalk/averages-median-2.st new file mode 100644 index 0000000000..eb22c411e2 --- /dev/null +++ b/Task/Averages-Median/Smalltalk/averages-median-2.st @@ -0,0 +1,4 @@ +{ 4.1 . 5.6 . 7.2 . 1.7 . 9.3 . 4.4 . 3.2 } asOrderedCollection + median displayNl. +{ 4.1 . 7.2 . 1.7 . 9.3 . 4.4 . 3.2 } asOrderedCollection + median displayNl. diff --git a/Task/Averages-Median/Tcl/averages-median.tcl b/Task/Averages-Median/Tcl/averages-median.tcl new file mode 100644 index 0000000000..c8fd81d191 --- /dev/null +++ b/Task/Averages-Median/Tcl/averages-median.tcl @@ -0,0 +1,16 @@ +proc median args { + set list [lsort -real $args] + set len [llength $list] + # Odd number of elements + if {$len & 1} { + return [lindex $list [expr {($len-1)/2}]] + } + # Even number of elements + set idx2 [expr {$len/2}] + set idx1 [expr {$idx2-1}] + return [expr { + ([lindex $list $idx1] + [lindex $list $idx2])/2.0 + }] +} + +puts [median 3.0 4.0 1.0 -8.4 7.2 4.0 1.0 1.2]; # --> 2.1 diff --git a/Task/Averages-Mode/0DESCRIPTION b/Task/Averages-Mode/0DESCRIPTION new file mode 100644 index 0000000000..79b7f33e89 --- /dev/null +++ b/Task/Averages-Mode/0DESCRIPTION @@ -0,0 +1,5 @@ +Write a program to find the [[wp:Mode (statistics)|mode]] value of a collection. The case where the collection is empty may be ignored. Care must be taken to handle the case where the mode is non-unique. + +If it is not appropriate or possible to support a general collection, use a vector (array), if possible. If it is not appropriate or possible to support an unspecified value type, use integers. + +See also: [[Averages/Arithmetic mean|Mean]], [[Averages/Median|Median]] diff --git a/Task/Averages-Mode/1META.yaml b/Task/Averages-Mode/1META.yaml new file mode 100644 index 0000000000..29aeacfd2a --- /dev/null +++ b/Task/Averages-Mode/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Probability and statistics diff --git a/Task/Averages-Pythagorean-means/0DESCRIPTION b/Task/Averages-Pythagorean-means/0DESCRIPTION new file mode 100644 index 0000000000..f5e13f5045 --- /dev/null +++ b/Task/Averages-Pythagorean-means/0DESCRIPTION @@ -0,0 +1,12 @@ +Compute all three of the [[wp:Pythagorean means|Pythagorean means]] of the set of integers 1 through 10. + +Show that A(x_1,\ldots,x_n) \geq G(x_1,\ldots,x_n) \geq H(x_1,\ldots,x_n) for this set of positive integers. + +* The most common of the three means, the [[Averages/Arithmetic mean|arithmetic mean]], is the sum of the list divided by its length: +: A(x_1, \ldots, x_n) = \frac{x_1 + \cdots + x_n}{n} +* The [[wp:Geometric mean|geometric mean]] is the nth root of the product of the list: +: G(x_1, \ldots, x_n) = \sqrt[n]{x_1 \cdots x_n} +* The [[wp:Harmonic mean|harmonic mean]] is n divided by the sum of the reciprocal of each item in the list: +: H(x_1, \ldots, x_n) = \frac{n}{\frac{1}{x_1} + \cdots + \frac{1}{x_n}} + +C.f. [[Averages/Root mean square]] diff --git a/Task/Averages-Pythagorean-means/ALGOL-68/averages-pythagorean-means.alg b/Task/Averages-Pythagorean-means/ALGOL-68/averages-pythagorean-means.alg new file mode 100644 index 0000000000..dec35de7b4 --- /dev/null +++ b/Task/Averages-Pythagorean-means/ALGOL-68/averages-pythagorean-means.alg @@ -0,0 +1,26 @@ +main: ( + INT count:=0; + LONG REAL f, sum:=0, prod:=1, resum:=0; + + FORMAT real = $g(0,4)$; # preferred real format # + + FILE fbuf; STRING sbuf; associate(fbuf,sbuf); + + BOOL opts := TRUE; + + FOR i TO argc DO + IF opts THEN # skip args up to the - token # + opts := argv(i) NE "-" + ELSE + rewind(fbuf); sbuf := argv(i); get(fbuf,f); + count +:= 1; + sum +:= f; + prod *:= f; + resum +:= 1/f + FI + OD; + printf(($"c: "f(real)l"s: "f(real)l"p: "f(real)l"r: "f(real)l$,count,sum,prod,resum)); + printf(($"Arithmetic mean = "f(real)l$,sum/count)); + printf(($"Geometric mean = "f(real)l$,prod**(1/count))); + printf(($"Harmonic mean = "f(real)l$,count/resum)) +) diff --git a/Task/Averages-Pythagorean-means/APL/averages-pythagorean-means.apl b/Task/Averages-Pythagorean-means/APL/averages-pythagorean-means.apl new file mode 100644 index 0000000000..98df57d8df --- /dev/null +++ b/Task/Averages-Pythagorean-means/APL/averages-pythagorean-means.apl @@ -0,0 +1,13 @@ + arithmetic←{(+/⍡)÷⍴⍡} + geometric←{(Γ—/⍡)*÷⍴⍡} + harmonic←{(⍴⍡)Γ·(+/÷⍡)} + + + x←⍳10 + + arithmetic x +5.5 + geometric x +4.528728688 + harmonic x +3.414171521 diff --git a/Task/Averages-Pythagorean-means/AWK/averages-pythagorean-means.awk b/Task/Averages-Pythagorean-means/AWK/averages-pythagorean-means.awk new file mode 100644 index 0000000000..9b45d92206 --- /dev/null +++ b/Task/Averages-Pythagorean-means/AWK/averages-pythagorean-means.awk @@ -0,0 +1,14 @@ +#!/usr/bin/awk -f +{ + x = $1; # value of 1st column + A += x; + G += log(x); + H += 1/x; + N++; +} + +END { + print "Arithmethic mean: ",A/N; + print "Geometric mean : ",exp(G/N); + print "Harmonic mean : ",N/H; +} diff --git a/Task/Averages-Pythagorean-means/ActionScript/averages-pythagorean-means.as b/Task/Averages-Pythagorean-means/ActionScript/averages-pythagorean-means.as new file mode 100644 index 0000000000..2fd01350d6 --- /dev/null +++ b/Task/Averages-Pythagorean-means/ActionScript/averages-pythagorean-means.as @@ -0,0 +1,25 @@ +function arithmeticMean(v:Vector.):Number +{ + var sum:Number = 0; + for(var i: uint = 0; i < v.length; i++) + sum += v[i]; + return sum/v.length; +} +function geometricMean(v:Vector.):Number +{ + var product:Number = 1; + for(var i: uint = 0; i < v.length; i++) + product *= v[i]; + return Math.pow(product, 1/v.length); +} +function harmonicMean(v:Vector.):Number +{ + var sum:Number = 0; + for(var i: uint = 0; i < v.length; i++) + sum += 1/v[i]; + return v.length/sum; +} +var list:Vector. = Vector.([1,2,3,4,5,6,7,8,9,10]); +trace("Arithmetic: ", arithmeticMean(list)); +trace("Geometric: ", geometricMean(list)); +trace("Harmonic: ", harmonicMean(list)); diff --git a/Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-1.ada b/Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-1.ada new file mode 100644 index 0000000000..37d9a64ce3 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-1.ada @@ -0,0 +1,6 @@ +package Pythagorean_Means is + type Set is array (Positive range <>) of Float; + function Arithmetic_Mean (Data : Set) return Float; + function Geometric_Mean (Data : Set) return Float; + function Harmonic_Mean (Data : Set) return Float; +end Pythagorean_Means; diff --git a/Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-2.ada b/Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-2.ada new file mode 100644 index 0000000000..c7aa66b7ac --- /dev/null +++ b/Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-2.ada @@ -0,0 +1,33 @@ +with Ada.Numerics.Generic_Elementary_Functions; +package body Pythagorean_Means is + package Math is new Ada.Numerics.Generic_Elementary_Functions (Float); + function "**" (Left, Right : Float) return Float renames Math."**"; + + function Arithmetic_Mean (Data : Set) return Float is + Sum : Float := 0.0; + begin + for I in Data'Range loop + Sum := Sum + Data (I); + end loop; + return Sum / Float (Data'Length); + end Arithmetic_Mean; + + function Geometric_Mean (Data : Set) return Float is + Product : Float := 1.0; + begin + for I in Data'Range loop + Product := Product * Data (I); + end loop; + return Product**(1.0/Float(Data'Length)); + end Geometric_Mean; + + function Harmonic_Mean (Data : Set) return Float is + Reciprocal_Sum : Float := 0.0; + begin + for I in Data'Range loop + Reciprocal_Sum := Reciprocal_Sum + Data (I)**(-1); + end loop; + return Float (Data'Length) / Reciprocal_Sum; + end Harmonic_Mean; + +end Pythagorean_Means; diff --git a/Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-3.ada b/Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-3.ada new file mode 100644 index 0000000000..4b4710e5b2 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Ada/averages-pythagorean-means-3.ada @@ -0,0 +1,13 @@ +with Ada.Text_IO; +with Pythagorean_Means; +procedure Main is + My_Set : Pythagorean_Means.Set := (1.0, 2.0, 3.0, 4.0, 5.0, + 6.0, 7.0, 8.0, 9.0, 10.0); + Arithmetic_Mean : Float := Pythagorean_Means.Arithmetic_Mean (My_Set); + Geometric_Mean : Float := Pythagorean_Means.Geometric_Mean (My_Set); + Harmonic_Mean : Float := Pythagorean_Means.Harmonic_Mean (My_Set); +begin + Ada.Text_IO.Put_Line (Float'Image (Arithmetic_Mean) & " >= " & + Float'Image (Geometric_Mean) & " >= " & + Float'Image (Harmonic_Mean)); +end Main; diff --git a/Task/Averages-Pythagorean-means/AutoHotkey/averages-pythagorean-means.ahk b/Task/Averages-Pythagorean-means/AutoHotkey/averages-pythagorean-means.ahk new file mode 100644 index 0000000000..41b2b77dc6 --- /dev/null +++ b/Task/Averages-Pythagorean-means/AutoHotkey/averages-pythagorean-means.ahk @@ -0,0 +1,41 @@ +A := ArithmeticMean(1, 10) +G := GeometricMean(1, 10) +H := HarmonicMean(1, 10) + +If G Between %H% And %A% + Result := "True" +Else + Result := "False" + +MsgBox, %A%`n%G%`n%H%`n%Result% + + +;--------------------------------------------------------------------------- +ArithmeticMean(a, b) { ; of integers a through b +;--------------------------------------------------------------------------- + n := b - a + 1 + Loop, %n% + Sum += (a + A_Index - 1) + Return, Sum / n +} + + +;--------------------------------------------------------------------------- +GeometricMean(a, b) { ; of integers a through b +;--------------------------------------------------------------------------- + n := b - a + 1 + Prod := 1 + Loop, %n% + Prod *= (a + A_Index - 1) + Return, Prod ** (1 / n) +} + + +;--------------------------------------------------------------------------- +HarmonicMean(a, b) { ; of integers a through b +;--------------------------------------------------------------------------- + n := b - a + 1 + Loop, %n% + Sum += 1 / (a + A_Index - 1) + Return, n / Sum +} diff --git a/Task/Averages-Pythagorean-means/C/averages-pythagorean-means.c b/Task/Averages-Pythagorean-means/C/averages-pythagorean-means.c new file mode 100644 index 0000000000..47eb5630e1 --- /dev/null +++ b/Task/Averages-Pythagorean-means/C/averages-pythagorean-means.c @@ -0,0 +1,23 @@ +#include +#include // atoi() +#include // pow() + +int main(int argc, char* argv[]) +{ + int i, count=0; + double f, sum=0.0, prod=1.0, resum=0.0; + + for (i=1; i=" g ">=" h) + (>= a g h)) diff --git a/Task/Averages-Pythagorean-means/Erlang/averages-pythagorean-means-1.erl b/Task/Averages-Pythagorean-means/Erlang/averages-pythagorean-means-1.erl new file mode 100644 index 0000000000..4e3dce6f9f --- /dev/null +++ b/Task/Averages-Pythagorean-means/Erlang/averages-pythagorean-means-1.erl @@ -0,0 +1,35 @@ +%% Author: Abhay Jain + +-module(mean_calculator). +-export([find_mean/0]). + +find_mean() -> +%% This is function calling. First argument is the the beginning number +%% and second argument is the initial value of sum for AM & HM and initial value of product for GM. + arithmetic_mean(1, 0), + geometric_mean(1, 1), + harmonic_mean(1, 0). + +%% Function to calculate Arithmetic Mean +arithmetic_mean(Number, Sum) when Number > 10 -> + AM = Sum / 10, + io:format("Arithmetic Mean ~p~n", [AM]); +arithmetic_mean(Number, Sum) -> + NewSum = Sum + Number, + arithmetic_mean(Number+1, NewSum). + +%% Function to calculate Geometric Mean +geometric_mean(Number, Product) when Number > 10 -> + GM = math:pow(Product, 0.1), + io:format("Geometric Mean ~p~n", [GM]); +geometric_mean(Number, Product) -> + NewProd = Product * Number, + geometric_mean(Number+1, NewProd). + +%% Function to calculate Harmonic Mean +harmonic_mean(Number, Sum) when Number > 10 -> + HM = 10 / Sum, + io:format("Harmonic Mean ~p~n", [HM]); +harmonic_mean(Number, Sum) -> + NewSum = Sum + (1/Number), + harmonic_mean(Number+1, NewSum). diff --git a/Task/Averages-Pythagorean-means/Erlang/averages-pythagorean-means-2.erl b/Task/Averages-Pythagorean-means/Erlang/averages-pythagorean-means-2.erl new file mode 100644 index 0000000000..b6eef6058c --- /dev/null +++ b/Task/Averages-Pythagorean-means/Erlang/averages-pythagorean-means-2.erl @@ -0,0 +1,3 @@ +Arithmetic Mean 5.5 +Geometric Mean 4.528728688116765 +Harmonic Mean 3.414171521474055 diff --git a/Task/Averages-Pythagorean-means/Forth/averages-pythagorean-means.fth b/Task/Averages-Pythagorean-means/Forth/averages-pythagorean-means.fth new file mode 100644 index 0000000000..922aac93d4 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Forth/averages-pythagorean-means.fth @@ -0,0 +1,27 @@ +: famean ( faddr n -- f ) + 0e + tuck floats bounds do + i f@ f+ + float +loop + 0 d>f f/ ; + +: fgmean ( faddr n -- f ) + 1e + tuck floats bounds do + i f@ f* + float +loop + 0 d>f 1/f f** ; + +: fhmean ( faddr n -- f ) + dup 0 d>f 0e + floats bounds do + i f@ 1/f f+ + float +loop + f/ ; + +create test 1e f, 2e f, 3e f, 4e f, 5e f, 6e f, 7e f, 8e f, 9e f, 10e f, +test 10 famean fdup f. +test 10 fgmean fdup fdup f. +test 10 fhmean fdup f. +( A G G H ) +f>= . f>= . \ -1 -1 diff --git a/Task/Averages-Pythagorean-means/Fortran/averages-pythagorean-means.f b/Task/Averages-Pythagorean-means/Fortran/averages-pythagorean-means.f new file mode 100644 index 0000000000..d5170ec129 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Fortran/averages-pythagorean-means.f @@ -0,0 +1,16 @@ +program Mean + + real :: a(10) = (/ (i, i=1,10) /) + real :: amean, gmean, hmean + + amean = sum(a) / size(a) + gmean = product(a)**(1.0/size(a)) + hmean = size(a) / sum(1.0/a) + + if ((amean < gmean) .or. (gmean < hmean)) then + print*, "Error!" + else + print*, amean, gmean, hmean + end if + +end program Mean diff --git a/Task/Averages-Pythagorean-means/Go/averages-pythagorean-means.go b/Task/Averages-Pythagorean-means/Go/averages-pythagorean-means.go new file mode 100644 index 0000000000..0b3be7f235 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Go/averages-pythagorean-means.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "math" +) + +func main() { + sum, sumr, prod := 0., 0., 1. + for n := 1.; n <= 10; n++ { + sum += n + sumr += 1 / n + prod *= n + } + a, g, h := sum/10, math.Pow(prod, .1), 10/sumr + fmt.Println("A:", a, "G:", g, "H:", h) + fmt.Println("A >= G >= H:", a >= g && g >= h) +} diff --git a/Task/Averages-Pythagorean-means/Haskell/averages-pythagorean-means.hs b/Task/Averages-Pythagorean-means/Haskell/averages-pythagorean-means.hs new file mode 100644 index 0000000000..8b90d26738 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Haskell/averages-pythagorean-means.hs @@ -0,0 +1,11 @@ +import Data.List (genericLength) +import Control.Monad (zipWithM_) + +mean :: Double -> [Double] -> Double +mean 0 xs = product xs ** (1 / genericLength xs) +mean p xs = (1 / genericLength xs * sum (map (** p) xs)) ** (1/p) + +main = do + let ms = zipWith ((. flip mean [1..10]). (,)) "agh" [1, 0, -1] + mapM_ (\(t,m) -> putStrLn $ t : ": " ++ show m) ms + putStrLn $ " a >= g >= h is " ++ show ((\(_,[a,g,h])-> a>=g && g>=h) (unzip ms)) diff --git a/Task/Averages-Pythagorean-means/Java/averages-pythagorean-means.java b/Task/Averages-Pythagorean-means/Java/averages-pythagorean-means.java new file mode 100644 index 0000000000..e55c6ea84d --- /dev/null +++ b/Task/Averages-Pythagorean-means/Java/averages-pythagorean-means.java @@ -0,0 +1,41 @@ +import java.util.Arrays; +import java.util.List; + +public class PythagoreanMeans { + public static double arithmeticMean(List numbers) { + if (numbers.isEmpty()) return Double.NaN; + double mean = 0.0; + for (Double number : numbers) { + mean += number; + } + return mean / numbers.size(); + } + + public static double geometricMean(List numbers) { + if (numbers.isEmpty()) return Double.NaN; + double mean = 1.0; + for (Double number : numbers) { + mean *= number; + } + return Math.pow(mean, 1.0 / numbers.size()); + } + + public static double harmonicMean(List numbers) { + if (numbers.isEmpty() || numbers.contains(0.0)) return Double.NaN; + double mean = 0.0; + for (Double number : numbers) { + mean += (1.0 / number); + } + return numbers.size() / mean; + } + + public static void main(String[] args) { + Double[] array = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}; + List list = Arrays.asList(array); + double arithmetic = arithmeticMean(list); + double geometric = geometricMean(list); + double harmonic = harmonicMean(list); + System.out.format("A = %f G = %f H = %f%n", arithmetic, geometric, harmonic); + System.out.format("A >= G is %b, G >= H is %b%n", (arithmetic >= geometric), (geometric >= harmonic)); + } +} diff --git a/Task/Averages-Pythagorean-means/JavaScript/averages-pythagorean-means.js b/Task/Averages-Pythagorean-means/JavaScript/averages-pythagorean-means.js new file mode 100644 index 0000000000..7c00c6efa0 --- /dev/null +++ b/Task/Averages-Pythagorean-means/JavaScript/averages-pythagorean-means.js @@ -0,0 +1,21 @@ +function arithmetic_mean(ary) { + var sum = ary.reduce(function(s,x) {return (s+x)}, 0); + return (sum / ary.length); +} + +function geometic_mean(ary) { + var product = ary.reduce(function(s,x) {return (s*x)}, 1); + return Math.pow(product, 1/ary.length); +} + +function harmonic_mean(ary) { + var sum_of_inv = ary.reduce(function(s,x) {return (s + 1/x)}, 0); + return (ary.length / sum_of_inv); +} + +var ary = [1,2,3,4,5,6,7,8,9,10]; +var A = arithmetic_mean(ary); +var G = geometic_mean(ary); +var H = harmonic_mean(ary); + +print("is A >= G >= H ? " + (A >= G && G >= H ? "yes" : "no")); diff --git a/Task/Averages-Pythagorean-means/Lua/averages-pythagorean-means.lua b/Task/Averages-Pythagorean-means/Lua/averages-pythagorean-means.lua new file mode 100644 index 0000000000..0235dc59ae --- /dev/null +++ b/Task/Averages-Pythagorean-means/Lua/averages-pythagorean-means.lua @@ -0,0 +1,12 @@ +function fsum(f, a, ...) return a and f(a) + fsum(f, ...) or 0 end +function pymean(t, f, finv) return finv(fsum(f, unpack(t)) / #t) end +nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + +--arithmetic +a = pymean(nums, function(n) return n end, function(n) return n end) +--geometric +g = pymean(nums, math.log, math.exp) +--harmonic +h = pymean(nums, function(n) return 1/n end, function(n) return 1/n end) +print(a, g, h) +assert(a >= g and g >= h) diff --git a/Task/Averages-Pythagorean-means/Perl/averages-pythagorean-means.pl b/Task/Averages-Pythagorean-means/Perl/averages-pythagorean-means.pl new file mode 100644 index 0000000000..26b79fb463 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Perl/averages-pythagorean-means.pl @@ -0,0 +1,26 @@ +sub A +{ + my $a = 0; + $a += $_ for @_; + return $a / @_; +} +sub G +{ + my $p = 1; + $p *= $_ for @_; + return $p**(1/@_); # power of 1/n == root of n +} +sub H +{ + my $h = 0; + $h += 1/$_ for @_; + return @_/$h; +} +my @ints = (1..10); + +my $a = A(@ints); +my $g = G(@ints); +my $h = H(@ints); + +print "A=$a\nG=$g\nH=$h\n"; +die "Error" unless $a >= $g and $g >= $h; diff --git a/Task/Averages-Pythagorean-means/PicoLisp/averages-pythagorean-means.l b/Task/Averages-Pythagorean-means/PicoLisp/averages-pythagorean-means.l new file mode 100644 index 0000000000..37b3dfcd4d --- /dev/null +++ b/Task/Averages-Pythagorean-means/PicoLisp/averages-pythagorean-means.l @@ -0,0 +1,15 @@ +(load "@lib/math.l") + +(let (Lst (1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0) Len (length Lst)) + (prinl "Arithmetic mean: " + (format + (/ (apply + Lst) Len) + *Scl ) ) + (prinl "Geometric mean: " + (format + (pow (*/ (apply * Lst) (** 1.0 (dec Len))) (/ 1.0 Len)) + *Scl ) ) + (prinl "Harmonic mean: " + (format + (*/ (* 1.0 Len) 1.0 (sum '((N) (*/ 1.0 1.0 N)) Lst)) + *Scl ) ) ) diff --git a/Task/Averages-Pythagorean-means/Python/averages-pythagorean-means.py b/Task/Averages-Pythagorean-means/Python/averages-pythagorean-means.py new file mode 100644 index 0000000000..7bd666da54 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Python/averages-pythagorean-means.py @@ -0,0 +1,16 @@ +from operator import mul +from functools import reduce + +def amean(num): + return sum(num)/len(num) + +def gmean(num): + return reduce(mul, num, 1)**(1/len(num)) + +def hmean(num): + return len(num)/sum(1/n for n in num) + +numbers = range(1,11) # 1..10 +a, g, h = amean(numbers), gmean(numbers), hmean(numbers) +print(a, g, h) +assert( a >= g >= h ) diff --git a/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-1.r b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-1.r new file mode 100644 index 0000000000..5e8bdd03e8 --- /dev/null +++ b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-1.r @@ -0,0 +1 @@ + x <- 1:10 diff --git a/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-2.r b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-2.r new file mode 100644 index 0000000000..5909969360 --- /dev/null +++ b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-2.r @@ -0,0 +1 @@ +a <- sum(x)/length(x) diff --git a/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-3.r b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-3.r new file mode 100644 index 0000000000..1783dce63b --- /dev/null +++ b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-3.r @@ -0,0 +1 @@ +a <- mean(x) diff --git a/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-4.r b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-4.r new file mode 100644 index 0000000000..57d0929798 --- /dev/null +++ b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-4.r @@ -0,0 +1 @@ +g <- prod(x)^(1/length(x)) diff --git a/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-5.r b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-5.r new file mode 100644 index 0000000000..53ea63bb77 --- /dev/null +++ b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-5.r @@ -0,0 +1 @@ +h <- length(x)/sum(1/x) diff --git a/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-6.r b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-6.r new file mode 100644 index 0000000000..e7ec338422 --- /dev/null +++ b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-6.r @@ -0,0 +1 @@ +a > g diff --git a/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-7.r b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-7.r new file mode 100644 index 0000000000..976e7fb904 --- /dev/null +++ b/Task/Averages-Pythagorean-means/R/averages-pythagorean-means-7.r @@ -0,0 +1 @@ +g > h diff --git a/Task/Averages-Pythagorean-means/REXX/averages-pythagorean-means.rexx b/Task/Averages-Pythagorean-means/REXX/averages-pythagorean-means.rexx new file mode 100644 index 0000000000..46ab67c07e --- /dev/null +++ b/Task/Averages-Pythagorean-means/REXX/averages-pythagorean-means.rexx @@ -0,0 +1,68 @@ +/*REXX program to compute/show Pythagorean means [Amean, Gmean, Hmean].*/ +parse arg n . /*maybe get an optional argument.*/ +if n=='' then n=10 /*None specified? Assume default*/ + /*══════════════════compute Amean [Arithmetic mean]*/ +sum=0; do j=1 for n + @.j=j /*populate the stemmed array @. */ + sum=sum+@.j /*compute the sum of all elements*/ + end /*j*/ +Amean=sum/n /*calculate the Amean. */ +say 'Amean =' Amean /*show and tell Amean. */ + /*══════════════════compute Gmean [Geometric mean].*/ +prod=1; do k=1 for n + prod=prod*@.k /*comp. product of all elements. */ + end /*k*/ +Gmean=iroot(prod,n) /*calculate the Gmean. */ +say 'Gmean =' Gmean /*show and tell Gmean. */ + /*══════════════════compute Hmean [Harmonic mean]. */ +rsum=0; do m=1 for n + rsum=rsum+1/@.m /*compute the sum of reciprocals.*/ + end /*m*/ +Hmean=n/rsum /*calculate the Hmean. */ +say 'Hmean =' Hmean /*show and tell Hmean. */ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────IROOT subroutine────────────────────*/ +iroot: procedure; arg x 1 ox,y 1 oy /*get both args, and also a copy.*/ +if x=0 | x=1 then return x /*handle special case of 0 & 1. */ +if y=0 then return 1 /*handle special case of root 0. */ +if y=1 then return x /*handle special case of root 1. */ +if x<0 & y//2==0 then do /*check for illegal combination. */ + say; say '*** error! *** (from IROOT):'; say + say 'root' y "can't be even if 1st argument is < 0." + say; return '[n/a]' /*return a not applicable.*/ + end +x=abs(x) /*use the absolute value for X. */ +y=abs(y) /*use the absolute value for root*/ +digO=digits() /*save original accuracy (digits)*/ +a=digO+5 /*use an extra 5 digs (accuracy).*/ +g=(x+1)/y**y /*use this as the 1st guesstimate*/ +m=y-1 /*use this as a fast [root-1]. */ +numeric fuzz 3 /*3 fuzz digits for comparisons. */ +d=5 /*start with 5 digits accuracy. When the */ + /*DIGITS is large, CPU time is wasted on */ + /*large accuracies when the guess isn't */ + /*close to the final answer. It's best to*/ + /*take baby steps before going full bore */ + /*throttle and putting the pedal to the */ + /*metal, getting it in high gear, and */ + /*then turning the volume all the way up. */ + + do forever /* ◄─────────────────┐ keep plugging as digs increases*/ + d=min(d+d,a) /* β”‚ limit the digits to orig digs┐5*/ + numeric digits d /* β”‚ keep increasing the accuracy. */ + old=0 /* β”‚ define old (guess). */ + /* β”‚ */ + do forever /* ◄────────────┐ β”‚ keep plugging at the Yth root.*/ + _=(m*g**y+x)/y/g**m /* β”‚ β”‚ this is the nitty-gritty stuff.*/ + if _=g | _=old then leave /* β”‚ β”‚ are we close enough yet ? */ + old=g /* β”‚ β”‚ save guess in old (guess). */ + g=_ /* β”‚ β”‚ set Guess to what's been calc. */ + end /*forever β–Ίβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ */ + /* β”‚ */ + if d==a then leave /* β”‚ are we at the desired accuracy?*/ + end /*forever β–Ίβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ */ + +_=g*sign(ox) /*adjust for the sign of orig X. */ +if oy<0 then _=1/_ /*adjust for negative root. */ +numeric digits digO /*restore the original digits. */ +return _/1 /*normalize result to orig digits*/ diff --git a/Task/Averages-Pythagorean-means/Racket/averages-pythagorean-means.rkt b/Task/Averages-Pythagorean-means/Racket/averages-pythagorean-means.rkt new file mode 100644 index 0000000000..113e3f4c9e --- /dev/null +++ b/Task/Averages-Pythagorean-means/Racket/averages-pythagorean-means.rkt @@ -0,0 +1,19 @@ +#lang racket + +(define (arithmetic xs) + (/ (for/sum ([x xs]) x) + (length xs))) + +(define (geometric xs) + (expt (for/product ([x xs]) x) + (/ (length xs)))) + +(define (harmonic xs) + (/ (length xs) + (for/sum ([x xs]) (/ x)))) + +(define xs (range 1 11)) +(arithmetic xs) +(geometric xs) +(harmonic xs) +(>= (arithmetic xs) (geometric xs) (harmonic xs)) diff --git a/Task/Averages-Pythagorean-means/Ruby/averages-pythagorean-means.rb b/Task/Averages-Pythagorean-means/Ruby/averages-pythagorean-means.rb new file mode 100644 index 0000000000..c712e326dd --- /dev/null +++ b/Task/Averages-Pythagorean-means/Ruby/averages-pythagorean-means.rb @@ -0,0 +1,28 @@ +class Array + def arithmetic_mean + inject(:+).to_f / length + end + + def geometric_mean + inject(:*) ** (1.0 / length) + end + + def harmonic_mean + length.to_f / inject(0) {|s, m| s += 1.0/m} + end +end + +class Range + def method_missing(m, *args) + case m + when /_mean$/ then to_a.send(m) + else super + end + end +end + +p a = (1..10).arithmetic_mean +p g = (1..10).geometric_mean +p h = (1..10).harmonic_mean +# is h < g < a ?? +p g.between?(h, a) diff --git a/Task/Averages-Pythagorean-means/Scala/averages-pythagorean-means.scala b/Task/Averages-Pythagorean-means/Scala/averages-pythagorean-means.scala new file mode 100644 index 0000000000..b21d41f0e7 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Scala/averages-pythagorean-means.scala @@ -0,0 +1,15 @@ +def arithmeticMean(n: Seq[Int]) = n.sum / n.size.toDouble +def geometricMean(n: Seq[Int]) = math.pow(n.foldLeft(1.0)(_*_), 1.0 / n.size.toDouble) +def harmonicMean(n: Seq[Int]) = n.size / n.map(1.0 / _).sum + +var nums = 1 to 10 + +var a = arithmeticMean(nums) +var g = geometricMean(nums) +var h = harmonicMean(nums) + +println("Arithmetic mean " + a) +println("Geometric mean " + g) +println("Harmonic mean " + h) + +assert(a >= g && g >= h) diff --git a/Task/Averages-Pythagorean-means/Scheme/averages-pythagorean-means-1.ss b/Task/Averages-Pythagorean-means/Scheme/averages-pythagorean-means-1.ss new file mode 100644 index 0000000000..912615db2f --- /dev/null +++ b/Task/Averages-Pythagorean-means/Scheme/averages-pythagorean-means-1.ss @@ -0,0 +1,23 @@ +(define (a-mean l) + (/ (apply + l) (length l))) + +(define (g-mean l) + (expt (apply * l) (/ (length l)))) + +(define (h-mean l) + (/ (length l) (apply + (map / l)))) + +(define (iota start stop) + (if (> start stop) + (list) + (cons start (iota (+ start 1) stop)))) + +(let* ((l (iota 1 10)) (a (a-mean l)) (g (g-mean l)) (h (h-mean l))) + (display a) + (display " >= ") + (display g) + (display " >= ") + (display h) + (newline) + (display (>= a g h)) + (newline)) diff --git a/Task/Averages-Pythagorean-means/Scheme/averages-pythagorean-means-2.ss b/Task/Averages-Pythagorean-means/Scheme/averages-pythagorean-means-2.ss new file mode 100644 index 0000000000..5b503882fe --- /dev/null +++ b/Task/Averages-Pythagorean-means/Scheme/averages-pythagorean-means-2.ss @@ -0,0 +1,2 @@ +11/2 >= 4.528728688116765 >= 25200/7381 +#t diff --git a/Task/Averages-Pythagorean-means/Smalltalk/averages-pythagorean-means.st b/Task/Averages-Pythagorean-means/Smalltalk/averages-pythagorean-means.st new file mode 100644 index 0000000000..908cd31633 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Smalltalk/averages-pythagorean-means.st @@ -0,0 +1,27 @@ +Collection extend +[ + arithmeticMean + [ + ^ (self fold: [:a :b| a + b ]) / (self size) + ] + + geometricMean + [ + ^ (self fold: [:a :b| a * b]) raisedTo: (self size reciprocal) + ] + + harmonicMean + [ + ^ (self size) / ((self collect: [:x|x reciprocal]) fold: [:a :b| a + b ] ) + ] +] + +|a| +a := #(1 2 3 4 5 6 7 8 9 10). + +a arithmeticMean asFloat displayNl. +a geometricMean asFloat displayNl. +a harmonicMean asFloat displayNl. + +((a arithmeticMean) >= (a geometricMean)) displayNl. +((a geometricMean) >= (a harmonicMean)) displayNl. diff --git a/Task/Averages-Pythagorean-means/Tcl/averages-pythagorean-means.tcl b/Task/Averages-Pythagorean-means/Tcl/averages-pythagorean-means.tcl new file mode 100644 index 0000000000..1197829cb8 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Tcl/averages-pythagorean-means.tcl @@ -0,0 +1,23 @@ +proc arithmeticMean list { + set sum 0.0 + foreach value $list { set sum [expr {$sum + $value}] } + return [expr {$sum / [llength $list]}] +} +proc geometricMean list { + set product 1.0 + foreach value $list { set product [expr {$product * $value}] } + return [expr {$product ** (1.0/[llength $list])}] +} +proc harmonicMean list { + set sum 0.0 + foreach value $list { set sum [expr {$sum + 1.0/$value}] } + return [expr {[llength $list] / $sum}] +} + +set nums {1 2 3 4 5 6 7 8 9 10} +set A10 [arithmeticMean $nums] +set G10 [geometricMean $nums] +set H10 [harmonicMean $nums] +puts "A10=$A10, G10=$G10, H10=$H10" +if {$A10 >= $G10} { puts "A10 >= G10" } +if {$G10 >= $H10} { puts "G10 >= H10" } diff --git a/Task/Averages-Root-mean-square/0DESCRIPTION b/Task/Averages-Root-mean-square/0DESCRIPTION new file mode 100644 index 0000000000..6fde1d5117 --- /dev/null +++ b/Task/Averages-Root-mean-square/0DESCRIPTION @@ -0,0 +1,8 @@ +Compute the [[wp:Root mean square|Root mean square]] of the numbers 1..10. + +The root mean square is also known by its initial RMS (or rms), and as the '''quadratic mean'''. + +The RMS is calculated as the mean of the squares of the numbers, square-rooted: +: x_{\mathrm{rms}} = \sqrt {{{x_1}^2 + {x_2}^2 + \cdots + {x_n}^2} \over n}. + +Cf. [[Averages/Pythagorean means]] diff --git a/Task/Averages-Root-mean-square/ALGOL-68/averages-root-mean-square.alg b/Task/Averages-Root-mean-square/ALGOL-68/averages-root-mean-square.alg new file mode 100644 index 0000000000..4388906f0a --- /dev/null +++ b/Task/Averages-Root-mean-square/ALGOL-68/averages-root-mean-square.alg @@ -0,0 +1,28 @@ +# Define the rms PROCedure & ABS OPerators for LONG... REAL # +MODE RMSFIELD = #LONG...# REAL; +PROC (RMSFIELD)RMSFIELD rms field sqrt = #long...# sqrt; +INT rms field width = #long...# real width; + +PROC crude rms = ([]RMSFIELD v)RMSFIELD: ( + RMSFIELD sum := 0; + FOR i FROM LWB v TO UPB v DO sum +:= v[i]**2 OD; + rms field sqrt(sum / (UPB v - LWB v + 1)) +); + +PROC rms = ([]RMSFIELD v)RMSFIELD: ( +# round off error accumulated at standard precision # + RMSFIELD sum := 0, round off error:= 0; + FOR i FROM LWB v TO UPB v DO + RMSFIELD org = sum, prod = v[i]**2; + sum +:= prod; + round off error +:= sum - org - prod + OD; + rms field sqrt((sum - round off error)/(UPB v - LWB v + 1)) +); + +main: ( + []RMSFIELD one to ten = (1,2,3,4,5,6,7,8,9,10); + + print(("crude rms(one to ten): ", crude rms(one to ten), new line)); + print(("rms(one to ten): ", rms(one to ten), new line)) +) diff --git a/Task/Averages-Root-mean-square/APL/averages-root-mean-square.apl b/Task/Averages-Root-mean-square/APL/averages-root-mean-square.apl new file mode 100644 index 0000000000..ff4a32a174 --- /dev/null +++ b/Task/Averages-Root-mean-square/APL/averages-root-mean-square.apl @@ -0,0 +1,5 @@ + rms←{((+/⍡*2)÷⍴⍡)*0.5} + x←⍳10 + + rms x +6.204836823 diff --git a/Task/Averages-Root-mean-square/AWK/averages-root-mean-square.awk b/Task/Averages-Root-mean-square/AWK/averages-root-mean-square.awk new file mode 100644 index 0000000000..0d1e58315d --- /dev/null +++ b/Task/Averages-Root-mean-square/AWK/averages-root-mean-square.awk @@ -0,0 +1,11 @@ +#!/usr/bin/awk -f +# computes RMS of the 1st column of a data file +{ + x = $1; # value of 1st column + S += x*x; + N++; +} + +END { + print "RMS: ",sqrt(S/N); +} diff --git a/Task/Averages-Root-mean-square/Ada/averages-root-mean-square.ada b/Task/Averages-Root-mean-square/Ada/averages-root-mean-square.ada new file mode 100644 index 0000000000..bc446862ed --- /dev/null +++ b/Task/Averages-Root-mean-square/Ada/averages-root-mean-square.ada @@ -0,0 +1,20 @@ +with Ada.Float_Text_IO; use Ada.Float_Text_IO; +with Ada.Numerics.Elementary_Functions; +use Ada.Numerics.Elementary_Functions; +procedure calcrms is + type float_arr is array(1..10) of Float; + + function rms(nums : float_arr) return Float is + sum : Float := 0.0; + begin + for p in nums'Range loop + sum := sum + nums(p)**2; + end loop; + return sqrt(sum/Float(nums'Length)); + end rms; + + list : float_arr; +begin +list := (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0); +put( rms(list) , Exp=>0); +end calcrms; diff --git a/Task/Averages-Root-mean-square/AutoHotkey/averages-root-mean-square-1.ahk b/Task/Averages-Root-mean-square/AutoHotkey/averages-root-mean-square-1.ahk new file mode 100644 index 0000000000..694bad73b7 --- /dev/null +++ b/Task/Averages-Root-mean-square/AutoHotkey/averages-root-mean-square-1.ahk @@ -0,0 +1,11 @@ +MsgBox, % RMS(1, 10) + + +;--------------------------------------------------------------------------- +RMS(a, b) { ; Root Mean Square of integers a through b +;--------------------------------------------------------------------------- + n := b - a + 1 + Loop, %n% + Sum += (a + A_Index - 1) ** 2 + Return, Sqrt(Sum / n) +} diff --git a/Task/Averages-Root-mean-square/AutoHotkey/averages-root-mean-square-2.ahk b/Task/Averages-Root-mean-square/AutoHotkey/averages-root-mean-square-2.ahk new file mode 100644 index 0000000000..6de16af0b8 --- /dev/null +++ b/Task/Averages-Root-mean-square/AutoHotkey/averages-root-mean-square-2.ahk @@ -0,0 +1,8 @@ +MsgBox, % RMS(1, 10) + + +;--------------------------------------------------------------------------- +RMS(a, b) { ; Root Mean Square of integers a through b +;--------------------------------------------------------------------------- + Return, Sqrt((b*(b+1)*(2*b+1)-a*(a-1)*(2*a-1))/6/(b-a+1)) +} diff --git a/Task/Averages-Root-mean-square/BASIC/averages-root-mean-square.bas b/Task/Averages-Root-mean-square/BASIC/averages-root-mean-square.bas new file mode 100644 index 0000000000..47a7f4f033 --- /dev/null +++ b/Task/Averages-Root-mean-square/BASIC/averages-root-mean-square.bas @@ -0,0 +1,14 @@ +DIM i(1 TO 10) AS DOUBLE, L0 AS LONG +FOR L0 = 1 TO 10 + i(L0) = L0 +NEXT +PRINT STR$(rms#(i())) + +FUNCTION rms# (what() AS DOUBLE) + DIM L0 AS LONG, tmp AS DOUBLE, rt AS DOUBLE + FOR L0 = LBOUND(what) TO UBOUND(what) + rt = rt + (what(L0) ^ 2) + NEXT + tmp = UBOUND(what) - LBOUND(what) + 1 + rms# = SQR(rt / tmp) +END FUNCTION diff --git a/Task/Averages-Root-mean-square/C/averages-root-mean-square.c b/Task/Averages-Root-mean-square/C/averages-root-mean-square.c new file mode 100644 index 0000000000..793e702e35 --- /dev/null +++ b/Task/Averages-Root-mean-square/C/averages-root-mean-square.c @@ -0,0 +1,18 @@ +#include +#include + +double rms(double *v, int n) +{ + int i; + double sum = 0.0; + for(i = 0; i < n; i++) + sum += v[i] * v[i]; + return sqrt(sum / n); +} + +int main(void) +{ + double v[] = {1., 2., 3., 4., 5., 6., 7., 8., 9., 10.}; + printf("%f\n", rms(v, sizeof(v)/sizeof(double))); + return 0; +} diff --git a/Task/Averages-Root-mean-square/Clojure/averages-root-mean-square.clj b/Task/Averages-Root-mean-square/Clojure/averages-root-mean-square.clj new file mode 100644 index 0000000000..f8ccf161df --- /dev/null +++ b/Task/Averages-Root-mean-square/Clojure/averages-root-mean-square.clj @@ -0,0 +1,7 @@ +(use '[clojure.contrib.math :only (sqrt)]) + +(defn rms [xs] + (sqrt (/ (reduce + (map #(* % %) xs)) + (count xs)))) + +(println (rms (range 1 11))) diff --git a/Task/Averages-Root-mean-square/CoffeeScript/averages-root-mean-square.coffee b/Task/Averages-Root-mean-square/CoffeeScript/averages-root-mean-square.coffee new file mode 100644 index 0000000000..c34e1f9a64 --- /dev/null +++ b/Task/Averages-Root-mean-square/CoffeeScript/averages-root-mean-square.coffee @@ -0,0 +1,5 @@ + root_mean_square = (ary) -> + sum_of_squares = ary.reduce ((s,x) -> s + x*x), 0 + return Math.sqrt(sum_of_squares / ary.length) + + alert root_mean_square([1..10]) diff --git a/Task/Averages-Root-mean-square/Erlang/averages-root-mean-square.erl b/Task/Averages-Root-mean-square/Erlang/averages-root-mean-square.erl new file mode 100644 index 0000000000..e9c1326a07 --- /dev/null +++ b/Task/Averages-Root-mean-square/Erlang/averages-root-mean-square.erl @@ -0,0 +1,4 @@ +rms(Nums) -> + math:sqrt(lists:foldl(fun(E,S) -> S+E*E end, 0, Nums) / length(Nums)). + +rms([1,2,3,4,5,6,7,8,9,10]). diff --git a/Task/Averages-Root-mean-square/Forth/averages-root-mean-square.fth b/Task/Averages-Root-mean-square/Forth/averages-root-mean-square.fth new file mode 100644 index 0000000000..977fde7f3f --- /dev/null +++ b/Task/Averages-Root-mean-square/Forth/averages-root-mean-square.fth @@ -0,0 +1,9 @@ +: rms ( faddr len -- frms ) + dup >r 0e + floats bounds do + i f@ fdup f* f+ + float +loop + r> s>f f/ fsqrt ; + +create test 1e f, 2e f, 3e f, 4e f, 5e f, 6e f, 7e f, 8e f, 9e f, 10e f, +test 10 rms f. \ 6.20483682299543 diff --git a/Task/Averages-Root-mean-square/Fortran/averages-root-mean-square.f b/Task/Averages-Root-mean-square/Fortran/averages-root-mean-square.f new file mode 100644 index 0000000000..52dc468808 --- /dev/null +++ b/Task/Averages-Root-mean-square/Fortran/averages-root-mean-square.f @@ -0,0 +1 @@ +print *,sqrt( sum(x**2)/size(x) ) diff --git a/Task/Averages-Root-mean-square/Go/averages-root-mean-square.go b/Task/Averages-Root-mean-square/Go/averages-root-mean-square.go new file mode 100644 index 0000000000..33312dfbba --- /dev/null +++ b/Task/Averages-Root-mean-square/Go/averages-root-mean-square.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "math" +) + +func main() { + const n = 10 + sum := 0. + for x := 1.; x <= n; x++ { + sum += x * x + } + fmt.Println(math.Sqrt(sum / n)) +} diff --git a/Task/Averages-Root-mean-square/Haskell/averages-root-mean-square.hs b/Task/Averages-Root-mean-square/Haskell/averages-root-mean-square.hs new file mode 100644 index 0000000000..8f3fd5d88c --- /dev/null +++ b/Task/Averages-Root-mean-square/Haskell/averages-root-mean-square.hs @@ -0,0 +1 @@ +main = print $ mean 2 [1 .. 10] diff --git a/Task/Averages-Root-mean-square/Java/averages-root-mean-square.java b/Task/Averages-Root-mean-square/Java/averages-root-mean-square.java new file mode 100644 index 0000000000..8bf65fce28 --- /dev/null +++ b/Task/Averages-Root-mean-square/Java/averages-root-mean-square.java @@ -0,0 +1,14 @@ +public class RMS { + public static double rms(double[] nums){ + double ms = 0; + for (int i = 0; i < nums.length; i++) + ms += nums[i] * nums[i]; + ms /= nums.length; + return Math.sqrt(ms); + } + + public static void main(String[] args){ + double[] nums = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}; + System.out.println("The RMS of the numbers from 1 to 10 is " + rms(nums)); + } +} diff --git a/Task/Averages-Root-mean-square/JavaScript/averages-root-mean-square.js b/Task/Averages-Root-mean-square/JavaScript/averages-root-mean-square.js new file mode 100644 index 0000000000..343a544460 --- /dev/null +++ b/Task/Averages-Root-mean-square/JavaScript/averages-root-mean-square.js @@ -0,0 +1,6 @@ +function root_mean_square(ary) { + var sum_of_squares = ary.reduce(function(s,x) {return (s + x*x)}, 0); + return Math.sqrt(sum_of_squares / ary.length); +} + +print( root_mean_square([1,2,3,4,5,6,7,8,9,10]) ); // ==> 6.2048368229954285 diff --git a/Task/Averages-Root-mean-square/Lua/averages-root-mean-square.lua b/Task/Averages-Root-mean-square/Lua/averages-root-mean-square.lua new file mode 100644 index 0000000000..6343c2ab2a --- /dev/null +++ b/Task/Averages-Root-mean-square/Lua/averages-root-mean-square.lua @@ -0,0 +1,4 @@ +function sumsq(a, ...) return a and a^2 + sumsq(...) or 0 end +function rms(t) return (sumsq(unpack(t)) / #t)^.5 end + +print(rms{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) diff --git a/Task/Averages-Root-mean-square/Perl/averages-root-mean-square.pl b/Task/Averages-Root-mean-square/Perl/averages-root-mean-square.pl new file mode 100644 index 0000000000..796f93c6fc --- /dev/null +++ b/Task/Averages-Root-mean-square/Perl/averages-root-mean-square.pl @@ -0,0 +1,9 @@ +use v5.10.0; +sub rms +{ + my $r = 0; + $r += $_**2 for @_; + return sqrt( $r/@_ ); +} + +say rms(1..10); diff --git a/Task/Averages-Root-mean-square/PicoLisp/averages-root-mean-square.l b/Task/Averages-Root-mean-square/PicoLisp/averages-root-mean-square.l new file mode 100644 index 0000000000..1215f5aa36 --- /dev/null +++ b/Task/Averages-Root-mean-square/PicoLisp/averages-root-mean-square.l @@ -0,0 +1,12 @@ +(scl 5) + +(let Lst (1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0) + (prinl + (format + (sqrt + (*/ + (sum '((N) (*/ N N 1.0)) Lst) + 1.0 + (length Lst) ) + T ) + *Scl ) ) ) diff --git a/Task/Averages-Root-mean-square/Python/averages-root-mean-square.py b/Task/Averages-Root-mean-square/Python/averages-root-mean-square.py new file mode 100644 index 0000000000..7be9a86302 --- /dev/null +++ b/Task/Averages-Root-mean-square/Python/averages-root-mean-square.py @@ -0,0 +1,6 @@ +>>> from math import sqrt +>>> def qmean(num): + return sqrt(sum(n*n for n in num)/len(num)) + +>>> qmean(range(1,11)) +6.2048368229954285 diff --git a/Task/Averages-Root-mean-square/R/averages-root-mean-square-1.r b/Task/Averages-Root-mean-square/R/averages-root-mean-square-1.r new file mode 100644 index 0000000000..6be53be3ba --- /dev/null +++ b/Task/Averages-Root-mean-square/R/averages-root-mean-square-1.r @@ -0,0 +1 @@ +sqrt(sum((1:10)^2/10)) diff --git a/Task/Averages-Root-mean-square/R/averages-root-mean-square-2.r b/Task/Averages-Root-mean-square/R/averages-root-mean-square-2.r new file mode 100644 index 0000000000..408cad4f72 --- /dev/null +++ b/Task/Averages-Root-mean-square/R/averages-root-mean-square-2.r @@ -0,0 +1,2 @@ +x<-1:10 +sqrt(sum((x)^2/length(x))) diff --git a/Task/Averages-Root-mean-square/REXX/averages-root-mean-square.rexx b/Task/Averages-Root-mean-square/REXX/averages-root-mean-square.rexx new file mode 100644 index 0000000000..8e2cdef991 --- /dev/null +++ b/Task/Averages-Root-mean-square/REXX/averages-root-mean-square.rexx @@ -0,0 +1,19 @@ +/*REXX program to compute the root mean square of a series of numbers.*/ + +parse arg n . /*get the argument (maybe). */ +if n=='' then n=10 /*Not specified? Then assume 10.*/ +numeric digits 50 /*let's go a little overboard. */ +sum=0 /*sum of numbers squared (so far)*/ + do j=1 for n /*step through N integers. */ + sum=sum+j**2 /*sum the squares of the integers*/ + end /*j*/ +rms=sqrt(sum/n) /*divide by N, then get SQRT. */ +say 'root mean square for 1──►'n "is" rms /*show & tell.*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────SQRT subroutine─────────────────────────*/ +sqrt: procedure; parse arg x;if x=0 then return 0;d=digits();numeric digits 11 +g=.sqrtGuess(); do j=0 while p>9; m.j=p; p=p%2+1; end; do k=j+5 to 0 by -1 +if m.k>11 then numeric digits m.k;g=.5*(g+x/g);end;numeric digits d;return g/1 + +.sqrtGuess: if x<0 then say 'negative number' x; numeric form; m.=11 +p=d+d%4+2; parse value format(x,2,1,,0) 'E0' with g 'E' _ .; return g*.5'E'_%2 diff --git a/Task/Averages-Root-mean-square/Ruby/averages-root-mean-square-1.rb b/Task/Averages-Root-mean-square/Ruby/averages-root-mean-square-1.rb new file mode 100644 index 0000000000..71c6f3f4af --- /dev/null +++ b/Task/Averages-Root-mean-square/Ruby/averages-root-mean-square-1.rb @@ -0,0 +1,13 @@ +class Array + def quadratic_mean + Math.sqrt( self.inject(0) {|s, y| s += y*y}.to_f / self.length ) + end +end + +class Range + def quadratic_mean + self.to_a.quadratic_mean + end +end + +(1..10).quadratic_mean # => 6.20483682299543 diff --git a/Task/Averages-Root-mean-square/Ruby/averages-root-mean-square-2.rb b/Task/Averages-Root-mean-square/Ruby/averages-root-mean-square-2.rb new file mode 100644 index 0000000000..89f07f17cb --- /dev/null +++ b/Task/Averages-Root-mean-square/Ruby/averages-root-mean-square-2.rb @@ -0,0 +1,4 @@ +def rms(seq) + Math.sqrt(seq.inject(0.0) {|sum, x| sum += x*x} / seq.length) +end +puts rms (1..10).to_a # => 6.2048368229954285 diff --git a/Task/Averages-Root-mean-square/Sather/averages-root-mean-square.sa b/Task/Averages-Root-mean-square/Sather/averages-root-mean-square.sa new file mode 100644 index 0000000000..c0a2a8911a --- /dev/null +++ b/Task/Averages-Root-mean-square/Sather/averages-root-mean-square.sa @@ -0,0 +1,16 @@ +class MAIN is + -- irrms stands for Integer Ranged RMS + irrms(i, f:INT):FLT + pre i <= f + is + sum ::= 0; + loop + sum := sum + i.upto!(f).pow(2); + end; + return (sum.flt / (f-i+1).flt).sqrt; + end; + + main is + #OUT + irrms(1, 10) + "\n"; + end; +end; diff --git a/Task/Averages-Root-mean-square/Scala/averages-root-mean-square.scala b/Task/Averages-Root-mean-square/Scala/averages-root-mean-square.scala new file mode 100644 index 0000000000..9454ad5d46 --- /dev/null +++ b/Task/Averages-Root-mean-square/Scala/averages-root-mean-square.scala @@ -0,0 +1,2 @@ +def rms(nums: Seq[Int]) = math.sqrt(nums.map(math.pow(_, 2)).sum / nums.size) +println(rms(1 to 10)) diff --git a/Task/Averages-Root-mean-square/Scheme/averages-root-mean-square.ss b/Task/Averages-Root-mean-square/Scheme/averages-root-mean-square.ss new file mode 100644 index 0000000000..681c8bfc79 --- /dev/null +++ b/Task/Averages-Root-mean-square/Scheme/averages-root-mean-square.ss @@ -0,0 +1,5 @@ +(define (rms nums) + (sqrt (/ (apply + (map * nums nums)) + (length nums)))) + +(rms '(1 2 3 4 5 6 7 8 9 10)) diff --git a/Task/Averages-Root-mean-square/Smalltalk/averages-root-mean-square.st b/Task/Averages-Root-mean-square/Smalltalk/averages-root-mean-square.st new file mode 100644 index 0000000000..72c4fb855a --- /dev/null +++ b/Task/Averages-Root-mean-square/Smalltalk/averages-root-mean-square.st @@ -0,0 +1 @@ +(((1 to: 10) inject: 0 into: [ :s :n | n*n + s ]) / 10) sqrt. diff --git a/Task/Averages-Root-mean-square/Tcl/averages-root-mean-square.tcl b/Task/Averages-Root-mean-square/Tcl/averages-root-mean-square.tcl new file mode 100644 index 0000000000..4ed2113c6d --- /dev/null +++ b/Task/Averages-Root-mean-square/Tcl/averages-root-mean-square.tcl @@ -0,0 +1,7 @@ +proc qmean list { + set sum 0.0 + foreach value $list { set sum [expr {$sum + $value**2}] } + return [expr { sqrt($sum / [llength $list]) }] +} + +puts "RMS(1..10) = [qmean {1 2 3 4 5 6 7 8 9 10}]" diff --git a/Task/Averages-Simple-moving-average/0DESCRIPTION b/Task/Averages-Simple-moving-average/0DESCRIPTION new file mode 100644 index 0000000000..2cb853c620 --- /dev/null +++ b/Task/Averages-Simple-moving-average/0DESCRIPTION @@ -0,0 +1,33 @@ +Computing the [[wp:Moving_average#Simple_moving_average|simple moving average]] of a series of numbers. + +The task is to: +:''Create a [[wp:Stateful|stateful]] function/class/instance that takes a period and returns a routine that takes a number as argument and returns a simple moving average of its arguments so far.'' + +'''Description'''
+A simple moving average is a method for computing an average of a stream of numbers by only averaging the last P numbers from the stream, where P is known as the period. It can be implemented by calling an initialing routine with P as its argument, I(P), which should then return a routine that when called with individual, successive members of a stream of numbers, computes the mean of (up to), the last P of them, lets call this SMA(). + +The word stateful in the task description refers to the need for SMA() to remember certain information between calls to it: +* The period, P +* An ordered container of at least the last P numbers from each of its individual calls. +Stateful also means that successive calls to I(), the initializer, should return separate routines that do ''not'' share saved state so they could be used on two independent streams of data. + +Pseudocode for an implementation of SMA is: +
+function SMA(number: N):
+    stateful integer: P
+    stateful list:    stream
+    number:           average
+
+    stream.append_last(N)
+    if stream.length() > P:
+        # Only average the last P elements of the stream
+        stream.delete_first()
+    if stream.length() == 0:
+        average = 0
+    else:
+        average = sum( stream.values() ) / stream.length()
+    return average
+
+ + +See also: [[Standard Deviation]] diff --git a/Task/Averages-Simple-moving-average/1META.yaml b/Task/Averages-Simple-moving-average/1META.yaml new file mode 100644 index 0000000000..29aeacfd2a --- /dev/null +++ b/Task/Averages-Simple-moving-average/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Probability and statistics diff --git a/Task/Averages-Simple-moving-average/ALGOL-68/averages-simple-moving-average.alg b/Task/Averages-Simple-moving-average/ALGOL-68/averages-simple-moving-average.alg new file mode 100644 index 0000000000..f832a2a8df --- /dev/null +++ b/Task/Averages-Simple-moving-average/ALGOL-68/averages-simple-moving-average.alg @@ -0,0 +1,88 @@ +MODE SMAOBJ = STRUCT( + LONG REAL sma, + LONG REAL sum, + INT period, + REF[]LONG REAL values, + INT lv +); + +MODE SMARESULT = UNION ( + REF SMAOBJ # handle #, + LONG REAL # sma #, + REF[]LONG REAL # values # +); + +MODE SMANEW = INT, + SMAFREE = STRUCT(REF SMAOBJ free obj), + SMAVALUES = STRUCT(REF SMAOBJ values obj), + SMAADD = STRUCT(REF SMAOBJ add obj, LONG REAL v), + SMAMEAN = STRUCT(REF SMAOBJ mean obj, REF[]LONG REAL v); + +MODE ACTION = UNION ( SMANEW, SMAFREE, SMAVALUES, SMAADD, SMAMEAN ); + +PROC sma = ([]ACTION action)SMARESULT: +( + SMARESULT result; + REF SMAOBJ obj; + LONG REAL v; + + FOR i FROM LWB action TO UPB action DO + CASE action[i] IN + (SMANEW period):( # args: INT period # + HEAP SMAOBJ handle; + sma OF handle := 0.0; + period OF handle := period; + values OF handle := HEAP [period OF handle]LONG REAL; + lv OF handle := 0; + sum OF handle := 0.0; + result := handle + ), + (SMAFREE args):( # args: REF SMAOBJ free obj # + free obj OF args := REF SMAOBJ(NIL) # let the garbage collector do it's job # + ), + (SMAVALUES args):( # args: REF SMAOBJ values obj # + result := values OF values obj OF args + ), + (SMAMEAN args):( # args: REF SMAOBJ mean obj # + result := sma OF mean obj OF args + ), + (SMAADD args):( # args: REF SMAOBJ add obj, LONG REAL v # + obj := add obj OF args; + v := v OF args; + IF lv OF obj < period OF obj THEN + (values OF obj)[lv OF obj+:=1] := v; + sum OF obj +:= v; + sma OF obj := sum OF obj / lv OF obj + ELSE + sum OF obj -:= (values OF obj)[ 1+ lv OF obj MOD period OF obj]; + sum OF obj +:= v; + sma OF obj := sum OF obj / period OF obj; + (values OF obj)[ 1+ lv OF obj MOD period OF obj ] := v; lv OF obj+:=1 + FI; + result := sma OF obj + ) + OUT + SKIP + ESAC + OD; + result +); + +[]LONG REAL v = ( 1, 2, 3, 4, 5, 5, 4, 3, 2, 1 ); + +main: ( + INT i; + + REF SMAOBJ h3 := ( sma(SMANEW(3)) | (REF SMAOBJ obj):obj ); + REF SMAOBJ h5 := ( sma(SMANEW(5)) | (REF SMAOBJ obj):obj ); + + FOR i FROM LWB v TO UPB v DO + printf(($"next number "g(0,6)", SMA_3 = "g(0,6)", SMA_5 = "g(0,6)l$, + v[i], (sma(SMAADD(h3, v[i]))|(LONG REAL r):r), ( sma(SMAADD(h5, v[i])) | (LONG REAL r):r ) + )) + OD#; + + sma(SMAFREE(h3)); + sma(SMAFREE(h5)) +# +) diff --git a/Task/Averages-Simple-moving-average/AWK/averages-simple-moving-average.awk b/Task/Averages-Simple-moving-average/AWK/averages-simple-moving-average.awk new file mode 100644 index 0000000000..43d74c96f5 --- /dev/null +++ b/Task/Averages-Simple-moving-average/AWK/averages-simple-moving-average.awk @@ -0,0 +1,13 @@ +#!/usr/bin/awk -f +# Moving average over the first column of a data file +BEGIN { + P = 5; +} + +{ + x = $1; + i = NR % P; + MA += (x - Z[i]) / P; + Z[i] = x; + print MA; +} diff --git a/Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-1.ada b/Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-1.ada new file mode 100644 index 0000000000..bb3ea3665a --- /dev/null +++ b/Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-1.ada @@ -0,0 +1,8 @@ +generic + Max_Elements : Positive; + type Number is digits <>; +package Moving is + procedure Add_Number (N : Number); + function Moving_Average (N : Number) return Number; + function Get_Average return Number; +end Moving; diff --git a/Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-2.ada b/Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-2.ada new file mode 100644 index 0000000000..288f762396 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-2.ada @@ -0,0 +1,40 @@ +with Ada.Containers.Vectors; + +package body Moving is + use Ada.Containers; + + package Number_Vectors is new Ada.Containers.Vectors + (Element_Type => Number, + Index_Type => Natural); + + Current_List : Number_Vectors.Vector := Number_Vectors.Empty_Vector; + + procedure Add_Number (N : Number) is + begin + if Natural (Current_List.Length) >= Max_Elements then + Current_List.Delete_First; + end if; + Current_List.Append (N); + end Add_Number; + + function Get_Average return Number is + Average : Number := 0.0; + procedure Sum (Position : Number_Vectors.Cursor) is + begin + Average := Average + Number_Vectors.Element (Position); + end Sum; + begin + Current_List.Iterate (Sum'Access); + if Current_List.Length > 1 then + Average := Average / Number (Current_List.Length); + end if; + return Average; + end Get_Average; + + function Moving_Average (N : Number) return Number is + begin + Add_Number (N); + return Get_Average; + end Moving_Average; + +end Moving; diff --git a/Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-3.ada b/Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-3.ada new file mode 100644 index 0000000000..c0c087b378 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Ada/averages-simple-moving-average-3.ada @@ -0,0 +1,19 @@ +with Ada.Text_IO; +with Moving; +procedure Main is + package Three_Average is new Moving (Max_Elements => 3, Number => Float); + package Five_Average is new Moving (Max_Elements => 5, Number => Float); +begin + for I in 1 .. 5 loop + Ada.Text_IO.Put_Line ("Inserting" & Integer'Image (I) & + " into max-3: " & Float'Image (Three_Average.Moving_Average (Float (I)))); + Ada.Text_IO.Put_Line ("Inserting" & Integer'Image (I) & + " into max-5: " & Float'Image (Five_Average.Moving_Average (Float (I)))); + end loop; + for I in reverse 1 .. 5 loop + Ada.Text_IO.Put_Line ("Inserting" & Integer'Image (I) & + " into max-3: " & Float'Image (Three_Average.Moving_Average (Float (I)))); + Ada.Text_IO.Put_Line ("Inserting" & Integer'Image (I) & + " into max-5: " & Float'Image (Five_Average.Moving_Average (Float (I)))); + end loop; +end Main; diff --git a/Task/Averages-Simple-moving-average/AutoHotkey/averages-simple-moving-average-1.ahk b/Task/Averages-Simple-moving-average/AutoHotkey/averages-simple-moving-average-1.ahk new file mode 100644 index 0000000000..b75de4f66a --- /dev/null +++ b/Task/Averages-Simple-moving-average/AutoHotkey/averages-simple-moving-average-1.ahk @@ -0,0 +1,18 @@ +MsgBox % MovingAverage(5,3) ; 5, averaging length <- 3 +MsgBox % MovingAverage(1) ; 3 +MsgBox % MovingAverage(-3) ; 1 +MsgBox % MovingAverage(8) ; 2 +MsgBox % MovingAverage(7) ; 4 + +MovingAverage(x,len="") { ; for integers (faster) + Static + Static sum:=0, n:=0, m:=10 ; default averaging length = 10 + If (len>"") ; non-blank 2nd parameter: set length, reset + sum := n := i := 0, m := len + If (n < m) ; until the buffer is not full + sum += x, n++ ; keep summing data + Else ; when buffer is full + sum += x-v%i% ; add new, subtract oldest + v%i% := x, i := mod(i+1,m) ; remember last m inputs, cycle insertion point + Return sum/n +} diff --git a/Task/Averages-Simple-moving-average/AutoHotkey/averages-simple-moving-average-2.ahk b/Task/Averages-Simple-moving-average/AutoHotkey/averages-simple-moving-average-2.ahk new file mode 100644 index 0000000000..37371f3257 --- /dev/null +++ b/Task/Averages-Simple-moving-average/AutoHotkey/averages-simple-moving-average-2.ahk @@ -0,0 +1,11 @@ +MovingAverage(x,len="") { ; for floating point numbers + Static + Static n:=0, m:=10 ; default averaging length = 10 + If (len>"") ; non-blank 2nd parameter: set length, reset + n := i := 0, m := len + n += n < m, sum := 0 + v%i% := x, i := mod(i+1,m) ; remember last m inputs, cycle insertion point + Loop %n% ; recompute sum to avoid error accumulation + j := A_Index-1, sum += v%j% + Return sum/n +} diff --git a/Task/Averages-Simple-moving-average/C/averages-simple-moving-average-1.c b/Task/Averages-Simple-moving-average/C/averages-simple-moving-average-1.c new file mode 100644 index 0000000000..e4f3b8d8ff --- /dev/null +++ b/Task/Averages-Simple-moving-average/C/averages-simple-moving-average-1.c @@ -0,0 +1,69 @@ +#include +#include +#include + +typedef struct sma_obj { + double sma; + double sum; + int period; + double *values; + int lv; +} sma_obj_t; + +typedef union sma_result { + sma_obj_t *handle; + double sma; + double *values; +} sma_result_t; + +enum Action { SMA_NEW, SMA_FREE, SMA_VALUES, SMA_ADD, SMA_MEAN }; +sma_result_t sma(enum Action action, ...) +{ + va_list vl; + sma_result_t r; + sma_obj_t *o; + double v; + + va_start(vl, action); + switch(action) { + case SMA_NEW: // args: int period + r.handle = malloc(sizeof(sma_obj_t)); + r.handle->sma = 0.0; + r.handle->period = va_arg(vl, int); + r.handle->values = malloc(r.handle->period * sizeof(double)); + r.handle->lv = 0; + r.handle->sum = 0.0; + break; + case SMA_FREE: // args: sma_obj_t *handle + r.handle = va_arg(vl, sma_obj_t *); + free(r.handle->values); + free(r.handle); + r.handle = NULL; + break; + case SMA_VALUES: // args: sma_obj_t *handle + o = va_arg(vl, sma_obj_t *); + r.values = o->values; + break; + case SMA_MEAN: // args: sma_obj_t *handle + o = va_arg(vl, sma_obj_t *); + r.sma = o->sma; + break; + case SMA_ADD: // args: sma_obj_t *handle, double value + o = va_arg(vl, sma_obj_t *); + v = va_arg(vl, double); + if ( o->lv < o->period ) { + o->values[o->lv++] = v; + o->sum += v; + o->sma = o->sum / o->lv; + } else { + o->sum -= o->values[ o->lv % o->period]; + o->sum += v; + o->sma = o->sum / o->period; + o->values[ o->lv % o->period ] = v; o->lv++; + } + r.sma = o->sma; + break; + } + va_end(vl); + return r; +} diff --git a/Task/Averages-Simple-moving-average/C/averages-simple-moving-average-2.c b/Task/Averages-Simple-moving-average/C/averages-simple-moving-average-2.c new file mode 100644 index 0000000000..f2a136dfc2 --- /dev/null +++ b/Task/Averages-Simple-moving-average/C/averages-simple-moving-average-2.c @@ -0,0 +1,18 @@ +double v[] = { 1, 2, 3, 4, 5, 5, 4, 3, 2, 1 }; + +int main() +{ + int i; + + sma_obj_t *h3 = sma(SMA_NEW, 3).handle; + sma_obj_t *h5 = sma(SMA_NEW, 5).handle; + + for(i=0; i < sizeof(v)/sizeof(double) ; i++) { + printf("next number %lf, SMA_3 = %lf, SMA_5 = %lf\n", + v[i], sma(SMA_ADD, h3, v[i]).sma, sma(SMA_ADD, h5, v[i]).sma); + } + + sma(SMA_FREE, h3); + sma(SMA_FREE, h5); + return 0; +} diff --git a/Task/Averages-Simple-moving-average/Clojure/averages-simple-moving-average.clj b/Task/Averages-Simple-moving-average/Clojure/averages-simple-moving-average.clj new file mode 100644 index 0000000000..2378b95544 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Clojure/averages-simple-moving-average.clj @@ -0,0 +1,12 @@ +(import '[clojure.lang PersistentQueue]) + +(defn enqueue-max [q p n] + (let [q (conj q n)] + (if (<= (count q) p) q (pop q)))) + +(defn avg [coll] (/ (reduce + coll) (count coll))) + +(defn init-moving-avg [p] + (let [state (atom PersistentQueue/EMPTY)] + (fn [n] + (avg (swap! state enqueue-max p n))))) diff --git a/Task/Averages-Simple-moving-average/CoffeeScript/averages-simple-moving-average-1.coffee b/Task/Averages-Simple-moving-average/CoffeeScript/averages-simple-moving-average-1.coffee new file mode 100644 index 0000000000..14477dbd6d --- /dev/null +++ b/Task/Averages-Simple-moving-average/CoffeeScript/averages-simple-moving-average-1.coffee @@ -0,0 +1,44 @@ +I = (P) -> + # The cryptic name "I" follows the problem description; + # it returns a function that computes a moving average + # of successive values over the period P, using closure + # variables to maintain state. + cq = circular_queue(P) + num_elems = 0 + sum = 0 + + SMA = (n) -> + sum += n + if num_elems < P + cq.add(n) + num_elems += 1 + sum / num_elems + else + old = cq.replace(n) + sum -= old + sum / P + +circular_queue = (n) -> + # queue that only ever stores up to n values; + # Caller shouldn't call replace until n values + # have been added. + i = 0 + arr = [] + + add: (elem) -> + arr.push elem + replace: (elem) -> + # return value whose age is "n" + old_val = arr[i] + arr[i] = elem + i = (i + 1) % n + old_val + +# The output of the code below should convince you that +# calling I multiple times returns functions with independent +# state. +sma3 = I(3) +sma7 = I(7) +sma11 = I(11) +for i in [1..10] + console.log i, sma3(i), sma7(i), sma11(i) diff --git a/Task/Averages-Simple-moving-average/CoffeeScript/averages-simple-moving-average-2.coffee b/Task/Averages-Simple-moving-average/CoffeeScript/averages-simple-moving-average-2.coffee new file mode 100644 index 0000000000..379c2bdcc9 --- /dev/null +++ b/Task/Averages-Simple-moving-average/CoffeeScript/averages-simple-moving-average-2.coffee @@ -0,0 +1,11 @@ +> coffee moving_average.coffee +1 1 1 1 +2 1.5 1.5 1.5 +3 2 2 2 +4 3 2.5 2.5 +5 4 3 3 +6 5 3.5 3.5 +7 6 4 4 +8 7 5 4.5 +9 8 6 5 +10 9 7 5.5 diff --git a/Task/Averages-Simple-moving-average/Erlang/averages-simple-moving-average-1.erl b/Task/Averages-Simple-moving-average/Erlang/averages-simple-moving-average-1.erl new file mode 100644 index 0000000000..bf693544e6 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Erlang/averages-simple-moving-average-1.erl @@ -0,0 +1,41 @@ +main() -> + SMA3 = sma(3), + SMA5 = sma(5), + Ns = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], + lists:foreach( + fun (N) -> + io:format("Added ~b, sma(3) -> ~f, sma(5) -> ~f~n",[N,next(SMA3,N),next(SMA5,N)]) + end, Ns), + stop(SMA3), + stop(SMA5). + +sma(W) -> + {sma,spawn(?MODULE,loop,[W,[]])}. + +loop(Window, Numbers) -> + receive + {_Pid, stop} -> + ok; + {Pid, N} when is_number(N) -> + case length(Numbers) < Window of + true -> + Next = Numbers++[N]; + false -> + Next = tl(Numbers)++[N] + end, + Pid ! {average, lists:sum(Next)/length(Next)}, + loop(Window,Next); + _ -> + ok + end. + +stop({sma,Pid}) -> + Pid ! {self(),stop}, + ok. + +next({sma,Pid},N) -> + Pid ! {self(), N}, + receive + {average, Ave} -> + Ave + end. diff --git a/Task/Averages-Simple-moving-average/Erlang/averages-simple-moving-average-2.erl b/Task/Averages-Simple-moving-average/Erlang/averages-simple-moving-average-2.erl new file mode 100644 index 0000000000..cd4390ca1e --- /dev/null +++ b/Task/Averages-Simple-moving-average/Erlang/averages-simple-moving-average-2.erl @@ -0,0 +1,12 @@ +9> sma:main(). +Added 1, sma(3) -> 1.000000, sma(5) -> 1.000000 +Added 2, sma(3) -> 1.500000, sma(5) -> 1.500000 +Added 3, sma(3) -> 2.000000, sma(5) -> 2.000000 +Added 4, sma(3) -> 3.000000, sma(5) -> 2.500000 +Added 5, sma(3) -> 4.000000, sma(5) -> 3.000000 +Added 5, sma(3) -> 4.666667, sma(5) -> 3.800000 +Added 4, sma(3) -> 4.666667, sma(5) -> 4.200000 +Added 3, sma(3) -> 4.000000, sma(5) -> 4.200000 +Added 2, sma(3) -> 3.000000, sma(5) -> 3.800000 +Added 1, sma(3) -> 2.000000, sma(5) -> 3.000000 +ok diff --git a/Task/Averages-Simple-moving-average/Forth/averages-simple-moving-average.fth b/Task/Averages-Simple-moving-average/Forth/averages-simple-moving-average.fth new file mode 100644 index 0000000000..d01e8bcba8 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Forth/averages-simple-moving-average.fth @@ -0,0 +1,27 @@ +: f+! ( f addr -- ) dup f@ f+ f! ; +: ,f0s ( n -- ) falign 0 do 0e f, loop ; + +: period @ ; +: used cell+ ; +: head 2 cells + ; +: sum 3 cells + faligned ; +: ring ( addr -- faddr ) + dup sum float+ swap head @ floats + ; + +: update ( fvalue addr -- addr ) + dup ring f@ fnegate dup sum f+! + fdup dup ring f! dup sum f+! + dup head @ 1+ over period mod over head ! ; + +: moving-average + create ( period -- ) dup , 0 , 0 , 1+ ,f0s + does> ( fvalue -- avg ) + update + dup used @ over period < if 1 over used +! then + dup sum f@ used @ 0 d>f f/ ; + +3 moving-average sma +1e sma f. \ 1. +2e sma f. \ 1.5 +3e sma f. \ 2. +4e sma f. \ 3. diff --git a/Task/Averages-Simple-moving-average/Fortran/averages-simple-moving-average.f b/Task/Averages-Simple-moving-average/Fortran/averages-simple-moving-average.f new file mode 100644 index 0000000000..6ae79e2b64 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Fortran/averages-simple-moving-average.f @@ -0,0 +1,33 @@ +program Movavg + implicit none + + integer :: i + + write (*, "(a)") "SIMPLE MOVING AVERAGE: PERIOD = 3" + + do i = 1, 5 + write (*, "(a, i2, a, f8.6)") "Next number:", i, " sma = ", sma(real(i)) + end do + do i = 5, 1, -1 + write (*, "(a, i2, a, f8.6)") "Next number:", i, " sma = ", sma(real(i)) + end do + +contains + +function sma(n) + real :: sma + real, intent(in) :: n + real, save :: a(3) = 0 + integer, save :: count = 0 + + if (count < 3) then + count = count + 1 + a(count) = n + else + a = eoshift(a, 1, n) + end if + + sma = sum(a(1:count)) / real(count) +end function + +end program Movavg diff --git a/Task/Averages-Simple-moving-average/Go/averages-simple-moving-average.go b/Task/Averages-Simple-moving-average/Go/averages-simple-moving-average.go new file mode 100644 index 0000000000..ec363bba81 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Go/averages-simple-moving-average.go @@ -0,0 +1,34 @@ +package main + +import "fmt" + +func sma(n int) func(float64) float64 { + s := make([]float64, 0, n) + i, sum, rn := 0, 0., 1/float64(n) + return func(x float64) float64 { + if len(s) < n { + sum += x + s = append(s, x) + return sum / float64(len(s)) + } + s[i] = x + i++ + if i == n { + i = 0 + } + sum = 0 + for _, x = range s { + sum += x + } + return sum * rn + } +} + +func main() { + sma3 := sma(3) + sma5 := sma(5) + fmt.Println("x sma3 sma5") + for _, x := range []float64{1, 2, 3, 4, 5, 5, 4, 3, 2, 1} { + fmt.Printf("%5.3f %5.3f %5.3f\n", x, sma3(x), sma5(x)) + } +} diff --git a/Task/Averages-Simple-moving-average/Haskell/averages-simple-moving-average.hs b/Task/Averages-Simple-moving-average/Haskell/averages-simple-moving-average.hs new file mode 100644 index 0000000000..21abba6e9a --- /dev/null +++ b/Task/Averages-Simple-moving-average/Haskell/averages-simple-moving-average.hs @@ -0,0 +1,10 @@ +import Data.List +import Control.Arrow +import Control.Monad + +sMA p = map (head *** head ).tail. + scanl (\(y,_) -> (id &&& return. av) . (: if length y == p then init y else y)) ([],[]) + where av = liftM2 (/) sum (fromIntegral.length) + +printSMA n p = mapM_ (\(n,a) -> putStrLn $ "Next number: " ++ show n ++ " Average: " ++ show a) + . take n . sMA p $ [1..5]++[5,4..1]++[3..] diff --git a/Task/Averages-Simple-moving-average/Java/averages-simple-moving-average.java b/Task/Averages-Simple-moving-average/Java/averages-simple-moving-average.java new file mode 100644 index 0000000000..3a6ca14b80 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Java/averages-simple-moving-average.java @@ -0,0 +1,38 @@ +import java.util.LinkedList; +import java.util.Queue; +public class MovingAverage { + private final Queue window = new LinkedList(); + private final int period; + private double sum; + + public MovingAverage(int period) { + assert period > 0 : "Period must be a positive integer"; + this.period = period; + } + + public void newNum(double num) { + sum += num; + window.add(num); + if (window.size() > period) { + sum -= window.remove(); + } + } + + public double getAvg() { + if (window.isEmpty()) return 0; // technically the average is undefined + return sum / window.size(); + } + + public static void main(String[] args) { + double[] testData = {1,2,3,4,5,5,4,3,2,1}; + int[] windowSizes = {3,5}; + for (int windSize : windowSizes) { + MovingAverage ma = new MovingAverage(windSize); + for (double x : testData) { + ma.newNum(x); + System.out.println("Next number = " + x + ", SMA = " + ma.getAvg()); + } + System.out.println(); + } + } +} diff --git a/Task/Averages-Simple-moving-average/JavaScript/averages-simple-moving-average.js b/Task/Averages-Simple-moving-average/JavaScript/averages-simple-moving-average.js new file mode 100644 index 0000000000..8085b441f6 --- /dev/null +++ b/Task/Averages-Simple-moving-average/JavaScript/averages-simple-moving-average.js @@ -0,0 +1,24 @@ +function simple_moving_averager(period) { + var nums = []; + return function(num) { + nums.push(num); + if (nums.length > period) + nums.splice(0,1); // remove the first element of the array + var sum = 0; + for (var i in nums) + sum += nums[i]; + var n = period; + if (nums.length < period) + n = nums.length; + return(sum/n); + } +} + +var sma3 = simple_moving_averager(3); +var sma5 = simple_moving_averager(5); +var data = [1,2,3,4,5,5,4,3,2,1]; +for (var i in data) { + var n = data[i]; + // using WSH + WScript.Echo("Next number = " + n + ", SMA_3 = " + sma3(n) + ", SMA_5 = " + sma5(n)); +} diff --git a/Task/Averages-Simple-moving-average/Lua/averages-simple-moving-average.lua b/Task/Averages-Simple-moving-average/Lua/averages-simple-moving-average.lua new file mode 100644 index 0000000000..623f0cbe66 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Lua/averages-simple-moving-average.lua @@ -0,0 +1,10 @@ +do + local t = {} + function f(a, b, ...) if b then return f(a+b, ...) else return a end end + function average(n) + if #t == 10 then table.remove(t, 1) end + t[#t + 1] = n + return f(unpack(t)) / #t + end +end +for v=1,30 do print(average(v)) end diff --git a/Task/Averages-Simple-moving-average/Perl/averages-simple-moving-average.pl b/Task/Averages-Simple-moving-average/Perl/averages-simple-moving-average.pl new file mode 100644 index 0000000000..ea33991644 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Perl/averages-simple-moving-average.pl @@ -0,0 +1,7 @@ +sub sma ($) + {my ($period, $sum, @a) = shift, 0; + return sub + {unshift @a, shift; + $sum += $a[0]; + @a > $period and $sum -= pop @a; + return $sum / @a;}} diff --git a/Task/Averages-Simple-moving-average/PicoLisp/averages-simple-moving-average-1.l b/Task/Averages-Simple-moving-average/PicoLisp/averages-simple-moving-average-1.l new file mode 100644 index 0000000000..831e7e52ea --- /dev/null +++ b/Task/Averages-Simple-moving-average/PicoLisp/averages-simple-moving-average-1.l @@ -0,0 +1,5 @@ +(de sma (@Len) + (curry (@Len (Data)) (N) + (push 'Data N) + (and (nth Data @Len) (con @)) # Truncate + (*/ (apply + Data) (length Data)) ) ) diff --git a/Task/Averages-Simple-moving-average/PicoLisp/averages-simple-moving-average-2.l b/Task/Averages-Simple-moving-average/PicoLisp/averages-simple-moving-average-2.l new file mode 100644 index 0000000000..d394f5c9d5 --- /dev/null +++ b/Task/Averages-Simple-moving-average/PicoLisp/averages-simple-moving-average-2.l @@ -0,0 +1,11 @@ +(def 'sma3 (sma 3)) +(def 'sma5 (sma 5)) + +(scl 2) +(for N (1.0 2.0 3.0 4.0 5.0 5.0 4.0 3.0 2.0 1.0) + (prinl + (format N *Scl) + " (sma3) " + (format (sma3 N) *Scl) + " (sma5) " + (format (sma5 N) *Scl) ) ) diff --git a/Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-1.py b/Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-1.py new file mode 100644 index 0000000000..2760de9e4c --- /dev/null +++ b/Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-1.py @@ -0,0 +1,17 @@ +from collections import deque + +def simplemovingaverage(period): + assert period == int(period) and period > 0, "Period must be an integer >0" + + summ = n = 0.0 + values = deque([0.0] * period) # old value queue + + def sma(x): + nonlocal summ, n + + values.append(x) + summ += x - values.popleft() + n = min(n+1, period) + return summ / n + + return sma diff --git a/Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-2.py b/Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-2.py new file mode 100644 index 0000000000..ea543a9cae --- /dev/null +++ b/Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-2.py @@ -0,0 +1,21 @@ +from collections import deque + +class Simplemovingaverage(): + def __init__(self, period): + assert period == int(period) and period > 0, "Period must be an integer >0" + self.period = period + self.stream = deque() + + def __call__(self, n): + stream = self.stream + stream.append(n) # appends on the right + streamlength = len(stream) + if streamlength > self.period: + stream.popleft() + streamlength -= 1 + if streamlength == 0: + average = 0 + else: + average = sum( stream ) / streamlength + + return average diff --git a/Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-3.py b/Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-3.py new file mode 100644 index 0000000000..625459956e --- /dev/null +++ b/Task/Averages-Simple-moving-average/Python/averages-simple-moving-average-3.py @@ -0,0 +1,15 @@ +if __name__ == '__main__': + for period in [3, 5]: + print ("\nSIMPLE MOVING AVERAGE (procedural): PERIOD =", period) + sma = simplemovingaverage(period) + for i in range(1,6): + print (" Next number = %-2g, SMA = %g " % (i, sma(i))) + for i in range(5, 0, -1): + print (" Next number = %-2g, SMA = %g " % (i, sma(i))) + for period in [3, 5]: + print ("\nSIMPLE MOVING AVERAGE (class based): PERIOD =", period) + sma = Simplemovingaverage(period) + for i in range(1,6): + print (" Next number = %-2g, SMA = %g " % (i, sma(i))) + for i in range(5, 0, -1): + print (" Next number = %-2g, SMA = %g " % (i, sma(i))) diff --git a/Task/Averages-Simple-moving-average/R/averages-simple-moving-average.r b/Task/Averages-Simple-moving-average/R/averages-simple-moving-average.r new file mode 100644 index 0000000000..4904407896 --- /dev/null +++ b/Task/Averages-Simple-moving-average/R/averages-simple-moving-average.r @@ -0,0 +1,31 @@ +#concat concatenates the new values to the existing vector of values, then discards any values that are too old. +lastvalues <- local( +{ + values <- c(); + function(x, len) + { + values <<- c(values, x); + lenv <- length(values); + if(lenv > len) values <<- values[(len-lenv):-1] + values + } +}) + +#moving.average accepts a numeric scalars input (and optionally a length, i.e. the number of values to retain) and calculates the stateful moving average. +moving.average <- function(latestvalue, len=3) +{ + #Check that all inputs are numeric scalars + is.numeric.scalar <- function(x) is.numeric(x) && length(x)==1L + if(!is.numeric.scalar(latestvalue) || !is.numeric.scalar(len)) + { + stop("all arguments must be numeric scalars") + } + + #Calculate mean of variables so far + mean(lastvalues(latestvalue, len)) +} +moving.average(5) # 5 +moving.average(1) # 3 +moving.average(-3) # 1 +moving.average(8) # 2 +moving.average(7) # 4 diff --git a/Task/Averages-Simple-moving-average/REXX/averages-simple-moving-average.rexx b/Task/Averages-Simple-moving-average/REXX/averages-simple-moving-average.rexx new file mode 100644 index 0000000000..ce756c022e --- /dev/null +++ b/Task/Averages-Simple-moving-average/REXX/averages-simple-moving-average.rexx @@ -0,0 +1,35 @@ +/*REXX program is illustrate simple moving average. */ +arg p q n . /*get some arguments (maybe). */ +if p=='' then p=3 /*the 1st period (default: 3).*/ +if q=='' then q=5 /* " 2nd " " 5 */ +if n=='' then n=10 /*number of items in the list.*/ +a.=0 + do j=1 for n%2 /*build beginning of the list,*/ + a.j=j /* ... increasing values. */ + end /*j*/ + + do k=n%2 to 1 by -1 /* ... decreasing values. */ + a.j=k + j=j+1 + end /*k*/ + + do i=1 for n /*show an indented item list. */ + say left('',60) 'item' right(i,3)'='right(a.i,3) + end /*i*/ + do m=1 for n /*OK the, let's start the SMA.*/ + smaP=sma(p,m) /*simple moving average for P.*/ + smaQ=sma(q,m) /* " " " " Q.*/ + + /*show 2 nicely formated SMAs.*/ + say 'm='right(m,3), /*show where we're at in list.*/ + " sma("p')='left(sma(p,m),11), /*show nicely aligned sma P. */ + " sma("q')='left(sma(q,m),11) /* " " " " Q. */ + end /*m*/ +exit +/*────────────────────────────────────────SMA subroutine────────────────*/ +sma: procedure expose A.; arg p,j; s=0; i=0 + do k=max(1,j-p+1) to j+p for p while k<=j + i=i+1 + s=s+a.k + end +return s/i diff --git a/Task/Averages-Simple-moving-average/Ruby/averages-simple-moving-average-1.rb b/Task/Averages-Simple-moving-average/Ruby/averages-simple-moving-average-1.rb new file mode 100644 index 0000000000..063aaa2398 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Ruby/averages-simple-moving-average-1.rb @@ -0,0 +1,18 @@ +def simple_moving_average(size) + nums = [] + sum = 0.0 + lambda do |hello| + nums << hello + goodbye = nums.length > size ? nums.shift : 0 + sum += hello - goodbye + sum / nums.length + end +end + +ma3 = simple_moving_average(3) +ma5 = simple_moving_average(5) + +(1.upto(5).to_a + 5.downto(1).to_a).each do |num| + printf "Next number = %d, SMA_3 = %.3f, SMA_5 = %.1f\n", + num, ma3.call(num), ma5.call(num) +end diff --git a/Task/Averages-Simple-moving-average/Ruby/averages-simple-moving-average-2.rb b/Task/Averages-Simple-moving-average/Ruby/averages-simple-moving-average-2.rb new file mode 100644 index 0000000000..a2e6f235a6 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Ruby/averages-simple-moving-average-2.rb @@ -0,0 +1,28 @@ +class MovingAverager + def initialize(size) + @size = size + @nums = [] + @sum = 0.0 + end + def <<(hello) + @nums << hello + goodbye = @nums.length > @size ? @nums.shift : 0 + @sum += hello - goodbye + self + end + def average + @sum / @nums.length + end + alias to_f average + def to_s + average.to_s + end +end + +ma3 = MovingAverager.new(3) +ma5 = MovingAverager.new(5) + +(1.upto(5).to_a + 5.downto(1).to_a).each do |num| + printf "Next number = %d, SMA_3 = %.3f, SMA_5 = %.1f\n", + num, ma3 << num, ma5 < period) + queue.dequeue + queue.sum / queue.size + } + override def toString = queue.mkString("(", ", ", ")")+", period "+period+", average "+(queue.sum / queue.size) + def clear = queue.clear +} diff --git a/Task/Averages-Simple-moving-average/Scheme/averages-simple-moving-average.ss b/Task/Averages-Simple-moving-average/Scheme/averages-simple-moving-average.ss new file mode 100644 index 0000000000..13e5fbc594 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Scheme/averages-simple-moving-average.ss @@ -0,0 +1,6 @@ +(define ((simple-moving-averager size . nums) num) + (set! nums (cons num (if (= (length nums) size) (reverse (cdr (reverse nums))) nums))) + (/ (apply + nums) (length nums))) + +(define av (simple-moving-averager 3)) +(map av '(1 2 3 4 5 5 4 3 2 1)) diff --git a/Task/Averages-Simple-moving-average/Smalltalk/averages-simple-moving-average-1.st b/Task/Averages-Simple-moving-average/Smalltalk/averages-simple-moving-average-1.st new file mode 100644 index 0000000000..047a78270f --- /dev/null +++ b/Task/Averages-Simple-moving-average/Smalltalk/averages-simple-moving-average-1.st @@ -0,0 +1,31 @@ +Object subclass: MovingAverage [ + |valueCollection period collectedNumber sum| + MovingAverage class >> newWithPeriod: thePeriod [ + |r| + r := super basicNew. + ^ r initWithPeriod: thePeriod + ] + initWithPeriod: thePeriod [ + valueCollection := OrderedCollection new: thePeriod. + period := thePeriod. + collectedNumber := 0. + sum := 0 + ] + sma [ collectedNumber < period + ifTrue: [ ^ sum / collectedNumber ] + ifFalse: [ ^ sum / period ] ] + add: value [ + collectedNumber < period + ifTrue: [ + sum := sum + value. + valueCollection add: value. + collectedNumber := collectedNumber + 1. + ] + ifFalse: [ + sum := sum - (valueCollection removeFirst). + sum := sum + value. + valueCollection add: value + ]. + ^ self sma + ] +]. diff --git a/Task/Averages-Simple-moving-average/Smalltalk/averages-simple-moving-average-2.st b/Task/Averages-Simple-moving-average/Smalltalk/averages-simple-moving-average-2.st new file mode 100644 index 0000000000..e978a96308 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Smalltalk/averages-simple-moving-average-2.st @@ -0,0 +1,10 @@ +|sma3 sma5| + +sma3 := MovingAverage newWithPeriod: 3. +sma5 := MovingAverage newWithPeriod: 5. + +#( 1 2 3 4 5 5 4 3 2 1 ) do: [ :v | + ('Next number %1, SMA_3 = %2, SMA_5 = %3' % { + v . (sma3 add: v) asFloat . (sma5 add: v) asFloat + }) displayNl +] diff --git a/Task/Averages-Simple-moving-average/Tcl/averages-simple-moving-average-1.tcl b/Task/Averages-Simple-moving-average/Tcl/averages-simple-moving-average-1.tcl new file mode 100644 index 0000000000..688dc9c48e --- /dev/null +++ b/Task/Averages-Simple-moving-average/Tcl/averages-simple-moving-average-1.tcl @@ -0,0 +1,11 @@ +oo::class create SimpleMovingAverage { + variable vals idx + constructor {{period 3}} { + set idx end-[expr {$period-1}] + set vals {} + } + method val x { + set vals [lrange [list {*}$vals $x] $idx end] + expr {[tcl::mathop::+ {*}$vals]/double([llength $vals])} + } +} diff --git a/Task/Averages-Simple-moving-average/Tcl/averages-simple-moving-average-2.tcl b/Task/Averages-Simple-moving-average/Tcl/averages-simple-moving-average-2.tcl new file mode 100644 index 0000000000..c08cfa150b --- /dev/null +++ b/Task/Averages-Simple-moving-average/Tcl/averages-simple-moving-average-2.tcl @@ -0,0 +1,5 @@ +SimpleMovingAverage create averager3 +SimpleMovingAverage create averager5 5 +foreach n {1 2 3 4 5 5 4 3 2 1} { + puts "Next number = $n, SMA_3 = [averager3 val $n], SMA_5 = [averager5 val $n]" +}