From 764da6cbbb704418f95af4d390566a5a361dd354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Wed, 10 Apr 2013 16:57:12 -0700 Subject: [PATCH] CDE --- .gitignore | 1 + Conf/.lang.yaml.swp | Bin 12288 -> 0 bytes Conf/.task.yaml.swp | Bin 12288 -> 0 bytes Conf/lang.yaml | 77 ++ Conf/task.yaml | 110 ++- Lang/0815/Count-in-octal | 1 + Lang/0815/Even-or-odd | 1 + Lang/4DOS-Batch/Create-a-file | 1 + Lang/6502-Assembly/Conditional-structures | 1 + Lang/6502-Assembly/Conways-Game-of-Life | 1 + .../Create-an-object-at-a-given-address | 1 + Lang/ABAP/Character-codes | 1 + Lang/ABAP/Date-format | 1 + Lang/ABAP/Day-of-the-week | 1 + Lang/ABAP/Dot-product | 1 + Lang/ACL2/Character-codes | 1 + Lang/ACL2/Compound-data-type | 1 + Lang/ACL2/Conways-Game-of-Life | 1 + Lang/ACL2/Dot-product | 1 + Lang/ACL2/Empty-string | 1 + Lang/ACL2/Enforced-immutability | 1 + Lang/ACL2/Enumerations | 1 + Lang/ACL2/Ethiopian-multiplication | 1 + Lang/ACL2/Evaluate-binomial-coefficients | 1 + Lang/ALGOL-68/CSV-to-HTML-translation | 1 + Lang/ALGOL-68/Calendar-for-real-programmers | 1 + Lang/ALGOL-68/Character-codes | 1 + Lang/ALGOL-68/Character-matching | 1 + Lang/ALGOL-68/Cholesky-decomposition | 1 + Lang/ALGOL-68/Combinations | 1 + Lang/ALGOL-68/Command-line-arguments | 1 + Lang/ALGOL-68/Compound-data-type | 1 + Lang/ALGOL-68/Concurrent-computing | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/ALGOL-68/Count-in-octal | 1 + .../ALGOL-68/Count-occurrences-of-a-substring | 1 + Lang/ALGOL-68/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/ALGOL-68/Date-format | 1 + Lang/ALGOL-68/Day-of-the-week | 1 + Lang/ALGOL-68/Dot-product | 1 + Lang/ALGOL-68/Doubly-linked-list-Definition | 1 + .../Doubly-linked-list-Element-definition | 1 + .../Doubly-linked-list-Element-insertion | 1 + Lang/ALGOL-68/Element-wise-operations | 1 + Lang/ALGOL-68/Empty-program | 1 + Lang/ALGOL-68/Enforced-immutability | 1 + Lang/ALGOL-68/Enumerations | 1 + Lang/ALGOL-68/Equilibrium-index | 1 + Lang/ALGOL-68/Ethiopian-multiplication | 1 + Lang/ALGOL-68/Euler-method | 1 + Lang/ALGOL-68/Evaluate-binomial-coefficients | 1 + Lang/ALGOL-68/Evolutionary-algorithm | 1 + Lang/ALGOL-68/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/ALGOL-68/Execute-a-system-command | 1 + Lang/ALGOL-68/Exponentiation-operator | 1 + Lang/APL/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/ATS/Continued-fraction | 1 + Lang/AWK/CSV-to-HTML-translation | 1 + Lang/AWK/Call-a-function | 1 + Lang/AWK/Case-sensitivity-of-identifiers | 1 + Lang/AWK/Character-codes | 1 + Lang/AWK/Combinations | 1 + Lang/AWK/Command-line-arguments | 1 + Lang/AWK/Compound-data-type | 1 + Lang/AWK/Conditional-structures | 1 + Lang/AWK/Conways-Game-of-Life | 1 + Lang/AWK/Count-in-octal | 1 + Lang/AWK/Count-occurrences-of-a-substring | 1 + Lang/AWK/Count-the-coins | 1 + Lang/AWK/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/AWK/Create-an-HTML-table | 1 + Lang/AWK/Date-format | 1 + Lang/AWK/Day-of-the-week | 1 + Lang/AWK/Discordian-date | 1 + Lang/AWK/Empty-program | 1 + Lang/AWK/Empty-string | 1 + Lang/AWK/Enumerations | 1 + Lang/AWK/Ethiopian-multiplication | 1 + Lang/AWK/Even-or-odd | 1 + Lang/AWK/Execute-a-system-command | 1 + Lang/AWK/Exponentiation-operator | 1 + Lang/AWK/Extreme-floating-point-values | 1 + Lang/ActionScript/Call-a-function | 1 + Lang/ActionScript/Call-an-object-method | 1 + Lang/ActionScript/Character-codes | 1 + Lang/ActionScript/Compound-data-type | 1 + Lang/ActionScript/Dot-product | 1 + Lang/ActionScript/Ethiopian-multiplication | 1 + Lang/Ada/CRC-32 | 1 + Lang/Ada/CSV-to-HTML-translation | 1 + Lang/Ada/Calendar-for-real-programmers | 1 + Lang/Ada/Call-a-foreign-language-function | 1 + Lang/Ada/Call-a-function | 1 + Lang/Ada/Call-a-function-in-a-shared-library | 1 + Lang/Ada/Carmichael-3-strong-pseudoprimes | 1 + Lang/Ada/Case-sensitivity-of-identifiers | 1 + Lang/Ada/Character-codes | 1 + Lang/Ada/Character-matching | 1 + Lang/Ada/Chat-server | 1 + Lang/Ada/Cholesky-decomposition | 1 + Lang/Ada/Combinations | 1 + Lang/Ada/Combinations-with-repetitions | 1 + Lang/Ada/Command-line-arguments | 1 + Lang/Ada/Compile-time-calculation | 1 + Lang/Ada/Compound-data-type | 1 + Lang/Ada/Concurrent-computing | 1 + Lang/Ada/Conditional-structures | 1 + Lang/Ada/Constrained-genericity | 1 + .../Ada/Constrained-random-points-on-a-circle | 1 + Lang/Ada/Continued-fraction | 1 + Lang/Ada/Conways-Game-of-Life | 1 + Lang/Ada/Count-in-factors | 1 + Lang/Ada/Count-in-octal | 1 + Lang/Ada/Count-occurrences-of-a-substring | 1 + Lang/Ada/Count-the-coins | 1 + Lang/Ada/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Ada/Create-an-HTML-table | 1 + Lang/Ada/Create-an-object-at-a-given-address | 1 + Lang/Ada/DNS-query | 1 + Lang/Ada/Date-format | 1 + Lang/Ada/Date-manipulation | 1 + Lang/Ada/Day-of-the-week | 1 + Lang/Ada/Deal-cards-for-FreeCell | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/Ada/Digital-root | 1 + Lang/Ada/Dinesmans-multiple-dwelling-problem | 1 + Lang/Ada/Dining-philosophers | 1 + Lang/Ada/Discordian-date | 1 + Lang/Ada/Distributed-programming | 1 + Lang/Ada/Documentation | 1 + Lang/Ada/Dot-product | 1 + .../Ada/Doubly-linked-list-Element-definition | 1 + Lang/Ada/Doubly-linked-list-Element-insertion | 1 + Lang/Ada/Doubly-linked-list-Traversal | 1 + Lang/Ada/Draw-a-cuboid | 1 + Lang/Ada/Draw-a-sphere | 1 + Lang/Ada/Dutch-national-flag-problem | 1 + Lang/Ada/Echo-server | 1 + Lang/Ada/Element-wise-operations | 1 + Lang/Ada/Empty-directory | 1 + Lang/Ada/Empty-program | 1 + Lang/Ada/Empty-string | 1 + Lang/Ada/Enforced-immutability | 1 + Lang/Ada/Enumerations | 1 + Lang/Ada/Equilibrium-index | 1 + Lang/Ada/Ethiopian-multiplication | 1 + Lang/Ada/Euler-method | 1 + Lang/Ada/Evaluate-binomial-coefficients | 1 + Lang/Ada/Even-or-odd | 1 + Lang/Ada/Events | 1 + Lang/Ada/Evolutionary-algorithm | 1 + Lang/Ada/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Ada/Executable-library | 1 + Lang/Ada/Execute-a-system-command | 1 + Lang/Ada/Exponentiation-operator | 1 + Lang/Ada/Extreme-floating-point-values | 1 + Lang/Agena/Empty-program | 1 + Lang/Aikido/Call-a-foreign-language-function | 1 + Lang/Aikido/Command-line-arguments | 1 + Lang/Aikido/Conditional-structures | 1 + Lang/Aikido/Create-a-file | 1 + .../Create-an-object-at-a-given-address | 1 + Lang/Aikido/Exceptions | 1 + Lang/Aikido/Execute-a-system-command | 1 + Lang/Aime/Character-codes | 1 + Lang/Aime/Conditional-structures | 1 + Lang/Aime/Execute-a-system-command | 1 + Lang/AmbientTalk/Conditional-structures | 1 + Lang/AmigaE/Compound-data-type | 1 + Lang/AmigaE/Conditional-structures | 1 + Lang/AmigaE/Empty-program | 1 + Lang/AmigaE/Enumerations | 1 + Lang/AppleScript/Combinations | 1 + Lang/AppleScript/Command-line-arguments | 1 + Lang/AppleScript/Conditional-structures | 1 + Lang/AppleScript/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/AppleScript/Date-manipulation | 1 + Lang/AppleScript/Day-of-the-week | 1 + Lang/AppleScript/Empty-program | 1 + .../Evaluate-binomial-coefficients | 1 + Lang/AppleScript/Exceptions | 1 + Lang/AppleScript/Execute-a-system-command | 1 + Lang/Argile/Empty-program | 1 + Lang/AutoHotkey/CSV-to-HTML-translation | 1 + .../Call-a-foreign-language-function | 1 + Lang/AutoHotkey/Call-a-function | 1 + .../Call-a-function-in-a-shared-library | 1 + Lang/AutoHotkey/Call-an-object-method | 1 + .../Case-sensitivity-of-identifiers | 1 + Lang/AutoHotkey/Character-codes | 1 + Lang/AutoHotkey/Character-matching | 1 + Lang/AutoHotkey/Colour-bars-Display | 1 + Lang/AutoHotkey/Colour-pinstripe-Display | 1 + Lang/AutoHotkey/Combinations | 1 + Lang/AutoHotkey/Command-line-arguments | 1 + .../Compare-sorting-algorithms-performance | 1 + Lang/AutoHotkey/Compound-data-type | 1 + Lang/AutoHotkey/Conditional-structures | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/AutoHotkey/Conways-Game-of-Life | 1 + Lang/AutoHotkey/Count-in-factors | 1 + Lang/AutoHotkey/Count-in-octal | 1 + .../Count-occurrences-of-a-substring | 1 + Lang/AutoHotkey/Count-the-coins | 1 + Lang/AutoHotkey/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/AutoHotkey/Create-an-HTML-table | 1 + .../Create-an-object-at-a-given-address | 1 + Lang/AutoHotkey/Date-format | 1 + Lang/AutoHotkey/Date-manipulation | 1 + Lang/AutoHotkey/Day-of-the-week | 1 + Lang/AutoHotkey/Documentation | 1 + Lang/AutoHotkey/Dot-product | 1 + Lang/AutoHotkey/Dynamic-variable-names | 1 + Lang/AutoHotkey/Echo-server | 1 + Lang/AutoHotkey/Empty-program | 1 + Lang/AutoHotkey/Empty-string | 1 + Lang/AutoHotkey/Enforced-immutability | 1 + Lang/AutoHotkey/Enumerations | 1 + Lang/AutoHotkey/Ethiopian-multiplication | 1 + .../AutoHotkey/Evaluate-binomial-coefficients | 1 + Lang/AutoHotkey/Even-or-odd | 1 + Lang/AutoHotkey/Events | 1 + Lang/AutoHotkey/Evolutionary-algorithm | 1 + Lang/AutoHotkey/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/AutoHotkey/Executable-library | 1 + Lang/AutoHotkey/Execute-HQ9+ | 1 + Lang/AutoHotkey/Execute-a-system-command | 1 + Lang/AutoHotkey/Exponentiation-operator | 1 + Lang/AutoIt/CSV-to-HTML-translation | 1 + Lang/AutoIt/Character-matching | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/AutoIt/Day-of-the-week | 1 + Lang/AutoIt/Dutch-national-flag-problem | 1 + Lang/AutoIt/Empty-program | 1 + Lang/AutoIt/Ethiopian-multiplication | 1 + Lang/Axiom/Continued-fraction | 1 + Lang/BASIC/Character-codes | 1 + Lang/BASIC/Character-matching | 1 + Lang/BASIC/Command-line-arguments | 1 + Lang/BASIC/Compile-time-calculation | 1 + Lang/BASIC/Compound-data-type | 1 + Lang/BASIC/Conditional-structures | 1 + Lang/BASIC/Count-in-octal | 1 + Lang/BASIC/Count-occurrences-of-a-substring | 1 + Lang/BASIC/Create-a-file | 1 + Lang/BASIC/Date-format | 1 + Lang/BASIC/Digital-root | 1 + Lang/BASIC/Discordian-date | 1 + Lang/BASIC/Draw-a-sphere | 1 + Lang/BASIC/Dynamic-variable-names | 1 + Lang/BASIC/Empty-program | 1 + Lang/BASIC/Empty-string | 1 + Lang/BASIC/Enforced-immutability | 1 + Lang/BASIC/Enumerations | 1 + Lang/BASIC/Ethiopian-multiplication | 1 + Lang/BASIC/Even-or-odd | 1 + Lang/BASIC/Execute-a-system-command | 1 + Lang/BASIC/Exponentiation-operator | 1 + Lang/BASIC256/Conways-Game-of-Life | 1 + Lang/BBC-BASIC/CSV-to-HTML-translation | 1 + Lang/BBC-BASIC/Calendar-for-real-programmers | 1 + .../Call-a-foreign-language-function | 1 + .../Call-a-function-in-a-shared-library | 1 + .../BBC-BASIC/Case-sensitivity-of-identifiers | 1 + Lang/BBC-BASIC/Character-codes | 1 + Lang/BBC-BASIC/Character-matching | 1 + Lang/BBC-BASIC/Cholesky-decomposition | 1 + Lang/BBC-BASIC/Colour-bars-Display | 1 + Lang/BBC-BASIC/Colour-pinstripe-Display | 1 + Lang/BBC-BASIC/Colour-pinstripe-Printer | 1 + Lang/BBC-BASIC/Combinations | 1 + Lang/BBC-BASIC/Combinations-with-repetitions | 1 + Lang/BBC-BASIC/Command-line-arguments | 1 + .../Compare-sorting-algorithms-performance | 1 + Lang/BBC-BASIC/Compound-data-type | 1 + Lang/BBC-BASIC/Concurrent-computing | 1 + Lang/BBC-BASIC/Conditional-structures | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/BBC-BASIC/Continued-fraction | 1 + Lang/BBC-BASIC/Conways-Game-of-Life | 1 + Lang/BBC-BASIC/Count-in-factors | 1 + Lang/BBC-BASIC/Count-in-octal | 1 + .../Count-occurrences-of-a-substring | 1 + Lang/BBC-BASIC/Count-the-coins | 1 + Lang/BBC-BASIC/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/BBC-BASIC/Create-an-HTML-table | 1 + .../Create-an-object-at-a-given-address | 1 + Lang/BBC-BASIC/DNS-query | 1 + Lang/BBC-BASIC/Date-format | 1 + Lang/BBC-BASIC/Date-manipulation | 1 + Lang/BBC-BASIC/Day-of-the-week | 1 + Lang/BBC-BASIC/Deal-cards-for-FreeCell | 1 + Lang/BBC-BASIC/Deconvolution-1D | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/BBC-BASIC/Digital-root | 1 + .../Dinesmans-multiple-dwelling-problem | 1 + Lang/BBC-BASIC/Dining-philosophers | 1 + Lang/BBC-BASIC/Discordian-date | 1 + Lang/BBC-BASIC/Dot-product | 1 + .../Doubly-linked-list-Element-definition | 1 + .../Doubly-linked-list-Element-insertion | 1 + Lang/BBC-BASIC/Doubly-linked-list-Traversal | 1 + Lang/BBC-BASIC/Draw-a-cuboid | 1 + Lang/BBC-BASIC/Draw-a-sphere | 1 + Lang/BBC-BASIC/Dutch-national-flag-problem | 1 + Lang/BBC-BASIC/Dynamic-variable-names | 1 + Lang/BBC-BASIC/Echo-server | 1 + Lang/BBC-BASIC/Element-wise-operations | 1 + Lang/BBC-BASIC/Empty-directory | 1 + Lang/BBC-BASIC/Empty-program | 1 + Lang/BBC-BASIC/Empty-string | 1 + Lang/BBC-BASIC/Enforced-immutability | 1 + Lang/BBC-BASIC/Equilibrium-index | 1 + Lang/BBC-BASIC/Ethiopian-multiplication | 1 + Lang/BBC-BASIC/Euler-method | 1 + Lang/BBC-BASIC/Evaluate-binomial-coefficients | 1 + Lang/BBC-BASIC/Even-or-odd | 1 + Lang/BBC-BASIC/Events | 1 + Lang/BBC-BASIC/Evolutionary-algorithm | 1 + Lang/BBC-BASIC/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/BBC-BASIC/Executable-library | 1 + Lang/BBC-BASIC/Execute-HQ9+ | 1 + Lang/BBC-BASIC/Execute-a-system-command | 1 + Lang/BBC-BASIC/Exponentiation-operator | 1 + Lang/Batch-File/Command-line-arguments | 1 + Lang/Batch-File/Create-a-file | 1 + Lang/Batch-File/Dynamic-variable-names | 1 + Lang/Batch-File/Empty-program | 1 + Lang/Befunge/Character-codes | 1 + Lang/Befunge/Conditional-structures | 1 + Lang/Bori/Conditional-structures | 1 + Lang/Bracmat/Character-matching | 1 + Lang/Bracmat/Combinations | 1 + Lang/Bracmat/Command-line-arguments | 1 + Lang/Bracmat/Compound-data-type | 1 + Lang/Bracmat/Conditional-structures | 1 + Lang/Bracmat/Count-in-octal | 1 + Lang/Bracmat/Count-occurrences-of-a-substring | 1 + Lang/Bracmat/Create-a-file | 1 + Lang/Bracmat/Deal-cards-for-FreeCell | 1 + .../Dinesmans-multiple-dwelling-problem | 1 + Lang/Bracmat/Dot-product | 1 + Lang/Bracmat/Dynamic-variable-names | 1 + Lang/Bracmat/Empty-program | 1 + Lang/Bracmat/Empty-string | 1 + Lang/Bracmat/Evaluate-binomial-coefficients | 1 + Lang/Bracmat/Even-or-odd | 1 + Lang/Bracmat/Execute-a-system-command | 1 + Lang/Brainf---/Conditional-structures | 1 + Lang/Brainf---/Count-in-octal | 1 + Lang/Brainf---/Even-or-odd | 1 + Lang/Brat/Execute-a-system-command | 1 + Lang/Brat/Exponentiation-operator | 1 + Lang/Brlcad/Case-sensitivity-of-identifiers | 1 + Lang/Brlcad/Draw-a-cuboid | 1 + Lang/Brlcad/Draw-a-sphere | 1 + Lang/Brlcad/Empty-program | 1 + Lang/Brlcad/Execute-a-system-command | 1 + Lang/Burlesque/Conditional-structures | 1 + Lang/Burlesque/Evaluate-binomial-coefficients | 1 + Lang/Burlesque/Even-or-odd | 1 + Lang/C++-CLI/0DESCRIPTION | 2 + Lang/C++-CLI/Color-of-a-screen-pixel | 1 + Lang/C++/0DESCRIPTION | 30 + Lang/C++/100-doors | 1 + Lang/C++/24-game | 1 + Lang/C++/99-Bottles-of-Beer | 1 + Lang/C++/A+B | 1 + Lang/C++/Abstract-type | 1 + Lang/C++/Accumulator-factory | 1 + Lang/C++/Ackermann-function | 1 + Lang/C++/Anagrams | 1 + Lang/C++/Animate-a-pendulum | 1 + Lang/C++/Anonymous-recursion | 1 + Lang/C++/Apply-a-callback-to-an-array | 1 + Lang/C++/Arena-storage-pool | 1 + Lang/C++/Arithmetic-Complex | 1 + Lang/C++/Arithmetic-Integer | 1 + Lang/C++/Arithmetic-Rational | 1 + Lang/C++/Arithmetic-evaluation | 1 + Lang/C++/Arithmetic-geometric-mean | 1 + Lang/C++/Array-concatenation | 1 + Lang/C++/Arrays | 1 + Lang/C++/Assertions | 1 + Lang/C++/Associative-array-Creation | 1 + Lang/C++/Associative-array-Iteration | 1 + Lang/C++/Averages-Arithmetic-mean | 1 + Lang/C++/Averages-Median | 1 + Lang/C++/Averages-Mode | 1 + Lang/C++/Averages-Pythagorean-means | 1 + Lang/C++/Averages-Root-mean-square | 1 + Lang/C++/Averages-Simple-moving-average | 1 + Lang/C++/Balanced-brackets | 1 + Lang/C++/Binary-search | 1 + Lang/C++/Bitmap | 1 + Lang/C++/Bitmap-Bresenhams-line-algorithm | 1 + Lang/C++/Bitwise-operations | 1 + Lang/C++/Box-the-compass | 1 + Lang/C++/Break-OO-privacy | 1 + Lang/C++/Bulls-and-cows | 1 + Lang/C++/CSV-to-HTML-translation | 1 + Lang/C++/Caesar-cipher | 1 + Lang/C++/Call-a-foreign-language-function | 1 + Lang/C++/Call-an-object-method | 1 + Lang/C++/Character-codes | 1 + Lang/C++/Character-matching | 1 + Lang/C++/Check-that-file-exists | 1 + Lang/C++/Classes | 1 + Lang/C++/Collections | 1 + Lang/C++/Colour-bars-Display | 1 + Lang/C++/Combinations | 1 + Lang/C++/Command-line-arguments | 1 + Lang/C++/Comments | 1 + Lang/C++/Compile-time-calculation | 1 + Lang/C++/Compound-data-type | 1 + Lang/C++/Concurrent-computing | 1 + Lang/C++/Conditional-structures | 1 + Lang/C++/Continued-fraction | 1 + ...-Arithmetic-Construct-from-rational-number | 1 + ...ithmetic-G(matrix-NG,-Contined-Fraction-N) | 1 + ...ontined-Fraction-N1,-Contined-Fraction-N2) | 1 + Lang/C++/Conways-Game-of-Life | 1 + Lang/C++/Count-in-octal | 1 + Lang/C++/Count-occurrences-of-a-substring | 1 + Lang/C++/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/C++/Create-an-HTML-table | 1 + Lang/C++/Create-an-object-at-a-given-address | 1 + Lang/C++/Date-format | 1 + Lang/C++/Date-manipulation | 1 + Lang/C++/Day-of-the-week | 1 + Lang/C++/Define-a-primitive-data-type | 1 + Lang/C++/Delegates | 1 + Lang/C++/Delete-a-file | 1 + Lang/C++/Determine-if-a-string-is-numeric | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/C++/Digital-root | 1 + Lang/C++/Dining-philosophers | 1 + Lang/C++/Dot-product | 1 + Lang/C++/Dutch-national-flag-problem | 1 + Lang/C++/Empty-program | 1 + Lang/C++/Empty-string | 1 + Lang/C++/Enforced-immutability | 1 + Lang/C++/Enumerations | 1 + Lang/C++/Equilibrium-index | 1 + Lang/C++/Ethiopian-multiplication | 1 + Lang/C++/Euler-method | 1 + Lang/C++/Evaluate-binomial-coefficients | 1 + Lang/C++/Even-or-odd | 1 + Lang/C++/Evolutionary-algorithm | 1 + Lang/C++/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/C++/Execute-HQ9+ | 1 + Lang/C++/Execute-a-system-command | 1 + Lang/C++/Exponentiation-operator | 1 + Lang/C++/FizzBuzz | 1 + Lang/C++/Infinity | 1 + Lang/C++/JSON | 1 + Lang/C++/Knuth-shuffle | 1 + Lang/C++/Ordered-words | 1 + Lang/C++/Pi | 1 + Lang/C++/Quine | 1 + Lang/C++/Search-a-list | 1 + Lang/C-Shell/0DESCRIPTION | 108 +++ Lang/C-sharp/0DESCRIPTION | 23 + Lang/C-sharp/100-doors | 1 + Lang/C-sharp/99-Bottles-of-Beer | 1 + Lang/C-sharp/Abstract-type | 1 + Lang/C-sharp/Ackermann-function | 1 + Lang/C-sharp/Address-of-a-variable | 1 + Lang/C-sharp/Align-columns | 1 + Lang/C-sharp/Animate-a-pendulum | 1 + Lang/C-sharp/Animation | 1 + Lang/C-sharp/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/C-sharp/Arithmetic-Complex | 1 + Lang/C-sharp/Arithmetic-geometric-mean | 1 + Lang/C-sharp/Array-concatenation | 1 + Lang/C-sharp/Arrays | 1 + Lang/C-sharp/Assertions | 1 + Lang/C-sharp/Associative-array-Creation | 1 + Lang/C-sharp/Associative-array-Iteration | 1 + Lang/C-sharp/Atomic-updates | 1 + Lang/C-sharp/Averages-Arithmetic-mean | 1 + Lang/C-sharp/Break-OO-privacy | 1 + Lang/C-sharp/CSV-to-HTML-translation | 1 + Lang/C-sharp/Case-sensitivity-of-identifiers | 1 + Lang/C-sharp/Conways-Game-of-Life | 1 + Lang/C-sharp/Count-occurrences-of-a-substring | 1 + Lang/C-sharp/Create-an-HTML-table | 1 + Lang/C-sharp/DNS-query | 1 + Lang/C-sharp/Deepcopy | 1 + Lang/C-sharp/Delegates | 1 + Lang/C-sharp/Doubly-linked-list-Definition | 1 + Lang/C-sharp/Doubly-linked-list-Traversal | 1 + Lang/C-sharp/Empty-string | 1 + Lang/C-sharp/Euler-method | 1 + Lang/C-sharp/Execute-HQ9+ | 1 + Lang/C-sharp/Forest-fire | 1 + Lang/C-sharp/JSON | 1 + Lang/C-sharp/Quine | 1 + Lang/C/CRC-32 | 1 + Lang/C/CSV-to-HTML-translation | 1 + Lang/C/Call-a-function | 1 + Lang/C/Call-a-function-in-a-shared-library | 1 + Lang/C/Canny-edge-detector | 1 + Lang/C/Case-sensitivity-of-identifiers | 1 + Lang/C/Catmull-Clark-subdivision-surface | 1 + Lang/C/Character-codes | 1 + Lang/C/Character-matching | 1 + Lang/C/Chat-server | 1 + Lang/C/Cholesky-decomposition | 1 + Lang/C/Color-quantization | 1 + Lang/C/Combinations | 1 + Lang/C/Combinations-with-repetitions | 1 + Lang/C/Command-line-arguments | 1 + Lang/C/Compare-sorting-algorithms-performance | 1 + Lang/C/Compile-time-calculation | 1 + Lang/C/Compound-data-type | 1 + Lang/C/Concurrent-computing | 1 + Lang/C/Constrained-random-points-on-a-circle | 1 + Lang/C/Continued-fraction | 1 + Lang/C/Conways-Game-of-Life | 1 + Lang/C/Count-in-factors | 1 + Lang/C/Count-in-octal | 1 + Lang/C/Count-occurrences-of-a-substring | 1 + Lang/C/Count-the-coins | 1 + Lang/C/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/C/Create-an-HTML-table | 1 + Lang/C/Create-an-object-at-a-given-address | 1 + Lang/C/Cut-a-rectangle | 1 + Lang/C/Date-format | 1 + Lang/C/Date-manipulation | 1 + Lang/C/Day-of-the-week | 1 + Lang/C/Deal-cards-for-FreeCell | 1 + Lang/C/Deconvolution-1D | 1 + Lang/C/Deconvolution-2D+ | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/C/Digital-root | 1 + Lang/C/Dinesmans-multiple-dwelling-problem | 1 + Lang/C/Dining-philosophers | 1 + Lang/C/Discordian-date | 1 + Lang/C/Distributed-programming | 1 + Lang/C/Documentation | 1 + Lang/C/Dot-product | 1 + Lang/C/Doubly-linked-list-Definition | 1 + Lang/C/Doubly-linked-list-Element-definition | 1 + Lang/C/Doubly-linked-list-Element-insertion | 1 + Lang/C/Doubly-linked-list-Traversal | 1 + Lang/C/Draw-a-cuboid | 1 + Lang/C/Draw-a-sphere | 1 + Lang/C/Echo-server | 1 + Lang/C/Element-wise-operations | 1 + Lang/C/Empty-directory | 1 + Lang/C/Empty-program | 1 + Lang/C/Empty-string | 1 + Lang/C/Enforced-immutability | 1 + Lang/C/Enumerations | 1 + Lang/C/Equilibrium-index | 1 + Lang/C/Ethiopian-multiplication | 1 + Lang/C/Euler-method | 1 + Lang/C/Evaluate-binomial-coefficients | 1 + Lang/C/Even-or-odd | 1 + Lang/C/Events | 1 + Lang/C/Evolutionary-algorithm | 1 + Lang/C/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/C/Executable-library | 1 + Lang/C/Execute-HQ9+ | 1 + Lang/C/Execute-a-system-command | 1 + Lang/C/Exponentiation-operator | 1 + Lang/C/Extend-your-language | 1 + Lang/C/Extreme-floating-point-values | 1 + Lang/C0H/0DESCRIPTION | 26 + Lang/C1R/0DESCRIPTION | 32 + Lang/C1R/100-doors | 1 + Lang/C1R/Quine | 1 + Lang/CB80/0DESCRIPTION | 1 + Lang/CLIPS/0DESCRIPTION | 10 + Lang/CLIPS/100-doors | 1 + Lang/CLIPS/99-Bottles-of-Beer | 1 + Lang/CLIPS/Ackermann-function | 1 + Lang/CLIPS/FizzBuzz | 1 + Lang/CMake/0DESCRIPTION | 98 +++ Lang/CMake/Boolean-values | 1 + Lang/CMake/Call-a-foreign-language-function | 1 + Lang/CMake/Conditional-structures | 1 + Lang/CMake/Execute-a-system-command | 1 + Lang/CMake/FizzBuzz | 1 + Lang/CMake/Knuth-shuffle | 1 + Lang/COBOL/0DESCRIPTION | 7 + Lang/COBOL/100-doors | 1 + Lang/COBOL/99-Bottles-of-Beer | 1 + Lang/COBOL/Address-of-a-variable | 1 + Lang/COBOL/Case-sensitivity-of-identifiers | 1 + Lang/COBOL/Comments | 1 + Lang/COBOL/Conditional-structures | 1 + .../COBOL/Create-an-object-at-a-given-address | 1 + Lang/COBOL/Empty-program | 1 + Lang/COBOL/Ethiopian-multiplication | 1 + Lang/COBOL/FizzBuzz | 1 + Lang/COBOL/Quine | 1 + Lang/Cache-ObjectScript/0DESCRIPTION | 18 + Lang/Cache-ObjectScript/DNS-query | 1 + Lang/Cache-ObjectScript/JSON | 1 + Lang/Caml/0DESCRIPTION | 2 + Lang/Cat/0DESCRIPTION | 9 + Lang/Cduce/0DESCRIPTION | 3 + Lang/Cduce/FizzBuzz | 1 + Lang/Cecil/0DESCRIPTION | 13 + Lang/Chapel/0DESCRIPTION | 7 + Lang/Chapel/99-Bottles-of-Beer | 1 + Lang/Chef/0DESCRIPTION | 8 + Lang/Chef/99-Bottles-of-Beer | 1 + Lang/Chef/Arithmetic-Integer | 1 + Lang/Chef/Averages-Arithmetic-mean | 1 + Lang/Chef/Comments | 1 + Lang/Chef/FizzBuzz | 1 + Lang/Cilk++/0DESCRIPTION | 13 + Lang/Cilk/0DESCRIPTION | 24 + Lang/Clay/0DESCRIPTION | 10 + Lang/Clay/99-Bottles-of-Beer | 1 + Lang/Clay/Accumulator-factory | 1 + Lang/Clay/Ackermann-function | 1 + Lang/Clay/Euler-method | 1 + Lang/Clay/Extend-your-language | 1 + Lang/Clay/FizzBuzz | 1 + Lang/Clean/0DESCRIPTION | 12 + Lang/Clean/Apply-a-callback-to-an-array | 1 + Lang/Clean/Boolean-values | 1 + Lang/Clean/Command-line-arguments | 1 + Lang/Clean/Comments | 1 + Lang/Clean/Compound-data-type | 1 + Lang/Clean/Conditional-structures | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Clean/Empty-program | 1 + Lang/Clipper-XBase++/0DESCRIPTION | 19 + Lang/Clipper/0DESCRIPTION | 1 + Lang/Clipper/FizzBuzz | 1 + Lang/Clojure/Character-codes | 1 + Lang/Clojure/Character-matching | 1 + Lang/Clojure/Combinations | 1 + Lang/Clojure/Combinations-with-repetitions | 1 + Lang/Clojure/Command-line-arguments | 1 + Lang/Clojure/Compile-time-calculation | 1 + Lang/Clojure/Compound-data-type | 1 + Lang/Clojure/Concurrent-computing | 1 + Lang/Clojure/Conditional-structures | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/Clojure/Conways-Game-of-Life | 1 + Lang/Clojure/Count-in-octal | 1 + Lang/Clojure/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Clojure/DNS-query | 1 + Lang/Clojure/Date-format | 1 + Lang/Clojure/Date-manipulation | 1 + Lang/Clojure/Day-of-the-week | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/Clojure/Dining-philosophers | 1 + Lang/Clojure/Documentation | 1 + Lang/Clojure/Dot-product | 1 + Lang/Clojure/Doubly-linked-list-Definition | 1 + .../Doubly-linked-list-Element-definition | 1 + .../Doubly-linked-list-Element-insertion | 1 + Lang/Clojure/Doubly-linked-list-Traversal | 1 + Lang/Clojure/Dynamic-variable-names | 1 + Lang/Clojure/Echo-server | 1 + Lang/Clojure/Element-wise-operations | 1 + Lang/Clojure/Empty-string | 1 + Lang/Clojure/Enforced-immutability | 1 + Lang/Clojure/Enumerations | 1 + Lang/Clojure/Equilibrium-index | 1 + Lang/Clojure/Ethiopian-multiplication | 1 + Lang/Clojure/Evaluate-binomial-coefficients | 1 + Lang/Clojure/Even-or-odd | 1 + Lang/Clojure/Evolutionary-algorithm | 1 + Lang/Clojure/Exceptions | 1 + Lang/Clojure/Execute-HQ9+ | 1 + Lang/Clojure/Execute-a-system-command | 1 + Lang/Clojure/Exponentiation-operator | 1 + Lang/Clojure/Extend-your-language | 1 + Lang/Cobra/0DESCRIPTION | 6 + Lang/Cobra/Averages-Arithmetic-mean | 1 + Lang/CoffeeScript/CSV-to-HTML-translation | 1 + .../Case-sensitivity-of-identifiers | 1 + Lang/CoffeeScript/Character-codes | 1 + Lang/CoffeeScript/Character-matching | 1 + Lang/CoffeeScript/Chat-server | 1 + Lang/CoffeeScript/Combinations | 1 + .../Combinations-with-repetitions | 1 + Lang/CoffeeScript/Compound-data-type | 1 + Lang/CoffeeScript/Concurrent-computing | 1 + Lang/CoffeeScript/Conditional-structures | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/CoffeeScript/Continued-fraction | 1 + Lang/CoffeeScript/Count-in-factors | 1 + Lang/CoffeeScript/Count-in-octal | 1 + .../Count-occurrences-of-a-substring | 1 + Lang/CoffeeScript/Create-an-HTML-table | 1 + Lang/CoffeeScript/DNS-query | 1 + Lang/CoffeeScript/Date-format | 1 + Lang/CoffeeScript/Day-of-the-week | 1 + Lang/CoffeeScript/Dot-product | 1 + Lang/CoffeeScript/Echo-server | 1 + Lang/CoffeeScript/Empty-directory | 1 + Lang/CoffeeScript/Empty-program | 1 + Lang/CoffeeScript/Empty-string | 1 + Lang/CoffeeScript/Ethiopian-multiplication | 1 + .../Evaluate-binomial-coefficients | 1 + Lang/ColdFusion/0DESCRIPTION | 11 + Lang/ColdFusion/100-doors | 1 + Lang/ColdFusion/99-Bottles-of-Beer | 1 + Lang/ColdFusion/Associative-array-Creation | 1 + Lang/ColdFusion/Comments | 1 + Lang/ColdFusion/Conditional-structures | 1 + Lang/ColdFusion/Date-format | 1 + Lang/ColdFusion/Day-of-the-week | 1 + .../Determine-if-a-string-is-numeric | 1 + Lang/ColdFusion/Ethiopian-multiplication | 1 + Lang/ColdFusion/Exceptions | 1 + Lang/Common-Lisp/0DESCRIPTION | 21 + Lang/Common-Lisp/100-doors | 1 + Lang/Common-Lisp/24-game | 1 + Lang/Common-Lisp/99-Bottles-of-Beer | 1 + Lang/Common-Lisp/A+B | 1 + Lang/Common-Lisp/Abstract-type | 1 + Lang/Common-Lisp/Accumulator-factory | 1 + Lang/Common-Lisp/Ackermann-function | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/Common-Lisp/Address-of-a-variable | 1 + Lang/Common-Lisp/Align-columns | 1 + Lang/Common-Lisp/Anagrams | 1 + Lang/Common-Lisp/Anagrams-Deranged-anagrams | 1 + Lang/Common-Lisp/Animation | 1 + Lang/Common-Lisp/Anonymous-recursion | 1 + Lang/Common-Lisp/Apply-a-callback-to-an-array | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Common-Lisp/Arithmetic-Complex | 1 + Lang/Common-Lisp/Arithmetic-Integer | 1 + Lang/Common-Lisp/Arithmetic-Rational | 1 + Lang/Common-Lisp/Arithmetic-evaluation | 1 + Lang/Common-Lisp/Arithmetic-geometric-mean | 1 + Lang/Common-Lisp/Array-concatenation | 1 + Lang/Common-Lisp/Arrays | 1 + Lang/Common-Lisp/Assertions | 1 + Lang/Common-Lisp/Associative-array-Creation | 1 + Lang/Common-Lisp/Associative-array-Iteration | 1 + Lang/Common-Lisp/Averages-Arithmetic-mean | 1 + Lang/Common-Lisp/Averages-Mean-angle | 1 + Lang/Common-Lisp/Averages-Median | 1 + Lang/Common-Lisp/Averages-Pythagorean-means | 1 + Lang/Common-Lisp/Averages-Root-mean-square | 1 + .../Averages-Simple-moving-average | 1 + Lang/Common-Lisp/Balanced-brackets | 1 + Lang/Common-Lisp/Balanced-ternary | 1 + Lang/Common-Lisp/Best-shuffle | 1 + Lang/Common-Lisp/Binary-search | 1 + Lang/Common-Lisp/Binary-strings | 1 + Lang/Common-Lisp/Bitmap | 1 + .../Bitmap-Bresenhams-line-algorithm | 1 + .../Bitmap-Midpoint-circle-algorithm | 1 + Lang/Common-Lisp/Bitmap-Read-a-PPM-file | 1 + Lang/Common-Lisp/Bitmap-Write-a-PPM-file | 1 + Lang/Common-Lisp/Bitwise-operations | 1 + Lang/Common-Lisp/Break-OO-privacy | 1 + Lang/Common-Lisp/Bulls-and-cows | 1 + Lang/Common-Lisp/CRC-32 | 1 + Lang/Common-Lisp/CSV-to-HTML-translation | 1 + Lang/Common-Lisp/Caesar-cipher | 1 + .../Call-a-foreign-language-function | 1 + .../Call-a-function-in-a-shared-library | 1 + .../Case-sensitivity-of-identifiers | 1 + Lang/Common-Lisp/Character-codes | 1 + Lang/Common-Lisp/Check-that-file-exists | 1 + Lang/Common-Lisp/Cholesky-decomposition | 1 + Lang/Common-Lisp/Classes | 1 + Lang/Common-Lisp/Closest-pair-problem | 1 + Lang/Common-Lisp/Collections | 1 + Lang/Common-Lisp/Combinations | 1 + Lang/Common-Lisp/Command-line-arguments | 1 + Lang/Common-Lisp/Comments | 1 + Lang/Common-Lisp/Compile-time-calculation | 1 + Lang/Common-Lisp/Compound-data-type | 1 + Lang/Common-Lisp/Concurrent-computing | 1 + Lang/Common-Lisp/Conditional-structures | 1 + Lang/Common-Lisp/Constrained-genericity | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/Common-Lisp/Continued-fraction | 1 + Lang/Common-Lisp/Conways-Game-of-Life | 1 + Lang/Common-Lisp/Count-in-factors | 1 + Lang/Common-Lisp/Count-in-octal | 1 + .../Count-occurrences-of-a-substring | 1 + Lang/Common-Lisp/Count-the-coins | 1 + Lang/Common-Lisp/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Common-Lisp/Cut-a-rectangle | 1 + Lang/Common-Lisp/DNS-query | 1 + Lang/Common-Lisp/Date-format | 1 + Lang/Common-Lisp/Day-of-the-week | 1 + Lang/Common-Lisp/Deal-cards-for-FreeCell | 1 + Lang/Common-Lisp/Deconvolution-1D | 1 + Lang/Common-Lisp/Deepcopy | 1 + Lang/Common-Lisp/Define-a-primitive-data-type | 1 + Lang/Common-Lisp/Delegates | 1 + Lang/Common-Lisp/Delete-a-file | 1 + Lang/Common-Lisp/Detect-division-by-zero | 1 + .../Determine-if-a-string-is-numeric | 1 + Lang/Common-Lisp/Dining-philosophers | 1 + Lang/Common-Lisp/Dot-product | 1 + .../Common-Lisp/Doubly-linked-list-Definition | 1 + .../Doubly-linked-list-Element-definition | 1 + Lang/Common-Lisp/Dynamic-variable-names | 1 + Lang/Common-Lisp/Echo-server | 1 + Lang/Common-Lisp/Element-wise-operations | 1 + Lang/Common-Lisp/Empty-string | 1 + Lang/Common-Lisp/Enumerations | 1 + Lang/Common-Lisp/Ethiopian-multiplication | 1 + Lang/Common-Lisp/Euler-method | 1 + .../Evaluate-binomial-coefficients | 1 + Lang/Common-Lisp/Even-or-odd | 1 + Lang/Common-Lisp/Evolutionary-algorithm | 1 + Lang/Common-Lisp/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Common-Lisp/Execute-a-system-command | 1 + Lang/Common-Lisp/Exponentiation-operator | 1 + Lang/Common-Lisp/Extend-your-language | 1 + Lang/Common-Lisp/FizzBuzz | 1 + Lang/Common-Lisp/Forest-fire | 1 + Lang/Common-Lisp/Infinity | 1 + Lang/Common-Lisp/JSON | 1 + Lang/Common-Lisp/Knuth-shuffle | 1 + Lang/Common-Lisp/Narcissist | 1 + Lang/Common-Lisp/Ordered-words | 1 + Lang/Common-Lisp/Quine | 1 + Lang/Common-Lisp/Search-a-list | 1 + Lang/Component-Pascal/0DESCRIPTION | 4 + Lang/Component-Pascal/Arrays | 1 + Lang/Component-Pascal/Assertions | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Coq/0DESCRIPTION | 6 + Lang/Coq/Ackermann-function | 1 + Lang/Crack/0DESCRIPTION | 14 + Lang/Crack/Conditional-structures | 1 + Lang/Curry/0DESCRIPTION | 11 + Lang/D/0DESCRIPTION | 19 + Lang/D/100-doors | 1 + Lang/D/24-game | 1 + Lang/D/99-Bottles-of-Beer | 1 + Lang/D/A+B | 1 + Lang/D/Abstract-type | 1 + Lang/D/Accumulator-factory | 1 + Lang/D/Ackermann-function | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/D/Address-of-a-variable | 1 + Lang/D/Align-columns | 1 + Lang/D/Anagrams-Deranged-anagrams | 1 + Lang/D/Animation | 1 + Lang/D/Anonymous-recursion | 1 + Lang/D/Apply-a-callback-to-an-array | 1 + .../D/Arbitrary-precision-integers-(included) | 1 + Lang/D/Arithmetic-Complex | 1 + Lang/D/Arithmetic-Integer | 1 + Lang/D/Arithmetic-Rational | 1 + Lang/D/Arithmetic-evaluation | 1 + Lang/D/Arithmetic-geometric-mean | 1 + Lang/D/Array-concatenation | 1 + Lang/D/Arrays | 1 + Lang/D/Assertions | 1 + Lang/D/Associative-array-Creation | 1 + Lang/D/Associative-array-Iteration | 1 + Lang/D/Atomic-updates | 1 + Lang/D/Average-loop-length | 1 + Lang/D/Averages-Arithmetic-mean | 1 + Lang/D/Averages-Mean-angle | 1 + Lang/D/Averages-Median | 1 + Lang/D/Averages-Mode | 1 + Lang/D/Averages-Pythagorean-means | 1 + Lang/D/Averages-Root-mean-square | 1 + Lang/D/Averages-Simple-moving-average | 1 + Lang/D/Balanced-brackets | 1 + Lang/D/Balanced-ternary | 1 + Lang/D/Best-shuffle | 1 + Lang/D/Binary-search | 1 + Lang/D/Binary-strings | 1 + Lang/D/Bitmap | 1 + Lang/D/Bitmap-B-zier-curves-Cubic | 1 + Lang/D/Bitmap-B-zier-curves-Quadratic | 1 + Lang/D/Bitmap-Bresenhams-line-algorithm | 1 + Lang/D/Bitmap-Flood-fill | 1 + Lang/D/Bitmap-Histogram | 1 + Lang/D/Bitmap-Midpoint-circle-algorithm | 1 + Lang/D/Bitwise-IO | 1 + Lang/D/Bitwise-operations | 1 + Lang/D/Box-the-compass | 1 + Lang/D/Bulls-and-cows | 1 + Lang/D/Bulls-and-cows-Player | 1 + Lang/D/CRC-32 | 1 + Lang/D/CSV-to-HTML-translation | 1 + Lang/D/Caesar-cipher | 1 + Lang/D/Calendar | 1 + Lang/D/Call-a-foreign-language-function | 1 + Lang/D/Call-a-function-in-a-shared-library | 1 + Lang/D/Call-an-object-method | 1 + Lang/D/Canny-edge-detector | 1 + Lang/D/Carmichael-3-strong-pseudoprimes | 1 + Lang/D/Case-sensitivity-of-identifiers | 1 + Lang/D/Character-codes | 1 + Lang/D/Character-matching | 1 + Lang/D/Check-Machin-like-formulas | 1 + Lang/D/Check-that-file-exists | 1 + Lang/D/Checkpoint-synchronization | 1 + Lang/D/Cholesky-decomposition | 1 + Lang/D/Classes | 1 + Lang/D/Closest-pair-problem | 1 + Lang/D/Collections | 1 + Lang/D/Color-quantization | 1 + Lang/D/Combinations | 1 + Lang/D/Combinations-with-repetitions | 1 + Lang/D/Command-line-arguments | 1 + Lang/D/Comments | 1 + Lang/D/Compare-sorting-algorithms-performance | 1 + Lang/D/Compile-time-calculation | 1 + Lang/D/Compound-data-type | 1 + Lang/D/Concurrent-computing | 1 + Lang/D/Conditional-structures | 1 + Lang/D/Constrained-genericity | 1 + Lang/D/Constrained-random-points-on-a-circle | 1 + Lang/D/Continued-fraction | 1 + Lang/D/Conways-Game-of-Life | 1 + Lang/D/Count-in-factors | 1 + Lang/D/Count-in-octal | 1 + Lang/D/Count-occurrences-of-a-substring | 1 + Lang/D/Count-the-coins | 1 + Lang/D/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/D/Create-an-HTML-table | 1 + Lang/D/Create-an-object-at-a-given-address | 1 + Lang/D/Cut-a-rectangle | 1 + Lang/D/DNS-query | 1 + Lang/D/Date-format | 1 + Lang/D/Day-of-the-week | 1 + Lang/D/Deal-cards-for-FreeCell | 1 + Lang/D/Death-Star | 1 + Lang/D/Deconvolution-1D | 1 + Lang/D/Deconvolution-2D+ | 1 + Lang/D/Define-a-primitive-data-type | 1 + Lang/D/Delegates | 1 + Lang/D/Delete-a-file | 1 + Lang/D/Detect-division-by-zero | 1 + Lang/D/Determine-if-a-string-is-numeric | 1 + Lang/D/Digital-root | 1 + Lang/D/Dinesmans-multiple-dwelling-problem | 1 + Lang/D/Dining-philosophers | 1 + Lang/D/Discordian-date | 1 + Lang/D/Distributed-programming | 1 + Lang/D/Documentation | 1 + Lang/D/Dot-product | 1 + Lang/D/Doubly-linked-list-Definition | 1 + Lang/D/Doubly-linked-list-Element-definition | 1 + Lang/D/Doubly-linked-list-Element-insertion | 1 + Lang/D/Doubly-linked-list-Traversal | 1 + Lang/D/Draw-a-cuboid | 1 + Lang/D/Draw-a-sphere | 1 + Lang/D/Dutch-national-flag-problem | 1 + Lang/D/Echo-server | 1 + Lang/D/Element-wise-operations | 1 + Lang/D/Empty-directory | 1 + Lang/D/Empty-program | 1 + Lang/D/Empty-string | 1 + Lang/D/Enforced-immutability | 1 + Lang/D/Entropy | 1 + Lang/D/Enumerations | 1 + Lang/D/Equilibrium-index | 1 + Lang/D/Ethiopian-multiplication | 1 + Lang/D/Euler-method | 1 + Lang/D/Evaluate-binomial-coefficients | 1 + Lang/D/Even-or-odd | 1 + Lang/D/Evolutionary-algorithm | 1 + Lang/D/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/D/Execute-HQ9+ | 1 + Lang/D/Execute-a-system-command | 1 + Lang/D/Exponentiation-operator | 1 + Lang/D/Extend-your-language | 1 + Lang/D/Extreme-floating-point-values | 1 + Lang/D/FizzBuzz | 1 + Lang/D/Forest-fire | 1 + Lang/D/Infinity | 1 + Lang/D/JSON | 1 + Lang/D/Knuth-shuffle | 1 + Lang/D/Ordered-words | 1 + Lang/D/Pi | 1 + Lang/D/Quine | 1 + Lang/D/Search-a-list | 1 + Lang/DCL/0DESCRIPTION | 1 + Lang/DCL/Create-a-file | 1 + Lang/DCL/Execute-a-system-command | 1 + Lang/DMS/0DESCRIPTION | 4 + Lang/DMS/A+B | 1 + Lang/DWScript/0DESCRIPTION | 18 + Lang/DWScript/100-doors | 1 + Lang/DWScript/A+B | 1 + Lang/DWScript/Ackermann-function | 1 + Lang/DWScript/Arithmetic-Integer | 1 + Lang/DWScript/Arrays | 1 + Lang/DWScript/Assertions | 1 + Lang/DWScript/Bitwise-operations | 1 + Lang/DWScript/Case-sensitivity-of-identifiers | 1 + Lang/DWScript/Character-codes | 1 + Lang/DWScript/Cholesky-decomposition | 1 + Lang/DWScript/Classes | 1 + Lang/DWScript/Comments | 1 + Lang/DWScript/Compile-time-calculation | 1 + Lang/DWScript/Count-in-factors | 1 + Lang/DWScript/Death-Star | 1 + Lang/DWScript/Dot-product | 1 + Lang/DWScript/Draw-a-sphere | 1 + Lang/DWScript/Empty-string | 1 + Lang/DWScript/Enumerations | 1 + Lang/DWScript/Even-or-odd | 1 + Lang/DWScript/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/DWScript/Execute-HQ9+ | 1 + Lang/DWScript/FizzBuzz | 1 + Lang/DWScript/Knuth-shuffle | 1 + Lang/DWScript/Search-a-list | 1 + Lang/Dao/0DESCRIPTION | 15 + Lang/Dao/Arrays | 1 + Lang/Dao/Associative-array-Creation | 1 + Lang/Dao/Associative-array-Iteration | 1 + Lang/Dao/Conditional-structures | 1 + Lang/Dao/Quine | 1 + Lang/Dart/0DESCRIPTION | 2 + Lang/Dart/100-doors | 1 + Lang/Dart/99-Bottles-of-Beer | 1 + Lang/Dart/Ackermann-function | 1 + Lang/Dart/Assertions | 1 + Lang/Dart/Caesar-cipher | 1 + Lang/Dart/Conways-Game-of-Life | 1 + Lang/Dart/Delegates | 1 + Lang/Dart/Empty-program | 1 + Lang/Dart/FizzBuzz | 1 + Lang/Datalog/0DESCRIPTION | 16 + Lang/Dc/0DESCRIPTION | 63 ++ Lang/Dc/Count-in-octal | 1 + Lang/Dc/Digital-root | 1 + Lang/Deja-Vu/0DESCRIPTION | 1 + Lang/Deja-Vu/A+B | 1 + Lang/Deja-Vu/Anonymous-recursion | 1 + Lang/Deja-Vu/Command-line-arguments | 1 + Lang/Deja-Vu/Conditional-structures | 1 + Lang/Deja-Vu/Narcissist | 1 + Lang/Deja-Vu/Quine | 1 + Lang/Delphi/0DESCRIPTION | 33 + Lang/Delphi/99-Bottles-of-Beer | 1 + Lang/Delphi/A+B | 1 + Lang/Delphi/Abstract-type | 1 + Lang/Delphi/Ackermann-function | 1 + Lang/Delphi/Align-columns | 1 + Lang/Delphi/Apply-a-callback-to-an-array | 1 + Lang/Delphi/Arithmetic-Integer | 1 + Lang/Delphi/Array-concatenation | 1 + Lang/Delphi/Arrays | 1 + Lang/Delphi/Assertions | 1 + Lang/Delphi/Associative-array-Creation | 1 + Lang/Delphi/Associative-array-Iteration | 1 + Lang/Delphi/Averages-Arithmetic-mean | 1 + Lang/Delphi/Averages-Median | 1 + Lang/Delphi/Averages-Pythagorean-means | 1 + Lang/Delphi/Averages-Root-mean-square | 1 + Lang/Delphi/Balanced-brackets | 1 + Lang/Delphi/Bitwise-operations | 1 + Lang/Delphi/CSV-to-HTML-translation | 1 + Lang/Delphi/Call-a-foreign-language-function | 1 + .../Call-a-function-in-a-shared-library | 1 + Lang/Delphi/Case-sensitivity-of-identifiers | 1 + Lang/Delphi/Character-codes | 1 + Lang/Delphi/Character-matching | 1 + Lang/Delphi/Check-that-file-exists | 1 + Lang/Delphi/Classes | 1 + Lang/Delphi/Color-of-a-screen-pixel | 1 + Lang/Delphi/Command-line-arguments | 1 + Lang/Delphi/Comments | 1 + Lang/Delphi/Compound-data-type | 1 + Lang/Delphi/Concurrent-computing | 1 + Lang/Delphi/Count-in-octal | 1 + Lang/Delphi/Count-occurrences-of-a-substring | 1 + Lang/Delphi/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Delphi/Create-an-HTML-table | 1 + Lang/Delphi/DNS-query | 1 + Lang/Delphi/Date-format | 1 + Lang/Delphi/Date-manipulation | 1 + Lang/Delphi/Day-of-the-week | 1 + Lang/Delphi/Delegates | 1 + Lang/Delphi/Delete-a-file | 1 + Lang/Delphi/Detect-division-by-zero | 1 + Lang/Delphi/Determine-if-a-string-is-numeric | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/Delphi/Documentation | 1 + Lang/Delphi/Dot-product | 1 + .../Doubly-linked-list-Element-definition | 1 + Lang/Delphi/Doubly-linked-list-Traversal | 1 + Lang/Delphi/Draw-a-sphere | 1 + Lang/Delphi/Echo-server | 1 + Lang/Delphi/Empty-string | 1 + Lang/Delphi/Enforced-immutability | 1 + Lang/Delphi/Enumerations | 1 + Lang/Delphi/Evaluate-binomial-coefficients | 1 + Lang/Delphi/Events | 1 + Lang/Delphi/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Delphi/Execute-a-system-command | 1 + Lang/Delphi/Extend-your-language | 1 + Lang/Delphi/Extreme-floating-point-values | 1 + Lang/Delphi/FizzBuzz | 1 + Lang/Delphi/Infinity | 1 + Lang/Delphi/Ordered-words | 1 + Lang/Delphi/Search-a-list | 1 + Lang/Deluge/0DESCRIPTION | 7 + Lang/Deluge/Comments | 1 + Lang/Deluge/Conditional-structures | 1 + Lang/Diesel/0DESCRIPTION | 5 + Lang/Dodo0/0DESCRIPTION | 3 + Lang/Dylan.NET/0DESCRIPTION | 1 + Lang/E/0DESCRIPTION | 48 ++ Lang/E/100-doors | 1 + Lang/E/99-Bottles-of-Beer | 1 + Lang/E/Abstract-type | 1 + Lang/E/Accumulator-factory | 1 + Lang/E/Ackermann-function | 1 + Lang/E/Active-object | 1 + Lang/E/Align-columns | 1 + Lang/E/Anagrams | 1 + Lang/E/Animate-a-pendulum | 1 + Lang/E/Animation | 1 + Lang/E/Apply-a-callback-to-an-array | 1 + .../E/Arbitrary-precision-integers-(included) | 1 + Lang/E/Arithmetic-Integer | 1 + Lang/E/Arithmetic-evaluation | 1 + Lang/E/Array-concatenation | 1 + Lang/E/Arrays | 1 + Lang/E/Assertions | 1 + Lang/E/Associative-array-Creation | 1 + Lang/E/Associative-array-Iteration | 1 + Lang/E/Atomic-updates | 1 + Lang/E/Averages-Arithmetic-mean | 1 + Lang/E/Averages-Median | 1 + Lang/E/Averages-Mode | 1 + Lang/E/Averages-Pythagorean-means | 1 + Lang/E/Averages-Root-mean-square | 1 + Lang/E/Averages-Simple-moving-average | 1 + Lang/E/Binary-search | 1 + Lang/E/Binary-strings | 1 + Lang/E/Bitmap | 1 + Lang/E/Bitmap-Bresenhams-line-algorithm | 1 + Lang/E/Bitmap-Flood-fill | 1 + Lang/E/Bitmap-Read-a-PPM-file | 1 + Lang/E/Bitwise-operations | 1 + Lang/E/Boolean-values | 1 + Lang/E/Bulls-and-cows | 1 + Lang/E/Call-an-object-method | 1 + Lang/E/Character-codes | 1 + Lang/E/Character-matching | 1 + Lang/E/Check-that-file-exists | 1 + Lang/E/Checkpoint-synchronization | 1 + Lang/E/Classes | 1 + Lang/E/Collections | 1 + Lang/E/Combinations | 1 + Lang/E/Command-line-arguments | 1 + Lang/E/Comments | 1 + Lang/E/Compound-data-type | 1 + Lang/E/Concurrent-computing | 1 + Lang/E/Conditional-structures | 1 + Lang/E/Constrained-genericity | 1 + Lang/E/Conways-Game-of-Life | 1 + Lang/E/Create-a-file | 1 + Lang/E/Deepcopy | 1 + Lang/E/Define-a-primitive-data-type | 1 + Lang/E/Delegates | 1 + Lang/E/Delete-a-file | 1 + Lang/E/Detect-division-by-zero | 1 + Lang/E/Determine-if-a-string-is-numeric | 1 + Lang/E/Distributed-programming | 1 + Lang/E/Documentation | 1 + Lang/E/Doubly-linked-list-Definition | 1 + Lang/E/Doubly-linked-list-Element-definition | 1 + Lang/E/Doubly-linked-list-Element-insertion | 1 + Lang/E/Doubly-linked-list-Traversal | 1 + Lang/E/Dynamic-variable-names | 1 + Lang/E/Empty-program | 1 + Lang/E/Enforced-immutability | 1 + Lang/E/Enumerations | 1 + Lang/E/Ethiopian-multiplication | 1 + Lang/E/Events | 1 + Lang/E/Evolutionary-algorithm | 1 + Lang/E/Exceptions | 1 + Lang/E/Execute-a-system-command | 1 + Lang/E/Exponentiation-operator | 1 + Lang/E/Extend-your-language | 1 + Lang/E/FizzBuzz | 1 + Lang/E/Infinity | 1 + Lang/E/Knuth-shuffle | 1 + Lang/E/Ordered-words | 1 + Lang/E/Quine | 1 + Lang/E/Search-a-list | 1 + Lang/EC/0DESCRIPTION | 56 ++ Lang/EGL/0DESCRIPTION | 7 + Lang/EGL/100-doors | 1 + Lang/EGL/99-Bottles-of-Beer | 1 + Lang/EGL/A+B | 1 + Lang/EGL/Apply-a-callback-to-an-array | 1 + Lang/EGL/Array-concatenation | 1 + Lang/EGL/Arrays | 1 + Lang/EGL/Boolean-values | 1 + Lang/EGL/Count-occurrences-of-a-substring | 1 + Lang/EGL/Date-format | 1 + Lang/EGL/Empty-program | 1 + Lang/EGL/Enumerations | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/EGL/JSON | 1 + Lang/ELLA/0DESCRIPTION | 11 + Lang/ESQL/0DESCRIPTION | 2 + Lang/Efene/0DESCRIPTION | 21 + Lang/Efene/Apply-a-callback-to-an-array | 1 + Lang/Efene/Arithmetic-Integer | 1 + Lang/Efene/Array-concatenation | 1 + Lang/Efene/Conditional-structures | 1 + Lang/Eiffel/Command-line-arguments | 1 + Lang/Eiffel/Constrained-genericity | 1 + Lang/Eiffel/Count-occurrences-of-a-substring | 1 + Lang/Eiffel/Dining-philosophers | 1 + Lang/Eiffel/Documentation | 1 + Lang/Eiffel/Empty-program | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Ela/0DESCRIPTION | 14 + Lang/Ela/100-doors | 1 + Lang/Ela/99-Bottles-of-Beer | 1 + Lang/Ela/A+B | 1 + Lang/Ela/Ackermann-function | 1 + Lang/Ela/Anonymous-recursion | 1 + Lang/Ela/Comments | 1 + Lang/Ela/Compound-data-type | 1 + Lang/Ela/Conditional-structures | 1 + Lang/Ela/Detect-division-by-zero | 1 + Lang/Ela/Dot-product | 1 + Lang/Ela/Enforced-immutability | 1 + Lang/Ela/Ethiopian-multiplication | 1 + Lang/Ela/Execute-HQ9+ | 1 + Lang/Ela/FizzBuzz | 1 + Lang/Elan/0DESCRIPTION | 4 + Lang/ElastiC/0DESCRIPTION | 26 + Lang/Elena/0DESCRIPTION | 39 + Lang/Elena/A+B | 1 + Lang/Elena/Accumulator-factory | 1 + Lang/Elena/Ackermann-function | 1 + ...-a-variable-to-a-class-instance-at-runtime | 1 + Lang/Elena/Anagrams | 1 + Lang/Elena/Anonymous-recursion | 1 + Lang/Elena/Apply-a-callback-to-an-array | 1 + Lang/Elena/Arithmetic-Integer | 1 + Lang/Elena/Arithmetic-evaluation | 1 + Lang/Elena/Array-concatenation | 1 + Lang/Elena/Arrays | 1 + Lang/Elena/Associative-array-Creation | 1 + Lang/Elena/Associative-array-Iteration | 1 + Lang/Elena/Averages-Arithmetic-mean | 1 + Lang/Elena/Averages-Median | 1 + Lang/Elena/Averages-Mode | 1 + Lang/Elena/Averages-Simple-moving-average | 1 + Lang/Elena/Balanced-brackets | 1 + Lang/Elena/Bitwise-operations | 1 + Lang/Elena/Bulls-and-cows | 1 + Lang/Elena/Caesar-cipher | 1 + Lang/Elena/Character-codes | 1 + Lang/Elena/Character-matching | 1 + Lang/Elisa/0DESCRIPTION | 6 + Lang/Elisa/Arithmetic-Rational | 1 + Lang/Elixir/0DESCRIPTION | 1 + Lang/Elixir/FizzBuzz | 1 + Lang/Emacs-Lisp/0DESCRIPTION | 10 + Lang/Emacs-Lisp/100-doors | 1 + .../Arbitrary-precision-integers-(included) | 1 + Lang/Emacs-Lisp/Assertions | 1 + Lang/Emacs-Lisp/Averages-Arithmetic-mean | 1 + Lang/Emacs-Lisp/Command-line-arguments | 1 + Lang/Emacs-Lisp/Comments | 1 + Lang/Emacs-Lisp/Count-in-octal | 1 + Lang/Epigram/0DESCRIPTION | 3 + Lang/Erlang/CRC-32 | 1 + Lang/Erlang/Character-codes | 1 + Lang/Erlang/Character-matching | 1 + Lang/Erlang/Chat-server | 1 + Lang/Erlang/Combinations | 1 + Lang/Erlang/Combinations-with-repetitions | 1 + Lang/Erlang/Command-line-arguments | 1 + Lang/Erlang/Compound-data-type | 1 + Lang/Erlang/Concurrent-computing | 1 + Lang/Erlang/Conditional-structures | 1 + Lang/Erlang/Conways-Game-of-Life | 1 + Lang/Erlang/Count-occurrences-of-a-substring | 1 + Lang/Erlang/Count-the-coins | 1 + Lang/Erlang/Date-format | 1 + Lang/Erlang/Dining-philosophers | 1 + Lang/Erlang/Distributed-programming | 1 + Lang/Erlang/Dot-product | 1 + Lang/Erlang/Dutch-national-flag-problem | 1 + Lang/Erlang/Echo-server | 1 + Lang/Erlang/Empty-program | 1 + Lang/Erlang/Empty-string | 1 + Lang/Erlang/Enforced-immutability | 1 + Lang/Erlang/Ethiopian-multiplication | 1 + Lang/Erlang/Evaluate-binomial-coefficients | 1 + Lang/Erlang/Events | 1 + Lang/Erlang/Evolutionary-algorithm | 1 + Lang/Erlang/Execute-HQ9+ | 1 + Lang/Erlang/Execute-a-system-command | 1 + Lang/Erlang/Exponentiation-operator | 1 + Lang/Es/0DESCRIPTION | 10 + Lang/Euler-Math-Toolbox/0DESCRIPTION | 6 + Lang/Euler-Math-Toolbox/100-doors | 1 + Lang/Euler-Math-Toolbox/A+B | 1 + Lang/Euler-Math-Toolbox/Ackermann-function | 1 + Lang/Euler-Math-Toolbox/Arithmetic-Complex | 1 + Lang/Euler-Math-Toolbox/Averages-Mean-angle | 1 + Lang/Euler-Math-Toolbox/Averages-Median | 1 + .../Averages-Pythagorean-means | 1 + .../Averages-Simple-moving-average | 1 + Lang/Euler-Math-Toolbox/Entropy | 1 + Lang/Euler-Math-Toolbox/Euler-method | 1 + Lang/Euler/0DESCRIPTION | 4 + Lang/Euphoria/0DESCRIPTION | 22 + Lang/Euphoria/100-doors | 1 + Lang/Euphoria/99-Bottles-of-Beer | 1 + Lang/Euphoria/A+B | 1 + Lang/Euphoria/Ackermann-function | 1 + Lang/Euphoria/Align-columns | 1 + Lang/Euphoria/Anagrams | 1 + Lang/Euphoria/Animate-a-pendulum | 1 + Lang/Euphoria/Apply-a-callback-to-an-array | 1 + Lang/Euphoria/Arithmetic-Complex | 1 + Lang/Euphoria/Arithmetic-Integer | 1 + Lang/Euphoria/Array-concatenation | 1 + Lang/Euphoria/Arrays | 1 + Lang/Euphoria/Assertions | 1 + Lang/Euphoria/Atomic-updates | 1 + Lang/Euphoria/Averages-Arithmetic-mean | 1 + Lang/Euphoria/Averages-Median | 1 + Lang/Euphoria/Averages-Mode | 1 + Lang/Euphoria/Averages-Pythagorean-means | 1 + Lang/Euphoria/Averages-Root-mean-square | 1 + Lang/Euphoria/Balanced-brackets | 1 + Lang/Euphoria/Binary-search | 1 + Lang/Euphoria/Bitmap | 1 + .../Euphoria/Bitmap-Bresenhams-line-algorithm | 1 + Lang/Euphoria/Bitmap-Read-a-PPM-file | 1 + Lang/Euphoria/Bitmap-Write-a-PPM-file | 1 + Lang/Euphoria/Box-the-compass | 1 + Lang/Euphoria/Bulls-and-cows | 1 + Lang/Euphoria/Bulls-and-cows-Player | 1 + Lang/Euphoria/CSV-to-HTML-translation | 1 + Lang/Euphoria/Caesar-cipher | 1 + Lang/Euphoria/Case-sensitivity-of-identifiers | 1 + Lang/Euphoria/Character-codes | 1 + Lang/Euphoria/Character-matching | 1 + Lang/Euphoria/Check-that-file-exists | 1 + Lang/Euphoria/Command-line-arguments | 1 + Lang/Euphoria/Comments | 1 + Lang/Euphoria/Concurrent-computing | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/Euphoria/Count-in-factors | 1 + Lang/Euphoria/Count-in-octal | 1 + .../Euphoria/Count-occurrences-of-a-substring | 1 + Lang/Euphoria/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Euphoria/Create-an-HTML-table | 1 + Lang/Euphoria/Date-format | 1 + Lang/Euphoria/Date-manipulation | 1 + Lang/Euphoria/Day-of-the-week | 1 + Lang/Euphoria/Define-a-primitive-data-type | 1 + .../Euphoria/Determine-if-a-string-is-numeric | 1 + Lang/Euphoria/Dining-philosophers | 1 + Lang/Euphoria/Discordian-date | 1 + Lang/Euphoria/Dot-product | 1 + Lang/Euphoria/Empty-program | 1 + Lang/Euphoria/Empty-string | 1 + Lang/Euphoria/Enforced-immutability | 1 + Lang/Euphoria/Equilibrium-index | 1 + Lang/Euphoria/Ethiopian-multiplication | 1 + Lang/Euphoria/Even-or-odd | 1 + Lang/Euphoria/Evolutionary-algorithm | 1 + Lang/Euphoria/Extreme-floating-point-values | 1 + Lang/Euphoria/FizzBuzz | 1 + Lang/Euphoria/Infinity | 1 + Lang/Euphoria/Knuth-shuffle | 1 + Lang/Euphoria/Ordered-words | 1 + Lang/Euphoria/Quine | 1 + Lang/Euphoria/Search-a-list | 1 + Lang/Excel/0DESCRIPTION | 2 + Lang/Forth/Call-a-foreign-language-function | 1 + Lang/Forth/Call-an-object-method | 1 + Lang/Forth/Character-codes | 1 + Lang/Forth/Character-matching | 1 + Lang/Forth/Command-line-arguments | 1 + Lang/Forth/Compile-time-calculation | 1 + Lang/Forth/Compound-data-type | 1 + Lang/Forth/Concurrent-computing | 1 + Lang/Forth/Conditional-structures | 1 + Lang/Forth/Continued-fraction | 1 + Lang/Forth/Conways-Game-of-Life | 1 + Lang/Forth/Count-in-factors | 1 + Lang/Forth/Count-in-octal | 1 + Lang/Forth/Count-occurrences-of-a-substring | 1 + Lang/Forth/Count-the-coins | 1 + Lang/Forth/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + .../Forth/Create-an-object-at-a-given-address | 1 + Lang/Forth/Date-format | 1 + Lang/Forth/Day-of-the-week | 1 + .../Forth/Dinesmans-multiple-dwelling-problem | 1 + Lang/Forth/Dot-product | 1 + Lang/Forth/Dynamic-variable-names | 1 + Lang/Forth/Echo-server | 1 + Lang/Forth/Empty-program | 1 + Lang/Forth/Empty-string | 1 + Lang/Forth/Enumerations | 1 + Lang/Forth/Ethiopian-multiplication | 1 + Lang/Forth/Evaluate-binomial-coefficients | 1 + Lang/Forth/Even-or-odd | 1 + Lang/Forth/Evolutionary-algorithm | 1 + Lang/Forth/Exceptions | 1 + Lang/Forth/Execute-HQ9+ | 1 + Lang/Forth/Execute-a-system-command | 1 + Lang/Forth/Exponentiation-operator | 1 + Lang/Forth/Extend-your-language | 1 + Lang/Forth/Extreme-floating-point-values | 1 + Lang/Fortran/Case-sensitivity-of-identifiers | 1 + Lang/Fortran/Character-codes | 1 + Lang/Fortran/Combinations | 1 + Lang/Fortran/Combinations-with-repetitions | 1 + Lang/Fortran/Command-line-arguments | 1 + Lang/Fortran/Compile-time-calculation | 1 + Lang/Fortran/Compound-data-type | 1 + Lang/Fortran/Concurrent-computing | 1 + Lang/Fortran/Conditional-structures | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/Fortran/Conways-Game-of-Life | 1 + Lang/Fortran/Count-in-octal | 1 + Lang/Fortran/Count-occurrences-of-a-substring | 1 + Lang/Fortran/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Fortran/Date-format | 1 + Lang/Fortran/Day-of-the-week | 1 + Lang/Fortran/Deconvolution-1D | 1 + Lang/Fortran/Dot-product | 1 + Lang/Fortran/Doubly-linked-list-Definition | 1 + .../Doubly-linked-list-Element-definition | 1 + .../Doubly-linked-list-Element-insertion | 1 + Lang/Fortran/Doubly-linked-list-Traversal | 1 + Lang/Fortran/Empty-program | 1 + Lang/Fortran/Enumerations | 1 + Lang/Fortran/Equilibrium-index | 1 + Lang/Fortran/Ethiopian-multiplication | 1 + Lang/Fortran/Euler-method | 1 + Lang/Fortran/Evaluate-binomial-coefficients | 1 + Lang/Fortran/Evolutionary-algorithm | 1 + Lang/Fortran/Execute-a-system-command | 1 + Lang/Fortran/Exponentiation-operator | 1 + Lang/Go/CRC-32 | 1 + Lang/Go/CSV-to-HTML-translation | 1 + Lang/Go/Call-a-foreign-language-function | 1 + Lang/Go/Call-an-object-method | 1 + Lang/Go/Case-sensitivity-of-identifiers | 1 + Lang/Go/Character-codes | 1 + Lang/Go/Character-matching | 1 + Lang/Go/Chat-server | 1 + Lang/Go/Check-Machin-like-formulas | 1 + Lang/Go/Cholesky-decomposition | 1 + Lang/Go/Combinations | 1 + Lang/Go/Combinations-with-repetitions | 1 + Lang/Go/Command-line-arguments | 1 + Lang/Go/Compile-time-calculation | 1 + Lang/Go/Compound-data-type | 1 + Lang/Go/Concurrent-computing | 1 + Lang/Go/Conditional-structures | 1 + Lang/Go/Constrained-genericity | 1 + Lang/Go/Constrained-random-points-on-a-circle | 1 + Lang/Go/Continued-fraction | 1 + Lang/Go/Conways-Game-of-Life | 1 + Lang/Go/Count-in-factors | 1 + Lang/Go/Count-in-octal | 1 + Lang/Go/Count-occurrences-of-a-substring | 1 + Lang/Go/Count-the-coins | 1 + Lang/Go/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Go/Create-an-HTML-table | 1 + Lang/Go/Create-an-object-at-a-given-address | 1 + Lang/Go/DNS-query | 1 + Lang/Go/Date-format | 1 + Lang/Go/Date-manipulation | 1 + Lang/Go/Day-of-the-week | 1 + Lang/Go/Deal-cards-for-FreeCell | 1 + Lang/Go/Deconvolution-1D | 1 + Lang/Go/Deepcopy | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/Go/Digital-root | 1 + Lang/Go/Dining-philosophers | 1 + Lang/Go/Discordian-date | 1 + Lang/Go/Distributed-programming | 1 + Lang/Go/Documentation | 1 + Lang/Go/Dot-product | 1 + Lang/Go/Doubly-linked-list-Definition | 1 + Lang/Go/Doubly-linked-list-Element-definition | 1 + Lang/Go/Doubly-linked-list-Element-insertion | 1 + Lang/Go/Doubly-linked-list-Traversal | 1 + Lang/Go/Draw-a-cuboid | 1 + Lang/Go/Draw-a-sphere | 1 + Lang/Go/Dutch-national-flag-problem | 1 + Lang/Go/Echo-server | 1 + Lang/Go/Element-wise-operations | 1 + Lang/Go/Empty-directory | 1 + Lang/Go/Empty-program | 1 + Lang/Go/Empty-string | 1 + Lang/Go/Enforced-immutability | 1 + Lang/Go/Enumerations | 1 + Lang/Go/Equilibrium-index | 1 + Lang/Go/Ethiopian-multiplication | 1 + Lang/Go/Euler-method | 1 + Lang/Go/Evaluate-binomial-coefficients | 1 + Lang/Go/Even-or-odd | 1 + Lang/Go/Events | 1 + Lang/Go/Evolutionary-algorithm | 1 + Lang/Go/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Go/Execute-a-system-command | 1 + Lang/Go/Exponentiation-operator | 1 + Lang/Go/Extreme-floating-point-values | 1 + Lang/Haskell/CSV-to-HTML-translation | 1 + Lang/Haskell/Call-a-foreign-language-function | 1 + Lang/Haskell/Carmichael-3-strong-pseudoprimes | 1 + Lang/Haskell/Case-sensitivity-of-identifiers | 1 + Lang/Haskell/Character-codes | 1 + Lang/Haskell/Character-matching | 1 + Lang/Haskell/Check-Machin-like-formulas | 1 + Lang/Haskell/Cholesky-decomposition | 1 + Lang/Haskell/Combinations | 1 + Lang/Haskell/Combinations-with-repetitions | 1 + Lang/Haskell/Command-line-arguments | 1 + Lang/Haskell/Compile-time-calculation | 1 + Lang/Haskell/Compound-data-type | 1 + Lang/Haskell/Concurrent-computing | 1 + Lang/Haskell/Conditional-structures | 1 + Lang/Haskell/Constrained-genericity | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/Haskell/Continued-fraction | 1 + ...-Arithmetic-Construct-from-rational-number | 1 + Lang/Haskell/Conways-Game-of-Life | 1 + Lang/Haskell/Count-in-factors | 1 + Lang/Haskell/Count-in-octal | 1 + Lang/Haskell/Count-occurrences-of-a-substring | 1 + Lang/Haskell/Count-the-coins | 1 + Lang/Haskell/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Haskell/Create-an-HTML-table | 1 + Lang/Haskell/Cut-a-rectangle | 1 + Lang/Haskell/Date-format | 1 + Lang/Haskell/Date-manipulation | 1 + Lang/Haskell/Day-of-the-week | 1 + Lang/Haskell/Deal-cards-for-FreeCell | 1 + Lang/Haskell/Deconvolution-1D | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/Haskell/Digital-root | 1 + .../Dinesmans-multiple-dwelling-problem | 1 + Lang/Haskell/Dining-philosophers | 1 + Lang/Haskell/Discordian-date | 1 + Lang/Haskell/Documentation | 1 + Lang/Haskell/Dot-product | 1 + Lang/Haskell/Doubly-linked-list-Definition | 1 + .../Doubly-linked-list-Element-definition | 1 + .../Doubly-linked-list-Element-insertion | 1 + Lang/Haskell/Doubly-linked-list-Traversal | 1 + Lang/Haskell/Draw-a-cuboid | 1 + Lang/Haskell/Draw-a-sphere | 1 + Lang/Haskell/Dutch-national-flag-problem | 1 + Lang/Haskell/Dynamic-variable-names | 1 + Lang/Haskell/Echo-server | 1 + Lang/Haskell/Empty-directory | 1 + Lang/Haskell/Empty-program | 1 + Lang/Haskell/Empty-string | 1 + Lang/Haskell/Enforced-immutability | 1 + Lang/Haskell/Enumerations | 1 + Lang/Haskell/Equilibrium-index | 1 + Lang/Haskell/Ethiopian-multiplication | 1 + Lang/Haskell/Euler-method | 1 + Lang/Haskell/Evaluate-binomial-coefficients | 1 + Lang/Haskell/Even-or-odd | 1 + Lang/Haskell/Events | 1 + Lang/Haskell/Evolutionary-algorithm | 1 + Lang/Haskell/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Haskell/Execute-a-system-command | 1 + Lang/Haskell/Exponentiation-operator | 1 + Lang/Haskell/Extend-your-language | 1 + Lang/Java/CRC-32 | 1 + Lang/Java/CSV-to-HTML-translation | 1 + Lang/Java/Call-a-foreign-language-function | 1 + Lang/Java/Call-a-function-in-a-shared-library | 1 + Lang/Java/Call-an-object-method | 1 + Lang/Java/Case-sensitivity-of-identifiers | 1 + Lang/Java/Character-codes | 1 + Lang/Java/Character-matching | 1 + Lang/Java/Chat-server | 1 + Lang/Java/Cholesky-decomposition | 1 + Lang/Java/Colour-bars-Display | 1 + Lang/Java/Combinations | 1 + Lang/Java/Combinations-with-repetitions | 1 + Lang/Java/Command-line-arguments | 1 + Lang/Java/Compound-data-type | 1 + Lang/Java/Concurrent-computing | 1 + Lang/Java/Conditional-structures | 1 + Lang/Java/Constrained-genericity | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/Java/Conways-Game-of-Life | 1 + Lang/Java/Count-in-factors | 1 + Lang/Java/Count-in-octal | 1 + Lang/Java/Count-occurrences-of-a-substring | 1 + Lang/Java/Count-the-coins | 1 + Lang/Java/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Java/Create-an-HTML-table | 1 + Lang/Java/Date-format | 1 + Lang/Java/Date-manipulation | 1 + Lang/Java/Day-of-the-week | 1 + Lang/Java/Deconvolution-1D | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/Java/Digital-root | 1 + Lang/Java/Dinesmans-multiple-dwelling-problem | 1 + Lang/Java/Dining-philosophers | 1 + Lang/Java/Documentation | 1 + Lang/Java/Dot-product | 1 + .../Doubly-linked-list-Element-definition | 1 + Lang/Java/Doubly-linked-list-Traversal | 1 + Lang/Java/Draw-a-sphere | 1 + Lang/Java/Echo-server | 1 + Lang/Java/Empty-directory | 1 + Lang/Java/Empty-program | 1 + Lang/Java/Empty-string | 1 + Lang/Java/Enforced-immutability | 1 + Lang/Java/Enumerations | 1 + Lang/Java/Equilibrium-index | 1 + Lang/Java/Ethiopian-multiplication | 1 + Lang/Java/Euler-method | 1 + Lang/Java/Evaluate-binomial-coefficients | 1 + Lang/Java/Even-or-odd | 1 + Lang/Java/Evolutionary-algorithm | 1 + Lang/Java/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Java/Execute-a-system-command | 1 + Lang/Java/Exponentiation-operator | 1 + Lang/Java/Extreme-floating-point-values | 1 + Lang/JavaScript/CSV-to-HTML-translation | 1 + Lang/JavaScript/Call-a-function | 1 + .../Case-sensitivity-of-identifiers | 1 + Lang/JavaScript/Character-codes | 1 + Lang/JavaScript/Character-matching | 1 + Lang/JavaScript/Chat-server | 1 + Lang/JavaScript/Combinations | 1 + Lang/JavaScript/Combinations-with-repetitions | 1 + Lang/JavaScript/Command-line-arguments | 1 + Lang/JavaScript/Compound-data-type | 1 + Lang/JavaScript/Concurrent-computing | 1 + Lang/JavaScript/Conditional-structures | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/JavaScript/Conways-Game-of-Life | 1 + Lang/JavaScript/Count-in-factors | 1 + Lang/JavaScript/Count-in-octal | 1 + .../Count-occurrences-of-a-substring | 1 + Lang/JavaScript/Count-the-coins | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/JavaScript/Create-an-HTML-table | 1 + Lang/JavaScript/Date-format | 1 + Lang/JavaScript/Date-manipulation | 1 + Lang/JavaScript/Day-of-the-week | 1 + Lang/JavaScript/Deal-cards-for-FreeCell | 1 + Lang/JavaScript/Deepcopy | 1 + Lang/JavaScript/Discordian-date | 1 + Lang/JavaScript/Distributed-programming | 1 + Lang/JavaScript/Dot-product | 1 + .../Doubly-linked-list-Element-definition | 1 + .../Doubly-linked-list-Element-insertion | 1 + Lang/JavaScript/Doubly-linked-list-Traversal | 1 + Lang/JavaScript/Dynamic-variable-names | 1 + Lang/JavaScript/Echo-server | 1 + Lang/JavaScript/Enforced-immutability | 1 + Lang/JavaScript/Enumerations | 1 + .../JavaScript/Evaluate-binomial-coefficients | 1 + Lang/JavaScript/Even-or-odd | 1 + Lang/JavaScript/Events | 1 + Lang/JavaScript/Evolutionary-algorithm | 1 + Lang/JavaScript/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/JavaScript/Execute-HQ9+ | 1 + Lang/JavaScript/Execute-a-system-command | 1 + Lang/JavaScript/Exponentiation-operator | 1 + Lang/LaTeX/Empty-program | 1 + Lang/Lua/CSV-to-HTML-translation | 1 + Lang/Lua/Case-sensitivity-of-identifiers | 1 + Lang/Lua/Character-codes | 1 + Lang/Lua/Character-matching | 1 + Lang/Lua/Combinations | 1 + Lang/Lua/Command-line-arguments | 1 + Lang/Lua/Compound-data-type | 1 + Lang/Lua/Concurrent-computing | 1 + Lang/Lua/Conditional-structures | 1 + Lang/Lua/Conways-Game-of-Life | 1 + Lang/Lua/Count-in-factors | 1 + Lang/Lua/Count-in-octal | 1 + Lang/Lua/Count-occurrences-of-a-substring | 1 + Lang/Lua/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Lua/Date-format | 1 + Lang/Lua/Date-manipulation | 1 + Lang/Lua/Day-of-the-week | 1 + Lang/Lua/Deconvolution-1D | 1 + Lang/Lua/Dot-product | 1 + Lang/Lua/Draw-a-sphere | 1 + Lang/Lua/Dynamic-variable-names | 1 + Lang/Lua/Empty-program | 1 + Lang/Lua/Empty-string | 1 + Lang/Lua/Enumerations | 1 + Lang/Lua/Ethiopian-multiplication | 1 + Lang/Lua/Euler-method | 1 + Lang/Lua/Evaluate-binomial-coefficients | 1 + Lang/Lua/Even-or-odd | 1 + Lang/Lua/Evolutionary-algorithm | 1 + Lang/Lua/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Lua/Execute-a-system-command | 1 + Lang/Lua/Exponentiation-operator | 1 + Lang/MATLAB/CSV-to-HTML-translation | 1 + Lang/MATLAB/Call-a-function | 1 + Lang/MATLAB/Case-sensitivity-of-identifiers | 1 + Lang/MATLAB/Character-codes | 1 + Lang/MATLAB/Character-matching | 1 + Lang/MATLAB/Cholesky-decomposition | 1 + Lang/MATLAB/Combinations | 1 + Lang/MATLAB/Conditional-structures | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/MATLAB/Conways-Game-of-Life | 1 + Lang/MATLAB/Count-in-octal | 1 + Lang/MATLAB/Count-occurrences-of-a-substring | 1 + Lang/MATLAB/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/MATLAB/Create-an-HTML-table | 1 + Lang/MATLAB/Date-format | 1 + Lang/MATLAB/Day-of-the-week | 1 + Lang/MATLAB/Deconvolution-1D | 1 + Lang/MATLAB/Dot-product | 1 + Lang/MATLAB/Empty-directory | 1 + Lang/MATLAB/Empty-program | 1 + Lang/MATLAB/Empty-string | 1 + Lang/MATLAB/Enumerations | 1 + Lang/MATLAB/Equilibrium-index | 1 + Lang/MATLAB/Ethiopian-multiplication | 1 + Lang/MATLAB/Evaluate-binomial-coefficients | 1 + Lang/MATLAB/Even-or-odd | 1 + Lang/MATLAB/Evolutionary-algorithm | 1 + Lang/MATLAB/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/MATLAB/Execute-a-system-command | 1 + Lang/PHP/CRC-32 | 1 + Lang/PHP/Calendar-for-real-programmers | 1 + Lang/PHP/Call-an-object-method | 1 + Lang/PHP/Character-codes | 1 + Lang/PHP/Colour-bars-Display | 1 + Lang/PHP/Combinations-with-repetitions | 1 + Lang/PHP/Command-line-arguments | 1 + Lang/PHP/Compound-data-type | 1 + Lang/PHP/Conditional-structures | 1 + Lang/PHP/Count-in-octal | 1 + Lang/PHP/Count-occurrences-of-a-substring | 1 + Lang/PHP/Create-a-file | 1 + Lang/PHP/Create-an-HTML-table | 1 + Lang/PHP/DNS-query | 1 + Lang/PHP/Date-format | 1 + Lang/PHP/Date-manipulation | 1 + Lang/PHP/Day-of-the-week | 1 + Lang/PHP/Deepcopy | 1 + Lang/PHP/Discordian-date | 1 + Lang/PHP/Dot-product | 1 + Lang/PHP/Dynamic-variable-names | 1 + Lang/PHP/Echo-server | 1 + Lang/PHP/Empty-directory | 1 + Lang/PHP/Empty-string | 1 + Lang/PHP/Enforced-immutability | 1 + Lang/PHP/Enumerations | 1 + Lang/PHP/Equilibrium-index | 1 + Lang/PHP/Ethiopian-multiplication | 1 + Lang/PHP/Evaluate-binomial-coefficients | 1 + Lang/PHP/Even-or-odd | 1 + Lang/PHP/Exceptions | 1 + Lang/PHP/Execute-a-system-command | 1 + Lang/PIR/Empty-program | 1 + Lang/Perl/CRC-32 | 1 + Lang/Perl/CSV-to-HTML-translation | 1 + Lang/Perl/Calendar-for-real-programmers | 1 + Lang/Perl/Call-a-foreign-language-function | 1 + Lang/Perl/Call-an-object-method | 1 + Lang/Perl/Case-sensitivity-of-identifiers | 1 + Lang/Perl/Character-codes | 1 + Lang/Perl/Character-matching | 1 + Lang/Perl/Colour-bars-Display | 1 + Lang/Perl/Colour-pinstripe-Display | 1 + Lang/Perl/Combinations | 1 + Lang/Perl/Combinations-with-repetitions | 1 + Lang/Perl/Command-line-arguments | 1 + Lang/Perl/Compile-time-calculation | 1 + Lang/Perl/Compound-data-type | 1 + Lang/Perl/Concurrent-computing | 1 + Lang/Perl/Conditional-structures | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/Perl/Continued-fraction | 1 + Lang/Perl/Conways-Game-of-Life | 1 + Lang/Perl/Count-in-factors | 1 + Lang/Perl/Count-in-octal | 1 + Lang/Perl/Count-occurrences-of-a-substring | 1 + Lang/Perl/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Perl/Create-an-HTML-table | 1 + Lang/Perl/DNS-query | 1 + Lang/Perl/Date-format | 1 + Lang/Perl/Date-manipulation | 1 + Lang/Perl/Day-of-the-week | 1 + Lang/Perl/Deal-cards-for-FreeCell | 1 + Lang/Perl/Deepcopy | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/Perl/Distributed-programming | 1 + Lang/Perl/Dot-product | 1 + .../Doubly-linked-list-Element-definition | 1 + .../Perl/Doubly-linked-list-Element-insertion | 1 + Lang/Perl/Draw-a-cuboid | 1 + Lang/Perl/Dynamic-variable-names | 1 + Lang/Perl/Echo-server | 1 + Lang/Perl/Element-wise-operations | 1 + Lang/Perl/Empty-directory | 1 + Lang/Perl/Empty-program | 1 + Lang/Perl/Empty-string | 1 + Lang/Perl/Enforced-immutability | 1 + Lang/Perl/Enumerations | 1 + Lang/Perl/Equilibrium-index | 1 + Lang/Perl/Ethiopian-multiplication | 1 + Lang/Perl/Euler-method | 1 + Lang/Perl/Evaluate-binomial-coefficients | 1 + Lang/Perl/Even-or-odd | 1 + Lang/Perl/Events | 1 + Lang/Perl/Evolutionary-algorithm | 1 + Lang/Perl/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Perl/Executable-library | 1 + Lang/Perl/Execute-a-system-command | 1 + Lang/Perl/Exponentiation-operator | 1 + Lang/Perl/Extend-your-language | 1 + Lang/Perl/Extreme-floating-point-values | 1 + Lang/PicoLisp/CSV-to-HTML-translation | 1 + Lang/PicoLisp/Calendar-for-real-programmers | 1 + .../PicoLisp/Call-a-foreign-language-function | 1 + Lang/PicoLisp/Call-a-function | 1 + .../Call-a-function-in-a-shared-library | 1 + Lang/PicoLisp/Call-an-object-method | 1 + Lang/PicoLisp/Case-sensitivity-of-identifiers | 1 + Lang/PicoLisp/Character-codes | 1 + Lang/PicoLisp/Character-matching | 1 + Lang/PicoLisp/Chat-server | 1 + Lang/PicoLisp/Cholesky-decomposition | 1 + Lang/PicoLisp/Colour-bars-Display | 1 + Lang/PicoLisp/Colour-pinstripe-Display | 1 + Lang/PicoLisp/Colour-pinstripe-Printer | 1 + Lang/PicoLisp/Combinations | 1 + Lang/PicoLisp/Combinations-with-repetitions | 1 + Lang/PicoLisp/Command-line-arguments | 1 + Lang/PicoLisp/Compile-time-calculation | 1 + Lang/PicoLisp/Compound-data-type | 1 + Lang/PicoLisp/Concurrent-computing | 1 + Lang/PicoLisp/Conditional-structures | 1 + Lang/PicoLisp/Constrained-genericity | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/PicoLisp/Conways-Game-of-Life | 1 + Lang/PicoLisp/Count-in-factors | 1 + Lang/PicoLisp/Count-in-octal | 1 + .../PicoLisp/Count-occurrences-of-a-substring | 1 + Lang/PicoLisp/Count-the-coins | 1 + Lang/PicoLisp/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/PicoLisp/Create-an-HTML-table | 1 + .../Create-an-object-at-a-given-address | 1 + Lang/PicoLisp/DNS-query | 1 + Lang/PicoLisp/Date-format | 1 + Lang/PicoLisp/Date-manipulation | 1 + Lang/PicoLisp/Day-of-the-week | 1 + Lang/PicoLisp/Deal-cards-for-FreeCell | 1 + Lang/PicoLisp/Deconvolution-1D | 1 + Lang/PicoLisp/Deepcopy | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/PicoLisp/Digital-root | 1 + .../Dinesmans-multiple-dwelling-problem | 1 + Lang/PicoLisp/Dining-philosophers | 1 + Lang/PicoLisp/Discordian-date | 1 + Lang/PicoLisp/Distributed-programming | 1 + Lang/PicoLisp/Documentation | 1 + Lang/PicoLisp/Dot-product | 1 + Lang/PicoLisp/Doubly-linked-list-Definition | 1 + .../Doubly-linked-list-Element-definition | 1 + .../Doubly-linked-list-Element-insertion | 1 + Lang/PicoLisp/Doubly-linked-list-Traversal | 1 + Lang/PicoLisp/Draw-a-cuboid | 1 + Lang/PicoLisp/Draw-a-sphere | 1 + Lang/PicoLisp/Dutch-national-flag-problem | 1 + Lang/PicoLisp/Dynamic-variable-names | 1 + Lang/PicoLisp/Echo-server | 1 + Lang/PicoLisp/Element-wise-operations | 1 + Lang/PicoLisp/Empty-directory | 1 + Lang/PicoLisp/Empty-program | 1 + Lang/PicoLisp/Empty-string | 1 + Lang/PicoLisp/Enforced-immutability | 1 + Lang/PicoLisp/Enumerations | 1 + Lang/PicoLisp/Equilibrium-index | 1 + Lang/PicoLisp/Ethiopian-multiplication | 1 + Lang/PicoLisp/Euler-method | 1 + Lang/PicoLisp/Evaluate-binomial-coefficients | 1 + Lang/PicoLisp/Even-or-odd | 1 + Lang/PicoLisp/Events | 1 + Lang/PicoLisp/Evolutionary-algorithm | 1 + Lang/PicoLisp/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/PicoLisp/Executable-library | 1 + Lang/PicoLisp/Execute-HQ9+ | 1 + Lang/PicoLisp/Execute-a-system-command | 1 + Lang/PicoLisp/Exponentiation-operator | 1 + Lang/PicoLisp/Extend-your-language | 1 + Lang/PicoLisp/Extreme-floating-point-values | 1 + Lang/Prolog/CSV-to-HTML-translation | 1 + Lang/Prolog/Case-sensitivity-of-identifiers | 1 + Lang/Prolog/Combinations | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/Prolog/Continued-fraction | 1 + Lang/Prolog/Conways-Game-of-Life | 1 + .../Dinesmans-multiple-dwelling-problem | 1 + Lang/Prolog/Dining-philosophers | 1 + Lang/Prolog/Dot-product | 1 + Lang/Prolog/Draw-a-cuboid | 1 + Lang/Prolog/Dutch-national-flag-problem | 1 + Lang/Prolog/Execute-a-system-command | 1 + Lang/Python/CRC-32 | 1 + Lang/Python/CSV-to-HTML-translation | 1 + Lang/Python/Call-a-foreign-language-function | 1 + Lang/Python/Call-a-function | 1 + .../Call-a-function-in-a-shared-library | 1 + Lang/Python/Call-an-object-method | 1 + Lang/Python/Carmichael-3-strong-pseudoprimes | 1 + Lang/Python/Case-sensitivity-of-identifiers | 1 + Lang/Python/Character-codes | 1 + Lang/Python/Character-matching | 1 + Lang/Python/Chat-server | 1 + Lang/Python/Check-Machin-like-formulas | 1 + Lang/Python/Cholesky-decomposition | 1 + Lang/Python/Colour-bars-Display | 1 + Lang/Python/Combinations | 1 + Lang/Python/Combinations-with-repetitions | 1 + Lang/Python/Command-line-arguments | 1 + .../Compare-sorting-algorithms-performance | 1 + Lang/Python/Compound-data-type | 1 + Lang/Python/Concurrent-computing | 1 + Lang/Python/Conditional-structures | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/Python/Continued-fraction | 1 + ...-Arithmetic-Construct-from-rational-number | 1 + Lang/Python/Conways-Game-of-Life | 1 + Lang/Python/Count-in-factors | 1 + Lang/Python/Count-in-octal | 1 + Lang/Python/Count-occurrences-of-a-substring | 1 + Lang/Python/Count-the-coins | 1 + Lang/Python/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Python/Create-an-HTML-table | 1 + Lang/Python/Cut-a-rectangle | 1 + Lang/Python/Date-format | 1 + Lang/Python/Date-manipulation | 1 + Lang/Python/Day-of-the-week | 1 + Lang/Python/Deal-cards-for-FreeCell | 1 + Lang/Python/Deconvolution-1D | 1 + Lang/Python/Deepcopy | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/Python/Digital-root | 1 + .../Dinesmans-multiple-dwelling-problem | 1 + Lang/Python/Dining-philosophers | 1 + Lang/Python/Discordian-date | 1 + Lang/Python/Distributed-programming | 1 + Lang/Python/Documentation | 1 + Lang/Python/Dot-product | 1 + .../Doubly-linked-list-Element-definition | 1 + .../Doubly-linked-list-Element-insertion | 1 + Lang/Python/Doubly-linked-list-Traversal | 1 + Lang/Python/Draw-a-cuboid | 1 + Lang/Python/Draw-a-sphere | 1 + Lang/Python/Dutch-national-flag-problem | 1 + Lang/Python/Dynamic-variable-names | 1 + Lang/Python/Echo-server | 1 + Lang/Python/Element-wise-operations | 1 + Lang/Python/Empty-directory | 1 + Lang/Python/Empty-string | 1 + Lang/Python/Enforced-immutability | 1 + Lang/Python/Enumerations | 1 + Lang/Python/Equilibrium-index | 1 + Lang/Python/Ethiopian-multiplication | 1 + Lang/Python/Euler-method | 1 + Lang/Python/Evaluate-binomial-coefficients | 1 + Lang/Python/Even-or-odd | 1 + Lang/Python/Evolutionary-algorithm | 1 + Lang/Python/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Python/Executable-library | 1 + Lang/Python/Execute-a-system-command | 1 + Lang/Python/Exponentiation-operator | 1 + Lang/Python/Extreme-floating-point-values | 1 + Lang/R/Case-sensitivity-of-identifiers | 1 + Lang/R/Character-codes | 1 + Lang/R/Cholesky-decomposition | 1 + Lang/R/Colour-bars-Display | 1 + Lang/R/Combinations | 1 + Lang/R/Command-line-arguments | 1 + Lang/R/Compound-data-type | 1 + Lang/R/Conditional-structures | 1 + Lang/R/Constrained-random-points-on-a-circle | 1 + Lang/R/Conways-Game-of-Life | 1 + Lang/R/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/R/Date-format | 1 + Lang/R/Date-manipulation | 1 + Lang/R/Day-of-the-week | 1 + Lang/R/Deconvolution-1D | 1 + Lang/R/Documentation | 1 + Lang/R/Dot-product | 1 + Lang/R/Dynamic-variable-names | 1 + Lang/R/Element-wise-operations | 1 + Lang/R/Empty-string | 1 + Lang/R/Enumerations | 1 + Lang/R/Ethiopian-multiplication | 1 + Lang/R/Evaluate-binomial-coefficients | 1 + Lang/R/Even-or-odd | 1 + Lang/R/Evolutionary-algorithm | 1 + Lang/R/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/R/Execute-a-system-command | 1 + Lang/R/Exponentiation-operator | 1 + Lang/R/Extend-your-language | 1 + Lang/R/Extreme-floating-point-values | 1 + Lang/REXX/CRC-32 | 1 + Lang/REXX/CSV-to-HTML-translation | 1 + Lang/REXX/Calendar-for-real-programmers | 1 + Lang/REXX/Call-a-function | 1 + Lang/REXX/Carmichael-3-strong-pseudoprimes | 1 + Lang/REXX/Case-sensitivity-of-identifiers | 1 + Lang/REXX/Character-codes | 1 + Lang/REXX/Character-matching | 1 + Lang/REXX/Cholesky-decomposition | 1 + Lang/REXX/Combinations | 1 + Lang/REXX/Combinations-with-repetitions | 1 + Lang/REXX/Command-line-arguments | 1 + Lang/REXX/Compile-time-calculation | 1 + Lang/REXX/Compound-data-type | 1 + Lang/REXX/Conditional-structures | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/REXX/Continued-fraction | 1 + ...-Arithmetic-Construct-from-rational-number | 1 + Lang/REXX/Conways-Game-of-Life | 1 + Lang/REXX/Count-in-factors | 1 + Lang/REXX/Count-in-octal | 1 + Lang/REXX/Count-occurrences-of-a-substring | 1 + Lang/REXX/Count-the-coins | 1 + Lang/REXX/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/REXX/Create-an-HTML-table | 1 + Lang/REXX/Cut-a-rectangle | 1 + Lang/REXX/Date-format | 1 + Lang/REXX/Date-manipulation | 1 + Lang/REXX/Day-of-the-week | 1 + Lang/REXX/Digital-root | 1 + Lang/REXX/Dinesmans-multiple-dwelling-problem | 1 + Lang/REXX/Discordian-date | 1 + Lang/REXX/Documentation | 1 + Lang/REXX/Dot-product | 1 + Lang/REXX/Doubly-linked-list-Definition | 1 + .../Doubly-linked-list-Element-definition | 1 + .../REXX/Doubly-linked-list-Element-insertion | 1 + Lang/REXX/Doubly-linked-list-Traversal | 1 + Lang/REXX/Draw-a-cuboid | 1 + Lang/REXX/Draw-a-sphere | 1 + Lang/REXX/Dutch-national-flag-problem | 1 + Lang/REXX/Dynamic-variable-names | 1 + Lang/REXX/Element-wise-operations | 1 + Lang/REXX/Empty-program | 1 + Lang/REXX/Empty-string | 1 + Lang/REXX/Enumerations | 1 + Lang/REXX/Equilibrium-index | 1 + Lang/REXX/Ethiopian-multiplication | 1 + Lang/REXX/Evaluate-binomial-coefficients | 1 + Lang/REXX/Even-or-odd | 1 + Lang/REXX/Evolutionary-algorithm | 1 + Lang/REXX/Executable-library | 1 + Lang/REXX/Execute-HQ9+ | 1 + Lang/REXX/Execute-a-system-command | 1 + Lang/REXX/Exponentiation-operator | 1 + Lang/Racket/CSV-to-HTML-translation | 1 + Lang/Racket/Call-a-foreign-language-function | 1 + .../Call-a-function-in-a-shared-library | 1 + Lang/Racket/Call-an-object-method | 1 + Lang/Racket/Case-sensitivity-of-identifiers | 1 + Lang/Racket/Character-matching | 1 + Lang/Racket/Color-quantization | 1 + Lang/Racket/Command-line-arguments | 1 + Lang/Racket/Compile-time-calculation | 1 + Lang/Racket/Compound-data-type | 1 + Lang/Racket/Concurrent-computing | 1 + Lang/Racket/Conways-Game-of-Life | 1 + Lang/Racket/Count-in-factors | 1 + Lang/Racket/Count-in-octal | 1 + Lang/Racket/Create-a-file | 1 + Lang/Racket/Create-an-HTML-table | 1 + Lang/Racket/DNS-query | 1 + Lang/Racket/Date-format | 1 + Lang/Racket/Digital-root | 1 + Lang/Racket/Documentation | 1 + Lang/Racket/Dot-product | 1 + Lang/Racket/Draw-a-sphere | 1 + Lang/Racket/Echo-server | 1 + Lang/Racket/Empty-directory | 1 + Lang/Racket/Empty-program | 1 + Lang/Racket/Empty-string | 1 + Lang/Racket/Evaluate-binomial-coefficients | 1 + Lang/Racket/Even-or-odd | 1 + Lang/Racket/Exceptions | 1 + Lang/Ruby/CRC-32 | 1 + Lang/Ruby/CSV-to-HTML-translation | 1 + Lang/Ruby/Calendar-for-real-programmers | 1 + Lang/Ruby/Call-a-foreign-language-function | 1 + Lang/Ruby/Call-a-function-in-a-shared-library | 1 + Lang/Ruby/Call-an-object-method | 1 + Lang/Ruby/Carmichael-3-strong-pseudoprimes | 1 + Lang/Ruby/Case-sensitivity-of-identifiers | 1 + Lang/Ruby/Character-codes | 1 + Lang/Ruby/Character-matching | 1 + Lang/Ruby/Chat-server | 1 + Lang/Ruby/Cholesky-decomposition | 1 + Lang/Ruby/Combinations | 1 + Lang/Ruby/Combinations-with-repetitions | 1 + Lang/Ruby/Command-line-arguments | 1 + Lang/Ruby/Compound-data-type | 1 + Lang/Ruby/Concurrent-computing | 1 + .../Constrained-random-points-on-a-circle | 1 + Lang/Ruby/Continued-fraction | 1 + ...-Arithmetic-Construct-from-rational-number | 1 + ...ithmetic-G(matrix-NG,-Contined-Fraction-N) | 1 + Lang/Ruby/Conways-Game-of-Life | 1 + Lang/Ruby/Count-in-factors | 1 + Lang/Ruby/Count-in-octal | 1 + Lang/Ruby/Count-occurrences-of-a-substring | 1 + Lang/Ruby/Count-the-coins | 1 + Lang/Ruby/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Ruby/Create-an-HTML-table | 1 + Lang/Ruby/Date-format | 1 + Lang/Ruby/Date-manipulation | 1 + Lang/Ruby/Day-of-the-week | 1 + Lang/Ruby/Deal-cards-for-FreeCell | 1 + Lang/Ruby/Deepcopy | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/Ruby/Dinesmans-multiple-dwelling-problem | 1 + Lang/Ruby/Dining-philosophers | 1 + Lang/Ruby/Discordian-date | 1 + Lang/Ruby/Distributed-programming | 1 + Lang/Ruby/Documentation | 1 + Lang/Ruby/Dot-product | 1 + .../Doubly-linked-list-Element-definition | 1 + .../Ruby/Doubly-linked-list-Element-insertion | 1 + Lang/Ruby/Doubly-linked-list-Traversal | 1 + Lang/Ruby/Draw-a-sphere | 1 + Lang/Ruby/Dutch-national-flag-problem | 1 + Lang/Ruby/Dynamic-variable-names | 1 + Lang/Ruby/Echo-server | 1 + Lang/Ruby/Empty-directory | 1 + Lang/Ruby/Empty-program | 1 + Lang/Ruby/Empty-string | 1 + Lang/Ruby/Enforced-immutability | 1 + Lang/Ruby/Enumerations | 1 + Lang/Ruby/Equilibrium-index | 1 + Lang/Ruby/Ethiopian-multiplication | 1 + Lang/Ruby/Euler-method | 1 + Lang/Ruby/Evaluate-binomial-coefficients | 1 + Lang/Ruby/Even-or-odd | 1 + Lang/Ruby/Evolutionary-algorithm | 1 + Lang/Ruby/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Ruby/Executable-library | 1 + Lang/Ruby/Execute-a-system-command | 1 + Lang/Ruby/Exponentiation-operator | 1 + Lang/Ruby/Extend-your-language | 1 + Lang/Ruby/Extreme-floating-point-values | 1 + Lang/SNUSP/Conditional-structures | 1 + Lang/SNUSP/Ethiopian-multiplication | 1 + Lang/SNUSP/Even-or-odd | 1 + Lang/Sather/Case-sensitivity-of-identifiers | 1 + Lang/Sather/Character-codes | 1 + Lang/Sather/Command-line-arguments | 1 + Lang/Sather/Conditional-structures | 1 + Lang/Sather/Constrained-genericity | 1 + Lang/Sather/Dot-product | 1 + Lang/Scala/CSV-to-HTML-translation | 1 + Lang/Scala/Case-sensitivity-of-identifiers | 1 + Lang/Scala/Character-codes | 1 + Lang/Scala/Character-matching | 1 + Lang/Scala/Colour-bars-Display | 1 + Lang/Scala/Combinations | 1 + Lang/Scala/Combinations-with-repetitions | 1 + Lang/Scala/Command-line-arguments | 1 + Lang/Scala/Compound-data-type | 1 + Lang/Scala/Concurrent-computing | 1 + Lang/Scala/Constrained-genericity | 1 + Lang/Scala/Continued-fraction | 1 + Lang/Scala/Count-in-octal | 1 + Lang/Scala/Count-occurrences-of-a-substring | 1 + Lang/Scala/Count-the-coins | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Scala/Date-format | 1 + Lang/Scala/Date-manipulation | 1 + Lang/Scala/Day-of-the-week | 1 + Lang/Scala/Digital-root | 1 + .../Scala/Dinesmans-multiple-dwelling-problem | 1 + Lang/Scala/Discordian-date | 1 + Lang/Scala/Dot-product | 1 + Lang/Scala/Empty-directory | 1 + Lang/Scala/Empty-program | 1 + Lang/Scala/Empty-string | 1 + Lang/Scala/Enforced-immutability | 1 + Lang/Scala/Enumerations | 1 + Lang/Scala/Ethiopian-multiplication | 1 + Lang/Scala/Euler-method | 1 + Lang/Scala/Evaluate-binomial-coefficients | 1 + Lang/Scala/Even-or-odd | 1 + Lang/Scala/Evolutionary-algorithm | 1 + Lang/Scala/Execute-HQ9+ | 1 + Lang/Scala/Execute-a-system-command | 1 + Lang/Scala/Exponentiation-operator | 1 + Lang/Scala/Extend-your-language | 1 + Lang/Scheme/Case-sensitivity-of-identifiers | 1 + Lang/Scheme/Character-codes | 1 + Lang/Scheme/Combinations | 1 + Lang/Scheme/Combinations-with-repetitions | 1 + Lang/Scheme/Command-line-arguments | 1 + Lang/Scheme/Compound-data-type | 1 + Lang/Scheme/Concurrent-computing | 1 + Lang/Scheme/Conditional-structures | 1 + Lang/Scheme/Conways-Game-of-Life | 1 + Lang/Scheme/Count-in-factors | 1 + Lang/Scheme/Count-in-octal | 1 + Lang/Scheme/Count-the-coins | 1 + Lang/Scheme/Create-a-file | 1 + Lang/Scheme/Create-an-HTML-table | 1 + Lang/Scheme/DNS-query | 1 + Lang/Scheme/Day-of-the-week | 1 + Lang/Scheme/Dot-product | 1 + Lang/Scheme/Dynamic-variable-names | 1 + Lang/Scheme/Echo-server | 1 + Lang/Scheme/Empty-program | 1 + Lang/Scheme/Empty-string | 1 + Lang/Scheme/Enumerations | 1 + Lang/Scheme/Ethiopian-multiplication | 1 + Lang/Scheme/Evaluate-binomial-coefficients | 1 + Lang/Scheme/Even-or-odd | 1 + Lang/Scheme/Exceptions | 1 + Lang/Scheme/Execute-a-system-command | 1 + Lang/Scheme/Exponentiation-operator | 1 + Lang/Scheme/Extend-your-language | 1 + Lang/Scheme/Extreme-floating-point-values | 1 + Lang/Smalltalk/CRC-32 | 1 + Lang/Smalltalk/Call-a-function | 1 + .../Call-a-function-in-a-shared-library | 1 + Lang/Smalltalk/Call-an-object-method | 1 + .../Smalltalk/Case-sensitivity-of-identifiers | 1 + Lang/Smalltalk/Character-codes | 1 + Lang/Smalltalk/Character-matching | 1 + Lang/Smalltalk/Combinations | 1 + Lang/Smalltalk/Command-line-arguments | 1 + Lang/Smalltalk/Conditional-structures | 1 + Lang/Smalltalk/Create-a-file | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Smalltalk/Date-manipulation | 1 + Lang/Smalltalk/Day-of-the-week | 1 + Lang/Smalltalk/Dining-philosophers | 1 + Lang/Smalltalk/Documentation | 1 + Lang/Smalltalk/Dot-product | 1 + Lang/Smalltalk/Draw-a-sphere | 1 + Lang/Smalltalk/Dynamic-variable-names | 1 + Lang/Smalltalk/Empty-program | 1 + Lang/Smalltalk/Ethiopian-multiplication | 1 + Lang/Smalltalk/Evolutionary-algorithm | 1 + Lang/Smalltalk/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Smalltalk/Execute-a-system-command | 1 + Lang/Smalltalk/Exponentiation-operator | 1 + Lang/Tcl/CRC-32 | 1 + Lang/Tcl/CSV-to-HTML-translation | 1 + Lang/Tcl/Calendar-for-real-programmers | 1 + Lang/Tcl/Call-a-foreign-language-function | 1 + Lang/Tcl/Call-a-function | 1 + Lang/Tcl/Call-a-function-in-a-shared-library | 1 + Lang/Tcl/Call-an-object-method | 1 + Lang/Tcl/Canny-edge-detector | 1 + Lang/Tcl/Carmichael-3-strong-pseudoprimes | 1 + Lang/Tcl/Case-sensitivity-of-identifiers | 1 + Lang/Tcl/Catmull-Clark-subdivision-surface | 1 + Lang/Tcl/Character-codes | 1 + Lang/Tcl/Character-matching | 1 + Lang/Tcl/Chat-server | 1 + Lang/Tcl/Check-Machin-like-formulas | 1 + Lang/Tcl/Cholesky-decomposition | 1 + Lang/Tcl/Color-quantization | 1 + Lang/Tcl/Colour-bars-Display | 1 + Lang/Tcl/Colour-pinstripe-Display | 1 + Lang/Tcl/Colour-pinstripe-Printer | 1 + Lang/Tcl/Combinations | 1 + Lang/Tcl/Combinations-with-repetitions | 1 + Lang/Tcl/Command-line-arguments | 1 + .../Compare-sorting-algorithms-performance | 1 + Lang/Tcl/Compile-time-calculation | 1 + Lang/Tcl/Compound-data-type | 1 + Lang/Tcl/Concurrent-computing | 1 + Lang/Tcl/Conditional-structures | 1 + .../Tcl/Constrained-random-points-on-a-circle | 1 + Lang/Tcl/Continued-fraction | 1 + ...-Arithmetic-Construct-from-rational-number | 1 + ...ithmetic-G(matrix-NG,-Contined-Fraction-N) | 1 + ...ontined-Fraction-N1,-Contined-Fraction-N2) | 1 + Lang/Tcl/Conways-Game-of-Life | 1 + Lang/Tcl/Count-in-factors | 1 + Lang/Tcl/Count-in-octal | 1 + Lang/Tcl/Count-occurrences-of-a-substring | 1 + Lang/Tcl/Count-the-coins | 1 + Lang/Tcl/Create-a-file | 1 + Lang/Tcl/Create-a-file-on-magnetic-tape | 1 + .../Create-a-two-dimensional-array-at-runtime | 1 + Lang/Tcl/Create-an-HTML-table | 1 + Lang/Tcl/Create-an-object-at-a-given-address | 1 + Lang/Tcl/Cut-a-rectangle | 1 + Lang/Tcl/DNS-query | 1 + Lang/Tcl/Date-format | 1 + Lang/Tcl/Date-manipulation | 1 + Lang/Tcl/Day-of-the-week | 1 + Lang/Tcl/Deal-cards-for-FreeCell | 1 + Lang/Tcl/Deconvolution-1D | 1 + Lang/Tcl/Deconvolution-2D+ | 1 + Lang/Tcl/Deepcopy | 1 + .../Determine-if-only-one-instance-is-running | 1 + Lang/Tcl/Digital-root | 1 + Lang/Tcl/Dinesmans-multiple-dwelling-problem | 1 + Lang/Tcl/Dining-philosophers | 1 + Lang/Tcl/Discordian-date | 1 + Lang/Tcl/Distributed-programming | 1 + Lang/Tcl/Documentation | 1 + Lang/Tcl/Dot-product | 1 + Lang/Tcl/Doubly-linked-list-Definition | 1 + .../Tcl/Doubly-linked-list-Element-definition | 1 + Lang/Tcl/Doubly-linked-list-Element-insertion | 1 + Lang/Tcl/Doubly-linked-list-Traversal | 1 + Lang/Tcl/Draw-a-cuboid | 1 + Lang/Tcl/Draw-a-sphere | 1 + Lang/Tcl/Dutch-national-flag-problem | 1 + Lang/Tcl/Dynamic-variable-names | 1 + Lang/Tcl/Echo-server | 1 + Lang/Tcl/Element-wise-operations | 1 + Lang/Tcl/Empty-directory | 1 + Lang/Tcl/Empty-program | 1 + Lang/Tcl/Empty-string | 1 + Lang/Tcl/Enforced-immutability | 1 + Lang/Tcl/Enumerations | 1 + Lang/Tcl/Equilibrium-index | 1 + Lang/Tcl/Ethiopian-multiplication | 1 + Lang/Tcl/Euler-method | 1 + Lang/Tcl/Evaluate-binomial-coefficients | 1 + Lang/Tcl/Even-or-odd | 1 + Lang/Tcl/Events | 1 + Lang/Tcl/Evolutionary-algorithm | 1 + Lang/Tcl/Exceptions | 1 + ...Catch-an-exception-thrown-in-a-nested-call | 1 + Lang/Tcl/Executable-library | 1 + Lang/Tcl/Execute-a-system-command | 1 + Lang/Tcl/Exponentiation-operator | 1 + Lang/Tcl/Extend-your-language | 1 + Lang/Tcl/Extreme-floating-point-values | 1 + Meta/Lang.yaml | 317 ++++++- Meta/Task.yaml | 365 ++++++++ Task/100-doors/C++/100-doors-1.cpp | 16 + Task/100-doors/C++/100-doors-2.cpp | 19 + Task/100-doors/C++/100-doors-3.cpp | 7 + Task/100-doors/C-sharp/100-doors-1.cs | 14 + Task/100-doors/C-sharp/100-doors-2.cs | 20 + Task/100-doors/C-sharp/100-doors-3.cs | 10 + Task/100-doors/C-sharp/100-doors-4.cs | 41 + Task/100-doors/C1R/100-doors.c1r | 1 + Task/100-doors/CLIPS/100-doors-1.clips | 64 ++ Task/100-doors/CLIPS/100-doors-2.clips | 20 + Task/100-doors/COBOL/100-doors.cobol | 31 + Task/100-doors/ColdFusion/100-doors-1.cfm | 25 + Task/100-doors/ColdFusion/100-doors-2.cfm | 11 + Task/100-doors/ColdFusion/100-doors-3.cfm | 11 + Task/100-doors/Common-Lisp/100-doors-1.lisp | 38 + Task/100-doors/Common-Lisp/100-doors-2.lisp | 9 + Task/100-doors/Common-Lisp/100-doors-3.lisp | 21 + Task/100-doors/Common-Lisp/100-doors-4.lisp | 5 + Task/100-doors/D/100-doors.d | 36 + Task/100-doors/DWScript/100-doors.dwscript | 11 + Task/100-doors/Dart/100-doors-1.dart | 7 + Task/100-doors/Dart/100-doors-2.dart | 4 + Task/100-doors/E/100-doors.e | 45 + Task/100-doors/EGL/100-doors.egl | 22 + Task/100-doors/Ela/100-doors-1.ela | 11 + Task/100-doors/Ela/100-doors-2.ela | 2 + Task/100-doors/Emacs-Lisp/100-doors.l | 83 ++ .../Euler-Math-Toolbox/100-doors.euler | 11 + Task/100-doors/Euphoria/100-doors.euphoria | 23 + Task/24-game/C++/24-game.cpp | 98 +++ Task/24-game/Common-Lisp/24-game-1.lisp | 36 + Task/24-game/Common-Lisp/24-game-2.lisp | 104 +++ Task/24-game/D/24-game.d | 37 + .../C++/99-bottles-of-beer-1.cpp | 13 + .../C++/99-bottles-of-beer-2.cpp | 28 + .../C++/99-bottles-of-beer-3.cpp | 20 + .../C++/99-bottles-of-beer-4.cpp | 30 + .../C++/99-bottles-of-beer-5.cpp | 37 + .../C-sharp/99-bottles-of-beer-1.cs | 29 + .../C-sharp/99-bottles-of-beer-2.cs | 18 + .../C-sharp/99-bottles-of-beer-3.cs | 28 + .../C-sharp/99-bottles-of-beer-4.cs | 21 + .../C-sharp/99-bottles-of-beer-5.cs | 131 +++ .../CLIPS/99-bottles-of-beer.clips | 19 + .../COBOL/99-bottles-of-beer-1.cobol | 122 +++ .../COBOL/99-bottles-of-beer-2.cobol | 104 +++ .../Chapel/99-bottles-of-beer.chapel | 68 ++ .../Chef/99-bottles-of-beer.chef | 225 +++++ .../Clay/99-bottles-of-beer.clay | 20 + .../ColdFusion/99-bottles-of-beer-1.cfm | 9 + .../ColdFusion/99-bottles-of-beer-2.cfm | 6 + .../Common-Lisp/99-bottles-of-beer-1.lisp | 6 + .../Common-Lisp/99-bottles-of-beer-2.lisp | 1 + .../99-Bottles-of-Beer/D/99-bottles-of-beer.d | 20 + .../Dart/99-bottles-of-beer.dart | 9 + .../Delphi/99-bottles-of-beer.delphi | 27 + .../99-Bottles-of-Beer/E/99-bottles-of-beer.e | 14 + .../EGL/99-bottles-of-beer.egl | 22 + .../Ela/99-bottles-of-beer.ela | 9 + .../Euphoria/99-bottles-of-beer.euphoria | 50 ++ Task/A+B/C++/a+b-1.cpp | 9 + Task/A+B/C++/a+b-2.cpp | 13 + Task/A+B/Common-Lisp/a+b.lisp | 1 + Task/A+B/D/a+b-1.d | 11 + Task/A+B/D/a+b-2.d | 8 + Task/A+B/DMS/a+b.dms | 3 + Task/A+B/DWScript/a+b.dwscript | 3 + Task/A+B/Deja-Vu/a+b.djv | 4 + Task/A+B/Delphi/a+b.delphi | 14 + Task/A+B/EGL/a+b.egl | 18 + Task/A+B/Ela/a+b.ela | 3 + Task/A+B/Elena/a+b.elena | 11 + Task/A+B/Euler-Math-Toolbox/a+b.euler | 7 + Task/A+B/Euphoria/a+b.euphoria | 12 + Task/Abstract-type/C++/abstract-type.cpp | 7 + Task/Abstract-type/C-sharp/abstract-type.cs | 9 + .../Common-Lisp/abstract-type-1.lisp | 13 + .../Common-Lisp/abstract-type-2.lisp | 10 + .../Common-Lisp/abstract-type-3.lisp | 11 + Task/Abstract-type/D/abstract-type.d | 27 + .../Delphi/abstract-type-1.delphi | 3 + .../Delphi/abstract-type-2.delphi | 13 + Task/Abstract-type/E/abstract-type-1.e | 3 + Task/Abstract-type/E/abstract-type-2.e | 9 + .../C++/accumulator-factory-1.cpp | 57 ++ .../C++/accumulator-factory-2.cpp | 17 + .../Clay/accumulator-factory-1.clay | 13 + .../Clay/accumulator-factory-2.clay | 2 + .../Clay/accumulator-factory-3.clay | 6 + .../Common-Lisp/accumulator-factory-1.lisp | 3 + .../Common-Lisp/accumulator-factory-2.lisp | 4 + .../D/accumulator-factory.d | 11 + .../E/accumulator-factory.e | 3 + .../Elena/accumulator-factory.elena | 17 + .../C++/ackermann-function.cpp | 18 + .../C-sharp/ackermann-function.cs | 32 + .../CLIPS/ackermann-function-1.clips | 10 + .../CLIPS/ackermann-function-2.clips | 68 ++ .../Clay/ackermann-function.clay | 8 + .../Common-Lisp/ackermann-function-1.lisp | 4 + .../Common-Lisp/ackermann-function-2.lisp | 10 + .../Coq/ackermann-function.coq | 10 + .../D/ackermann-function-1.d | 11 + .../D/ackermann-function-2.d | 50 ++ .../DWScript/ackermann-function.dwscript | 8 + .../Dart/ackermann-function.dart | 13 + .../Delphi/ackermann-function.delphi | 9 + .../Ackermann-function/E/ackermann-function.e | 5 + .../Ela/ackermann-function.ela | 3 + .../Elena/ackermann-function.elena | 33 + .../ackermann-function.euler | 16 + .../Euphoria/ackermann-function.euphoria | 16 + Task/Active-object/E/active-object.e | 51 ++ ...able-to-a-class-instance-at-runtime-1.lisp | 5 + ...able-to-a-class-instance-at-runtime-2.lisp | 12 + ...ariable-to-a-class-instance-at-runtime-1.d | 31 + ...ariable-to-a-class-instance-at-runtime-2.d | 13 + ...iable-to-a-class-instance-at-runtime.elena | 27 + .../C-sharp/address-of-a-variable.cs | 5 + .../COBOL/address-of-a-variable-1.cobol | 7 + .../COBOL/address-of-a-variable-2.cobol | 12 + .../Common-Lisp/address-of-a-variable-1.lisp | 16 + .../Common-Lisp/address-of-a-variable-2.lisp | 27 + .../D/address-of-a-variable-1.d | 2 + .../D/address-of-a-variable-2.d | 1 + .../D/address-of-a-variable-3.d | 7 + Task/Align-columns/C-sharp/align-columns.cs | 74 ++ .../Common-Lisp/align-columns.lisp | 48 ++ Task/Align-columns/D/align-columns.d | 23 + .../Align-columns/Delphi/align-columns.delphi | 56 ++ Task/Align-columns/E/align-columns-1.e | 29 + Task/Align-columns/E/align-columns-2.e | 30 + .../Euphoria/align-columns.euphoria | 61 ++ .../anagrams-deranged-anagrams.lisp | 20 + .../D/anagrams-deranged-anagrams.d | 28 + Task/Anagrams/C++/anagrams.cpp | 35 + Task/Anagrams/Common-Lisp/anagrams-1.lisp | 23 + Task/Anagrams/Common-Lisp/anagrams-2.lisp | 3 + Task/Anagrams/Common-Lisp/anagrams-3.lisp | 19 + Task/Anagrams/Common-Lisp/anagrams-4.lisp | 9 + Task/Anagrams/Common-Lisp/anagrams-5.lisp | 13 + Task/Anagrams/Common-Lisp/anagrams-6.lisp | 10 + Task/Anagrams/E/anagrams.e | 22 + Task/Anagrams/Elena/anagrams.elena | 47 ++ Task/Anagrams/Euphoria/anagrams.euphoria | 49 ++ .../C++/animate-a-pendulum-1.cpp | 66 ++ .../C++/animate-a-pendulum-2.cpp | 112 +++ .../C-sharp/animate-a-pendulum.cs | 54 ++ .../Animate-a-pendulum/E/animate-a-pendulum.e | 88 ++ .../Euphoria/animate-a-pendulum.euphoria | 57 ++ Task/Animation/C-sharp/animation.cs | 56 ++ Task/Animation/Common-Lisp/animation.lisp | 33 + Task/Animation/D/animation.d | 24 + Task/Animation/E/animation-1.e | 38 + Task/Animation/E/animation-2.e | 17 + .../C++/anonymous-recursion-1.cpp | 27 + .../C++/anonymous-recursion-2.cpp | 16 + .../Common-Lisp/anonymous-recursion-1.lisp | 9 + .../Common-Lisp/anonymous-recursion-2.lisp | 8 + .../Common-Lisp/anonymous-recursion-3.lisp | 5 + .../Common-Lisp/anonymous-recursion-4.lisp | 64 ++ .../D/anonymous-recursion-1.d | 9 + .../D/anonymous-recursion-2.d | 18 + .../Deja-Vu/anonymous-recursion-1.djv | 18 + .../Deja-Vu/anonymous-recursion-2.djv | 15 + .../Ela/anonymous-recursion-1.ela | 2 + .../Ela/anonymous-recursion-2.ela | 1 + .../Elena/anonymous-recursion.elena | 21 + .../C++/apply-a-callback-to-an-array-1.cpp | 16 + .../C++/apply-a-callback-to-an-array-2.cpp | 22 + .../C++/apply-a-callback-to-an-array-3.cpp | 24 + .../C++/apply-a-callback-to-an-array-4.cpp | 6 + .../C++/apply-a-callback-to-an-array-5.cpp | 15 + .../C-sharp/apply-a-callback-to-an-array-1.cs | 34 + .../C-sharp/apply-a-callback-to-an-array-2.cs | 2 + .../apply-a-callback-to-an-array-1.clean | 4 + .../apply-a-callback-to-an-array-2.clean | 1 + .../apply-a-callback-to-an-array-3.clean | 2 + .../apply-a-callback-to-an-array-1.lisp | 1 + .../apply-a-callback-to-an-array-2.lisp | 2 + .../apply-a-callback-to-an-array-3.lisp | 2 + .../D/apply-a-callback-to-an-array.d | 7 + .../apply-a-callback-to-an-array.delphi | 17 + .../E/apply-a-callback-to-an-array-1.e | 4 + .../E/apply-a-callback-to-an-array-2.e | 4 + .../E/apply-a-callback-to-an-array-3.e | 8 + .../EGL/apply-a-callback-to-an-array.egl | 20 + .../Efene/apply-a-callback-to-an-array.efene | 32 + .../Elena/apply-a-callback-to-an-array.elena | 11 + .../apply-a-callback-to-an-array.euphoria | 18 + ...arbitrary-precision-integers-(included).cs | 23 + ...bitrary-precision-integers-(included).lisp | 3 + .../arbitrary-precision-integers-(included).d | 6 + .../arbitrary-precision-integers-(included).e | 10 + .../arbitrary-precision-integers-(included).l | 9 + .../C++/arena-storage-pool-1.cpp | 1 + .../C++/arena-storage-pool-2.cpp | 104 +++ .../C++/arithmetic-complex.cpp | 19 + .../C-sharp/arithmetic-complex-1.cs | 17 + .../C-sharp/arithmetic-complex-2.cs | 205 +++++ .../Common-Lisp/arithmetic-complex-1.lisp | 5 + .../Common-Lisp/arithmetic-complex-2.lisp | 17 + .../Common-Lisp/arithmetic-complex-3.lisp | 8 + .../Arithmetic-Complex/D/arithmetic-complex.d | 11 + .../arithmetic-complex.euler | 13 + .../Euphoria/arithmetic-complex.euphoria | 58 ++ .../C++/arithmetic-integer.cpp | 12 + .../Chef/arithmetic-integer.chef | 36 + .../Common-Lisp/arithmetic-integer.lisp | 6 + .../D/arithmetic-integer-1.d | 17 + .../D/arithmetic-integer-2.d | 13 + .../DWScript/arithmetic-integer.dwscript | 9 + .../Delphi/arithmetic-integer.delphi | 19 + .../Arithmetic-Integer/E/arithmetic-integer.e | 8 + .../Efene/arithmetic-integer.efene | 15 + .../Elena/arithmetic-integer.elena | 14 + .../Euphoria/arithmetic-integer.euphoria | 13 + .../C++/arithmetic-rational.cpp | 27 + .../Common-Lisp/arithmetic-rational.lisp | 7 + .../D/arithmetic-rational.d | 170 ++++ .../Elisa/arithmetic-rational-1.elisa | 61 ++ .../Elisa/arithmetic-rational-2.elisa | 14 + .../C++/arithmetic-evaluation.cpp | 116 +++ .../Common-Lisp/arithmetic-evaluation.lisp | 86 ++ .../D/arithmetic-evaluation.d | 219 +++++ .../E/arithmetic-evaluation-1.e | 18 + .../E/arithmetic-evaluation-2.e | 8 + .../Elena/arithmetic-evaluation-1.elena | 285 +++++++ .../Elena/arithmetic-evaluation-2.elena | 30 + .../C++/arithmetic-geometric-mean.cpp | 34 + .../C-sharp/arithmetic-geometric-mean.cs | 78 ++ .../arithmetic-geometric-mean.lisp | 5 + .../D/arithmetic-geometric-mean.d | 15 + .../C++/array-concatenation.cpp | 14 + .../C-sharp/array-concatenation-1.cs | 22 + .../C-sharp/array-concatenation-2.cs | 12 + .../Common-Lisp/array-concatenation.lisp | 2 + .../D/array-concatenation.d | 8 + .../Delphi/array-concatenation.delphi | 38 + .../E/array-concatenation.e | 2 + .../EGL/array-concatenation.egl | 13 + .../Efene/array-concatenation.efene | 11 + .../Elena/array-concatenation.elena | 11 + .../Euphoria/array-concatenation.euphoria | 5 + Task/Arrays/C++/arrays-1.cpp | 4 + Task/Arrays/C++/arrays-2.cpp | 4 + Task/Arrays/C++/arrays-3.cpp | 6 + Task/Arrays/C++/arrays-4.cpp | 7 + Task/Arrays/C++/arrays-5.cpp | 8 + Task/Arrays/C++/arrays-6.cpp | 25 + Task/Arrays/C-sharp/arrays-1.cs | 1 + Task/Arrays/C-sharp/arrays-10.cs | 2 + Task/Arrays/C-sharp/arrays-11.cs | 2 + Task/Arrays/C-sharp/arrays-12.cs | 2 + Task/Arrays/C-sharp/arrays-13.cs | 2 + Task/Arrays/C-sharp/arrays-2.cs | 1 + Task/Arrays/C-sharp/arrays-3.cs | 1 + Task/Arrays/C-sharp/arrays-4.cs | 1 + Task/Arrays/C-sharp/arrays-5.cs | 1 + Task/Arrays/C-sharp/arrays-6.cs | 1 + Task/Arrays/C-sharp/arrays-7.cs | 6 + Task/Arrays/C-sharp/arrays-8.cs | 11 + Task/Arrays/C-sharp/arrays-9.cs | 2 + Task/Arrays/Common-Lisp/arrays-1.lisp | 4 + Task/Arrays/Common-Lisp/arrays-2.lisp | 5 + Task/Arrays/Common-Lisp/arrays-3.lisp | 1 + Task/Arrays/Common-Lisp/arrays-4.lisp | 1 + Task/Arrays/Common-Lisp/arrays-5.lisp | 4 + Task/Arrays/Component-Pascal/arrays.pascal | 27 + Task/Arrays/D/arrays.d | 41 + Task/Arrays/DWScript/arrays.dwscript | 14 + Task/Arrays/Dao/arrays.dao | 10 + Task/Arrays/Delphi/arrays.delphi | 30 + Task/Arrays/E/arrays-1.e | 11 + Task/Arrays/E/arrays-2.e | 8 + Task/Arrays/E/arrays-3.e | 12 + Task/Arrays/E/arrays-4.e | 1 + Task/Arrays/EGL/arrays.egl | 3 + Task/Arrays/Elena/arrays-1.elena | 3 + Task/Arrays/Elena/arrays-2.elena | 4 + Task/Arrays/Euphoria/arrays.euphoria | 29 + Task/Assertions/C++/assertions.cpp | 10 + Task/Assertions/C-sharp/assertions.cs | 3 + Task/Assertions/Common-Lisp/assertions.lisp | 2 + .../Component-Pascal/assertions.pascal | 11 + Task/Assertions/D/assertions.d | 5 + .../Assertions/DWScript/assertions-1.dwscript | 1 + .../Assertions/DWScript/assertions-2.dwscript | 8 + Task/Assertions/Dart/assertions.dart | 7 + Task/Assertions/Delphi/assertions-1.delphi | 1 + Task/Assertions/Delphi/assertions-2.delphi | 1 + Task/Assertions/Delphi/assertions-3.delphi | 21 + Task/Assertions/E/assertions.e | 5 + Task/Assertions/Emacs-Lisp/assertions.l | 3 + Task/Assertions/Euphoria/assertions.euphoria | 7 + .../C++/associative-array-creation-1.cpp | 1 + .../C++/associative-array-creation-10.cpp | 26 + .../C++/associative-array-creation-2.cpp | 1 + .../C++/associative-array-creation-3.cpp | 1 + .../C++/associative-array-creation-4.cpp | 1 + .../C++/associative-array-creation-5.cpp | 3 + .../C++/associative-array-creation-6.cpp | 1 + .../C++/associative-array-creation-7.cpp | 1 + .../C++/associative-array-creation-8.cpp | 1 + .../C++/associative-array-creation-9.cpp | 7 + .../C-sharp/associative-array-creation-1.cs | 2 + .../C-sharp/associative-array-creation-2.cs | 2 + .../C-sharp/associative-array-creation-3.cs | 1 + .../ColdFusion/associative-array-creation.cfm | 4 + .../associative-array-creation.lisp | 13 + .../D/associative-array-creation.d | 4 + .../Dao/associative-array-creation.dao | 5 + .../Delphi/associative-array-creation.delphi | 19 + .../E/associative-array-creation.e | 5 + .../Elena/associative-array-creation.elena | 8 + .../C++/associative-array-iteration-1.cpp | 12 + .../C++/associative-array-iteration-2.cpp | 21 + .../C-sharp/associative-array-iteration.cs | 33 + .../associative-array-iteration-1.lisp | 8 + .../associative-array-iteration-2.lisp | 2 + .../associative-array-iteration-3.lisp | 3 + .../associative-array-iteration-4.lisp | 2 + .../associative-array-iteration-5.lisp | 6 + .../D/associative-array-iteration.d | 40 + .../Dao/associative-array-iteration.dao | 3 + .../Delphi/associative-array-iteration.delphi | 29 + .../E/associative-array-iteration.e | 21 + .../Elena/associative-array-iteration.elena | 26 + Task/Atomic-updates/C-sharp/atomic-updates.cs | 125 +++ Task/Atomic-updates/D/atomic-updates.d | 118 +++ Task/Atomic-updates/E/atomic-updates.e | 123 +++ .../Euphoria/atomic-updates.euphoria | 69 ++ .../D/average-loop-length.d | 44 + .../C++/averages-arithmetic-mean-1.cpp | 12 + .../C++/averages-arithmetic-mean-2.cpp | 9 + .../C++/averages-arithmetic-mean-3.cpp | 10 + .../C-sharp/averages-arithmetic-mean-1.cs | 10 + .../C-sharp/averages-arithmetic-mean-2.cs | 29 + .../Chef/averages-arithmetic-mean.chef | 31 + .../Cobra/averages-arithmetic-mean.cobra | 13 + .../averages-arithmetic-mean-1.lisp | 4 + .../averages-arithmetic-mean-2.lisp | 4 + .../D/averages-arithmetic-mean-1.d | 23 + .../D/averages-arithmetic-mean-2.d | 13 + .../D/averages-arithmetic-mean-3.d | 14 + .../Delphi/averages-arithmetic-mean.delphi | 22 + .../E/averages-arithmetic-mean.e | 9 + .../Elena/averages-arithmetic-mean.elena | 50 ++ .../Emacs-Lisp/averages-arithmetic-mean.l | 3 + .../averages-arithmetic-mean.euphoria | 16 + .../Common-Lisp/averages-mean-angle.lisp | 17 + .../D/averages-mean-angle.d | 16 + .../averages-mean-angle.euler | 16 + Task/Averages-Median/C++/averages-median.cpp | 32 + .../Common-Lisp/averages-median.lisp | 23 + Task/Averages-Median/D/averages-median.d | 17 + .../Delphi/averages-median.delphi | 23 + Task/Averages-Median/E/averages-median-1.e | 11 + Task/Averages-Median/E/averages-median-2.e | 5 + .../Elena/averages-median.elena | 27 + .../Euler-Math-Toolbox/averages-median.euler | 50 ++ .../Euphoria/averages-median.euphoria | 25 + Task/Averages-Mode/C++/averages-mode.cpp | 68 ++ Task/Averages-Mode/D/averages-mode.d | 17 + Task/Averages-Mode/E/averages-mode-1.e | 9 + Task/Averages-Mode/E/averages-mode-2.e | 2 + Task/Averages-Mode/E/averages-mode-3.e | 3 + Task/Averages-Mode/Elena/averages-mode.elena | 44 + .../Euphoria/averages-mode.euphoria | 39 + .../C++/averages-pythagorean-means.cpp | 25 + .../averages-pythagorean-means.lisp | 23 + .../D/averages-pythagorean-means.d | 19 + .../Delphi/averages-pythagorean-means.delphi | 50 ++ .../E/averages-pythagorean-means-1.e | 15 + .../E/averages-pythagorean-means-2.e | 8 + .../averages-pythagorean-means-1.euler | 7 + .../averages-pythagorean-means-2.euler | 1 + .../averages-pythagorean-means.euphoria | 52 ++ .../C++/averages-root-mean-square.cpp | 13 + .../averages-root-mean-square.lisp | 5 + .../D/averages-root-mean-square.d | 9 + .../Delphi/averages-root-mean-square.delphi | 22 + .../E/averages-root-mean-square-1.e | 13 + .../E/averages-root-mean-square-2.e | 2 + .../averages-root-mean-square.euphoria | 14 + .../C++/averages-simple-moving-average.cpp | 101 +++ .../averages-simple-moving-average.lisp | 11 + .../D/averages-simple-moving-average-1.d | 25 + .../D/averages-simple-moving-average-2.d | 24 + .../E/averages-simple-moving-average-1.e | 22 + .../E/averages-simple-moving-average-2.e | 33 + .../averages-simple-moving-average.elena | 54 ++ .../averages-simple-moving-average-1.euler | 3 + .../averages-simple-moving-average-2.euler | 30 + .../C++/balanced-brackets.cpp | 33 + .../Common-Lisp/balanced-brackets.lisp | 27 + .../Balanced-brackets/D/balanced-brackets-1.d | 10 + .../Balanced-brackets/D/balanced-brackets-2.d | 20 + .../Balanced-brackets/D/balanced-brackets-3.d | 20 + .../Delphi/balanced-brackets.delphi | 31 + .../Elena/balanced-brackets.elena | 32 + .../Euphoria/balanced-brackets.euphoria | 45 + .../Common-Lisp/balanced-ternary-1.lisp | 93 +++ .../Common-Lisp/balanced-ternary-2.lisp | 4 + Task/Balanced-ternary/D/balanced-ternary.d | 142 ++++ .../Common-Lisp/best-shuffle-1.lisp | 23 + .../Common-Lisp/best-shuffle-2.lisp | 46 ++ Task/Best-shuffle/D/best-shuffle-1.d | 40 + Task/Best-shuffle/D/best-shuffle-2.d | 103 +++ Task/Binary-search/C++/binary-search-1.cpp | 28 + Task/Binary-search/C++/binary-search-2.cpp | 15 + Task/Binary-search/C++/binary-search-3.cpp | 1 + Task/Binary-search/C++/binary-search-4.cpp | 1 + Task/Binary-search/C++/binary-search-5.cpp | 1 + Task/Binary-search/C++/binary-search-6.cpp | 1 + Task/Binary-search/C++/binary-search-7.cpp | 1 + .../Common-Lisp/binary-search-1.lisp | 14 + .../Common-Lisp/binary-search-2.lisp | 12 + Task/Binary-search/D/binary-search.d | 36 + Task/Binary-search/E/binary-search.e | 14 + .../Euphoria/binary-search-1.euphoria | 16 + .../Euphoria/binary-search-2.euphoria | 17 + .../Common-Lisp/binary-strings-1.lisp | 2 + .../Common-Lisp/binary-strings-2.lisp | 1 + .../Common-Lisp/binary-strings-3.lisp | 1 + .../Common-Lisp/binary-strings-4.lisp | 1 + .../Common-Lisp/binary-strings-5.lisp | 4 + .../Common-Lisp/binary-strings-6.lisp | 1 + .../Common-Lisp/binary-strings-7.lisp | 2 + Task/Binary-strings/D/binary-strings.d | 45 + Task/Binary-strings/E/binary-strings-1.e | 2 + Task/Binary-strings/E/binary-strings-2.e | 8 + Task/Binary-strings/E/binary-strings-3.e | 2 + Task/Binary-strings/E/binary-strings-4.e | 5 + Task/Binary-strings/E/binary-strings-5.e | 3 + Task/Binary-strings/E/binary-strings-6.e | 6 + Task/Binary-strings/E/binary-strings-7.e | 3 + Task/Binary-strings/E/binary-strings-8.e | 3 + .../D/bitmap-b-zier-curves-cubic.d | 34 + .../D/bitmap-b-zier-curves-quadratic.d | 29 + .../C++/bitmap-bresenhams-line-algorithm.cpp | 44 + .../bitmap-bresenhams-line-algorithm.lisp | 28 + .../D/bitmap-bresenhams-line-algorithm.d | 52 ++ .../E/bitmap-bresenhams-line-algorithm-1.e | 30 + .../E/bitmap-bresenhams-line-algorithm-2.e | 3 + .../bitmap-bresenhams-line-algorithm.euphoria | 115 +++ Task/Bitmap-Flood-fill/D/bitmap-flood-fill.d | 31 + .../Bitmap-Flood-fill/E/bitmap-flood-fill-1.e | 69 ++ .../Bitmap-Flood-fill/E/bitmap-flood-fill-2.e | 11 + Task/Bitmap-Histogram/D/bitmap-histogram.d | 47 ++ .../bitmap-midpoint-circle-algorithm-1.lisp | 29 + .../bitmap-midpoint-circle-algorithm-2.lisp | 5 + .../D/bitmap-midpoint-circle-algorithm.d | 40 + .../Common-Lisp/bitmap-read-a-ppm-file-1.lisp | 71 ++ .../Common-Lisp/bitmap-read-a-ppm-file-2.lisp | 1 + .../E/bitmap-read-a-ppm-file-1.e | 55 ++ .../E/bitmap-read-a-ppm-file-2.e | 6 + .../bitmap-read-a-ppm-file-1.euphoria | 41 + .../bitmap-read-a-ppm-file-2.euphoria | 5 + .../Common-Lisp/bitmap-write-a-ppm-file.lisp | 28 + .../bitmap-write-a-ppm-file-1.euphoria | 15 + .../bitmap-write-a-ppm-file-2.euphoria | 14 + Task/Bitmap/C++/bitmap.cpp | 20 + Task/Bitmap/Common-Lisp/bitmap-1.lisp | 7 + Task/Bitmap/Common-Lisp/bitmap-2.lisp | 69 ++ Task/Bitmap/Common-Lisp/bitmap-3.lisp | 6 + Task/Bitmap/D/bitmap.d | 144 ++++ Task/Bitmap/E/bitmap-1.e | 97 +++ Task/Bitmap/E/bitmap-2.e | 29 + Task/Bitmap/Euphoria/bitmap.euphoria | 23 + Task/Bitwise-IO/D/bitwise-io.d | 131 +++ .../C++/bitwise-operations.cpp | 14 + .../Common-Lisp/bitwise-operations.lisp | 9 + .../Bitwise-operations/D/bitwise-operations.d | 23 + .../DWScript/bitwise-operations.dwscript | 6 + .../Delphi/bitwise-operations.delphi | 14 + .../Bitwise-operations/E/bitwise-operations.e | 10 + .../Elena/bitwise-operations.elena | 20 + .../Boolean-values/CMake/boolean-values.cmake | 8 + .../Boolean-values/Clean/boolean-values.clean | 1 + Task/Boolean-values/E/boolean-values-1.e | 8 + Task/Boolean-values/E/boolean-values-2.e | 7 + Task/Boolean-values/EGL/boolean-values.egl | 20 + Task/Box-the-compass/C++/box-the-compass.cpp | 59 ++ Task/Box-the-compass/D/box-the-compass.d | 34 + .../Euphoria/box-the-compass.euphoria | 23 + .../C++/break-oo-privacy-1.cpp | 67 ++ .../C++/break-oo-privacy-2.cpp | 6 + .../C++/break-oo-privacy-3.cpp | 66 ++ .../C-sharp/break-oo-privacy-1.cs | 18 + .../C-sharp/break-oo-privacy-2.cs | 1 + .../Common-Lisp/break-oo-privacy.lisp | 44 + .../D/bulls-and-cows-player.d | 28 + .../Euphoria/bulls-and-cows-player.euphoria | 84 ++ Task/Bulls-and-cows/C++/bulls-and-cows.cpp | 78 ++ .../Common-Lisp/bulls-and-cows.lisp | 42 + Task/Bulls-and-cows/D/bulls-and-cows.d | 36 + Task/Bulls-and-cows/E/bulls-and-cows-1.e | 82 ++ Task/Bulls-and-cows/E/bulls-and-cows-2.e | 15 + .../Bulls-and-cows/Elena/bulls-and-cows.elena | 85 ++ .../Euphoria/bulls-and-cows.euphoria | 103 +++ Task/CRC-32/0DESCRIPTION | 3 + Task/CRC-32/1META.yaml | 2 + Task/CRC-32/Ada/crc-32.ada | 14 + Task/CRC-32/C/crc-32-1.c | 11 + Task/CRC-32/C/crc-32-2.c | 47 ++ Task/CRC-32/Common-Lisp/crc-32.lisp | 13 + Task/CRC-32/D/crc-32.d | 6 + Task/CRC-32/Erlang/crc-32-1.erl | 4 + Task/CRC-32/Erlang/crc-32-2.erl | 1 + Task/CRC-32/Go/crc-32-1.go | 12 + Task/CRC-32/Go/crc-32-2.go | 31 + Task/CRC-32/Java/crc-32.java | 10 + Task/CRC-32/PHP/crc-32.php | 1 + Task/CRC-32/Perl/crc-32.pl | 9 + Task/CRC-32/Python/crc-32-1.py | 3 + Task/CRC-32/Python/crc-32-2.py | 3 + Task/CRC-32/REXX/crc-32.rexx | 37 + Task/CRC-32/Ruby/crc-32-1.rb | 3 + Task/CRC-32/Ruby/crc-32-2.rb | 75 ++ Task/CRC-32/Smalltalk/crc-32.st | 1 + Task/CRC-32/Tcl/crc-32-1.tcl | 4 + Task/CRC-32/Tcl/crc-32-2.tcl | 2 + Task/CSV-to-HTML-translation/0DESCRIPTION | 18 + .../ALGOL-68/csv-to-html-translation-1.alg | 69 ++ .../ALGOL-68/csv-to-html-translation-2.alg | 19 + .../AWK/csv-to-html-translation-1.awk | 23 + .../AWK/csv-to-html-translation-2.awk | 26 + .../AWK/csv-to-html-translation-3.awk | 26 + .../Ada/csv-to-html-translation-1.ada | 40 + .../Ada/csv-to-html-translation-2.ada | 8 + .../Ada/csv-to-html-translation-3.ada | 26 + .../AutoHotkey/csv-to-html-translation.ahk | 25 + .../AutoIt/csv-to-html-translation.autoit | 28 + .../BBC-BASIC/csv-to-html-translation.bbc | 42 + .../C++/csv-to-html-translation-1.cpp | 32 + .../C++/csv-to-html-translation-2.cpp | 8 + .../C-sharp/csv-to-html-translation-1.cs | 32 + .../C-sharp/csv-to-html-translation-2.cs | 1 + .../C-sharp/csv-to-html-translation-3.cs | 54 ++ .../C-sharp/csv-to-html-translation-4.cs | 26 + .../C/csv-to-html-translation-1.c | 29 + .../C/csv-to-html-translation-2.c | 8 + .../csv-to-html-translation-1.coffee | 39 + .../csv-to-html-translation-2.coffee | 18 + .../csv-to-html-translation-1.lisp | 53 ++ .../csv-to-html-translation-2.lisp | 8 + .../D/csv-to-html-translation-1.d | 34 + .../D/csv-to-html-translation-2.d | 19 + .../Delphi/csv-to-html-translation-1.delphi | 173 ++++ .../Delphi/csv-to-html-translation-2.delphi | 29 + .../Delphi/csv-to-html-translation-3.delphi | 29 + .../Euphoria/csv-to-html-translation.euphoria | 20 + .../Go/csv-to-html-translation-1.go | 36 + .../Go/csv-to-html-translation-2.go | 56 ++ .../Go/csv-to-html-translation-3.go | 12 + .../Go/csv-to-html-translation-4.go | 8 + .../Haskell/csv-to-html-translation-1.hs | 26 + .../Haskell/csv-to-html-translation-2.hs | 11 + .../Haskell/csv-to-html-translation-3.hs | 26 + .../Java/csv-to-html-translation-1.java | 86 ++ .../Java/csv-to-html-translation-2.java | 18 + .../Java/csv-to-html-translation-3.java | 18 + .../JavaScript/csv-to-html-translation-1.js | 30 + .../JavaScript/csv-to-html-translation-2.js | 9 + .../JavaScript/csv-to-html-translation-3.js | 20 + .../Lua/csv-to-html-translation-1.lua | 28 + .../Lua/csv-to-html-translation-2.lua | 8 + .../MATLAB/csv-to-html-translation-1.m | 15 + .../MATLAB/csv-to-html-translation-2.m | 1 + .../MATLAB/csv-to-html-translation-3.m | 25 + .../Perl/csv-to-html-translation-1.pl | 15 + .../Perl/csv-to-html-translation-2.pl | 8 + .../PicoLisp/csv-to-html-translation-1.l | 8 + .../PicoLisp/csv-to-html-translation-2.l | 8 + .../PicoLisp/csv-to-html-translation-3.l | 9 + .../PicoLisp/csv-to-html-translation-4.l | 7 + .../Prolog/csv-to-html-translation-1.pro | 52 ++ .../Prolog/csv-to-html-translation-2.pro | 20 + .../Prolog/csv-to-html-translation-3.pro | 90 ++ .../Prolog/csv-to-html-translation-4.pro | 24 + .../Python/csv-to-html-translation-1.py | 28 + .../Python/csv-to-html-translation-2.py | 8 + .../Python/csv-to-html-translation-3.py | 30 + .../Python/csv-to-html-translation-4.py | 8 + .../REXX/csv-to-html-translation-1.rexx | 38 + .../REXX/csv-to-html-translation-2.rexx | 26 + .../Racket/csv-to-html-translation-1.rkt | 28 + .../Racket/csv-to-html-translation-2.rkt | 7 + .../Ruby/csv-to-html-translation-1.rb | 17 + .../Ruby/csv-to-html-translation-2.rb | 8 + .../Scala/csv-to-html-translation-1.scala | 35 + .../Scala/csv-to-html-translation-2.scala | 13 + .../Tcl/csv-to-html-translation-1.tcl | 24 + .../Tcl/csv-to-html-translation-2.tcl | 45 + .../Tcl/csv-to-html-translation-3.tcl | 8 + Task/Caesar-cipher/C++/caesar-cipher.cpp | 45 + .../Common-Lisp/caesar-cipher.lisp | 23 + Task/Caesar-cipher/D/caesar-cipher-1.d | 21 + Task/Caesar-cipher/D/caesar-cipher-2.d | 20 + Task/Caesar-cipher/Dart/caesar-cipher.dart | 64 ++ Task/Caesar-cipher/Elena/caesar-cipher.elena | 59 ++ .../Euphoria/caesar-cipher.euphoria | 54 ++ .../0DESCRIPTION | 22 + Task/Calendar-for-real-programmers/1META.yaml | 2 + .../calendar-for-real-programmers.alg | 108 +++ .../Ada/calendar-for-real-programmers.ada | 21 + .../calendar-for-real-programmers.bbc | 47 ++ .../PHP/calendar-for-real-programmers.php | 20 + .../Perl/calendar-for-real-programmers-1.pl | 44 + .../Perl/calendar-for-real-programmers-2.pl | 1 + .../PicoLisp/calendar-for-real-programmers.l | 14 + .../REXX/calendar-for-real-programmers.rexx | 170 ++++ .../Ruby/calendar-for-real-programmers-1.rb | 26 + .../Ruby/calendar-for-real-programmers-2.rb | 84 ++ .../Tcl/calendar-for-real-programmers.tcl | 48 ++ Task/Calendar/D/calendar.d | 41 + .../0DESCRIPTION | 11 + .../1META.yaml | 2 + .../Ada/call-a-foreign-language-function.ada | 15 + .../call-a-foreign-language-function-1.aikido | 13 + .../call-a-foreign-language-function-2.aikido | 2 + .../call-a-foreign-language-function-3.aikido | 14 + .../call-a-foreign-language-function.ahk | 4 + .../call-a-foreign-language-function.bbc | 7 + .../call-a-foreign-language-function-1.cpp | 2 + .../call-a-foreign-language-function-2.cpp | 42 + .../call-a-foreign-language-function-1.cmake | 25 + .../call-a-foreign-language-function-2.cmake | 8 + .../call-a-foreign-language-function-3.cmake | 55 ++ .../call-a-foreign-language-function.lisp | 7 + .../D/call-a-foreign-language-function.d | 36 + .../call-a-foreign-language-function-1.delphi | 1 + .../call-a-foreign-language-function-2.delphi | 1 + .../call-a-foreign-language-function.fth | 23 + .../Go/call-a-foreign-language-function.go | 28 + .../call-a-foreign-language-function-1.hs | 15 + .../call-a-foreign-language-function-2.hs | 18 + .../call-a-foreign-language-function-3.hs | 23 + .../call-a-foreign-language-function-1.java | 12 + .../call-a-foreign-language-function-2.java | 21 + .../call-a-foreign-language-function-3.java | 43 + .../call-a-foreign-language-function-1.pl | 11 + .../call-a-foreign-language-function-2.pl | 8 + .../call-a-foreign-language-function-1.l | 19 + .../call-a-foreign-language-function-2.l | 17 + .../call-a-foreign-language-function.py | 4 + .../call-a-foreign-language-function.rkt | 41 + .../call-a-foreign-language-function-1.rb | 14 + .../call-a-foreign-language-function-2.rb | 19 + .../call-a-foreign-language-function-3.rb | 33 + .../Tcl/call-a-foreign-language-function.tcl | 8 + .../0DESCRIPTION | 6 + .../1META.yaml | 2 + .../call-a-function-in-a-shared-library-1.ada | 45 + .../call-a-function-in-a-shared-library-2.ada | 49 ++ .../call-a-function-in-a-shared-library-1.ahk | 3 + .../call-a-function-in-a-shared-library-2.ahk | 1 + .../call-a-function-in-a-shared-library.bbc | 1 + .../C/call-a-function-in-a-shared-library-1.c | 36 + .../C/call-a-function-in-a-shared-library-2.c | 8 + .../call-a-function-in-a-shared-library.lisp | 7 + .../D/call-a-function-in-a-shared-library.d | 9 + ...ll-a-function-in-a-shared-library-1.delphi | 1 + ...ll-a-function-in-a-shared-library-2.delphi | 1 + ...ll-a-function-in-a-shared-library-3.delphi | 12 + ...call-a-function-in-a-shared-library-1.java | 8 + ...call-a-function-in-a-shared-library-2.java | 15 + .../call-a-function-in-a-shared-library-1.l | 26 + .../call-a-function-in-a-shared-library-2.l | 4 + .../call-a-function-in-a-shared-library.py | 4 + .../call-a-function-in-a-shared-library.rkt | 6 + .../call-a-function-in-a-shared-library-1.rb | 11 + .../call-a-function-in-a-shared-library-2.rb | 8 + .../call-a-function-in-a-shared-library.st | 14 + .../call-a-function-in-a-shared-library.tcl | 8 + Task/Call-a-function/0DESCRIPTION | 15 + Task/Call-a-function/1META.yaml | 3 + Task/Call-a-function/AWK/call-a-function.awk | 4 + .../ActionScript/call-a-function.as | 3 + .../Call-a-function/Ada/call-a-function-1.ada | 1 + .../Call-a-function/Ada/call-a-function-2.ada | 5 + .../Call-a-function/Ada/call-a-function-3.ada | 12 + .../Call-a-function/Ada/call-a-function-4.ada | 9 + .../Call-a-function/Ada/call-a-function-5.ada | 3 + .../AutoHotkey/call-a-function.ahk | 39 + Task/Call-a-function/C/call-a-function.c | 48 ++ .../JavaScript/call-a-function-1.js | 3 + .../JavaScript/call-a-function-2.js | 1 + .../JavaScript/call-a-function-3.js | 5 + .../JavaScript/call-a-function-4.js | 4 + .../JavaScript/call-a-function-5.js | 6 + Task/Call-a-function/MATLAB/call-a-function.m | 49 ++ .../PicoLisp/call-a-function-1.l | 2 + .../PicoLisp/call-a-function-2.l | 2 + .../PicoLisp/call-a-function-3.l | 1 + .../Call-a-function/Python/call-a-function.py | 51 ++ .../Call-a-function/REXX/call-a-function.rexx | 137 +++ .../Smalltalk/call-a-function.st | 1 + .../Call-a-function/Tcl/call-a-function-1.tcl | 7 + .../Call-a-function/Tcl/call-a-function-2.tcl | 2 + Task/Call-an-object-method/0DESCRIPTION | 3 + Task/Call-an-object-method/1META.yaml | 5 + .../ActionScript/call-an-object-method.as | 5 + .../AutoHotkey/call-an-object-method.ahk | 10 + .../C++/call-an-object-method.cpp | 5 + .../D/call-an-object-method.d | 37 + .../E/call-an-object-method.e | 1 + .../Forth/call-an-object-method.fth | 40 + .../Go/call-an-object-method-1.go | 29 + .../Go/call-an-object-method-2.go | 29 + .../Go/call-an-object-method-3.go | 16 + .../Go/call-an-object-method-4.go | 23 + .../Java/call-an-object-method-1.java | 1 + .../Java/call-an-object-method-2.java | 4 + .../PHP/call-an-object-method.php | 9 + .../Perl/call-an-object-method.pl | 17 + .../PicoLisp/call-an-object-method.l | 2 + .../Python/call-an-object-method.py | 24 + .../Racket/call-an-object-method.rkt | 4 + .../Ruby/call-an-object-method.rb | 16 + .../Smalltalk/call-an-object-method-1.st | 17 + .../Smalltalk/call-an-object-method-2.st | 1 + .../Smalltalk/call-an-object-method-3.st | 2 + .../Smalltalk/call-an-object-method-4.st | 2 + .../Smalltalk/call-an-object-method-5.st | 5 + .../Tcl/call-an-object-method.tcl | 6 + Task/Canny-edge-detector/0DESCRIPTION | 8 + .../C/canny-edge-detector.c | 453 ++++++++++ .../D/canny-edge-detector.d | 201 +++++ .../Tcl/canny-edge-detector.tcl | 17 + .../0DESCRIPTION | 18 + .../Ada/carmichael-3-strong-pseudoprimes.ada | 41 + .../D/carmichael-3-strong-pseudoprimes.d | 23 + .../carmichael-3-strong-pseudoprimes.hs | 18 + .../carmichael-3-strong-pseudoprimes.py | 71 ++ .../carmichael-3-strong-pseudoprimes-1.rexx | 37 + .../carmichael-3-strong-pseudoprimes-2.rexx | 40 + .../Ruby/carmichael-3-strong-pseudoprimes.rb | 21 + .../carmichael-3-strong-pseudoprimes-1.tcl | 23 + .../carmichael-3-strong-pseudoprimes-2.tcl | 5 + .../0DESCRIPTION | 10 + .../1META.yaml | 2 + .../AWK/case-sensitivity-of-identifiers.awk | 6 + .../Ada/case-sensitivity-of-identifiers.ada | 6 + .../case-sensitivity-of-identifiers.ahk | 4 + .../case-sensitivity-of-identifiers.bbc | 4 + .../case-sensitivity-of-identifiers.brlcad | 6 + .../case-sensitivity-of-identifiers.cs | 12 + .../C/case-sensitivity-of-identifiers.c | 11 + .../case-sensitivity-of-identifiers.cobol | 21 + .../case-sensitivity-of-identifiers-1.coffee | 4 + .../case-sensitivity-of-identifiers-2.coffee | 2 + .../case-sensitivity-of-identifiers.lisp | 15 + .../D/case-sensitivity-of-identifiers.d | 10 + .../case-sensitivity-of-identifiers.dwscript | 7 + .../case-sensitivity-of-identifiers.delphi | 12 + .../case-sensitivity-of-identifiers.euphoria | 5 + .../Fortran/case-sensitivity-of-identifiers.f | 16 + .../Go/case-sensitivity-of-identifiers-1.go | 19 + .../Go/case-sensitivity-of-identifiers-2.go | 47 ++ .../case-sensitivity-of-identifiers.hs | 6 + .../Java/case-sensitivity-of-identifiers.java | 5 + .../case-sensitivity-of-identifiers.js | 4 + .../Lua/case-sensitivity-of-identifiers.lua | 5 + .../MATLAB/case-sensitivity-of-identifiers.m | 5 + .../Perl/case-sensitivity-of-identifiers.pl | 5 + .../case-sensitivity-of-identifiers.l | 2 + .../case-sensitivity-of-identifiers.pro | 5 + .../Python/case-sensitivity-of-identifiers.py | 4 + .../R/case-sensitivity-of-identifiers.r | 14 + .../REXX/case-sensitivity-of-identifiers.rexx | 22 + .../case-sensitivity-of-identifiers-1.rkt | 8 + .../case-sensitivity-of-identifiers-2.rkt | 9 + .../Ruby/case-sensitivity-of-identifiers.rb | 14 + .../Sather/case-sensitivity-of-identifiers.sa | 9 + .../case-sensitivity-of-identifiers.scala | 4 + .../Scheme/case-sensitivity-of-identifiers.ss | 15 + .../case-sensitivity-of-identifiers.st | 6 + .../Tcl/case-sensitivity-of-identifiers.tcl | 4 + .../0DESCRIPTION | 42 + .../1META.yaml | 6 + .../C/catmull-clark-subdivision-surface.c | 93 +++ .../Tcl/catmull-clark-subdivision-surface.tcl | 122 +++ Task/Character-codes/0DESCRIPTION | 1 + Task/Character-codes/1META.yaml | 5 + .../Character-codes/ABAP/character-codes.abap | 7 + .../Character-codes/ACL2/character-codes.acl2 | 2 + .../ALGOL-68/character-codes-1.alg | 4 + .../ALGOL-68/character-codes-2.alg | 4 + .../ALGOL-68/character-codes-3.alg | 1 + Task/Character-codes/AWK/character-codes.awk | 13 + .../ActionScript/character-codes.as | 2 + Task/Character-codes/Ada/character-codes.ada | 6 + .../Character-codes/Aime/character-codes.aime | 6 + .../AutoHotkey/character-codes.ahk | 2 + .../BASIC/character-codes-1.bas | 4 + .../BASIC/character-codes-2.bas | 4 + .../BBC-BASIC/character-codes.bbc | 4 + .../Befunge/character-codes.bf | 1 + Task/Character-codes/C++/character-codes.cpp | 7 + Task/Character-codes/C/character-codes.c | 7 + .../Clojure/character-codes.clj | 6 + .../CoffeeScript/character-codes.coffee | 2 + .../Common-Lisp/character-codes.lisp | 2 + Task/Character-codes/D/character-codes.d | 13 + .../DWScript/character-codes.dwscript | 2 + .../Delphi/character-codes.delphi | 19 + Task/Character-codes/E/character-codes.e | 5 + .../Elena/character-codes.elena | 8 + .../Erlang/character-codes-1.erl | 4 + .../Erlang/character-codes-2.erl | 2 + .../Euphoria/character-codes.euphoria | 2 + .../Character-codes/Forth/character-codes.fth | 3 + .../Character-codes/Fortran/character-codes.f | 2 + Task/Character-codes/Go/character-codes-1.go | 2 + Task/Character-codes/Go/character-codes-2.go | 16 + Task/Character-codes/Go/character-codes-3.go | 3 + Task/Character-codes/Go/character-codes-4.go | 3 + .../Haskell/character-codes.hs | 7 + .../Java/character-codes-1.java | 6 + .../Java/character-codes-2.java | 6 + .../JavaScript/character-codes.js | 2 + Task/Character-codes/Lua/character-codes.lua | 2 + .../MATLAB/character-codes-1.m | 1 + .../MATLAB/character-codes-2.m | 1 + .../MATLAB/character-codes-3.m | 3 + .../MATLAB/character-codes-4.m | 17 + Task/Character-codes/PHP/character-codes.php | 2 + Task/Character-codes/Perl/character-codes.pl | 2 + .../PicoLisp/character-codes.l | 10 + .../Python/character-codes-1.py | 2 + .../Python/character-codes-2.py | 2 + .../Python/character-codes-3.py | 4 + Task/Character-codes/R/character-codes.r | 2 + .../Character-codes/REXX/character-codes.rexx | 14 + .../Character-codes/Ruby/character-codes-1.rb | 6 + .../Character-codes/Ruby/character-codes-2.rb | 4 + .../Character-codes/Sather/character-codes.sa | 7 + .../Scala/character-codes-1.scala | 5 + .../Scala/character-codes-2.scala | 7 + .../Character-codes/Scheme/character-codes.ss | 2 + .../Smalltalk/character-codes.st | 2 + Task/Character-codes/Tcl/character-codes.tcl | 6 + Task/Character-matching/0DESCRIPTION | 10 + Task/Character-matching/1META.yaml | 2 + .../ALGOL-68/character-matching.alg | 18 + .../Ada/character-matching.ada | 20 + .../AutoHotkey/character-matching.ahk | 14 + .../AutoIt/character-matching.autoit | 29 + .../BASIC/character-matching.bas | 27 + .../BBC-BASIC/character-matching.bbc | 32 + .../Bracmat/character-matching.bracmat | 9 + .../C++/character-matching.cpp | 14 + .../C/character-matching-1.c | 32 + .../C/character-matching-2.c | 44 + .../Clojure/character-matching.clj | 10 + .../CoffeeScript/character-matching.coffee | 20 + .../Character-matching/D/character-matching.d | 16 + .../Delphi/character-matching.delphi | 13 + .../Character-matching/E/character-matching.e | 11 + .../Elena/character-matching.elena | 22 + .../Erlang/character-matching.erl | 28 + .../Euphoria/character-matching.euphoria | 30 + .../Forth/character-matching.fth | 5 + .../Go/character-matching.go | 30 + .../Haskell/character-matching-1.hs | 12 + .../Haskell/character-matching-2.hs | 10 + .../Java/character-matching.java | 7 + .../JavaScript/character-matching.js | 27 + .../Lua/character-matching.lua | 13 + .../MATLAB/character-matching.m | 11 + .../Perl/character-matching.pl | 8 + .../PicoLisp/character-matching.l | 24 + .../Python/character-matching.py | 7 + .../REXX/character-matching.rexx | 36 + .../Racket/character-matching.rkt | 6 + .../Ruby/character-matching.rb | 8 + .../Scala/character-matching.scala | 8 + .../Smalltalk/character-matching.st | 5 + .../Tcl/character-matching-1.tcl | 3 + .../Tcl/character-matching-2.tcl | 3 + .../Tcl/character-matching-3.tcl | 1 + .../Tcl/character-matching-4.tcl | 12 + Task/Chat-server/0DESCRIPTION | 1 + Task/Chat-server/1META.yaml | 2 + Task/Chat-server/Ada/chat-server.ada | 85 ++ Task/Chat-server/C/chat-server.c | 248 ++++++ .../CoffeeScript/chat-server.coffee | 107 +++ Task/Chat-server/Erlang/chat-server.erl | 63 ++ Task/Chat-server/Go/chat-server.go | 148 ++++ Task/Chat-server/Java/chat-server.java | 152 ++++ Task/Chat-server/JavaScript/chat-server.js | 158 ++++ Task/Chat-server/PicoLisp/chat-server.l | 28 + Task/Chat-server/Python/chat-server.py | 78 ++ Task/Chat-server/Ruby/chat-server.rb | 68 ++ Task/Chat-server/Tcl/chat-server.tcl | 61 ++ Task/Check-Machin-like-formulas/0DESCRIPTION | 30 + .../D/check-machin-like-formulas.d | 72 ++ .../Go/check-machin-like-formulas.go | 64 ++ .../Haskell/check-machin-like-formulas-1.hs | 31 + .../Haskell/check-machin-like-formulas-2.hs | 34 + .../Python/check-machin-like-formulas.py | 71 ++ .../Tcl/check-machin-like-formulas.tcl | 79 ++ .../C++/check-that-file-exists.cpp | 25 + .../Common-Lisp/check-that-file-exists-1.lisp | 11 + .../Common-Lisp/check-that-file-exists-2.lisp | 3 + .../D/check-that-file-exists.d | 18 + .../Delphi/check-that-file-exists.delphi | 28 + .../E/check-that-file-exists.e | 11 + .../Euphoria/check-that-file-exists.euphoria | 22 + .../D/checkpoint-synchronization.d | 24 + .../E/checkpoint-synchronization.e | 114 +++ Task/Cholesky-decomposition/0DESCRIPTION | 73 ++ Task/Cholesky-decomposition/1META.yaml | 2 + .../ALGOL-68/cholesky-decomposition.alg | 59 ++ .../Ada/cholesky-decomposition-1.ada | 9 + .../Ada/cholesky-decomposition-2.ada | 33 + .../Ada/cholesky-decomposition-3.ada | 45 + .../BBC-BASIC/cholesky-decomposition.bbc | 46 ++ .../C/cholesky-decomposition.c | 51 ++ .../Common-Lisp/cholesky-decomposition-1.lisp | 29 + .../Common-Lisp/cholesky-decomposition-2.lisp | 6 + .../Common-Lisp/cholesky-decomposition-3.lisp | 7 + .../Common-Lisp/cholesky-decomposition-4.lisp | 11 + .../Common-Lisp/cholesky-decomposition-5.lisp | 10 + .../Common-Lisp/cholesky-decomposition-6.lisp | 11 + .../D/cholesky-decomposition.d | 27 + .../DWScript/cholesky-decomposition.dwscript | 46 ++ .../Go/cholesky-decomposition-1.go | 105 +++ .../Go/cholesky-decomposition-2.go | 81 ++ .../Go/cholesky-decomposition-3.go | 33 + .../Haskell/cholesky-decomposition-1.hs | 29 + .../Haskell/cholesky-decomposition-2.hs | 17 + .../Java/cholesky-decomposition.java | 31 + .../MATLAB/cholesky-decomposition.m | 13 + .../PicoLisp/cholesky-decomposition-1.l | 17 + .../PicoLisp/cholesky-decomposition-2.l | 11 + .../Python/cholesky-decomposition.py | 22 + .../R/cholesky-decomposition.r | 12 + .../REXX/cholesky-decomposition.rexx | 66 ++ .../Ruby/cholesky-decomposition.rb | 38 + .../Tcl/cholesky-decomposition-1.tcl | 19 + .../Tcl/cholesky-decomposition-2.tcl | 13 + Task/Classes/C++/classes-1.cpp | 29 + Task/Classes/C++/classes-2.cpp | 8 + Task/Classes/C++/classes-3.cpp | 6 + Task/Classes/Common-Lisp/classes.lisp | 12 + Task/Classes/D/classes.d | 43 + Task/Classes/DWScript/classes.dwscript | 25 + Task/Classes/Delphi/classes.delphi | 44 + Task/Classes/E/classes-1.e | 8 + Task/Classes/E/classes-2.e | 5 + .../Common-Lisp/closest-pair-problem.lisp | 55 ++ .../D/closest-pair-problem-1.d | 68 ++ .../D/closest-pair-problem-2.d | 49 ++ Task/Collections/C++/collections-1.cpp | 8 + Task/Collections/C++/collections-2.cpp | 5 + Task/Collections/C++/collections-3.cpp | 6 + Task/Collections/C++/collections-4.cpp | 8 + Task/Collections/C++/collections-5.cpp | 6 + Task/Collections/C++/collections-6.cpp | 6 + .../Common-Lisp/collections-1.lisp | 41 + .../Common-Lisp/collections-2.lisp | 36 + Task/Collections/D/collections-1.d | 3 + Task/Collections/D/collections-2.d | 6 + Task/Collections/D/collections-3.d | 8 + Task/Collections/E/collections.e | 27 + .../C++-CLI/color-of-a-screen-pixel.cpp | 18 + .../Delphi/color-of-a-screen-pixel.delphi | 71 ++ Task/Color-quantization/0DESCRIPTION | 8 + Task/Color-quantization/1META.yaml | 2 + .../Color-quantization/C/color-quantization.c | 111 +++ .../Color-quantization/D/color-quantization.d | 165 ++++ .../Racket/color-quantization.rkt | 326 ++++++++ .../Tcl/color-quantization-1.tcl | 78 ++ .../Tcl/color-quantization-2.tcl | 5 + Task/Colour-bars-Display/0DESCRIPTION | 1 + .../AutoHotkey/colour-bars-display.ahk | 93 +++ .../BBC-BASIC/colour-bars-display.bbc | 19 + .../C++/colour-bars-display-1.cpp | 18 + .../C++/colour-bars-display-2.cpp | 27 + .../C++/colour-bars-display-3.cpp | 10 + .../Java/colour-bars-display.java | 28 + .../PHP/colour-bars-display.php | 25 + .../Perl/colour-bars-display.pl | 21 + .../PicoLisp/colour-bars-display.l | 10 + .../Python/colour-bars-display.py | 19 + .../R/colour-bars-display.r | 3 + .../Scala/colour-bars-display-1.scala | 16 + .../Scala/colour-bars-display-2.scala | 6 + .../Tcl/colour-bars-display-1.tcl | 12 + .../Tcl/colour-bars-display-2.tcl | 24 + Task/Colour-pinstripe-Display/0DESCRIPTION | 3 + Task/Colour-pinstripe-Display/1META.yaml | 2 + .../AutoHotkey/colour-pinstripe-display.ahk | 43 + .../BBC-BASIC/colour-pinstripe-display.bbc | 24 + .../Perl/colour-pinstripe-display.pl | 36 + .../PicoLisp/colour-pinstripe-display.l | 18 + .../Tcl/colour-pinstripe-display.tcl | 17 + Task/Colour-pinstripe-Printer/0DESCRIPTION | 7 + Task/Colour-pinstripe-Printer/1META.yaml | 4 + .../BBC-BASIC/colour-pinstripe-printer.bbc | 43 + .../PicoLisp/colour-pinstripe-printer.l | 25 + .../Tcl/colour-pinstripe-printer.tcl | 16 + .../0DESCRIPTION | 14 + Task/Combinations-with-repetitions/1META.yaml | 2 + .../Ada/combinations-with-repetitions.ada | 64 ++ .../combinations-with-repetitions.bbc | 27 + .../C/combinations-with-repetitions.c | 32 + .../combinations-with-repetitions-1.clj | 6 + .../combinations-with-repetitions-2.clj | 2 + .../combinations-with-repetitions-1.coffee | 12 + .../combinations-with-repetitions-2.coffee | 8 + .../D/combinations-with-repetitions.d | 86 ++ .../combinations-with-repetitions-1.erl | 9 + .../combinations-with-repetitions-2.erl | 9 + .../Fortran/combinations-with-repetitions.f | 53 ++ .../Go/combinations-with-repetitions-1.go | 23 + .../Go/combinations-with-repetitions-2.go | 58 ++ .../Go/combinations-with-repetitions-3.go | 102 +++ .../combinations-with-repetitions-1.hs | 16 + .../combinations-with-repetitions-2.hs | 2 + .../Java/combinations-with-repetitions-1.java | 26 + .../Java/combinations-with-repetitions-2.java | 48 ++ .../combinations-with-repetitions-1.js | 24 + .../combinations-with-repetitions-2.js | 8 + .../PHP/combinations-with-repetitions-1.php | 32 + .../PHP/combinations-with-repetitions-2.php | 7 + .../Perl/combinations-with-repetitions.pl | 9 + .../PicoLisp/combinations-with-repetitions.l | 10 + .../Python/combinations-with-repetitions.py | 8 + .../REXX/combinations-with-repetitions.rexx | 30 + .../Ruby/combinations-with-repetitions.rb | 3 + .../Scala/combinations-with-repetitions.scala | 13 + .../Scheme/combinations-with-repetitions.ss | 11 + .../Tcl/combinations-with-repetitions.tcl | 23 + Task/Combinations/0DESCRIPTION | 14 + Task/Combinations/1META.yaml | 2 + Task/Combinations/ALGOL-68/combinations.alg | 54 ++ Task/Combinations/AWK/combinations.awk | 37 + Task/Combinations/Ada/combinations-1.ada | 56 ++ Task/Combinations/Ada/combinations-2.ada | 1 + .../AppleScript/combinations-1.applescript | 27 + .../AppleScript/combinations-2.applescript | 1 + Task/Combinations/AutoHotkey/combinations.ahk | 26 + Task/Combinations/BBC-BASIC/combinations.bbc | 45 + .../Combinations/Bracmat/combinations.bracmat | 24 + Task/Combinations/C++/combinations.cpp | 23 + Task/Combinations/C/combinations-1.c | 29 + Task/Combinations/C/combinations-2.c | 26 + Task/Combinations/Clojure/combinations.clj | 20 + .../CoffeeScript/combinations-1.coffee | 25 + .../CoffeeScript/combinations-2.coffee | 39 + .../Common-Lisp/combinations-1.lisp | 18 + .../Common-Lisp/combinations-2.lisp | 9 + Task/Combinations/D/combinations-1.d | 15 + Task/Combinations/D/combinations-2.d | 13 + Task/Combinations/D/combinations-3.d | 126 +++ Task/Combinations/D/combinations-4.d | 100 +++ Task/Combinations/E/combinations.e | 13 + Task/Combinations/Erlang/combinations.erl | 9 + Task/Combinations/Fortran/combinations-1.f | 89 ++ Task/Combinations/Fortran/combinations-2.f | 32 + Task/Combinations/Fortran/combinations-3.f | 10 + Task/Combinations/Go/combinations.go | 29 + Task/Combinations/Haskell/combinations-1.hs | 4 + Task/Combinations/Haskell/combinations-2.hs | 5 + Task/Combinations/Haskell/combinations-3.hs | 1 + Task/Combinations/Haskell/combinations-4.hs | 1 + Task/Combinations/Haskell/combinations-5.hs | 2 + Task/Combinations/Haskell/combinations-6.hs | 1 + Task/Combinations/Java/combinations.java | 30 + .../Combinations/JavaScript/combinations-1.js | 18 + .../Combinations/JavaScript/combinations-2.js | 25 + Task/Combinations/Lua/combinations.lua | 45 + Task/Combinations/MATLAB/combinations.m | 14 + Task/Combinations/Perl/combinations.pl | 4 + Task/Combinations/PicoLisp/combinations.l | 12 + Task/Combinations/Prolog/combinations-1.pro | 7 + Task/Combinations/Prolog/combinations-2.pro | 12 + Task/Combinations/Prolog/combinations-3.pro | 10 + Task/Combinations/Prolog/combinations-4.pro | 3 + Task/Combinations/Python/combinations-1.py | 3 + Task/Combinations/Python/combinations-2.py | 6 + Task/Combinations/Python/combinations-3.py | 2 + Task/Combinations/Python/combinations-4.py | 6 + Task/Combinations/R/combinations-1.r | 1 + Task/Combinations/R/combinations-2.r | 2 + Task/Combinations/REXX/combinations.rexx | 27 + Task/Combinations/Ruby/combinations.rb | 5 + Task/Combinations/Scala/combinations.scala | 8 + Task/Combinations/Scheme/combinations.ss | 8 + Task/Combinations/Smalltalk/combinations.st | 15 + Task/Combinations/Tcl/combinations.tcl | 21 + Task/Command-line-arguments/0DESCRIPTION | 9 + .../ALGOL-68/command-line-arguments.alg | 5 + .../AWK/command-line-arguments.awk | 8 + .../Ada/command-line-arguments-1.ada | 14 + .../Ada/command-line-arguments-2.ada | 12 + .../Aikido/command-line-arguments.aikido | 3 + .../command-line-arguments.applescript | 5 + .../AutoHotkey/command-line-arguments.ahk | 6 + .../BASIC/command-line-arguments-1.bas | 1 + .../BASIC/command-line-arguments-2.bas | 14 + .../BBC-BASIC/command-line-arguments.bbc | 1 + .../Batch-File/command-line-arguments-1.bat | 15 + .../Batch-File/command-line-arguments-2.bat | 23 + .../Batch-File/command-line-arguments-3.bat | 8 + .../Bracmat/command-line-arguments.bracmat | 1 + .../C++/command-line-arguments.cpp | 11 + .../C/command-line-arguments.c | 11 + .../Clean/command-line-arguments.clean | 3 + .../Clojure/command-line-arguments.clj | 1 + .../Common-Lisp/command-line-arguments.lisp | 11 + .../D/command-line-arguments-1.d | 6 + .../D/command-line-arguments-2.d | 18 + .../Deja-Vu/command-line-arguments.djv | 11 + .../Delphi/command-line-arguments.delphi | 13 + .../E/command-line-arguments.e | 1 + .../Eiffel/command-line-arguments.e | 17 + .../Emacs-Lisp/command-line-arguments.l | 2 + .../Erlang/command-line-arguments-1.erl | 1 + .../Erlang/command-line-arguments-2.erl | 5 + .../Erlang/command-line-arguments-3.erl | 4 + .../Euphoria/command-line-arguments.euphoria | 9 + .../Forth/command-line-arguments-1.fth | 5 + .../Forth/command-line-arguments-2.fth | 7 + .../Fortran/command-line-arguments-1.f | 16 + .../Fortran/command-line-arguments-2.f | 6 + .../Go/command-line-arguments.go | 15 + .../Haskell/command-line-arguments.hs | 2 + .../Java/command-line-arguments.java | 7 + .../JavaScript/command-line-arguments-1.js | 3 + .../JavaScript/command-line-arguments-2.js | 4 + .../JavaScript/command-line-arguments-3.js | 2 + .../Lua/command-line-arguments.lua | 6 + .../PHP/command-line-arguments.php | 4 + .../Perl/command-line-arguments-1.pl | 4 + .../Perl/command-line-arguments-2.pl | 5 + .../PicoLisp/command-line-arguments.l | 10 + .../Python/command-line-arguments.py | 4 + .../R/command-line-arguments-1.r | 1 + .../R/command-line-arguments-2.r | 18 + .../REXX/command-line-arguments-1.rexx | 2 + .../REXX/command-line-arguments-2.rexx | 22 + .../Racket/command-line-arguments-1.rkt | 2 + .../Racket/command-line-arguments-2.rkt | 3 + .../Ruby/command-line-arguments.rb | 2 + .../Sather/command-line-arguments.sa | 7 + .../Scala/command-line-arguments-1.scala | 5 + .../Scala/command-line-arguments-2.scala | 1 + .../Scheme/command-line-arguments.ss | 2 + .../Smalltalk/command-line-arguments-1.st | 3 + .../Smalltalk/command-line-arguments-2.st | 1 + .../Tcl/command-line-arguments.tcl | 3 + Task/Comments/C++/comments-1.cpp | 1 + Task/Comments/C++/comments-2.cpp | 1 + Task/Comments/C++/comments-3.cpp | 3 + Task/Comments/COBOL/comments.cobol | 1 + Task/Comments/Chef/comments.chef | 16 + Task/Comments/Clean/comments-1.clean | 2 + Task/Comments/Clean/comments-2.clean | 1 + Task/Comments/ColdFusion/comments-1.cfm | 5 + Task/Comments/ColdFusion/comments-2.cfm | 2 + Task/Comments/Common-Lisp/comments-1.lisp | 12 + Task/Comments/Common-Lisp/comments-2.lisp | 7 + Task/Comments/D/comments-1.d | 3 + Task/Comments/D/comments-2.d | 5 + Task/Comments/D/comments-3.d | 5 + Task/Comments/D/comments-4.d | 11 + Task/Comments/DWScript/comments.dwscript | 10 + Task/Comments/Delphi/comments.delphi | 1 + Task/Comments/Deluge/comments.deluge | 1 + Task/Comments/E/comments.e | 6 + Task/Comments/Ela/comments.ela | 4 + Task/Comments/Emacs-Lisp/comments-1.l | 1 + Task/Comments/Emacs-Lisp/comments-2.l | 2 + Task/Comments/Emacs-Lisp/comments-3.l | 3 + Task/Comments/Euphoria/comments-1.euphoria | 1 + Task/Comments/Euphoria/comments-2.euphoria | 3 + .../0DESCRIPTION | 24 + .../1META.yaml | 2 + ...compare-sorting-algorithms-performance.ahk | 304 +++++++ ...compare-sorting-algorithms-performance.bbc | 163 ++++ ...compare-sorting-algorithms-performance-1.c | 9 + ...compare-sorting-algorithms-performance-2.c | 31 + ...compare-sorting-algorithms-performance-3.c | 39 + ...compare-sorting-algorithms-performance-4.c | 104 +++ ...compare-sorting-algorithms-performance-5.c | 30 + .../compare-sorting-algorithms-performance.d | 148 ++++ ...ompare-sorting-algorithms-performance-1.py | 19 + ...ompare-sorting-algorithms-performance-2.py | 10 + ...ompare-sorting-algorithms-performance-3.py | 7 + ...ompare-sorting-algorithms-performance-4.py | 23 + ...ompare-sorting-algorithms-performance-5.py | 30 + ...ompare-sorting-algorithms-performance-6.py | 18 + ...compare-sorting-algorithms-performance.tcl | 222 +++++ Task/Compile-time-calculation/0DESCRIPTION | 3 + .../Ada/compile-time-calculation-1.ada | 7 + .../Ada/compile-time-calculation-2.ada | 16 + .../Ada/compile-time-calculation-3.ada | 12 + .../Ada/compile-time-calculation-4.ada | 2 + .../BASIC/compile-time-calculation-1.bas | 1 + .../BASIC/compile-time-calculation-2.bas | 2 + .../C++/compile-time-calculation-1.cpp | 18 + .../C++/compile-time-calculation-2.cpp | 12 + .../C++/compile-time-calculation-3.cpp | 12 + .../C/compile-time-calculation.c | 10 + .../Clojure/compile-time-calculation.clj | 2 + .../compile-time-calculation-1.lisp | 2 + .../compile-time-calculation-2.lisp | 6 + .../compile-time-calculation-3.lisp | 6 + .../compile-time-calculation-4.lisp | 1 + .../compile-time-calculation-5.lisp | 1 + .../compile-time-calculation-6.lisp | 4 + .../D/compile-time-calculation-1.d | 15 + .../D/compile-time-calculation-2.d | 11 + .../compile-time-calculation.dwscript | 1 + .../Forth/compile-time-calculation-1.fth | 7 + .../Forth/compile-time-calculation-2.fth | 9 + .../Fortran/compile-time-calculation.f | 8 + .../Go/compile-time-calculation.go | 7 + .../Haskell/compile-time-calculation.hs | 5 + .../Perl/compile-time-calculation-1.pl | 6 + .../Perl/compile-time-calculation-2.pl | 1 + .../PicoLisp/compile-time-calculation.l | 5 + .../REXX/compile-time-calculation.rexx | 3 + .../Racket/compile-time-calculation.rkt | 21 + .../Tcl/compile-time-calculation-1.tcl | 8 + .../Tcl/compile-time-calculation-2.tcl | 9 + Task/Compound-data-type/0DESCRIPTION | 4 + Task/Compound-data-type/1META.yaml | 2 + .../ACL2/compound-data-type.acl2 | 9 + .../ALGOL-68/compound-data-type-1.alg | 8 + .../ALGOL-68/compound-data-type-2.alg | 9 + .../ALGOL-68/compound-data-type-3.alg | 4 + .../ALGOL-68/compound-data-type-4.alg | 9 + .../AWK/compound-data-type.awk | 2 + .../ActionScript/compound-data-type.as | 14 + .../Ada/compound-data-type-1.ada | 4 + .../Ada/compound-data-type-2.ada | 4 + .../Ada/compound-data-type-3.ada | 11 + .../AmigaE/compound-data-type.amiga | 12 + .../AutoHotkey/compound-data-type.ahk | 3 + .../BASIC/compound-data-type.bas | 4 + .../BBC-BASIC/compound-data-type.bbc | 1 + .../Bracmat/compound-data-type.bracmat | 11 + .../C++/compound-data-type-1.cpp | 5 + .../C++/compound-data-type-2.cpp | 6 + .../C++/compound-data-type-3.cpp | 10 + .../Compound-data-type/C/compound-data-type.c | 5 + .../Clean/compound-data-type-1.clean | 1 + .../Clean/compound-data-type-2.clean | 1 + .../Clean/compound-data-type-3.clean | 1 + .../Clojure/compound-data-type-1.clj | 1 + .../Clojure/compound-data-type-2.clj | 3 + .../CoffeeScript/compound-data-type.coffee | 20 + .../Common-Lisp/compound-data-type-1.lisp | 2 + .../Common-Lisp/compound-data-type-2.lisp | 12 + .../Compound-data-type/D/compound-data-type.d | 47 ++ .../Delphi/compound-data-type.delphi | 4 + .../Compound-data-type/E/compound-data-type.e | 7 + .../Ela/compound-data-type-1.ela | 1 + .../Ela/compound-data-type-2.ela | 4 + .../Erlang/compound-data-type.erl | 10 + .../Forth/compound-data-type-1.fth | 7 + .../Forth/compound-data-type-2.fth | 4 + .../Fortran/compound-data-type.f | 22 + .../Go/compound-data-type.go | 11 + .../Haskell/compound-data-type.hs | 1 + .../Java/compound-data-type.java | 14 + .../JavaScript/compound-data-type.js | 1 + .../Lua/compound-data-type-1.lua | 8 + .../Lua/compound-data-type-2.lua | 9 + .../Lua/compound-data-type-3.lua | 9 + .../Lua/compound-data-type-4.lua | 14 + .../Lua/compound-data-type-5.lua | 7 + .../PHP/compound-data-type-1.php | 10 + .../PHP/compound-data-type-2.php | 8 + .../PHP/compound-data-type-3.php | 7 + .../Perl/compound-data-type-1.pl | 1 + .../Perl/compound-data-type-2.pl | 4 + .../Perl/compound-data-type-3.pl | 9 + .../PicoLisp/compound-data-type.l | 9 + .../Python/compound-data-type-1.py | 5 + .../Python/compound-data-type-2.py | 7 + .../Python/compound-data-type-3.py | 5 + .../Python/compound-data-type-4.py | 27 + .../Compound-data-type/R/compound-data-type.r | 20 + .../REXX/compound-data-type-1.rexx | 4 + .../REXX/compound-data-type-2.rexx | 8 + .../Racket/compound-data-type-1.rkt | 2 + .../Racket/compound-data-type-2.rkt | 5 + .../Ruby/compound-data-type.rb | 5 + .../Scala/compound-data-type.scala | 4 + .../Scheme/compound-data-type.ss | 5 + .../Tcl/compound-data-type-1.tcl | 4 + .../Tcl/compound-data-type-2.tcl | 3 + .../Tcl/compound-data-type-3.tcl | 10 + Task/Concurrent-computing/0DESCRIPTION | 1 + Task/Concurrent-computing/1META.yaml | 4 + .../ALGOL-68/concurrent-computing.alg | 9 + .../Ada/concurrent-computing.ada | 17 + .../BBC-BASIC/concurrent-computing.bbc | 31 + .../C++/concurrent-computing.cpp | 20 + .../C/concurrent-computing-1.c | 56 ++ .../C/concurrent-computing-2.c | 11 + .../Clojure/concurrent-computing.clj | 2 + .../CoffeeScript/concurrent-computing.coffee | 5 + .../Common-Lisp/concurrent-computing.lisp | 10 + .../D/concurrent-computing-1.d | 8 + .../D/concurrent-computing-2.d | 9 + .../Delphi/concurrent-computing.delphi | 39 + .../E/concurrent-computing-1.e | 4 + .../E/concurrent-computing-2.e | 9 + .../Erlang/concurrent-computing-1.erl | 19 + .../Erlang/concurrent-computing-2.erl | 2 + .../Euphoria/concurrent-computing.euphoria | 17 + .../Forth/concurrent-computing.fth | 17 + .../Fortran/concurrent-computing.f | 44 + .../Go/concurrent-computing-1.go | 22 + .../Go/concurrent-computing-2.go | 25 + .../Go/concurrent-computing-3.go | 25 + .../Haskell/concurrent-computing-1.hs | 6 + .../Haskell/concurrent-computing-2.hs | 19 + .../Haskell/concurrent-computing-3.hs | 4 + .../Java/concurrent-computing.java | 33 + .../JavaScript/concurrent-computing-1.js | 4 + .../JavaScript/concurrent-computing-2.js | 10 + .../Lua/concurrent-computing.lua | 16 + .../Perl/concurrent-computing-1.pl | 9 + .../Perl/concurrent-computing-2.pl | 10 + .../PicoLisp/concurrent-computing-1.l | 5 + .../PicoLisp/concurrent-computing-2.l | 6 + .../Python/concurrent-computing-1.py | 10 + .../Python/concurrent-computing-2.py | 9 + .../Python/concurrent-computing-3.py | 8 + .../Python/concurrent-computing-4.py | 14 + .../Python/concurrent-computing-5.py | 9 + .../Python/concurrent-computing-6.py | 9 + .../Python/concurrent-computing-7.py | 7 + .../Racket/concurrent-computing.rkt | 4 + .../Ruby/concurrent-computing.rb | 8 + .../Scala/concurrent-computing.scala | 7 + .../Scheme/concurrent-computing.ss | 3 + .../Tcl/concurrent-computing-1.tcl | 3 + .../Tcl/concurrent-computing-2.tcl | 3 + .../Tcl/concurrent-computing-3.tcl | 13 + Task/Conditional-structures/0DESCRIPTION | 1 + Task/Conditional-structures/1META.yaml | 2 + .../conditional-structures-1.6502 | 2 + .../conditional-structures-2.6502 | 20 + .../conditional-structures-3.6502 | 6 + .../conditional-structures-4.6502 | 4 + .../AWK/conditional-structures-1.awk | 1 + .../AWK/conditional-structures-2.awk | 1 + .../Ada/conditional-structures-1.ada | 10 + .../Ada/conditional-structures-2.ada | 13 + .../Ada/conditional-structures-3.ada | 9 + .../Ada/conditional-structures-4.ada | 10 + .../Ada/conditional-structures-5.ada | 7 + .../Ada/conditional-structures-6.ada | 5 + .../Aikido/conditional-structures-1.aikido | 1 + .../Aikido/conditional-structures-2.aikido | 7 + .../Aikido/conditional-structures-3.aikido | 25 + .../Aime/conditional-structures.aime | 9 + .../conditional-structures-1.ambient | 5 + .../conditional-structures-2.ambient | 1 + .../AmigaE/conditional-structures-1.amiga | 7 + .../AmigaE/conditional-structures-2.amiga | 1 + .../AmigaE/conditional-structures-3.amiga | 2 + .../AmigaE/conditional-structures-4.amiga | 8 + .../AmigaE/conditional-structures-5.amiga | 10 + .../conditional-structures.applescript | 10 + .../AutoHotkey/conditional-structures.ahk | 19 + .../BASIC/conditional-structures-1.bas | 7 + .../BASIC/conditional-structures-2.bas | 2 + .../BASIC/conditional-structures-3.bas | 7 + .../BASIC/conditional-structures-4.bas | 5 + .../BASIC/conditional-structures-5.bas | 12 + .../BASIC/conditional-structures-6.bas | 9 + .../BASIC/conditional-structures-7.bas | 12 + .../BBC-BASIC/conditional-structures.bbc | 26 + .../Befunge/conditional-structures-1.bf | 3 + .../Befunge/conditional-structures-2.bf | 2 + .../Bori/conditional-structures.bori | 6 + .../Bracmat/conditional-structures-1.bracmat | 5 + .../Bracmat/conditional-structures-2.bracmat | 8 + .../Brainf---/conditional-structures-1.bf | 1 + .../Brainf---/conditional-structures-2.bf | 1 + .../Brainf---/conditional-structures-3.bf | 1 + .../Burlesque/conditional-structures-1.blq | 2 + .../Burlesque/conditional-structures-2.blq | 4 + .../Burlesque/conditional-structures-3.blq | 4 + .../Burlesque/conditional-structures-4.blq | 4 + .../C++/conditional-structures.cpp | 17 + .../CMake/conditional-structures.cmake | 10 + .../COBOL/conditional-structures-1.cobol | 19 + .../COBOL/conditional-structures-2.cobol | 33 + .../Clean/conditional-structures-1.clean | 1 + .../Clean/conditional-structures-2.clean | 3 + .../Clean/conditional-structures-3.clean | 2 + .../Clean/conditional-structures-4.clean | 8 + .../Clojure/conditional-structures-1.clj | 5 + .../Clojure/conditional-structures-2.clj | 4 + .../Clojure/conditional-structures-3.clj | 6 + .../Clojure/conditional-structures-4.clj | 3 + .../Clojure/conditional-structures-5.clj | 5 + .../Clojure/conditional-structures-6.clj | 4 + .../Clojure/conditional-structures-7.clj | 4 + .../conditional-structures-1.coffee | 6 + .../conditional-structures-2.coffee | 9 + .../conditional-structures-3.coffee | 7 + .../ColdFusion/conditional-structures-1.cfm | 7 + .../ColdFusion/conditional-structures-2.cfm | 11 + .../Common-Lisp/conditional-structures-1.lisp | 3 + .../Common-Lisp/conditional-structures-2.lisp | 4 + .../Crack/conditional-structures-1.crack | 17 + .../Crack/conditional-structures-2.crack | 2 + .../D/conditional-structures-1.d | 1 + .../D/conditional-structures-2.d | 9 + .../Dao/conditional-structures-1.dao | 8 + .../Dao/conditional-structures-2.dao | 7 + .../Deja-Vu/conditional-structures.djv | 6 + .../Deluge/conditional-structures.deluge | 7 + .../E/conditional-structures-1.e | 7 + .../E/conditional-structures-2.e | 1 + .../E/conditional-structures-3.e | 5 + .../E/conditional-structures-4.e | 7 + .../Efene/conditional-structures.efene | 60 ++ .../Ela/conditional-structures-1.ela | 1 + .../Ela/conditional-structures-2.ela | 2 + .../Ela/conditional-structures-3.ela | 2 + .../Ela/conditional-structures-4.ela | 3 + .../Erlang/conditional-structures-1.erl | 5 + .../Erlang/conditional-structures-2.erl | 6 + .../Erlang/conditional-structures-3.erl | 3 + .../Forth/conditional-structures-1.fth | 2 + .../Forth/conditional-structures-2.fth | 1 + .../Forth/conditional-structures-3.fth | 5 + .../Forth/conditional-structures-4.fth | 6 + .../Forth/conditional-structures-5.fth | 19 + .../Fortran/conditional-structures-1.f | 7 + .../Fortran/conditional-structures-2.f | 8 + .../Fortran/conditional-structures-3.f | 31 + .../Go/conditional-structures-1.go | 3 + .../Go/conditional-structures-10.go | 7 + .../Go/conditional-structures-2.go | 6 + .../Go/conditional-structures-3.go | 5 + .../Go/conditional-structures-4.go | 5 + .../Go/conditional-structures-5.go | 11 + .../Go/conditional-structures-6.go | 7 + .../Go/conditional-structures-7.go | 7 + .../Go/conditional-structures-8.go | 10 + .../Go/conditional-structures-9.go | 7 + .../Haskell/conditional-structures-1.hs | 3 + .../Haskell/conditional-structures-2.hs | 2 + .../Haskell/conditional-structures-3.hs | 2 + .../Haskell/conditional-structures-4.hs | 2 + .../Java/conditional-structures-1.java | 10 + .../Java/conditional-structures-2.java | 3 + .../Java/conditional-structures-3.java | 3 + .../Java/conditional-structures-4.java | 1 + .../Java/conditional-structures-5.java | 9 + .../Java/conditional-structures-6.java | 8 + .../JavaScript/conditional-structures-1.js | 7 + .../JavaScript/conditional-structures-2.js | 15 + .../JavaScript/conditional-structures-3.js | 1 + .../Lua/conditional-structures.lua | 32 + .../MATLAB/conditional-structures-1.m | 7 + .../MATLAB/conditional-structures-2.m | 8 + .../PHP/conditional-structures-1.php | 22 + .../PHP/conditional-structures-2.php | 18 + .../Perl/conditional-structures.pl | 8 + .../PicoLisp/conditional-structures-1.l | 9 + .../PicoLisp/conditional-structures-2.l | 7 + .../PicoLisp/conditional-structures-3.l | 6 + .../PicoLisp/conditional-structures-4.l | 21 + .../PicoLisp/conditional-structures-5.l | 9 + .../Python/conditional-structures-1.py | 8 + .../Python/conditional-structures-2.py | 1 + .../Python/conditional-structures-3.py | 3 + .../Python/conditional-structures-4.py | 4 + .../Python/conditional-structures-5.py | 10 + .../R/conditional-structures-1.r | 13 + .../R/conditional-structures-2.r | 3 + .../R/conditional-structures-3.r | 12 + .../REXX/conditional-structures-1.rexx | 22 + .../REXX/conditional-structures-2.rexx | 13 + .../REXX/conditional-structures-3.rexx | 14 + .../SNUSP/conditional-structures.snusp | 2 + .../Sather/conditional-structures-1.sa | 7 + .../Sather/conditional-structures-2.sa | 8 + .../Scheme/conditional-structures-1.ss | 1 + .../Scheme/conditional-structures-10.ss | 2 + .../Scheme/conditional-structures-2.ss | 1 + .../Scheme/conditional-structures-3.ss | 9 + .../Scheme/conditional-structures-4.ss | 2 + .../Scheme/conditional-structures-5.ss | 1 + .../Scheme/conditional-structures-6.ss | 9 + .../Scheme/conditional-structures-7.ss | 2 + .../Scheme/conditional-structures-8.ss | 1 + .../Scheme/conditional-structures-9.ss | 11 + .../Smalltalk/conditional-structures-1.st | 4 + .../Smalltalk/conditional-structures-2.st | 1 + .../Tcl/conditional-structures-1.tcl | 7 + .../Tcl/conditional-structures-2.tcl | 1 + .../Tcl/conditional-structures-3.tcl | 5 + Task/Constrained-genericity/0DESCRIPTION | 4 + Task/Constrained-genericity/1META.yaml | 4 + .../Ada/constrained-genericity-1.ada | 24 + .../Ada/constrained-genericity-2.ada | 8 + .../Common-Lisp/constrained-genericity.lisp | 34 + .../D/constrained-genericity-1.d | 21 + .../D/constrained-genericity-2.d | 17 + .../E/constrained-genericity.e | 14 + .../Eiffel/constrained-genericity-1.e | 10 + .../Eiffel/constrained-genericity-2.e | 14 + .../Eiffel/constrained-genericity-3.e | 14 + .../Eiffel/constrained-genericity-4.e | 10 + .../Eiffel/constrained-genericity-5.e | 1 + .../Eiffel/constrained-genericity-6.e | 1 + .../Eiffel/constrained-genericity-7.e | 34 + .../Eiffel/constrained-genericity-8.e | 1 + .../Go/constrained-genericity-1.go | 3 + .../Go/constrained-genericity-2.go | 1 + .../Go/constrained-genericity-3.go | 6 + .../Go/constrained-genericity-4.go | 22 + .../Haskell/constrained-genericity-1.hs | 2 + .../Haskell/constrained-genericity-2.hs | 1 + .../Haskell/constrained-genericity-3.hs | 3 + .../Haskell/constrained-genericity-4.hs | 2 + .../Haskell/constrained-genericity-5.hs | 2 + .../Haskell/constrained-genericity-6.hs | 2 + .../Java/constrained-genericity-1.java | 4 + .../Java/constrained-genericity-2.java | 6 + .../Java/constrained-genericity-3.java | 2 + .../Java/constrained-genericity-4.java | 3 + .../Java/constrained-genericity-5.java | 1 + .../PicoLisp/constrained-genericity.l | 18 + .../Sather/constrained-genericity.sa | 51 ++ .../Scala/constrained-genericity.scala | 11 + .../0DESCRIPTION | 8 + .../1META.yaml | 2 + .../constrained-random-points-on-a-circle.alg | 72 ++ .../constrained-random-points-on-a-circle.ada | 94 +++ .../constrained-random-points-on-a-circle.ahk | 18 + .../constrained-random-points-on-a-circle.bbc | 8 + .../constrained-random-points-on-a-circle-1.c | 35 + .../constrained-random-points-on-a-circle-2.c | 30 + .../constrained-random-points-on-a-circle.clj | 19 + ...trained-random-points-on-a-circle-1.coffee | 27 + ...trained-random-points-on-a-circle-2.coffee | 30 + ...constrained-random-points-on-a-circle.lisp | 9 + .../D/constrained-random-points-on-a-circle.d | 16 + ...ained-random-points-on-a-circle-1.euphoria | 65 ++ ...ained-random-points-on-a-circle-2.euphoria | 19 + .../constrained-random-points-on-a-circle.f | 76 ++ ...constrained-random-points-on-a-circle-1.go | 34 + ...constrained-random-points-on-a-circle-2.go | 39 + .../constrained-random-points-on-a-circle.hs | 15 + ...constrained-random-points-on-a-circle.java | 29 + .../constrained-random-points-on-a-circle.js | 46 ++ .../constrained-random-points-on-a-circle-1.m | 31 + .../constrained-random-points-on-a-circle-2.m | 2 + .../constrained-random-points-on-a-circle.pl | 22 + .../constrained-random-points-on-a-circle.l | 13 + .../constrained-random-points-on-a-circle.pro | 36 + ...constrained-random-points-on-a-circle-1.py | 44 + ...constrained-random-points-on-a-circle-2.py | 38 + .../R/constrained-random-points-on-a-circle.r | 18 + ...nstrained-random-points-on-a-circle-1.rexx | 25 + ...nstrained-random-points-on-a-circle-2.rexx | 25 + .../constrained-random-points-on-a-circle.rb | 21 + .../constrained-random-points-on-a-circle.tcl | 34 + .../0DESCRIPTION | 34 + ...metic-construct-from-rational-number-1.cpp | 32 + ...metic-construct-from-rational-number-2.cpp | 15 + ...metic-construct-from-rational-number-3.cpp | 10 + ...metic-construct-from-rational-number-4.cpp | 19 + ...ithmetic-construct-from-rational-number.hs | 11 + ...hmetic-construct-from-rational-number-1.py | 14 + ...hmetic-construct-from-rational-number-2.py | 13 + ...hmetic-construct-from-rational-number.rexx | 62 ++ ...hmetic-construct-from-rational-number-1.rb | 10 + ...metic-construct-from-rational-number-10.rb | 1 + ...hmetic-construct-from-rational-number-2.rb | 1 + ...hmetic-construct-from-rational-number-3.rb | 1 + ...hmetic-construct-from-rational-number-4.rb | 1 + ...hmetic-construct-from-rational-number-5.rb | 1 + ...hmetic-construct-from-rational-number-6.rb | 1 + ...hmetic-construct-from-rational-number-7.rb | 1 + ...hmetic-construct-from-rational-number-8.rb | 1 + ...hmetic-construct-from-rational-number-9.rb | 1 + ...metic-construct-from-rational-number-1.tcl | 19 + ...metic-construct-from-rational-number-2.tcl | 31 + ...metic-construct-from-rational-number-3.tcl | 109 +++ .../0DESCRIPTION | 41 + ...ic-g(matrix-ng,-contined-fraction-n)-1.cpp | 48 ++ ...ic-g(matrix-ng,-contined-fraction-n)-2.cpp | 7 + ...ic-g(matrix-ng,-contined-fraction-n)-3.cpp | 7 + ...ic-g(matrix-ng,-contined-fraction-n)-4.cpp | 7 + ...ic-g(matrix-ng,-contined-fraction-n)-5.cpp | 7 + ...ic-g(matrix-ng,-contined-fraction-n)-6.cpp | 10 + ...ic-g(matrix-ng,-contined-fraction-n)-7.cpp | 10 + ...tic-g(matrix-ng,-contined-fraction-n)-1.rb | 29 + ...tic-g(matrix-ng,-contined-fraction-n)-2.rb | 3 + ...tic-g(matrix-ng,-contined-fraction-n)-3.rb | 3 + ...tic-g(matrix-ng,-contined-fraction-n)-4.rb | 3 + ...ic-g(matrix-ng,-contined-fraction-n)-1.tcl | 50 ++ ...ic-g(matrix-ng,-contined-fraction-n)-2.tcl | 29 + .../0DESCRIPTION | 59 ++ .../1META.yaml | 2 + ...d-fraction-n1,-contined-fraction-n2)-1.cpp | 29 + ...d-fraction-n1,-contined-fraction-n2)-2.cpp | 13 + ...d-fraction-n1,-contined-fraction-n2)-3.cpp | 12 + ...d-fraction-n1,-contined-fraction-n2)-4.cpp | 10 + ...d-fraction-n1,-contined-fraction-n2)-5.cpp | 8 + ...d-fraction-n1,-contined-fraction-n2)-6.cpp | 20 + ...d-fraction-n1,-contined-fraction-n2)-1.tcl | 101 +++ ...d-fraction-n1,-contined-fraction-n2)-2.tcl | 16 + Task/Continued-fraction/0DESCRIPTION | 20 + .../ATS/continued-fraction.ats | 37 + .../Ada/continued-fraction-1.ada | 6 + .../Ada/continued-fraction-2.ada | 11 + .../Ada/continued-fraction-3.ada | 35 + .../Ada/continued-fraction-4.ada | 6 + .../Ada/continued-fraction-5.ada | 18 + .../Ada/continued-fraction-6.ada | 87 ++ .../Axiom/continued-fraction-1.axiom | 4 + .../Axiom/continued-fraction-2.axiom | 8 + .../Axiom/continued-fraction-3.axiom | 9 + .../BBC-BASIC/continued-fraction.bbc | 16 + .../C++/continued-fraction.cpp | 42 + .../Continued-fraction/C/continued-fraction.c | 71 ++ .../CoffeeScript/continued-fraction.coffee | 35 + .../Common-Lisp/continued-fraction.lisp | 24 + .../Continued-fraction/D/continued-fraction.d | 37 + .../Forth/continued-fraction.fth | 9 + .../Go/continued-fraction.go | 53 ++ .../Haskell/continued-fraction-1.hs | 24 + .../Haskell/continued-fraction-2.hs | 30 + .../Perl/continued-fraction.pl | 10 + .../Prolog/continued-fraction.pro | 43 + .../Python/continued-fraction-1.py | 67 ++ .../Python/continued-fraction-2.py | 24 + .../REXX/continued-fraction-1.rexx | 80 ++ .../REXX/continued-fraction-2.rexx | 44 + .../REXX/continued-fraction-3.rexx | 72 ++ .../Ruby/continued-fraction.rb | 47 ++ .../Scala/continued-fraction-1.scala | 31 + .../Scala/continued-fraction-2.scala | 35 + .../Tcl/continued-fraction.tcl | 41 + Task/Conways-Game-of-Life/0DESCRIPTION | 17 + Task/Conways-Game-of-Life/1META.yaml | 4 + .../6502-Assembly/conways-game-of-life.6502 | 123 +++ .../ACL2/conways-game-of-life.acl2 | 105 +++ .../AWK/conways-game-of-life.awk | 21 + .../Ada/conways-game-of-life.ada | 90 ++ .../AutoHotkey/conways-game-of-life.ahk | 40 + .../BASIC256/conways-game-of-life.basic256 | 69 ++ .../BBC-BASIC/conways-game-of-life.bbc | 35 + .../C++/conways-game-of-life.cpp | 204 +++++ .../C-sharp/conways-game-of-life.cs | 240 ++++++ .../C/conways-game-of-life.c | 56 ++ .../Clojure/conways-game-of-life.clj | 27 + .../Common-Lisp/conways-game-of-life-1.lisp | 42 + .../Common-Lisp/conways-game-of-life-2.lisp | 6 + .../Common-Lisp/conways-game-of-life-3.lisp | 42 + .../D/conways-game-of-life-1.d | 66 ++ .../D/conways-game-of-life-2.d | 83 ++ .../Dart/conways-game-of-life-1.dart | 157 ++++ .../Dart/conways-game-of-life-2.dart | 98 +++ .../E/conways-game-of-life.e | 61 ++ .../Erlang/conways-game-of-life.erl | 206 +++++ .../Forth/conways-game-of-life.fth | 79 ++ .../Fortran/conways-game-of-life.f | 74 ++ .../Go/conways-game-of-life.go | 83 ++ .../Haskell/conways-game-of-life-1.hs | 22 + .../Haskell/conways-game-of-life-2.hs | 40 + .../Haskell/conways-game-of-life-3.hs | 43 + .../Java/conways-game-of-life.java | 91 ++ .../JavaScript/conways-game-of-life-1.js | 99 +++ .../JavaScript/conways-game-of-life-2.js | 151 ++++ .../Lua/conways-game-of-life.lua | 51 ++ .../MATLAB/conways-game-of-life-1.m | 1 + .../MATLAB/conways-game-of-life-2.m | 1 + .../MATLAB/conways-game-of-life-3.m | 10 + .../Perl/conways-game-of-life-1.pl | 59 ++ .../Perl/conways-game-of-life-2.pl | 32 + .../PicoLisp/conways-game-of-life.l | 30 + .../Prolog/conways-game-of-life.pro | 179 ++++ .../Python/conways-game-of-life-1.py | 55 ++ .../Python/conways-game-of-life-2.py | 29 + .../R/conways-game-of-life.r | 82 ++ .../REXX/conways-game-of-life.rexx | 70 ++ .../Racket/conways-game-of-life.rkt | 132 +++ .../Ruby/conways-game-of-life-1.rb | 66 ++ .../Ruby/conways-game-of-life-2.rb | 148 ++++ .../Scheme/conways-game-of-life.ss | 89 ++ .../Tcl/conways-game-of-life.tcl | 79 ++ Task/Count-in-factors/0DESCRIPTION | 7 + .../Count-in-factors/Ada/count-in-factors.ada | 61 ++ .../AutoHotkey/count-in-factors.ahk | 17 + .../BBC-BASIC/count-in-factors.bbc | 18 + Task/Count-in-factors/C/count-in-factors.c | 64 ++ .../CoffeeScript/count-in-factors.coffee | 40 + .../Common-Lisp/count-in-factors-1.lisp | 27 + .../Common-Lisp/count-in-factors-2.lisp | 9 + Task/Count-in-factors/D/count-in-factors-1.d | 22 + Task/Count-in-factors/D/count-in-factors-2.d | 32 + .../DWScript/count-in-factors.dwscript | 18 + .../Euphoria/count-in-factors.euphoria | 28 + .../Forth/count-in-factors.fth | 15 + Task/Count-in-factors/Go/count-in-factors.go | 19 + .../Haskell/count-in-factors-1.hs | 3 + .../Haskell/count-in-factors-2.hs | 42 + .../Java/count-in-factors.java | 41 + .../JavaScript/count-in-factors.js | 15 + .../Count-in-factors/Lua/count-in-factors.lua | 24 + .../Count-in-factors/Perl/count-in-factors.pl | 26 + .../PicoLisp/count-in-factors.l | 11 + .../Python/count-in-factors.py | 35 + .../REXX/count-in-factors.rexx | 35 + .../Racket/count-in-factors.rkt | 15 + .../Count-in-factors/Ruby/count-in-factors.rb | 23 + .../Scheme/count-in-factors.ss | 20 + .../Tcl/count-in-factors-1.tcl | 62 ++ .../Tcl/count-in-factors-2.tcl | 4 + Task/Count-in-octal/0815/count-in-octal.0815 | 17 + Task/Count-in-octal/0DESCRIPTION | 3 + .../ALGOL-68/count-in-octal.alg | 9 + Task/Count-in-octal/AWK/count-in-octal.awk | 5 + Task/Count-in-octal/Ada/count-in-octal.ada | 10 + .../AutoHotkey/count-in-octal.ahk | 11 + .../Count-in-octal/BASIC/count-in-octal-1.bas | 4 + .../Count-in-octal/BASIC/count-in-octal-2.bas | 15 + .../BBC-BASIC/count-in-octal.bbc | 18 + .../Bracmat/count-in-octal.bracmat | 8 + .../Brainf---/count-in-octal.bf | 17 + Task/Count-in-octal/C++/count-in-octal.cpp | 12 + Task/Count-in-octal/C/count-in-octal.c | 8 + .../Count-in-octal/Clojure/count-in-octal.clj | 1 + .../CoffeeScript/count-in-octal.coffee | 5 + .../Common-Lisp/count-in-octal.lisp | 1 + Task/Count-in-octal/D/count-in-octal.d | 7 + Task/Count-in-octal/Dc/count-in-octal.dc | 1 + .../Delphi/count-in-octal.delphi | 24 + .../Emacs-Lisp/count-in-octal.l | 2 + .../Euphoria/count-in-octal.euphoria | 6 + Task/Count-in-octal/Forth/count-in-octal.fth | 3 + Task/Count-in-octal/Fortran/count-in-octal.f | 13 + Task/Count-in-octal/Go/count-in-octal-1.go | 15 + Task/Count-in-octal/Go/count-in-octal-2.go | 8 + Task/Count-in-octal/Go/count-in-octal-3.go | 17 + Task/Count-in-octal/Go/count-in-octal-4.go | 14 + Task/Count-in-octal/Haskell/count-in-octal.hs | 3 + Task/Count-in-octal/Java/count-in-octal.java | 7 + .../JavaScript/count-in-octal.js | 3 + Task/Count-in-octal/Lua/count-in-octal.lua | 3 + Task/Count-in-octal/MATLAB/count-in-octal-1.m | 5 + Task/Count-in-octal/MATLAB/count-in-octal-2.m | 5 + Task/Count-in-octal/MATLAB/count-in-octal-3.m | 2 + Task/Count-in-octal/MATLAB/count-in-octal-4.m | 1 + Task/Count-in-octal/PHP/count-in-octal.php | 5 + Task/Count-in-octal/Perl/count-in-octal-1.pl | 2 + Task/Count-in-octal/Perl/count-in-octal-2.pl | 3 + Task/Count-in-octal/PicoLisp/count-in-octal.l | 2 + Task/Count-in-octal/Python/count-in-octal.py | 3 + Task/Count-in-octal/REXX/count-in-octal.rexx | 33 + Task/Count-in-octal/Racket/count-in-octal.rkt | 3 + Task/Count-in-octal/Ruby/count-in-octal.rb | 5 + .../Count-in-octal/Scala/count-in-octal.scala | 1 + Task/Count-in-octal/Scheme/count-in-octal.ss | 1 + Task/Count-in-octal/Tcl/count-in-octal.tcl | 4 + .../0DESCRIPTION | 10 + .../1META.yaml | 2 + .../count-occurrences-of-a-substring.alg | 17 + .../AWK/count-occurrences-of-a-substring.awk | 16 + .../Ada/count-occurrences-of-a-substring.ada | 18 + .../count-occurrences-of-a-substring.ahk | 7 + .../count-occurrences-of-a-substring.bas | 15 + .../count-occurrences-of-a-substring.bbc | 16 + .../count-occurrences-of-a-substring.bracmat | 16 + .../C++/count-occurrences-of-a-substring.cpp | 24 + .../count-occurrences-of-a-substring.cs | 26 + .../C/count-occurrences-of-a-substring-1.c | 22 + .../C/count-occurrences-of-a-substring-2.c | 22 + .../count-occurrences-of-a-substring.coffee | 10 + .../count-occurrences-of-a-substring.lisp | 8 + .../D/count-occurrences-of-a-substring.d | 6 + .../count-occurrences-of-a-substring.delphi | 23 + .../EGL/count-occurrences-of-a-substring.egl | 51 ++ .../Eiffel/count-occurrences-of-a-substring.e | 35 + .../count-occurrences-of-a-substring-1.erl | 24 + .../count-occurrences-of-a-substring-2.erl | 1 + .../count-occurrences-of-a-substring.euphoria | 17 + .../count-occurrences-of-a-substring.fth | 9 + .../count-occurrences-of-a-substring.f | 28 + .../Go/count-occurrences-of-a-substring.go | 10 + .../count-occurrences-of-a-substring.hs | 8 + .../count-occurrences-of-a-substring-1.java | 11 + .../count-occurrences-of-a-substring-2.java | 15 + .../count-occurrences-of-a-substring-3.java | 15 + .../count-occurrences-of-a-substring.js | 3 + .../Lua/count-occurrences-of-a-substring.lua | 8 + .../MATLAB/count-occurrences-of-a-substring.m | 6 + .../PHP/count-occurrences-of-a-substring.php | 4 + .../Perl/count-occurrences-of-a-substring.pl | 10 + .../count-occurrences-of-a-substring.l | 7 + .../count-occurrences-of-a-substring.py | 4 + .../count-occurrences-of-a-substring.rexx | 15 + .../Ruby/count-occurrences-of-a-substring.rb | 8 + .../count-occurrences-of-a-substring.scala | 11 + .../Tcl/count-occurrences-of-a-substring.tcl | 6 + Task/Count-the-coins/0DESCRIPTION | 16 + .../Count-the-coins/AWK/count-the-coins-1.awk | 26 + .../Count-the-coins/AWK/count-the-coins-2.awk | 27 + Task/Count-the-coins/Ada/count-the-coins.ada | 32 + .../AutoHotkey/count-the-coins.ahk | 17 + .../BBC-BASIC/count-the-coins.bbc | 36 + Task/Count-the-coins/C/count-the-coins-1.c | 100 +++ Task/Count-the-coins/C/count-the-coins-2.c | 9 + .../Common-Lisp/count-the-coins.lisp | 23 + Task/Count-the-coins/D/count-the-coins-1.d | 15 + Task/Count-the-coins/D/count-the-coins-2.d | 41 + Task/Count-the-coins/D/count-the-coins-3.d | 60 ++ .../Erlang/count-the-coins.erl | 31 + .../Count-the-coins/Forth/count-the-coins.fth | 16 + Task/Count-the-coins/Go/count-the-coins-1.go | 37 + Task/Count-the-coins/Go/count-the-coins-2.go | 19 + .../Haskell/count-the-coins-1.hs | 5 + .../Haskell/count-the-coins-2.hs | 7 + .../Count-the-coins/Java/count-the-coins.java | 46 ++ .../JavaScript/count-the-coins-1.js | 19 + .../JavaScript/count-the-coins-2.js | 2 + .../JavaScript/count-the-coins-3.js | 25 + .../JavaScript/count-the-coins-4.js | 2 + .../PicoLisp/count-the-coins-1.l | 8 + .../PicoLisp/count-the-coins-2.l | 6 + .../Python/count-the-coins-1.py | 10 + .../Python/count-the-coins-2.py | 38 + .../Count-the-coins/REXX/count-the-coins.rexx | 21 + .../Count-the-coins/Ruby/count-the-coins-1.rb | 18 + .../Count-the-coins/Ruby/count-the-coins-2.rb | 14 + .../Scala/count-the-coins.scala | 11 + .../Count-the-coins/Scheme/count-the-coins.ss | 9 + Task/Count-the-coins/Tcl/count-the-coins.tcl | 22 + .../0DESCRIPTION | 1 + .../Create-a-file-on-magnetic-tape/1META.yaml | 2 + .../Tcl/create-a-file-on-magnetic-tape.tcl | 13 + Task/Create-a-file/0DESCRIPTION | 2 + Task/Create-a-file/1META.yaml | 2 + .../4DOS-Batch/create-a-file.4dos | 5 + Task/Create-a-file/ALGOL-68/create-a-file.alg | 38 + Task/Create-a-file/APL/create-a-file.apl | 4 + Task/Create-a-file/AWK/create-a-file.awk | 5 + Task/Create-a-file/Ada/create-a-file.ada | 17 + .../Create-a-file/Aikido/create-a-file.aikido | 8 + .../AppleScript/create-a-file-1.applescript | 1 + .../AppleScript/create-a-file-2.applescript | 1 + .../AppleScript/create-a-file-3.applescript | 2 + .../AppleScript/create-a-file-4.applescript | 1 + .../AutoHotkey/create-a-file.ahk | 4 + Task/Create-a-file/BASIC/create-a-file.bas | 4 + .../Create-a-file/BBC-BASIC/create-a-file.bbc | 4 + .../Batch-File/create-a-file-1.bat | 2 + .../Batch-File/create-a-file-2.bat | 2 + .../Bracmat/create-a-file-1.bracmat | 1 + .../Bracmat/create-a-file-2.bracmat | 1 + .../Bracmat/create-a-file-3.bracmat | 1 + .../Bracmat/create-a-file-4.bracmat | 1 + .../Bracmat/create-a-file-5.bracmat | 1 + Task/Create-a-file/C++/create-a-file.cpp | 14 + Task/Create-a-file/C/create-a-file-1.c | 8 + Task/Create-a-file/C/create-a-file-2.c | 14 + Task/Create-a-file/Clojure/create-a-file.clj | 5 + .../Common-Lisp/create-a-file-1.lisp | 2 + .../Common-Lisp/create-a-file-2.lisp | 3 + .../Common-Lisp/create-a-file-3.lisp | 3 + .../Common-Lisp/create-a-file-4.lisp | 4 + .../Common-Lisp/create-a-file-5.lisp | 1 + Task/Create-a-file/D/create-a-file.d | 46 ++ Task/Create-a-file/DCL/create-a-file.dcl | 4 + .../Create-a-file/Delphi/create-a-file.delphi | 100 +++ Task/Create-a-file/E/create-a-file.e | 4 + .../Euphoria/create-a-file.euphoria | 11 + Task/Create-a-file/Forth/create-a-file.fth | 2 + Task/Create-a-file/Fortran/create-a-file.f | 4 + Task/Create-a-file/Go/create-a-file.go | 33 + Task/Create-a-file/Haskell/create-a-file.hs | 9 + Task/Create-a-file/Java/create-a-file.java | 13 + Task/Create-a-file/Lua/create-a-file-1.lua | 2 + Task/Create-a-file/Lua/create-a-file-2.lua | 2 + Task/Create-a-file/Lua/create-a-file-3.lua | 3 + Task/Create-a-file/MATLAB/create-a-file.m | 4 + Task/Create-a-file/PHP/create-a-file.php | 6 + Task/Create-a-file/Perl/create-a-file-1.pl | 9 + Task/Create-a-file/Perl/create-a-file-2.pl | 2 + Task/Create-a-file/Perl/create-a-file-3.pl | 2 + Task/Create-a-file/Perl/create-a-file-4.pl | 4 + Task/Create-a-file/Perl/create-a-file-5.pl | 2 + Task/Create-a-file/PicoLisp/create-a-file.l | 4 + Task/Create-a-file/Python/create-a-file-1.py | 4 + Task/Create-a-file/Python/create-a-file-2.py | 9 + Task/Create-a-file/R/create-a-file.r | 10 + Task/Create-a-file/REXX/create-a-file.rexx | 4 + Task/Create-a-file/Racket/create-a-file.rkt | 6 + Task/Create-a-file/Ruby/create-a-file.rb | 4 + Task/Create-a-file/Scheme/create-a-file.ss | 2 + .../Smalltalk/create-a-file-1.st | 1 + .../Smalltalk/create-a-file-2.st | 7 + Task/Create-a-file/Tcl/create-a-file.tcl | 5 + .../0DESCRIPTION | 2 + .../1META.yaml | 2 + ...ate-a-two-dimensional-array-at-runtime.alg | 6 + ...ate-a-two-dimensional-array-at-runtime.apl | 7 + ...ate-a-two-dimensional-array-at-runtime.awk | 13 + ...ate-a-two-dimensional-array-at-runtime.ada | 21 + ...o-dimensional-array-at-runtime.applescript | 24 + ...ate-a-two-dimensional-array-at-runtime.ahk | 5 + ...-a-two-dimensional-array-at-runtime.autoit | 12 + ...ate-a-two-dimensional-array-at-runtime.bbc | 5 + ...e-a-two-dimensional-array-at-runtime-1.cpp | 26 + ...e-a-two-dimensional-array-at-runtime-2.cpp | 22 + ...e-a-two-dimensional-array-at-runtime-3.cpp | 20 + ...ate-a-two-dimensional-array-at-runtime-1.c | 13 + ...ate-a-two-dimensional-array-at-runtime-2.c | 20 + ...ate-a-two-dimensional-array-at-runtime-3.c | 28 + ...ate-a-two-dimensional-array-at-runtime-4.c | 18 + ...e-a-two-dimensional-array-at-runtime.clean | 8 + ...ate-a-two-dimensional-array-at-runtime.clj | 5 + ...te-a-two-dimensional-array-at-runtime.lisp | 10 + ...-a-two-dimensional-array-at-runtime.pascal | 18 + ...reate-a-two-dimensional-array-at-runtime.d | 25 + ...-a-two-dimensional-array-at-runtime.delphi | 28 + ...-two-dimensional-array-at-runtime.euphoria | 15 + ...e-a-two-dimensional-array-at-runtime-1.fth | 8 + ...e-a-two-dimensional-array-at-runtime-2.fth | 7 + ...reate-a-two-dimensional-array-at-runtime.f | 20 + ...te-a-two-dimensional-array-at-runtime-1.go | 28 + ...te-a-two-dimensional-array-at-runtime-2.go | 6 + ...te-a-two-dimensional-array-at-runtime-3.go | 3 + ...eate-a-two-dimensional-array-at-runtime.hs | 1 + ...te-a-two-dimensional-array-at-runtime.java | 14 + ...eate-a-two-dimensional-array-at-runtime.js | 28 + ...ate-a-two-dimensional-array-at-runtime.lua | 7 + ...ate-a-two-dimensional-array-at-runtime-1.m | 10 + ...ate-a-two-dimensional-array-at-runtime-2.m | 3 + ...te-a-two-dimensional-array-at-runtime-1.pl | 19 + ...te-a-two-dimensional-array-at-runtime-2.pl | 19 + ...reate-a-two-dimensional-array-at-runtime.l | 7 + ...te-a-two-dimensional-array-at-runtime-1.py | 5 + ...te-a-two-dimensional-array-at-runtime-2.py | 4 + ...reate-a-two-dimensional-array-at-runtime.r | 7 + ...te-a-two-dimensional-array-at-runtime.rexx | 39 + ...eate-a-two-dimensional-array-at-runtime.rb | 5 + ...e-a-two-dimensional-array-at-runtime.scala | 10 + ...te-a-two-dimensional-array-at-runtime-1.st | 11 + ...te-a-two-dimensional-array-at-runtime-2.st | 17 + ...te-a-two-dimensional-array-at-runtime-3.st | 26 + ...te-a-two-dimensional-array-at-runtime-4.st | 20 + ...ate-a-two-dimensional-array-at-runtime.tcl | 17 + Task/Create-an-HTML-table/0DESCRIPTION | 6 + Task/Create-an-HTML-table/1META.yaml | 3 + .../AWK/create-an-html-table.awk | 13 + .../Ada/create-an-html-table-1.ada | 19 + .../Ada/create-an-html-table-2.ada | 56 ++ .../Ada/create-an-html-table-3.ada | 32 + .../Ada/create-an-html-table-4.ada | 11 + .../AutoHotkey/create-an-html-table.ahk | 10 + .../BBC-BASIC/create-an-html-table.bbc | 30 + .../C++/create-an-html-table.cpp | 68 ++ .../C-sharp/create-an-html-table.cs | 34 + .../C/create-an-html-table.c | 16 + .../CoffeeScript/create-an-html-table.coffee | 32 + .../D/create-an-html-table.d | 10 + .../Delphi/create-an-html-table-1.delphi | 23 + .../Delphi/create-an-html-table-2.delphi | 7 + .../Euphoria/create-an-html-table-1.euphoria | 10 + .../Euphoria/create-an-html-table-2.euphoria | 6 + .../Go/create-an-html-table-1.go | 36 + .../Go/create-an-html-table-2.go | 7 + .../Haskell/create-an-html-table.hs | 20 + .../Java/create-an-html-table-1.java | 25 + .../Java/create-an-html-table-2.java | 1 + .../JavaScript/create-an-html-table.js | 35 + .../MATLAB/create-an-html-table.m | 12 + .../PHP/create-an-html-table-1.php | 36 + .../PHP/create-an-html-table-2.php | 35 + .../Perl/create-an-html-table.pl | 13 + .../PicoLisp/create-an-html-table.l | 5 + .../Python/create-an-html-table-1.py | 17 + .../Python/create-an-html-table-2.py | 8 + .../REXX/create-an-html-table.rexx | 32 + .../Racket/create-an-html-table.rkt | 17 + .../Ruby/create-an-html-table-1.rb | 22 + .../Ruby/create-an-html-table-2.rb | 20 + .../Ruby/create-an-html-table-3.rb | 26 + .../Scheme/create-an-html-table.ss | 21 + .../Tcl/create-an-html-table.tcl | 41 + .../0DESCRIPTION | 11 + .../1META.yaml | 2 + ...create-an-object-at-a-given-address-1.6502 | 3 + ...create-an-object-at-a-given-address-2.6502 | 4 + ...create-an-object-at-a-given-address-3.6502 | 6 + ...create-an-object-at-a-given-address-4.6502 | 6 + .../create-an-object-at-a-given-address-1.ada | 3 + .../create-an-object-at-a-given-address-2.ada | 13 + ...create-an-object-at-a-given-address.aikido | 9 + .../create-an-object-at-a-given-address.ahk | 9 + .../create-an-object-at-a-given-address.bbc | 19 + .../create-an-object-at-a-given-address.cpp | 24 + .../C/create-an-object-at-a-given-address-1.c | 19 + .../C/create-an-object-at-a-given-address-2.c | 15 + .../create-an-object-at-a-given-address.cobol | 20 + .../D/create-an-object-at-a-given-address.d | 34 + .../create-an-object-at-a-given-address.fth | 4 + .../Go/create-an-object-at-a-given-address.go | 58 ++ .../create-an-object-at-a-given-address.l | 11 + .../create-an-object-at-a-given-address-1.tcl | 21 + .../create-an-object-at-a-given-address-2.tcl | 7 + Task/Cut-a-rectangle/0DESCRIPTION | 7 + Task/Cut-a-rectangle/C/cut-a-rectangle-1.c | 80 ++ Task/Cut-a-rectangle/C/cut-a-rectangle-2.c | 40 + Task/Cut-a-rectangle/C/cut-a-rectangle-3.c | 191 +++++ .../Common-Lisp/cut-a-rectangle-1.lisp | 43 + .../Common-Lisp/cut-a-rectangle-2.lisp | 30 + Task/Cut-a-rectangle/D/cut-a-rectangle.d | 88 ++ .../Haskell/cut-a-rectangle.hs | 80 ++ .../Python/cut-a-rectangle-1.py | 53 ++ .../Python/cut-a-rectangle-2.py | 70 ++ .../Cut-a-rectangle/REXX/cut-a-rectangle.rexx | 45 + Task/Cut-a-rectangle/Tcl/cut-a-rectangle.tcl | 82 ++ Task/DNS-query/0DESCRIPTION | 3 + Task/DNS-query/1META.yaml | 2 + Task/DNS-query/Ada/dns-query.ada | 13 + Task/DNS-query/BBC-BASIC/dns-query-1.bbc | 52 ++ Task/DNS-query/BBC-BASIC/dns-query-2.bbc | 58 ++ Task/DNS-query/C-sharp/dns-query.cs | 18 + .../Cache-ObjectScript/dns-query.cos | 57 ++ Task/DNS-query/Clojure/dns-query.clj | 6 + Task/DNS-query/CoffeeScript/dns-query.coffee | 10 + Task/DNS-query/Common-Lisp/dns-query-1.lisp | 3 + Task/DNS-query/Common-Lisp/dns-query-2.lisp | 3 + Task/DNS-query/Common-Lisp/dns-query-3.lisp | 7 + Task/DNS-query/D/dns-query.d | 11 + Task/DNS-query/Delphi/dns-query.delphi | 21 + Task/DNS-query/Go/dns-query-1.go | 14 + Task/DNS-query/Go/dns-query-2.go | 16 + Task/DNS-query/Go/dns-query-3.go | 21 + Task/DNS-query/Go/dns-query-4.go | 13 + Task/DNS-query/PHP/dns-query.php | 6 + Task/DNS-query/Perl/dns-query.pl | 8 + Task/DNS-query/PicoLisp/dns-query-1.l | 4 + Task/DNS-query/PicoLisp/dns-query-2.l | 6 + Task/DNS-query/PicoLisp/dns-query-3.l | 5 + Task/DNS-query/Racket/dns-query.rkt | 4 + Task/DNS-query/Scheme/dns-query.ss | 7 + Task/DNS-query/Tcl/dns-query.tcl | 10 + Task/Date-format/0DESCRIPTION | 1 + Task/Date-format/1META.yaml | 2 + Task/Date-format/ABAP/date-format.abap | 21 + Task/Date-format/ALGOL-68/date-format.alg | 23 + Task/Date-format/AWK/date-format.awk | 3 + Task/Date-format/Ada/date-format.ada | 44 + Task/Date-format/AutoHotkey/date-format.ahk | 3 + Task/Date-format/BASIC/date-format.bas | 6 + Task/Date-format/BBC-BASIC/date-format.bbc | 18 + Task/Date-format/C++/date-format.cpp | 64 ++ Task/Date-format/C/date-format.c | 23 + Task/Date-format/Clojure/date-format.clj | 5 + .../CoffeeScript/date-format-1.coffee | 26 + .../CoffeeScript/date-format-2.coffee | 3 + Task/Date-format/ColdFusion/date-format.cfm | 4 + Task/Date-format/Common-Lisp/date-format.lisp | 10 + Task/Date-format/D/date-format.d | 17 + Task/Date-format/Delphi/date-format.delphi | 1 + Task/Date-format/EGL/date-format.egl | 5 + Task/Date-format/Erlang/date-format.erl | 24 + .../Date-format/Euphoria/date-format.euphoria | 11 + Task/Date-format/Forth/date-format.fth | 55 ++ Task/Date-format/Fortran/date-format.f | 69 ++ Task/Date-format/Go/date-format.go | 9 + Task/Date-format/Haskell/date-format.hs | 13 + Task/Date-format/Java/date-format.java | 29 + Task/Date-format/JavaScript/date-format.js | 8 + Task/Date-format/Lua/date-format.lua | 2 + Task/Date-format/MATLAB/date-format.m | 11 + Task/Date-format/PHP/date-format.php | 4 + Task/Date-format/Perl/date-format-1.pl | 4 + Task/Date-format/Perl/date-format-2.pl | 4 + Task/Date-format/PicoLisp/date-format.l | 10 + Task/Date-format/Python/date-format.py | 6 + Task/Date-format/R/date-format.r | 3 + Task/Date-format/REXX/date-format.rexx | 11 + Task/Date-format/Racket/date-format.rkt | 13 + Task/Date-format/Ruby/date-format.rb | 3 + Task/Date-format/Scala/date-format.scala | 3 + Task/Date-format/Tcl/date-format.tcl | 3 + Task/Date-manipulation/0DESCRIPTION | 3 + Task/Date-manipulation/1META.yaml | 2 + .../Ada/date-manipulation.ada | 97 +++ .../date-manipulation-1.applescript | 2 + .../date-manipulation-2.applescript | 1 + .../AutoHotkey/date-manipulation.ahk | 65 ++ .../BBC-BASIC/date-manipulation.bbc | 32 + .../C++/date-manipulation.cpp | 67 ++ Task/Date-manipulation/C/date-manipulation.c | 19 + .../Clojure/date-manipulation.clj | 11 + .../Delphi/date-manipulation.delphi | 81 ++ .../Euphoria/date-manipulation.euphoria | 10 + .../Date-manipulation/Go/date-manipulation.go | 31 + .../Haskell/date-manipulation.hs | 9 + .../Java/date-manipulation.java | 16 + .../JavaScript/date-manipulation.js | 51 ++ .../Lua/date-manipulation.lua | 26 + .../PHP/date-manipulation.php | 5 + .../Perl/date-manipulation.pl | 11 + .../PicoLisp/date-manipulation.l | 19 + .../Python/date-manipulation.py | 12 + Task/Date-manipulation/R/date-manipulation.r | 5 + .../REXX/date-manipulation.rexx | 13 + .../Ruby/date-manipulation-1.rb | 18 + .../Ruby/date-manipulation-2.rb | 3 + .../Scala/date-manipulation.scala | 17 + .../Smalltalk/date-manipulation-1.st | 50 ++ .../Smalltalk/date-manipulation-2.st | 29 + .../Tcl/date-manipulation.tcl | 5 + Task/Day-of-the-week/0DESCRIPTION | 5 + .../Day-of-the-week/ABAP/day-of-the-week.abap | 24 + .../ALGOL-68/day-of-the-week.alg | 22 + Task/Day-of-the-week/AWK/day-of-the-week.awk | 8 + Task/Day-of-the-week/Ada/day-of-the-week.ada | 11 + .../AppleScript/day-of-the-week.applescript | 9 + .../AutoHotkey/day-of-the-week.ahk | 10 + .../AutoIt/day-of-the-week.autoit | 7 + .../BBC-BASIC/day-of-the-week.bbc | 7 + Task/Day-of-the-week/C++/day-of-the-week.cpp | 18 + Task/Day-of-the-week/C/day-of-the-week.c | 24 + .../Clojure/day-of-the-week.clj | 7 + .../CoffeeScript/day-of-the-week-1.coffee | 5 + .../CoffeeScript/day-of-the-week-2.coffee | 1 + .../CoffeeScript/day-of-the-week-3.coffee | 17 + .../ColdFusion/day-of-the-week.cfm | 6 + .../Common-Lisp/day-of-the-week.lisp | 6 + Task/Day-of-the-week/D/day-of-the-week.d | 10 + .../Delphi/day-of-the-week.delphi | 17 + .../Euphoria/day-of-the-week.euphoria | 15 + .../Forth/day-of-the-week-1.fth | 16 + .../Forth/day-of-the-week-2.fth | 3 + .../Forth/day-of-the-week-3.fth | 9 + .../Forth/day-of-the-week-4.fth | 10 + .../Day-of-the-week/Fortran/day-of-the-week.f | 30 + Task/Day-of-the-week/Go/day-of-the-week.go | 13 + .../Haskell/day-of-the-week-1.hs | 8 + .../Haskell/day-of-the-week-2.hs | 21 + .../Day-of-the-week/Java/day-of-the-week.java | 15 + .../JavaScript/day-of-the-week.js | 5 + Task/Day-of-the-week/Lua/day-of-the-week.lua | 7 + Task/Day-of-the-week/MATLAB/day-of-the-week.m | 3 + Task/Day-of-the-week/PHP/day-of-the-week.php | 10 + .../Day-of-the-week/Perl/day-of-the-week-1.pl | 16 + .../Day-of-the-week/Perl/day-of-the-week-2.pl | 18 + .../Day-of-the-week/Perl/day-of-the-week-3.pl | 11 + .../Day-of-the-week/Perl/day-of-the-week-4.pl | 8 + .../PicoLisp/day-of-the-week.l | 3 + .../Day-of-the-week/Python/day-of-the-week.py | 8 + Task/Day-of-the-week/R/day-of-the-week-1.r | 3 + Task/Day-of-the-week/R/day-of-the-week-2.r | 4 + Task/Day-of-the-week/R/day-of-the-week-3.r | 6 + .../REXX/day-of-the-week-1.rexx | 3 + .../REXX/day-of-the-week-2.rexx | 3 + .../REXX/day-of-the-week-3.rexx | 14 + .../REXX/day-of-the-week-4.rexx | 14 + .../Day-of-the-week/Ruby/day-of-the-week-1.rb | 5 + .../Day-of-the-week/Ruby/day-of-the-week-2.rb | 11 + .../Scala/day-of-the-week.scala | 13 + .../Day-of-the-week/Scheme/day-of-the-week.ss | 19 + .../Smalltalk/day-of-the-week.st | 5 + Task/Day-of-the-week/Tcl/day-of-the-week.tcl | 7 + Task/Deal-cards-for-FreeCell/0DESCRIPTION | 53 ++ Task/Deal-cards-for-FreeCell/1META.yaml | 2 + .../Ada/deal-cards-for-freecell.ada | 38 + .../BBC-BASIC/deal-cards-for-freecell.bbc | 45 + .../Bracmat/deal-cards-for-freecell.bracmat | 63 ++ .../C/deal-cards-for-freecell.c | 46 ++ .../Common-Lisp/deal-cards-for-freecell.lisp | 26 + .../D/deal-cards-for-freecell.d | 40 + .../Go/deal-cards-for-freecell.go | 65 ++ .../Haskell/deal-cards-for-freecell.hs | 36 + .../JavaScript/deal-cards-for-freecell.js | 87 ++ .../Perl/deal-cards-for-freecell.pl | 42 + .../PicoLisp/deal-cards-for-freecell.l | 20 + .../Python/deal-cards-for-freecell.py | 29 + .../Ruby/deal-cards-for-freecell.rb | 72 ++ .../Tcl/deal-cards-for-freecell.tcl | 31 + Task/Death-Star/D/death-star.d | 109 +++ Task/Death-Star/DWScript/death-star.dwscript | 94 +++ Task/Deconvolution-1D/0DESCRIPTION | 78 ++ Task/Deconvolution-1D/1META.yaml | 2 + .../BBC-BASIC/deconvolution-1d.bbc | 38 + Task/Deconvolution-1D/C/deconvolution-1d-1.c | 92 +++ Task/Deconvolution-1D/C/deconvolution-1d-2.c | 4 + .../Common-Lisp/deconvolution-1d-1.lisp | 22 + .../Common-Lisp/deconvolution-1d-2.lisp | 29 + Task/Deconvolution-1D/D/deconvolution-1d.d | 23 + .../Fortran/deconvolution-1d-1.f | 73 ++ .../Fortran/deconvolution-1d-2.f | 2 + .../Deconvolution-1D/Go/deconvolution-1d-1.go | 30 + .../Deconvolution-1D/Go/deconvolution-1d-2.go | 65 ++ .../Haskell/deconvolution-1d-1.hs | 16 + .../Haskell/deconvolution-1d-2.hs | 5 + .../Java/deconvolution-1d.java | 26 + .../Lua/deconvolution-1d-1.lua | 15 + .../Lua/deconvolution-1d-2.lua | 5 + .../MATLAB/deconvolution-1d.m | 14 + .../PicoLisp/deconvolution-1d-1.l | 10 + .../PicoLisp/deconvolution-1d-2.l | 7 + .../Python/deconvolution-1d.py | 53 ++ Task/Deconvolution-1D/R/deconvolution-1d-1.r | 17 + Task/Deconvolution-1D/R/deconvolution-1d-2.r | 7 + Task/Deconvolution-1D/R/deconvolution-1d-3.r | 1 + .../Tcl/deconvolution-1d-1.tcl | 100 +++ .../Tcl/deconvolution-1d-2.tcl | 18 + Task/Deconvolution-2D+/0DESCRIPTION | 79 ++ Task/Deconvolution-2D+/1META.yaml | 2 + .../Deconvolution-2D+/C/deconvolution-2d+-1.c | 218 +++++ .../Deconvolution-2D+/C/deconvolution-2d+-2.c | 18 + Task/Deconvolution-2D+/D/deconvolution-2d+.d | 185 +++++ .../Tcl/deconvolution-2d+-1.tcl | 165 ++++ .../Tcl/deconvolution-2d+-2.tcl | 52 ++ Task/Deepcopy/0DESCRIPTION | 13 + Task/Deepcopy/C-sharp/deepcopy.cs | 28 + Task/Deepcopy/Common-Lisp/deepcopy.lisp | 7 + Task/Deepcopy/E/deepcopy-1.e | 4 + Task/Deepcopy/E/deepcopy-2.e | 22 + Task/Deepcopy/Go/deepcopy-1.go | 37 + Task/Deepcopy/Go/deepcopy-2.go | 62 ++ Task/Deepcopy/JavaScript/deepcopy-1.js | 8 + Task/Deepcopy/JavaScript/deepcopy-2.js | 8 + Task/Deepcopy/PHP/deepcopy-1.php | 21 + Task/Deepcopy/PHP/deepcopy-2.php | 14 + Task/Deepcopy/Perl/deepcopy.pl | 11 + Task/Deepcopy/PicoLisp/deepcopy-1.l | 1 + Task/Deepcopy/PicoLisp/deepcopy-2.l | 4 + Task/Deepcopy/PicoLisp/deepcopy-3.l | 25 + Task/Deepcopy/PicoLisp/deepcopy-4.l | 11 + Task/Deepcopy/PicoLisp/deepcopy-5.l | 12 + Task/Deepcopy/Python/deepcopy.py | 2 + Task/Deepcopy/Ruby/deepcopy.rb | 22 + Task/Deepcopy/Tcl/deepcopy-1.tcl | 1 + Task/Deepcopy/Tcl/deepcopy-2.tcl | 1 + .../C++/define-a-primitive-data-type.cpp | 62 ++ .../define-a-primitive-data-type-1.lisp | 2 + .../define-a-primitive-data-type-2.lisp | 13 + .../define-a-primitive-data-type-3.lisp | 3 + .../D/define-a-primitive-data-type.d | 84 ++ .../E/define-a-primitive-data-type.e | 5 + .../define-a-primitive-data-type.euphoria | 3 + Task/Delegates/C++/delegates.cpp | 79 ++ Task/Delegates/C-sharp/delegates.cs | 39 + Task/Delegates/Common-Lisp/delegates.lisp | 29 + Task/Delegates/D/delegates-1.d | 24 + Task/Delegates/D/delegates-2.d | 29 + Task/Delegates/Dart/delegates.dart | 29 + Task/Delegates/Delphi/delegates-1.delphi | 50 ++ Task/Delegates/Delphi/delegates-2.delphi | 19 + Task/Delegates/E/delegates.e | 34 + Task/Delete-a-file/C++/delete-a-file.cpp | 11 + .../Common-Lisp/delete-a-file-1.lisp | 2 + .../Common-Lisp/delete-a-file-2.lisp | 5 + .../Common-Lisp/delete-a-file-3.lisp | 2 + Task/Delete-a-file/D/delete-a-file-1.d | 5 + Task/Delete-a-file/D/delete-a-file-2.d | 8 + Task/Delete-a-file/D/delete-a-file-3.d | 8 + .../Delete-a-file/Delphi/delete-a-file.delphi | 12 + Task/Delete-a-file/E/delete-a-file.e | 4 + .../Common-Lisp/detect-division-by-zero.lisp | 2 + .../D/detect-division-by-zero.d | 59 ++ .../Delphi/detect-division-by-zero.delphi | 18 + .../E/detect-division-by-zero.e | 8 + .../Ela/detect-division-by-zero-1.ela | 6 + .../Ela/detect-division-by-zero-2.ela | 2 + .../determine-if-a-string-is-numeric-1.cpp | 28 + .../determine-if-a-string-is-numeric-2.cpp | 7 + .../determine-if-a-string-is-numeric-3.cpp | 3 + .../determine-if-a-string-is-numeric.cfm | 15 + .../determine-if-a-string-is-numeric-1.lisp | 3 + .../determine-if-a-string-is-numeric-2.lisp | 5 + .../D/determine-if-a-string-is-numeric-1.d | 9 + .../D/determine-if-a-string-is-numeric-2.d | 27 + .../determine-if-a-string-is-numeric-1.delphi | 6 + .../determine-if-a-string-is-numeric-2.delphi | 51 ++ .../E/determine-if-a-string-is-numeric.e | 8 + .../determine-if-a-string-is-numeric.euphoria | 7 + .../0DESCRIPTION | 1 + .../1META.yaml | 2 + ...ermine-if-only-one-instance-is-running.ada | 28 + ...ermine-if-only-one-instance-is-running.bbc | 11 + ...mine-if-only-one-instance-is-running-1.cpp | 1 + ...mine-if-only-one-instance-is-running-2.cpp | 1 + ...mine-if-only-one-instance-is-running-3.cpp | 5 + ...mine-if-only-one-instance-is-running-4.cpp | 1 + ...ermine-if-only-one-instance-is-running-1.c | 94 +++ ...ermine-if-only-one-instance-is-running-2.c | 36 + ...ermine-if-only-one-instance-is-running.clj | 5 + ...ine-if-only-one-instance-is-running.delphi | 27 + ...termine-if-only-one-instance-is-running.go | 49 ++ ...termine-if-only-one-instance-is-running.hs | 42 + ...rmine-if-only-one-instance-is-running.java | 23 + ...termine-if-only-one-instance-is-running.pl | 9 + ...ermine-if-only-one-instance-is-running-1.l | 3 + ...ermine-if-only-one-instance-is-running-2.l | 2 + ...termine-if-only-one-instance-is-running.py | 8 + ...termine-if-only-one-instance-is-running.rb | 15 + ...ermine-if-only-one-instance-is-running.tcl | 10 + Task/Digital-root/0DESCRIPTION | 20 + Task/Digital-root/Ada/digital-root.ada | 48 ++ Task/Digital-root/BASIC/digital-root.bas | 24 + Task/Digital-root/BBC-BASIC/digital-root.bbc | 29 + Task/Digital-root/C++/digital-root.cpp | 32 + Task/Digital-root/C/digital-root.c | 26 + Task/Digital-root/D/digital-root.d | 37 + Task/Digital-root/Dc/digital-root.dc | 1 + Task/Digital-root/Go/digital-root.go | 56 ++ Task/Digital-root/Haskell/digital-root-1.hs | 11 + Task/Digital-root/Haskell/digital-root-2.hs | 52 ++ Task/Digital-root/Java/digital-root.java | 31 + Task/Digital-root/PicoLisp/digital-root.l | 4 + Task/Digital-root/Python/digital-root.py | 10 + Task/Digital-root/REXX/digital-root-1.rexx | 27 + Task/Digital-root/REXX/digital-root-2.rexx | 21 + Task/Digital-root/REXX/digital-root-3.rexx | 11 + Task/Digital-root/Racket/digital-root.rkt | 25 + Task/Digital-root/Scala/digital-root.scala | 12 + Task/Digital-root/Tcl/digital-root.tcl | 12 + .../0DESCRIPTION | 8 + .../dinesmans-multiple-dwelling-problem.ada | 46 ++ .../dinesmans-multiple-dwelling-problem.bbc | 48 ++ ...inesmans-multiple-dwelling-problem.bracmat | 26 + .../C/dinesmans-multiple-dwelling-problem-1.c | 81 ++ .../C/dinesmans-multiple-dwelling-problem-2.c | 6 + .../D/dinesmans-multiple-dwelling-problem-1.d | 17 + .../D/dinesmans-multiple-dwelling-problem-2.d | 13 + .../dinesmans-multiple-dwelling-problem.fth | 51 ++ .../dinesmans-multiple-dwelling-problem-1.hs | 37 + .../dinesmans-multiple-dwelling-problem-2.hs | 2 + .../dinesmans-multiple-dwelling-problem.java | 64 ++ .../dinesmans-multiple-dwelling-problem.l | 27 + .../dinesmans-multiple-dwelling-problem-1.pro | 82 ++ .../dinesmans-multiple-dwelling-problem-2.pro | 33 + .../dinesmans-multiple-dwelling-problem-3.pro | 26 + .../dinesmans-multiple-dwelling-problem-1.py | 132 +++ .../dinesmans-multiple-dwelling-problem-2.py | 22 + .../dinesmans-multiple-dwelling-problem-3.py | 57 ++ .../dinesmans-multiple-dwelling-problem-4.py | 18 + .../dinesmans-multiple-dwelling-problem.rexx | 32 + .../dinesmans-multiple-dwelling-problem.rb | 38 + ...inesmans-multiple-dwelling-problem-1.scala | 31 + ...inesmans-multiple-dwelling-problem-2.scala | 11 + .../dinesmans-multiple-dwelling-problem-1.tcl | 31 + .../dinesmans-multiple-dwelling-problem-2.tcl | 10 + Task/Dining-philosophers/0DESCRIPTION | 7 + Task/Dining-philosophers/1META.yaml | 6 + .../Ada/dining-philosophers-1.ada | 50 ++ .../Ada/dining-philosophers-2.ada | 53 ++ .../Ada/dining-philosophers-3.ada | 75 ++ .../BBC-BASIC/dining-philosophers.bbc | 66 ++ .../C++/dining-philosophers.cpp | 159 ++++ .../C/dining-philosophers-1.c | 95 +++ .../C/dining-philosophers-2.c | 94 +++ .../Clojure/dining-philosophers-1.clj | 30 + .../Clojure/dining-philosophers-2.clj | 20 + .../Common-Lisp/dining-philosophers.lisp | 73 ++ .../D/dining-philosophers.d | 40 + .../Eiffel/dining-philosophers-1.e | 58 ++ .../Eiffel/dining-philosophers-2.e | 110 +++ .../Eiffel/dining-philosophers-3.e | 34 + .../Erlang/dining-philosophers.erl | 105 +++ .../Euphoria/dining-philosophers.euphoria | 54 ++ .../Go/dining-philosophers.go | 74 ++ .../Haskell/dining-philosophers.hs | 65 ++ .../Java/dining-philosophers.java | 113 +++ .../PicoLisp/dining-philosophers.l | 36 + .../Prolog/dining-philosophers.pro | 449 ++++++++++ .../Python/dining-philosophers.py | 67 ++ .../Ruby/dining-philosophers.rb | 70 ++ .../Smalltalk/dining-philosophers.st | 97 +++ .../Tcl/dining-philosophers.tcl | 68 ++ Task/Discordian-date/0DESCRIPTION | 4 + Task/Discordian-date/AWK/discordian-date.awk | 95 +++ Task/Discordian-date/Ada/discordian-date.ada | 80 ++ .../Discordian-date/BASIC/discordian-date.bas | 52 ++ .../BBC-BASIC/discordian-date.bbc | 38 + Task/Discordian-date/C/discordian-date.c | 65 ++ Task/Discordian-date/D/discordian-date.d | 55 ++ .../Euphoria/discordian-date.euphoria | 59 ++ Task/Discordian-date/Go/discordian-date-1.go | 133 +++ Task/Discordian-date/Go/discordian-date-2.go | 43 + .../Haskell/discordian-date.hs | 14 + .../JavaScript/discordian-date-1.js | 49 ++ .../JavaScript/discordian-date-2.js | 8 + Task/Discordian-date/PHP/discordian-date.php | 62 ++ .../PicoLisp/discordian-date.l | 14 + .../Discordian-date/Python/discordian-date.py | 17 + .../Discordian-date/REXX/discordian-date.rexx | 30 + .../Discordian-date/Ruby/discordian-date-1.rb | 44 + .../Discordian-date/Ruby/discordian-date-2.rb | 4 + .../Scala/discordian-date.scala | 19 + .../Discordian-date/Tcl/discordian-date-1.tcl | 23 + .../Discordian-date/Tcl/discordian-date-2.tcl | 4 + Task/Distributed-programming/0DESCRIPTION | 5 + Task/Distributed-programming/1META.yaml | 2 + .../Ada/distributed-programming-1.ada | 5 + .../Ada/distributed-programming-2.ada | 13 + .../Ada/distributed-programming-3.ada | 9 + .../Ada/distributed-programming-4.ada | 13 + .../C/distributed-programming-1.c | 50 ++ .../C/distributed-programming-2.c | 11 + .../D/distributed-programming-1.d | 38 + .../D/distributed-programming-2.d | 24 + .../E/distributed-programming-1.e | 19 + .../E/distributed-programming-2.e | 14 + .../Erlang/distributed-programming-1.erl | 19 + .../Erlang/distributed-programming-2.erl | 17 + .../Go/distributed-programming-1.go | 30 + .../Go/distributed-programming-2.go | 23 + .../JavaScript/distributed-programming-1.js | 8 + .../JavaScript/distributed-programming-2.js | 12 + .../Perl/distributed-programming.pl | 43 + .../PicoLisp/distributed-programming-1.l | 9 + .../PicoLisp/distributed-programming-2.l | 6 + .../Python/distributed-programming-1.py | 38 + .../Python/distributed-programming-10.py | 12 + .../Python/distributed-programming-2.py | 23 + .../Python/distributed-programming-3.py | 30 + .../Python/distributed-programming-4.py | 15 + .../Python/distributed-programming-5.py | 57 ++ .../Python/distributed-programming-6.py | 55 ++ .../Python/distributed-programming-7.py | 26 + .../Python/distributed-programming-8.py | 17 + .../Python/distributed-programming-9.py | 18 + .../Ruby/distributed-programming-1.rb | 21 + .../Ruby/distributed-programming-2.rb | 14 + .../Tcl/distributed-programming-1.tcl | 63 ++ .../Tcl/distributed-programming-2.tcl | 36 + Task/Documentation/0DESCRIPTION | 1 + Task/Documentation/1META.yaml | 2 + Task/Documentation/Ada/documentation.ada | 25 + .../AutoHotkey/documentation.ahk | 17 + Task/Documentation/C/documentation.c | 13 + Task/Documentation/Clojure/documentation.clj | 7 + Task/Documentation/D/documentation.d | 29 + .../Documentation/Delphi/documentation.delphi | 10 + Task/Documentation/E/documentation.e | 8 + Task/Documentation/Eiffel/documentation-1.e | 88 ++ Task/Documentation/Eiffel/documentation-2.e | 63 ++ Task/Documentation/Go/documentation.go | 25 + Task/Documentation/Haskell/documentation-1.hs | 26 + Task/Documentation/Haskell/documentation-2.hs | 25 + Task/Documentation/Haskell/documentation-3.hs | 1 + Task/Documentation/Java/documentation.java | 22 + Task/Documentation/PicoLisp/documentation.l | 5 + Task/Documentation/Python/documentation-1.py | 8 + Task/Documentation/Python/documentation-2.py | 11 + Task/Documentation/R/documentation-1.r | 1 + Task/Documentation/R/documentation-2.r | 59 ++ Task/Documentation/REXX/documentation.rexx | 36 + Task/Documentation/Racket/documentation.rkt | 7 + Task/Documentation/Ruby/documentation.rb | 35 + Task/Documentation/Smalltalk/documentation.st | 1 + Task/Documentation/Tcl/documentation.tcl | 18 + Task/Dot-product/0DESCRIPTION | 8 + Task/Dot-product/ABAP/dot-product.abap | 26 + Task/Dot-product/ACL2/dot-product.acl2 | 5 + Task/Dot-product/ALGOL-68/dot-product.alg | 38 + Task/Dot-product/ActionScript/dot-product.as | 9 + Task/Dot-product/Ada/dot-product.ada | 19 + Task/Dot-product/AutoHotkey/dot-product.ahk | 17 + Task/Dot-product/BBC-BASIC/dot-product.bbc | 7 + Task/Dot-product/Bracmat/dot-product.bracmat | 7 + Task/Dot-product/C++/dot-product.cpp | 12 + Task/Dot-product/C/dot-product.c | 28 + Task/Dot-product/Clojure/dot-product.clj | 6 + .../CoffeeScript/dot-product.coffee | 13 + .../Common-Lisp/dot-product-1.lisp | 2 + .../Common-Lisp/dot-product-2.lisp | 2 + Task/Dot-product/D/dot-product-1.d | 5 + Task/Dot-product/D/dot-product-2.d | 9 + .../DWScript/dot-product-1.dwscript | 12 + .../DWScript/dot-product-2.dwscript | 4 + Task/Dot-product/Delphi/dot-product.delphi | 27 + Task/Dot-product/Ela/dot-product.ela | 6 + Task/Dot-product/Erlang/dot-product.erl | 7 + .../Euphoria/dot-product-1.euphoria | 11 + .../Euphoria/dot-product-2.euphoria | 5 + Task/Dot-product/Forth/dot-product.fth | 17 + Task/Dot-product/Fortran/dot-product.f | 5 + Task/Dot-product/Go/dot-product.go | 25 + Task/Dot-product/Haskell/dot-product.hs | 4 + Task/Dot-product/Java/dot-product.java | 20 + Task/Dot-product/JavaScript/dot-product.js | 11 + Task/Dot-product/Lua/dot-product.lua | 9 + Task/Dot-product/MATLAB/dot-product-1.m | 3 + Task/Dot-product/MATLAB/dot-product-2.m | 3 + Task/Dot-product/PHP/dot-product.php | 9 + Task/Dot-product/Perl/dot-product.pl | 13 + Task/Dot-product/PicoLisp/dot-product.l | 4 + Task/Dot-product/Prolog/dot-product.pro | 6 + Task/Dot-product/Python/dot-product.py | 7 + Task/Dot-product/R/dot-product.r | 16 + Task/Dot-product/REXX/dot-product.rexx | 32 + Task/Dot-product/Racket/dot-product.rkt | 7 + Task/Dot-product/Ruby/dot-product-1.rb | 4 + Task/Dot-product/Ruby/dot-product-2.rb | 8 + Task/Dot-product/Sather/dot-product.sa | 7 + Task/Dot-product/Scala/dot-product.scala | 12 + Task/Dot-product/Scheme/dot-product.ss | 5 + Task/Dot-product/Smalltalk/dot-product.st | 12 + Task/Dot-product/Tcl/dot-product.tcl | 7 + .../0DESCRIPTION | 7 + Task/Doubly-linked-list-Definition/1META.yaml | 2 + .../doubly-linked-list-definition.alg | 113 +++ .../C-sharp/doubly-linked-list-definition.cs | 42 + .../C/doubly-linked-list-definition-1.c | 157 ++++ .../C/doubly-linked-list-definition-2.c | 35 + .../doubly-linked-list-definition-1.clj | 111 +++ .../doubly-linked-list-definition-2.clj | 22 + .../doubly-linked-list-definition-1.lisp | 48 ++ .../doubly-linked-list-definition-2.lisp | 8 + .../D/doubly-linked-list-definition.d | 106 +++ .../E/doubly-linked-list-definition-1.e | 107 +++ .../E/doubly-linked-list-definition-2.e | 31 + .../Fortran/doubly-linked-list-definition.f | 207 +++++ .../Go/doubly-linked-list-definition.go | 13 + .../doubly-linked-list-definition-1.hs | 55 ++ .../doubly-linked-list-definition-2.hs | 5 + .../doubly-linked-list-definition-3.hs | 38 + .../doubly-linked-list-definition-4.hs | 7 + .../doubly-linked-list-definition-5.hs | 12 + .../PicoLisp/doubly-linked-list-definition.l | 10 + .../REXX/doubly-linked-list-definition.rexx | 70 ++ .../Tcl/doubly-linked-list-definition-1.tcl | 71 ++ .../Tcl/doubly-linked-list-definition-2.tcl | 26 + .../0DESCRIPTION | 1 + .../1META.yaml | 2 + .../doubly-linked-list-element-definition.alg | 26 + ...oubly-linked-list-element-definition-1.ada | 7 + ...oubly-linked-list-element-definition-2.ada | 23 + ...oubly-linked-list-element-definition-3.ada | 5 + .../doubly-linked-list-element-definition.bbc | 1 + .../C/doubly-linked-list-element-definition.c | 5 + .../doubly-linked-list-element-definition.clj | 4 + ...doubly-linked-list-element-definition.lisp | 2 + .../D/doubly-linked-list-element-definition.d | 4 + ...ubly-linked-list-element-definition.delphi | 13 + .../E/doubly-linked-list-element-definition.e | 14 + .../doubly-linked-list-element-definition.f | 8 + .../doubly-linked-list-element-definition.go | 4 + ...doubly-linked-list-element-definition-1.hs | 13 + ...doubly-linked-list-element-definition-2.hs | 6 + ...doubly-linked-list-element-definition.java | 42 + .../doubly-linked-list-element-definition.js | 27 + .../doubly-linked-list-element-definition.pl | 6 + .../doubly-linked-list-element-definition.l | 10 + .../doubly-linked-list-element-definition.py | 19 + ...doubly-linked-list-element-definition.rexx | 79 ++ .../doubly-linked-list-element-definition.rb | 20 + .../doubly-linked-list-element-definition.tcl | 20 + .../0DESCRIPTION | 3 + .../1META.yaml | 2 + .../doubly-linked-list-element-insertion.alg | 51 ++ ...doubly-linked-list-element-insertion-1.ada | 11 + ...doubly-linked-list-element-insertion-2.ada | 12 + ...doubly-linked-list-element-insertion-3.ada | 19 + .../doubly-linked-list-element-insertion.bbc | 20 + .../doubly-linked-list-element-insertion-1.c | 6 + .../doubly-linked-list-element-insertion-2.c | 8 + .../doubly-linked-list-element-insertion-3.c | 1 + .../doubly-linked-list-element-insertion.clj | 24 + .../D/doubly-linked-list-element-insertion.d | 41 + .../doubly-linked-list-element-insertion-1.e | 5 + .../doubly-linked-list-element-insertion-2.e | 1 + .../doubly-linked-list-element-insertion-1.f | 55 ++ .../doubly-linked-list-element-insertion-2.f | 21 + .../doubly-linked-list-element-insertion.go | 55 ++ .../doubly-linked-list-element-insertion-1.hs | 7 + .../doubly-linked-list-element-insertion-2.hs | 15 + .../doubly-linked-list-element-insertion.js | 16 + .../doubly-linked-list-element-insertion.pl | 25 + .../doubly-linked-list-element-insertion.l | 12 + .../doubly-linked-list-element-insertion.py | 5 + .../doubly-linked-list-element-insertion.rexx | 79 ++ .../doubly-linked-list-element-insertion.rb | 19 + ...doubly-linked-list-element-insertion-1.tcl | 18 + ...doubly-linked-list-element-insertion-2.tcl | 5 + .../Doubly-linked-list-Traversal/0DESCRIPTION | 1 + Task/Doubly-linked-list-Traversal/1META.yaml | 4 + .../Ada/doubly-linked-list-traversal.ada | 27 + .../doubly-linked-list-traversal.bbc | 37 + .../C-sharp/doubly-linked-list-traversal.cs | 27 + .../C/doubly-linked-list-traversal.c | 128 +++ .../Clojure/doubly-linked-list-traversal.clj | 18 + .../D/doubly-linked-list-traversal.d | 42 + .../doubly-linked-list-traversal.delphi | 26 + .../E/doubly-linked-list-traversal-1.e | 19 + .../E/doubly-linked-list-traversal-2.e | 14 + .../Fortran/doubly-linked-list-traversal.f | 48 ++ .../Go/doubly-linked-list-traversal.go | 62 ++ .../Haskell/doubly-linked-list-traversal.hs | 19 + .../Java/doubly-linked-list-traversal.java | 13 + .../doubly-linked-list-traversal.js | 17 + .../PicoLisp/doubly-linked-list-traversal.l | 11 + .../Python/doubly-linked-list-traversal-1.py | 29 + .../Python/doubly-linked-list-traversal-2.py | 5 + .../REXX/doubly-linked-list-traversal.rexx | 79 ++ .../Ruby/doubly-linked-list-traversal.rb | 15 + .../Tcl/doubly-linked-list-traversal.tcl | 24 + Task/Draw-a-cuboid/0DESCRIPTION | 1 + Task/Draw-a-cuboid/1META.yaml | 4 + Task/Draw-a-cuboid/Ada/draw-a-cuboid.ada | 55 ++ .../Draw-a-cuboid/BBC-BASIC/draw-a-cuboid.bbc | 10 + .../Draw-a-cuboid/Brlcad/draw-a-cuboid.brlcad | 3 + Task/Draw-a-cuboid/C/draw-a-cuboid-1.c | 136 +++ Task/Draw-a-cuboid/C/draw-a-cuboid-2.c | 28 + Task/Draw-a-cuboid/D/draw-a-cuboid.d | 27 + Task/Draw-a-cuboid/Go/draw-a-cuboid.go | 35 + Task/Draw-a-cuboid/Haskell/draw-a-cuboid.hs | 60 ++ Task/Draw-a-cuboid/Perl/draw-a-cuboid-1.pl | 38 + Task/Draw-a-cuboid/Perl/draw-a-cuboid-2.pl | 34 + Task/Draw-a-cuboid/PicoLisp/draw-a-cuboid-1.l | 19 + Task/Draw-a-cuboid/PicoLisp/draw-a-cuboid-2.l | 59 ++ Task/Draw-a-cuboid/Prolog/draw-a-cuboid.pro | 78 ++ Task/Draw-a-cuboid/Python/draw-a-cuboid.py | 26 + Task/Draw-a-cuboid/REXX/draw-a-cuboid.rexx | 20 + Task/Draw-a-cuboid/Tcl/draw-a-cuboid-1.tcl | 79 ++ Task/Draw-a-cuboid/Tcl/draw-a-cuboid-2.tcl | 11 + Task/Draw-a-sphere/0DESCRIPTION | 1 + Task/Draw-a-sphere/1META.yaml | 3 + Task/Draw-a-sphere/Ada/draw-a-sphere.ada | 30 + Task/Draw-a-sphere/BASIC/draw-a-sphere-1.bas | 19 + Task/Draw-a-sphere/BASIC/draw-a-sphere-2.bas | 1 + .../Draw-a-sphere/BBC-BASIC/draw-a-sphere.bbc | 117 +++ .../Draw-a-sphere/Brlcad/draw-a-sphere.brlcad | 3 + Task/Draw-a-sphere/C/draw-a-sphere-1.c | 57 ++ Task/Draw-a-sphere/C/draw-a-sphere-2.c | 61 ++ Task/Draw-a-sphere/C/draw-a-sphere-3.c | 162 ++++ Task/Draw-a-sphere/D/draw-a-sphere.d | 39 + .../DWScript/draw-a-sphere.dwscript | 55 ++ .../Draw-a-sphere/Delphi/draw-a-sphere.delphi | 70 ++ Task/Draw-a-sphere/Go/draw-a-sphere.go | 68 ++ Task/Draw-a-sphere/Haskell/draw-a-sphere-1.hs | 48 ++ Task/Draw-a-sphere/Haskell/draw-a-sphere-2.hs | 7 + Task/Draw-a-sphere/Java/draw-a-sphere.java | 43 + Task/Draw-a-sphere/Lua/draw-a-sphere.lua | 37 + Task/Draw-a-sphere/PicoLisp/draw-a-sphere-1.l | 26 + Task/Draw-a-sphere/PicoLisp/draw-a-sphere-2.l | 60 ++ Task/Draw-a-sphere/Python/draw-a-sphere-1.py | 32 + Task/Draw-a-sphere/Python/draw-a-sphere-2.py | 777 ++++++++++++++++++ Task/Draw-a-sphere/REXX/draw-a-sphere.rexx | 39 + Task/Draw-a-sphere/Racket/draw-a-sphere.rkt | 4 + Task/Draw-a-sphere/Ruby/draw-a-sphere.rb | 28 + Task/Draw-a-sphere/Smalltalk/draw-a-sphere.st | 63 ++ Task/Draw-a-sphere/Tcl/draw-a-sphere.tcl | 9 + Task/Dutch-national-flag-problem/0DESCRIPTION | 12 + .../Ada/dutch-national-flag-problem.ada | 99 +++ .../AutoIt/dutch-national-flag-problem.autoit | 24 + .../BBC-BASIC/dutch-national-flag-problem.bbc | 38 + .../C++/dutch-national-flag-problem.cpp | 41 + .../D/dutch-national-flag-problem-1.d | 31 + .../D/dutch-national-flag-problem-2.d | 72 ++ .../Erlang/dutch-national-flag-problem-1.erl | 26 + .../Erlang/dutch-national-flag-problem-2.erl | 6 + .../Go/dutch-national-flag-problem.go | 88 ++ .../Haskell/dutch-national-flag-problem-1.hs | 26 + .../Haskell/dutch-national-flag-problem-2.hs | 23 + .../PicoLisp/dutch-national-flag-problem.l | 13 + .../Prolog/dutch-national-flag-problem-1.pro | 59 ++ .../Prolog/dutch-national-flag-problem-2.pro | 62 ++ .../Python/dutch-national-flag-problem-1.py | 35 + .../Python/dutch-national-flag-problem-2.py | 5 + .../Python/dutch-national-flag-problem-3.py | 3 + .../Python/dutch-national-flag-problem-4.py | 3 + .../Python/dutch-national-flag-problem-5.py | 50 ++ .../REXX/dutch-national-flag-problem-1.rexx | 33 + .../REXX/dutch-national-flag-problem-2.rexx | 30 + .../Ruby/dutch-national-flag-problem-1.rb | 60 ++ .../Ruby/dutch-national-flag-problem-2.rb | 9 + .../Tcl/dutch-national-flag-problem.tcl | 30 + Task/Dynamic-variable-names/0DESCRIPTION | 4 + Task/Dynamic-variable-names/1META.yaml | 2 + .../AutoHotkey/dynamic-variable-names.ahk | 4 + .../BASIC/dynamic-variable-names.bas | 2 + .../BBC-BASIC/dynamic-variable-names.bbc | 7 + .../Batch-File/dynamic-variable-names.bat | 14 + .../Bracmat/dynamic-variable-names.bracmat | 9 + .../Clojure/dynamic-variable-names.clj | 1 + .../Common-Lisp/dynamic-variable-names-1.lisp | 6 + .../Common-Lisp/dynamic-variable-names-2.lisp | 5 + .../E/dynamic-variable-names.e | 27 + .../Forth/dynamic-variable-names.fth | 3 + .../Haskell/dynamic-variable-names.hs | 6 + .../JavaScript/dynamic-variable-names.js | 3 + .../Lua/dynamic-variable-names.lua | 1 + .../PHP/dynamic-variable-names.php | 5 + .../Perl/dynamic-variable-names-1.pl | 7 + .../Perl/dynamic-variable-names-2.pl | 9 + .../PicoLisp/dynamic-variable-names.l | 6 + .../Python/dynamic-variable-names-1.py | 5 + .../Python/dynamic-variable-names-2.py | 5 + .../R/dynamic-variable-names.r | 10 + .../REXX/dynamic-variable-names.rexx | 7 + .../Ruby/dynamic-variable-names.rb | 4 + .../Scheme/dynamic-variable-names.ss | 8 + .../Smalltalk/dynamic-variable-names.st | 9 + .../Tcl/dynamic-variable-names-1.tcl | 4 + .../Tcl/dynamic-variable-names-2.tcl | 4 + .../Tcl/dynamic-variable-names-3.tcl | 5 + Task/Echo-server/0DESCRIPTION | 5 + Task/Echo-server/1META.yaml | 2 + Task/Echo-server/Ada/echo-server.ada | 38 + Task/Echo-server/AutoHotkey/echo-server.ahk | 200 +++++ Task/Echo-server/BBC-BASIC/echo-server.bbc | 54 ++ Task/Echo-server/C/echo-server.c | 118 +++ Task/Echo-server/Clojure/echo-server.clj | 7 + .../CoffeeScript/echo-server.coffee | 17 + .../Common-Lisp/echo-server-1.lisp | 47 ++ .../Common-Lisp/echo-server-2.lisp | 38 + .../Common-Lisp/echo-server-3.lisp | 22 + Task/Echo-server/D/echo-server-1.d | 20 + Task/Echo-server/D/echo-server-2.d | 109 +++ Task/Echo-server/Delphi/echo-server.delphi | 58 ++ Task/Echo-server/Erlang/echo-server.erl | 23 + Task/Echo-server/Forth/echo-server.fth | 30 + Task/Echo-server/Go/echo-server.go | 29 + Task/Echo-server/Haskell/echo-server.hs | 25 + Task/Echo-server/Java/echo-server.java | 78 ++ Task/Echo-server/JavaScript/echo-server.js | 20 + Task/Echo-server/PHP/echo-server.php | 31 + Task/Echo-server/Perl/echo-server-1.pl | 29 + Task/Echo-server/Perl/echo-server-2.pl | 6 + Task/Echo-server/Perl/echo-server-3.pl | 6 + Task/Echo-server/PicoLisp/echo-server.l | 16 + Task/Echo-server/Python/echo-server.py | 33 + Task/Echo-server/Racket/echo-server.rkt | 8 + Task/Echo-server/Ruby/echo-server-1.rb | 20 + Task/Echo-server/Ruby/echo-server-2.rb | 18 + Task/Echo-server/Scheme/echo-server.ss | 41 + Task/Echo-server/Tcl/echo-server-1.tcl | 21 + Task/Echo-server/Tcl/echo-server-2.tcl | 16 + Task/Element-wise-operations/0DESCRIPTION | 3 + Task/Element-wise-operations/1META.yaml | 4 + .../ALGOL-68/element-wise-operations.alg | 54 ++ .../Ada/element-wise-operations-1.ada | 31 + .../Ada/element-wise-operations-2.ada | 16 + .../Ada/element-wise-operations-3.ada | 45 + .../BBC-BASIC/element-wise-operations.bbc | 53 ++ .../C/element-wise-operations.c | 14 + .../Clojure/element-wise-operations.clj | 8 + .../element-wise-operations-1.lisp | 19 + .../element-wise-operations-2.lisp | 19 + .../D/element-wise-operations.d | 40 + .../Go/element-wise-operations-1.go | 98 +++ .../Go/element-wise-operations-2.go | 91 ++ .../Perl/element-wise-operations-1.pl | 32 + .../Perl/element-wise-operations-2.pl | 23 + .../PicoLisp/element-wise-operations.l | 5 + .../Python/element-wise-operations.py | 43 + .../R/element-wise-operations.r | 12 + .../REXX/element-wise-operations-1.rexx | 32 + .../REXX/element-wise-operations-2.rexx | 27 + .../Tcl/element-wise-operations.tcl | 40 + Task/Empty-directory/0DESCRIPTION | 3 + Task/Empty-directory/Ada/empty-directory.ada | 24 + .../BBC-BASIC/empty-directory.bbc | 17 + Task/Empty-directory/C/empty-directory.c | 40 + .../CoffeeScript/empty-directory.coffee | 7 + Task/Empty-directory/D/empty-directory.d | 12 + Task/Empty-directory/Go/empty-directory.go | 27 + .../Haskell/empty-directory-1.hs | 9 + .../Haskell/empty-directory-2.hs | 5 + .../Haskell/empty-directory-3.hs | 15 + .../Empty-directory/Java/empty-directory.java | 5 + Task/Empty-directory/MATLAB/empty-directory.m | 8 + Task/Empty-directory/PHP/empty-directory.php | 16 + .../Empty-directory/Perl/empty-directory-1.pl | 1 + .../Empty-directory/Perl/empty-directory-2.pl | 2 + .../PicoLisp/empty-directory.l | 1 + .../Empty-directory/Python/empty-directory.py | 5 + .../Racket/empty-directory.rkt | 2 + .../Empty-directory/Ruby/empty-directory-1.rb | 5 + .../Empty-directory/Ruby/empty-directory-2.rb | 8 + .../Scala/empty-directory.scala | 4 + Task/Empty-directory/Tcl/empty-directory.tcl | 6 + Task/Empty-program/0DESCRIPTION | 3 + Task/Empty-program/1META.yaml | 2 + .../ALGOL-68/empty-program-1.alg | 1 + .../ALGOL-68/empty-program-2.alg | 1 + Task/Empty-program/AWK/empty-program.awk | 1 + Task/Empty-program/Ada/empty-program.ada | 4 + Task/Empty-program/Agena/empty-program.agena | 0 Task/Empty-program/AmigaE/empty-program.amiga | 2 + .../AppleScript/empty-program.applescript | 1 + .../Empty-program/Argile/empty-program.argile | 0 .../AutoHotkey/empty-program.ahk | 1 + .../Empty-program/AutoIt/empty-program.autoit | 1 + Task/Empty-program/BASIC/empty-program-1.bas | 1 + Task/Empty-program/BASIC/empty-program-2.bas | 1 + .../Empty-program/BBC-BASIC/empty-program.bbc | 0 .../Batch-File/empty-program-1.bat | 0 .../Batch-File/empty-program-2.bat | 1 + .../Bracmat/empty-program-1.bracmat | 2 + .../Bracmat/empty-program-2.bracmat | 2 + .../Bracmat/empty-program-3.bracmat | 1 + .../Bracmat/empty-program-4.bracmat | 1 + .../Empty-program/Brlcad/empty-program.brlcad | 1 + Task/Empty-program/C++/empty-program.cpp | 11 + Task/Empty-program/C/empty-program-1.c | 4 + Task/Empty-program/C/empty-program-2.c | 4 + Task/Empty-program/C/empty-program-3.c | 3 + Task/Empty-program/COBOL/empty-program.cobol | 2 + Task/Empty-program/Clean/empty-program.clean | 3 + .../CoffeeScript/empty-program.coffee | 0 Task/Empty-program/D/empty-program.d | 1 + Task/Empty-program/Dart/empty-program.dart | 2 + Task/Empty-program/E/empty-program.e | 1 + Task/Empty-program/EGL/empty-program.egl | 6 + Task/Empty-program/Eiffel/empty-program.e | 12 + Task/Empty-program/Erlang/empty-program-1.erl | 1 + Task/Empty-program/Erlang/empty-program-2.erl | 1 + .../Euphoria/empty-program.euphoria | 0 Task/Empty-program/Forth/empty-program-1.fth | 0 Task/Empty-program/Forth/empty-program-2.fth | 1 + Task/Empty-program/Fortran/empty-program.f | 1 + Task/Empty-program/Go/empty-program.go | 2 + Task/Empty-program/Haskell/empty-program-1.hs | 1 + Task/Empty-program/Haskell/empty-program-2.hs | 1 + Task/Empty-program/Java/empty-program-1.java | 4 + Task/Empty-program/Java/empty-program-2.java | 4 + Task/Empty-program/Java/empty-program-3.java | 1 + Task/Empty-program/Java/empty-program-4.java | 4 + Task/Empty-program/Java/empty-program-5.java | 4 + Task/Empty-program/LaTeX/empty-program.tex | 3 + Task/Empty-program/Lua/empty-program.lua | 0 Task/Empty-program/MATLAB/empty-program.m | 1 + Task/Empty-program/PIR/empty-program.pir | 2 + Task/Empty-program/Perl/empty-program-1.pl | 2 + Task/Empty-program/Perl/empty-program-2.pl | 2 + Task/Empty-program/Perl/empty-program-3.pl | 2 + Task/Empty-program/Perl/empty-program-4.pl | 1 + Task/Empty-program/PicoLisp/empty-program.l | 1 + Task/Empty-program/REXX/empty-program-1.rexx | 1 + Task/Empty-program/REXX/empty-program-2.rexx | 1 + Task/Empty-program/REXX/empty-program-3.rexx | 1 + Task/Empty-program/Racket/empty-program.rkt | 1 + Task/Empty-program/Ruby/empty-program.rb | 1 + Task/Empty-program/Scala/empty-program.scala | 3 + Task/Empty-program/Scheme/empty-program.ss | 0 Task/Empty-program/Smalltalk/empty-program.st | 1 + Task/Empty-program/Tcl/empty-program.tcl | 0 Task/Empty-string/0DESCRIPTION | 10 + Task/Empty-string/ACL2/empty-string.acl2 | 1 + Task/Empty-string/AWK/empty-string.awk | 16 + Task/Empty-string/Ada/empty-string.ada | 15 + Task/Empty-string/AutoHotkey/empty-string.ahk | 20 + Task/Empty-string/BASIC/empty-string.bas | 4 + Task/Empty-string/BBC-BASIC/empty-string.bbc | 8 + .../Empty-string/Bracmat/empty-string.bracmat | 9 + Task/Empty-string/C++/empty-string.cpp | 11 + Task/Empty-string/C-sharp/empty-string.cs | 9 + Task/Empty-string/C/empty-string.c | 10 + Task/Empty-string/Clojure/empty-string.clj | 6 + .../CoffeeScript/empty-string.coffee | 12 + .../Common-Lisp/empty-string.lisp | 4 + Task/Empty-string/D/empty-string.d | 27 + .../DWScript/empty-string.dwscript | 11 + Task/Empty-string/Delphi/empty-string.delphi | 20 + Task/Empty-string/Erlang/empty-string.erl | 8 + .../Euphoria/empty-string.euphoria | 15 + Task/Empty-string/Forth/empty-string.fth | 3 + Task/Empty-string/Go/empty-string.go | 8 + Task/Empty-string/Haskell/empty-string.hs | 10 + Task/Empty-string/Java/empty-string.java | 6 + Task/Empty-string/Lua/empty-string.lua | 11 + Task/Empty-string/MATLAB/empty-string.m | 8 + Task/Empty-string/PHP/empty-string.php | 16 + Task/Empty-string/Perl/empty-string-1.pl | 6 + Task/Empty-string/Perl/empty-string-2.pl | 14 + Task/Empty-string/PicoLisp/empty-string.l | 14 + Task/Empty-string/Python/empty-string.py | 5 + Task/Empty-string/R/empty-string.r | 9 + Task/Empty-string/REXX/empty-string.rexx | 40 + Task/Empty-string/Racket/empty-string.rkt | 5 + Task/Empty-string/Ruby/empty-string-1.rb | 3 + Task/Empty-string/Ruby/empty-string-2.rb | 8 + Task/Empty-string/Ruby/empty-string-3.rb | 3 + Task/Empty-string/Ruby/empty-string-4.rb | 1 + Task/Empty-string/Scala/empty-string.scala | 10 + Task/Empty-string/Scheme/empty-string.ss | 3 + Task/Empty-string/Tcl/empty-string-1.tcl | 3 + Task/Empty-string/Tcl/empty-string-2.tcl | 3 + Task/Enforced-immutability/0DESCRIPTION | 2 + .../ACL2/enforced-immutability.acl2 | 1 + .../ALGOL-68/enforced-immutability.alg | 4 + .../Ada/enforced-immutability.ada | 2 + .../AutoHotkey/enforced-immutability.ahk | 23 + .../BASIC/enforced-immutability-1.bas | 1 + .../BASIC/enforced-immutability-2.bas | 1 + .../BBC-BASIC/enforced-immutability.bbc | 3 + .../C++/enforced-immutability-1.cpp | 22 + .../C++/enforced-immutability-2.cpp | 11 + .../C/enforced-immutability-1.c | 3 + .../C/enforced-immutability-2.c | 19 + .../Clojure/enforced-immutability.clj | 6 + .../D/enforced-immutability.d | 67 ++ .../Delphi/enforced-immutability.delphi | 3 + .../E/enforced-immutability-1.e | 3 + .../E/enforced-immutability-2.e | 5 + .../Ela/enforced-immutability-1.ela | 2 + .../Ela/enforced-immutability-2.ela | 1 + .../Ela/enforced-immutability-3.ela | 1 + .../Erlang/enforced-immutability-1.erl | 2 + .../Erlang/enforced-immutability-2.erl | 2 + .../Euphoria/enforced-immutability.euphoria | 3 + .../Go/enforced-immutability.go | 6 + .../Haskell/enforced-immutability.hs | 2 + .../Java/enforced-immutability-1.java | 4 + .../Java/enforced-immutability-2.java | 5 + .../Java/enforced-immutability-3.java | 25 + .../JavaScript/enforced-immutability.js | 2 + .../PHP/enforced-immutability-1.php | 2 + .../PHP/enforced-immutability-2.php | 2 + .../Perl/enforced-immutability-1.pl | 2 + .../Perl/enforced-immutability-2.pl | 11 + .../PicoLisp/enforced-immutability-1.l | 5 + .../PicoLisp/enforced-immutability-2.l | 5 + .../Python/enforced-immutability-1.py | 7 + .../Python/enforced-immutability-2.py | 26 + .../Ruby/enforced-immutability.rb | 2 + .../Scala/enforced-immutability.scala | 2 + .../Tcl/enforced-immutability-1.tcl | 10 + .../Tcl/enforced-immutability-2.tcl | 7 + Task/Entropy/D/entropy.d | 15 + Task/Entropy/Euler-Math-Toolbox/entropy.euler | 8 + Task/Enumerations/0DESCRIPTION | 1 + Task/Enumerations/1META.yaml | 2 + Task/Enumerations/ACL2/enumerations.acl2 | 22 + Task/Enumerations/ALGOL-68/enumerations-1.alg | 13 + Task/Enumerations/ALGOL-68/enumerations-2.alg | 24 + Task/Enumerations/AWK/enumerations.awk | 3 + Task/Enumerations/Ada/enumerations.ada | 2 + Task/Enumerations/AmigaE/enumerations.amiga | 7 + Task/Enumerations/AutoHotkey/enumerations.ahk | 3 + Task/Enumerations/BASIC/enumerations.bas | 16 + Task/Enumerations/C++/enumerations.cpp | 3 + Task/Enumerations/C/enumerations.c | 3 + Task/Enumerations/Clojure/enumerations.clj | 11 + .../Common-Lisp/enumerations-1.lisp | 8 + .../Common-Lisp/enumerations-2.lisp | 2 + Task/Enumerations/D/enumerations.d | 17 + .../DWScript/enumerations.dwscript | 2 + Task/Enumerations/Delphi/enumerations.delphi | 4 + Task/Enumerations/E/enumerations-1.e | 3 + Task/Enumerations/E/enumerations-2.e | 6 + Task/Enumerations/E/enumerations-3.e | 4 + Task/Enumerations/EGL/enumerations-1.egl | 27 + Task/Enumerations/EGL/enumerations-2.egl | 27 + Task/Enumerations/Forth/enumerations-1.fth | 4 + Task/Enumerations/Forth/enumerations-2.fth | 1 + Task/Enumerations/Forth/enumerations-3.fth | 1 + Task/Enumerations/Forth/enumerations-4.fth | 1 + Task/Enumerations/Forth/enumerations-5.fth | 2 + Task/Enumerations/Forth/enumerations-6.fth | 6 + Task/Enumerations/Forth/enumerations-7.fth | 4 + Task/Enumerations/Fortran/enumerations-1.f | 4 + Task/Enumerations/Fortran/enumerations-2.f | 3 + Task/Enumerations/Go/enumerations-1.go | 5 + Task/Enumerations/Go/enumerations-2.go | 5 + Task/Enumerations/Haskell/enumerations.hs | 1 + Task/Enumerations/Java/enumerations-1.java | 3 + Task/Enumerations/Java/enumerations-2.java | 6 + Task/Enumerations/JavaScript/enumerations.js | 1 + Task/Enumerations/Lua/enumerations-1.lua | 1 + Task/Enumerations/Lua/enumerations-2.lua | 1 + Task/Enumerations/MATLAB/enumerations.m | 5 + Task/Enumerations/PHP/enumerations.php | 18 + Task/Enumerations/Perl/enumerations.pl | 5 + Task/Enumerations/PicoLisp/enumerations-1.l | 2 + Task/Enumerations/PicoLisp/enumerations-2.l | 2 + Task/Enumerations/Python/enumerations-1.py | 1 + Task/Enumerations/Python/enumerations-2.py | 1 + Task/Enumerations/R/enumerations.r | 3 + Task/Enumerations/REXX/enumerations.rexx | 50 ++ Task/Enumerations/Ruby/enumerations.rb | 5 + Task/Enumerations/Scala/enumerations-1.scala | 4 + Task/Enumerations/Scala/enumerations-2.scala | 3 + Task/Enumerations/Scheme/enumerations.ss | 8 + Task/Enumerations/Tcl/enumerations-1.tcl | 4 + Task/Enumerations/Tcl/enumerations-2.tcl | 6 + Task/Equilibrium-index/0DESCRIPTION | 24 + .../ALGOL-68/equilibrium-index.alg | 25 + .../Ada/equilibrium-index-1.ada | 18 + .../Ada/equilibrium-index-2.ada | 20 + .../Ada/equilibrium-index-3.ada | 52 ++ .../Ada/equilibrium-index-4.ada | 68 ++ .../BBC-BASIC/equilibrium-index.bbc | 13 + .../C++/equilibrium-index.cpp | 40 + Task/Equilibrium-index/C/equilibrium-index.c | 44 + .../Clojure/equilibrium-index.clj | 8 + .../Equilibrium-index/D/equilibrium-index-1.d | 10 + .../Equilibrium-index/D/equilibrium-index-2.d | 18 + .../Euphoria/equilibrium-index.euphoria | 20 + .../Fortran/equilibrium-index.f | 19 + .../Equilibrium-index/Go/equilibrium-index.go | 36 + .../Haskell/equilibrium-index-1.hs | 11 + .../Haskell/equilibrium-index-2.hs | 2 + .../Haskell/equilibrium-index-3.hs | 2 + .../Java/equilibrium-index.java | 20 + .../MATLAB/equilibrium-index-1.m | 11 + .../MATLAB/equilibrium-index-2.m | 5 + .../PHP/equilibrium-index.php | 18 + .../Perl/equilibrium-index.pl | 15 + .../PicoLisp/equilibrium-index.l | 6 + .../Python/equilibrium-index-1.py | 9 + .../Python/equilibrium-index-2.py | 6 + .../Python/equilibrium-index-3.py | 4 + .../Python/equilibrium-index-4.py | 9 + .../Python/equilibrium-index-5.py | 10 + .../REXX/equilibrium-index.rexx | 33 + .../Ruby/equilibrium-index-1.rb | 7 + .../Ruby/equilibrium-index-2.rb | 14 + .../Ruby/equilibrium-index-3.rb | 14 + .../Tcl/equilibrium-index-1.tcl | 16 + .../Tcl/equilibrium-index-2.tcl | 2 + Task/Ethiopian-multiplication/0DESCRIPTION | 51 ++ Task/Ethiopian-multiplication/1META.yaml | 2 + .../ACL2/ethiopian-multiplication.acl2 | 18 + .../ALGOL-68/ethiopian-multiplication.alg | 29 + .../AWK/ethiopian-multiplication.awk | 31 + .../ethiopian-multiplication-1.as | 31 + .../ethiopian-multiplication-2.as | 6 + .../Ada/ethiopian-multiplication-1.ada | 3 + .../Ada/ethiopian-multiplication-2.ada | 31 + .../Ada/ethiopian-multiplication-3.ada | 11 + .../AutoHotkey/ethiopian-multiplication.ahk | 30 + .../AutoIt/ethiopian-multiplication.autoit | 39 + .../BASIC/ethiopian-multiplication.bas | 35 + .../BBC-BASIC/ethiopian-multiplication.bbc | 22 + .../C++/ethiopian-multiplication.cpp | 54 ++ .../C/ethiopian-multiplication.c | 32 + .../COBOL/ethiopian-multiplication.cobol | 93 +++ .../Clojure/ethiopian-multiplication.clj | 25 + .../ethiopian-multiplication.coffee | 17 + .../ColdFusion/ethiopian-multiplication-1.cfm | 35 + .../ColdFusion/ethiopian-multiplication-2.cfm | 57 ++ .../Common-Lisp/ethiopian-multiplication.lisp | 8 + .../D/ethiopian-multiplication.d | 30 + .../E/ethiopian-multiplication.e | 13 + .../Ela/ethiopian-multiplication.ela | 8 + .../Erlang/ethiopian-multiplication.erl | 25 + .../ethiopian-multiplication.euphoria | 31 + .../Forth/ethiopian-multiplication.fth | 4 + .../Fortran/ethiopian-multiplication.f | 58 ++ .../Go/ethiopian-multiplication.go | 22 + .../Haskell/ethiopian-multiplication.hs | 15 + .../Java/ethiopian-multiplication-1.java | 41 + .../Java/ethiopian-multiplication-2.java | 51 ++ .../Java/ethiopian-multiplication-3.java | 27 + .../Lua/ethiopian-multiplication.lua | 28 + .../MATLAB/ethiopian-multiplication-1.m | 5 + .../MATLAB/ethiopian-multiplication-2.m | 5 + .../MATLAB/ethiopian-multiplication-3.m | 6 + .../MATLAB/ethiopian-multiplication-4.m | 15 + .../MATLAB/ethiopian-multiplication-5.m | 5 + .../PHP/ethiopian-multiplication-1.php | 33 + .../PHP/ethiopian-multiplication-2.php | 46 ++ .../Perl/ethiopian-multiplication.pl | 24 + .../PicoLisp/ethiopian-multiplication.l | 17 + .../Python/ethiopian-multiplication-1.py | 28 + .../Python/ethiopian-multiplication-2.py | 14 + .../Python/ethiopian-multiplication-3.py | 42 + .../R/ethiopian-multiplication.r | 19 + .../REXX/ethiopian-multiplication.rexx | 30 + .../Ruby/ethiopian-multiplication-1.rb | 26 + .../Ruby/ethiopian-multiplication-2.rb | 15 + .../SNUSP/ethiopian-multiplication.snusp | 11 + .../Scala/ethiopian-multiplication.scala | 24 + .../Scheme/ethiopian-multiplication.ss | 16 + .../Smalltalk/ethiopian-multiplication-1.st | 32 + .../Smalltalk/ethiopian-multiplication-2.st | 1 + .../Tcl/ethiopian-multiplication-1.tcl | 30 + .../Tcl/ethiopian-multiplication-2.tcl | 1 + Task/Euler-method/0DESCRIPTION | 50 ++ Task/Euler-method/1META.yaml | 2 + Task/Euler-method/ALGOL-68/euler-method.alg | 24 + Task/Euler-method/Ada/euler-method-1.ada | 11 + Task/Euler-method/Ada/euler-method-2.ada | 17 + Task/Euler-method/Ada/euler-method-3.ada | 18 + Task/Euler-method/BBC-BASIC/euler-method.bbc | 15 + Task/Euler-method/C++/euler-method.cpp | 32 + Task/Euler-method/C-sharp/euler-method.cs | 38 + Task/Euler-method/C/euler-method-1.c | 44 + Task/Euler-method/C/euler-method-2.c | 5 + Task/Euler-method/Clay/euler-method.clay | 16 + .../Common-Lisp/euler-method.lisp | 26 + Task/Euler-method/D/euler-method.d | 26 + .../Euler-Math-Toolbox/euler-method.euler | 21 + Task/Euler-method/Fortran/euler-method.f | 57 ++ Task/Euler-method/Go/euler-method.go | 68 ++ Task/Euler-method/Haskell/euler-method.hs | 15 + Task/Euler-method/Java/euler-method.java | 33 + Task/Euler-method/Lua/euler-method.lua | 22 + Task/Euler-method/Perl/euler-method.pl | 32 + Task/Euler-method/PicoLisp/euler-method.l | 14 + Task/Euler-method/Python/euler-method.py | 11 + Task/Euler-method/Ruby/euler-method.rb | 10 + Task/Euler-method/Scala/euler-method.scala | 29 + Task/Euler-method/Tcl/euler-method-1.tcl | 9 + Task/Euler-method/Tcl/euler-method-2.tcl | 7 + .../0DESCRIPTION | 6 + .../Evaluate-binomial-coefficients/1META.yaml | 2 + .../ACL2/evaluate-binomial-coefficients.acl2 | 7 + .../evaluate-binomial-coefficients.alg | 25 + .../Ada/evaluate-binomial-coefficients.ada | 27 + ...evaluate-binomial-coefficients.applescript | 17 + .../evaluate-binomial-coefficients.ahk | 12 + .../evaluate-binomial-coefficients.bbc | 20 + .../evaluate-binomial-coefficients.bracmat | 16 + .../evaluate-binomial-coefficients.blq | 2 + .../C++/evaluate-binomial-coefficients-1.cpp | 23 + .../C++/evaluate-binomial-coefficients-2.cpp | 5 + .../C/evaluate-binomial-coefficients-1.c | 27 + .../C/evaluate-binomial-coefficients-2.c | 1 + .../evaluate-binomial-coefficients.clj | 3 + .../evaluate-binomial-coefficients-1.coffee | 9 + .../evaluate-binomial-coefficients-2.coffee | 7 + .../evaluate-binomial-coefficients.lisp | 5 + .../D/evaluate-binomial-coefficients.d | 16 + .../evaluate-binomial-coefficients.delphi | 28 + .../Erlang/evaluate-binomial-coefficients.erl | 7 + .../Forth/evaluate-binomial-coefficients.fth | 4 + .../evaluate-binomial-coefficients-1.f | 31 + .../evaluate-binomial-coefficients-2.f | 1 + .../Go/evaluate-binomial-coefficients.go | 7 + .../evaluate-binomial-coefficients-1.hs | 2 + .../evaluate-binomial-coefficients-2.hs | 2 + .../evaluate-binomial-coefficients-3.hs | 2 + .../evaluate-binomial-coefficients-1.java | 17 + .../evaluate-binomial-coefficients-2.java | 13 + .../evaluate-binomial-coefficients.js | 7 + .../Lua/evaluate-binomial-coefficients.lua | 11 + .../MATLAB/evaluate-binomial-coefficients-1.m | 3 + .../MATLAB/evaluate-binomial-coefficients-2.m | 4 + .../MATLAB/evaluate-binomial-coefficients-3.m | 3 + .../MATLAB/evaluate-binomial-coefficients-4.m | 4 + .../MATLAB/evaluate-binomial-coefficients-5.m | 21 + .../MATLAB/evaluate-binomial-coefficients-6.m | 40 + .../PHP/evaluate-binomial-coefficients-1.php | 10 + .../PHP/evaluate-binomial-coefficients-2.php | 8 + .../Perl/evaluate-binomial-coefficients.pl | 8 + .../PicoLisp/evaluate-binomial-coefficients.l | 3 + .../evaluate-binomial-coefficients-1.py | 8 + .../evaluate-binomial-coefficients-2.py | 17 + .../R/evaluate-binomial-coefficients-1.r | 1 + .../R/evaluate-binomial-coefficients-2.r | 1 + .../REXX/evaluate-binomial-coefficients.rexx | 12 + .../Racket/evaluate-binomial-coefficients.rkt | 3 + .../Ruby/evaluate-binomial-coefficients-1.rb | 13 + .../Ruby/evaluate-binomial-coefficients-2.rb | 3 + .../evaluate-binomial-coefficients-1.scala | 11 + .../evaluate-binomial-coefficients-2.scala | 1 + .../evaluate-binomial-coefficients-3.scala | 8 + .../evaluate-binomial-coefficients-4.scala | 2 + .../evaluate-binomial-coefficients-5.scala | 6 + .../evaluate-binomial-coefficients-6.scala | 1 + .../evaluate-binomial-coefficients-1.ss | 12 + .../evaluate-binomial-coefficients-2.ss | 1 + .../Tcl/evaluate-binomial-coefficients-1.tcl | 17 + .../Tcl/evaluate-binomial-coefficients-2.tcl | 2 + Task/Even-or-odd/0815/even-or-odd.0815 | 2 + Task/Even-or-odd/0DESCRIPTION | 10 + Task/Even-or-odd/AWK/even-or-odd.awk | 7 + Task/Even-or-odd/Ada/even-or-odd.ada | 15 + Task/Even-or-odd/AutoHotkey/even-or-odd.ahk | 5 + Task/Even-or-odd/BASIC/even-or-odd.bas | 4 + Task/Even-or-odd/BBC-BASIC/even-or-odd.bbc | 13 + Task/Even-or-odd/Bracmat/even-or-odd.bracmat | 29 + Task/Even-or-odd/Brainf---/even-or-odd-1.bf | 8 + Task/Even-or-odd/Brainf---/even-or-odd-2.bf | 1 + Task/Even-or-odd/Burlesque/even-or-odd.blq | 1 + Task/Even-or-odd/C++/even-or-odd.cpp | 6 + Task/Even-or-odd/C/even-or-odd-1.c | 5 + Task/Even-or-odd/C/even-or-odd-2.c | 4 + Task/Even-or-odd/Clojure/even-or-odd.clj | 2 + Task/Even-or-odd/Common-Lisp/even-or-odd.lisp | 2 + Task/Even-or-odd/D/even-or-odd.d | 6 + .../DWScript/even-or-odd-1.dwscript | 1 + .../DWScript/even-or-odd-2.dwscript | 1 + .../DWScript/even-or-odd-3.dwscript | 1 + .../Even-or-odd/Euphoria/even-or-odd.euphoria | 5 + Task/Even-or-odd/Forth/even-or-odd.fth | 1 + Task/Even-or-odd/Go/even-or-odd.go | 48 ++ Task/Even-or-odd/Haskell/even-or-odd.hs | 8 + Task/Even-or-odd/Java/even-or-odd-1.java | 3 + Task/Even-or-odd/Java/even-or-odd-2.java | 3 + Task/Even-or-odd/Java/even-or-odd-3.java | 3 + Task/Even-or-odd/Java/even-or-odd-4.java | 3 + Task/Even-or-odd/Java/even-or-odd-5.java | 3 + Task/Even-or-odd/JavaScript/even-or-odd.js | 3 + Task/Even-or-odd/Lua/even-or-odd.lua | 9 + Task/Even-or-odd/MATLAB/even-or-odd-1.m | 2 + Task/Even-or-odd/MATLAB/even-or-odd-2.m | 2 + Task/Even-or-odd/MATLAB/even-or-odd-3.m | 2 + Task/Even-or-odd/PHP/even-or-odd.php | 7 + Task/Even-or-odd/Perl/even-or-odd-1.pl | 3 + Task/Even-or-odd/Perl/even-or-odd-2.pl | 1 + Task/Even-or-odd/PicoLisp/even-or-odd.l | 5 + Task/Even-or-odd/Python/even-or-odd-1.py | 9 + Task/Even-or-odd/Python/even-or-odd-2.py | 8 + Task/Even-or-odd/R/even-or-odd.r | 5 + Task/Even-or-odd/REXX/even-or-odd.rexx | 31 + Task/Even-or-odd/Racket/even-or-odd-1.rkt | 4 + Task/Even-or-odd/Racket/even-or-odd-2.rkt | 5 + Task/Even-or-odd/Ruby/even-or-odd-1.rb | 4 + Task/Even-or-odd/Ruby/even-or-odd-2.rb | 10 + Task/Even-or-odd/SNUSP/even-or-odd.snusp | 3 + Task/Even-or-odd/Scala/even-or-odd-1.scala | 2 + Task/Even-or-odd/Scala/even-or-odd-2.scala | 2 + Task/Even-or-odd/Scheme/even-or-odd.ss | 8 + Task/Even-or-odd/Tcl/even-or-odd.tcl | 9 + Task/Events/0DESCRIPTION | 23 + Task/Events/1META.yaml | 6 + Task/Events/Ada/events-1.ada | 7 + Task/Events/Ada/events-2.ada | 14 + Task/Events/Ada/events-3.ada | 18 + Task/Events/AutoHotkey/events.ahk | 11 + Task/Events/BBC-BASIC/events-1.bbc | 17 + Task/Events/BBC-BASIC/events-2.bbc | 16 + Task/Events/C/events.c | 19 + Task/Events/Delphi/events.delphi | 54 ++ Task/Events/E/events-1.e | 24 + Task/Events/E/events-2.e | 16 + Task/Events/Erlang/events-1.erl | 22 + Task/Events/Erlang/events-2.erl | 7 + Task/Events/Go/events.go | 23 + Task/Events/Haskell/events-1.hs | 11 + Task/Events/Haskell/events-2.hs | 11 + Task/Events/JavaScript/events-1.js | 10 + Task/Events/JavaScript/events-2.js | 10 + Task/Events/Perl/events-1.pl | 31 + Task/Events/Perl/events-2.pl | 15 + Task/Events/PicoLisp/events.l | 3 + Task/Events/Tcl/events-1.tcl | 54 ++ Task/Events/Tcl/events-2.tcl | 4 + Task/Evolutionary-algorithm/0DESCRIPTION | 13 + .../ALGOL-68/evolutionary-algorithm.alg | 70 ++ .../Ada/evolutionary-algorithm.ada | 124 +++ .../AutoHotkey/evolutionary-algorithm.ahk | 56 ++ .../BBC-BASIC/evolutionary-algorithm.bbc | 39 + .../C++/evolutionary-algorithm.cpp | 110 +++ .../C/evolutionary-algorithm-1.c | 67 ++ .../C/evolutionary-algorithm-2.c | 8 + .../Clojure/evolutionary-algorithm-1.clj | 7 + .../Clojure/evolutionary-algorithm-2.clj | 5 + .../Clojure/evolutionary-algorithm-3.clj | 6 + .../Common-Lisp/evolutionary-algorithm-1.lisp | 39 + .../Common-Lisp/evolutionary-algorithm-2.lisp | 23 + .../Common-Lisp/evolutionary-algorithm-3.lisp | 27 + .../D/evolutionary-algorithm-1.d | 33 + .../D/evolutionary-algorithm-2.d | 19 + .../E/evolutionary-algorithm.e | 44 + .../Erlang/evolutionary-algorithm.erl | 60 ++ .../Euphoria/evolutionary-algorithm.euphoria | 51 ++ .../Forth/evolutionary-algorithm.fth | 73 ++ .../Fortran/evolutionary-algorithm-1.f | 135 +++ .../Fortran/evolutionary-algorithm-2.f | 17 + .../Go/evolutionary-algorithm.go | 65 ++ .../Haskell/evolutionary-algorithm-1.hs | 48 ++ .../Haskell/evolutionary-algorithm-2.hs | 36 + .../Java/evolutionary-algorithm.java | 58 ++ .../JavaScript/evolutionary-algorithm.js | 230 ++++++ .../Lua/evolutionary-algorithm.lua | 52 ++ .../MATLAB/evolutionary-algorithm-1.m | 220 +++++ .../MATLAB/evolutionary-algorithm-2.m | 27 + .../Perl/evolutionary-algorithm.pl | 45 + .../PicoLisp/evolutionary-algorithm.l | 37 + .../Python/evolutionary-algorithm-1.py | 35 + .../Python/evolutionary-algorithm-2.py | 21 + .../R/evolutionary-algorithm.r | 52 ++ .../REXX/evolutionary-algorithm-1.rexx | 54 ++ .../REXX/evolutionary-algorithm-2.rexx | 35 + .../REXX/evolutionary-algorithm-3.rexx | 45 + .../Ruby/evolutionary-algorithm.rb | 40 + .../Scala/evolutionary-algorithm.scala | 37 + .../Smalltalk/evolutionary-algorithm.st | 116 +++ .../Tcl/evolutionary-algorithm-1.tcl | 55 ++ .../Tcl/evolutionary-algorithm-2.tcl | 70 ++ .../0DESCRIPTION | 8 + ...h-an-exception-thrown-in-a-nested-call.alg | 56 ++ ...h-an-exception-thrown-in-a-nested-call.ada | 31 + ...an-exception-thrown-in-a-nested-call-1.ahk | 24 + ...an-exception-thrown-in-a-nested-call-2.ahk | 30 + ...h-an-exception-thrown-in-a-nested-call.bbc | 26 + ...h-an-exception-thrown-in-a-nested-call.cpp | 28 + ...h-an-exception-thrown-in-a-nested-call-1.c | 73 ++ ...h-an-exception-thrown-in-a-nested-call-2.c | 10 + ...n-exception-thrown-in-a-nested-call-1.lisp | 18 + ...n-exception-thrown-in-a-nested-call-2.lisp | 6 + ...tch-an-exception-thrown-in-a-nested-call.d | 34 + ...exception-thrown-in-a-nested-call.dwscript | 30 + ...n-exception-thrown-in-a-nested-call.delphi | 43 + ...h-an-exception-thrown-in-a-nested-call.egl | 35 + ...tch-an-exception-thrown-in-a-nested-call.e | 38 + ...ch-an-exception-thrown-in-a-nested-call.go | 103 +++ ...-an-exception-thrown-in-a-nested-call-1.hs | 38 + ...-an-exception-thrown-in-a-nested-call-2.hs | 45 + ...-an-exception-thrown-in-a-nested-call.java | 29 + ...ch-an-exception-thrown-in-a-nested-call.js | 35 + ...h-an-exception-thrown-in-a-nested-call.lua | 33 + ...h-an-exception-thrown-in-a-nested-call-1.m | 31 + ...h-an-exception-thrown-in-a-nested-call-2.m | 10 + ...ch-an-exception-thrown-in-a-nested-call.pl | 18 + ...tch-an-exception-thrown-in-a-nested-call.l | 13 + ...ch-an-exception-thrown-in-a-nested-call.py | 17 + ...h-an-exception-thrown-in-a-nested-call-1.r | 15 + ...h-an-exception-thrown-in-a-nested-call-2.r | 2 + ...-an-exception-thrown-in-a-nested-call-1.rb | 25 + ...-an-exception-thrown-in-a-nested-call-2.rb | 3 + ...-an-exception-thrown-in-a-nested-call-3.rb | 1 + ...-an-exception-thrown-in-a-nested-call-1.st | 30 + ...-an-exception-thrown-in-a-nested-call-2.st | 43 + ...h-an-exception-thrown-in-a-nested-call.tcl | 26 + Task/Exceptions/0DESCRIPTION | 4 + Task/Exceptions/1META.yaml | 2 + Task/Exceptions/ALGOL-68/exceptions-1.alg | 6 + Task/Exceptions/ALGOL-68/exceptions-2.alg | 8 + Task/Exceptions/ALGOL-68/exceptions-3.alg | 5 + Task/Exceptions/ALGOL-68/exceptions-4.alg | 7 + Task/Exceptions/Ada/exceptions-1.ada | 1 + Task/Exceptions/Ada/exceptions-2.ada | 4 + Task/Exceptions/Ada/exceptions-3.ada | 6 + Task/Exceptions/Ada/exceptions-4.ada | 9 + Task/Exceptions/Ada/exceptions-5.ada | 12 + Task/Exceptions/Aikido/exceptions-1.aikido | 6 + Task/Exceptions/Aikido/exceptions-2.aikido | 7 + .../AppleScript/exceptions-1.applescript | 4 + .../AppleScript/exceptions-2.applescript | 7 + .../AppleScript/exceptions-3.applescript | 1 + Task/Exceptions/AutoHotkey/exceptions-1.ahk | 8 + Task/Exceptions/AutoHotkey/exceptions-2.ahk | 12 + Task/Exceptions/BBC-BASIC/exceptions.bbc | 10 + Task/Exceptions/C++/exceptions-1.cpp | 4 + Task/Exceptions/C++/exceptions-2.cpp | 5 + Task/Exceptions/C++/exceptions-3.cpp | 17 + Task/Exceptions/C++/exceptions-4.cpp | 17 + Task/Exceptions/C/exceptions-1.c | 27 + Task/Exceptions/C/exceptions-2.c | 82 ++ Task/Exceptions/Clojure/exceptions.clj | 8 + Task/Exceptions/ColdFusion/exceptions-1.cfm | 5 + Task/Exceptions/ColdFusion/exceptions-2.cfm | 4 + Task/Exceptions/Common-Lisp/exceptions.lisp | 14 + Task/Exceptions/D/exceptions.d | 35 + .../Exceptions/DWScript/exceptions-1.dwscript | 4 + .../Exceptions/DWScript/exceptions-2.dwscript | 11 + .../Exceptions/DWScript/exceptions-3.dwscript | 8 + Task/Exceptions/Delphi/exceptions-1.delphi | 4 + Task/Exceptions/Delphi/exceptions-2.delphi | 9 + Task/Exceptions/Delphi/exceptions-3.delphi | 8 + Task/Exceptions/E/exceptions-1.e | 15 + Task/Exceptions/E/exceptions-2.e | 8 + Task/Exceptions/E/exceptions-3.e | 15 + Task/Exceptions/E/exceptions-4.e | 8 + Task/Exceptions/E/exceptions-5.e | 11 + Task/Exceptions/Forth/exceptions-1.fth | 2 + Task/Exceptions/Forth/exceptions-2.fth | 4 + Task/Exceptions/Forth/exceptions-3.fth | 2 + Task/Exceptions/Forth/exceptions-4.fth | 1 + Task/Exceptions/Go/exceptions.go | 19 + Task/Exceptions/Haskell/exceptions-1.hs | 2 + Task/Exceptions/Haskell/exceptions-2.hs | 2 + Task/Exceptions/Haskell/exceptions-3.hs | 2 + Task/Exceptions/Haskell/exceptions-4.hs | 4 + Task/Exceptions/Haskell/exceptions-5.hs | 4 + Task/Exceptions/Haskell/exceptions-6.hs | 17 + Task/Exceptions/Java/exceptions-1.java | 7 + Task/Exceptions/Java/exceptions-2.java | 7 + Task/Exceptions/Java/exceptions-3.java | 15 + Task/Exceptions/Java/exceptions-4.java | 13 + Task/Exceptions/JavaScript/exceptions-1.js | 3 + Task/Exceptions/JavaScript/exceptions-2.js | 9 + Task/Exceptions/Lua/exceptions-1.lua | 1 + Task/Exceptions/Lua/exceptions-2.lua | 11 + Task/Exceptions/Lua/exceptions-3.lua | 8 + Task/Exceptions/Lua/exceptions-4.lua | 6 + Task/Exceptions/MATLAB/exceptions.m | 2 + Task/Exceptions/PHP/exceptions-1.php | 4 + Task/Exceptions/PHP/exceptions-2.php | 4 + Task/Exceptions/PHP/exceptions-3.php | 5 + Task/Exceptions/Perl/exceptions-1.pl | 11 + Task/Exceptions/Perl/exceptions-2.pl | 2 + Task/Exceptions/Perl/exceptions-3.pl | 6 + Task/Exceptions/Perl/exceptions-4.pl | 2 + Task/Exceptions/PicoLisp/exceptions.l | 4 + Task/Exceptions/Python/exceptions-1.py | 4 + Task/Exceptions/Python/exceptions-2.py | 2 + Task/Exceptions/Python/exceptions-3.py | 2 + Task/Exceptions/Python/exceptions-4.py | 2 + Task/Exceptions/Python/exceptions-5.py | 2 + Task/Exceptions/Python/exceptions-6.py | 10 + Task/Exceptions/Python/exceptions-7.py | 10 + Task/Exceptions/R/exceptions-1.r | 1 + Task/Exceptions/R/exceptions-2.r | 2 + Task/Exceptions/R/exceptions-3.r | 13 + Task/Exceptions/Racket/exceptions.rkt | 13 + Task/Exceptions/Ruby/exceptions-1.rb | 3 + Task/Exceptions/Ruby/exceptions-2.rb | 2 + Task/Exceptions/Ruby/exceptions-3.rb | 11 + Task/Exceptions/Ruby/exceptions-4.rb | 15 + Task/Exceptions/Ruby/exceptions-5.rb | 2 + Task/Exceptions/Ruby/exceptions-6.rb | 7 + Task/Exceptions/Scheme/exceptions.ss | 22 + Task/Exceptions/Smalltalk/exceptions-1.st | 5 + Task/Exceptions/Smalltalk/exceptions-2.st | 7 + Task/Exceptions/Smalltalk/exceptions-3.st | 9 + Task/Exceptions/Smalltalk/exceptions-4.st | 3 + Task/Exceptions/Tcl/exceptions.tcl | 15 + Task/Executable-library/0DESCRIPTION | 18 + .../Ada/executable-library-1.ada | 4 + .../Ada/executable-library-2.ada | 49 ++ .../Ada/executable-library-3.ada | 1 + .../Ada/executable-library-4.ada | 35 + .../AutoHotkey/executable-library-1.ahk | 28 + .../AutoHotkey/executable-library-2.ahk | 17 + .../BBC-BASIC/executable-library-1.bbc | 21 + .../BBC-BASIC/executable-library-2.bbc | 18 + .../C/executable-library-1.c | 7 + .../C/executable-library-2.c | 44 + .../C/executable-library-3.c | 20 + .../Perl/executable-library-1.pl | 26 + .../Perl/executable-library-2.pl | 11 + .../PicoLisp/executable-library-1.l | 20 + .../PicoLisp/executable-library-2.l | 11 + .../Python/executable-library-1.py | 12 + .../Python/executable-library-2.py | 13 + .../REXX/executable-library-1.rexx | 9 + .../REXX/executable-library-2.rexx | 16 + .../REXX/executable-library-3.rexx | 15 + .../Ruby/executable-library-1.rb | 26 + .../Ruby/executable-library-2.rb | 11 + .../Tcl/executable-library-1.tcl | 25 + .../Tcl/executable-library-2.tcl | 1 + .../Tcl/executable-library-3.tcl | 16 + Task/Execute-HQ9+/0DESCRIPTION | 1 + Task/Execute-HQ9+/AutoHotkey/execute-hq9+.ahk | 28 + Task/Execute-HQ9+/BBC-BASIC/execute-hq9+.bbc | 22 + Task/Execute-HQ9+/C++/execute-hq9+.cpp | 34 + Task/Execute-HQ9+/C-sharp/execute-hq9+.cs | 21 + Task/Execute-HQ9+/C/execute-hq9+.c | 34 + Task/Execute-HQ9+/Clojure/execute-hq9+.clj | 23 + Task/Execute-HQ9+/D/execute-hq9+.d | 36 + .../DWScript/execute-hq9+.dwscript | 28 + Task/Execute-HQ9+/Ela/execute-hq9+-1.ela | 21 + Task/Execute-HQ9+/Ela/execute-hq9+-2.ela | 19 + Task/Execute-HQ9+/Ela/execute-hq9+-3.ela | 2 + Task/Execute-HQ9+/Erlang/execute-hq9+.erl | 56 ++ Task/Execute-HQ9+/Forth/execute-hq9+.fth | 11 + Task/Execute-HQ9+/JavaScript/execute-hq9+.js | 23 + Task/Execute-HQ9+/PicoLisp/execute-hq9+.l | 15 + Task/Execute-HQ9+/REXX/execute-hq9+.rexx | 29 + Task/Execute-HQ9+/Scala/execute-hq9+.scala | 34 + Task/Execute-a-system-command/0DESCRIPTION | 1 + Task/Execute-a-system-command/1META.yaml | 2 + .../ALGOL-68/execute-a-system-command-1.alg | 1 + .../ALGOL-68/execute-a-system-command-2.alg | 5 + .../AWK/execute-a-system-command.awk | 3 + .../Ada/execute-a-system-command-1.ada | 8 + .../Ada/execute-a-system-command-2.ada | 9 + .../Ada/execute-a-system-command-3.ada | 20 + .../Aikido/execute-a-system-command-1.aikido | 4 + .../Aikido/execute-a-system-command-2.aikido | 1 + .../Aikido/execute-a-system-command-3.aikido | 8 + .../Aime/execute-a-system-command.aime | 7 + .../execute-a-system-command.applescript | 1 + .../AutoHotkey/execute-a-system-command.ahk | 1 + .../BASIC/execute-a-system-command.bas | 1 + .../BBC-BASIC/execute-a-system-command-1.bbc | 1 + .../BBC-BASIC/execute-a-system-command-2.bbc | 1 + .../BBC-BASIC/execute-a-system-command-3.bbc | 1 + .../Bracmat/execute-a-system-command.bracmat | 1 + .../Brat/execute-a-system-command.brat | 3 + .../Brlcad/execute-a-system-command.brlcad | 1 + .../C++/execute-a-system-command.cpp | 1 + .../C/execute-a-system-command.c | 7 + .../CMake/execute-a-system-command-1.cmake | 1 + .../CMake/execute-a-system-command-2.cmake | 7 + .../Clojure/execute-a-system-command-1.clj | 1 + .../Clojure/execute-a-system-command-2.clj | 18 + .../Clojure/execute-a-system-command-3.clj | 14 + .../execute-a-system-command-1.lisp | 1 + .../execute-a-system-command-2.lisp | 1 + .../execute-a-system-command-3.lisp | 1 + .../D/execute-a-system-command.d | 1 + .../DCL/execute-a-system-command-1.dcl | 1 + .../DCL/execute-a-system-command-2.dcl | 1 + .../Delphi/execute-a-system-command.delphi | 9 + .../E/execute-a-system-command.e | 10 + .../Erlang/execute-a-system-command.erl | 1 + .../Forth/execute-a-system-command.fth | 1 + .../Fortran/execute-a-system-command.f | 3 + .../Go/execute-a-system-command.go | 13 + .../Haskell/execute-a-system-command.hs | 3 + .../Java/execute-a-system-command-1.java | 15 + .../Java/execute-a-system-command-2.java | 39 + .../Java/execute-a-system-command-3.java | 64 ++ .../JavaScript/execute-a-system-command-1.js | 2 + .../JavaScript/execute-a-system-command-2.js | 10 + .../Lua/execute-a-system-command.lua | 6 + .../MATLAB/execute-a-system-command.m | 8 + .../PHP/execute-a-system-command-1.php | 2 + .../PHP/execute-a-system-command-2.php | 11 + .../Perl/execute-a-system-command.pl | 13 + .../PicoLisp/execute-a-system-command.l | 1 + .../Prolog/execute-a-system-command.pro | 1 + .../Python/execute-a-system-command-1.py | 3 + .../Python/execute-a-system-command-2.py | 5 + .../Python/execute-a-system-command-3.py | 3 + .../Python/execute-a-system-command-4.py | 4 + .../R/execute-a-system-command.r | 2 + .../REXX/execute-a-system-command.rexx | 1 + .../Ruby/execute-a-system-command.rb | 18 + .../Scala/execute-a-system-command.scala | 2 + .../Scheme/execute-a-system-command.ss | 1 + .../Smalltalk/execute-a-system-command.st | 1 + .../Tcl/execute-a-system-command-1.tcl | 1 + .../Tcl/execute-a-system-command-2.tcl | 1 + .../Tcl/execute-a-system-command-3.tcl | 1 + .../Tcl/execute-a-system-command-4.tcl | 1 + Task/Exponentiation-operator/0DESCRIPTION | 4 + Task/Exponentiation-operator/1META.yaml | 2 + .../ALGOL-68/exponentiation-operator-1.alg | 61 ++ .../ALGOL-68/exponentiation-operator-2.alg | 50 ++ .../AWK/exponentiation-operator.awk | 7 + .../Ada/exponentiation-operator-1.ada | 15 + .../Ada/exponentiation-operator-2.ada | 19 + .../Ada/exponentiation-operator-3.ada | 49 ++ .../AutoHotkey/exponentiation-operator.ahk | 9 + .../BASIC/exponentiation-operator.bas | 39 + .../BBC-BASIC/exponentiation-operator.bbc | 23 + .../Brat/exponentiation-operator.brat | 13 + .../C++/exponentiation-operator.cpp | 32 + .../C/exponentiation-operator.c | 43 + .../Clojure/exponentiation-operator.clj | 1 + .../exponentiation-operator-1.lisp | 4 + .../exponentiation-operator-2.lisp | 4 + .../exponentiation-operator-3.lisp | 4 + .../D/exponentiation-operator.d | 47 ++ .../E/exponentiation-operator.e | 11 + .../Erlang/exponentiation-operator-1.erl | 19 + .../Erlang/exponentiation-operator-2.erl | 21 + .../Forth/exponentiation-operator-1.fth | 2 + .../Forth/exponentiation-operator-2.fth | 8 + .../Fortran/exponentiation-operator.f | 51 ++ .../Go/exponentiation-operator.go | 77 ++ .../Haskell/exponentiation-operator-1.hs | 8 + .../Haskell/exponentiation-operator-2.hs | 2 + .../Haskell/exponentiation-operator-3.hs | 2 + .../Java/exponentiation-operator.java | 14 + .../JavaScript/exponentiation-operator.js | 12 + .../Lua/exponentiation-operator.lua | 26 + .../Perl/exponentiation-operator.pl | 26 + .../PicoLisp/exponentiation-operator.l | 8 + .../Python/exponentiation-operator.py | 22 + .../R/exponentiation-operator.r | 12 + .../REXX/exponentiation-operator.rexx | 38 + .../Ruby/exponentiation-operator-1.rb | 16 + .../Ruby/exponentiation-operator-2.rb | 5 + .../Ruby/exponentiation-operator-3.rb | 22 + .../Scala/exponentiation-operator-1.scala | 43 + .../Scala/exponentiation-operator-2.scala | 7 + .../Scheme/exponentiation-operator.ss | 15 + .../Smalltalk/exponentiation-operator.st | 16 + .../Tcl/exponentiation-operator.tcl | 10 + Task/Extend-your-language/0DESCRIPTION | 32 + .../C/extend-your-language-1.c | 16 + .../C/extend-your-language-2.c | 24 + .../C/extend-your-language-3.c | 9 + .../C/extend-your-language-4.c | 34 + .../Clay/extend-your-language.clay | 15 + .../Clojure/extend-your-language.clj | 5 + .../Common-Lisp/extend-your-language.lisp | 9 + .../D/extend-your-language.d | 32 + .../Delphi/extend-your-language-1.delphi | 15 + .../Delphi/extend-your-language-2.delphi | 10 + .../E/extend-your-language-1.e | 44 + .../E/extend-your-language-2.e | 11 + .../Forth/extend-your-language.fth | 14 + .../Haskell/extend-your-language.hs | 7 + .../Perl/extend-your-language-1.pl | 136 +++ .../Perl/extend-your-language-2.pl | 10 + .../PicoLisp/extend-your-language.l | 8 + .../R/extend-your-language-1.r | 8 + .../R/extend-your-language-2.r | 12 + .../R/extend-your-language-3.r | 10 + .../R/extend-your-language-4.r | 13 + .../Ruby/extend-your-language-1.rb | 23 + .../Ruby/extend-your-language-2.rb | 9 + .../Scala/extend-your-language-1.scala | 17 + .../Scala/extend-your-language-2.scala | 21 + .../Scheme/extend-your-language.ss | 7 + .../Tcl/extend-your-language-1.tcl | 15 + .../Tcl/extend-your-language-2.tcl | 9 + .../Tcl/extend-your-language-3.tcl | 8 + .../Tcl/extend-your-language-4.tcl | 6 + .../Tcl/extend-your-language-5.tcl | 8 + .../0DESCRIPTION | 10 + .../AWK/extreme-floating-point-values.awk | 34 + .../Ada/extreme-floating-point-values-1.ada | 1 + .../Ada/extreme-floating-point-values-2.ada | 29 + .../C/extreme-floating-point-values-1.c | 31 + .../C/extreme-floating-point-values-2.c | 31 + .../D/extreme-floating-point-values-1.d | 64 ++ .../D/extreme-floating-point-values-2.d | 13 + .../extreme-floating-point-values.delphi | 39 + .../extreme-floating-point-values.euphoria | 16 + .../Forth/extreme-floating-point-values.fth | 5 + .../Go/extreme-floating-point-values.go | 78 ++ .../Java/extreme-floating-point-values.java | 16 + .../Perl/extreme-floating-point-values-1.pl | 23 + .../Perl/extreme-floating-point-values-2.pl | 23 + .../PicoLisp/extreme-floating-point-values.l | 7 + .../Python/extreme-floating-point-values-1.py | 42 + .../Python/extreme-floating-point-values-2.py | 8 + .../R/extreme-floating-point-values.r | 3 + .../Ruby/extreme-floating-point-values.rb | 10 + .../Scheme/extreme-floating-point-values.ss | 9 + .../Tcl/extreme-floating-point-values-1.tcl | 16 + .../Tcl/extreme-floating-point-values-2.tcl | 7 + Task/FizzBuzz/C++/fizzbuzz-1.cpp | 18 + Task/FizzBuzz/C++/fizzbuzz-2.cpp | 19 + Task/FizzBuzz/C++/fizzbuzz-3.cpp | 48 ++ Task/FizzBuzz/C++/fizzbuzz-4.cpp | 164 ++++ Task/FizzBuzz/CLIPS/fizzbuzz.clips | 26 + Task/FizzBuzz/CMake/fizzbuzz.cmake | 13 + Task/FizzBuzz/COBOL/fizzbuzz-1.cobol | 36 + Task/FizzBuzz/COBOL/fizzbuzz-2.cobol | 16 + Task/FizzBuzz/Cduce/fizzbuzz.cduce | 18 + Task/FizzBuzz/Chef/fizzbuzz.chef | 187 +++++ Task/FizzBuzz/Clay/fizzbuzz.clay | 8 + Task/FizzBuzz/Clipper/fizzbuzz.clipper | 9 + Task/FizzBuzz/Common-Lisp/fizzbuzz.lisp | 22 + Task/FizzBuzz/D/fizzbuzz.d | 35 + Task/FizzBuzz/DWScript/fizzbuzz.dwscript | 11 + Task/FizzBuzz/Dart/fizzbuzz.dart | 4 + Task/FizzBuzz/Delphi/fizzbuzz.delphi | 21 + Task/FizzBuzz/E/fizzbuzz.e | 8 + Task/FizzBuzz/Ela/fizzbuzz.ela | 8 + Task/FizzBuzz/Elixir/fizzbuzz.elixir | 12 + Task/FizzBuzz/Euphoria/fizzbuzz.euphoria | 33 + Task/Forest-fire/C-sharp/forest-fire.cs | 136 +++ .../Common-Lisp/forest-fire-1.lisp | 73 ++ .../Common-Lisp/forest-fire-2.lisp | 74 ++ Task/Forest-fire/D/forest-fire-1.d | 54 ++ Task/Forest-fire/D/forest-fire-2.d | 72 ++ Task/Infinity/C++/infinity.cpp | 9 + Task/Infinity/Common-Lisp/infinity.lisp | 13 + Task/Infinity/D/infinity.d | 5 + Task/Infinity/Delphi/infinity-1.delphi | 2 + Task/Infinity/Delphi/infinity-2.delphi | 1 + Task/Infinity/E/infinity.e | 3 + Task/Infinity/Euphoria/infinity.euphoria | 3 + Task/JSON/C++/json.cpp | 14 + Task/JSON/C-sharp/json.cs | 23 + Task/JSON/Cache-ObjectScript/json.cos | 10 + Task/JSON/Common-Lisp/json.lisp | 9 + Task/JSON/D/json.d | 6 + Task/JSON/EGL/json-1.egl | 15 + Task/JSON/EGL/json-2.egl | 22 + Task/JSON/EGL/json-3.egl | 25 + Task/JSON/EGL/json-4.egl | 15 + Task/Knuth-shuffle/C++/knuth-shuffle-1.cpp | 13 + Task/Knuth-shuffle/C++/knuth-shuffle-2.cpp | 11 + .../Knuth-shuffle/CMake/knuth-shuffle-1.cmake | 33 + .../Knuth-shuffle/CMake/knuth-shuffle-2.cmake | 4 + .../Common-Lisp/knuth-shuffle-1.lisp | 5 + .../Common-Lisp/knuth-shuffle-2.lisp | 16 + Task/Knuth-shuffle/D/knuth-shuffle-1.d | 7 + Task/Knuth-shuffle/D/knuth-shuffle-2.d | 12 + .../DWScript/knuth-shuffle.dwscript | 9 + Task/Knuth-shuffle/E/knuth-shuffle-1.e | 9 + Task/Knuth-shuffle/E/knuth-shuffle-2.e | 6 + .../Euphoria/knuth-shuffle.euphoria | 23 + Task/Narcissist/Common-Lisp/narcissist.lisp | 1 + Task/Narcissist/Deja-Vu/narcissist.djv | 1 + Task/Ordered-words/C++/ordered-words.cpp | 44 + .../Common-Lisp/ordered-words.lisp | 26 + Task/Ordered-words/D/ordered-words-1.d | 20 + Task/Ordered-words/D/ordered-words-2.d | 19 + Task/Ordered-words/D/ordered-words-3.d | 7 + Task/Ordered-words/D/ordered-words-4.d | 44 + .../Delphi/ordered-words-1.delphi | 54 ++ .../Delphi/ordered-words-2.delphi | 1 + Task/Ordered-words/E/ordered-words-1.e | 7 + Task/Ordered-words/E/ordered-words-2.e | 11 + .../Euphoria/ordered-words.euphoria | 36 + Task/Pi/C++/pi.cpp | 41 + Task/Pi/D/pi-1.d | 38 + Task/Pi/D/pi-2.d | 33 + Task/Quine/C++/quine.cpp | 40 + Task/Quine/C-sharp/quine.cs | 1 + Task/Quine/C1R/quine.c1r | 1 + Task/Quine/COBOL/quine-1.cobol | 339 ++++++++ Task/Quine/COBOL/quine-2.cobol | 48 ++ Task/Quine/Common-Lisp/quine-1.lisp | 2 + Task/Quine/Common-Lisp/quine-2.lisp | 1 + Task/Quine/Common-Lisp/quine-3.lisp | 1 + Task/Quine/Common-Lisp/quine-4.lisp | 1 + Task/Quine/Common-Lisp/quine-5.lisp | 1 + Task/Quine/Common-Lisp/quine-6.lisp | 1 + Task/Quine/D/quine.d | 3 + Task/Quine/Dao/quine.dao | 1 + Task/Quine/Deja-Vu/quine.djv | 2 + Task/Quine/E/quine.e | 1 + Task/Quine/Euphoria/quine.euphoria | 1 + Task/Search-a-list/C++/search-a-list.cpp | 112 +++ .../Common-Lisp/search-a-list.lisp | 6 + Task/Search-a-list/D/search-a-list.d | 18 + .../DWScript/search-a-list.dwscript | 11 + .../Search-a-list/Delphi/search-a-list.delphi | 36 + Task/Search-a-list/E/search-a-list.e | 12 + .../Euphoria/search-a-list.euphoria | 46 ++ 6144 files changed, 83610 insertions(+), 11 deletions(-) delete mode 100644 Conf/.lang.yaml.swp delete mode 100644 Conf/.task.yaml.swp create mode 120000 Lang/0815/Count-in-octal create mode 120000 Lang/0815/Even-or-odd create mode 120000 Lang/4DOS-Batch/Create-a-file create mode 120000 Lang/6502-Assembly/Conditional-structures create mode 120000 Lang/6502-Assembly/Conways-Game-of-Life create mode 120000 Lang/6502-Assembly/Create-an-object-at-a-given-address create mode 120000 Lang/ABAP/Character-codes create mode 120000 Lang/ABAP/Date-format create mode 120000 Lang/ABAP/Day-of-the-week create mode 120000 Lang/ABAP/Dot-product create mode 120000 Lang/ACL2/Character-codes create mode 120000 Lang/ACL2/Compound-data-type create mode 120000 Lang/ACL2/Conways-Game-of-Life create mode 120000 Lang/ACL2/Dot-product create mode 120000 Lang/ACL2/Empty-string create mode 120000 Lang/ACL2/Enforced-immutability create mode 120000 Lang/ACL2/Enumerations create mode 120000 Lang/ACL2/Ethiopian-multiplication create mode 120000 Lang/ACL2/Evaluate-binomial-coefficients create mode 120000 Lang/ALGOL-68/CSV-to-HTML-translation create mode 120000 Lang/ALGOL-68/Calendar-for-real-programmers create mode 120000 Lang/ALGOL-68/Character-codes create mode 120000 Lang/ALGOL-68/Character-matching create mode 120000 Lang/ALGOL-68/Cholesky-decomposition create mode 120000 Lang/ALGOL-68/Combinations create mode 120000 Lang/ALGOL-68/Command-line-arguments create mode 120000 Lang/ALGOL-68/Compound-data-type create mode 120000 Lang/ALGOL-68/Concurrent-computing create mode 120000 Lang/ALGOL-68/Constrained-random-points-on-a-circle create mode 120000 Lang/ALGOL-68/Count-in-octal create mode 120000 Lang/ALGOL-68/Count-occurrences-of-a-substring create mode 120000 Lang/ALGOL-68/Create-a-file create mode 120000 Lang/ALGOL-68/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/ALGOL-68/Date-format create mode 120000 Lang/ALGOL-68/Day-of-the-week create mode 120000 Lang/ALGOL-68/Dot-product create mode 120000 Lang/ALGOL-68/Doubly-linked-list-Definition create mode 120000 Lang/ALGOL-68/Doubly-linked-list-Element-definition create mode 120000 Lang/ALGOL-68/Doubly-linked-list-Element-insertion create mode 120000 Lang/ALGOL-68/Element-wise-operations create mode 120000 Lang/ALGOL-68/Empty-program create mode 120000 Lang/ALGOL-68/Enforced-immutability create mode 120000 Lang/ALGOL-68/Enumerations create mode 120000 Lang/ALGOL-68/Equilibrium-index create mode 120000 Lang/ALGOL-68/Ethiopian-multiplication create mode 120000 Lang/ALGOL-68/Euler-method create mode 120000 Lang/ALGOL-68/Evaluate-binomial-coefficients create mode 120000 Lang/ALGOL-68/Evolutionary-algorithm create mode 120000 Lang/ALGOL-68/Exceptions create mode 120000 Lang/ALGOL-68/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/ALGOL-68/Execute-a-system-command create mode 120000 Lang/ALGOL-68/Exponentiation-operator create mode 120000 Lang/APL/Create-a-file create mode 120000 Lang/APL/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/ATS/Continued-fraction create mode 120000 Lang/AWK/CSV-to-HTML-translation create mode 120000 Lang/AWK/Call-a-function create mode 120000 Lang/AWK/Case-sensitivity-of-identifiers create mode 120000 Lang/AWK/Character-codes create mode 120000 Lang/AWK/Combinations create mode 120000 Lang/AWK/Command-line-arguments create mode 120000 Lang/AWK/Compound-data-type create mode 120000 Lang/AWK/Conditional-structures create mode 120000 Lang/AWK/Conways-Game-of-Life create mode 120000 Lang/AWK/Count-in-octal create mode 120000 Lang/AWK/Count-occurrences-of-a-substring create mode 120000 Lang/AWK/Count-the-coins create mode 120000 Lang/AWK/Create-a-file create mode 120000 Lang/AWK/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/AWK/Create-an-HTML-table create mode 120000 Lang/AWK/Date-format create mode 120000 Lang/AWK/Day-of-the-week create mode 120000 Lang/AWK/Discordian-date create mode 120000 Lang/AWK/Empty-program create mode 120000 Lang/AWK/Empty-string create mode 120000 Lang/AWK/Enumerations create mode 120000 Lang/AWK/Ethiopian-multiplication create mode 120000 Lang/AWK/Even-or-odd create mode 120000 Lang/AWK/Execute-a-system-command create mode 120000 Lang/AWK/Exponentiation-operator create mode 120000 Lang/AWK/Extreme-floating-point-values create mode 120000 Lang/ActionScript/Call-a-function create mode 120000 Lang/ActionScript/Call-an-object-method create mode 120000 Lang/ActionScript/Character-codes create mode 120000 Lang/ActionScript/Compound-data-type create mode 120000 Lang/ActionScript/Dot-product create mode 120000 Lang/ActionScript/Ethiopian-multiplication create mode 120000 Lang/Ada/CRC-32 create mode 120000 Lang/Ada/CSV-to-HTML-translation create mode 120000 Lang/Ada/Calendar-for-real-programmers create mode 120000 Lang/Ada/Call-a-foreign-language-function create mode 120000 Lang/Ada/Call-a-function create mode 120000 Lang/Ada/Call-a-function-in-a-shared-library create mode 120000 Lang/Ada/Carmichael-3-strong-pseudoprimes create mode 120000 Lang/Ada/Case-sensitivity-of-identifiers create mode 120000 Lang/Ada/Character-codes create mode 120000 Lang/Ada/Character-matching create mode 120000 Lang/Ada/Chat-server create mode 120000 Lang/Ada/Cholesky-decomposition create mode 120000 Lang/Ada/Combinations create mode 120000 Lang/Ada/Combinations-with-repetitions create mode 120000 Lang/Ada/Command-line-arguments create mode 120000 Lang/Ada/Compile-time-calculation create mode 120000 Lang/Ada/Compound-data-type create mode 120000 Lang/Ada/Concurrent-computing create mode 120000 Lang/Ada/Conditional-structures create mode 120000 Lang/Ada/Constrained-genericity create mode 120000 Lang/Ada/Constrained-random-points-on-a-circle create mode 120000 Lang/Ada/Continued-fraction create mode 120000 Lang/Ada/Conways-Game-of-Life create mode 120000 Lang/Ada/Count-in-factors create mode 120000 Lang/Ada/Count-in-octal create mode 120000 Lang/Ada/Count-occurrences-of-a-substring create mode 120000 Lang/Ada/Count-the-coins create mode 120000 Lang/Ada/Create-a-file create mode 120000 Lang/Ada/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Ada/Create-an-HTML-table create mode 120000 Lang/Ada/Create-an-object-at-a-given-address create mode 120000 Lang/Ada/DNS-query create mode 120000 Lang/Ada/Date-format create mode 120000 Lang/Ada/Date-manipulation create mode 120000 Lang/Ada/Day-of-the-week create mode 120000 Lang/Ada/Deal-cards-for-FreeCell create mode 120000 Lang/Ada/Determine-if-only-one-instance-is-running create mode 120000 Lang/Ada/Digital-root create mode 120000 Lang/Ada/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/Ada/Dining-philosophers create mode 120000 Lang/Ada/Discordian-date create mode 120000 Lang/Ada/Distributed-programming create mode 120000 Lang/Ada/Documentation create mode 120000 Lang/Ada/Dot-product create mode 120000 Lang/Ada/Doubly-linked-list-Element-definition create mode 120000 Lang/Ada/Doubly-linked-list-Element-insertion create mode 120000 Lang/Ada/Doubly-linked-list-Traversal create mode 120000 Lang/Ada/Draw-a-cuboid create mode 120000 Lang/Ada/Draw-a-sphere create mode 120000 Lang/Ada/Dutch-national-flag-problem create mode 120000 Lang/Ada/Echo-server create mode 120000 Lang/Ada/Element-wise-operations create mode 120000 Lang/Ada/Empty-directory create mode 120000 Lang/Ada/Empty-program create mode 120000 Lang/Ada/Empty-string create mode 120000 Lang/Ada/Enforced-immutability create mode 120000 Lang/Ada/Enumerations create mode 120000 Lang/Ada/Equilibrium-index create mode 120000 Lang/Ada/Ethiopian-multiplication create mode 120000 Lang/Ada/Euler-method create mode 120000 Lang/Ada/Evaluate-binomial-coefficients create mode 120000 Lang/Ada/Even-or-odd create mode 120000 Lang/Ada/Events create mode 120000 Lang/Ada/Evolutionary-algorithm create mode 120000 Lang/Ada/Exceptions create mode 120000 Lang/Ada/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Ada/Executable-library create mode 120000 Lang/Ada/Execute-a-system-command create mode 120000 Lang/Ada/Exponentiation-operator create mode 120000 Lang/Ada/Extreme-floating-point-values create mode 120000 Lang/Agena/Empty-program create mode 120000 Lang/Aikido/Call-a-foreign-language-function create mode 120000 Lang/Aikido/Command-line-arguments create mode 120000 Lang/Aikido/Conditional-structures create mode 120000 Lang/Aikido/Create-a-file create mode 120000 Lang/Aikido/Create-an-object-at-a-given-address create mode 120000 Lang/Aikido/Exceptions create mode 120000 Lang/Aikido/Execute-a-system-command create mode 120000 Lang/Aime/Character-codes create mode 120000 Lang/Aime/Conditional-structures create mode 120000 Lang/Aime/Execute-a-system-command create mode 120000 Lang/AmbientTalk/Conditional-structures create mode 120000 Lang/AmigaE/Compound-data-type create mode 120000 Lang/AmigaE/Conditional-structures create mode 120000 Lang/AmigaE/Empty-program create mode 120000 Lang/AmigaE/Enumerations create mode 120000 Lang/AppleScript/Combinations create mode 120000 Lang/AppleScript/Command-line-arguments create mode 120000 Lang/AppleScript/Conditional-structures create mode 120000 Lang/AppleScript/Create-a-file create mode 120000 Lang/AppleScript/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/AppleScript/Date-manipulation create mode 120000 Lang/AppleScript/Day-of-the-week create mode 120000 Lang/AppleScript/Empty-program create mode 120000 Lang/AppleScript/Evaluate-binomial-coefficients create mode 120000 Lang/AppleScript/Exceptions create mode 120000 Lang/AppleScript/Execute-a-system-command create mode 120000 Lang/Argile/Empty-program create mode 120000 Lang/AutoHotkey/CSV-to-HTML-translation create mode 120000 Lang/AutoHotkey/Call-a-foreign-language-function create mode 120000 Lang/AutoHotkey/Call-a-function create mode 120000 Lang/AutoHotkey/Call-a-function-in-a-shared-library create mode 120000 Lang/AutoHotkey/Call-an-object-method create mode 120000 Lang/AutoHotkey/Case-sensitivity-of-identifiers create mode 120000 Lang/AutoHotkey/Character-codes create mode 120000 Lang/AutoHotkey/Character-matching create mode 120000 Lang/AutoHotkey/Colour-bars-Display create mode 120000 Lang/AutoHotkey/Colour-pinstripe-Display create mode 120000 Lang/AutoHotkey/Combinations create mode 120000 Lang/AutoHotkey/Command-line-arguments create mode 120000 Lang/AutoHotkey/Compare-sorting-algorithms-performance create mode 120000 Lang/AutoHotkey/Compound-data-type create mode 120000 Lang/AutoHotkey/Conditional-structures create mode 120000 Lang/AutoHotkey/Constrained-random-points-on-a-circle create mode 120000 Lang/AutoHotkey/Conways-Game-of-Life create mode 120000 Lang/AutoHotkey/Count-in-factors create mode 120000 Lang/AutoHotkey/Count-in-octal create mode 120000 Lang/AutoHotkey/Count-occurrences-of-a-substring create mode 120000 Lang/AutoHotkey/Count-the-coins create mode 120000 Lang/AutoHotkey/Create-a-file create mode 120000 Lang/AutoHotkey/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/AutoHotkey/Create-an-HTML-table create mode 120000 Lang/AutoHotkey/Create-an-object-at-a-given-address create mode 120000 Lang/AutoHotkey/Date-format create mode 120000 Lang/AutoHotkey/Date-manipulation create mode 120000 Lang/AutoHotkey/Day-of-the-week create mode 120000 Lang/AutoHotkey/Documentation create mode 120000 Lang/AutoHotkey/Dot-product create mode 120000 Lang/AutoHotkey/Dynamic-variable-names create mode 120000 Lang/AutoHotkey/Echo-server create mode 120000 Lang/AutoHotkey/Empty-program create mode 120000 Lang/AutoHotkey/Empty-string create mode 120000 Lang/AutoHotkey/Enforced-immutability create mode 120000 Lang/AutoHotkey/Enumerations create mode 120000 Lang/AutoHotkey/Ethiopian-multiplication create mode 120000 Lang/AutoHotkey/Evaluate-binomial-coefficients create mode 120000 Lang/AutoHotkey/Even-or-odd create mode 120000 Lang/AutoHotkey/Events create mode 120000 Lang/AutoHotkey/Evolutionary-algorithm create mode 120000 Lang/AutoHotkey/Exceptions create mode 120000 Lang/AutoHotkey/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/AutoHotkey/Executable-library create mode 120000 Lang/AutoHotkey/Execute-HQ9+ create mode 120000 Lang/AutoHotkey/Execute-a-system-command create mode 120000 Lang/AutoHotkey/Exponentiation-operator create mode 120000 Lang/AutoIt/CSV-to-HTML-translation create mode 120000 Lang/AutoIt/Character-matching create mode 120000 Lang/AutoIt/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/AutoIt/Day-of-the-week create mode 120000 Lang/AutoIt/Dutch-national-flag-problem create mode 120000 Lang/AutoIt/Empty-program create mode 120000 Lang/AutoIt/Ethiopian-multiplication create mode 120000 Lang/Axiom/Continued-fraction create mode 120000 Lang/BASIC/Character-codes create mode 120000 Lang/BASIC/Character-matching create mode 120000 Lang/BASIC/Command-line-arguments create mode 120000 Lang/BASIC/Compile-time-calculation create mode 120000 Lang/BASIC/Compound-data-type create mode 120000 Lang/BASIC/Conditional-structures create mode 120000 Lang/BASIC/Count-in-octal create mode 120000 Lang/BASIC/Count-occurrences-of-a-substring create mode 120000 Lang/BASIC/Create-a-file create mode 120000 Lang/BASIC/Date-format create mode 120000 Lang/BASIC/Digital-root create mode 120000 Lang/BASIC/Discordian-date create mode 120000 Lang/BASIC/Draw-a-sphere create mode 120000 Lang/BASIC/Dynamic-variable-names create mode 120000 Lang/BASIC/Empty-program create mode 120000 Lang/BASIC/Empty-string create mode 120000 Lang/BASIC/Enforced-immutability create mode 120000 Lang/BASIC/Enumerations create mode 120000 Lang/BASIC/Ethiopian-multiplication create mode 120000 Lang/BASIC/Even-or-odd create mode 120000 Lang/BASIC/Execute-a-system-command create mode 120000 Lang/BASIC/Exponentiation-operator create mode 120000 Lang/BASIC256/Conways-Game-of-Life create mode 120000 Lang/BBC-BASIC/CSV-to-HTML-translation create mode 120000 Lang/BBC-BASIC/Calendar-for-real-programmers create mode 120000 Lang/BBC-BASIC/Call-a-foreign-language-function create mode 120000 Lang/BBC-BASIC/Call-a-function-in-a-shared-library create mode 120000 Lang/BBC-BASIC/Case-sensitivity-of-identifiers create mode 120000 Lang/BBC-BASIC/Character-codes create mode 120000 Lang/BBC-BASIC/Character-matching create mode 120000 Lang/BBC-BASIC/Cholesky-decomposition create mode 120000 Lang/BBC-BASIC/Colour-bars-Display create mode 120000 Lang/BBC-BASIC/Colour-pinstripe-Display create mode 120000 Lang/BBC-BASIC/Colour-pinstripe-Printer create mode 120000 Lang/BBC-BASIC/Combinations create mode 120000 Lang/BBC-BASIC/Combinations-with-repetitions create mode 120000 Lang/BBC-BASIC/Command-line-arguments create mode 120000 Lang/BBC-BASIC/Compare-sorting-algorithms-performance create mode 120000 Lang/BBC-BASIC/Compound-data-type create mode 120000 Lang/BBC-BASIC/Concurrent-computing create mode 120000 Lang/BBC-BASIC/Conditional-structures create mode 120000 Lang/BBC-BASIC/Constrained-random-points-on-a-circle create mode 120000 Lang/BBC-BASIC/Continued-fraction create mode 120000 Lang/BBC-BASIC/Conways-Game-of-Life create mode 120000 Lang/BBC-BASIC/Count-in-factors create mode 120000 Lang/BBC-BASIC/Count-in-octal create mode 120000 Lang/BBC-BASIC/Count-occurrences-of-a-substring create mode 120000 Lang/BBC-BASIC/Count-the-coins create mode 120000 Lang/BBC-BASIC/Create-a-file create mode 120000 Lang/BBC-BASIC/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/BBC-BASIC/Create-an-HTML-table create mode 120000 Lang/BBC-BASIC/Create-an-object-at-a-given-address create mode 120000 Lang/BBC-BASIC/DNS-query create mode 120000 Lang/BBC-BASIC/Date-format create mode 120000 Lang/BBC-BASIC/Date-manipulation create mode 120000 Lang/BBC-BASIC/Day-of-the-week create mode 120000 Lang/BBC-BASIC/Deal-cards-for-FreeCell create mode 120000 Lang/BBC-BASIC/Deconvolution-1D create mode 120000 Lang/BBC-BASIC/Determine-if-only-one-instance-is-running create mode 120000 Lang/BBC-BASIC/Digital-root create mode 120000 Lang/BBC-BASIC/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/BBC-BASIC/Dining-philosophers create mode 120000 Lang/BBC-BASIC/Discordian-date create mode 120000 Lang/BBC-BASIC/Dot-product create mode 120000 Lang/BBC-BASIC/Doubly-linked-list-Element-definition create mode 120000 Lang/BBC-BASIC/Doubly-linked-list-Element-insertion create mode 120000 Lang/BBC-BASIC/Doubly-linked-list-Traversal create mode 120000 Lang/BBC-BASIC/Draw-a-cuboid create mode 120000 Lang/BBC-BASIC/Draw-a-sphere create mode 120000 Lang/BBC-BASIC/Dutch-national-flag-problem create mode 120000 Lang/BBC-BASIC/Dynamic-variable-names create mode 120000 Lang/BBC-BASIC/Echo-server create mode 120000 Lang/BBC-BASIC/Element-wise-operations create mode 120000 Lang/BBC-BASIC/Empty-directory create mode 120000 Lang/BBC-BASIC/Empty-program create mode 120000 Lang/BBC-BASIC/Empty-string create mode 120000 Lang/BBC-BASIC/Enforced-immutability create mode 120000 Lang/BBC-BASIC/Equilibrium-index create mode 120000 Lang/BBC-BASIC/Ethiopian-multiplication create mode 120000 Lang/BBC-BASIC/Euler-method create mode 120000 Lang/BBC-BASIC/Evaluate-binomial-coefficients create mode 120000 Lang/BBC-BASIC/Even-or-odd create mode 120000 Lang/BBC-BASIC/Events create mode 120000 Lang/BBC-BASIC/Evolutionary-algorithm create mode 120000 Lang/BBC-BASIC/Exceptions create mode 120000 Lang/BBC-BASIC/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/BBC-BASIC/Executable-library create mode 120000 Lang/BBC-BASIC/Execute-HQ9+ create mode 120000 Lang/BBC-BASIC/Execute-a-system-command create mode 120000 Lang/BBC-BASIC/Exponentiation-operator create mode 120000 Lang/Batch-File/Command-line-arguments create mode 120000 Lang/Batch-File/Create-a-file create mode 120000 Lang/Batch-File/Dynamic-variable-names create mode 120000 Lang/Batch-File/Empty-program create mode 120000 Lang/Befunge/Character-codes create mode 120000 Lang/Befunge/Conditional-structures create mode 120000 Lang/Bori/Conditional-structures create mode 120000 Lang/Bracmat/Character-matching create mode 120000 Lang/Bracmat/Combinations create mode 120000 Lang/Bracmat/Command-line-arguments create mode 120000 Lang/Bracmat/Compound-data-type create mode 120000 Lang/Bracmat/Conditional-structures create mode 120000 Lang/Bracmat/Count-in-octal create mode 120000 Lang/Bracmat/Count-occurrences-of-a-substring create mode 120000 Lang/Bracmat/Create-a-file create mode 120000 Lang/Bracmat/Deal-cards-for-FreeCell create mode 120000 Lang/Bracmat/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/Bracmat/Dot-product create mode 120000 Lang/Bracmat/Dynamic-variable-names create mode 120000 Lang/Bracmat/Empty-program create mode 120000 Lang/Bracmat/Empty-string create mode 120000 Lang/Bracmat/Evaluate-binomial-coefficients create mode 120000 Lang/Bracmat/Even-or-odd create mode 120000 Lang/Bracmat/Execute-a-system-command create mode 120000 Lang/Brainf---/Conditional-structures create mode 120000 Lang/Brainf---/Count-in-octal create mode 120000 Lang/Brainf---/Even-or-odd create mode 120000 Lang/Brat/Execute-a-system-command create mode 120000 Lang/Brat/Exponentiation-operator create mode 120000 Lang/Brlcad/Case-sensitivity-of-identifiers create mode 120000 Lang/Brlcad/Draw-a-cuboid create mode 120000 Lang/Brlcad/Draw-a-sphere create mode 120000 Lang/Brlcad/Empty-program create mode 120000 Lang/Brlcad/Execute-a-system-command create mode 120000 Lang/Burlesque/Conditional-structures create mode 120000 Lang/Burlesque/Evaluate-binomial-coefficients create mode 120000 Lang/Burlesque/Even-or-odd create mode 100644 Lang/C++-CLI/0DESCRIPTION create mode 120000 Lang/C++-CLI/Color-of-a-screen-pixel create mode 100644 Lang/C++/0DESCRIPTION create mode 120000 Lang/C++/100-doors create mode 120000 Lang/C++/24-game create mode 120000 Lang/C++/99-Bottles-of-Beer 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++/Ackermann-function create mode 120000 Lang/C++/Anagrams create mode 120000 Lang/C++/Animate-a-pendulum create mode 120000 Lang/C++/Anonymous-recursion create mode 120000 Lang/C++/Apply-a-callback-to-an-array create mode 120000 Lang/C++/Arena-storage-pool create mode 120000 Lang/C++/Arithmetic-Complex create mode 120000 Lang/C++/Arithmetic-Integer create mode 120000 Lang/C++/Arithmetic-Rational create mode 120000 Lang/C++/Arithmetic-evaluation create mode 120000 Lang/C++/Arithmetic-geometric-mean create mode 120000 Lang/C++/Array-concatenation create mode 120000 Lang/C++/Arrays create mode 120000 Lang/C++/Assertions create mode 120000 Lang/C++/Associative-array-Creation create mode 120000 Lang/C++/Associative-array-Iteration create mode 120000 Lang/C++/Averages-Arithmetic-mean create mode 120000 Lang/C++/Averages-Median create mode 120000 Lang/C++/Averages-Mode 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/C++/Balanced-brackets create mode 120000 Lang/C++/Binary-search create mode 120000 Lang/C++/Bitmap create mode 120000 Lang/C++/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/C++/Bitwise-operations create mode 120000 Lang/C++/Box-the-compass create mode 120000 Lang/C++/Break-OO-privacy create mode 120000 Lang/C++/Bulls-and-cows create mode 120000 Lang/C++/CSV-to-HTML-translation create mode 120000 Lang/C++/Caesar-cipher create mode 120000 Lang/C++/Call-a-foreign-language-function create mode 120000 Lang/C++/Call-an-object-method create mode 120000 Lang/C++/Character-codes create mode 120000 Lang/C++/Character-matching create mode 120000 Lang/C++/Check-that-file-exists create mode 120000 Lang/C++/Classes create mode 120000 Lang/C++/Collections create mode 120000 Lang/C++/Colour-bars-Display create mode 120000 Lang/C++/Combinations create mode 120000 Lang/C++/Command-line-arguments create mode 120000 Lang/C++/Comments create mode 120000 Lang/C++/Compile-time-calculation create mode 120000 Lang/C++/Compound-data-type create mode 120000 Lang/C++/Concurrent-computing create mode 120000 Lang/C++/Conditional-structures create mode 120000 Lang/C++/Continued-fraction create mode 120000 Lang/C++/Continued-fraction-Arithmetic-Construct-from-rational-number create mode 120000 Lang/C++/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) create mode 120000 Lang/C++/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2) create mode 120000 Lang/C++/Conways-Game-of-Life create mode 120000 Lang/C++/Count-in-octal create mode 120000 Lang/C++/Count-occurrences-of-a-substring create mode 120000 Lang/C++/Create-a-file create mode 120000 Lang/C++/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/C++/Create-an-HTML-table create mode 120000 Lang/C++/Create-an-object-at-a-given-address create mode 120000 Lang/C++/Date-format create mode 120000 Lang/C++/Date-manipulation create mode 120000 Lang/C++/Day-of-the-week create mode 120000 Lang/C++/Define-a-primitive-data-type create mode 120000 Lang/C++/Delegates create mode 120000 Lang/C++/Delete-a-file create mode 120000 Lang/C++/Determine-if-a-string-is-numeric create mode 120000 Lang/C++/Determine-if-only-one-instance-is-running create mode 120000 Lang/C++/Digital-root create mode 120000 Lang/C++/Dining-philosophers create mode 120000 Lang/C++/Dot-product create mode 120000 Lang/C++/Dutch-national-flag-problem create mode 120000 Lang/C++/Empty-program create mode 120000 Lang/C++/Empty-string create mode 120000 Lang/C++/Enforced-immutability create mode 120000 Lang/C++/Enumerations create mode 120000 Lang/C++/Equilibrium-index create mode 120000 Lang/C++/Ethiopian-multiplication create mode 120000 Lang/C++/Euler-method create mode 120000 Lang/C++/Evaluate-binomial-coefficients create mode 120000 Lang/C++/Even-or-odd create mode 120000 Lang/C++/Evolutionary-algorithm create mode 120000 Lang/C++/Exceptions create mode 120000 Lang/C++/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/C++/Execute-HQ9+ create mode 120000 Lang/C++/Execute-a-system-command create mode 120000 Lang/C++/Exponentiation-operator create mode 120000 Lang/C++/FizzBuzz create mode 120000 Lang/C++/Infinity create mode 120000 Lang/C++/JSON create mode 120000 Lang/C++/Knuth-shuffle create mode 120000 Lang/C++/Ordered-words create mode 120000 Lang/C++/Pi create mode 120000 Lang/C++/Quine create mode 120000 Lang/C++/Search-a-list create mode 100644 Lang/C-Shell/0DESCRIPTION create mode 100644 Lang/C-sharp/0DESCRIPTION create mode 120000 Lang/C-sharp/100-doors create mode 120000 Lang/C-sharp/99-Bottles-of-Beer create mode 120000 Lang/C-sharp/Abstract-type create mode 120000 Lang/C-sharp/Ackermann-function create mode 120000 Lang/C-sharp/Address-of-a-variable create mode 120000 Lang/C-sharp/Align-columns create mode 120000 Lang/C-sharp/Animate-a-pendulum create mode 120000 Lang/C-sharp/Animation create mode 120000 Lang/C-sharp/Apply-a-callback-to-an-array create mode 120000 Lang/C-sharp/Arbitrary-precision-integers-(included) create mode 120000 Lang/C-sharp/Arithmetic-Complex create mode 120000 Lang/C-sharp/Arithmetic-geometric-mean create mode 120000 Lang/C-sharp/Array-concatenation create mode 120000 Lang/C-sharp/Arrays create mode 120000 Lang/C-sharp/Assertions create mode 120000 Lang/C-sharp/Associative-array-Creation create mode 120000 Lang/C-sharp/Associative-array-Iteration create mode 120000 Lang/C-sharp/Atomic-updates create mode 120000 Lang/C-sharp/Averages-Arithmetic-mean create mode 120000 Lang/C-sharp/Break-OO-privacy create mode 120000 Lang/C-sharp/CSV-to-HTML-translation create mode 120000 Lang/C-sharp/Case-sensitivity-of-identifiers create mode 120000 Lang/C-sharp/Conways-Game-of-Life create mode 120000 Lang/C-sharp/Count-occurrences-of-a-substring create mode 120000 Lang/C-sharp/Create-an-HTML-table create mode 120000 Lang/C-sharp/DNS-query create mode 120000 Lang/C-sharp/Deepcopy create mode 120000 Lang/C-sharp/Delegates create mode 120000 Lang/C-sharp/Doubly-linked-list-Definition create mode 120000 Lang/C-sharp/Doubly-linked-list-Traversal create mode 120000 Lang/C-sharp/Empty-string create mode 120000 Lang/C-sharp/Euler-method create mode 120000 Lang/C-sharp/Execute-HQ9+ create mode 120000 Lang/C-sharp/Forest-fire create mode 120000 Lang/C-sharp/JSON create mode 120000 Lang/C-sharp/Quine create mode 120000 Lang/C/CRC-32 create mode 120000 Lang/C/CSV-to-HTML-translation create mode 120000 Lang/C/Call-a-function create mode 120000 Lang/C/Call-a-function-in-a-shared-library create mode 120000 Lang/C/Canny-edge-detector create mode 120000 Lang/C/Case-sensitivity-of-identifiers create mode 120000 Lang/C/Catmull-Clark-subdivision-surface create mode 120000 Lang/C/Character-codes create mode 120000 Lang/C/Character-matching create mode 120000 Lang/C/Chat-server create mode 120000 Lang/C/Cholesky-decomposition create mode 120000 Lang/C/Color-quantization create mode 120000 Lang/C/Combinations create mode 120000 Lang/C/Combinations-with-repetitions create mode 120000 Lang/C/Command-line-arguments create mode 120000 Lang/C/Compare-sorting-algorithms-performance create mode 120000 Lang/C/Compile-time-calculation create mode 120000 Lang/C/Compound-data-type create mode 120000 Lang/C/Concurrent-computing create mode 120000 Lang/C/Constrained-random-points-on-a-circle create mode 120000 Lang/C/Continued-fraction create mode 120000 Lang/C/Conways-Game-of-Life create mode 120000 Lang/C/Count-in-factors create mode 120000 Lang/C/Count-in-octal create mode 120000 Lang/C/Count-occurrences-of-a-substring create mode 120000 Lang/C/Count-the-coins create mode 120000 Lang/C/Create-a-file create mode 120000 Lang/C/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/C/Create-an-HTML-table create mode 120000 Lang/C/Create-an-object-at-a-given-address create mode 120000 Lang/C/Cut-a-rectangle create mode 120000 Lang/C/Date-format create mode 120000 Lang/C/Date-manipulation create mode 120000 Lang/C/Day-of-the-week create mode 120000 Lang/C/Deal-cards-for-FreeCell create mode 120000 Lang/C/Deconvolution-1D create mode 120000 Lang/C/Deconvolution-2D+ create mode 120000 Lang/C/Determine-if-only-one-instance-is-running create mode 120000 Lang/C/Digital-root create mode 120000 Lang/C/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/C/Dining-philosophers create mode 120000 Lang/C/Discordian-date create mode 120000 Lang/C/Distributed-programming create mode 120000 Lang/C/Documentation create mode 120000 Lang/C/Dot-product create mode 120000 Lang/C/Doubly-linked-list-Definition create mode 120000 Lang/C/Doubly-linked-list-Element-definition create mode 120000 Lang/C/Doubly-linked-list-Element-insertion create mode 120000 Lang/C/Doubly-linked-list-Traversal create mode 120000 Lang/C/Draw-a-cuboid create mode 120000 Lang/C/Draw-a-sphere create mode 120000 Lang/C/Echo-server create mode 120000 Lang/C/Element-wise-operations create mode 120000 Lang/C/Empty-directory create mode 120000 Lang/C/Empty-program create mode 120000 Lang/C/Empty-string create mode 120000 Lang/C/Enforced-immutability create mode 120000 Lang/C/Enumerations create mode 120000 Lang/C/Equilibrium-index create mode 120000 Lang/C/Ethiopian-multiplication create mode 120000 Lang/C/Euler-method create mode 120000 Lang/C/Evaluate-binomial-coefficients create mode 120000 Lang/C/Even-or-odd create mode 120000 Lang/C/Events create mode 120000 Lang/C/Evolutionary-algorithm create mode 120000 Lang/C/Exceptions create mode 120000 Lang/C/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/C/Executable-library create mode 120000 Lang/C/Execute-HQ9+ create mode 120000 Lang/C/Execute-a-system-command create mode 120000 Lang/C/Exponentiation-operator create mode 120000 Lang/C/Extend-your-language create mode 120000 Lang/C/Extreme-floating-point-values create mode 100644 Lang/C0H/0DESCRIPTION create mode 100644 Lang/C1R/0DESCRIPTION create mode 120000 Lang/C1R/100-doors create mode 120000 Lang/C1R/Quine create mode 100644 Lang/CB80/0DESCRIPTION create mode 100644 Lang/CLIPS/0DESCRIPTION create mode 120000 Lang/CLIPS/100-doors create mode 120000 Lang/CLIPS/99-Bottles-of-Beer create mode 120000 Lang/CLIPS/Ackermann-function create mode 120000 Lang/CLIPS/FizzBuzz create mode 100644 Lang/CMake/0DESCRIPTION create mode 120000 Lang/CMake/Boolean-values create mode 120000 Lang/CMake/Call-a-foreign-language-function create mode 120000 Lang/CMake/Conditional-structures create mode 120000 Lang/CMake/Execute-a-system-command create mode 120000 Lang/CMake/FizzBuzz create mode 120000 Lang/CMake/Knuth-shuffle create mode 100644 Lang/COBOL/0DESCRIPTION create mode 120000 Lang/COBOL/100-doors create mode 120000 Lang/COBOL/99-Bottles-of-Beer create mode 120000 Lang/COBOL/Address-of-a-variable create mode 120000 Lang/COBOL/Case-sensitivity-of-identifiers create mode 120000 Lang/COBOL/Comments create mode 120000 Lang/COBOL/Conditional-structures create mode 120000 Lang/COBOL/Create-an-object-at-a-given-address create mode 120000 Lang/COBOL/Empty-program create mode 120000 Lang/COBOL/Ethiopian-multiplication create mode 120000 Lang/COBOL/FizzBuzz create mode 120000 Lang/COBOL/Quine create mode 100644 Lang/Cache-ObjectScript/0DESCRIPTION create mode 120000 Lang/Cache-ObjectScript/DNS-query create mode 120000 Lang/Cache-ObjectScript/JSON create mode 100644 Lang/Caml/0DESCRIPTION create mode 100644 Lang/Cat/0DESCRIPTION create mode 100644 Lang/Cduce/0DESCRIPTION create mode 120000 Lang/Cduce/FizzBuzz create mode 100644 Lang/Cecil/0DESCRIPTION create mode 100644 Lang/Chapel/0DESCRIPTION create mode 120000 Lang/Chapel/99-Bottles-of-Beer create mode 100644 Lang/Chef/0DESCRIPTION create mode 120000 Lang/Chef/99-Bottles-of-Beer create mode 120000 Lang/Chef/Arithmetic-Integer create mode 120000 Lang/Chef/Averages-Arithmetic-mean create mode 120000 Lang/Chef/Comments create mode 120000 Lang/Chef/FizzBuzz create mode 100644 Lang/Cilk++/0DESCRIPTION create mode 100644 Lang/Cilk/0DESCRIPTION create mode 100644 Lang/Clay/0DESCRIPTION create mode 120000 Lang/Clay/99-Bottles-of-Beer create mode 120000 Lang/Clay/Accumulator-factory create mode 120000 Lang/Clay/Ackermann-function create mode 120000 Lang/Clay/Euler-method create mode 120000 Lang/Clay/Extend-your-language create mode 120000 Lang/Clay/FizzBuzz create mode 100644 Lang/Clean/0DESCRIPTION create mode 120000 Lang/Clean/Apply-a-callback-to-an-array create mode 120000 Lang/Clean/Boolean-values create mode 120000 Lang/Clean/Command-line-arguments create mode 120000 Lang/Clean/Comments create mode 120000 Lang/Clean/Compound-data-type create mode 120000 Lang/Clean/Conditional-structures create mode 120000 Lang/Clean/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Clean/Empty-program create mode 100644 Lang/Clipper-XBase++/0DESCRIPTION create mode 100644 Lang/Clipper/0DESCRIPTION create mode 120000 Lang/Clipper/FizzBuzz create mode 120000 Lang/Clojure/Character-codes create mode 120000 Lang/Clojure/Character-matching create mode 120000 Lang/Clojure/Combinations create mode 120000 Lang/Clojure/Combinations-with-repetitions create mode 120000 Lang/Clojure/Command-line-arguments create mode 120000 Lang/Clojure/Compile-time-calculation create mode 120000 Lang/Clojure/Compound-data-type create mode 120000 Lang/Clojure/Concurrent-computing create mode 120000 Lang/Clojure/Conditional-structures create mode 120000 Lang/Clojure/Constrained-random-points-on-a-circle create mode 120000 Lang/Clojure/Conways-Game-of-Life create mode 120000 Lang/Clojure/Count-in-octal create mode 120000 Lang/Clojure/Create-a-file create mode 120000 Lang/Clojure/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Clojure/DNS-query create mode 120000 Lang/Clojure/Date-format create mode 120000 Lang/Clojure/Date-manipulation create mode 120000 Lang/Clojure/Day-of-the-week create mode 120000 Lang/Clojure/Determine-if-only-one-instance-is-running create mode 120000 Lang/Clojure/Dining-philosophers create mode 120000 Lang/Clojure/Documentation create mode 120000 Lang/Clojure/Dot-product create mode 120000 Lang/Clojure/Doubly-linked-list-Definition create mode 120000 Lang/Clojure/Doubly-linked-list-Element-definition create mode 120000 Lang/Clojure/Doubly-linked-list-Element-insertion create mode 120000 Lang/Clojure/Doubly-linked-list-Traversal create mode 120000 Lang/Clojure/Dynamic-variable-names create mode 120000 Lang/Clojure/Echo-server create mode 120000 Lang/Clojure/Element-wise-operations create mode 120000 Lang/Clojure/Empty-string create mode 120000 Lang/Clojure/Enforced-immutability create mode 120000 Lang/Clojure/Enumerations create mode 120000 Lang/Clojure/Equilibrium-index create mode 120000 Lang/Clojure/Ethiopian-multiplication create mode 120000 Lang/Clojure/Evaluate-binomial-coefficients create mode 120000 Lang/Clojure/Even-or-odd create mode 120000 Lang/Clojure/Evolutionary-algorithm create mode 120000 Lang/Clojure/Exceptions create mode 120000 Lang/Clojure/Execute-HQ9+ create mode 120000 Lang/Clojure/Execute-a-system-command create mode 120000 Lang/Clojure/Exponentiation-operator create mode 120000 Lang/Clojure/Extend-your-language create mode 100644 Lang/Cobra/0DESCRIPTION create mode 120000 Lang/Cobra/Averages-Arithmetic-mean create mode 120000 Lang/CoffeeScript/CSV-to-HTML-translation create mode 120000 Lang/CoffeeScript/Case-sensitivity-of-identifiers create mode 120000 Lang/CoffeeScript/Character-codes create mode 120000 Lang/CoffeeScript/Character-matching create mode 120000 Lang/CoffeeScript/Chat-server create mode 120000 Lang/CoffeeScript/Combinations create mode 120000 Lang/CoffeeScript/Combinations-with-repetitions create mode 120000 Lang/CoffeeScript/Compound-data-type create mode 120000 Lang/CoffeeScript/Concurrent-computing create mode 120000 Lang/CoffeeScript/Conditional-structures create mode 120000 Lang/CoffeeScript/Constrained-random-points-on-a-circle create mode 120000 Lang/CoffeeScript/Continued-fraction create mode 120000 Lang/CoffeeScript/Count-in-factors create mode 120000 Lang/CoffeeScript/Count-in-octal create mode 120000 Lang/CoffeeScript/Count-occurrences-of-a-substring create mode 120000 Lang/CoffeeScript/Create-an-HTML-table create mode 120000 Lang/CoffeeScript/DNS-query create mode 120000 Lang/CoffeeScript/Date-format create mode 120000 Lang/CoffeeScript/Day-of-the-week create mode 120000 Lang/CoffeeScript/Dot-product create mode 120000 Lang/CoffeeScript/Echo-server create mode 120000 Lang/CoffeeScript/Empty-directory create mode 120000 Lang/CoffeeScript/Empty-program create mode 120000 Lang/CoffeeScript/Empty-string create mode 120000 Lang/CoffeeScript/Ethiopian-multiplication create mode 120000 Lang/CoffeeScript/Evaluate-binomial-coefficients create mode 100644 Lang/ColdFusion/0DESCRIPTION create mode 120000 Lang/ColdFusion/100-doors create mode 120000 Lang/ColdFusion/99-Bottles-of-Beer create mode 120000 Lang/ColdFusion/Associative-array-Creation create mode 120000 Lang/ColdFusion/Comments create mode 120000 Lang/ColdFusion/Conditional-structures create mode 120000 Lang/ColdFusion/Date-format create mode 120000 Lang/ColdFusion/Day-of-the-week create mode 120000 Lang/ColdFusion/Determine-if-a-string-is-numeric create mode 120000 Lang/ColdFusion/Ethiopian-multiplication create mode 120000 Lang/ColdFusion/Exceptions create mode 100644 Lang/Common-Lisp/0DESCRIPTION create mode 120000 Lang/Common-Lisp/100-doors create mode 120000 Lang/Common-Lisp/24-game create mode 120000 Lang/Common-Lisp/99-Bottles-of-Beer create mode 120000 Lang/Common-Lisp/A+B create mode 120000 Lang/Common-Lisp/Abstract-type create mode 120000 Lang/Common-Lisp/Accumulator-factory create mode 120000 Lang/Common-Lisp/Ackermann-function create mode 120000 Lang/Common-Lisp/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/Common-Lisp/Address-of-a-variable create mode 120000 Lang/Common-Lisp/Align-columns create mode 120000 Lang/Common-Lisp/Anagrams create mode 120000 Lang/Common-Lisp/Anagrams-Deranged-anagrams create mode 120000 Lang/Common-Lisp/Animation create mode 120000 Lang/Common-Lisp/Anonymous-recursion create mode 120000 Lang/Common-Lisp/Apply-a-callback-to-an-array create mode 120000 Lang/Common-Lisp/Arbitrary-precision-integers-(included) create mode 120000 Lang/Common-Lisp/Arithmetic-Complex create mode 120000 Lang/Common-Lisp/Arithmetic-Integer create mode 120000 Lang/Common-Lisp/Arithmetic-Rational create mode 120000 Lang/Common-Lisp/Arithmetic-evaluation create mode 120000 Lang/Common-Lisp/Arithmetic-geometric-mean create mode 120000 Lang/Common-Lisp/Array-concatenation create mode 120000 Lang/Common-Lisp/Arrays create mode 120000 Lang/Common-Lisp/Assertions create mode 120000 Lang/Common-Lisp/Associative-array-Creation create mode 120000 Lang/Common-Lisp/Associative-array-Iteration create mode 120000 Lang/Common-Lisp/Averages-Arithmetic-mean create mode 120000 Lang/Common-Lisp/Averages-Mean-angle create mode 120000 Lang/Common-Lisp/Averages-Median create mode 120000 Lang/Common-Lisp/Averages-Pythagorean-means create mode 120000 Lang/Common-Lisp/Averages-Root-mean-square create mode 120000 Lang/Common-Lisp/Averages-Simple-moving-average create mode 120000 Lang/Common-Lisp/Balanced-brackets create mode 120000 Lang/Common-Lisp/Balanced-ternary create mode 120000 Lang/Common-Lisp/Best-shuffle create mode 120000 Lang/Common-Lisp/Binary-search create mode 120000 Lang/Common-Lisp/Binary-strings create mode 120000 Lang/Common-Lisp/Bitmap create mode 120000 Lang/Common-Lisp/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Common-Lisp/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/Common-Lisp/Bitmap-Read-a-PPM-file create mode 120000 Lang/Common-Lisp/Bitmap-Write-a-PPM-file create mode 120000 Lang/Common-Lisp/Bitwise-operations create mode 120000 Lang/Common-Lisp/Break-OO-privacy create mode 120000 Lang/Common-Lisp/Bulls-and-cows create mode 120000 Lang/Common-Lisp/CRC-32 create mode 120000 Lang/Common-Lisp/CSV-to-HTML-translation create mode 120000 Lang/Common-Lisp/Caesar-cipher create mode 120000 Lang/Common-Lisp/Call-a-foreign-language-function create mode 120000 Lang/Common-Lisp/Call-a-function-in-a-shared-library create mode 120000 Lang/Common-Lisp/Case-sensitivity-of-identifiers create mode 120000 Lang/Common-Lisp/Character-codes create mode 120000 Lang/Common-Lisp/Check-that-file-exists create mode 120000 Lang/Common-Lisp/Cholesky-decomposition create mode 120000 Lang/Common-Lisp/Classes create mode 120000 Lang/Common-Lisp/Closest-pair-problem create mode 120000 Lang/Common-Lisp/Collections create mode 120000 Lang/Common-Lisp/Combinations create mode 120000 Lang/Common-Lisp/Command-line-arguments create mode 120000 Lang/Common-Lisp/Comments create mode 120000 Lang/Common-Lisp/Compile-time-calculation create mode 120000 Lang/Common-Lisp/Compound-data-type create mode 120000 Lang/Common-Lisp/Concurrent-computing create mode 120000 Lang/Common-Lisp/Conditional-structures create mode 120000 Lang/Common-Lisp/Constrained-genericity create mode 120000 Lang/Common-Lisp/Constrained-random-points-on-a-circle create mode 120000 Lang/Common-Lisp/Continued-fraction create mode 120000 Lang/Common-Lisp/Conways-Game-of-Life create mode 120000 Lang/Common-Lisp/Count-in-factors create mode 120000 Lang/Common-Lisp/Count-in-octal create mode 120000 Lang/Common-Lisp/Count-occurrences-of-a-substring create mode 120000 Lang/Common-Lisp/Count-the-coins create mode 120000 Lang/Common-Lisp/Create-a-file create mode 120000 Lang/Common-Lisp/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Common-Lisp/Cut-a-rectangle create mode 120000 Lang/Common-Lisp/DNS-query create mode 120000 Lang/Common-Lisp/Date-format create mode 120000 Lang/Common-Lisp/Day-of-the-week create mode 120000 Lang/Common-Lisp/Deal-cards-for-FreeCell create mode 120000 Lang/Common-Lisp/Deconvolution-1D create mode 120000 Lang/Common-Lisp/Deepcopy create mode 120000 Lang/Common-Lisp/Define-a-primitive-data-type create mode 120000 Lang/Common-Lisp/Delegates create mode 120000 Lang/Common-Lisp/Delete-a-file create mode 120000 Lang/Common-Lisp/Detect-division-by-zero create mode 120000 Lang/Common-Lisp/Determine-if-a-string-is-numeric create mode 120000 Lang/Common-Lisp/Dining-philosophers create mode 120000 Lang/Common-Lisp/Dot-product create mode 120000 Lang/Common-Lisp/Doubly-linked-list-Definition create mode 120000 Lang/Common-Lisp/Doubly-linked-list-Element-definition create mode 120000 Lang/Common-Lisp/Dynamic-variable-names create mode 120000 Lang/Common-Lisp/Echo-server create mode 120000 Lang/Common-Lisp/Element-wise-operations create mode 120000 Lang/Common-Lisp/Empty-string create mode 120000 Lang/Common-Lisp/Enumerations create mode 120000 Lang/Common-Lisp/Ethiopian-multiplication create mode 120000 Lang/Common-Lisp/Euler-method create mode 120000 Lang/Common-Lisp/Evaluate-binomial-coefficients create mode 120000 Lang/Common-Lisp/Even-or-odd create mode 120000 Lang/Common-Lisp/Evolutionary-algorithm create mode 120000 Lang/Common-Lisp/Exceptions create mode 120000 Lang/Common-Lisp/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Common-Lisp/Execute-a-system-command create mode 120000 Lang/Common-Lisp/Exponentiation-operator create mode 120000 Lang/Common-Lisp/Extend-your-language create mode 120000 Lang/Common-Lisp/FizzBuzz create mode 120000 Lang/Common-Lisp/Forest-fire create mode 120000 Lang/Common-Lisp/Infinity create mode 120000 Lang/Common-Lisp/JSON create mode 120000 Lang/Common-Lisp/Knuth-shuffle create mode 120000 Lang/Common-Lisp/Narcissist create mode 120000 Lang/Common-Lisp/Ordered-words create mode 120000 Lang/Common-Lisp/Quine create mode 120000 Lang/Common-Lisp/Search-a-list create mode 100644 Lang/Component-Pascal/0DESCRIPTION create mode 120000 Lang/Component-Pascal/Arrays create mode 120000 Lang/Component-Pascal/Assertions create mode 120000 Lang/Component-Pascal/Create-a-two-dimensional-array-at-runtime create mode 100644 Lang/Coq/0DESCRIPTION create mode 120000 Lang/Coq/Ackermann-function create mode 100644 Lang/Crack/0DESCRIPTION create mode 120000 Lang/Crack/Conditional-structures create mode 100644 Lang/Curry/0DESCRIPTION create mode 100644 Lang/D/0DESCRIPTION create mode 120000 Lang/D/100-doors create mode 120000 Lang/D/24-game create mode 120000 Lang/D/99-Bottles-of-Beer create mode 120000 Lang/D/A+B create mode 120000 Lang/D/Abstract-type create mode 120000 Lang/D/Accumulator-factory create mode 120000 Lang/D/Ackermann-function create mode 120000 Lang/D/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/D/Address-of-a-variable create mode 120000 Lang/D/Align-columns create mode 120000 Lang/D/Anagrams-Deranged-anagrams create mode 120000 Lang/D/Animation create mode 120000 Lang/D/Anonymous-recursion create mode 120000 Lang/D/Apply-a-callback-to-an-array create mode 120000 Lang/D/Arbitrary-precision-integers-(included) create mode 120000 Lang/D/Arithmetic-Complex create mode 120000 Lang/D/Arithmetic-Integer create mode 120000 Lang/D/Arithmetic-Rational create mode 120000 Lang/D/Arithmetic-evaluation create mode 120000 Lang/D/Arithmetic-geometric-mean create mode 120000 Lang/D/Array-concatenation create mode 120000 Lang/D/Arrays create mode 120000 Lang/D/Assertions create mode 120000 Lang/D/Associative-array-Creation create mode 120000 Lang/D/Associative-array-Iteration create mode 120000 Lang/D/Atomic-updates create mode 120000 Lang/D/Average-loop-length create mode 120000 Lang/D/Averages-Arithmetic-mean create mode 120000 Lang/D/Averages-Mean-angle create mode 120000 Lang/D/Averages-Median create mode 120000 Lang/D/Averages-Mode create mode 120000 Lang/D/Averages-Pythagorean-means create mode 120000 Lang/D/Averages-Root-mean-square create mode 120000 Lang/D/Averages-Simple-moving-average create mode 120000 Lang/D/Balanced-brackets create mode 120000 Lang/D/Balanced-ternary create mode 120000 Lang/D/Best-shuffle create mode 120000 Lang/D/Binary-search create mode 120000 Lang/D/Binary-strings create mode 120000 Lang/D/Bitmap create mode 120000 Lang/D/Bitmap-B-zier-curves-Cubic create mode 120000 Lang/D/Bitmap-B-zier-curves-Quadratic create mode 120000 Lang/D/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/D/Bitmap-Flood-fill create mode 120000 Lang/D/Bitmap-Histogram create mode 120000 Lang/D/Bitmap-Midpoint-circle-algorithm create mode 120000 Lang/D/Bitwise-IO create mode 120000 Lang/D/Bitwise-operations create mode 120000 Lang/D/Box-the-compass create mode 120000 Lang/D/Bulls-and-cows create mode 120000 Lang/D/Bulls-and-cows-Player create mode 120000 Lang/D/CRC-32 create mode 120000 Lang/D/CSV-to-HTML-translation create mode 120000 Lang/D/Caesar-cipher create mode 120000 Lang/D/Calendar create mode 120000 Lang/D/Call-a-foreign-language-function create mode 120000 Lang/D/Call-a-function-in-a-shared-library create mode 120000 Lang/D/Call-an-object-method create mode 120000 Lang/D/Canny-edge-detector create mode 120000 Lang/D/Carmichael-3-strong-pseudoprimes create mode 120000 Lang/D/Case-sensitivity-of-identifiers create mode 120000 Lang/D/Character-codes create mode 120000 Lang/D/Character-matching create mode 120000 Lang/D/Check-Machin-like-formulas create mode 120000 Lang/D/Check-that-file-exists create mode 120000 Lang/D/Checkpoint-synchronization create mode 120000 Lang/D/Cholesky-decomposition create mode 120000 Lang/D/Classes create mode 120000 Lang/D/Closest-pair-problem create mode 120000 Lang/D/Collections create mode 120000 Lang/D/Color-quantization create mode 120000 Lang/D/Combinations create mode 120000 Lang/D/Combinations-with-repetitions create mode 120000 Lang/D/Command-line-arguments create mode 120000 Lang/D/Comments create mode 120000 Lang/D/Compare-sorting-algorithms-performance create mode 120000 Lang/D/Compile-time-calculation create mode 120000 Lang/D/Compound-data-type create mode 120000 Lang/D/Concurrent-computing create mode 120000 Lang/D/Conditional-structures create mode 120000 Lang/D/Constrained-genericity create mode 120000 Lang/D/Constrained-random-points-on-a-circle create mode 120000 Lang/D/Continued-fraction create mode 120000 Lang/D/Conways-Game-of-Life create mode 120000 Lang/D/Count-in-factors create mode 120000 Lang/D/Count-in-octal create mode 120000 Lang/D/Count-occurrences-of-a-substring create mode 120000 Lang/D/Count-the-coins create mode 120000 Lang/D/Create-a-file create mode 120000 Lang/D/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/D/Create-an-HTML-table create mode 120000 Lang/D/Create-an-object-at-a-given-address create mode 120000 Lang/D/Cut-a-rectangle create mode 120000 Lang/D/DNS-query create mode 120000 Lang/D/Date-format create mode 120000 Lang/D/Day-of-the-week create mode 120000 Lang/D/Deal-cards-for-FreeCell create mode 120000 Lang/D/Death-Star create mode 120000 Lang/D/Deconvolution-1D create mode 120000 Lang/D/Deconvolution-2D+ create mode 120000 Lang/D/Define-a-primitive-data-type create mode 120000 Lang/D/Delegates create mode 120000 Lang/D/Delete-a-file create mode 120000 Lang/D/Detect-division-by-zero create mode 120000 Lang/D/Determine-if-a-string-is-numeric create mode 120000 Lang/D/Digital-root create mode 120000 Lang/D/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/D/Dining-philosophers create mode 120000 Lang/D/Discordian-date create mode 120000 Lang/D/Distributed-programming create mode 120000 Lang/D/Documentation create mode 120000 Lang/D/Dot-product create mode 120000 Lang/D/Doubly-linked-list-Definition create mode 120000 Lang/D/Doubly-linked-list-Element-definition create mode 120000 Lang/D/Doubly-linked-list-Element-insertion create mode 120000 Lang/D/Doubly-linked-list-Traversal create mode 120000 Lang/D/Draw-a-cuboid create mode 120000 Lang/D/Draw-a-sphere create mode 120000 Lang/D/Dutch-national-flag-problem create mode 120000 Lang/D/Echo-server create mode 120000 Lang/D/Element-wise-operations create mode 120000 Lang/D/Empty-directory create mode 120000 Lang/D/Empty-program create mode 120000 Lang/D/Empty-string create mode 120000 Lang/D/Enforced-immutability create mode 120000 Lang/D/Entropy create mode 120000 Lang/D/Enumerations create mode 120000 Lang/D/Equilibrium-index create mode 120000 Lang/D/Ethiopian-multiplication create mode 120000 Lang/D/Euler-method create mode 120000 Lang/D/Evaluate-binomial-coefficients create mode 120000 Lang/D/Even-or-odd create mode 120000 Lang/D/Evolutionary-algorithm create mode 120000 Lang/D/Exceptions create mode 120000 Lang/D/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/D/Execute-HQ9+ create mode 120000 Lang/D/Execute-a-system-command create mode 120000 Lang/D/Exponentiation-operator create mode 120000 Lang/D/Extend-your-language create mode 120000 Lang/D/Extreme-floating-point-values create mode 120000 Lang/D/FizzBuzz create mode 120000 Lang/D/Forest-fire create mode 120000 Lang/D/Infinity create mode 120000 Lang/D/JSON create mode 120000 Lang/D/Knuth-shuffle create mode 120000 Lang/D/Ordered-words create mode 120000 Lang/D/Pi create mode 120000 Lang/D/Quine create mode 120000 Lang/D/Search-a-list create mode 100644 Lang/DCL/0DESCRIPTION create mode 120000 Lang/DCL/Create-a-file create mode 120000 Lang/DCL/Execute-a-system-command create mode 100644 Lang/DMS/0DESCRIPTION create mode 120000 Lang/DMS/A+B create mode 100644 Lang/DWScript/0DESCRIPTION create mode 120000 Lang/DWScript/100-doors create mode 120000 Lang/DWScript/A+B create mode 120000 Lang/DWScript/Ackermann-function create mode 120000 Lang/DWScript/Arithmetic-Integer create mode 120000 Lang/DWScript/Arrays create mode 120000 Lang/DWScript/Assertions create mode 120000 Lang/DWScript/Bitwise-operations create mode 120000 Lang/DWScript/Case-sensitivity-of-identifiers create mode 120000 Lang/DWScript/Character-codes create mode 120000 Lang/DWScript/Cholesky-decomposition create mode 120000 Lang/DWScript/Classes create mode 120000 Lang/DWScript/Comments create mode 120000 Lang/DWScript/Compile-time-calculation create mode 120000 Lang/DWScript/Count-in-factors create mode 120000 Lang/DWScript/Death-Star create mode 120000 Lang/DWScript/Dot-product create mode 120000 Lang/DWScript/Draw-a-sphere create mode 120000 Lang/DWScript/Empty-string create mode 120000 Lang/DWScript/Enumerations create mode 120000 Lang/DWScript/Even-or-odd create mode 120000 Lang/DWScript/Exceptions create mode 120000 Lang/DWScript/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/DWScript/Execute-HQ9+ create mode 120000 Lang/DWScript/FizzBuzz create mode 120000 Lang/DWScript/Knuth-shuffle create mode 120000 Lang/DWScript/Search-a-list create mode 100644 Lang/Dao/0DESCRIPTION create mode 120000 Lang/Dao/Arrays create mode 120000 Lang/Dao/Associative-array-Creation create mode 120000 Lang/Dao/Associative-array-Iteration create mode 120000 Lang/Dao/Conditional-structures create mode 120000 Lang/Dao/Quine create mode 100644 Lang/Dart/0DESCRIPTION create mode 120000 Lang/Dart/100-doors create mode 120000 Lang/Dart/99-Bottles-of-Beer create mode 120000 Lang/Dart/Ackermann-function create mode 120000 Lang/Dart/Assertions create mode 120000 Lang/Dart/Caesar-cipher create mode 120000 Lang/Dart/Conways-Game-of-Life create mode 120000 Lang/Dart/Delegates create mode 120000 Lang/Dart/Empty-program create mode 120000 Lang/Dart/FizzBuzz create mode 100644 Lang/Datalog/0DESCRIPTION create mode 100644 Lang/Dc/0DESCRIPTION create mode 120000 Lang/Dc/Count-in-octal create mode 120000 Lang/Dc/Digital-root create mode 100644 Lang/Deja-Vu/0DESCRIPTION create mode 120000 Lang/Deja-Vu/A+B create mode 120000 Lang/Deja-Vu/Anonymous-recursion create mode 120000 Lang/Deja-Vu/Command-line-arguments create mode 120000 Lang/Deja-Vu/Conditional-structures create mode 120000 Lang/Deja-Vu/Narcissist create mode 120000 Lang/Deja-Vu/Quine create mode 100644 Lang/Delphi/0DESCRIPTION create mode 120000 Lang/Delphi/99-Bottles-of-Beer create mode 120000 Lang/Delphi/A+B create mode 120000 Lang/Delphi/Abstract-type create mode 120000 Lang/Delphi/Ackermann-function create mode 120000 Lang/Delphi/Align-columns create mode 120000 Lang/Delphi/Apply-a-callback-to-an-array create mode 120000 Lang/Delphi/Arithmetic-Integer create mode 120000 Lang/Delphi/Array-concatenation create mode 120000 Lang/Delphi/Arrays create mode 120000 Lang/Delphi/Assertions create mode 120000 Lang/Delphi/Associative-array-Creation create mode 120000 Lang/Delphi/Associative-array-Iteration create mode 120000 Lang/Delphi/Averages-Arithmetic-mean create mode 120000 Lang/Delphi/Averages-Median create mode 120000 Lang/Delphi/Averages-Pythagorean-means create mode 120000 Lang/Delphi/Averages-Root-mean-square create mode 120000 Lang/Delphi/Balanced-brackets create mode 120000 Lang/Delphi/Bitwise-operations create mode 120000 Lang/Delphi/CSV-to-HTML-translation create mode 120000 Lang/Delphi/Call-a-foreign-language-function create mode 120000 Lang/Delphi/Call-a-function-in-a-shared-library create mode 120000 Lang/Delphi/Case-sensitivity-of-identifiers create mode 120000 Lang/Delphi/Character-codes create mode 120000 Lang/Delphi/Character-matching create mode 120000 Lang/Delphi/Check-that-file-exists create mode 120000 Lang/Delphi/Classes create mode 120000 Lang/Delphi/Color-of-a-screen-pixel create mode 120000 Lang/Delphi/Command-line-arguments create mode 120000 Lang/Delphi/Comments create mode 120000 Lang/Delphi/Compound-data-type create mode 120000 Lang/Delphi/Concurrent-computing create mode 120000 Lang/Delphi/Count-in-octal create mode 120000 Lang/Delphi/Count-occurrences-of-a-substring create mode 120000 Lang/Delphi/Create-a-file create mode 120000 Lang/Delphi/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Delphi/Create-an-HTML-table create mode 120000 Lang/Delphi/DNS-query create mode 120000 Lang/Delphi/Date-format create mode 120000 Lang/Delphi/Date-manipulation create mode 120000 Lang/Delphi/Day-of-the-week create mode 120000 Lang/Delphi/Delegates create mode 120000 Lang/Delphi/Delete-a-file create mode 120000 Lang/Delphi/Detect-division-by-zero create mode 120000 Lang/Delphi/Determine-if-a-string-is-numeric create mode 120000 Lang/Delphi/Determine-if-only-one-instance-is-running create mode 120000 Lang/Delphi/Documentation create mode 120000 Lang/Delphi/Dot-product create mode 120000 Lang/Delphi/Doubly-linked-list-Element-definition create mode 120000 Lang/Delphi/Doubly-linked-list-Traversal create mode 120000 Lang/Delphi/Draw-a-sphere create mode 120000 Lang/Delphi/Echo-server create mode 120000 Lang/Delphi/Empty-string create mode 120000 Lang/Delphi/Enforced-immutability create mode 120000 Lang/Delphi/Enumerations create mode 120000 Lang/Delphi/Evaluate-binomial-coefficients create mode 120000 Lang/Delphi/Events create mode 120000 Lang/Delphi/Exceptions create mode 120000 Lang/Delphi/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Delphi/Execute-a-system-command create mode 120000 Lang/Delphi/Extend-your-language create mode 120000 Lang/Delphi/Extreme-floating-point-values create mode 120000 Lang/Delphi/FizzBuzz create mode 120000 Lang/Delphi/Infinity create mode 120000 Lang/Delphi/Ordered-words create mode 120000 Lang/Delphi/Search-a-list create mode 100644 Lang/Deluge/0DESCRIPTION create mode 120000 Lang/Deluge/Comments create mode 120000 Lang/Deluge/Conditional-structures create mode 100644 Lang/Diesel/0DESCRIPTION create mode 100644 Lang/Dodo0/0DESCRIPTION create mode 100644 Lang/Dylan.NET/0DESCRIPTION create mode 100644 Lang/E/0DESCRIPTION create mode 120000 Lang/E/100-doors create mode 120000 Lang/E/99-Bottles-of-Beer create mode 120000 Lang/E/Abstract-type create mode 120000 Lang/E/Accumulator-factory create mode 120000 Lang/E/Ackermann-function create mode 120000 Lang/E/Active-object create mode 120000 Lang/E/Align-columns create mode 120000 Lang/E/Anagrams create mode 120000 Lang/E/Animate-a-pendulum create mode 120000 Lang/E/Animation create mode 120000 Lang/E/Apply-a-callback-to-an-array create mode 120000 Lang/E/Arbitrary-precision-integers-(included) create mode 120000 Lang/E/Arithmetic-Integer create mode 120000 Lang/E/Arithmetic-evaluation create mode 120000 Lang/E/Array-concatenation create mode 120000 Lang/E/Arrays create mode 120000 Lang/E/Assertions create mode 120000 Lang/E/Associative-array-Creation create mode 120000 Lang/E/Associative-array-Iteration create mode 120000 Lang/E/Atomic-updates create mode 120000 Lang/E/Averages-Arithmetic-mean create mode 120000 Lang/E/Averages-Median create mode 120000 Lang/E/Averages-Mode create mode 120000 Lang/E/Averages-Pythagorean-means create mode 120000 Lang/E/Averages-Root-mean-square create mode 120000 Lang/E/Averages-Simple-moving-average create mode 120000 Lang/E/Binary-search create mode 120000 Lang/E/Binary-strings create mode 120000 Lang/E/Bitmap create mode 120000 Lang/E/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/E/Bitmap-Flood-fill create mode 120000 Lang/E/Bitmap-Read-a-PPM-file create mode 120000 Lang/E/Bitwise-operations create mode 120000 Lang/E/Boolean-values create mode 120000 Lang/E/Bulls-and-cows create mode 120000 Lang/E/Call-an-object-method create mode 120000 Lang/E/Character-codes create mode 120000 Lang/E/Character-matching create mode 120000 Lang/E/Check-that-file-exists create mode 120000 Lang/E/Checkpoint-synchronization create mode 120000 Lang/E/Classes create mode 120000 Lang/E/Collections create mode 120000 Lang/E/Combinations create mode 120000 Lang/E/Command-line-arguments create mode 120000 Lang/E/Comments create mode 120000 Lang/E/Compound-data-type create mode 120000 Lang/E/Concurrent-computing create mode 120000 Lang/E/Conditional-structures create mode 120000 Lang/E/Constrained-genericity create mode 120000 Lang/E/Conways-Game-of-Life create mode 120000 Lang/E/Create-a-file create mode 120000 Lang/E/Deepcopy create mode 120000 Lang/E/Define-a-primitive-data-type create mode 120000 Lang/E/Delegates create mode 120000 Lang/E/Delete-a-file create mode 120000 Lang/E/Detect-division-by-zero create mode 120000 Lang/E/Determine-if-a-string-is-numeric create mode 120000 Lang/E/Distributed-programming create mode 120000 Lang/E/Documentation create mode 120000 Lang/E/Doubly-linked-list-Definition create mode 120000 Lang/E/Doubly-linked-list-Element-definition create mode 120000 Lang/E/Doubly-linked-list-Element-insertion create mode 120000 Lang/E/Doubly-linked-list-Traversal create mode 120000 Lang/E/Dynamic-variable-names create mode 120000 Lang/E/Empty-program create mode 120000 Lang/E/Enforced-immutability create mode 120000 Lang/E/Enumerations create mode 120000 Lang/E/Ethiopian-multiplication create mode 120000 Lang/E/Events create mode 120000 Lang/E/Evolutionary-algorithm create mode 120000 Lang/E/Exceptions create mode 120000 Lang/E/Execute-a-system-command create mode 120000 Lang/E/Exponentiation-operator create mode 120000 Lang/E/Extend-your-language create mode 120000 Lang/E/FizzBuzz create mode 120000 Lang/E/Infinity create mode 120000 Lang/E/Knuth-shuffle create mode 120000 Lang/E/Ordered-words create mode 120000 Lang/E/Quine create mode 120000 Lang/E/Search-a-list create mode 100644 Lang/EC/0DESCRIPTION create mode 100644 Lang/EGL/0DESCRIPTION create mode 120000 Lang/EGL/100-doors create mode 120000 Lang/EGL/99-Bottles-of-Beer create mode 120000 Lang/EGL/A+B create mode 120000 Lang/EGL/Apply-a-callback-to-an-array create mode 120000 Lang/EGL/Array-concatenation create mode 120000 Lang/EGL/Arrays create mode 120000 Lang/EGL/Boolean-values create mode 120000 Lang/EGL/Count-occurrences-of-a-substring create mode 120000 Lang/EGL/Date-format create mode 120000 Lang/EGL/Empty-program create mode 120000 Lang/EGL/Enumerations create mode 120000 Lang/EGL/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/EGL/JSON create mode 100644 Lang/ELLA/0DESCRIPTION create mode 100644 Lang/ESQL/0DESCRIPTION create mode 100644 Lang/Efene/0DESCRIPTION create mode 120000 Lang/Efene/Apply-a-callback-to-an-array create mode 120000 Lang/Efene/Arithmetic-Integer create mode 120000 Lang/Efene/Array-concatenation create mode 120000 Lang/Efene/Conditional-structures create mode 120000 Lang/Eiffel/Command-line-arguments create mode 120000 Lang/Eiffel/Constrained-genericity create mode 120000 Lang/Eiffel/Count-occurrences-of-a-substring create mode 120000 Lang/Eiffel/Dining-philosophers create mode 120000 Lang/Eiffel/Documentation create mode 120000 Lang/Eiffel/Empty-program create mode 120000 Lang/Eiffel/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 100644 Lang/Ela/0DESCRIPTION create mode 120000 Lang/Ela/100-doors create mode 120000 Lang/Ela/99-Bottles-of-Beer create mode 120000 Lang/Ela/A+B create mode 120000 Lang/Ela/Ackermann-function create mode 120000 Lang/Ela/Anonymous-recursion create mode 120000 Lang/Ela/Comments create mode 120000 Lang/Ela/Compound-data-type create mode 120000 Lang/Ela/Conditional-structures create mode 120000 Lang/Ela/Detect-division-by-zero create mode 120000 Lang/Ela/Dot-product create mode 120000 Lang/Ela/Enforced-immutability create mode 120000 Lang/Ela/Ethiopian-multiplication create mode 120000 Lang/Ela/Execute-HQ9+ create mode 120000 Lang/Ela/FizzBuzz create mode 100644 Lang/Elan/0DESCRIPTION create mode 100644 Lang/ElastiC/0DESCRIPTION create mode 100644 Lang/Elena/0DESCRIPTION create mode 120000 Lang/Elena/A+B create mode 120000 Lang/Elena/Accumulator-factory create mode 120000 Lang/Elena/Ackermann-function create mode 120000 Lang/Elena/Add-a-variable-to-a-class-instance-at-runtime create mode 120000 Lang/Elena/Anagrams create mode 120000 Lang/Elena/Anonymous-recursion create mode 120000 Lang/Elena/Apply-a-callback-to-an-array create mode 120000 Lang/Elena/Arithmetic-Integer create mode 120000 Lang/Elena/Arithmetic-evaluation create mode 120000 Lang/Elena/Array-concatenation create mode 120000 Lang/Elena/Arrays create mode 120000 Lang/Elena/Associative-array-Creation create mode 120000 Lang/Elena/Associative-array-Iteration create mode 120000 Lang/Elena/Averages-Arithmetic-mean create mode 120000 Lang/Elena/Averages-Median create mode 120000 Lang/Elena/Averages-Mode create mode 120000 Lang/Elena/Averages-Simple-moving-average create mode 120000 Lang/Elena/Balanced-brackets create mode 120000 Lang/Elena/Bitwise-operations create mode 120000 Lang/Elena/Bulls-and-cows create mode 120000 Lang/Elena/Caesar-cipher create mode 120000 Lang/Elena/Character-codes create mode 120000 Lang/Elena/Character-matching create mode 100644 Lang/Elisa/0DESCRIPTION create mode 120000 Lang/Elisa/Arithmetic-Rational create mode 100644 Lang/Elixir/0DESCRIPTION create mode 120000 Lang/Elixir/FizzBuzz create mode 100644 Lang/Emacs-Lisp/0DESCRIPTION create mode 120000 Lang/Emacs-Lisp/100-doors create mode 120000 Lang/Emacs-Lisp/Arbitrary-precision-integers-(included) create mode 120000 Lang/Emacs-Lisp/Assertions create mode 120000 Lang/Emacs-Lisp/Averages-Arithmetic-mean create mode 120000 Lang/Emacs-Lisp/Command-line-arguments create mode 120000 Lang/Emacs-Lisp/Comments create mode 120000 Lang/Emacs-Lisp/Count-in-octal create mode 100644 Lang/Epigram/0DESCRIPTION create mode 120000 Lang/Erlang/CRC-32 create mode 120000 Lang/Erlang/Character-codes create mode 120000 Lang/Erlang/Character-matching create mode 120000 Lang/Erlang/Chat-server create mode 120000 Lang/Erlang/Combinations create mode 120000 Lang/Erlang/Combinations-with-repetitions create mode 120000 Lang/Erlang/Command-line-arguments create mode 120000 Lang/Erlang/Compound-data-type create mode 120000 Lang/Erlang/Concurrent-computing create mode 120000 Lang/Erlang/Conditional-structures create mode 120000 Lang/Erlang/Conways-Game-of-Life create mode 120000 Lang/Erlang/Count-occurrences-of-a-substring create mode 120000 Lang/Erlang/Count-the-coins create mode 120000 Lang/Erlang/Date-format create mode 120000 Lang/Erlang/Dining-philosophers create mode 120000 Lang/Erlang/Distributed-programming create mode 120000 Lang/Erlang/Dot-product create mode 120000 Lang/Erlang/Dutch-national-flag-problem create mode 120000 Lang/Erlang/Echo-server create mode 120000 Lang/Erlang/Empty-program create mode 120000 Lang/Erlang/Empty-string create mode 120000 Lang/Erlang/Enforced-immutability create mode 120000 Lang/Erlang/Ethiopian-multiplication create mode 120000 Lang/Erlang/Evaluate-binomial-coefficients create mode 120000 Lang/Erlang/Events create mode 120000 Lang/Erlang/Evolutionary-algorithm create mode 120000 Lang/Erlang/Execute-HQ9+ create mode 120000 Lang/Erlang/Execute-a-system-command create mode 120000 Lang/Erlang/Exponentiation-operator create mode 100644 Lang/Es/0DESCRIPTION create mode 100644 Lang/Euler-Math-Toolbox/0DESCRIPTION create mode 120000 Lang/Euler-Math-Toolbox/100-doors create mode 120000 Lang/Euler-Math-Toolbox/A+B create mode 120000 Lang/Euler-Math-Toolbox/Ackermann-function create mode 120000 Lang/Euler-Math-Toolbox/Arithmetic-Complex create mode 120000 Lang/Euler-Math-Toolbox/Averages-Mean-angle create mode 120000 Lang/Euler-Math-Toolbox/Averages-Median create mode 120000 Lang/Euler-Math-Toolbox/Averages-Pythagorean-means create mode 120000 Lang/Euler-Math-Toolbox/Averages-Simple-moving-average create mode 120000 Lang/Euler-Math-Toolbox/Entropy create mode 120000 Lang/Euler-Math-Toolbox/Euler-method create mode 100644 Lang/Euler/0DESCRIPTION create mode 100644 Lang/Euphoria/0DESCRIPTION create mode 120000 Lang/Euphoria/100-doors create mode 120000 Lang/Euphoria/99-Bottles-of-Beer create mode 120000 Lang/Euphoria/A+B create mode 120000 Lang/Euphoria/Ackermann-function create mode 120000 Lang/Euphoria/Align-columns create mode 120000 Lang/Euphoria/Anagrams create mode 120000 Lang/Euphoria/Animate-a-pendulum create mode 120000 Lang/Euphoria/Apply-a-callback-to-an-array create mode 120000 Lang/Euphoria/Arithmetic-Complex create mode 120000 Lang/Euphoria/Arithmetic-Integer create mode 120000 Lang/Euphoria/Array-concatenation create mode 120000 Lang/Euphoria/Arrays create mode 120000 Lang/Euphoria/Assertions create mode 120000 Lang/Euphoria/Atomic-updates create mode 120000 Lang/Euphoria/Averages-Arithmetic-mean create mode 120000 Lang/Euphoria/Averages-Median create mode 120000 Lang/Euphoria/Averages-Mode create mode 120000 Lang/Euphoria/Averages-Pythagorean-means create mode 120000 Lang/Euphoria/Averages-Root-mean-square create mode 120000 Lang/Euphoria/Balanced-brackets create mode 120000 Lang/Euphoria/Binary-search create mode 120000 Lang/Euphoria/Bitmap create mode 120000 Lang/Euphoria/Bitmap-Bresenhams-line-algorithm create mode 120000 Lang/Euphoria/Bitmap-Read-a-PPM-file create mode 120000 Lang/Euphoria/Bitmap-Write-a-PPM-file create mode 120000 Lang/Euphoria/Box-the-compass create mode 120000 Lang/Euphoria/Bulls-and-cows create mode 120000 Lang/Euphoria/Bulls-and-cows-Player create mode 120000 Lang/Euphoria/CSV-to-HTML-translation create mode 120000 Lang/Euphoria/Caesar-cipher create mode 120000 Lang/Euphoria/Case-sensitivity-of-identifiers create mode 120000 Lang/Euphoria/Character-codes create mode 120000 Lang/Euphoria/Character-matching create mode 120000 Lang/Euphoria/Check-that-file-exists create mode 120000 Lang/Euphoria/Command-line-arguments create mode 120000 Lang/Euphoria/Comments create mode 120000 Lang/Euphoria/Concurrent-computing create mode 120000 Lang/Euphoria/Constrained-random-points-on-a-circle create mode 120000 Lang/Euphoria/Count-in-factors create mode 120000 Lang/Euphoria/Count-in-octal create mode 120000 Lang/Euphoria/Count-occurrences-of-a-substring create mode 120000 Lang/Euphoria/Create-a-file create mode 120000 Lang/Euphoria/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Euphoria/Create-an-HTML-table create mode 120000 Lang/Euphoria/Date-format create mode 120000 Lang/Euphoria/Date-manipulation create mode 120000 Lang/Euphoria/Day-of-the-week create mode 120000 Lang/Euphoria/Define-a-primitive-data-type create mode 120000 Lang/Euphoria/Determine-if-a-string-is-numeric create mode 120000 Lang/Euphoria/Dining-philosophers create mode 120000 Lang/Euphoria/Discordian-date create mode 120000 Lang/Euphoria/Dot-product create mode 120000 Lang/Euphoria/Empty-program create mode 120000 Lang/Euphoria/Empty-string create mode 120000 Lang/Euphoria/Enforced-immutability create mode 120000 Lang/Euphoria/Equilibrium-index create mode 120000 Lang/Euphoria/Ethiopian-multiplication create mode 120000 Lang/Euphoria/Even-or-odd create mode 120000 Lang/Euphoria/Evolutionary-algorithm create mode 120000 Lang/Euphoria/Extreme-floating-point-values create mode 120000 Lang/Euphoria/FizzBuzz create mode 120000 Lang/Euphoria/Infinity create mode 120000 Lang/Euphoria/Knuth-shuffle create mode 120000 Lang/Euphoria/Ordered-words create mode 120000 Lang/Euphoria/Quine create mode 120000 Lang/Euphoria/Search-a-list create mode 100644 Lang/Excel/0DESCRIPTION create mode 120000 Lang/Forth/Call-a-foreign-language-function create mode 120000 Lang/Forth/Call-an-object-method create mode 120000 Lang/Forth/Character-codes create mode 120000 Lang/Forth/Character-matching create mode 120000 Lang/Forth/Command-line-arguments create mode 120000 Lang/Forth/Compile-time-calculation create mode 120000 Lang/Forth/Compound-data-type create mode 120000 Lang/Forth/Concurrent-computing create mode 120000 Lang/Forth/Conditional-structures create mode 120000 Lang/Forth/Continued-fraction create mode 120000 Lang/Forth/Conways-Game-of-Life create mode 120000 Lang/Forth/Count-in-factors create mode 120000 Lang/Forth/Count-in-octal create mode 120000 Lang/Forth/Count-occurrences-of-a-substring create mode 120000 Lang/Forth/Count-the-coins create mode 120000 Lang/Forth/Create-a-file create mode 120000 Lang/Forth/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Forth/Create-an-object-at-a-given-address create mode 120000 Lang/Forth/Date-format create mode 120000 Lang/Forth/Day-of-the-week create mode 120000 Lang/Forth/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/Forth/Dot-product create mode 120000 Lang/Forth/Dynamic-variable-names create mode 120000 Lang/Forth/Echo-server create mode 120000 Lang/Forth/Empty-program create mode 120000 Lang/Forth/Empty-string create mode 120000 Lang/Forth/Enumerations create mode 120000 Lang/Forth/Ethiopian-multiplication create mode 120000 Lang/Forth/Evaluate-binomial-coefficients create mode 120000 Lang/Forth/Even-or-odd create mode 120000 Lang/Forth/Evolutionary-algorithm create mode 120000 Lang/Forth/Exceptions create mode 120000 Lang/Forth/Execute-HQ9+ create mode 120000 Lang/Forth/Execute-a-system-command create mode 120000 Lang/Forth/Exponentiation-operator create mode 120000 Lang/Forth/Extend-your-language create mode 120000 Lang/Forth/Extreme-floating-point-values create mode 120000 Lang/Fortran/Case-sensitivity-of-identifiers create mode 120000 Lang/Fortran/Character-codes create mode 120000 Lang/Fortran/Combinations create mode 120000 Lang/Fortran/Combinations-with-repetitions create mode 120000 Lang/Fortran/Command-line-arguments create mode 120000 Lang/Fortran/Compile-time-calculation create mode 120000 Lang/Fortran/Compound-data-type create mode 120000 Lang/Fortran/Concurrent-computing create mode 120000 Lang/Fortran/Conditional-structures create mode 120000 Lang/Fortran/Constrained-random-points-on-a-circle create mode 120000 Lang/Fortran/Conways-Game-of-Life create mode 120000 Lang/Fortran/Count-in-octal create mode 120000 Lang/Fortran/Count-occurrences-of-a-substring create mode 120000 Lang/Fortran/Create-a-file create mode 120000 Lang/Fortran/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Fortran/Date-format create mode 120000 Lang/Fortran/Day-of-the-week create mode 120000 Lang/Fortran/Deconvolution-1D create mode 120000 Lang/Fortran/Dot-product create mode 120000 Lang/Fortran/Doubly-linked-list-Definition create mode 120000 Lang/Fortran/Doubly-linked-list-Element-definition create mode 120000 Lang/Fortran/Doubly-linked-list-Element-insertion create mode 120000 Lang/Fortran/Doubly-linked-list-Traversal create mode 120000 Lang/Fortran/Empty-program create mode 120000 Lang/Fortran/Enumerations create mode 120000 Lang/Fortran/Equilibrium-index create mode 120000 Lang/Fortran/Ethiopian-multiplication create mode 120000 Lang/Fortran/Euler-method create mode 120000 Lang/Fortran/Evaluate-binomial-coefficients create mode 120000 Lang/Fortran/Evolutionary-algorithm create mode 120000 Lang/Fortran/Execute-a-system-command create mode 120000 Lang/Fortran/Exponentiation-operator create mode 120000 Lang/Go/CRC-32 create mode 120000 Lang/Go/CSV-to-HTML-translation create mode 120000 Lang/Go/Call-a-foreign-language-function create mode 120000 Lang/Go/Call-an-object-method create mode 120000 Lang/Go/Case-sensitivity-of-identifiers create mode 120000 Lang/Go/Character-codes create mode 120000 Lang/Go/Character-matching create mode 120000 Lang/Go/Chat-server create mode 120000 Lang/Go/Check-Machin-like-formulas create mode 120000 Lang/Go/Cholesky-decomposition create mode 120000 Lang/Go/Combinations create mode 120000 Lang/Go/Combinations-with-repetitions create mode 120000 Lang/Go/Command-line-arguments create mode 120000 Lang/Go/Compile-time-calculation create mode 120000 Lang/Go/Compound-data-type create mode 120000 Lang/Go/Concurrent-computing create mode 120000 Lang/Go/Conditional-structures create mode 120000 Lang/Go/Constrained-genericity create mode 120000 Lang/Go/Constrained-random-points-on-a-circle create mode 120000 Lang/Go/Continued-fraction create mode 120000 Lang/Go/Conways-Game-of-Life create mode 120000 Lang/Go/Count-in-factors create mode 120000 Lang/Go/Count-in-octal create mode 120000 Lang/Go/Count-occurrences-of-a-substring create mode 120000 Lang/Go/Count-the-coins create mode 120000 Lang/Go/Create-a-file create mode 120000 Lang/Go/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Go/Create-an-HTML-table create mode 120000 Lang/Go/Create-an-object-at-a-given-address create mode 120000 Lang/Go/DNS-query create mode 120000 Lang/Go/Date-format create mode 120000 Lang/Go/Date-manipulation create mode 120000 Lang/Go/Day-of-the-week create mode 120000 Lang/Go/Deal-cards-for-FreeCell create mode 120000 Lang/Go/Deconvolution-1D create mode 120000 Lang/Go/Deepcopy create mode 120000 Lang/Go/Determine-if-only-one-instance-is-running create mode 120000 Lang/Go/Digital-root create mode 120000 Lang/Go/Dining-philosophers create mode 120000 Lang/Go/Discordian-date create mode 120000 Lang/Go/Distributed-programming create mode 120000 Lang/Go/Documentation create mode 120000 Lang/Go/Dot-product create mode 120000 Lang/Go/Doubly-linked-list-Definition create mode 120000 Lang/Go/Doubly-linked-list-Element-definition create mode 120000 Lang/Go/Doubly-linked-list-Element-insertion create mode 120000 Lang/Go/Doubly-linked-list-Traversal create mode 120000 Lang/Go/Draw-a-cuboid create mode 120000 Lang/Go/Draw-a-sphere create mode 120000 Lang/Go/Dutch-national-flag-problem create mode 120000 Lang/Go/Echo-server create mode 120000 Lang/Go/Element-wise-operations create mode 120000 Lang/Go/Empty-directory create mode 120000 Lang/Go/Empty-program create mode 120000 Lang/Go/Empty-string create mode 120000 Lang/Go/Enforced-immutability create mode 120000 Lang/Go/Enumerations create mode 120000 Lang/Go/Equilibrium-index create mode 120000 Lang/Go/Ethiopian-multiplication create mode 120000 Lang/Go/Euler-method create mode 120000 Lang/Go/Evaluate-binomial-coefficients create mode 120000 Lang/Go/Even-or-odd create mode 120000 Lang/Go/Events create mode 120000 Lang/Go/Evolutionary-algorithm create mode 120000 Lang/Go/Exceptions create mode 120000 Lang/Go/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Go/Execute-a-system-command create mode 120000 Lang/Go/Exponentiation-operator create mode 120000 Lang/Go/Extreme-floating-point-values create mode 120000 Lang/Haskell/CSV-to-HTML-translation create mode 120000 Lang/Haskell/Call-a-foreign-language-function create mode 120000 Lang/Haskell/Carmichael-3-strong-pseudoprimes create mode 120000 Lang/Haskell/Case-sensitivity-of-identifiers create mode 120000 Lang/Haskell/Character-codes create mode 120000 Lang/Haskell/Character-matching create mode 120000 Lang/Haskell/Check-Machin-like-formulas create mode 120000 Lang/Haskell/Cholesky-decomposition create mode 120000 Lang/Haskell/Combinations create mode 120000 Lang/Haskell/Combinations-with-repetitions create mode 120000 Lang/Haskell/Command-line-arguments create mode 120000 Lang/Haskell/Compile-time-calculation create mode 120000 Lang/Haskell/Compound-data-type create mode 120000 Lang/Haskell/Concurrent-computing create mode 120000 Lang/Haskell/Conditional-structures create mode 120000 Lang/Haskell/Constrained-genericity create mode 120000 Lang/Haskell/Constrained-random-points-on-a-circle create mode 120000 Lang/Haskell/Continued-fraction create mode 120000 Lang/Haskell/Continued-fraction-Arithmetic-Construct-from-rational-number create mode 120000 Lang/Haskell/Conways-Game-of-Life create mode 120000 Lang/Haskell/Count-in-factors create mode 120000 Lang/Haskell/Count-in-octal create mode 120000 Lang/Haskell/Count-occurrences-of-a-substring create mode 120000 Lang/Haskell/Count-the-coins create mode 120000 Lang/Haskell/Create-a-file create mode 120000 Lang/Haskell/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Haskell/Create-an-HTML-table create mode 120000 Lang/Haskell/Cut-a-rectangle create mode 120000 Lang/Haskell/Date-format create mode 120000 Lang/Haskell/Date-manipulation create mode 120000 Lang/Haskell/Day-of-the-week create mode 120000 Lang/Haskell/Deal-cards-for-FreeCell create mode 120000 Lang/Haskell/Deconvolution-1D create mode 120000 Lang/Haskell/Determine-if-only-one-instance-is-running create mode 120000 Lang/Haskell/Digital-root create mode 120000 Lang/Haskell/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/Haskell/Dining-philosophers create mode 120000 Lang/Haskell/Discordian-date create mode 120000 Lang/Haskell/Documentation create mode 120000 Lang/Haskell/Dot-product create mode 120000 Lang/Haskell/Doubly-linked-list-Definition create mode 120000 Lang/Haskell/Doubly-linked-list-Element-definition create mode 120000 Lang/Haskell/Doubly-linked-list-Element-insertion create mode 120000 Lang/Haskell/Doubly-linked-list-Traversal create mode 120000 Lang/Haskell/Draw-a-cuboid create mode 120000 Lang/Haskell/Draw-a-sphere create mode 120000 Lang/Haskell/Dutch-national-flag-problem create mode 120000 Lang/Haskell/Dynamic-variable-names create mode 120000 Lang/Haskell/Echo-server create mode 120000 Lang/Haskell/Empty-directory create mode 120000 Lang/Haskell/Empty-program create mode 120000 Lang/Haskell/Empty-string create mode 120000 Lang/Haskell/Enforced-immutability create mode 120000 Lang/Haskell/Enumerations create mode 120000 Lang/Haskell/Equilibrium-index create mode 120000 Lang/Haskell/Ethiopian-multiplication create mode 120000 Lang/Haskell/Euler-method create mode 120000 Lang/Haskell/Evaluate-binomial-coefficients create mode 120000 Lang/Haskell/Even-or-odd create mode 120000 Lang/Haskell/Events create mode 120000 Lang/Haskell/Evolutionary-algorithm create mode 120000 Lang/Haskell/Exceptions create mode 120000 Lang/Haskell/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Haskell/Execute-a-system-command create mode 120000 Lang/Haskell/Exponentiation-operator create mode 120000 Lang/Haskell/Extend-your-language create mode 120000 Lang/Java/CRC-32 create mode 120000 Lang/Java/CSV-to-HTML-translation create mode 120000 Lang/Java/Call-a-foreign-language-function create mode 120000 Lang/Java/Call-a-function-in-a-shared-library create mode 120000 Lang/Java/Call-an-object-method create mode 120000 Lang/Java/Case-sensitivity-of-identifiers create mode 120000 Lang/Java/Character-codes create mode 120000 Lang/Java/Character-matching create mode 120000 Lang/Java/Chat-server create mode 120000 Lang/Java/Cholesky-decomposition create mode 120000 Lang/Java/Colour-bars-Display create mode 120000 Lang/Java/Combinations create mode 120000 Lang/Java/Combinations-with-repetitions create mode 120000 Lang/Java/Command-line-arguments create mode 120000 Lang/Java/Compound-data-type create mode 120000 Lang/Java/Concurrent-computing create mode 120000 Lang/Java/Conditional-structures create mode 120000 Lang/Java/Constrained-genericity create mode 120000 Lang/Java/Constrained-random-points-on-a-circle create mode 120000 Lang/Java/Conways-Game-of-Life create mode 120000 Lang/Java/Count-in-factors create mode 120000 Lang/Java/Count-in-octal create mode 120000 Lang/Java/Count-occurrences-of-a-substring create mode 120000 Lang/Java/Count-the-coins create mode 120000 Lang/Java/Create-a-file create mode 120000 Lang/Java/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Java/Create-an-HTML-table create mode 120000 Lang/Java/Date-format create mode 120000 Lang/Java/Date-manipulation create mode 120000 Lang/Java/Day-of-the-week create mode 120000 Lang/Java/Deconvolution-1D create mode 120000 Lang/Java/Determine-if-only-one-instance-is-running create mode 120000 Lang/Java/Digital-root create mode 120000 Lang/Java/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/Java/Dining-philosophers create mode 120000 Lang/Java/Documentation create mode 120000 Lang/Java/Dot-product create mode 120000 Lang/Java/Doubly-linked-list-Element-definition create mode 120000 Lang/Java/Doubly-linked-list-Traversal create mode 120000 Lang/Java/Draw-a-sphere create mode 120000 Lang/Java/Echo-server create mode 120000 Lang/Java/Empty-directory create mode 120000 Lang/Java/Empty-program create mode 120000 Lang/Java/Empty-string create mode 120000 Lang/Java/Enforced-immutability create mode 120000 Lang/Java/Enumerations create mode 120000 Lang/Java/Equilibrium-index create mode 120000 Lang/Java/Ethiopian-multiplication create mode 120000 Lang/Java/Euler-method create mode 120000 Lang/Java/Evaluate-binomial-coefficients create mode 120000 Lang/Java/Even-or-odd create mode 120000 Lang/Java/Evolutionary-algorithm create mode 120000 Lang/Java/Exceptions create mode 120000 Lang/Java/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Java/Execute-a-system-command create mode 120000 Lang/Java/Exponentiation-operator create mode 120000 Lang/Java/Extreme-floating-point-values create mode 120000 Lang/JavaScript/CSV-to-HTML-translation create mode 120000 Lang/JavaScript/Call-a-function create mode 120000 Lang/JavaScript/Case-sensitivity-of-identifiers create mode 120000 Lang/JavaScript/Character-codes create mode 120000 Lang/JavaScript/Character-matching create mode 120000 Lang/JavaScript/Chat-server create mode 120000 Lang/JavaScript/Combinations create mode 120000 Lang/JavaScript/Combinations-with-repetitions create mode 120000 Lang/JavaScript/Command-line-arguments create mode 120000 Lang/JavaScript/Compound-data-type create mode 120000 Lang/JavaScript/Concurrent-computing create mode 120000 Lang/JavaScript/Conditional-structures create mode 120000 Lang/JavaScript/Constrained-random-points-on-a-circle create mode 120000 Lang/JavaScript/Conways-Game-of-Life create mode 120000 Lang/JavaScript/Count-in-factors create mode 120000 Lang/JavaScript/Count-in-octal create mode 120000 Lang/JavaScript/Count-occurrences-of-a-substring create mode 120000 Lang/JavaScript/Count-the-coins create mode 120000 Lang/JavaScript/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/JavaScript/Create-an-HTML-table create mode 120000 Lang/JavaScript/Date-format create mode 120000 Lang/JavaScript/Date-manipulation create mode 120000 Lang/JavaScript/Day-of-the-week create mode 120000 Lang/JavaScript/Deal-cards-for-FreeCell create mode 120000 Lang/JavaScript/Deepcopy create mode 120000 Lang/JavaScript/Discordian-date create mode 120000 Lang/JavaScript/Distributed-programming create mode 120000 Lang/JavaScript/Dot-product create mode 120000 Lang/JavaScript/Doubly-linked-list-Element-definition create mode 120000 Lang/JavaScript/Doubly-linked-list-Element-insertion create mode 120000 Lang/JavaScript/Doubly-linked-list-Traversal create mode 120000 Lang/JavaScript/Dynamic-variable-names create mode 120000 Lang/JavaScript/Echo-server create mode 120000 Lang/JavaScript/Enforced-immutability create mode 120000 Lang/JavaScript/Enumerations create mode 120000 Lang/JavaScript/Evaluate-binomial-coefficients create mode 120000 Lang/JavaScript/Even-or-odd create mode 120000 Lang/JavaScript/Events create mode 120000 Lang/JavaScript/Evolutionary-algorithm create mode 120000 Lang/JavaScript/Exceptions create mode 120000 Lang/JavaScript/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/JavaScript/Execute-HQ9+ create mode 120000 Lang/JavaScript/Execute-a-system-command create mode 120000 Lang/JavaScript/Exponentiation-operator create mode 120000 Lang/LaTeX/Empty-program create mode 120000 Lang/Lua/CSV-to-HTML-translation create mode 120000 Lang/Lua/Case-sensitivity-of-identifiers create mode 120000 Lang/Lua/Character-codes create mode 120000 Lang/Lua/Character-matching create mode 120000 Lang/Lua/Combinations create mode 120000 Lang/Lua/Command-line-arguments create mode 120000 Lang/Lua/Compound-data-type create mode 120000 Lang/Lua/Concurrent-computing create mode 120000 Lang/Lua/Conditional-structures create mode 120000 Lang/Lua/Conways-Game-of-Life create mode 120000 Lang/Lua/Count-in-factors create mode 120000 Lang/Lua/Count-in-octal create mode 120000 Lang/Lua/Count-occurrences-of-a-substring create mode 120000 Lang/Lua/Create-a-file create mode 120000 Lang/Lua/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Lua/Date-format create mode 120000 Lang/Lua/Date-manipulation create mode 120000 Lang/Lua/Day-of-the-week create mode 120000 Lang/Lua/Deconvolution-1D create mode 120000 Lang/Lua/Dot-product create mode 120000 Lang/Lua/Draw-a-sphere create mode 120000 Lang/Lua/Dynamic-variable-names create mode 120000 Lang/Lua/Empty-program create mode 120000 Lang/Lua/Empty-string create mode 120000 Lang/Lua/Enumerations create mode 120000 Lang/Lua/Ethiopian-multiplication create mode 120000 Lang/Lua/Euler-method create mode 120000 Lang/Lua/Evaluate-binomial-coefficients create mode 120000 Lang/Lua/Even-or-odd create mode 120000 Lang/Lua/Evolutionary-algorithm create mode 120000 Lang/Lua/Exceptions create mode 120000 Lang/Lua/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Lua/Execute-a-system-command create mode 120000 Lang/Lua/Exponentiation-operator create mode 120000 Lang/MATLAB/CSV-to-HTML-translation create mode 120000 Lang/MATLAB/Call-a-function create mode 120000 Lang/MATLAB/Case-sensitivity-of-identifiers create mode 120000 Lang/MATLAB/Character-codes create mode 120000 Lang/MATLAB/Character-matching create mode 120000 Lang/MATLAB/Cholesky-decomposition create mode 120000 Lang/MATLAB/Combinations create mode 120000 Lang/MATLAB/Conditional-structures create mode 120000 Lang/MATLAB/Constrained-random-points-on-a-circle create mode 120000 Lang/MATLAB/Conways-Game-of-Life create mode 120000 Lang/MATLAB/Count-in-octal create mode 120000 Lang/MATLAB/Count-occurrences-of-a-substring create mode 120000 Lang/MATLAB/Create-a-file create mode 120000 Lang/MATLAB/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/MATLAB/Create-an-HTML-table create mode 120000 Lang/MATLAB/Date-format create mode 120000 Lang/MATLAB/Day-of-the-week create mode 120000 Lang/MATLAB/Deconvolution-1D create mode 120000 Lang/MATLAB/Dot-product create mode 120000 Lang/MATLAB/Empty-directory create mode 120000 Lang/MATLAB/Empty-program create mode 120000 Lang/MATLAB/Empty-string create mode 120000 Lang/MATLAB/Enumerations create mode 120000 Lang/MATLAB/Equilibrium-index create mode 120000 Lang/MATLAB/Ethiopian-multiplication create mode 120000 Lang/MATLAB/Evaluate-binomial-coefficients create mode 120000 Lang/MATLAB/Even-or-odd create mode 120000 Lang/MATLAB/Evolutionary-algorithm create mode 120000 Lang/MATLAB/Exceptions create mode 120000 Lang/MATLAB/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/MATLAB/Execute-a-system-command create mode 120000 Lang/PHP/CRC-32 create mode 120000 Lang/PHP/Calendar-for-real-programmers create mode 120000 Lang/PHP/Call-an-object-method create mode 120000 Lang/PHP/Character-codes create mode 120000 Lang/PHP/Colour-bars-Display create mode 120000 Lang/PHP/Combinations-with-repetitions create mode 120000 Lang/PHP/Command-line-arguments create mode 120000 Lang/PHP/Compound-data-type create mode 120000 Lang/PHP/Conditional-structures create mode 120000 Lang/PHP/Count-in-octal create mode 120000 Lang/PHP/Count-occurrences-of-a-substring create mode 120000 Lang/PHP/Create-a-file create mode 120000 Lang/PHP/Create-an-HTML-table create mode 120000 Lang/PHP/DNS-query create mode 120000 Lang/PHP/Date-format create mode 120000 Lang/PHP/Date-manipulation create mode 120000 Lang/PHP/Day-of-the-week create mode 120000 Lang/PHP/Deepcopy create mode 120000 Lang/PHP/Discordian-date create mode 120000 Lang/PHP/Dot-product create mode 120000 Lang/PHP/Dynamic-variable-names create mode 120000 Lang/PHP/Echo-server create mode 120000 Lang/PHP/Empty-directory create mode 120000 Lang/PHP/Empty-string create mode 120000 Lang/PHP/Enforced-immutability create mode 120000 Lang/PHP/Enumerations create mode 120000 Lang/PHP/Equilibrium-index create mode 120000 Lang/PHP/Ethiopian-multiplication create mode 120000 Lang/PHP/Evaluate-binomial-coefficients create mode 120000 Lang/PHP/Even-or-odd create mode 120000 Lang/PHP/Exceptions create mode 120000 Lang/PHP/Execute-a-system-command create mode 120000 Lang/PIR/Empty-program create mode 120000 Lang/Perl/CRC-32 create mode 120000 Lang/Perl/CSV-to-HTML-translation create mode 120000 Lang/Perl/Calendar-for-real-programmers create mode 120000 Lang/Perl/Call-a-foreign-language-function create mode 120000 Lang/Perl/Call-an-object-method create mode 120000 Lang/Perl/Case-sensitivity-of-identifiers create mode 120000 Lang/Perl/Character-codes create mode 120000 Lang/Perl/Character-matching create mode 120000 Lang/Perl/Colour-bars-Display create mode 120000 Lang/Perl/Colour-pinstripe-Display create mode 120000 Lang/Perl/Combinations create mode 120000 Lang/Perl/Combinations-with-repetitions create mode 120000 Lang/Perl/Command-line-arguments create mode 120000 Lang/Perl/Compile-time-calculation create mode 120000 Lang/Perl/Compound-data-type create mode 120000 Lang/Perl/Concurrent-computing create mode 120000 Lang/Perl/Conditional-structures create mode 120000 Lang/Perl/Constrained-random-points-on-a-circle create mode 120000 Lang/Perl/Continued-fraction create mode 120000 Lang/Perl/Conways-Game-of-Life create mode 120000 Lang/Perl/Count-in-factors create mode 120000 Lang/Perl/Count-in-octal create mode 120000 Lang/Perl/Count-occurrences-of-a-substring create mode 120000 Lang/Perl/Create-a-file create mode 120000 Lang/Perl/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Perl/Create-an-HTML-table create mode 120000 Lang/Perl/DNS-query create mode 120000 Lang/Perl/Date-format create mode 120000 Lang/Perl/Date-manipulation create mode 120000 Lang/Perl/Day-of-the-week create mode 120000 Lang/Perl/Deal-cards-for-FreeCell create mode 120000 Lang/Perl/Deepcopy create mode 120000 Lang/Perl/Determine-if-only-one-instance-is-running create mode 120000 Lang/Perl/Distributed-programming create mode 120000 Lang/Perl/Dot-product create mode 120000 Lang/Perl/Doubly-linked-list-Element-definition create mode 120000 Lang/Perl/Doubly-linked-list-Element-insertion create mode 120000 Lang/Perl/Draw-a-cuboid create mode 120000 Lang/Perl/Dynamic-variable-names create mode 120000 Lang/Perl/Echo-server create mode 120000 Lang/Perl/Element-wise-operations create mode 120000 Lang/Perl/Empty-directory create mode 120000 Lang/Perl/Empty-program create mode 120000 Lang/Perl/Empty-string create mode 120000 Lang/Perl/Enforced-immutability create mode 120000 Lang/Perl/Enumerations create mode 120000 Lang/Perl/Equilibrium-index create mode 120000 Lang/Perl/Ethiopian-multiplication create mode 120000 Lang/Perl/Euler-method create mode 120000 Lang/Perl/Evaluate-binomial-coefficients create mode 120000 Lang/Perl/Even-or-odd create mode 120000 Lang/Perl/Events create mode 120000 Lang/Perl/Evolutionary-algorithm create mode 120000 Lang/Perl/Exceptions create mode 120000 Lang/Perl/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Perl/Executable-library create mode 120000 Lang/Perl/Execute-a-system-command create mode 120000 Lang/Perl/Exponentiation-operator create mode 120000 Lang/Perl/Extend-your-language create mode 120000 Lang/Perl/Extreme-floating-point-values create mode 120000 Lang/PicoLisp/CSV-to-HTML-translation create mode 120000 Lang/PicoLisp/Calendar-for-real-programmers create mode 120000 Lang/PicoLisp/Call-a-foreign-language-function create mode 120000 Lang/PicoLisp/Call-a-function create mode 120000 Lang/PicoLisp/Call-a-function-in-a-shared-library create mode 120000 Lang/PicoLisp/Call-an-object-method create mode 120000 Lang/PicoLisp/Case-sensitivity-of-identifiers create mode 120000 Lang/PicoLisp/Character-codes create mode 120000 Lang/PicoLisp/Character-matching create mode 120000 Lang/PicoLisp/Chat-server create mode 120000 Lang/PicoLisp/Cholesky-decomposition create mode 120000 Lang/PicoLisp/Colour-bars-Display create mode 120000 Lang/PicoLisp/Colour-pinstripe-Display create mode 120000 Lang/PicoLisp/Colour-pinstripe-Printer create mode 120000 Lang/PicoLisp/Combinations create mode 120000 Lang/PicoLisp/Combinations-with-repetitions create mode 120000 Lang/PicoLisp/Command-line-arguments create mode 120000 Lang/PicoLisp/Compile-time-calculation create mode 120000 Lang/PicoLisp/Compound-data-type create mode 120000 Lang/PicoLisp/Concurrent-computing create mode 120000 Lang/PicoLisp/Conditional-structures create mode 120000 Lang/PicoLisp/Constrained-genericity create mode 120000 Lang/PicoLisp/Constrained-random-points-on-a-circle create mode 120000 Lang/PicoLisp/Conways-Game-of-Life create mode 120000 Lang/PicoLisp/Count-in-factors create mode 120000 Lang/PicoLisp/Count-in-octal create mode 120000 Lang/PicoLisp/Count-occurrences-of-a-substring create mode 120000 Lang/PicoLisp/Count-the-coins create mode 120000 Lang/PicoLisp/Create-a-file create mode 120000 Lang/PicoLisp/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/PicoLisp/Create-an-HTML-table create mode 120000 Lang/PicoLisp/Create-an-object-at-a-given-address create mode 120000 Lang/PicoLisp/DNS-query create mode 120000 Lang/PicoLisp/Date-format create mode 120000 Lang/PicoLisp/Date-manipulation create mode 120000 Lang/PicoLisp/Day-of-the-week create mode 120000 Lang/PicoLisp/Deal-cards-for-FreeCell create mode 120000 Lang/PicoLisp/Deconvolution-1D create mode 120000 Lang/PicoLisp/Deepcopy create mode 120000 Lang/PicoLisp/Determine-if-only-one-instance-is-running create mode 120000 Lang/PicoLisp/Digital-root create mode 120000 Lang/PicoLisp/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/PicoLisp/Dining-philosophers create mode 120000 Lang/PicoLisp/Discordian-date create mode 120000 Lang/PicoLisp/Distributed-programming create mode 120000 Lang/PicoLisp/Documentation create mode 120000 Lang/PicoLisp/Dot-product create mode 120000 Lang/PicoLisp/Doubly-linked-list-Definition create mode 120000 Lang/PicoLisp/Doubly-linked-list-Element-definition create mode 120000 Lang/PicoLisp/Doubly-linked-list-Element-insertion create mode 120000 Lang/PicoLisp/Doubly-linked-list-Traversal create mode 120000 Lang/PicoLisp/Draw-a-cuboid create mode 120000 Lang/PicoLisp/Draw-a-sphere create mode 120000 Lang/PicoLisp/Dutch-national-flag-problem create mode 120000 Lang/PicoLisp/Dynamic-variable-names create mode 120000 Lang/PicoLisp/Echo-server create mode 120000 Lang/PicoLisp/Element-wise-operations create mode 120000 Lang/PicoLisp/Empty-directory create mode 120000 Lang/PicoLisp/Empty-program create mode 120000 Lang/PicoLisp/Empty-string create mode 120000 Lang/PicoLisp/Enforced-immutability create mode 120000 Lang/PicoLisp/Enumerations create mode 120000 Lang/PicoLisp/Equilibrium-index create mode 120000 Lang/PicoLisp/Ethiopian-multiplication create mode 120000 Lang/PicoLisp/Euler-method create mode 120000 Lang/PicoLisp/Evaluate-binomial-coefficients create mode 120000 Lang/PicoLisp/Even-or-odd create mode 120000 Lang/PicoLisp/Events create mode 120000 Lang/PicoLisp/Evolutionary-algorithm create mode 120000 Lang/PicoLisp/Exceptions create mode 120000 Lang/PicoLisp/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/PicoLisp/Executable-library create mode 120000 Lang/PicoLisp/Execute-HQ9+ create mode 120000 Lang/PicoLisp/Execute-a-system-command create mode 120000 Lang/PicoLisp/Exponentiation-operator create mode 120000 Lang/PicoLisp/Extend-your-language create mode 120000 Lang/PicoLisp/Extreme-floating-point-values create mode 120000 Lang/Prolog/CSV-to-HTML-translation create mode 120000 Lang/Prolog/Case-sensitivity-of-identifiers create mode 120000 Lang/Prolog/Combinations create mode 120000 Lang/Prolog/Constrained-random-points-on-a-circle create mode 120000 Lang/Prolog/Continued-fraction create mode 120000 Lang/Prolog/Conways-Game-of-Life create mode 120000 Lang/Prolog/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/Prolog/Dining-philosophers create mode 120000 Lang/Prolog/Dot-product create mode 120000 Lang/Prolog/Draw-a-cuboid create mode 120000 Lang/Prolog/Dutch-national-flag-problem create mode 120000 Lang/Prolog/Execute-a-system-command create mode 120000 Lang/Python/CRC-32 create mode 120000 Lang/Python/CSV-to-HTML-translation create mode 120000 Lang/Python/Call-a-foreign-language-function create mode 120000 Lang/Python/Call-a-function create mode 120000 Lang/Python/Call-a-function-in-a-shared-library create mode 120000 Lang/Python/Call-an-object-method create mode 120000 Lang/Python/Carmichael-3-strong-pseudoprimes create mode 120000 Lang/Python/Case-sensitivity-of-identifiers create mode 120000 Lang/Python/Character-codes create mode 120000 Lang/Python/Character-matching create mode 120000 Lang/Python/Chat-server create mode 120000 Lang/Python/Check-Machin-like-formulas create mode 120000 Lang/Python/Cholesky-decomposition create mode 120000 Lang/Python/Colour-bars-Display create mode 120000 Lang/Python/Combinations create mode 120000 Lang/Python/Combinations-with-repetitions create mode 120000 Lang/Python/Command-line-arguments create mode 120000 Lang/Python/Compare-sorting-algorithms-performance create mode 120000 Lang/Python/Compound-data-type create mode 120000 Lang/Python/Concurrent-computing create mode 120000 Lang/Python/Conditional-structures create mode 120000 Lang/Python/Constrained-random-points-on-a-circle create mode 120000 Lang/Python/Continued-fraction create mode 120000 Lang/Python/Continued-fraction-Arithmetic-Construct-from-rational-number create mode 120000 Lang/Python/Conways-Game-of-Life create mode 120000 Lang/Python/Count-in-factors create mode 120000 Lang/Python/Count-in-octal create mode 120000 Lang/Python/Count-occurrences-of-a-substring create mode 120000 Lang/Python/Count-the-coins create mode 120000 Lang/Python/Create-a-file create mode 120000 Lang/Python/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Python/Create-an-HTML-table create mode 120000 Lang/Python/Cut-a-rectangle create mode 120000 Lang/Python/Date-format create mode 120000 Lang/Python/Date-manipulation create mode 120000 Lang/Python/Day-of-the-week create mode 120000 Lang/Python/Deal-cards-for-FreeCell create mode 120000 Lang/Python/Deconvolution-1D create mode 120000 Lang/Python/Deepcopy create mode 120000 Lang/Python/Determine-if-only-one-instance-is-running create mode 120000 Lang/Python/Digital-root create mode 120000 Lang/Python/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/Python/Dining-philosophers create mode 120000 Lang/Python/Discordian-date create mode 120000 Lang/Python/Distributed-programming create mode 120000 Lang/Python/Documentation create mode 120000 Lang/Python/Dot-product create mode 120000 Lang/Python/Doubly-linked-list-Element-definition create mode 120000 Lang/Python/Doubly-linked-list-Element-insertion create mode 120000 Lang/Python/Doubly-linked-list-Traversal create mode 120000 Lang/Python/Draw-a-cuboid create mode 120000 Lang/Python/Draw-a-sphere create mode 120000 Lang/Python/Dutch-national-flag-problem create mode 120000 Lang/Python/Dynamic-variable-names create mode 120000 Lang/Python/Echo-server create mode 120000 Lang/Python/Element-wise-operations create mode 120000 Lang/Python/Empty-directory create mode 120000 Lang/Python/Empty-string create mode 120000 Lang/Python/Enforced-immutability create mode 120000 Lang/Python/Enumerations create mode 120000 Lang/Python/Equilibrium-index create mode 120000 Lang/Python/Ethiopian-multiplication create mode 120000 Lang/Python/Euler-method create mode 120000 Lang/Python/Evaluate-binomial-coefficients create mode 120000 Lang/Python/Even-or-odd create mode 120000 Lang/Python/Evolutionary-algorithm create mode 120000 Lang/Python/Exceptions create mode 120000 Lang/Python/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Python/Executable-library create mode 120000 Lang/Python/Execute-a-system-command create mode 120000 Lang/Python/Exponentiation-operator create mode 120000 Lang/Python/Extreme-floating-point-values create mode 120000 Lang/R/Case-sensitivity-of-identifiers create mode 120000 Lang/R/Character-codes create mode 120000 Lang/R/Cholesky-decomposition create mode 120000 Lang/R/Colour-bars-Display create mode 120000 Lang/R/Combinations create mode 120000 Lang/R/Command-line-arguments create mode 120000 Lang/R/Compound-data-type create mode 120000 Lang/R/Conditional-structures create mode 120000 Lang/R/Constrained-random-points-on-a-circle create mode 120000 Lang/R/Conways-Game-of-Life create mode 120000 Lang/R/Create-a-file create mode 120000 Lang/R/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/R/Date-format create mode 120000 Lang/R/Date-manipulation create mode 120000 Lang/R/Day-of-the-week create mode 120000 Lang/R/Deconvolution-1D create mode 120000 Lang/R/Documentation create mode 120000 Lang/R/Dot-product create mode 120000 Lang/R/Dynamic-variable-names create mode 120000 Lang/R/Element-wise-operations create mode 120000 Lang/R/Empty-string create mode 120000 Lang/R/Enumerations create mode 120000 Lang/R/Ethiopian-multiplication create mode 120000 Lang/R/Evaluate-binomial-coefficients create mode 120000 Lang/R/Even-or-odd create mode 120000 Lang/R/Evolutionary-algorithm create mode 120000 Lang/R/Exceptions create mode 120000 Lang/R/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/R/Execute-a-system-command create mode 120000 Lang/R/Exponentiation-operator create mode 120000 Lang/R/Extend-your-language create mode 120000 Lang/R/Extreme-floating-point-values create mode 120000 Lang/REXX/CRC-32 create mode 120000 Lang/REXX/CSV-to-HTML-translation create mode 120000 Lang/REXX/Calendar-for-real-programmers create mode 120000 Lang/REXX/Call-a-function create mode 120000 Lang/REXX/Carmichael-3-strong-pseudoprimes create mode 120000 Lang/REXX/Case-sensitivity-of-identifiers create mode 120000 Lang/REXX/Character-codes create mode 120000 Lang/REXX/Character-matching create mode 120000 Lang/REXX/Cholesky-decomposition create mode 120000 Lang/REXX/Combinations create mode 120000 Lang/REXX/Combinations-with-repetitions create mode 120000 Lang/REXX/Command-line-arguments create mode 120000 Lang/REXX/Compile-time-calculation create mode 120000 Lang/REXX/Compound-data-type create mode 120000 Lang/REXX/Conditional-structures create mode 120000 Lang/REXX/Constrained-random-points-on-a-circle create mode 120000 Lang/REXX/Continued-fraction create mode 120000 Lang/REXX/Continued-fraction-Arithmetic-Construct-from-rational-number create mode 120000 Lang/REXX/Conways-Game-of-Life create mode 120000 Lang/REXX/Count-in-factors create mode 120000 Lang/REXX/Count-in-octal create mode 120000 Lang/REXX/Count-occurrences-of-a-substring create mode 120000 Lang/REXX/Count-the-coins create mode 120000 Lang/REXX/Create-a-file create mode 120000 Lang/REXX/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/REXX/Create-an-HTML-table create mode 120000 Lang/REXX/Cut-a-rectangle create mode 120000 Lang/REXX/Date-format create mode 120000 Lang/REXX/Date-manipulation create mode 120000 Lang/REXX/Day-of-the-week create mode 120000 Lang/REXX/Digital-root create mode 120000 Lang/REXX/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/REXX/Discordian-date create mode 120000 Lang/REXX/Documentation create mode 120000 Lang/REXX/Dot-product create mode 120000 Lang/REXX/Doubly-linked-list-Definition create mode 120000 Lang/REXX/Doubly-linked-list-Element-definition create mode 120000 Lang/REXX/Doubly-linked-list-Element-insertion create mode 120000 Lang/REXX/Doubly-linked-list-Traversal create mode 120000 Lang/REXX/Draw-a-cuboid create mode 120000 Lang/REXX/Draw-a-sphere create mode 120000 Lang/REXX/Dutch-national-flag-problem create mode 120000 Lang/REXX/Dynamic-variable-names create mode 120000 Lang/REXX/Element-wise-operations create mode 120000 Lang/REXX/Empty-program create mode 120000 Lang/REXX/Empty-string create mode 120000 Lang/REXX/Enumerations create mode 120000 Lang/REXX/Equilibrium-index create mode 120000 Lang/REXX/Ethiopian-multiplication create mode 120000 Lang/REXX/Evaluate-binomial-coefficients create mode 120000 Lang/REXX/Even-or-odd create mode 120000 Lang/REXX/Evolutionary-algorithm create mode 120000 Lang/REXX/Executable-library create mode 120000 Lang/REXX/Execute-HQ9+ create mode 120000 Lang/REXX/Execute-a-system-command create mode 120000 Lang/REXX/Exponentiation-operator create mode 120000 Lang/Racket/CSV-to-HTML-translation create mode 120000 Lang/Racket/Call-a-foreign-language-function create mode 120000 Lang/Racket/Call-a-function-in-a-shared-library create mode 120000 Lang/Racket/Call-an-object-method create mode 120000 Lang/Racket/Case-sensitivity-of-identifiers create mode 120000 Lang/Racket/Character-matching create mode 120000 Lang/Racket/Color-quantization create mode 120000 Lang/Racket/Command-line-arguments create mode 120000 Lang/Racket/Compile-time-calculation create mode 120000 Lang/Racket/Compound-data-type create mode 120000 Lang/Racket/Concurrent-computing create mode 120000 Lang/Racket/Conways-Game-of-Life create mode 120000 Lang/Racket/Count-in-factors create mode 120000 Lang/Racket/Count-in-octal create mode 120000 Lang/Racket/Create-a-file create mode 120000 Lang/Racket/Create-an-HTML-table create mode 120000 Lang/Racket/DNS-query create mode 120000 Lang/Racket/Date-format create mode 120000 Lang/Racket/Digital-root create mode 120000 Lang/Racket/Documentation create mode 120000 Lang/Racket/Dot-product create mode 120000 Lang/Racket/Draw-a-sphere create mode 120000 Lang/Racket/Echo-server create mode 120000 Lang/Racket/Empty-directory create mode 120000 Lang/Racket/Empty-program create mode 120000 Lang/Racket/Empty-string create mode 120000 Lang/Racket/Evaluate-binomial-coefficients create mode 120000 Lang/Racket/Even-or-odd create mode 120000 Lang/Racket/Exceptions create mode 120000 Lang/Ruby/CRC-32 create mode 120000 Lang/Ruby/CSV-to-HTML-translation create mode 120000 Lang/Ruby/Calendar-for-real-programmers create mode 120000 Lang/Ruby/Call-a-foreign-language-function create mode 120000 Lang/Ruby/Call-a-function-in-a-shared-library create mode 120000 Lang/Ruby/Call-an-object-method create mode 120000 Lang/Ruby/Carmichael-3-strong-pseudoprimes create mode 120000 Lang/Ruby/Case-sensitivity-of-identifiers create mode 120000 Lang/Ruby/Character-codes create mode 120000 Lang/Ruby/Character-matching create mode 120000 Lang/Ruby/Chat-server create mode 120000 Lang/Ruby/Cholesky-decomposition create mode 120000 Lang/Ruby/Combinations create mode 120000 Lang/Ruby/Combinations-with-repetitions create mode 120000 Lang/Ruby/Command-line-arguments create mode 120000 Lang/Ruby/Compound-data-type create mode 120000 Lang/Ruby/Concurrent-computing create mode 120000 Lang/Ruby/Constrained-random-points-on-a-circle create mode 120000 Lang/Ruby/Continued-fraction create mode 120000 Lang/Ruby/Continued-fraction-Arithmetic-Construct-from-rational-number create mode 120000 Lang/Ruby/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) create mode 120000 Lang/Ruby/Conways-Game-of-Life create mode 120000 Lang/Ruby/Count-in-factors create mode 120000 Lang/Ruby/Count-in-octal create mode 120000 Lang/Ruby/Count-occurrences-of-a-substring create mode 120000 Lang/Ruby/Count-the-coins create mode 120000 Lang/Ruby/Create-a-file create mode 120000 Lang/Ruby/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Ruby/Create-an-HTML-table create mode 120000 Lang/Ruby/Date-format create mode 120000 Lang/Ruby/Date-manipulation create mode 120000 Lang/Ruby/Day-of-the-week create mode 120000 Lang/Ruby/Deal-cards-for-FreeCell create mode 120000 Lang/Ruby/Deepcopy create mode 120000 Lang/Ruby/Determine-if-only-one-instance-is-running create mode 120000 Lang/Ruby/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/Ruby/Dining-philosophers create mode 120000 Lang/Ruby/Discordian-date create mode 120000 Lang/Ruby/Distributed-programming create mode 120000 Lang/Ruby/Documentation create mode 120000 Lang/Ruby/Dot-product create mode 120000 Lang/Ruby/Doubly-linked-list-Element-definition create mode 120000 Lang/Ruby/Doubly-linked-list-Element-insertion create mode 120000 Lang/Ruby/Doubly-linked-list-Traversal create mode 120000 Lang/Ruby/Draw-a-sphere create mode 120000 Lang/Ruby/Dutch-national-flag-problem create mode 120000 Lang/Ruby/Dynamic-variable-names create mode 120000 Lang/Ruby/Echo-server create mode 120000 Lang/Ruby/Empty-directory create mode 120000 Lang/Ruby/Empty-program create mode 120000 Lang/Ruby/Empty-string create mode 120000 Lang/Ruby/Enforced-immutability create mode 120000 Lang/Ruby/Enumerations create mode 120000 Lang/Ruby/Equilibrium-index create mode 120000 Lang/Ruby/Ethiopian-multiplication create mode 120000 Lang/Ruby/Euler-method create mode 120000 Lang/Ruby/Evaluate-binomial-coefficients create mode 120000 Lang/Ruby/Even-or-odd create mode 120000 Lang/Ruby/Evolutionary-algorithm create mode 120000 Lang/Ruby/Exceptions create mode 120000 Lang/Ruby/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Ruby/Executable-library create mode 120000 Lang/Ruby/Execute-a-system-command create mode 120000 Lang/Ruby/Exponentiation-operator create mode 120000 Lang/Ruby/Extend-your-language create mode 120000 Lang/Ruby/Extreme-floating-point-values create mode 120000 Lang/SNUSP/Conditional-structures create mode 120000 Lang/SNUSP/Ethiopian-multiplication create mode 120000 Lang/SNUSP/Even-or-odd create mode 120000 Lang/Sather/Case-sensitivity-of-identifiers create mode 120000 Lang/Sather/Character-codes create mode 120000 Lang/Sather/Command-line-arguments create mode 120000 Lang/Sather/Conditional-structures create mode 120000 Lang/Sather/Constrained-genericity create mode 120000 Lang/Sather/Dot-product create mode 120000 Lang/Scala/CSV-to-HTML-translation create mode 120000 Lang/Scala/Case-sensitivity-of-identifiers create mode 120000 Lang/Scala/Character-codes create mode 120000 Lang/Scala/Character-matching create mode 120000 Lang/Scala/Colour-bars-Display create mode 120000 Lang/Scala/Combinations create mode 120000 Lang/Scala/Combinations-with-repetitions create mode 120000 Lang/Scala/Command-line-arguments create mode 120000 Lang/Scala/Compound-data-type create mode 120000 Lang/Scala/Concurrent-computing create mode 120000 Lang/Scala/Constrained-genericity create mode 120000 Lang/Scala/Continued-fraction create mode 120000 Lang/Scala/Count-in-octal create mode 120000 Lang/Scala/Count-occurrences-of-a-substring create mode 120000 Lang/Scala/Count-the-coins create mode 120000 Lang/Scala/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Scala/Date-format create mode 120000 Lang/Scala/Date-manipulation create mode 120000 Lang/Scala/Day-of-the-week create mode 120000 Lang/Scala/Digital-root create mode 120000 Lang/Scala/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/Scala/Discordian-date create mode 120000 Lang/Scala/Dot-product create mode 120000 Lang/Scala/Empty-directory create mode 120000 Lang/Scala/Empty-program create mode 120000 Lang/Scala/Empty-string create mode 120000 Lang/Scala/Enforced-immutability create mode 120000 Lang/Scala/Enumerations create mode 120000 Lang/Scala/Ethiopian-multiplication create mode 120000 Lang/Scala/Euler-method create mode 120000 Lang/Scala/Evaluate-binomial-coefficients create mode 120000 Lang/Scala/Even-or-odd create mode 120000 Lang/Scala/Evolutionary-algorithm create mode 120000 Lang/Scala/Execute-HQ9+ create mode 120000 Lang/Scala/Execute-a-system-command create mode 120000 Lang/Scala/Exponentiation-operator create mode 120000 Lang/Scala/Extend-your-language create mode 120000 Lang/Scheme/Case-sensitivity-of-identifiers create mode 120000 Lang/Scheme/Character-codes create mode 120000 Lang/Scheme/Combinations create mode 120000 Lang/Scheme/Combinations-with-repetitions create mode 120000 Lang/Scheme/Command-line-arguments create mode 120000 Lang/Scheme/Compound-data-type create mode 120000 Lang/Scheme/Concurrent-computing create mode 120000 Lang/Scheme/Conditional-structures create mode 120000 Lang/Scheme/Conways-Game-of-Life create mode 120000 Lang/Scheme/Count-in-factors create mode 120000 Lang/Scheme/Count-in-octal create mode 120000 Lang/Scheme/Count-the-coins create mode 120000 Lang/Scheme/Create-a-file create mode 120000 Lang/Scheme/Create-an-HTML-table create mode 120000 Lang/Scheme/DNS-query create mode 120000 Lang/Scheme/Day-of-the-week create mode 120000 Lang/Scheme/Dot-product create mode 120000 Lang/Scheme/Dynamic-variable-names create mode 120000 Lang/Scheme/Echo-server create mode 120000 Lang/Scheme/Empty-program create mode 120000 Lang/Scheme/Empty-string create mode 120000 Lang/Scheme/Enumerations create mode 120000 Lang/Scheme/Ethiopian-multiplication create mode 120000 Lang/Scheme/Evaluate-binomial-coefficients create mode 120000 Lang/Scheme/Even-or-odd create mode 120000 Lang/Scheme/Exceptions create mode 120000 Lang/Scheme/Execute-a-system-command create mode 120000 Lang/Scheme/Exponentiation-operator create mode 120000 Lang/Scheme/Extend-your-language create mode 120000 Lang/Scheme/Extreme-floating-point-values create mode 120000 Lang/Smalltalk/CRC-32 create mode 120000 Lang/Smalltalk/Call-a-function create mode 120000 Lang/Smalltalk/Call-a-function-in-a-shared-library create mode 120000 Lang/Smalltalk/Call-an-object-method create mode 120000 Lang/Smalltalk/Case-sensitivity-of-identifiers create mode 120000 Lang/Smalltalk/Character-codes create mode 120000 Lang/Smalltalk/Character-matching create mode 120000 Lang/Smalltalk/Combinations create mode 120000 Lang/Smalltalk/Command-line-arguments create mode 120000 Lang/Smalltalk/Conditional-structures create mode 120000 Lang/Smalltalk/Create-a-file create mode 120000 Lang/Smalltalk/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Smalltalk/Date-manipulation create mode 120000 Lang/Smalltalk/Day-of-the-week create mode 120000 Lang/Smalltalk/Dining-philosophers create mode 120000 Lang/Smalltalk/Documentation create mode 120000 Lang/Smalltalk/Dot-product create mode 120000 Lang/Smalltalk/Draw-a-sphere create mode 120000 Lang/Smalltalk/Dynamic-variable-names create mode 120000 Lang/Smalltalk/Empty-program create mode 120000 Lang/Smalltalk/Ethiopian-multiplication create mode 120000 Lang/Smalltalk/Evolutionary-algorithm create mode 120000 Lang/Smalltalk/Exceptions create mode 120000 Lang/Smalltalk/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Smalltalk/Execute-a-system-command create mode 120000 Lang/Smalltalk/Exponentiation-operator create mode 120000 Lang/Tcl/CRC-32 create mode 120000 Lang/Tcl/CSV-to-HTML-translation create mode 120000 Lang/Tcl/Calendar-for-real-programmers create mode 120000 Lang/Tcl/Call-a-foreign-language-function create mode 120000 Lang/Tcl/Call-a-function create mode 120000 Lang/Tcl/Call-a-function-in-a-shared-library create mode 120000 Lang/Tcl/Call-an-object-method create mode 120000 Lang/Tcl/Canny-edge-detector create mode 120000 Lang/Tcl/Carmichael-3-strong-pseudoprimes create mode 120000 Lang/Tcl/Case-sensitivity-of-identifiers create mode 120000 Lang/Tcl/Catmull-Clark-subdivision-surface create mode 120000 Lang/Tcl/Character-codes create mode 120000 Lang/Tcl/Character-matching create mode 120000 Lang/Tcl/Chat-server create mode 120000 Lang/Tcl/Check-Machin-like-formulas create mode 120000 Lang/Tcl/Cholesky-decomposition create mode 120000 Lang/Tcl/Color-quantization create mode 120000 Lang/Tcl/Colour-bars-Display create mode 120000 Lang/Tcl/Colour-pinstripe-Display create mode 120000 Lang/Tcl/Colour-pinstripe-Printer create mode 120000 Lang/Tcl/Combinations create mode 120000 Lang/Tcl/Combinations-with-repetitions create mode 120000 Lang/Tcl/Command-line-arguments create mode 120000 Lang/Tcl/Compare-sorting-algorithms-performance create mode 120000 Lang/Tcl/Compile-time-calculation create mode 120000 Lang/Tcl/Compound-data-type create mode 120000 Lang/Tcl/Concurrent-computing create mode 120000 Lang/Tcl/Conditional-structures create mode 120000 Lang/Tcl/Constrained-random-points-on-a-circle create mode 120000 Lang/Tcl/Continued-fraction create mode 120000 Lang/Tcl/Continued-fraction-Arithmetic-Construct-from-rational-number create mode 120000 Lang/Tcl/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) create mode 120000 Lang/Tcl/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2) create mode 120000 Lang/Tcl/Conways-Game-of-Life create mode 120000 Lang/Tcl/Count-in-factors create mode 120000 Lang/Tcl/Count-in-octal create mode 120000 Lang/Tcl/Count-occurrences-of-a-substring create mode 120000 Lang/Tcl/Count-the-coins create mode 120000 Lang/Tcl/Create-a-file create mode 120000 Lang/Tcl/Create-a-file-on-magnetic-tape create mode 120000 Lang/Tcl/Create-a-two-dimensional-array-at-runtime create mode 120000 Lang/Tcl/Create-an-HTML-table create mode 120000 Lang/Tcl/Create-an-object-at-a-given-address create mode 120000 Lang/Tcl/Cut-a-rectangle create mode 120000 Lang/Tcl/DNS-query create mode 120000 Lang/Tcl/Date-format create mode 120000 Lang/Tcl/Date-manipulation create mode 120000 Lang/Tcl/Day-of-the-week create mode 120000 Lang/Tcl/Deal-cards-for-FreeCell create mode 120000 Lang/Tcl/Deconvolution-1D create mode 120000 Lang/Tcl/Deconvolution-2D+ create mode 120000 Lang/Tcl/Deepcopy create mode 120000 Lang/Tcl/Determine-if-only-one-instance-is-running create mode 120000 Lang/Tcl/Digital-root create mode 120000 Lang/Tcl/Dinesmans-multiple-dwelling-problem create mode 120000 Lang/Tcl/Dining-philosophers create mode 120000 Lang/Tcl/Discordian-date create mode 120000 Lang/Tcl/Distributed-programming create mode 120000 Lang/Tcl/Documentation create mode 120000 Lang/Tcl/Dot-product create mode 120000 Lang/Tcl/Doubly-linked-list-Definition create mode 120000 Lang/Tcl/Doubly-linked-list-Element-definition create mode 120000 Lang/Tcl/Doubly-linked-list-Element-insertion create mode 120000 Lang/Tcl/Doubly-linked-list-Traversal create mode 120000 Lang/Tcl/Draw-a-cuboid create mode 120000 Lang/Tcl/Draw-a-sphere create mode 120000 Lang/Tcl/Dutch-national-flag-problem create mode 120000 Lang/Tcl/Dynamic-variable-names create mode 120000 Lang/Tcl/Echo-server create mode 120000 Lang/Tcl/Element-wise-operations create mode 120000 Lang/Tcl/Empty-directory create mode 120000 Lang/Tcl/Empty-program create mode 120000 Lang/Tcl/Empty-string create mode 120000 Lang/Tcl/Enforced-immutability create mode 120000 Lang/Tcl/Enumerations create mode 120000 Lang/Tcl/Equilibrium-index create mode 120000 Lang/Tcl/Ethiopian-multiplication create mode 120000 Lang/Tcl/Euler-method create mode 120000 Lang/Tcl/Evaluate-binomial-coefficients create mode 120000 Lang/Tcl/Even-or-odd create mode 120000 Lang/Tcl/Events create mode 120000 Lang/Tcl/Evolutionary-algorithm create mode 120000 Lang/Tcl/Exceptions create mode 120000 Lang/Tcl/Exceptions-Catch-an-exception-thrown-in-a-nested-call create mode 120000 Lang/Tcl/Executable-library create mode 120000 Lang/Tcl/Execute-a-system-command create mode 120000 Lang/Tcl/Exponentiation-operator create mode 120000 Lang/Tcl/Extend-your-language create mode 120000 Lang/Tcl/Extreme-floating-point-values create mode 100644 Task/100-doors/C++/100-doors-1.cpp create mode 100644 Task/100-doors/C++/100-doors-2.cpp create mode 100644 Task/100-doors/C++/100-doors-3.cpp create mode 100644 Task/100-doors/C-sharp/100-doors-1.cs create mode 100644 Task/100-doors/C-sharp/100-doors-2.cs create mode 100644 Task/100-doors/C-sharp/100-doors-3.cs create mode 100644 Task/100-doors/C-sharp/100-doors-4.cs create mode 100644 Task/100-doors/C1R/100-doors.c1r create mode 100644 Task/100-doors/CLIPS/100-doors-1.clips create mode 100644 Task/100-doors/CLIPS/100-doors-2.clips create mode 100644 Task/100-doors/COBOL/100-doors.cobol create mode 100644 Task/100-doors/ColdFusion/100-doors-1.cfm create mode 100644 Task/100-doors/ColdFusion/100-doors-2.cfm create mode 100644 Task/100-doors/ColdFusion/100-doors-3.cfm create mode 100644 Task/100-doors/Common-Lisp/100-doors-1.lisp create mode 100644 Task/100-doors/Common-Lisp/100-doors-2.lisp create mode 100644 Task/100-doors/Common-Lisp/100-doors-3.lisp create mode 100644 Task/100-doors/Common-Lisp/100-doors-4.lisp create mode 100644 Task/100-doors/D/100-doors.d create mode 100644 Task/100-doors/DWScript/100-doors.dwscript create mode 100644 Task/100-doors/Dart/100-doors-1.dart create mode 100644 Task/100-doors/Dart/100-doors-2.dart create mode 100644 Task/100-doors/E/100-doors.e create mode 100644 Task/100-doors/EGL/100-doors.egl create mode 100644 Task/100-doors/Ela/100-doors-1.ela create mode 100644 Task/100-doors/Ela/100-doors-2.ela create mode 100644 Task/100-doors/Emacs-Lisp/100-doors.l create mode 100644 Task/100-doors/Euler-Math-Toolbox/100-doors.euler create mode 100644 Task/100-doors/Euphoria/100-doors.euphoria create mode 100644 Task/24-game/C++/24-game.cpp create mode 100644 Task/24-game/Common-Lisp/24-game-1.lisp create mode 100644 Task/24-game/Common-Lisp/24-game-2.lisp create mode 100644 Task/24-game/D/24-game.d create mode 100644 Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-1.cpp create mode 100644 Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-2.cpp create mode 100644 Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-3.cpp create mode 100644 Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-4.cpp create mode 100644 Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-5.cpp create mode 100644 Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-1.cs create mode 100644 Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-2.cs create mode 100644 Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-3.cs create mode 100644 Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-4.cs create mode 100644 Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-5.cs create mode 100644 Task/99-Bottles-of-Beer/CLIPS/99-bottles-of-beer.clips create mode 100644 Task/99-Bottles-of-Beer/COBOL/99-bottles-of-beer-1.cobol create mode 100644 Task/99-Bottles-of-Beer/COBOL/99-bottles-of-beer-2.cobol create mode 100644 Task/99-Bottles-of-Beer/Chapel/99-bottles-of-beer.chapel create mode 100644 Task/99-Bottles-of-Beer/Chef/99-bottles-of-beer.chef create mode 100644 Task/99-Bottles-of-Beer/Clay/99-bottles-of-beer.clay create mode 100644 Task/99-Bottles-of-Beer/ColdFusion/99-bottles-of-beer-1.cfm create mode 100644 Task/99-Bottles-of-Beer/ColdFusion/99-bottles-of-beer-2.cfm create mode 100644 Task/99-Bottles-of-Beer/Common-Lisp/99-bottles-of-beer-1.lisp create mode 100644 Task/99-Bottles-of-Beer/Common-Lisp/99-bottles-of-beer-2.lisp create mode 100644 Task/99-Bottles-of-Beer/D/99-bottles-of-beer.d create mode 100644 Task/99-Bottles-of-Beer/Dart/99-bottles-of-beer.dart create mode 100644 Task/99-Bottles-of-Beer/Delphi/99-bottles-of-beer.delphi create mode 100644 Task/99-Bottles-of-Beer/E/99-bottles-of-beer.e create mode 100644 Task/99-Bottles-of-Beer/EGL/99-bottles-of-beer.egl create mode 100644 Task/99-Bottles-of-Beer/Ela/99-bottles-of-beer.ela create mode 100644 Task/99-Bottles-of-Beer/Euphoria/99-bottles-of-beer.euphoria create mode 100644 Task/A+B/C++/a+b-1.cpp create mode 100644 Task/A+B/C++/a+b-2.cpp create mode 100644 Task/A+B/Common-Lisp/a+b.lisp create mode 100644 Task/A+B/D/a+b-1.d create mode 100644 Task/A+B/D/a+b-2.d create mode 100644 Task/A+B/DMS/a+b.dms create mode 100644 Task/A+B/DWScript/a+b.dwscript create mode 100644 Task/A+B/Deja-Vu/a+b.djv create mode 100644 Task/A+B/Delphi/a+b.delphi create mode 100644 Task/A+B/EGL/a+b.egl create mode 100644 Task/A+B/Ela/a+b.ela create mode 100644 Task/A+B/Elena/a+b.elena create mode 100644 Task/A+B/Euler-Math-Toolbox/a+b.euler create mode 100644 Task/A+B/Euphoria/a+b.euphoria create mode 100644 Task/Abstract-type/C++/abstract-type.cpp create mode 100644 Task/Abstract-type/C-sharp/abstract-type.cs create mode 100644 Task/Abstract-type/Common-Lisp/abstract-type-1.lisp create mode 100644 Task/Abstract-type/Common-Lisp/abstract-type-2.lisp create mode 100644 Task/Abstract-type/Common-Lisp/abstract-type-3.lisp create mode 100644 Task/Abstract-type/D/abstract-type.d create mode 100644 Task/Abstract-type/Delphi/abstract-type-1.delphi create mode 100644 Task/Abstract-type/Delphi/abstract-type-2.delphi create mode 100644 Task/Abstract-type/E/abstract-type-1.e create mode 100644 Task/Abstract-type/E/abstract-type-2.e create mode 100644 Task/Accumulator-factory/C++/accumulator-factory-1.cpp create mode 100644 Task/Accumulator-factory/C++/accumulator-factory-2.cpp create mode 100644 Task/Accumulator-factory/Clay/accumulator-factory-1.clay create mode 100644 Task/Accumulator-factory/Clay/accumulator-factory-2.clay create mode 100644 Task/Accumulator-factory/Clay/accumulator-factory-3.clay create mode 100644 Task/Accumulator-factory/Common-Lisp/accumulator-factory-1.lisp create mode 100644 Task/Accumulator-factory/Common-Lisp/accumulator-factory-2.lisp create mode 100644 Task/Accumulator-factory/D/accumulator-factory.d create mode 100644 Task/Accumulator-factory/E/accumulator-factory.e create mode 100644 Task/Accumulator-factory/Elena/accumulator-factory.elena create mode 100644 Task/Ackermann-function/C++/ackermann-function.cpp create mode 100644 Task/Ackermann-function/C-sharp/ackermann-function.cs create mode 100644 Task/Ackermann-function/CLIPS/ackermann-function-1.clips create mode 100644 Task/Ackermann-function/CLIPS/ackermann-function-2.clips create mode 100644 Task/Ackermann-function/Clay/ackermann-function.clay create mode 100644 Task/Ackermann-function/Common-Lisp/ackermann-function-1.lisp create mode 100644 Task/Ackermann-function/Common-Lisp/ackermann-function-2.lisp create mode 100644 Task/Ackermann-function/Coq/ackermann-function.coq create mode 100644 Task/Ackermann-function/D/ackermann-function-1.d create mode 100644 Task/Ackermann-function/D/ackermann-function-2.d create mode 100644 Task/Ackermann-function/DWScript/ackermann-function.dwscript create mode 100644 Task/Ackermann-function/Dart/ackermann-function.dart create mode 100644 Task/Ackermann-function/Delphi/ackermann-function.delphi create mode 100644 Task/Ackermann-function/E/ackermann-function.e create mode 100644 Task/Ackermann-function/Ela/ackermann-function.ela create mode 100644 Task/Ackermann-function/Elena/ackermann-function.elena create mode 100644 Task/Ackermann-function/Euler-Math-Toolbox/ackermann-function.euler create mode 100644 Task/Ackermann-function/Euphoria/ackermann-function.euphoria create mode 100644 Task/Active-object/E/active-object.e create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Common-Lisp/add-a-variable-to-a-class-instance-at-runtime-1.lisp create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Common-Lisp/add-a-variable-to-a-class-instance-at-runtime-2.lisp create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/D/add-a-variable-to-a-class-instance-at-runtime-1.d create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/D/add-a-variable-to-a-class-instance-at-runtime-2.d create mode 100644 Task/Add-a-variable-to-a-class-instance-at-runtime/Elena/add-a-variable-to-a-class-instance-at-runtime.elena create mode 100644 Task/Address-of-a-variable/C-sharp/address-of-a-variable.cs create mode 100644 Task/Address-of-a-variable/COBOL/address-of-a-variable-1.cobol create mode 100644 Task/Address-of-a-variable/COBOL/address-of-a-variable-2.cobol create mode 100644 Task/Address-of-a-variable/Common-Lisp/address-of-a-variable-1.lisp create mode 100644 Task/Address-of-a-variable/Common-Lisp/address-of-a-variable-2.lisp create mode 100644 Task/Address-of-a-variable/D/address-of-a-variable-1.d create mode 100644 Task/Address-of-a-variable/D/address-of-a-variable-2.d create mode 100644 Task/Address-of-a-variable/D/address-of-a-variable-3.d create mode 100644 Task/Align-columns/C-sharp/align-columns.cs create mode 100644 Task/Align-columns/Common-Lisp/align-columns.lisp create mode 100644 Task/Align-columns/D/align-columns.d create mode 100644 Task/Align-columns/Delphi/align-columns.delphi create mode 100644 Task/Align-columns/E/align-columns-1.e create mode 100644 Task/Align-columns/E/align-columns-2.e create mode 100644 Task/Align-columns/Euphoria/align-columns.euphoria create mode 100644 Task/Anagrams-Deranged-anagrams/Common-Lisp/anagrams-deranged-anagrams.lisp create mode 100644 Task/Anagrams-Deranged-anagrams/D/anagrams-deranged-anagrams.d create mode 100644 Task/Anagrams/C++/anagrams.cpp create mode 100644 Task/Anagrams/Common-Lisp/anagrams-1.lisp create mode 100644 Task/Anagrams/Common-Lisp/anagrams-2.lisp create mode 100644 Task/Anagrams/Common-Lisp/anagrams-3.lisp create mode 100644 Task/Anagrams/Common-Lisp/anagrams-4.lisp create mode 100644 Task/Anagrams/Common-Lisp/anagrams-5.lisp create mode 100644 Task/Anagrams/Common-Lisp/anagrams-6.lisp create mode 100644 Task/Anagrams/E/anagrams.e create mode 100644 Task/Anagrams/Elena/anagrams.elena create mode 100644 Task/Anagrams/Euphoria/anagrams.euphoria create mode 100644 Task/Animate-a-pendulum/C++/animate-a-pendulum-1.cpp create mode 100644 Task/Animate-a-pendulum/C++/animate-a-pendulum-2.cpp create mode 100644 Task/Animate-a-pendulum/C-sharp/animate-a-pendulum.cs create mode 100644 Task/Animate-a-pendulum/E/animate-a-pendulum.e create mode 100644 Task/Animate-a-pendulum/Euphoria/animate-a-pendulum.euphoria create mode 100644 Task/Animation/C-sharp/animation.cs create mode 100644 Task/Animation/Common-Lisp/animation.lisp create mode 100644 Task/Animation/D/animation.d create mode 100644 Task/Animation/E/animation-1.e create mode 100644 Task/Animation/E/animation-2.e create mode 100644 Task/Anonymous-recursion/C++/anonymous-recursion-1.cpp create mode 100644 Task/Anonymous-recursion/C++/anonymous-recursion-2.cpp create mode 100644 Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-1.lisp create mode 100644 Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-2.lisp create mode 100644 Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-3.lisp create mode 100644 Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-4.lisp create mode 100644 Task/Anonymous-recursion/D/anonymous-recursion-1.d create mode 100644 Task/Anonymous-recursion/D/anonymous-recursion-2.d create mode 100644 Task/Anonymous-recursion/Deja-Vu/anonymous-recursion-1.djv create mode 100644 Task/Anonymous-recursion/Deja-Vu/anonymous-recursion-2.djv create mode 100644 Task/Anonymous-recursion/Ela/anonymous-recursion-1.ela create mode 100644 Task/Anonymous-recursion/Ela/anonymous-recursion-2.ela create mode 100644 Task/Anonymous-recursion/Elena/anonymous-recursion.elena create mode 100644 Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-1.cpp create mode 100644 Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-2.cpp create mode 100644 Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-3.cpp create mode 100644 Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-4.cpp create mode 100644 Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-5.cpp create mode 100644 Task/Apply-a-callback-to-an-array/C-sharp/apply-a-callback-to-an-array-1.cs create mode 100644 Task/Apply-a-callback-to-an-array/C-sharp/apply-a-callback-to-an-array-2.cs create mode 100644 Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-1.clean create mode 100644 Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-2.clean create mode 100644 Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-3.clean create mode 100644 Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-1.lisp create mode 100644 Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-2.lisp create mode 100644 Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-3.lisp create mode 100644 Task/Apply-a-callback-to-an-array/D/apply-a-callback-to-an-array.d create mode 100644 Task/Apply-a-callback-to-an-array/Delphi/apply-a-callback-to-an-array.delphi create mode 100644 Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-1.e create mode 100644 Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-2.e create mode 100644 Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-3.e create mode 100644 Task/Apply-a-callback-to-an-array/EGL/apply-a-callback-to-an-array.egl create mode 100644 Task/Apply-a-callback-to-an-array/Efene/apply-a-callback-to-an-array.efene create mode 100644 Task/Apply-a-callback-to-an-array/Elena/apply-a-callback-to-an-array.elena create mode 100644 Task/Apply-a-callback-to-an-array/Euphoria/apply-a-callback-to-an-array.euphoria create mode 100644 Task/Arbitrary-precision-integers-(included)/C-sharp/arbitrary-precision-integers-(included).cs create mode 100644 Task/Arbitrary-precision-integers-(included)/Common-Lisp/arbitrary-precision-integers-(included).lisp create mode 100644 Task/Arbitrary-precision-integers-(included)/D/arbitrary-precision-integers-(included).d create mode 100644 Task/Arbitrary-precision-integers-(included)/E/arbitrary-precision-integers-(included).e create mode 100644 Task/Arbitrary-precision-integers-(included)/Emacs-Lisp/arbitrary-precision-integers-(included).l create mode 100644 Task/Arena-storage-pool/C++/arena-storage-pool-1.cpp create mode 100644 Task/Arena-storage-pool/C++/arena-storage-pool-2.cpp create mode 100644 Task/Arithmetic-Complex/C++/arithmetic-complex.cpp create mode 100644 Task/Arithmetic-Complex/C-sharp/arithmetic-complex-1.cs create mode 100644 Task/Arithmetic-Complex/C-sharp/arithmetic-complex-2.cs create mode 100644 Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-1.lisp create mode 100644 Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-2.lisp create mode 100644 Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-3.lisp create mode 100644 Task/Arithmetic-Complex/D/arithmetic-complex.d create mode 100644 Task/Arithmetic-Complex/Euler-Math-Toolbox/arithmetic-complex.euler create mode 100644 Task/Arithmetic-Complex/Euphoria/arithmetic-complex.euphoria create mode 100644 Task/Arithmetic-Integer/C++/arithmetic-integer.cpp create mode 100644 Task/Arithmetic-Integer/Chef/arithmetic-integer.chef create mode 100644 Task/Arithmetic-Integer/Common-Lisp/arithmetic-integer.lisp create mode 100644 Task/Arithmetic-Integer/D/arithmetic-integer-1.d create mode 100644 Task/Arithmetic-Integer/D/arithmetic-integer-2.d create mode 100644 Task/Arithmetic-Integer/DWScript/arithmetic-integer.dwscript create mode 100644 Task/Arithmetic-Integer/Delphi/arithmetic-integer.delphi create mode 100644 Task/Arithmetic-Integer/E/arithmetic-integer.e create mode 100644 Task/Arithmetic-Integer/Efene/arithmetic-integer.efene create mode 100644 Task/Arithmetic-Integer/Elena/arithmetic-integer.elena create mode 100644 Task/Arithmetic-Integer/Euphoria/arithmetic-integer.euphoria create mode 100644 Task/Arithmetic-Rational/C++/arithmetic-rational.cpp create mode 100644 Task/Arithmetic-Rational/Common-Lisp/arithmetic-rational.lisp create mode 100644 Task/Arithmetic-Rational/D/arithmetic-rational.d create mode 100644 Task/Arithmetic-Rational/Elisa/arithmetic-rational-1.elisa create mode 100644 Task/Arithmetic-Rational/Elisa/arithmetic-rational-2.elisa create mode 100644 Task/Arithmetic-evaluation/C++/arithmetic-evaluation.cpp create mode 100644 Task/Arithmetic-evaluation/Common-Lisp/arithmetic-evaluation.lisp create mode 100644 Task/Arithmetic-evaluation/D/arithmetic-evaluation.d create mode 100644 Task/Arithmetic-evaluation/E/arithmetic-evaluation-1.e create mode 100644 Task/Arithmetic-evaluation/E/arithmetic-evaluation-2.e create mode 100644 Task/Arithmetic-evaluation/Elena/arithmetic-evaluation-1.elena create mode 100644 Task/Arithmetic-evaluation/Elena/arithmetic-evaluation-2.elena create mode 100644 Task/Arithmetic-geometric-mean/C++/arithmetic-geometric-mean.cpp create mode 100644 Task/Arithmetic-geometric-mean/C-sharp/arithmetic-geometric-mean.cs create mode 100644 Task/Arithmetic-geometric-mean/Common-Lisp/arithmetic-geometric-mean.lisp create mode 100644 Task/Arithmetic-geometric-mean/D/arithmetic-geometric-mean.d create mode 100644 Task/Array-concatenation/C++/array-concatenation.cpp create mode 100644 Task/Array-concatenation/C-sharp/array-concatenation-1.cs create mode 100644 Task/Array-concatenation/C-sharp/array-concatenation-2.cs create mode 100644 Task/Array-concatenation/Common-Lisp/array-concatenation.lisp create mode 100644 Task/Array-concatenation/D/array-concatenation.d create mode 100644 Task/Array-concatenation/Delphi/array-concatenation.delphi create mode 100644 Task/Array-concatenation/E/array-concatenation.e create mode 100644 Task/Array-concatenation/EGL/array-concatenation.egl create mode 100644 Task/Array-concatenation/Efene/array-concatenation.efene create mode 100644 Task/Array-concatenation/Elena/array-concatenation.elena create mode 100644 Task/Array-concatenation/Euphoria/array-concatenation.euphoria create mode 100644 Task/Arrays/C++/arrays-1.cpp create mode 100644 Task/Arrays/C++/arrays-2.cpp create mode 100644 Task/Arrays/C++/arrays-3.cpp create mode 100644 Task/Arrays/C++/arrays-4.cpp create mode 100644 Task/Arrays/C++/arrays-5.cpp create mode 100644 Task/Arrays/C++/arrays-6.cpp create mode 100644 Task/Arrays/C-sharp/arrays-1.cs create mode 100644 Task/Arrays/C-sharp/arrays-10.cs create mode 100644 Task/Arrays/C-sharp/arrays-11.cs create mode 100644 Task/Arrays/C-sharp/arrays-12.cs create mode 100644 Task/Arrays/C-sharp/arrays-13.cs create mode 100644 Task/Arrays/C-sharp/arrays-2.cs create mode 100644 Task/Arrays/C-sharp/arrays-3.cs create mode 100644 Task/Arrays/C-sharp/arrays-4.cs create mode 100644 Task/Arrays/C-sharp/arrays-5.cs create mode 100644 Task/Arrays/C-sharp/arrays-6.cs create mode 100644 Task/Arrays/C-sharp/arrays-7.cs create mode 100644 Task/Arrays/C-sharp/arrays-8.cs create mode 100644 Task/Arrays/C-sharp/arrays-9.cs create mode 100644 Task/Arrays/Common-Lisp/arrays-1.lisp create mode 100644 Task/Arrays/Common-Lisp/arrays-2.lisp create mode 100644 Task/Arrays/Common-Lisp/arrays-3.lisp create mode 100644 Task/Arrays/Common-Lisp/arrays-4.lisp create mode 100644 Task/Arrays/Common-Lisp/arrays-5.lisp create mode 100644 Task/Arrays/Component-Pascal/arrays.pascal create mode 100644 Task/Arrays/D/arrays.d create mode 100644 Task/Arrays/DWScript/arrays.dwscript create mode 100644 Task/Arrays/Dao/arrays.dao create mode 100644 Task/Arrays/Delphi/arrays.delphi create mode 100644 Task/Arrays/E/arrays-1.e create mode 100644 Task/Arrays/E/arrays-2.e create mode 100644 Task/Arrays/E/arrays-3.e create mode 100644 Task/Arrays/E/arrays-4.e create mode 100644 Task/Arrays/EGL/arrays.egl create mode 100644 Task/Arrays/Elena/arrays-1.elena create mode 100644 Task/Arrays/Elena/arrays-2.elena create mode 100644 Task/Arrays/Euphoria/arrays.euphoria create mode 100644 Task/Assertions/C++/assertions.cpp create mode 100644 Task/Assertions/C-sharp/assertions.cs create mode 100644 Task/Assertions/Common-Lisp/assertions.lisp create mode 100644 Task/Assertions/Component-Pascal/assertions.pascal create mode 100644 Task/Assertions/D/assertions.d create mode 100644 Task/Assertions/DWScript/assertions-1.dwscript create mode 100644 Task/Assertions/DWScript/assertions-2.dwscript create mode 100644 Task/Assertions/Dart/assertions.dart create mode 100644 Task/Assertions/Delphi/assertions-1.delphi create mode 100644 Task/Assertions/Delphi/assertions-2.delphi create mode 100644 Task/Assertions/Delphi/assertions-3.delphi create mode 100644 Task/Assertions/E/assertions.e create mode 100644 Task/Assertions/Emacs-Lisp/assertions.l create mode 100644 Task/Assertions/Euphoria/assertions.euphoria create mode 100644 Task/Associative-array-Creation/C++/associative-array-creation-1.cpp create mode 100644 Task/Associative-array-Creation/C++/associative-array-creation-10.cpp create mode 100644 Task/Associative-array-Creation/C++/associative-array-creation-2.cpp create mode 100644 Task/Associative-array-Creation/C++/associative-array-creation-3.cpp create mode 100644 Task/Associative-array-Creation/C++/associative-array-creation-4.cpp create mode 100644 Task/Associative-array-Creation/C++/associative-array-creation-5.cpp create mode 100644 Task/Associative-array-Creation/C++/associative-array-creation-6.cpp create mode 100644 Task/Associative-array-Creation/C++/associative-array-creation-7.cpp create mode 100644 Task/Associative-array-Creation/C++/associative-array-creation-8.cpp create mode 100644 Task/Associative-array-Creation/C++/associative-array-creation-9.cpp create mode 100644 Task/Associative-array-Creation/C-sharp/associative-array-creation-1.cs create mode 100644 Task/Associative-array-Creation/C-sharp/associative-array-creation-2.cs create mode 100644 Task/Associative-array-Creation/C-sharp/associative-array-creation-3.cs create mode 100644 Task/Associative-array-Creation/ColdFusion/associative-array-creation.cfm create mode 100644 Task/Associative-array-Creation/Common-Lisp/associative-array-creation.lisp create mode 100644 Task/Associative-array-Creation/D/associative-array-creation.d create mode 100644 Task/Associative-array-Creation/Dao/associative-array-creation.dao create mode 100644 Task/Associative-array-Creation/Delphi/associative-array-creation.delphi create mode 100644 Task/Associative-array-Creation/E/associative-array-creation.e create mode 100644 Task/Associative-array-Creation/Elena/associative-array-creation.elena create mode 100644 Task/Associative-array-Iteration/C++/associative-array-iteration-1.cpp create mode 100644 Task/Associative-array-Iteration/C++/associative-array-iteration-2.cpp create mode 100644 Task/Associative-array-Iteration/C-sharp/associative-array-iteration.cs create mode 100644 Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-1.lisp create mode 100644 Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-2.lisp create mode 100644 Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-3.lisp create mode 100644 Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-4.lisp create mode 100644 Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-5.lisp create mode 100644 Task/Associative-array-Iteration/D/associative-array-iteration.d create mode 100644 Task/Associative-array-Iteration/Dao/associative-array-iteration.dao create mode 100644 Task/Associative-array-Iteration/Delphi/associative-array-iteration.delphi create mode 100644 Task/Associative-array-Iteration/E/associative-array-iteration.e create mode 100644 Task/Associative-array-Iteration/Elena/associative-array-iteration.elena create mode 100644 Task/Atomic-updates/C-sharp/atomic-updates.cs create mode 100644 Task/Atomic-updates/D/atomic-updates.d create mode 100644 Task/Atomic-updates/E/atomic-updates.e create mode 100644 Task/Atomic-updates/Euphoria/atomic-updates.euphoria create mode 100644 Task/Average-loop-length/D/average-loop-length.d create mode 100644 Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-1.cpp create mode 100644 Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-2.cpp create mode 100644 Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-3.cpp create mode 100644 Task/Averages-Arithmetic-mean/C-sharp/averages-arithmetic-mean-1.cs create mode 100644 Task/Averages-Arithmetic-mean/C-sharp/averages-arithmetic-mean-2.cs create mode 100644 Task/Averages-Arithmetic-mean/Chef/averages-arithmetic-mean.chef create mode 100644 Task/Averages-Arithmetic-mean/Cobra/averages-arithmetic-mean.cobra create mode 100644 Task/Averages-Arithmetic-mean/Common-Lisp/averages-arithmetic-mean-1.lisp create mode 100644 Task/Averages-Arithmetic-mean/Common-Lisp/averages-arithmetic-mean-2.lisp create mode 100644 Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-1.d create mode 100644 Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-2.d create mode 100644 Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-3.d create mode 100644 Task/Averages-Arithmetic-mean/Delphi/averages-arithmetic-mean.delphi create mode 100644 Task/Averages-Arithmetic-mean/E/averages-arithmetic-mean.e create mode 100644 Task/Averages-Arithmetic-mean/Elena/averages-arithmetic-mean.elena create mode 100644 Task/Averages-Arithmetic-mean/Emacs-Lisp/averages-arithmetic-mean.l create mode 100644 Task/Averages-Arithmetic-mean/Euphoria/averages-arithmetic-mean.euphoria create mode 100644 Task/Averages-Mean-angle/Common-Lisp/averages-mean-angle.lisp create mode 100644 Task/Averages-Mean-angle/D/averages-mean-angle.d create mode 100644 Task/Averages-Mean-angle/Euler-Math-Toolbox/averages-mean-angle.euler create mode 100644 Task/Averages-Median/C++/averages-median.cpp create mode 100644 Task/Averages-Median/Common-Lisp/averages-median.lisp create mode 100644 Task/Averages-Median/D/averages-median.d create mode 100644 Task/Averages-Median/Delphi/averages-median.delphi create mode 100644 Task/Averages-Median/E/averages-median-1.e create mode 100644 Task/Averages-Median/E/averages-median-2.e create mode 100644 Task/Averages-Median/Elena/averages-median.elena create mode 100644 Task/Averages-Median/Euler-Math-Toolbox/averages-median.euler create mode 100644 Task/Averages-Median/Euphoria/averages-median.euphoria create mode 100644 Task/Averages-Mode/C++/averages-mode.cpp create mode 100644 Task/Averages-Mode/D/averages-mode.d create mode 100644 Task/Averages-Mode/E/averages-mode-1.e create mode 100644 Task/Averages-Mode/E/averages-mode-2.e create mode 100644 Task/Averages-Mode/E/averages-mode-3.e create mode 100644 Task/Averages-Mode/Elena/averages-mode.elena create mode 100644 Task/Averages-Mode/Euphoria/averages-mode.euphoria create mode 100644 Task/Averages-Pythagorean-means/C++/averages-pythagorean-means.cpp create mode 100644 Task/Averages-Pythagorean-means/Common-Lisp/averages-pythagorean-means.lisp create mode 100644 Task/Averages-Pythagorean-means/D/averages-pythagorean-means.d create mode 100644 Task/Averages-Pythagorean-means/Delphi/averages-pythagorean-means.delphi create mode 100644 Task/Averages-Pythagorean-means/E/averages-pythagorean-means-1.e create mode 100644 Task/Averages-Pythagorean-means/E/averages-pythagorean-means-2.e create mode 100644 Task/Averages-Pythagorean-means/Euler-Math-Toolbox/averages-pythagorean-means-1.euler create mode 100644 Task/Averages-Pythagorean-means/Euler-Math-Toolbox/averages-pythagorean-means-2.euler create mode 100644 Task/Averages-Pythagorean-means/Euphoria/averages-pythagorean-means.euphoria create mode 100644 Task/Averages-Root-mean-square/C++/averages-root-mean-square.cpp create mode 100644 Task/Averages-Root-mean-square/Common-Lisp/averages-root-mean-square.lisp create mode 100644 Task/Averages-Root-mean-square/D/averages-root-mean-square.d create mode 100644 Task/Averages-Root-mean-square/Delphi/averages-root-mean-square.delphi create mode 100644 Task/Averages-Root-mean-square/E/averages-root-mean-square-1.e create mode 100644 Task/Averages-Root-mean-square/E/averages-root-mean-square-2.e create mode 100644 Task/Averages-Root-mean-square/Euphoria/averages-root-mean-square.euphoria create mode 100644 Task/Averages-Simple-moving-average/C++/averages-simple-moving-average.cpp create mode 100644 Task/Averages-Simple-moving-average/Common-Lisp/averages-simple-moving-average.lisp create mode 100644 Task/Averages-Simple-moving-average/D/averages-simple-moving-average-1.d create mode 100644 Task/Averages-Simple-moving-average/D/averages-simple-moving-average-2.d create mode 100644 Task/Averages-Simple-moving-average/E/averages-simple-moving-average-1.e create mode 100644 Task/Averages-Simple-moving-average/E/averages-simple-moving-average-2.e create mode 100644 Task/Averages-Simple-moving-average/Elena/averages-simple-moving-average.elena create mode 100644 Task/Averages-Simple-moving-average/Euler-Math-Toolbox/averages-simple-moving-average-1.euler create mode 100644 Task/Averages-Simple-moving-average/Euler-Math-Toolbox/averages-simple-moving-average-2.euler create mode 100644 Task/Balanced-brackets/C++/balanced-brackets.cpp create mode 100644 Task/Balanced-brackets/Common-Lisp/balanced-brackets.lisp create mode 100644 Task/Balanced-brackets/D/balanced-brackets-1.d create mode 100644 Task/Balanced-brackets/D/balanced-brackets-2.d create mode 100644 Task/Balanced-brackets/D/balanced-brackets-3.d create mode 100644 Task/Balanced-brackets/Delphi/balanced-brackets.delphi create mode 100644 Task/Balanced-brackets/Elena/balanced-brackets.elena create mode 100644 Task/Balanced-brackets/Euphoria/balanced-brackets.euphoria create mode 100644 Task/Balanced-ternary/Common-Lisp/balanced-ternary-1.lisp create mode 100644 Task/Balanced-ternary/Common-Lisp/balanced-ternary-2.lisp create mode 100644 Task/Balanced-ternary/D/balanced-ternary.d create mode 100644 Task/Best-shuffle/Common-Lisp/best-shuffle-1.lisp create mode 100644 Task/Best-shuffle/Common-Lisp/best-shuffle-2.lisp create mode 100644 Task/Best-shuffle/D/best-shuffle-1.d create mode 100644 Task/Best-shuffle/D/best-shuffle-2.d create mode 100644 Task/Binary-search/C++/binary-search-1.cpp create mode 100644 Task/Binary-search/C++/binary-search-2.cpp create mode 100644 Task/Binary-search/C++/binary-search-3.cpp create mode 100644 Task/Binary-search/C++/binary-search-4.cpp create mode 100644 Task/Binary-search/C++/binary-search-5.cpp create mode 100644 Task/Binary-search/C++/binary-search-6.cpp create mode 100644 Task/Binary-search/C++/binary-search-7.cpp create mode 100644 Task/Binary-search/Common-Lisp/binary-search-1.lisp create mode 100644 Task/Binary-search/Common-Lisp/binary-search-2.lisp create mode 100644 Task/Binary-search/D/binary-search.d create mode 100644 Task/Binary-search/E/binary-search.e create mode 100644 Task/Binary-search/Euphoria/binary-search-1.euphoria create mode 100644 Task/Binary-search/Euphoria/binary-search-2.euphoria create mode 100644 Task/Binary-strings/Common-Lisp/binary-strings-1.lisp create mode 100644 Task/Binary-strings/Common-Lisp/binary-strings-2.lisp create mode 100644 Task/Binary-strings/Common-Lisp/binary-strings-3.lisp create mode 100644 Task/Binary-strings/Common-Lisp/binary-strings-4.lisp create mode 100644 Task/Binary-strings/Common-Lisp/binary-strings-5.lisp create mode 100644 Task/Binary-strings/Common-Lisp/binary-strings-6.lisp create mode 100644 Task/Binary-strings/Common-Lisp/binary-strings-7.lisp create mode 100644 Task/Binary-strings/D/binary-strings.d create mode 100644 Task/Binary-strings/E/binary-strings-1.e create mode 100644 Task/Binary-strings/E/binary-strings-2.e create mode 100644 Task/Binary-strings/E/binary-strings-3.e create mode 100644 Task/Binary-strings/E/binary-strings-4.e create mode 100644 Task/Binary-strings/E/binary-strings-5.e create mode 100644 Task/Binary-strings/E/binary-strings-6.e create mode 100644 Task/Binary-strings/E/binary-strings-7.e create mode 100644 Task/Binary-strings/E/binary-strings-8.e create mode 100644 Task/Bitmap-B-zier-curves-Cubic/D/bitmap-b-zier-curves-cubic.d create mode 100644 Task/Bitmap-B-zier-curves-Quadratic/D/bitmap-b-zier-curves-quadratic.d create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/C++/bitmap-bresenhams-line-algorithm.cpp create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Common-Lisp/bitmap-bresenhams-line-algorithm.lisp create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/D/bitmap-bresenhams-line-algorithm.d create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/E/bitmap-bresenhams-line-algorithm-1.e create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/E/bitmap-bresenhams-line-algorithm-2.e create mode 100644 Task/Bitmap-Bresenhams-line-algorithm/Euphoria/bitmap-bresenhams-line-algorithm.euphoria create mode 100644 Task/Bitmap-Flood-fill/D/bitmap-flood-fill.d create mode 100644 Task/Bitmap-Flood-fill/E/bitmap-flood-fill-1.e create mode 100644 Task/Bitmap-Flood-fill/E/bitmap-flood-fill-2.e create mode 100644 Task/Bitmap-Histogram/D/bitmap-histogram.d create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Common-Lisp/bitmap-midpoint-circle-algorithm-1.lisp create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/Common-Lisp/bitmap-midpoint-circle-algorithm-2.lisp create mode 100644 Task/Bitmap-Midpoint-circle-algorithm/D/bitmap-midpoint-circle-algorithm.d create mode 100644 Task/Bitmap-Read-a-PPM-file/Common-Lisp/bitmap-read-a-ppm-file-1.lisp create mode 100644 Task/Bitmap-Read-a-PPM-file/Common-Lisp/bitmap-read-a-ppm-file-2.lisp create mode 100644 Task/Bitmap-Read-a-PPM-file/E/bitmap-read-a-ppm-file-1.e create mode 100644 Task/Bitmap-Read-a-PPM-file/E/bitmap-read-a-ppm-file-2.e create mode 100644 Task/Bitmap-Read-a-PPM-file/Euphoria/bitmap-read-a-ppm-file-1.euphoria create mode 100644 Task/Bitmap-Read-a-PPM-file/Euphoria/bitmap-read-a-ppm-file-2.euphoria create mode 100644 Task/Bitmap-Write-a-PPM-file/Common-Lisp/bitmap-write-a-ppm-file.lisp create mode 100644 Task/Bitmap-Write-a-PPM-file/Euphoria/bitmap-write-a-ppm-file-1.euphoria create mode 100644 Task/Bitmap-Write-a-PPM-file/Euphoria/bitmap-write-a-ppm-file-2.euphoria create mode 100644 Task/Bitmap/C++/bitmap.cpp create mode 100644 Task/Bitmap/Common-Lisp/bitmap-1.lisp create mode 100644 Task/Bitmap/Common-Lisp/bitmap-2.lisp create mode 100644 Task/Bitmap/Common-Lisp/bitmap-3.lisp create mode 100644 Task/Bitmap/D/bitmap.d create mode 100644 Task/Bitmap/E/bitmap-1.e create mode 100644 Task/Bitmap/E/bitmap-2.e create mode 100644 Task/Bitmap/Euphoria/bitmap.euphoria create mode 100644 Task/Bitwise-IO/D/bitwise-io.d create mode 100644 Task/Bitwise-operations/C++/bitwise-operations.cpp create mode 100644 Task/Bitwise-operations/Common-Lisp/bitwise-operations.lisp create mode 100644 Task/Bitwise-operations/D/bitwise-operations.d create mode 100644 Task/Bitwise-operations/DWScript/bitwise-operations.dwscript create mode 100644 Task/Bitwise-operations/Delphi/bitwise-operations.delphi create mode 100644 Task/Bitwise-operations/E/bitwise-operations.e create mode 100644 Task/Bitwise-operations/Elena/bitwise-operations.elena create mode 100644 Task/Boolean-values/CMake/boolean-values.cmake create mode 100644 Task/Boolean-values/Clean/boolean-values.clean create mode 100644 Task/Boolean-values/E/boolean-values-1.e create mode 100644 Task/Boolean-values/E/boolean-values-2.e create mode 100644 Task/Boolean-values/EGL/boolean-values.egl create mode 100644 Task/Box-the-compass/C++/box-the-compass.cpp create mode 100644 Task/Box-the-compass/D/box-the-compass.d create mode 100644 Task/Box-the-compass/Euphoria/box-the-compass.euphoria create mode 100644 Task/Break-OO-privacy/C++/break-oo-privacy-1.cpp create mode 100644 Task/Break-OO-privacy/C++/break-oo-privacy-2.cpp create mode 100644 Task/Break-OO-privacy/C++/break-oo-privacy-3.cpp create mode 100644 Task/Break-OO-privacy/C-sharp/break-oo-privacy-1.cs create mode 100644 Task/Break-OO-privacy/C-sharp/break-oo-privacy-2.cs create mode 100644 Task/Break-OO-privacy/Common-Lisp/break-oo-privacy.lisp create mode 100644 Task/Bulls-and-cows-Player/D/bulls-and-cows-player.d create mode 100644 Task/Bulls-and-cows-Player/Euphoria/bulls-and-cows-player.euphoria create mode 100644 Task/Bulls-and-cows/C++/bulls-and-cows.cpp create mode 100644 Task/Bulls-and-cows/Common-Lisp/bulls-and-cows.lisp create mode 100644 Task/Bulls-and-cows/D/bulls-and-cows.d create mode 100644 Task/Bulls-and-cows/E/bulls-and-cows-1.e create mode 100644 Task/Bulls-and-cows/E/bulls-and-cows-2.e create mode 100644 Task/Bulls-and-cows/Elena/bulls-and-cows.elena create mode 100644 Task/Bulls-and-cows/Euphoria/bulls-and-cows.euphoria create mode 100644 Task/CRC-32/0DESCRIPTION create mode 100644 Task/CRC-32/1META.yaml create mode 100644 Task/CRC-32/Ada/crc-32.ada create mode 100644 Task/CRC-32/C/crc-32-1.c create mode 100644 Task/CRC-32/C/crc-32-2.c create mode 100644 Task/CRC-32/Common-Lisp/crc-32.lisp create mode 100644 Task/CRC-32/D/crc-32.d create mode 100644 Task/CRC-32/Erlang/crc-32-1.erl create mode 100644 Task/CRC-32/Erlang/crc-32-2.erl create mode 100644 Task/CRC-32/Go/crc-32-1.go create mode 100644 Task/CRC-32/Go/crc-32-2.go create mode 100644 Task/CRC-32/Java/crc-32.java create mode 100644 Task/CRC-32/PHP/crc-32.php create mode 100644 Task/CRC-32/Perl/crc-32.pl create mode 100644 Task/CRC-32/Python/crc-32-1.py create mode 100644 Task/CRC-32/Python/crc-32-2.py create mode 100644 Task/CRC-32/REXX/crc-32.rexx create mode 100644 Task/CRC-32/Ruby/crc-32-1.rb create mode 100644 Task/CRC-32/Ruby/crc-32-2.rb create mode 100644 Task/CRC-32/Smalltalk/crc-32.st create mode 100644 Task/CRC-32/Tcl/crc-32-1.tcl create mode 100644 Task/CRC-32/Tcl/crc-32-2.tcl create mode 100644 Task/CSV-to-HTML-translation/0DESCRIPTION create mode 100644 Task/CSV-to-HTML-translation/ALGOL-68/csv-to-html-translation-1.alg create mode 100644 Task/CSV-to-HTML-translation/ALGOL-68/csv-to-html-translation-2.alg create mode 100644 Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-1.awk create mode 100644 Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-2.awk create mode 100644 Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-3.awk create mode 100644 Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-1.ada create mode 100644 Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-2.ada create mode 100644 Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-3.ada create mode 100644 Task/CSV-to-HTML-translation/AutoHotkey/csv-to-html-translation.ahk create mode 100644 Task/CSV-to-HTML-translation/AutoIt/csv-to-html-translation.autoit create mode 100644 Task/CSV-to-HTML-translation/BBC-BASIC/csv-to-html-translation.bbc create mode 100644 Task/CSV-to-HTML-translation/C++/csv-to-html-translation-1.cpp create mode 100644 Task/CSV-to-HTML-translation/C++/csv-to-html-translation-2.cpp create mode 100644 Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-1.cs create mode 100644 Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-2.cs create mode 100644 Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-3.cs create mode 100644 Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-4.cs create mode 100644 Task/CSV-to-HTML-translation/C/csv-to-html-translation-1.c create mode 100644 Task/CSV-to-HTML-translation/C/csv-to-html-translation-2.c create mode 100644 Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-1.coffee create mode 100644 Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-2.coffee create mode 100644 Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-1.lisp create mode 100644 Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-2.lisp create mode 100644 Task/CSV-to-HTML-translation/D/csv-to-html-translation-1.d create mode 100644 Task/CSV-to-HTML-translation/D/csv-to-html-translation-2.d create mode 100644 Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-1.delphi create mode 100644 Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-2.delphi create mode 100644 Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-3.delphi create mode 100644 Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation.euphoria create mode 100644 Task/CSV-to-HTML-translation/Go/csv-to-html-translation-1.go create mode 100644 Task/CSV-to-HTML-translation/Go/csv-to-html-translation-2.go create mode 100644 Task/CSV-to-HTML-translation/Go/csv-to-html-translation-3.go create mode 100644 Task/CSV-to-HTML-translation/Go/csv-to-html-translation-4.go create mode 100644 Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-1.hs create mode 100644 Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-2.hs create mode 100644 Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-3.hs create mode 100644 Task/CSV-to-HTML-translation/Java/csv-to-html-translation-1.java create mode 100644 Task/CSV-to-HTML-translation/Java/csv-to-html-translation-2.java create mode 100644 Task/CSV-to-HTML-translation/Java/csv-to-html-translation-3.java create mode 100644 Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-1.js create mode 100644 Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-2.js create mode 100644 Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-3.js create mode 100644 Task/CSV-to-HTML-translation/Lua/csv-to-html-translation-1.lua create mode 100644 Task/CSV-to-HTML-translation/Lua/csv-to-html-translation-2.lua create mode 100644 Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-1.m create mode 100644 Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-2.m create mode 100644 Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-3.m create mode 100644 Task/CSV-to-HTML-translation/Perl/csv-to-html-translation-1.pl create mode 100644 Task/CSV-to-HTML-translation/Perl/csv-to-html-translation-2.pl create mode 100644 Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-1.l create mode 100644 Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-2.l create mode 100644 Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-3.l create mode 100644 Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-4.l create mode 100644 Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-1.pro create mode 100644 Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-2.pro create mode 100644 Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-3.pro create mode 100644 Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-4.pro create mode 100644 Task/CSV-to-HTML-translation/Python/csv-to-html-translation-1.py create mode 100644 Task/CSV-to-HTML-translation/Python/csv-to-html-translation-2.py create mode 100644 Task/CSV-to-HTML-translation/Python/csv-to-html-translation-3.py create mode 100644 Task/CSV-to-HTML-translation/Python/csv-to-html-translation-4.py create mode 100644 Task/CSV-to-HTML-translation/REXX/csv-to-html-translation-1.rexx create mode 100644 Task/CSV-to-HTML-translation/REXX/csv-to-html-translation-2.rexx create mode 100644 Task/CSV-to-HTML-translation/Racket/csv-to-html-translation-1.rkt create mode 100644 Task/CSV-to-HTML-translation/Racket/csv-to-html-translation-2.rkt create mode 100644 Task/CSV-to-HTML-translation/Ruby/csv-to-html-translation-1.rb create mode 100644 Task/CSV-to-HTML-translation/Ruby/csv-to-html-translation-2.rb create mode 100644 Task/CSV-to-HTML-translation/Scala/csv-to-html-translation-1.scala create mode 100644 Task/CSV-to-HTML-translation/Scala/csv-to-html-translation-2.scala create mode 100644 Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-1.tcl create mode 100644 Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-2.tcl create mode 100644 Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-3.tcl create mode 100644 Task/Caesar-cipher/C++/caesar-cipher.cpp create mode 100644 Task/Caesar-cipher/Common-Lisp/caesar-cipher.lisp create mode 100644 Task/Caesar-cipher/D/caesar-cipher-1.d create mode 100644 Task/Caesar-cipher/D/caesar-cipher-2.d create mode 100644 Task/Caesar-cipher/Dart/caesar-cipher.dart create mode 100644 Task/Caesar-cipher/Elena/caesar-cipher.elena create mode 100644 Task/Caesar-cipher/Euphoria/caesar-cipher.euphoria create mode 100644 Task/Calendar-for-real-programmers/0DESCRIPTION create mode 100644 Task/Calendar-for-real-programmers/1META.yaml create mode 100644 Task/Calendar-for-real-programmers/ALGOL-68/calendar-for-real-programmers.alg create mode 100644 Task/Calendar-for-real-programmers/Ada/calendar-for-real-programmers.ada create mode 100644 Task/Calendar-for-real-programmers/BBC-BASIC/calendar-for-real-programmers.bbc create mode 100644 Task/Calendar-for-real-programmers/PHP/calendar-for-real-programmers.php create mode 100644 Task/Calendar-for-real-programmers/Perl/calendar-for-real-programmers-1.pl create mode 100644 Task/Calendar-for-real-programmers/Perl/calendar-for-real-programmers-2.pl create mode 100644 Task/Calendar-for-real-programmers/PicoLisp/calendar-for-real-programmers.l create mode 100644 Task/Calendar-for-real-programmers/REXX/calendar-for-real-programmers.rexx create mode 100644 Task/Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-1.rb create mode 100644 Task/Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-2.rb create mode 100644 Task/Calendar-for-real-programmers/Tcl/calendar-for-real-programmers.tcl create mode 100644 Task/Calendar/D/calendar.d create mode 100644 Task/Call-a-foreign-language-function/0DESCRIPTION create mode 100644 Task/Call-a-foreign-language-function/1META.yaml create mode 100644 Task/Call-a-foreign-language-function/Ada/call-a-foreign-language-function.ada create mode 100644 Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-1.aikido create mode 100644 Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-2.aikido create mode 100644 Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-3.aikido create mode 100644 Task/Call-a-foreign-language-function/AutoHotkey/call-a-foreign-language-function.ahk create mode 100644 Task/Call-a-foreign-language-function/BBC-BASIC/call-a-foreign-language-function.bbc create mode 100644 Task/Call-a-foreign-language-function/C++/call-a-foreign-language-function-1.cpp create mode 100644 Task/Call-a-foreign-language-function/C++/call-a-foreign-language-function-2.cpp create mode 100644 Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-1.cmake create mode 100644 Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-2.cmake create mode 100644 Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-3.cmake create mode 100644 Task/Call-a-foreign-language-function/Common-Lisp/call-a-foreign-language-function.lisp create mode 100644 Task/Call-a-foreign-language-function/D/call-a-foreign-language-function.d create mode 100644 Task/Call-a-foreign-language-function/Delphi/call-a-foreign-language-function-1.delphi create mode 100644 Task/Call-a-foreign-language-function/Delphi/call-a-foreign-language-function-2.delphi create mode 100644 Task/Call-a-foreign-language-function/Forth/call-a-foreign-language-function.fth create mode 100644 Task/Call-a-foreign-language-function/Go/call-a-foreign-language-function.go create mode 100644 Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-1.hs create mode 100644 Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-2.hs create mode 100644 Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-3.hs create mode 100644 Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-1.java create mode 100644 Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-2.java create mode 100644 Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-3.java create mode 100644 Task/Call-a-foreign-language-function/Perl/call-a-foreign-language-function-1.pl create mode 100644 Task/Call-a-foreign-language-function/Perl/call-a-foreign-language-function-2.pl create mode 100644 Task/Call-a-foreign-language-function/PicoLisp/call-a-foreign-language-function-1.l create mode 100644 Task/Call-a-foreign-language-function/PicoLisp/call-a-foreign-language-function-2.l create mode 100644 Task/Call-a-foreign-language-function/Python/call-a-foreign-language-function.py create mode 100644 Task/Call-a-foreign-language-function/Racket/call-a-foreign-language-function.rkt create mode 100644 Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-1.rb create mode 100644 Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-2.rb create mode 100644 Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-3.rb create mode 100644 Task/Call-a-foreign-language-function/Tcl/call-a-foreign-language-function.tcl create mode 100644 Task/Call-a-function-in-a-shared-library/0DESCRIPTION create mode 100644 Task/Call-a-function-in-a-shared-library/1META.yaml create mode 100644 Task/Call-a-function-in-a-shared-library/Ada/call-a-function-in-a-shared-library-1.ada create mode 100644 Task/Call-a-function-in-a-shared-library/Ada/call-a-function-in-a-shared-library-2.ada create mode 100644 Task/Call-a-function-in-a-shared-library/AutoHotkey/call-a-function-in-a-shared-library-1.ahk create mode 100644 Task/Call-a-function-in-a-shared-library/AutoHotkey/call-a-function-in-a-shared-library-2.ahk create mode 100644 Task/Call-a-function-in-a-shared-library/BBC-BASIC/call-a-function-in-a-shared-library.bbc create mode 100644 Task/Call-a-function-in-a-shared-library/C/call-a-function-in-a-shared-library-1.c create mode 100644 Task/Call-a-function-in-a-shared-library/C/call-a-function-in-a-shared-library-2.c create mode 100644 Task/Call-a-function-in-a-shared-library/Common-Lisp/call-a-function-in-a-shared-library.lisp create mode 100644 Task/Call-a-function-in-a-shared-library/D/call-a-function-in-a-shared-library.d create mode 100644 Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-1.delphi create mode 100644 Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-2.delphi create mode 100644 Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-3.delphi create mode 100644 Task/Call-a-function-in-a-shared-library/Java/call-a-function-in-a-shared-library-1.java create mode 100644 Task/Call-a-function-in-a-shared-library/Java/call-a-function-in-a-shared-library-2.java create mode 100644 Task/Call-a-function-in-a-shared-library/PicoLisp/call-a-function-in-a-shared-library-1.l create mode 100644 Task/Call-a-function-in-a-shared-library/PicoLisp/call-a-function-in-a-shared-library-2.l create mode 100644 Task/Call-a-function-in-a-shared-library/Python/call-a-function-in-a-shared-library.py create mode 100644 Task/Call-a-function-in-a-shared-library/Racket/call-a-function-in-a-shared-library.rkt create mode 100644 Task/Call-a-function-in-a-shared-library/Ruby/call-a-function-in-a-shared-library-1.rb create mode 100644 Task/Call-a-function-in-a-shared-library/Ruby/call-a-function-in-a-shared-library-2.rb create mode 100644 Task/Call-a-function-in-a-shared-library/Smalltalk/call-a-function-in-a-shared-library.st create mode 100644 Task/Call-a-function-in-a-shared-library/Tcl/call-a-function-in-a-shared-library.tcl create mode 100644 Task/Call-a-function/0DESCRIPTION create mode 100644 Task/Call-a-function/1META.yaml create mode 100644 Task/Call-a-function/AWK/call-a-function.awk create mode 100644 Task/Call-a-function/ActionScript/call-a-function.as create mode 100644 Task/Call-a-function/Ada/call-a-function-1.ada create mode 100644 Task/Call-a-function/Ada/call-a-function-2.ada create mode 100644 Task/Call-a-function/Ada/call-a-function-3.ada create mode 100644 Task/Call-a-function/Ada/call-a-function-4.ada create mode 100644 Task/Call-a-function/Ada/call-a-function-5.ada create mode 100644 Task/Call-a-function/AutoHotkey/call-a-function.ahk create mode 100644 Task/Call-a-function/C/call-a-function.c create mode 100644 Task/Call-a-function/JavaScript/call-a-function-1.js create mode 100644 Task/Call-a-function/JavaScript/call-a-function-2.js create mode 100644 Task/Call-a-function/JavaScript/call-a-function-3.js create mode 100644 Task/Call-a-function/JavaScript/call-a-function-4.js create mode 100644 Task/Call-a-function/JavaScript/call-a-function-5.js create mode 100644 Task/Call-a-function/MATLAB/call-a-function.m create mode 100644 Task/Call-a-function/PicoLisp/call-a-function-1.l create mode 100644 Task/Call-a-function/PicoLisp/call-a-function-2.l create mode 100644 Task/Call-a-function/PicoLisp/call-a-function-3.l create mode 100644 Task/Call-a-function/Python/call-a-function.py create mode 100644 Task/Call-a-function/REXX/call-a-function.rexx create mode 100644 Task/Call-a-function/Smalltalk/call-a-function.st create mode 100644 Task/Call-a-function/Tcl/call-a-function-1.tcl create mode 100644 Task/Call-a-function/Tcl/call-a-function-2.tcl create mode 100644 Task/Call-an-object-method/0DESCRIPTION create mode 100644 Task/Call-an-object-method/1META.yaml create mode 100644 Task/Call-an-object-method/ActionScript/call-an-object-method.as create mode 100644 Task/Call-an-object-method/AutoHotkey/call-an-object-method.ahk create mode 100644 Task/Call-an-object-method/C++/call-an-object-method.cpp create mode 100644 Task/Call-an-object-method/D/call-an-object-method.d create mode 100644 Task/Call-an-object-method/E/call-an-object-method.e create mode 100644 Task/Call-an-object-method/Forth/call-an-object-method.fth create mode 100644 Task/Call-an-object-method/Go/call-an-object-method-1.go create mode 100644 Task/Call-an-object-method/Go/call-an-object-method-2.go create mode 100644 Task/Call-an-object-method/Go/call-an-object-method-3.go create mode 100644 Task/Call-an-object-method/Go/call-an-object-method-4.go create mode 100644 Task/Call-an-object-method/Java/call-an-object-method-1.java create mode 100644 Task/Call-an-object-method/Java/call-an-object-method-2.java create mode 100644 Task/Call-an-object-method/PHP/call-an-object-method.php create mode 100644 Task/Call-an-object-method/Perl/call-an-object-method.pl create mode 100644 Task/Call-an-object-method/PicoLisp/call-an-object-method.l create mode 100644 Task/Call-an-object-method/Python/call-an-object-method.py create mode 100644 Task/Call-an-object-method/Racket/call-an-object-method.rkt create mode 100644 Task/Call-an-object-method/Ruby/call-an-object-method.rb create mode 100644 Task/Call-an-object-method/Smalltalk/call-an-object-method-1.st create mode 100644 Task/Call-an-object-method/Smalltalk/call-an-object-method-2.st create mode 100644 Task/Call-an-object-method/Smalltalk/call-an-object-method-3.st create mode 100644 Task/Call-an-object-method/Smalltalk/call-an-object-method-4.st create mode 100644 Task/Call-an-object-method/Smalltalk/call-an-object-method-5.st create mode 100644 Task/Call-an-object-method/Tcl/call-an-object-method.tcl create mode 100644 Task/Canny-edge-detector/0DESCRIPTION create mode 100644 Task/Canny-edge-detector/C/canny-edge-detector.c create mode 100644 Task/Canny-edge-detector/D/canny-edge-detector.d create mode 100644 Task/Canny-edge-detector/Tcl/canny-edge-detector.tcl create mode 100644 Task/Carmichael-3-strong-pseudoprimes/0DESCRIPTION create mode 100644 Task/Carmichael-3-strong-pseudoprimes/Ada/carmichael-3-strong-pseudoprimes.ada create mode 100644 Task/Carmichael-3-strong-pseudoprimes/D/carmichael-3-strong-pseudoprimes.d create mode 100644 Task/Carmichael-3-strong-pseudoprimes/Haskell/carmichael-3-strong-pseudoprimes.hs create mode 100644 Task/Carmichael-3-strong-pseudoprimes/Python/carmichael-3-strong-pseudoprimes.py create mode 100644 Task/Carmichael-3-strong-pseudoprimes/REXX/carmichael-3-strong-pseudoprimes-1.rexx create mode 100644 Task/Carmichael-3-strong-pseudoprimes/REXX/carmichael-3-strong-pseudoprimes-2.rexx create mode 100644 Task/Carmichael-3-strong-pseudoprimes/Ruby/carmichael-3-strong-pseudoprimes.rb create mode 100644 Task/Carmichael-3-strong-pseudoprimes/Tcl/carmichael-3-strong-pseudoprimes-1.tcl create mode 100644 Task/Carmichael-3-strong-pseudoprimes/Tcl/carmichael-3-strong-pseudoprimes-2.tcl create mode 100644 Task/Case-sensitivity-of-identifiers/0DESCRIPTION create mode 100644 Task/Case-sensitivity-of-identifiers/1META.yaml create mode 100644 Task/Case-sensitivity-of-identifiers/AWK/case-sensitivity-of-identifiers.awk create mode 100644 Task/Case-sensitivity-of-identifiers/Ada/case-sensitivity-of-identifiers.ada create mode 100644 Task/Case-sensitivity-of-identifiers/AutoHotkey/case-sensitivity-of-identifiers.ahk create mode 100644 Task/Case-sensitivity-of-identifiers/BBC-BASIC/case-sensitivity-of-identifiers.bbc create mode 100644 Task/Case-sensitivity-of-identifiers/Brlcad/case-sensitivity-of-identifiers.brlcad create mode 100644 Task/Case-sensitivity-of-identifiers/C-sharp/case-sensitivity-of-identifiers.cs create mode 100644 Task/Case-sensitivity-of-identifiers/C/case-sensitivity-of-identifiers.c create mode 100644 Task/Case-sensitivity-of-identifiers/COBOL/case-sensitivity-of-identifiers.cobol create mode 100644 Task/Case-sensitivity-of-identifiers/CoffeeScript/case-sensitivity-of-identifiers-1.coffee create mode 100644 Task/Case-sensitivity-of-identifiers/CoffeeScript/case-sensitivity-of-identifiers-2.coffee create mode 100644 Task/Case-sensitivity-of-identifiers/Common-Lisp/case-sensitivity-of-identifiers.lisp create mode 100644 Task/Case-sensitivity-of-identifiers/D/case-sensitivity-of-identifiers.d create mode 100644 Task/Case-sensitivity-of-identifiers/DWScript/case-sensitivity-of-identifiers.dwscript create mode 100644 Task/Case-sensitivity-of-identifiers/Delphi/case-sensitivity-of-identifiers.delphi create mode 100644 Task/Case-sensitivity-of-identifiers/Euphoria/case-sensitivity-of-identifiers.euphoria create mode 100644 Task/Case-sensitivity-of-identifiers/Fortran/case-sensitivity-of-identifiers.f create mode 100644 Task/Case-sensitivity-of-identifiers/Go/case-sensitivity-of-identifiers-1.go create mode 100644 Task/Case-sensitivity-of-identifiers/Go/case-sensitivity-of-identifiers-2.go create mode 100644 Task/Case-sensitivity-of-identifiers/Haskell/case-sensitivity-of-identifiers.hs create mode 100644 Task/Case-sensitivity-of-identifiers/Java/case-sensitivity-of-identifiers.java create mode 100644 Task/Case-sensitivity-of-identifiers/JavaScript/case-sensitivity-of-identifiers.js create mode 100644 Task/Case-sensitivity-of-identifiers/Lua/case-sensitivity-of-identifiers.lua create mode 100644 Task/Case-sensitivity-of-identifiers/MATLAB/case-sensitivity-of-identifiers.m create mode 100644 Task/Case-sensitivity-of-identifiers/Perl/case-sensitivity-of-identifiers.pl create mode 100644 Task/Case-sensitivity-of-identifiers/PicoLisp/case-sensitivity-of-identifiers.l create mode 100644 Task/Case-sensitivity-of-identifiers/Prolog/case-sensitivity-of-identifiers.pro create mode 100644 Task/Case-sensitivity-of-identifiers/Python/case-sensitivity-of-identifiers.py create mode 100644 Task/Case-sensitivity-of-identifiers/R/case-sensitivity-of-identifiers.r create mode 100644 Task/Case-sensitivity-of-identifiers/REXX/case-sensitivity-of-identifiers.rexx create mode 100644 Task/Case-sensitivity-of-identifiers/Racket/case-sensitivity-of-identifiers-1.rkt create mode 100644 Task/Case-sensitivity-of-identifiers/Racket/case-sensitivity-of-identifiers-2.rkt create mode 100644 Task/Case-sensitivity-of-identifiers/Ruby/case-sensitivity-of-identifiers.rb create mode 100644 Task/Case-sensitivity-of-identifiers/Sather/case-sensitivity-of-identifiers.sa create mode 100644 Task/Case-sensitivity-of-identifiers/Scala/case-sensitivity-of-identifiers.scala create mode 100644 Task/Case-sensitivity-of-identifiers/Scheme/case-sensitivity-of-identifiers.ss create mode 100644 Task/Case-sensitivity-of-identifiers/Smalltalk/case-sensitivity-of-identifiers.st create mode 100644 Task/Case-sensitivity-of-identifiers/Tcl/case-sensitivity-of-identifiers.tcl create mode 100644 Task/Catmull-Clark-subdivision-surface/0DESCRIPTION create mode 100644 Task/Catmull-Clark-subdivision-surface/1META.yaml create mode 100644 Task/Catmull-Clark-subdivision-surface/C/catmull-clark-subdivision-surface.c create mode 100644 Task/Catmull-Clark-subdivision-surface/Tcl/catmull-clark-subdivision-surface.tcl create mode 100644 Task/Character-codes/0DESCRIPTION create mode 100644 Task/Character-codes/1META.yaml create mode 100644 Task/Character-codes/ABAP/character-codes.abap create mode 100644 Task/Character-codes/ACL2/character-codes.acl2 create mode 100644 Task/Character-codes/ALGOL-68/character-codes-1.alg create mode 100644 Task/Character-codes/ALGOL-68/character-codes-2.alg create mode 100644 Task/Character-codes/ALGOL-68/character-codes-3.alg create mode 100644 Task/Character-codes/AWK/character-codes.awk create mode 100644 Task/Character-codes/ActionScript/character-codes.as create mode 100644 Task/Character-codes/Ada/character-codes.ada create mode 100644 Task/Character-codes/Aime/character-codes.aime create mode 100644 Task/Character-codes/AutoHotkey/character-codes.ahk create mode 100644 Task/Character-codes/BASIC/character-codes-1.bas create mode 100644 Task/Character-codes/BASIC/character-codes-2.bas create mode 100644 Task/Character-codes/BBC-BASIC/character-codes.bbc create mode 100644 Task/Character-codes/Befunge/character-codes.bf create mode 100644 Task/Character-codes/C++/character-codes.cpp create mode 100644 Task/Character-codes/C/character-codes.c create mode 100644 Task/Character-codes/Clojure/character-codes.clj create mode 100644 Task/Character-codes/CoffeeScript/character-codes.coffee create mode 100644 Task/Character-codes/Common-Lisp/character-codes.lisp create mode 100644 Task/Character-codes/D/character-codes.d create mode 100644 Task/Character-codes/DWScript/character-codes.dwscript create mode 100644 Task/Character-codes/Delphi/character-codes.delphi create mode 100644 Task/Character-codes/E/character-codes.e create mode 100644 Task/Character-codes/Elena/character-codes.elena create mode 100644 Task/Character-codes/Erlang/character-codes-1.erl create mode 100644 Task/Character-codes/Erlang/character-codes-2.erl create mode 100644 Task/Character-codes/Euphoria/character-codes.euphoria create mode 100644 Task/Character-codes/Forth/character-codes.fth create mode 100644 Task/Character-codes/Fortran/character-codes.f create mode 100644 Task/Character-codes/Go/character-codes-1.go create mode 100644 Task/Character-codes/Go/character-codes-2.go create mode 100644 Task/Character-codes/Go/character-codes-3.go create mode 100644 Task/Character-codes/Go/character-codes-4.go create mode 100644 Task/Character-codes/Haskell/character-codes.hs create mode 100644 Task/Character-codes/Java/character-codes-1.java create mode 100644 Task/Character-codes/Java/character-codes-2.java create mode 100644 Task/Character-codes/JavaScript/character-codes.js create mode 100644 Task/Character-codes/Lua/character-codes.lua create mode 100644 Task/Character-codes/MATLAB/character-codes-1.m create mode 100644 Task/Character-codes/MATLAB/character-codes-2.m create mode 100644 Task/Character-codes/MATLAB/character-codes-3.m create mode 100644 Task/Character-codes/MATLAB/character-codes-4.m create mode 100644 Task/Character-codes/PHP/character-codes.php create mode 100644 Task/Character-codes/Perl/character-codes.pl create mode 100644 Task/Character-codes/PicoLisp/character-codes.l create mode 100644 Task/Character-codes/Python/character-codes-1.py create mode 100644 Task/Character-codes/Python/character-codes-2.py create mode 100644 Task/Character-codes/Python/character-codes-3.py create mode 100644 Task/Character-codes/R/character-codes.r create mode 100644 Task/Character-codes/REXX/character-codes.rexx create mode 100644 Task/Character-codes/Ruby/character-codes-1.rb create mode 100644 Task/Character-codes/Ruby/character-codes-2.rb create mode 100644 Task/Character-codes/Sather/character-codes.sa create mode 100644 Task/Character-codes/Scala/character-codes-1.scala create mode 100644 Task/Character-codes/Scala/character-codes-2.scala create mode 100644 Task/Character-codes/Scheme/character-codes.ss create mode 100644 Task/Character-codes/Smalltalk/character-codes.st create mode 100644 Task/Character-codes/Tcl/character-codes.tcl create mode 100644 Task/Character-matching/0DESCRIPTION create mode 100644 Task/Character-matching/1META.yaml create mode 100644 Task/Character-matching/ALGOL-68/character-matching.alg create mode 100644 Task/Character-matching/Ada/character-matching.ada create mode 100644 Task/Character-matching/AutoHotkey/character-matching.ahk create mode 100644 Task/Character-matching/AutoIt/character-matching.autoit create mode 100644 Task/Character-matching/BASIC/character-matching.bas create mode 100644 Task/Character-matching/BBC-BASIC/character-matching.bbc create mode 100644 Task/Character-matching/Bracmat/character-matching.bracmat create mode 100644 Task/Character-matching/C++/character-matching.cpp create mode 100644 Task/Character-matching/C/character-matching-1.c create mode 100644 Task/Character-matching/C/character-matching-2.c create mode 100644 Task/Character-matching/Clojure/character-matching.clj create mode 100644 Task/Character-matching/CoffeeScript/character-matching.coffee create mode 100644 Task/Character-matching/D/character-matching.d create mode 100644 Task/Character-matching/Delphi/character-matching.delphi create mode 100644 Task/Character-matching/E/character-matching.e create mode 100644 Task/Character-matching/Elena/character-matching.elena create mode 100644 Task/Character-matching/Erlang/character-matching.erl create mode 100644 Task/Character-matching/Euphoria/character-matching.euphoria create mode 100644 Task/Character-matching/Forth/character-matching.fth create mode 100644 Task/Character-matching/Go/character-matching.go create mode 100644 Task/Character-matching/Haskell/character-matching-1.hs create mode 100644 Task/Character-matching/Haskell/character-matching-2.hs create mode 100644 Task/Character-matching/Java/character-matching.java create mode 100644 Task/Character-matching/JavaScript/character-matching.js create mode 100644 Task/Character-matching/Lua/character-matching.lua create mode 100644 Task/Character-matching/MATLAB/character-matching.m create mode 100644 Task/Character-matching/Perl/character-matching.pl create mode 100644 Task/Character-matching/PicoLisp/character-matching.l create mode 100644 Task/Character-matching/Python/character-matching.py create mode 100644 Task/Character-matching/REXX/character-matching.rexx create mode 100644 Task/Character-matching/Racket/character-matching.rkt create mode 100644 Task/Character-matching/Ruby/character-matching.rb create mode 100644 Task/Character-matching/Scala/character-matching.scala create mode 100644 Task/Character-matching/Smalltalk/character-matching.st create mode 100644 Task/Character-matching/Tcl/character-matching-1.tcl create mode 100644 Task/Character-matching/Tcl/character-matching-2.tcl create mode 100644 Task/Character-matching/Tcl/character-matching-3.tcl create mode 100644 Task/Character-matching/Tcl/character-matching-4.tcl create mode 100644 Task/Chat-server/0DESCRIPTION create mode 100644 Task/Chat-server/1META.yaml create mode 100644 Task/Chat-server/Ada/chat-server.ada create mode 100644 Task/Chat-server/C/chat-server.c create mode 100644 Task/Chat-server/CoffeeScript/chat-server.coffee create mode 100644 Task/Chat-server/Erlang/chat-server.erl create mode 100644 Task/Chat-server/Go/chat-server.go create mode 100644 Task/Chat-server/Java/chat-server.java create mode 100644 Task/Chat-server/JavaScript/chat-server.js create mode 100644 Task/Chat-server/PicoLisp/chat-server.l create mode 100644 Task/Chat-server/Python/chat-server.py create mode 100644 Task/Chat-server/Ruby/chat-server.rb create mode 100644 Task/Chat-server/Tcl/chat-server.tcl create mode 100644 Task/Check-Machin-like-formulas/0DESCRIPTION create mode 100644 Task/Check-Machin-like-formulas/D/check-machin-like-formulas.d create mode 100644 Task/Check-Machin-like-formulas/Go/check-machin-like-formulas.go create mode 100644 Task/Check-Machin-like-formulas/Haskell/check-machin-like-formulas-1.hs create mode 100644 Task/Check-Machin-like-formulas/Haskell/check-machin-like-formulas-2.hs create mode 100644 Task/Check-Machin-like-formulas/Python/check-machin-like-formulas.py create mode 100644 Task/Check-Machin-like-formulas/Tcl/check-machin-like-formulas.tcl create mode 100644 Task/Check-that-file-exists/C++/check-that-file-exists.cpp create mode 100644 Task/Check-that-file-exists/Common-Lisp/check-that-file-exists-1.lisp create mode 100644 Task/Check-that-file-exists/Common-Lisp/check-that-file-exists-2.lisp create mode 100644 Task/Check-that-file-exists/D/check-that-file-exists.d create mode 100644 Task/Check-that-file-exists/Delphi/check-that-file-exists.delphi create mode 100644 Task/Check-that-file-exists/E/check-that-file-exists.e create mode 100644 Task/Check-that-file-exists/Euphoria/check-that-file-exists.euphoria create mode 100644 Task/Checkpoint-synchronization/D/checkpoint-synchronization.d create mode 100644 Task/Checkpoint-synchronization/E/checkpoint-synchronization.e create mode 100644 Task/Cholesky-decomposition/0DESCRIPTION create mode 100644 Task/Cholesky-decomposition/1META.yaml create mode 100644 Task/Cholesky-decomposition/ALGOL-68/cholesky-decomposition.alg create mode 100644 Task/Cholesky-decomposition/Ada/cholesky-decomposition-1.ada create mode 100644 Task/Cholesky-decomposition/Ada/cholesky-decomposition-2.ada create mode 100644 Task/Cholesky-decomposition/Ada/cholesky-decomposition-3.ada create mode 100644 Task/Cholesky-decomposition/BBC-BASIC/cholesky-decomposition.bbc create mode 100644 Task/Cholesky-decomposition/C/cholesky-decomposition.c create mode 100644 Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-1.lisp create mode 100644 Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-2.lisp create mode 100644 Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-3.lisp create mode 100644 Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-4.lisp create mode 100644 Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-5.lisp create mode 100644 Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-6.lisp create mode 100644 Task/Cholesky-decomposition/D/cholesky-decomposition.d create mode 100644 Task/Cholesky-decomposition/DWScript/cholesky-decomposition.dwscript create mode 100644 Task/Cholesky-decomposition/Go/cholesky-decomposition-1.go create mode 100644 Task/Cholesky-decomposition/Go/cholesky-decomposition-2.go create mode 100644 Task/Cholesky-decomposition/Go/cholesky-decomposition-3.go create mode 100644 Task/Cholesky-decomposition/Haskell/cholesky-decomposition-1.hs create mode 100644 Task/Cholesky-decomposition/Haskell/cholesky-decomposition-2.hs create mode 100644 Task/Cholesky-decomposition/Java/cholesky-decomposition.java create mode 100644 Task/Cholesky-decomposition/MATLAB/cholesky-decomposition.m create mode 100644 Task/Cholesky-decomposition/PicoLisp/cholesky-decomposition-1.l create mode 100644 Task/Cholesky-decomposition/PicoLisp/cholesky-decomposition-2.l create mode 100644 Task/Cholesky-decomposition/Python/cholesky-decomposition.py create mode 100644 Task/Cholesky-decomposition/R/cholesky-decomposition.r create mode 100644 Task/Cholesky-decomposition/REXX/cholesky-decomposition.rexx create mode 100644 Task/Cholesky-decomposition/Ruby/cholesky-decomposition.rb create mode 100644 Task/Cholesky-decomposition/Tcl/cholesky-decomposition-1.tcl create mode 100644 Task/Cholesky-decomposition/Tcl/cholesky-decomposition-2.tcl create mode 100644 Task/Classes/C++/classes-1.cpp create mode 100644 Task/Classes/C++/classes-2.cpp create mode 100644 Task/Classes/C++/classes-3.cpp create mode 100644 Task/Classes/Common-Lisp/classes.lisp create mode 100644 Task/Classes/D/classes.d create mode 100644 Task/Classes/DWScript/classes.dwscript create mode 100644 Task/Classes/Delphi/classes.delphi create mode 100644 Task/Classes/E/classes-1.e create mode 100644 Task/Classes/E/classes-2.e create mode 100644 Task/Closest-pair-problem/Common-Lisp/closest-pair-problem.lisp create mode 100644 Task/Closest-pair-problem/D/closest-pair-problem-1.d create mode 100644 Task/Closest-pair-problem/D/closest-pair-problem-2.d create mode 100644 Task/Collections/C++/collections-1.cpp create mode 100644 Task/Collections/C++/collections-2.cpp create mode 100644 Task/Collections/C++/collections-3.cpp create mode 100644 Task/Collections/C++/collections-4.cpp create mode 100644 Task/Collections/C++/collections-5.cpp create mode 100644 Task/Collections/C++/collections-6.cpp create mode 100644 Task/Collections/Common-Lisp/collections-1.lisp create mode 100644 Task/Collections/Common-Lisp/collections-2.lisp create mode 100644 Task/Collections/D/collections-1.d create mode 100644 Task/Collections/D/collections-2.d create mode 100644 Task/Collections/D/collections-3.d create mode 100644 Task/Collections/E/collections.e create mode 100644 Task/Color-of-a-screen-pixel/C++-CLI/color-of-a-screen-pixel.cpp create mode 100644 Task/Color-of-a-screen-pixel/Delphi/color-of-a-screen-pixel.delphi create mode 100644 Task/Color-quantization/0DESCRIPTION create mode 100644 Task/Color-quantization/1META.yaml create mode 100644 Task/Color-quantization/C/color-quantization.c create mode 100644 Task/Color-quantization/D/color-quantization.d create mode 100644 Task/Color-quantization/Racket/color-quantization.rkt create mode 100644 Task/Color-quantization/Tcl/color-quantization-1.tcl create mode 100644 Task/Color-quantization/Tcl/color-quantization-2.tcl create mode 100644 Task/Colour-bars-Display/0DESCRIPTION create mode 100644 Task/Colour-bars-Display/AutoHotkey/colour-bars-display.ahk create mode 100644 Task/Colour-bars-Display/BBC-BASIC/colour-bars-display.bbc create mode 100644 Task/Colour-bars-Display/C++/colour-bars-display-1.cpp create mode 100644 Task/Colour-bars-Display/C++/colour-bars-display-2.cpp create mode 100644 Task/Colour-bars-Display/C++/colour-bars-display-3.cpp create mode 100644 Task/Colour-bars-Display/Java/colour-bars-display.java create mode 100644 Task/Colour-bars-Display/PHP/colour-bars-display.php create mode 100644 Task/Colour-bars-Display/Perl/colour-bars-display.pl create mode 100644 Task/Colour-bars-Display/PicoLisp/colour-bars-display.l create mode 100644 Task/Colour-bars-Display/Python/colour-bars-display.py create mode 100644 Task/Colour-bars-Display/R/colour-bars-display.r create mode 100644 Task/Colour-bars-Display/Scala/colour-bars-display-1.scala create mode 100644 Task/Colour-bars-Display/Scala/colour-bars-display-2.scala create mode 100644 Task/Colour-bars-Display/Tcl/colour-bars-display-1.tcl create mode 100644 Task/Colour-bars-Display/Tcl/colour-bars-display-2.tcl create mode 100644 Task/Colour-pinstripe-Display/0DESCRIPTION create mode 100644 Task/Colour-pinstripe-Display/1META.yaml create mode 100644 Task/Colour-pinstripe-Display/AutoHotkey/colour-pinstripe-display.ahk create mode 100644 Task/Colour-pinstripe-Display/BBC-BASIC/colour-pinstripe-display.bbc create mode 100644 Task/Colour-pinstripe-Display/Perl/colour-pinstripe-display.pl create mode 100644 Task/Colour-pinstripe-Display/PicoLisp/colour-pinstripe-display.l create mode 100644 Task/Colour-pinstripe-Display/Tcl/colour-pinstripe-display.tcl create mode 100644 Task/Colour-pinstripe-Printer/0DESCRIPTION create mode 100644 Task/Colour-pinstripe-Printer/1META.yaml create mode 100644 Task/Colour-pinstripe-Printer/BBC-BASIC/colour-pinstripe-printer.bbc create mode 100644 Task/Colour-pinstripe-Printer/PicoLisp/colour-pinstripe-printer.l create mode 100644 Task/Colour-pinstripe-Printer/Tcl/colour-pinstripe-printer.tcl create mode 100644 Task/Combinations-with-repetitions/0DESCRIPTION create mode 100644 Task/Combinations-with-repetitions/1META.yaml create mode 100644 Task/Combinations-with-repetitions/Ada/combinations-with-repetitions.ada create mode 100644 Task/Combinations-with-repetitions/BBC-BASIC/combinations-with-repetitions.bbc create mode 100644 Task/Combinations-with-repetitions/C/combinations-with-repetitions.c create mode 100644 Task/Combinations-with-repetitions/Clojure/combinations-with-repetitions-1.clj create mode 100644 Task/Combinations-with-repetitions/Clojure/combinations-with-repetitions-2.clj create mode 100644 Task/Combinations-with-repetitions/CoffeeScript/combinations-with-repetitions-1.coffee create mode 100644 Task/Combinations-with-repetitions/CoffeeScript/combinations-with-repetitions-2.coffee create mode 100644 Task/Combinations-with-repetitions/D/combinations-with-repetitions.d create mode 100644 Task/Combinations-with-repetitions/Erlang/combinations-with-repetitions-1.erl create mode 100644 Task/Combinations-with-repetitions/Erlang/combinations-with-repetitions-2.erl create mode 100644 Task/Combinations-with-repetitions/Fortran/combinations-with-repetitions.f create mode 100644 Task/Combinations-with-repetitions/Go/combinations-with-repetitions-1.go create mode 100644 Task/Combinations-with-repetitions/Go/combinations-with-repetitions-2.go create mode 100644 Task/Combinations-with-repetitions/Go/combinations-with-repetitions-3.go create mode 100644 Task/Combinations-with-repetitions/Haskell/combinations-with-repetitions-1.hs create mode 100644 Task/Combinations-with-repetitions/Haskell/combinations-with-repetitions-2.hs create mode 100644 Task/Combinations-with-repetitions/Java/combinations-with-repetitions-1.java create mode 100644 Task/Combinations-with-repetitions/Java/combinations-with-repetitions-2.java create mode 100644 Task/Combinations-with-repetitions/JavaScript/combinations-with-repetitions-1.js create mode 100644 Task/Combinations-with-repetitions/JavaScript/combinations-with-repetitions-2.js create mode 100644 Task/Combinations-with-repetitions/PHP/combinations-with-repetitions-1.php create mode 100644 Task/Combinations-with-repetitions/PHP/combinations-with-repetitions-2.php create mode 100644 Task/Combinations-with-repetitions/Perl/combinations-with-repetitions.pl create mode 100644 Task/Combinations-with-repetitions/PicoLisp/combinations-with-repetitions.l create mode 100644 Task/Combinations-with-repetitions/Python/combinations-with-repetitions.py create mode 100644 Task/Combinations-with-repetitions/REXX/combinations-with-repetitions.rexx create mode 100644 Task/Combinations-with-repetitions/Ruby/combinations-with-repetitions.rb create mode 100644 Task/Combinations-with-repetitions/Scala/combinations-with-repetitions.scala create mode 100644 Task/Combinations-with-repetitions/Scheme/combinations-with-repetitions.ss create mode 100644 Task/Combinations-with-repetitions/Tcl/combinations-with-repetitions.tcl create mode 100644 Task/Combinations/0DESCRIPTION create mode 100644 Task/Combinations/1META.yaml create mode 100644 Task/Combinations/ALGOL-68/combinations.alg create mode 100644 Task/Combinations/AWK/combinations.awk create mode 100644 Task/Combinations/Ada/combinations-1.ada create mode 100644 Task/Combinations/Ada/combinations-2.ada create mode 100644 Task/Combinations/AppleScript/combinations-1.applescript create mode 100644 Task/Combinations/AppleScript/combinations-2.applescript create mode 100644 Task/Combinations/AutoHotkey/combinations.ahk create mode 100644 Task/Combinations/BBC-BASIC/combinations.bbc create mode 100644 Task/Combinations/Bracmat/combinations.bracmat create mode 100644 Task/Combinations/C++/combinations.cpp create mode 100644 Task/Combinations/C/combinations-1.c create mode 100644 Task/Combinations/C/combinations-2.c create mode 100644 Task/Combinations/Clojure/combinations.clj create mode 100644 Task/Combinations/CoffeeScript/combinations-1.coffee create mode 100644 Task/Combinations/CoffeeScript/combinations-2.coffee create mode 100644 Task/Combinations/Common-Lisp/combinations-1.lisp create mode 100644 Task/Combinations/Common-Lisp/combinations-2.lisp create mode 100644 Task/Combinations/D/combinations-1.d create mode 100644 Task/Combinations/D/combinations-2.d create mode 100644 Task/Combinations/D/combinations-3.d create mode 100644 Task/Combinations/D/combinations-4.d create mode 100644 Task/Combinations/E/combinations.e create mode 100644 Task/Combinations/Erlang/combinations.erl create mode 100644 Task/Combinations/Fortran/combinations-1.f create mode 100644 Task/Combinations/Fortran/combinations-2.f create mode 100644 Task/Combinations/Fortran/combinations-3.f create mode 100644 Task/Combinations/Go/combinations.go create mode 100644 Task/Combinations/Haskell/combinations-1.hs create mode 100644 Task/Combinations/Haskell/combinations-2.hs create mode 100644 Task/Combinations/Haskell/combinations-3.hs create mode 100644 Task/Combinations/Haskell/combinations-4.hs create mode 100644 Task/Combinations/Haskell/combinations-5.hs create mode 100644 Task/Combinations/Haskell/combinations-6.hs create mode 100644 Task/Combinations/Java/combinations.java create mode 100644 Task/Combinations/JavaScript/combinations-1.js create mode 100644 Task/Combinations/JavaScript/combinations-2.js create mode 100644 Task/Combinations/Lua/combinations.lua create mode 100644 Task/Combinations/MATLAB/combinations.m create mode 100644 Task/Combinations/Perl/combinations.pl create mode 100644 Task/Combinations/PicoLisp/combinations.l create mode 100644 Task/Combinations/Prolog/combinations-1.pro create mode 100644 Task/Combinations/Prolog/combinations-2.pro create mode 100644 Task/Combinations/Prolog/combinations-3.pro create mode 100644 Task/Combinations/Prolog/combinations-4.pro create mode 100644 Task/Combinations/Python/combinations-1.py create mode 100644 Task/Combinations/Python/combinations-2.py create mode 100644 Task/Combinations/Python/combinations-3.py create mode 100644 Task/Combinations/Python/combinations-4.py create mode 100644 Task/Combinations/R/combinations-1.r create mode 100644 Task/Combinations/R/combinations-2.r create mode 100644 Task/Combinations/REXX/combinations.rexx create mode 100644 Task/Combinations/Ruby/combinations.rb create mode 100644 Task/Combinations/Scala/combinations.scala create mode 100644 Task/Combinations/Scheme/combinations.ss create mode 100644 Task/Combinations/Smalltalk/combinations.st create mode 100644 Task/Combinations/Tcl/combinations.tcl create mode 100644 Task/Command-line-arguments/0DESCRIPTION create mode 100644 Task/Command-line-arguments/ALGOL-68/command-line-arguments.alg create mode 100644 Task/Command-line-arguments/AWK/command-line-arguments.awk create mode 100644 Task/Command-line-arguments/Ada/command-line-arguments-1.ada create mode 100644 Task/Command-line-arguments/Ada/command-line-arguments-2.ada create mode 100644 Task/Command-line-arguments/Aikido/command-line-arguments.aikido create mode 100644 Task/Command-line-arguments/AppleScript/command-line-arguments.applescript create mode 100644 Task/Command-line-arguments/AutoHotkey/command-line-arguments.ahk create mode 100644 Task/Command-line-arguments/BASIC/command-line-arguments-1.bas create mode 100644 Task/Command-line-arguments/BASIC/command-line-arguments-2.bas create mode 100644 Task/Command-line-arguments/BBC-BASIC/command-line-arguments.bbc create mode 100644 Task/Command-line-arguments/Batch-File/command-line-arguments-1.bat create mode 100644 Task/Command-line-arguments/Batch-File/command-line-arguments-2.bat create mode 100644 Task/Command-line-arguments/Batch-File/command-line-arguments-3.bat create mode 100644 Task/Command-line-arguments/Bracmat/command-line-arguments.bracmat create mode 100644 Task/Command-line-arguments/C++/command-line-arguments.cpp create mode 100644 Task/Command-line-arguments/C/command-line-arguments.c create mode 100644 Task/Command-line-arguments/Clean/command-line-arguments.clean create mode 100644 Task/Command-line-arguments/Clojure/command-line-arguments.clj create mode 100644 Task/Command-line-arguments/Common-Lisp/command-line-arguments.lisp create mode 100644 Task/Command-line-arguments/D/command-line-arguments-1.d create mode 100644 Task/Command-line-arguments/D/command-line-arguments-2.d create mode 100644 Task/Command-line-arguments/Deja-Vu/command-line-arguments.djv create mode 100644 Task/Command-line-arguments/Delphi/command-line-arguments.delphi create mode 100644 Task/Command-line-arguments/E/command-line-arguments.e create mode 100644 Task/Command-line-arguments/Eiffel/command-line-arguments.e create mode 100644 Task/Command-line-arguments/Emacs-Lisp/command-line-arguments.l create mode 100644 Task/Command-line-arguments/Erlang/command-line-arguments-1.erl create mode 100644 Task/Command-line-arguments/Erlang/command-line-arguments-2.erl create mode 100644 Task/Command-line-arguments/Erlang/command-line-arguments-3.erl create mode 100644 Task/Command-line-arguments/Euphoria/command-line-arguments.euphoria create mode 100644 Task/Command-line-arguments/Forth/command-line-arguments-1.fth create mode 100644 Task/Command-line-arguments/Forth/command-line-arguments-2.fth create mode 100644 Task/Command-line-arguments/Fortran/command-line-arguments-1.f create mode 100644 Task/Command-line-arguments/Fortran/command-line-arguments-2.f create mode 100644 Task/Command-line-arguments/Go/command-line-arguments.go create mode 100644 Task/Command-line-arguments/Haskell/command-line-arguments.hs create mode 100644 Task/Command-line-arguments/Java/command-line-arguments.java create mode 100644 Task/Command-line-arguments/JavaScript/command-line-arguments-1.js create mode 100644 Task/Command-line-arguments/JavaScript/command-line-arguments-2.js create mode 100644 Task/Command-line-arguments/JavaScript/command-line-arguments-3.js create mode 100644 Task/Command-line-arguments/Lua/command-line-arguments.lua create mode 100644 Task/Command-line-arguments/PHP/command-line-arguments.php create mode 100644 Task/Command-line-arguments/Perl/command-line-arguments-1.pl create mode 100644 Task/Command-line-arguments/Perl/command-line-arguments-2.pl create mode 100644 Task/Command-line-arguments/PicoLisp/command-line-arguments.l create mode 100644 Task/Command-line-arguments/Python/command-line-arguments.py create mode 100644 Task/Command-line-arguments/R/command-line-arguments-1.r create mode 100644 Task/Command-line-arguments/R/command-line-arguments-2.r create mode 100644 Task/Command-line-arguments/REXX/command-line-arguments-1.rexx create mode 100644 Task/Command-line-arguments/REXX/command-line-arguments-2.rexx create mode 100644 Task/Command-line-arguments/Racket/command-line-arguments-1.rkt create mode 100644 Task/Command-line-arguments/Racket/command-line-arguments-2.rkt create mode 100644 Task/Command-line-arguments/Ruby/command-line-arguments.rb create mode 100644 Task/Command-line-arguments/Sather/command-line-arguments.sa create mode 100644 Task/Command-line-arguments/Scala/command-line-arguments-1.scala create mode 100644 Task/Command-line-arguments/Scala/command-line-arguments-2.scala create mode 100644 Task/Command-line-arguments/Scheme/command-line-arguments.ss create mode 100644 Task/Command-line-arguments/Smalltalk/command-line-arguments-1.st create mode 100644 Task/Command-line-arguments/Smalltalk/command-line-arguments-2.st create mode 100644 Task/Command-line-arguments/Tcl/command-line-arguments.tcl create mode 100644 Task/Comments/C++/comments-1.cpp create mode 100644 Task/Comments/C++/comments-2.cpp create mode 100644 Task/Comments/C++/comments-3.cpp create mode 100644 Task/Comments/COBOL/comments.cobol create mode 100644 Task/Comments/Chef/comments.chef create mode 100644 Task/Comments/Clean/comments-1.clean create mode 100644 Task/Comments/Clean/comments-2.clean create mode 100644 Task/Comments/ColdFusion/comments-1.cfm create mode 100644 Task/Comments/ColdFusion/comments-2.cfm create mode 100644 Task/Comments/Common-Lisp/comments-1.lisp create mode 100644 Task/Comments/Common-Lisp/comments-2.lisp create mode 100644 Task/Comments/D/comments-1.d create mode 100644 Task/Comments/D/comments-2.d create mode 100644 Task/Comments/D/comments-3.d create mode 100644 Task/Comments/D/comments-4.d create mode 100644 Task/Comments/DWScript/comments.dwscript create mode 100644 Task/Comments/Delphi/comments.delphi create mode 100644 Task/Comments/Deluge/comments.deluge create mode 100644 Task/Comments/E/comments.e create mode 100644 Task/Comments/Ela/comments.ela create mode 100644 Task/Comments/Emacs-Lisp/comments-1.l create mode 100644 Task/Comments/Emacs-Lisp/comments-2.l create mode 100644 Task/Comments/Emacs-Lisp/comments-3.l create mode 100644 Task/Comments/Euphoria/comments-1.euphoria create mode 100644 Task/Comments/Euphoria/comments-2.euphoria create mode 100644 Task/Compare-sorting-algorithms-performance/0DESCRIPTION create mode 100644 Task/Compare-sorting-algorithms-performance/1META.yaml create mode 100644 Task/Compare-sorting-algorithms-performance/AutoHotkey/compare-sorting-algorithms-performance.ahk create mode 100644 Task/Compare-sorting-algorithms-performance/BBC-BASIC/compare-sorting-algorithms-performance.bbc create mode 100644 Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-1.c create mode 100644 Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-2.c create mode 100644 Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-3.c create mode 100644 Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-4.c create mode 100644 Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-5.c create mode 100644 Task/Compare-sorting-algorithms-performance/D/compare-sorting-algorithms-performance.d create mode 100644 Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-1.py create mode 100644 Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-2.py create mode 100644 Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-3.py create mode 100644 Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-4.py create mode 100644 Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-5.py create mode 100644 Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-6.py create mode 100644 Task/Compare-sorting-algorithms-performance/Tcl/compare-sorting-algorithms-performance.tcl create mode 100644 Task/Compile-time-calculation/0DESCRIPTION create mode 100644 Task/Compile-time-calculation/Ada/compile-time-calculation-1.ada create mode 100644 Task/Compile-time-calculation/Ada/compile-time-calculation-2.ada create mode 100644 Task/Compile-time-calculation/Ada/compile-time-calculation-3.ada create mode 100644 Task/Compile-time-calculation/Ada/compile-time-calculation-4.ada create mode 100644 Task/Compile-time-calculation/BASIC/compile-time-calculation-1.bas create mode 100644 Task/Compile-time-calculation/BASIC/compile-time-calculation-2.bas create mode 100644 Task/Compile-time-calculation/C++/compile-time-calculation-1.cpp create mode 100644 Task/Compile-time-calculation/C++/compile-time-calculation-2.cpp create mode 100644 Task/Compile-time-calculation/C++/compile-time-calculation-3.cpp create mode 100644 Task/Compile-time-calculation/C/compile-time-calculation.c create mode 100644 Task/Compile-time-calculation/Clojure/compile-time-calculation.clj create mode 100644 Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-1.lisp create mode 100644 Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-2.lisp create mode 100644 Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-3.lisp create mode 100644 Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-4.lisp create mode 100644 Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-5.lisp create mode 100644 Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-6.lisp create mode 100644 Task/Compile-time-calculation/D/compile-time-calculation-1.d create mode 100644 Task/Compile-time-calculation/D/compile-time-calculation-2.d create mode 100644 Task/Compile-time-calculation/DWScript/compile-time-calculation.dwscript create mode 100644 Task/Compile-time-calculation/Forth/compile-time-calculation-1.fth create mode 100644 Task/Compile-time-calculation/Forth/compile-time-calculation-2.fth create mode 100644 Task/Compile-time-calculation/Fortran/compile-time-calculation.f create mode 100644 Task/Compile-time-calculation/Go/compile-time-calculation.go create mode 100644 Task/Compile-time-calculation/Haskell/compile-time-calculation.hs create mode 100644 Task/Compile-time-calculation/Perl/compile-time-calculation-1.pl create mode 100644 Task/Compile-time-calculation/Perl/compile-time-calculation-2.pl create mode 100644 Task/Compile-time-calculation/PicoLisp/compile-time-calculation.l create mode 100644 Task/Compile-time-calculation/REXX/compile-time-calculation.rexx create mode 100644 Task/Compile-time-calculation/Racket/compile-time-calculation.rkt create mode 100644 Task/Compile-time-calculation/Tcl/compile-time-calculation-1.tcl create mode 100644 Task/Compile-time-calculation/Tcl/compile-time-calculation-2.tcl create mode 100644 Task/Compound-data-type/0DESCRIPTION create mode 100644 Task/Compound-data-type/1META.yaml create mode 100644 Task/Compound-data-type/ACL2/compound-data-type.acl2 create mode 100644 Task/Compound-data-type/ALGOL-68/compound-data-type-1.alg create mode 100644 Task/Compound-data-type/ALGOL-68/compound-data-type-2.alg create mode 100644 Task/Compound-data-type/ALGOL-68/compound-data-type-3.alg create mode 100644 Task/Compound-data-type/ALGOL-68/compound-data-type-4.alg create mode 100644 Task/Compound-data-type/AWK/compound-data-type.awk create mode 100644 Task/Compound-data-type/ActionScript/compound-data-type.as create mode 100644 Task/Compound-data-type/Ada/compound-data-type-1.ada create mode 100644 Task/Compound-data-type/Ada/compound-data-type-2.ada create mode 100644 Task/Compound-data-type/Ada/compound-data-type-3.ada create mode 100644 Task/Compound-data-type/AmigaE/compound-data-type.amiga create mode 100644 Task/Compound-data-type/AutoHotkey/compound-data-type.ahk create mode 100644 Task/Compound-data-type/BASIC/compound-data-type.bas create mode 100644 Task/Compound-data-type/BBC-BASIC/compound-data-type.bbc create mode 100644 Task/Compound-data-type/Bracmat/compound-data-type.bracmat create mode 100644 Task/Compound-data-type/C++/compound-data-type-1.cpp create mode 100644 Task/Compound-data-type/C++/compound-data-type-2.cpp create mode 100644 Task/Compound-data-type/C++/compound-data-type-3.cpp create mode 100644 Task/Compound-data-type/C/compound-data-type.c create mode 100644 Task/Compound-data-type/Clean/compound-data-type-1.clean create mode 100644 Task/Compound-data-type/Clean/compound-data-type-2.clean create mode 100644 Task/Compound-data-type/Clean/compound-data-type-3.clean create mode 100644 Task/Compound-data-type/Clojure/compound-data-type-1.clj create mode 100644 Task/Compound-data-type/Clojure/compound-data-type-2.clj create mode 100644 Task/Compound-data-type/CoffeeScript/compound-data-type.coffee create mode 100644 Task/Compound-data-type/Common-Lisp/compound-data-type-1.lisp create mode 100644 Task/Compound-data-type/Common-Lisp/compound-data-type-2.lisp create mode 100644 Task/Compound-data-type/D/compound-data-type.d create mode 100644 Task/Compound-data-type/Delphi/compound-data-type.delphi create mode 100644 Task/Compound-data-type/E/compound-data-type.e create mode 100644 Task/Compound-data-type/Ela/compound-data-type-1.ela create mode 100644 Task/Compound-data-type/Ela/compound-data-type-2.ela create mode 100644 Task/Compound-data-type/Erlang/compound-data-type.erl create mode 100644 Task/Compound-data-type/Forth/compound-data-type-1.fth create mode 100644 Task/Compound-data-type/Forth/compound-data-type-2.fth create mode 100644 Task/Compound-data-type/Fortran/compound-data-type.f create mode 100644 Task/Compound-data-type/Go/compound-data-type.go create mode 100644 Task/Compound-data-type/Haskell/compound-data-type.hs create mode 100644 Task/Compound-data-type/Java/compound-data-type.java create mode 100644 Task/Compound-data-type/JavaScript/compound-data-type.js create mode 100644 Task/Compound-data-type/Lua/compound-data-type-1.lua create mode 100644 Task/Compound-data-type/Lua/compound-data-type-2.lua create mode 100644 Task/Compound-data-type/Lua/compound-data-type-3.lua create mode 100644 Task/Compound-data-type/Lua/compound-data-type-4.lua create mode 100644 Task/Compound-data-type/Lua/compound-data-type-5.lua create mode 100644 Task/Compound-data-type/PHP/compound-data-type-1.php create mode 100644 Task/Compound-data-type/PHP/compound-data-type-2.php create mode 100644 Task/Compound-data-type/PHP/compound-data-type-3.php create mode 100644 Task/Compound-data-type/Perl/compound-data-type-1.pl create mode 100644 Task/Compound-data-type/Perl/compound-data-type-2.pl create mode 100644 Task/Compound-data-type/Perl/compound-data-type-3.pl create mode 100644 Task/Compound-data-type/PicoLisp/compound-data-type.l create mode 100644 Task/Compound-data-type/Python/compound-data-type-1.py create mode 100644 Task/Compound-data-type/Python/compound-data-type-2.py create mode 100644 Task/Compound-data-type/Python/compound-data-type-3.py create mode 100644 Task/Compound-data-type/Python/compound-data-type-4.py create mode 100644 Task/Compound-data-type/R/compound-data-type.r create mode 100644 Task/Compound-data-type/REXX/compound-data-type-1.rexx create mode 100644 Task/Compound-data-type/REXX/compound-data-type-2.rexx create mode 100644 Task/Compound-data-type/Racket/compound-data-type-1.rkt create mode 100644 Task/Compound-data-type/Racket/compound-data-type-2.rkt create mode 100644 Task/Compound-data-type/Ruby/compound-data-type.rb create mode 100644 Task/Compound-data-type/Scala/compound-data-type.scala create mode 100644 Task/Compound-data-type/Scheme/compound-data-type.ss create mode 100644 Task/Compound-data-type/Tcl/compound-data-type-1.tcl create mode 100644 Task/Compound-data-type/Tcl/compound-data-type-2.tcl create mode 100644 Task/Compound-data-type/Tcl/compound-data-type-3.tcl create mode 100644 Task/Concurrent-computing/0DESCRIPTION create mode 100644 Task/Concurrent-computing/1META.yaml create mode 100644 Task/Concurrent-computing/ALGOL-68/concurrent-computing.alg create mode 100644 Task/Concurrent-computing/Ada/concurrent-computing.ada create mode 100644 Task/Concurrent-computing/BBC-BASIC/concurrent-computing.bbc create mode 100644 Task/Concurrent-computing/C++/concurrent-computing.cpp create mode 100644 Task/Concurrent-computing/C/concurrent-computing-1.c create mode 100644 Task/Concurrent-computing/C/concurrent-computing-2.c create mode 100644 Task/Concurrent-computing/Clojure/concurrent-computing.clj create mode 100644 Task/Concurrent-computing/CoffeeScript/concurrent-computing.coffee create mode 100644 Task/Concurrent-computing/Common-Lisp/concurrent-computing.lisp create mode 100644 Task/Concurrent-computing/D/concurrent-computing-1.d create mode 100644 Task/Concurrent-computing/D/concurrent-computing-2.d create mode 100644 Task/Concurrent-computing/Delphi/concurrent-computing.delphi create mode 100644 Task/Concurrent-computing/E/concurrent-computing-1.e create mode 100644 Task/Concurrent-computing/E/concurrent-computing-2.e create mode 100644 Task/Concurrent-computing/Erlang/concurrent-computing-1.erl create mode 100644 Task/Concurrent-computing/Erlang/concurrent-computing-2.erl create mode 100644 Task/Concurrent-computing/Euphoria/concurrent-computing.euphoria create mode 100644 Task/Concurrent-computing/Forth/concurrent-computing.fth create mode 100644 Task/Concurrent-computing/Fortran/concurrent-computing.f create mode 100644 Task/Concurrent-computing/Go/concurrent-computing-1.go create mode 100644 Task/Concurrent-computing/Go/concurrent-computing-2.go create mode 100644 Task/Concurrent-computing/Go/concurrent-computing-3.go create mode 100644 Task/Concurrent-computing/Haskell/concurrent-computing-1.hs create mode 100644 Task/Concurrent-computing/Haskell/concurrent-computing-2.hs create mode 100644 Task/Concurrent-computing/Haskell/concurrent-computing-3.hs create mode 100644 Task/Concurrent-computing/Java/concurrent-computing.java create mode 100644 Task/Concurrent-computing/JavaScript/concurrent-computing-1.js create mode 100644 Task/Concurrent-computing/JavaScript/concurrent-computing-2.js create mode 100644 Task/Concurrent-computing/Lua/concurrent-computing.lua create mode 100644 Task/Concurrent-computing/Perl/concurrent-computing-1.pl create mode 100644 Task/Concurrent-computing/Perl/concurrent-computing-2.pl create mode 100644 Task/Concurrent-computing/PicoLisp/concurrent-computing-1.l create mode 100644 Task/Concurrent-computing/PicoLisp/concurrent-computing-2.l create mode 100644 Task/Concurrent-computing/Python/concurrent-computing-1.py create mode 100644 Task/Concurrent-computing/Python/concurrent-computing-2.py create mode 100644 Task/Concurrent-computing/Python/concurrent-computing-3.py create mode 100644 Task/Concurrent-computing/Python/concurrent-computing-4.py create mode 100644 Task/Concurrent-computing/Python/concurrent-computing-5.py create mode 100644 Task/Concurrent-computing/Python/concurrent-computing-6.py create mode 100644 Task/Concurrent-computing/Python/concurrent-computing-7.py create mode 100644 Task/Concurrent-computing/Racket/concurrent-computing.rkt create mode 100644 Task/Concurrent-computing/Ruby/concurrent-computing.rb create mode 100644 Task/Concurrent-computing/Scala/concurrent-computing.scala create mode 100644 Task/Concurrent-computing/Scheme/concurrent-computing.ss create mode 100644 Task/Concurrent-computing/Tcl/concurrent-computing-1.tcl create mode 100644 Task/Concurrent-computing/Tcl/concurrent-computing-2.tcl create mode 100644 Task/Concurrent-computing/Tcl/concurrent-computing-3.tcl create mode 100644 Task/Conditional-structures/0DESCRIPTION create mode 100644 Task/Conditional-structures/1META.yaml create mode 100644 Task/Conditional-structures/6502-Assembly/conditional-structures-1.6502 create mode 100644 Task/Conditional-structures/6502-Assembly/conditional-structures-2.6502 create mode 100644 Task/Conditional-structures/6502-Assembly/conditional-structures-3.6502 create mode 100644 Task/Conditional-structures/6502-Assembly/conditional-structures-4.6502 create mode 100644 Task/Conditional-structures/AWK/conditional-structures-1.awk create mode 100644 Task/Conditional-structures/AWK/conditional-structures-2.awk create mode 100644 Task/Conditional-structures/Ada/conditional-structures-1.ada create mode 100644 Task/Conditional-structures/Ada/conditional-structures-2.ada create mode 100644 Task/Conditional-structures/Ada/conditional-structures-3.ada create mode 100644 Task/Conditional-structures/Ada/conditional-structures-4.ada create mode 100644 Task/Conditional-structures/Ada/conditional-structures-5.ada create mode 100644 Task/Conditional-structures/Ada/conditional-structures-6.ada create mode 100644 Task/Conditional-structures/Aikido/conditional-structures-1.aikido create mode 100644 Task/Conditional-structures/Aikido/conditional-structures-2.aikido create mode 100644 Task/Conditional-structures/Aikido/conditional-structures-3.aikido create mode 100644 Task/Conditional-structures/Aime/conditional-structures.aime create mode 100644 Task/Conditional-structures/AmbientTalk/conditional-structures-1.ambient create mode 100644 Task/Conditional-structures/AmbientTalk/conditional-structures-2.ambient create mode 100644 Task/Conditional-structures/AmigaE/conditional-structures-1.amiga create mode 100644 Task/Conditional-structures/AmigaE/conditional-structures-2.amiga create mode 100644 Task/Conditional-structures/AmigaE/conditional-structures-3.amiga create mode 100644 Task/Conditional-structures/AmigaE/conditional-structures-4.amiga create mode 100644 Task/Conditional-structures/AmigaE/conditional-structures-5.amiga create mode 100644 Task/Conditional-structures/AppleScript/conditional-structures.applescript create mode 100644 Task/Conditional-structures/AutoHotkey/conditional-structures.ahk create mode 100644 Task/Conditional-structures/BASIC/conditional-structures-1.bas create mode 100644 Task/Conditional-structures/BASIC/conditional-structures-2.bas create mode 100644 Task/Conditional-structures/BASIC/conditional-structures-3.bas create mode 100644 Task/Conditional-structures/BASIC/conditional-structures-4.bas create mode 100644 Task/Conditional-structures/BASIC/conditional-structures-5.bas create mode 100644 Task/Conditional-structures/BASIC/conditional-structures-6.bas create mode 100644 Task/Conditional-structures/BASIC/conditional-structures-7.bas create mode 100644 Task/Conditional-structures/BBC-BASIC/conditional-structures.bbc create mode 100644 Task/Conditional-structures/Befunge/conditional-structures-1.bf create mode 100644 Task/Conditional-structures/Befunge/conditional-structures-2.bf create mode 100644 Task/Conditional-structures/Bori/conditional-structures.bori create mode 100644 Task/Conditional-structures/Bracmat/conditional-structures-1.bracmat create mode 100644 Task/Conditional-structures/Bracmat/conditional-structures-2.bracmat create mode 100644 Task/Conditional-structures/Brainf---/conditional-structures-1.bf create mode 100644 Task/Conditional-structures/Brainf---/conditional-structures-2.bf create mode 100644 Task/Conditional-structures/Brainf---/conditional-structures-3.bf create mode 100644 Task/Conditional-structures/Burlesque/conditional-structures-1.blq create mode 100644 Task/Conditional-structures/Burlesque/conditional-structures-2.blq create mode 100644 Task/Conditional-structures/Burlesque/conditional-structures-3.blq create mode 100644 Task/Conditional-structures/Burlesque/conditional-structures-4.blq create mode 100644 Task/Conditional-structures/C++/conditional-structures.cpp create mode 100644 Task/Conditional-structures/CMake/conditional-structures.cmake create mode 100644 Task/Conditional-structures/COBOL/conditional-structures-1.cobol create mode 100644 Task/Conditional-structures/COBOL/conditional-structures-2.cobol create mode 100644 Task/Conditional-structures/Clean/conditional-structures-1.clean create mode 100644 Task/Conditional-structures/Clean/conditional-structures-2.clean create mode 100644 Task/Conditional-structures/Clean/conditional-structures-3.clean create mode 100644 Task/Conditional-structures/Clean/conditional-structures-4.clean create mode 100644 Task/Conditional-structures/Clojure/conditional-structures-1.clj create mode 100644 Task/Conditional-structures/Clojure/conditional-structures-2.clj create mode 100644 Task/Conditional-structures/Clojure/conditional-structures-3.clj create mode 100644 Task/Conditional-structures/Clojure/conditional-structures-4.clj create mode 100644 Task/Conditional-structures/Clojure/conditional-structures-5.clj create mode 100644 Task/Conditional-structures/Clojure/conditional-structures-6.clj create mode 100644 Task/Conditional-structures/Clojure/conditional-structures-7.clj create mode 100644 Task/Conditional-structures/CoffeeScript/conditional-structures-1.coffee create mode 100644 Task/Conditional-structures/CoffeeScript/conditional-structures-2.coffee create mode 100644 Task/Conditional-structures/CoffeeScript/conditional-structures-3.coffee create mode 100644 Task/Conditional-structures/ColdFusion/conditional-structures-1.cfm create mode 100644 Task/Conditional-structures/ColdFusion/conditional-structures-2.cfm create mode 100644 Task/Conditional-structures/Common-Lisp/conditional-structures-1.lisp create mode 100644 Task/Conditional-structures/Common-Lisp/conditional-structures-2.lisp create mode 100644 Task/Conditional-structures/Crack/conditional-structures-1.crack create mode 100644 Task/Conditional-structures/Crack/conditional-structures-2.crack create mode 100644 Task/Conditional-structures/D/conditional-structures-1.d create mode 100644 Task/Conditional-structures/D/conditional-structures-2.d create mode 100644 Task/Conditional-structures/Dao/conditional-structures-1.dao create mode 100644 Task/Conditional-structures/Dao/conditional-structures-2.dao create mode 100644 Task/Conditional-structures/Deja-Vu/conditional-structures.djv create mode 100644 Task/Conditional-structures/Deluge/conditional-structures.deluge create mode 100644 Task/Conditional-structures/E/conditional-structures-1.e create mode 100644 Task/Conditional-structures/E/conditional-structures-2.e create mode 100644 Task/Conditional-structures/E/conditional-structures-3.e create mode 100644 Task/Conditional-structures/E/conditional-structures-4.e create mode 100644 Task/Conditional-structures/Efene/conditional-structures.efene create mode 100644 Task/Conditional-structures/Ela/conditional-structures-1.ela create mode 100644 Task/Conditional-structures/Ela/conditional-structures-2.ela create mode 100644 Task/Conditional-structures/Ela/conditional-structures-3.ela create mode 100644 Task/Conditional-structures/Ela/conditional-structures-4.ela create mode 100644 Task/Conditional-structures/Erlang/conditional-structures-1.erl create mode 100644 Task/Conditional-structures/Erlang/conditional-structures-2.erl create mode 100644 Task/Conditional-structures/Erlang/conditional-structures-3.erl create mode 100644 Task/Conditional-structures/Forth/conditional-structures-1.fth create mode 100644 Task/Conditional-structures/Forth/conditional-structures-2.fth create mode 100644 Task/Conditional-structures/Forth/conditional-structures-3.fth create mode 100644 Task/Conditional-structures/Forth/conditional-structures-4.fth create mode 100644 Task/Conditional-structures/Forth/conditional-structures-5.fth create mode 100644 Task/Conditional-structures/Fortran/conditional-structures-1.f create mode 100644 Task/Conditional-structures/Fortran/conditional-structures-2.f create mode 100644 Task/Conditional-structures/Fortran/conditional-structures-3.f create mode 100644 Task/Conditional-structures/Go/conditional-structures-1.go create mode 100644 Task/Conditional-structures/Go/conditional-structures-10.go create mode 100644 Task/Conditional-structures/Go/conditional-structures-2.go create mode 100644 Task/Conditional-structures/Go/conditional-structures-3.go create mode 100644 Task/Conditional-structures/Go/conditional-structures-4.go create mode 100644 Task/Conditional-structures/Go/conditional-structures-5.go create mode 100644 Task/Conditional-structures/Go/conditional-structures-6.go create mode 100644 Task/Conditional-structures/Go/conditional-structures-7.go create mode 100644 Task/Conditional-structures/Go/conditional-structures-8.go create mode 100644 Task/Conditional-structures/Go/conditional-structures-9.go create mode 100644 Task/Conditional-structures/Haskell/conditional-structures-1.hs create mode 100644 Task/Conditional-structures/Haskell/conditional-structures-2.hs create mode 100644 Task/Conditional-structures/Haskell/conditional-structures-3.hs create mode 100644 Task/Conditional-structures/Haskell/conditional-structures-4.hs create mode 100644 Task/Conditional-structures/Java/conditional-structures-1.java create mode 100644 Task/Conditional-structures/Java/conditional-structures-2.java create mode 100644 Task/Conditional-structures/Java/conditional-structures-3.java create mode 100644 Task/Conditional-structures/Java/conditional-structures-4.java create mode 100644 Task/Conditional-structures/Java/conditional-structures-5.java create mode 100644 Task/Conditional-structures/Java/conditional-structures-6.java create mode 100644 Task/Conditional-structures/JavaScript/conditional-structures-1.js create mode 100644 Task/Conditional-structures/JavaScript/conditional-structures-2.js create mode 100644 Task/Conditional-structures/JavaScript/conditional-structures-3.js create mode 100644 Task/Conditional-structures/Lua/conditional-structures.lua create mode 100644 Task/Conditional-structures/MATLAB/conditional-structures-1.m create mode 100644 Task/Conditional-structures/MATLAB/conditional-structures-2.m create mode 100644 Task/Conditional-structures/PHP/conditional-structures-1.php create mode 100644 Task/Conditional-structures/PHP/conditional-structures-2.php create mode 100644 Task/Conditional-structures/Perl/conditional-structures.pl create mode 100644 Task/Conditional-structures/PicoLisp/conditional-structures-1.l create mode 100644 Task/Conditional-structures/PicoLisp/conditional-structures-2.l create mode 100644 Task/Conditional-structures/PicoLisp/conditional-structures-3.l create mode 100644 Task/Conditional-structures/PicoLisp/conditional-structures-4.l create mode 100644 Task/Conditional-structures/PicoLisp/conditional-structures-5.l create mode 100644 Task/Conditional-structures/Python/conditional-structures-1.py create mode 100644 Task/Conditional-structures/Python/conditional-structures-2.py create mode 100644 Task/Conditional-structures/Python/conditional-structures-3.py create mode 100644 Task/Conditional-structures/Python/conditional-structures-4.py create mode 100644 Task/Conditional-structures/Python/conditional-structures-5.py create mode 100644 Task/Conditional-structures/R/conditional-structures-1.r create mode 100644 Task/Conditional-structures/R/conditional-structures-2.r create mode 100644 Task/Conditional-structures/R/conditional-structures-3.r create mode 100644 Task/Conditional-structures/REXX/conditional-structures-1.rexx create mode 100644 Task/Conditional-structures/REXX/conditional-structures-2.rexx create mode 100644 Task/Conditional-structures/REXX/conditional-structures-3.rexx create mode 100644 Task/Conditional-structures/SNUSP/conditional-structures.snusp create mode 100644 Task/Conditional-structures/Sather/conditional-structures-1.sa create mode 100644 Task/Conditional-structures/Sather/conditional-structures-2.sa create mode 100644 Task/Conditional-structures/Scheme/conditional-structures-1.ss create mode 100644 Task/Conditional-structures/Scheme/conditional-structures-10.ss create mode 100644 Task/Conditional-structures/Scheme/conditional-structures-2.ss create mode 100644 Task/Conditional-structures/Scheme/conditional-structures-3.ss create mode 100644 Task/Conditional-structures/Scheme/conditional-structures-4.ss create mode 100644 Task/Conditional-structures/Scheme/conditional-structures-5.ss create mode 100644 Task/Conditional-structures/Scheme/conditional-structures-6.ss create mode 100644 Task/Conditional-structures/Scheme/conditional-structures-7.ss create mode 100644 Task/Conditional-structures/Scheme/conditional-structures-8.ss create mode 100644 Task/Conditional-structures/Scheme/conditional-structures-9.ss create mode 100644 Task/Conditional-structures/Smalltalk/conditional-structures-1.st create mode 100644 Task/Conditional-structures/Smalltalk/conditional-structures-2.st create mode 100644 Task/Conditional-structures/Tcl/conditional-structures-1.tcl create mode 100644 Task/Conditional-structures/Tcl/conditional-structures-2.tcl create mode 100644 Task/Conditional-structures/Tcl/conditional-structures-3.tcl create mode 100644 Task/Constrained-genericity/0DESCRIPTION create mode 100644 Task/Constrained-genericity/1META.yaml create mode 100644 Task/Constrained-genericity/Ada/constrained-genericity-1.ada create mode 100644 Task/Constrained-genericity/Ada/constrained-genericity-2.ada create mode 100644 Task/Constrained-genericity/Common-Lisp/constrained-genericity.lisp create mode 100644 Task/Constrained-genericity/D/constrained-genericity-1.d create mode 100644 Task/Constrained-genericity/D/constrained-genericity-2.d create mode 100644 Task/Constrained-genericity/E/constrained-genericity.e create mode 100644 Task/Constrained-genericity/Eiffel/constrained-genericity-1.e create mode 100644 Task/Constrained-genericity/Eiffel/constrained-genericity-2.e create mode 100644 Task/Constrained-genericity/Eiffel/constrained-genericity-3.e create mode 100644 Task/Constrained-genericity/Eiffel/constrained-genericity-4.e create mode 100644 Task/Constrained-genericity/Eiffel/constrained-genericity-5.e create mode 100644 Task/Constrained-genericity/Eiffel/constrained-genericity-6.e create mode 100644 Task/Constrained-genericity/Eiffel/constrained-genericity-7.e create mode 100644 Task/Constrained-genericity/Eiffel/constrained-genericity-8.e create mode 100644 Task/Constrained-genericity/Go/constrained-genericity-1.go create mode 100644 Task/Constrained-genericity/Go/constrained-genericity-2.go create mode 100644 Task/Constrained-genericity/Go/constrained-genericity-3.go create mode 100644 Task/Constrained-genericity/Go/constrained-genericity-4.go create mode 100644 Task/Constrained-genericity/Haskell/constrained-genericity-1.hs create mode 100644 Task/Constrained-genericity/Haskell/constrained-genericity-2.hs create mode 100644 Task/Constrained-genericity/Haskell/constrained-genericity-3.hs create mode 100644 Task/Constrained-genericity/Haskell/constrained-genericity-4.hs create mode 100644 Task/Constrained-genericity/Haskell/constrained-genericity-5.hs create mode 100644 Task/Constrained-genericity/Haskell/constrained-genericity-6.hs create mode 100644 Task/Constrained-genericity/Java/constrained-genericity-1.java create mode 100644 Task/Constrained-genericity/Java/constrained-genericity-2.java create mode 100644 Task/Constrained-genericity/Java/constrained-genericity-3.java create mode 100644 Task/Constrained-genericity/Java/constrained-genericity-4.java create mode 100644 Task/Constrained-genericity/Java/constrained-genericity-5.java create mode 100644 Task/Constrained-genericity/PicoLisp/constrained-genericity.l create mode 100644 Task/Constrained-genericity/Sather/constrained-genericity.sa create mode 100644 Task/Constrained-genericity/Scala/constrained-genericity.scala create mode 100644 Task/Constrained-random-points-on-a-circle/0DESCRIPTION create mode 100644 Task/Constrained-random-points-on-a-circle/1META.yaml create mode 100644 Task/Constrained-random-points-on-a-circle/ALGOL-68/constrained-random-points-on-a-circle.alg create mode 100644 Task/Constrained-random-points-on-a-circle/Ada/constrained-random-points-on-a-circle.ada create mode 100644 Task/Constrained-random-points-on-a-circle/AutoHotkey/constrained-random-points-on-a-circle.ahk create mode 100644 Task/Constrained-random-points-on-a-circle/BBC-BASIC/constrained-random-points-on-a-circle.bbc create mode 100644 Task/Constrained-random-points-on-a-circle/C/constrained-random-points-on-a-circle-1.c create mode 100644 Task/Constrained-random-points-on-a-circle/C/constrained-random-points-on-a-circle-2.c create mode 100644 Task/Constrained-random-points-on-a-circle/Clojure/constrained-random-points-on-a-circle.clj create mode 100644 Task/Constrained-random-points-on-a-circle/CoffeeScript/constrained-random-points-on-a-circle-1.coffee create mode 100644 Task/Constrained-random-points-on-a-circle/CoffeeScript/constrained-random-points-on-a-circle-2.coffee create mode 100644 Task/Constrained-random-points-on-a-circle/Common-Lisp/constrained-random-points-on-a-circle.lisp create mode 100644 Task/Constrained-random-points-on-a-circle/D/constrained-random-points-on-a-circle.d create mode 100644 Task/Constrained-random-points-on-a-circle/Euphoria/constrained-random-points-on-a-circle-1.euphoria create mode 100644 Task/Constrained-random-points-on-a-circle/Euphoria/constrained-random-points-on-a-circle-2.euphoria create mode 100644 Task/Constrained-random-points-on-a-circle/Fortran/constrained-random-points-on-a-circle.f create mode 100644 Task/Constrained-random-points-on-a-circle/Go/constrained-random-points-on-a-circle-1.go create mode 100644 Task/Constrained-random-points-on-a-circle/Go/constrained-random-points-on-a-circle-2.go create mode 100644 Task/Constrained-random-points-on-a-circle/Haskell/constrained-random-points-on-a-circle.hs create mode 100644 Task/Constrained-random-points-on-a-circle/Java/constrained-random-points-on-a-circle.java create mode 100644 Task/Constrained-random-points-on-a-circle/JavaScript/constrained-random-points-on-a-circle.js create mode 100644 Task/Constrained-random-points-on-a-circle/MATLAB/constrained-random-points-on-a-circle-1.m create mode 100644 Task/Constrained-random-points-on-a-circle/MATLAB/constrained-random-points-on-a-circle-2.m create mode 100644 Task/Constrained-random-points-on-a-circle/Perl/constrained-random-points-on-a-circle.pl create mode 100644 Task/Constrained-random-points-on-a-circle/PicoLisp/constrained-random-points-on-a-circle.l create mode 100644 Task/Constrained-random-points-on-a-circle/Prolog/constrained-random-points-on-a-circle.pro create mode 100644 Task/Constrained-random-points-on-a-circle/Python/constrained-random-points-on-a-circle-1.py create mode 100644 Task/Constrained-random-points-on-a-circle/Python/constrained-random-points-on-a-circle-2.py create mode 100644 Task/Constrained-random-points-on-a-circle/R/constrained-random-points-on-a-circle.r create mode 100644 Task/Constrained-random-points-on-a-circle/REXX/constrained-random-points-on-a-circle-1.rexx create mode 100644 Task/Constrained-random-points-on-a-circle/REXX/constrained-random-points-on-a-circle-2.rexx create mode 100644 Task/Constrained-random-points-on-a-circle/Ruby/constrained-random-points-on-a-circle.rb create mode 100644 Task/Constrained-random-points-on-a-circle/Tcl/constrained-random-points-on-a-circle.tcl create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/0DESCRIPTION create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-1.cpp create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-2.cpp create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-3.cpp create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-4.cpp create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Haskell/continued-fraction-arithmetic-construct-from-rational-number.hs create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Python/continued-fraction-arithmetic-construct-from-rational-number-1.py create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Python/continued-fraction-arithmetic-construct-from-rational-number-2.py create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/REXX/continued-fraction-arithmetic-construct-from-rational-number.rexx create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-1.rb create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-10.rb create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-2.rb create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-3.rb create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-4.rb create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-5.rb create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-6.rb create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-7.rb create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-8.rb create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-9.rb create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-1.tcl create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-2.tcl create mode 100644 Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-3.tcl create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/0DESCRIPTION create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-3.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-4.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-5.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-6.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-7.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.rb create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.rb create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-3.rb create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-4.rb create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.tcl create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.tcl create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/0DESCRIPTION create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/1META.yaml create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-1.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-2.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-3.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-4.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-5.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-6.cpp create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-1.tcl create mode 100644 Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-2.tcl create mode 100644 Task/Continued-fraction/0DESCRIPTION create mode 100644 Task/Continued-fraction/ATS/continued-fraction.ats create mode 100644 Task/Continued-fraction/Ada/continued-fraction-1.ada create mode 100644 Task/Continued-fraction/Ada/continued-fraction-2.ada create mode 100644 Task/Continued-fraction/Ada/continued-fraction-3.ada create mode 100644 Task/Continued-fraction/Ada/continued-fraction-4.ada create mode 100644 Task/Continued-fraction/Ada/continued-fraction-5.ada create mode 100644 Task/Continued-fraction/Ada/continued-fraction-6.ada create mode 100644 Task/Continued-fraction/Axiom/continued-fraction-1.axiom create mode 100644 Task/Continued-fraction/Axiom/continued-fraction-2.axiom create mode 100644 Task/Continued-fraction/Axiom/continued-fraction-3.axiom create mode 100644 Task/Continued-fraction/BBC-BASIC/continued-fraction.bbc create mode 100644 Task/Continued-fraction/C++/continued-fraction.cpp create mode 100644 Task/Continued-fraction/C/continued-fraction.c create mode 100644 Task/Continued-fraction/CoffeeScript/continued-fraction.coffee create mode 100644 Task/Continued-fraction/Common-Lisp/continued-fraction.lisp create mode 100644 Task/Continued-fraction/D/continued-fraction.d create mode 100644 Task/Continued-fraction/Forth/continued-fraction.fth create mode 100644 Task/Continued-fraction/Go/continued-fraction.go create mode 100644 Task/Continued-fraction/Haskell/continued-fraction-1.hs create mode 100644 Task/Continued-fraction/Haskell/continued-fraction-2.hs create mode 100644 Task/Continued-fraction/Perl/continued-fraction.pl create mode 100644 Task/Continued-fraction/Prolog/continued-fraction.pro create mode 100644 Task/Continued-fraction/Python/continued-fraction-1.py create mode 100644 Task/Continued-fraction/Python/continued-fraction-2.py create mode 100644 Task/Continued-fraction/REXX/continued-fraction-1.rexx create mode 100644 Task/Continued-fraction/REXX/continued-fraction-2.rexx create mode 100644 Task/Continued-fraction/REXX/continued-fraction-3.rexx create mode 100644 Task/Continued-fraction/Ruby/continued-fraction.rb create mode 100644 Task/Continued-fraction/Scala/continued-fraction-1.scala create mode 100644 Task/Continued-fraction/Scala/continued-fraction-2.scala create mode 100644 Task/Continued-fraction/Tcl/continued-fraction.tcl create mode 100644 Task/Conways-Game-of-Life/0DESCRIPTION create mode 100644 Task/Conways-Game-of-Life/1META.yaml create mode 100644 Task/Conways-Game-of-Life/6502-Assembly/conways-game-of-life.6502 create mode 100644 Task/Conways-Game-of-Life/ACL2/conways-game-of-life.acl2 create mode 100644 Task/Conways-Game-of-Life/AWK/conways-game-of-life.awk create mode 100644 Task/Conways-Game-of-Life/Ada/conways-game-of-life.ada create mode 100644 Task/Conways-Game-of-Life/AutoHotkey/conways-game-of-life.ahk create mode 100644 Task/Conways-Game-of-Life/BASIC256/conways-game-of-life.basic256 create mode 100644 Task/Conways-Game-of-Life/BBC-BASIC/conways-game-of-life.bbc create mode 100644 Task/Conways-Game-of-Life/C++/conways-game-of-life.cpp create mode 100644 Task/Conways-Game-of-Life/C-sharp/conways-game-of-life.cs create mode 100644 Task/Conways-Game-of-Life/C/conways-game-of-life.c create mode 100644 Task/Conways-Game-of-Life/Clojure/conways-game-of-life.clj create mode 100644 Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-1.lisp create mode 100644 Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-2.lisp create mode 100644 Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-3.lisp create mode 100644 Task/Conways-Game-of-Life/D/conways-game-of-life-1.d create mode 100644 Task/Conways-Game-of-Life/D/conways-game-of-life-2.d create mode 100644 Task/Conways-Game-of-Life/Dart/conways-game-of-life-1.dart create mode 100644 Task/Conways-Game-of-Life/Dart/conways-game-of-life-2.dart create mode 100644 Task/Conways-Game-of-Life/E/conways-game-of-life.e create mode 100644 Task/Conways-Game-of-Life/Erlang/conways-game-of-life.erl create mode 100644 Task/Conways-Game-of-Life/Forth/conways-game-of-life.fth create mode 100644 Task/Conways-Game-of-Life/Fortran/conways-game-of-life.f create mode 100644 Task/Conways-Game-of-Life/Go/conways-game-of-life.go create mode 100644 Task/Conways-Game-of-Life/Haskell/conways-game-of-life-1.hs create mode 100644 Task/Conways-Game-of-Life/Haskell/conways-game-of-life-2.hs create mode 100644 Task/Conways-Game-of-Life/Haskell/conways-game-of-life-3.hs create mode 100644 Task/Conways-Game-of-Life/Java/conways-game-of-life.java create mode 100644 Task/Conways-Game-of-Life/JavaScript/conways-game-of-life-1.js create mode 100644 Task/Conways-Game-of-Life/JavaScript/conways-game-of-life-2.js create mode 100644 Task/Conways-Game-of-Life/Lua/conways-game-of-life.lua create mode 100644 Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-1.m create mode 100644 Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-2.m create mode 100644 Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-3.m create mode 100644 Task/Conways-Game-of-Life/Perl/conways-game-of-life-1.pl create mode 100644 Task/Conways-Game-of-Life/Perl/conways-game-of-life-2.pl create mode 100644 Task/Conways-Game-of-Life/PicoLisp/conways-game-of-life.l create mode 100644 Task/Conways-Game-of-Life/Prolog/conways-game-of-life.pro create mode 100644 Task/Conways-Game-of-Life/Python/conways-game-of-life-1.py create mode 100644 Task/Conways-Game-of-Life/Python/conways-game-of-life-2.py create mode 100644 Task/Conways-Game-of-Life/R/conways-game-of-life.r create mode 100644 Task/Conways-Game-of-Life/REXX/conways-game-of-life.rexx create mode 100644 Task/Conways-Game-of-Life/Racket/conways-game-of-life.rkt create mode 100644 Task/Conways-Game-of-Life/Ruby/conways-game-of-life-1.rb create mode 100644 Task/Conways-Game-of-Life/Ruby/conways-game-of-life-2.rb create mode 100644 Task/Conways-Game-of-Life/Scheme/conways-game-of-life.ss create mode 100644 Task/Conways-Game-of-Life/Tcl/conways-game-of-life.tcl create mode 100644 Task/Count-in-factors/0DESCRIPTION create mode 100644 Task/Count-in-factors/Ada/count-in-factors.ada create mode 100644 Task/Count-in-factors/AutoHotkey/count-in-factors.ahk create mode 100644 Task/Count-in-factors/BBC-BASIC/count-in-factors.bbc create mode 100644 Task/Count-in-factors/C/count-in-factors.c create mode 100644 Task/Count-in-factors/CoffeeScript/count-in-factors.coffee create mode 100644 Task/Count-in-factors/Common-Lisp/count-in-factors-1.lisp create mode 100644 Task/Count-in-factors/Common-Lisp/count-in-factors-2.lisp create mode 100644 Task/Count-in-factors/D/count-in-factors-1.d create mode 100644 Task/Count-in-factors/D/count-in-factors-2.d create mode 100644 Task/Count-in-factors/DWScript/count-in-factors.dwscript create mode 100644 Task/Count-in-factors/Euphoria/count-in-factors.euphoria create mode 100644 Task/Count-in-factors/Forth/count-in-factors.fth create mode 100644 Task/Count-in-factors/Go/count-in-factors.go create mode 100644 Task/Count-in-factors/Haskell/count-in-factors-1.hs create mode 100644 Task/Count-in-factors/Haskell/count-in-factors-2.hs create mode 100644 Task/Count-in-factors/Java/count-in-factors.java create mode 100644 Task/Count-in-factors/JavaScript/count-in-factors.js create mode 100644 Task/Count-in-factors/Lua/count-in-factors.lua create mode 100644 Task/Count-in-factors/Perl/count-in-factors.pl create mode 100644 Task/Count-in-factors/PicoLisp/count-in-factors.l create mode 100644 Task/Count-in-factors/Python/count-in-factors.py create mode 100644 Task/Count-in-factors/REXX/count-in-factors.rexx create mode 100644 Task/Count-in-factors/Racket/count-in-factors.rkt create mode 100644 Task/Count-in-factors/Ruby/count-in-factors.rb create mode 100644 Task/Count-in-factors/Scheme/count-in-factors.ss create mode 100644 Task/Count-in-factors/Tcl/count-in-factors-1.tcl create mode 100644 Task/Count-in-factors/Tcl/count-in-factors-2.tcl create mode 100644 Task/Count-in-octal/0815/count-in-octal.0815 create mode 100644 Task/Count-in-octal/0DESCRIPTION create mode 100644 Task/Count-in-octal/ALGOL-68/count-in-octal.alg create mode 100644 Task/Count-in-octal/AWK/count-in-octal.awk create mode 100644 Task/Count-in-octal/Ada/count-in-octal.ada create mode 100644 Task/Count-in-octal/AutoHotkey/count-in-octal.ahk create mode 100644 Task/Count-in-octal/BASIC/count-in-octal-1.bas create mode 100644 Task/Count-in-octal/BASIC/count-in-octal-2.bas create mode 100644 Task/Count-in-octal/BBC-BASIC/count-in-octal.bbc create mode 100644 Task/Count-in-octal/Bracmat/count-in-octal.bracmat create mode 100644 Task/Count-in-octal/Brainf---/count-in-octal.bf create mode 100644 Task/Count-in-octal/C++/count-in-octal.cpp create mode 100644 Task/Count-in-octal/C/count-in-octal.c create mode 100644 Task/Count-in-octal/Clojure/count-in-octal.clj create mode 100644 Task/Count-in-octal/CoffeeScript/count-in-octal.coffee create mode 100644 Task/Count-in-octal/Common-Lisp/count-in-octal.lisp create mode 100644 Task/Count-in-octal/D/count-in-octal.d create mode 100644 Task/Count-in-octal/Dc/count-in-octal.dc create mode 100644 Task/Count-in-octal/Delphi/count-in-octal.delphi create mode 100644 Task/Count-in-octal/Emacs-Lisp/count-in-octal.l create mode 100644 Task/Count-in-octal/Euphoria/count-in-octal.euphoria create mode 100644 Task/Count-in-octal/Forth/count-in-octal.fth create mode 100644 Task/Count-in-octal/Fortran/count-in-octal.f create mode 100644 Task/Count-in-octal/Go/count-in-octal-1.go create mode 100644 Task/Count-in-octal/Go/count-in-octal-2.go create mode 100644 Task/Count-in-octal/Go/count-in-octal-3.go create mode 100644 Task/Count-in-octal/Go/count-in-octal-4.go create mode 100644 Task/Count-in-octal/Haskell/count-in-octal.hs create mode 100644 Task/Count-in-octal/Java/count-in-octal.java create mode 100644 Task/Count-in-octal/JavaScript/count-in-octal.js create mode 100644 Task/Count-in-octal/Lua/count-in-octal.lua create mode 100644 Task/Count-in-octal/MATLAB/count-in-octal-1.m create mode 100644 Task/Count-in-octal/MATLAB/count-in-octal-2.m create mode 100644 Task/Count-in-octal/MATLAB/count-in-octal-3.m create mode 100644 Task/Count-in-octal/MATLAB/count-in-octal-4.m create mode 100644 Task/Count-in-octal/PHP/count-in-octal.php create mode 100644 Task/Count-in-octal/Perl/count-in-octal-1.pl create mode 100644 Task/Count-in-octal/Perl/count-in-octal-2.pl create mode 100644 Task/Count-in-octal/PicoLisp/count-in-octal.l create mode 100644 Task/Count-in-octal/Python/count-in-octal.py create mode 100644 Task/Count-in-octal/REXX/count-in-octal.rexx create mode 100644 Task/Count-in-octal/Racket/count-in-octal.rkt create mode 100644 Task/Count-in-octal/Ruby/count-in-octal.rb create mode 100644 Task/Count-in-octal/Scala/count-in-octal.scala create mode 100644 Task/Count-in-octal/Scheme/count-in-octal.ss create mode 100644 Task/Count-in-octal/Tcl/count-in-octal.tcl create mode 100644 Task/Count-occurrences-of-a-substring/0DESCRIPTION create mode 100644 Task/Count-occurrences-of-a-substring/1META.yaml create mode 100644 Task/Count-occurrences-of-a-substring/ALGOL-68/count-occurrences-of-a-substring.alg create mode 100644 Task/Count-occurrences-of-a-substring/AWK/count-occurrences-of-a-substring.awk create mode 100644 Task/Count-occurrences-of-a-substring/Ada/count-occurrences-of-a-substring.ada create mode 100644 Task/Count-occurrences-of-a-substring/AutoHotkey/count-occurrences-of-a-substring.ahk create mode 100644 Task/Count-occurrences-of-a-substring/BASIC/count-occurrences-of-a-substring.bas create mode 100644 Task/Count-occurrences-of-a-substring/BBC-BASIC/count-occurrences-of-a-substring.bbc create mode 100644 Task/Count-occurrences-of-a-substring/Bracmat/count-occurrences-of-a-substring.bracmat create mode 100644 Task/Count-occurrences-of-a-substring/C++/count-occurrences-of-a-substring.cpp create mode 100644 Task/Count-occurrences-of-a-substring/C-sharp/count-occurrences-of-a-substring.cs create mode 100644 Task/Count-occurrences-of-a-substring/C/count-occurrences-of-a-substring-1.c create mode 100644 Task/Count-occurrences-of-a-substring/C/count-occurrences-of-a-substring-2.c create mode 100644 Task/Count-occurrences-of-a-substring/CoffeeScript/count-occurrences-of-a-substring.coffee create mode 100644 Task/Count-occurrences-of-a-substring/Common-Lisp/count-occurrences-of-a-substring.lisp create mode 100644 Task/Count-occurrences-of-a-substring/D/count-occurrences-of-a-substring.d create mode 100644 Task/Count-occurrences-of-a-substring/Delphi/count-occurrences-of-a-substring.delphi create mode 100644 Task/Count-occurrences-of-a-substring/EGL/count-occurrences-of-a-substring.egl create mode 100644 Task/Count-occurrences-of-a-substring/Eiffel/count-occurrences-of-a-substring.e create mode 100644 Task/Count-occurrences-of-a-substring/Erlang/count-occurrences-of-a-substring-1.erl create mode 100644 Task/Count-occurrences-of-a-substring/Erlang/count-occurrences-of-a-substring-2.erl create mode 100644 Task/Count-occurrences-of-a-substring/Euphoria/count-occurrences-of-a-substring.euphoria create mode 100644 Task/Count-occurrences-of-a-substring/Forth/count-occurrences-of-a-substring.fth create mode 100644 Task/Count-occurrences-of-a-substring/Fortran/count-occurrences-of-a-substring.f create mode 100644 Task/Count-occurrences-of-a-substring/Go/count-occurrences-of-a-substring.go create mode 100644 Task/Count-occurrences-of-a-substring/Haskell/count-occurrences-of-a-substring.hs create mode 100644 Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-1.java create mode 100644 Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-2.java create mode 100644 Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-3.java create mode 100644 Task/Count-occurrences-of-a-substring/JavaScript/count-occurrences-of-a-substring.js create mode 100644 Task/Count-occurrences-of-a-substring/Lua/count-occurrences-of-a-substring.lua create mode 100644 Task/Count-occurrences-of-a-substring/MATLAB/count-occurrences-of-a-substring.m create mode 100644 Task/Count-occurrences-of-a-substring/PHP/count-occurrences-of-a-substring.php create mode 100644 Task/Count-occurrences-of-a-substring/Perl/count-occurrences-of-a-substring.pl create mode 100644 Task/Count-occurrences-of-a-substring/PicoLisp/count-occurrences-of-a-substring.l create mode 100644 Task/Count-occurrences-of-a-substring/Python/count-occurrences-of-a-substring.py create mode 100644 Task/Count-occurrences-of-a-substring/REXX/count-occurrences-of-a-substring.rexx create mode 100644 Task/Count-occurrences-of-a-substring/Ruby/count-occurrences-of-a-substring.rb create mode 100644 Task/Count-occurrences-of-a-substring/Scala/count-occurrences-of-a-substring.scala create mode 100644 Task/Count-occurrences-of-a-substring/Tcl/count-occurrences-of-a-substring.tcl create mode 100644 Task/Count-the-coins/0DESCRIPTION create mode 100644 Task/Count-the-coins/AWK/count-the-coins-1.awk create mode 100644 Task/Count-the-coins/AWK/count-the-coins-2.awk create mode 100644 Task/Count-the-coins/Ada/count-the-coins.ada create mode 100644 Task/Count-the-coins/AutoHotkey/count-the-coins.ahk create mode 100644 Task/Count-the-coins/BBC-BASIC/count-the-coins.bbc create mode 100644 Task/Count-the-coins/C/count-the-coins-1.c create mode 100644 Task/Count-the-coins/C/count-the-coins-2.c create mode 100644 Task/Count-the-coins/Common-Lisp/count-the-coins.lisp create mode 100644 Task/Count-the-coins/D/count-the-coins-1.d create mode 100644 Task/Count-the-coins/D/count-the-coins-2.d create mode 100644 Task/Count-the-coins/D/count-the-coins-3.d create mode 100644 Task/Count-the-coins/Erlang/count-the-coins.erl create mode 100644 Task/Count-the-coins/Forth/count-the-coins.fth create mode 100644 Task/Count-the-coins/Go/count-the-coins-1.go create mode 100644 Task/Count-the-coins/Go/count-the-coins-2.go create mode 100644 Task/Count-the-coins/Haskell/count-the-coins-1.hs create mode 100644 Task/Count-the-coins/Haskell/count-the-coins-2.hs create mode 100644 Task/Count-the-coins/Java/count-the-coins.java create mode 100644 Task/Count-the-coins/JavaScript/count-the-coins-1.js create mode 100644 Task/Count-the-coins/JavaScript/count-the-coins-2.js create mode 100644 Task/Count-the-coins/JavaScript/count-the-coins-3.js create mode 100644 Task/Count-the-coins/JavaScript/count-the-coins-4.js create mode 100644 Task/Count-the-coins/PicoLisp/count-the-coins-1.l create mode 100644 Task/Count-the-coins/PicoLisp/count-the-coins-2.l create mode 100644 Task/Count-the-coins/Python/count-the-coins-1.py create mode 100644 Task/Count-the-coins/Python/count-the-coins-2.py create mode 100644 Task/Count-the-coins/REXX/count-the-coins.rexx create mode 100644 Task/Count-the-coins/Ruby/count-the-coins-1.rb create mode 100644 Task/Count-the-coins/Ruby/count-the-coins-2.rb create mode 100644 Task/Count-the-coins/Scala/count-the-coins.scala create mode 100644 Task/Count-the-coins/Scheme/count-the-coins.ss create mode 100644 Task/Count-the-coins/Tcl/count-the-coins.tcl create mode 100644 Task/Create-a-file-on-magnetic-tape/0DESCRIPTION create mode 100644 Task/Create-a-file-on-magnetic-tape/1META.yaml create mode 100644 Task/Create-a-file-on-magnetic-tape/Tcl/create-a-file-on-magnetic-tape.tcl create mode 100644 Task/Create-a-file/0DESCRIPTION create mode 100644 Task/Create-a-file/1META.yaml create mode 100644 Task/Create-a-file/4DOS-Batch/create-a-file.4dos create mode 100644 Task/Create-a-file/ALGOL-68/create-a-file.alg create mode 100644 Task/Create-a-file/APL/create-a-file.apl create mode 100644 Task/Create-a-file/AWK/create-a-file.awk create mode 100644 Task/Create-a-file/Ada/create-a-file.ada create mode 100644 Task/Create-a-file/Aikido/create-a-file.aikido create mode 100644 Task/Create-a-file/AppleScript/create-a-file-1.applescript create mode 100644 Task/Create-a-file/AppleScript/create-a-file-2.applescript create mode 100644 Task/Create-a-file/AppleScript/create-a-file-3.applescript create mode 100644 Task/Create-a-file/AppleScript/create-a-file-4.applescript create mode 100644 Task/Create-a-file/AutoHotkey/create-a-file.ahk create mode 100644 Task/Create-a-file/BASIC/create-a-file.bas create mode 100644 Task/Create-a-file/BBC-BASIC/create-a-file.bbc create mode 100644 Task/Create-a-file/Batch-File/create-a-file-1.bat create mode 100644 Task/Create-a-file/Batch-File/create-a-file-2.bat create mode 100644 Task/Create-a-file/Bracmat/create-a-file-1.bracmat create mode 100644 Task/Create-a-file/Bracmat/create-a-file-2.bracmat create mode 100644 Task/Create-a-file/Bracmat/create-a-file-3.bracmat create mode 100644 Task/Create-a-file/Bracmat/create-a-file-4.bracmat create mode 100644 Task/Create-a-file/Bracmat/create-a-file-5.bracmat create mode 100644 Task/Create-a-file/C++/create-a-file.cpp create mode 100644 Task/Create-a-file/C/create-a-file-1.c create mode 100644 Task/Create-a-file/C/create-a-file-2.c create mode 100644 Task/Create-a-file/Clojure/create-a-file.clj create mode 100644 Task/Create-a-file/Common-Lisp/create-a-file-1.lisp create mode 100644 Task/Create-a-file/Common-Lisp/create-a-file-2.lisp create mode 100644 Task/Create-a-file/Common-Lisp/create-a-file-3.lisp create mode 100644 Task/Create-a-file/Common-Lisp/create-a-file-4.lisp create mode 100644 Task/Create-a-file/Common-Lisp/create-a-file-5.lisp create mode 100644 Task/Create-a-file/D/create-a-file.d create mode 100644 Task/Create-a-file/DCL/create-a-file.dcl create mode 100644 Task/Create-a-file/Delphi/create-a-file.delphi create mode 100644 Task/Create-a-file/E/create-a-file.e create mode 100644 Task/Create-a-file/Euphoria/create-a-file.euphoria create mode 100644 Task/Create-a-file/Forth/create-a-file.fth create mode 100644 Task/Create-a-file/Fortran/create-a-file.f create mode 100644 Task/Create-a-file/Go/create-a-file.go create mode 100644 Task/Create-a-file/Haskell/create-a-file.hs create mode 100644 Task/Create-a-file/Java/create-a-file.java create mode 100644 Task/Create-a-file/Lua/create-a-file-1.lua create mode 100644 Task/Create-a-file/Lua/create-a-file-2.lua create mode 100644 Task/Create-a-file/Lua/create-a-file-3.lua create mode 100644 Task/Create-a-file/MATLAB/create-a-file.m create mode 100644 Task/Create-a-file/PHP/create-a-file.php create mode 100644 Task/Create-a-file/Perl/create-a-file-1.pl create mode 100644 Task/Create-a-file/Perl/create-a-file-2.pl create mode 100644 Task/Create-a-file/Perl/create-a-file-3.pl create mode 100644 Task/Create-a-file/Perl/create-a-file-4.pl create mode 100644 Task/Create-a-file/Perl/create-a-file-5.pl create mode 100644 Task/Create-a-file/PicoLisp/create-a-file.l create mode 100644 Task/Create-a-file/Python/create-a-file-1.py create mode 100644 Task/Create-a-file/Python/create-a-file-2.py create mode 100644 Task/Create-a-file/R/create-a-file.r create mode 100644 Task/Create-a-file/REXX/create-a-file.rexx create mode 100644 Task/Create-a-file/Racket/create-a-file.rkt create mode 100644 Task/Create-a-file/Ruby/create-a-file.rb create mode 100644 Task/Create-a-file/Scheme/create-a-file.ss create mode 100644 Task/Create-a-file/Smalltalk/create-a-file-1.st create mode 100644 Task/Create-a-file/Smalltalk/create-a-file-2.st create mode 100644 Task/Create-a-file/Tcl/create-a-file.tcl create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/0DESCRIPTION create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/1META.yaml create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/ALGOL-68/create-a-two-dimensional-array-at-runtime.alg create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/APL/create-a-two-dimensional-array-at-runtime.apl create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/AWK/create-a-two-dimensional-array-at-runtime.awk create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Ada/create-a-two-dimensional-array-at-runtime.ada create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/AppleScript/create-a-two-dimensional-array-at-runtime.applescript create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/AutoHotkey/create-a-two-dimensional-array-at-runtime.ahk create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/AutoIt/create-a-two-dimensional-array-at-runtime.autoit create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/BBC-BASIC/create-a-two-dimensional-array-at-runtime.bbc create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-1.cpp create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-2.cpp create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-3.cpp create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/C/create-a-two-dimensional-array-at-runtime-1.c create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/C/create-a-two-dimensional-array-at-runtime-2.c create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/C/create-a-two-dimensional-array-at-runtime-3.c create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/C/create-a-two-dimensional-array-at-runtime-4.c create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Clean/create-a-two-dimensional-array-at-runtime.clean create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Clojure/create-a-two-dimensional-array-at-runtime.clj create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Common-Lisp/create-a-two-dimensional-array-at-runtime.lisp create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Component-Pascal/create-a-two-dimensional-array-at-runtime.pascal create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/D/create-a-two-dimensional-array-at-runtime.d create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Delphi/create-a-two-dimensional-array-at-runtime.delphi create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Euphoria/create-a-two-dimensional-array-at-runtime.euphoria create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Forth/create-a-two-dimensional-array-at-runtime-1.fth create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Forth/create-a-two-dimensional-array-at-runtime-2.fth create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Fortran/create-a-two-dimensional-array-at-runtime.f create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-1.go create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-2.go create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-3.go create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Haskell/create-a-two-dimensional-array-at-runtime.hs create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Java/create-a-two-dimensional-array-at-runtime.java create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/JavaScript/create-a-two-dimensional-array-at-runtime.js create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Lua/create-a-two-dimensional-array-at-runtime.lua create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/MATLAB/create-a-two-dimensional-array-at-runtime-1.m create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/MATLAB/create-a-two-dimensional-array-at-runtime-2.m create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Perl/create-a-two-dimensional-array-at-runtime-1.pl create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Perl/create-a-two-dimensional-array-at-runtime-2.pl create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/PicoLisp/create-a-two-dimensional-array-at-runtime.l create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Python/create-a-two-dimensional-array-at-runtime-1.py create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Python/create-a-two-dimensional-array-at-runtime-2.py create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/R/create-a-two-dimensional-array-at-runtime.r create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/REXX/create-a-two-dimensional-array-at-runtime.rexx create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Ruby/create-a-two-dimensional-array-at-runtime.rb create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Scala/create-a-two-dimensional-array-at-runtime.scala create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-1.st create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-2.st create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-3.st create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-4.st create mode 100644 Task/Create-a-two-dimensional-array-at-runtime/Tcl/create-a-two-dimensional-array-at-runtime.tcl create mode 100644 Task/Create-an-HTML-table/0DESCRIPTION create mode 100644 Task/Create-an-HTML-table/1META.yaml create mode 100644 Task/Create-an-HTML-table/AWK/create-an-html-table.awk create mode 100644 Task/Create-an-HTML-table/Ada/create-an-html-table-1.ada create mode 100644 Task/Create-an-HTML-table/Ada/create-an-html-table-2.ada create mode 100644 Task/Create-an-HTML-table/Ada/create-an-html-table-3.ada create mode 100644 Task/Create-an-HTML-table/Ada/create-an-html-table-4.ada create mode 100644 Task/Create-an-HTML-table/AutoHotkey/create-an-html-table.ahk create mode 100644 Task/Create-an-HTML-table/BBC-BASIC/create-an-html-table.bbc create mode 100644 Task/Create-an-HTML-table/C++/create-an-html-table.cpp create mode 100644 Task/Create-an-HTML-table/C-sharp/create-an-html-table.cs create mode 100644 Task/Create-an-HTML-table/C/create-an-html-table.c create mode 100644 Task/Create-an-HTML-table/CoffeeScript/create-an-html-table.coffee create mode 100644 Task/Create-an-HTML-table/D/create-an-html-table.d create mode 100644 Task/Create-an-HTML-table/Delphi/create-an-html-table-1.delphi create mode 100644 Task/Create-an-HTML-table/Delphi/create-an-html-table-2.delphi create mode 100644 Task/Create-an-HTML-table/Euphoria/create-an-html-table-1.euphoria create mode 100644 Task/Create-an-HTML-table/Euphoria/create-an-html-table-2.euphoria create mode 100644 Task/Create-an-HTML-table/Go/create-an-html-table-1.go create mode 100644 Task/Create-an-HTML-table/Go/create-an-html-table-2.go create mode 100644 Task/Create-an-HTML-table/Haskell/create-an-html-table.hs create mode 100644 Task/Create-an-HTML-table/Java/create-an-html-table-1.java create mode 100644 Task/Create-an-HTML-table/Java/create-an-html-table-2.java create mode 100644 Task/Create-an-HTML-table/JavaScript/create-an-html-table.js create mode 100644 Task/Create-an-HTML-table/MATLAB/create-an-html-table.m create mode 100644 Task/Create-an-HTML-table/PHP/create-an-html-table-1.php create mode 100644 Task/Create-an-HTML-table/PHP/create-an-html-table-2.php create mode 100644 Task/Create-an-HTML-table/Perl/create-an-html-table.pl create mode 100644 Task/Create-an-HTML-table/PicoLisp/create-an-html-table.l create mode 100644 Task/Create-an-HTML-table/Python/create-an-html-table-1.py create mode 100644 Task/Create-an-HTML-table/Python/create-an-html-table-2.py create mode 100644 Task/Create-an-HTML-table/REXX/create-an-html-table.rexx create mode 100644 Task/Create-an-HTML-table/Racket/create-an-html-table.rkt create mode 100644 Task/Create-an-HTML-table/Ruby/create-an-html-table-1.rb create mode 100644 Task/Create-an-HTML-table/Ruby/create-an-html-table-2.rb create mode 100644 Task/Create-an-HTML-table/Ruby/create-an-html-table-3.rb create mode 100644 Task/Create-an-HTML-table/Scheme/create-an-html-table.ss create mode 100644 Task/Create-an-HTML-table/Tcl/create-an-html-table.tcl create mode 100644 Task/Create-an-object-at-a-given-address/0DESCRIPTION create mode 100644 Task/Create-an-object-at-a-given-address/1META.yaml create mode 100644 Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-1.6502 create mode 100644 Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-2.6502 create mode 100644 Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-3.6502 create mode 100644 Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-4.6502 create mode 100644 Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-1.ada create mode 100644 Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-2.ada create mode 100644 Task/Create-an-object-at-a-given-address/Aikido/create-an-object-at-a-given-address.aikido create mode 100644 Task/Create-an-object-at-a-given-address/AutoHotkey/create-an-object-at-a-given-address.ahk create mode 100644 Task/Create-an-object-at-a-given-address/BBC-BASIC/create-an-object-at-a-given-address.bbc create mode 100644 Task/Create-an-object-at-a-given-address/C++/create-an-object-at-a-given-address.cpp create mode 100644 Task/Create-an-object-at-a-given-address/C/create-an-object-at-a-given-address-1.c create mode 100644 Task/Create-an-object-at-a-given-address/C/create-an-object-at-a-given-address-2.c create mode 100644 Task/Create-an-object-at-a-given-address/COBOL/create-an-object-at-a-given-address.cobol create mode 100644 Task/Create-an-object-at-a-given-address/D/create-an-object-at-a-given-address.d create mode 100644 Task/Create-an-object-at-a-given-address/Forth/create-an-object-at-a-given-address.fth create mode 100644 Task/Create-an-object-at-a-given-address/Go/create-an-object-at-a-given-address.go create mode 100644 Task/Create-an-object-at-a-given-address/PicoLisp/create-an-object-at-a-given-address.l create mode 100644 Task/Create-an-object-at-a-given-address/Tcl/create-an-object-at-a-given-address-1.tcl create mode 100644 Task/Create-an-object-at-a-given-address/Tcl/create-an-object-at-a-given-address-2.tcl create mode 100644 Task/Cut-a-rectangle/0DESCRIPTION create mode 100644 Task/Cut-a-rectangle/C/cut-a-rectangle-1.c create mode 100644 Task/Cut-a-rectangle/C/cut-a-rectangle-2.c create mode 100644 Task/Cut-a-rectangle/C/cut-a-rectangle-3.c create mode 100644 Task/Cut-a-rectangle/Common-Lisp/cut-a-rectangle-1.lisp create mode 100644 Task/Cut-a-rectangle/Common-Lisp/cut-a-rectangle-2.lisp create mode 100644 Task/Cut-a-rectangle/D/cut-a-rectangle.d create mode 100644 Task/Cut-a-rectangle/Haskell/cut-a-rectangle.hs create mode 100644 Task/Cut-a-rectangle/Python/cut-a-rectangle-1.py create mode 100644 Task/Cut-a-rectangle/Python/cut-a-rectangle-2.py create mode 100644 Task/Cut-a-rectangle/REXX/cut-a-rectangle.rexx create mode 100644 Task/Cut-a-rectangle/Tcl/cut-a-rectangle.tcl create mode 100644 Task/DNS-query/0DESCRIPTION create mode 100644 Task/DNS-query/1META.yaml create mode 100644 Task/DNS-query/Ada/dns-query.ada create mode 100644 Task/DNS-query/BBC-BASIC/dns-query-1.bbc create mode 100644 Task/DNS-query/BBC-BASIC/dns-query-2.bbc create mode 100644 Task/DNS-query/C-sharp/dns-query.cs create mode 100644 Task/DNS-query/Cache-ObjectScript/dns-query.cos create mode 100644 Task/DNS-query/Clojure/dns-query.clj create mode 100644 Task/DNS-query/CoffeeScript/dns-query.coffee create mode 100644 Task/DNS-query/Common-Lisp/dns-query-1.lisp create mode 100644 Task/DNS-query/Common-Lisp/dns-query-2.lisp create mode 100644 Task/DNS-query/Common-Lisp/dns-query-3.lisp create mode 100644 Task/DNS-query/D/dns-query.d create mode 100644 Task/DNS-query/Delphi/dns-query.delphi create mode 100644 Task/DNS-query/Go/dns-query-1.go create mode 100644 Task/DNS-query/Go/dns-query-2.go create mode 100644 Task/DNS-query/Go/dns-query-3.go create mode 100644 Task/DNS-query/Go/dns-query-4.go create mode 100644 Task/DNS-query/PHP/dns-query.php create mode 100644 Task/DNS-query/Perl/dns-query.pl create mode 100644 Task/DNS-query/PicoLisp/dns-query-1.l create mode 100644 Task/DNS-query/PicoLisp/dns-query-2.l create mode 100644 Task/DNS-query/PicoLisp/dns-query-3.l create mode 100644 Task/DNS-query/Racket/dns-query.rkt create mode 100644 Task/DNS-query/Scheme/dns-query.ss create mode 100644 Task/DNS-query/Tcl/dns-query.tcl create mode 100644 Task/Date-format/0DESCRIPTION create mode 100644 Task/Date-format/1META.yaml create mode 100644 Task/Date-format/ABAP/date-format.abap create mode 100644 Task/Date-format/ALGOL-68/date-format.alg create mode 100644 Task/Date-format/AWK/date-format.awk create mode 100644 Task/Date-format/Ada/date-format.ada create mode 100644 Task/Date-format/AutoHotkey/date-format.ahk create mode 100644 Task/Date-format/BASIC/date-format.bas create mode 100644 Task/Date-format/BBC-BASIC/date-format.bbc create mode 100644 Task/Date-format/C++/date-format.cpp create mode 100644 Task/Date-format/C/date-format.c create mode 100644 Task/Date-format/Clojure/date-format.clj create mode 100644 Task/Date-format/CoffeeScript/date-format-1.coffee create mode 100644 Task/Date-format/CoffeeScript/date-format-2.coffee create mode 100644 Task/Date-format/ColdFusion/date-format.cfm create mode 100644 Task/Date-format/Common-Lisp/date-format.lisp create mode 100644 Task/Date-format/D/date-format.d create mode 100644 Task/Date-format/Delphi/date-format.delphi create mode 100644 Task/Date-format/EGL/date-format.egl create mode 100644 Task/Date-format/Erlang/date-format.erl create mode 100644 Task/Date-format/Euphoria/date-format.euphoria create mode 100644 Task/Date-format/Forth/date-format.fth create mode 100644 Task/Date-format/Fortran/date-format.f create mode 100644 Task/Date-format/Go/date-format.go create mode 100644 Task/Date-format/Haskell/date-format.hs create mode 100644 Task/Date-format/Java/date-format.java create mode 100644 Task/Date-format/JavaScript/date-format.js create mode 100644 Task/Date-format/Lua/date-format.lua create mode 100644 Task/Date-format/MATLAB/date-format.m create mode 100644 Task/Date-format/PHP/date-format.php create mode 100644 Task/Date-format/Perl/date-format-1.pl create mode 100644 Task/Date-format/Perl/date-format-2.pl create mode 100644 Task/Date-format/PicoLisp/date-format.l create mode 100644 Task/Date-format/Python/date-format.py create mode 100644 Task/Date-format/R/date-format.r create mode 100644 Task/Date-format/REXX/date-format.rexx create mode 100644 Task/Date-format/Racket/date-format.rkt create mode 100644 Task/Date-format/Ruby/date-format.rb create mode 100644 Task/Date-format/Scala/date-format.scala create mode 100644 Task/Date-format/Tcl/date-format.tcl create mode 100644 Task/Date-manipulation/0DESCRIPTION create mode 100644 Task/Date-manipulation/1META.yaml create mode 100644 Task/Date-manipulation/Ada/date-manipulation.ada create mode 100644 Task/Date-manipulation/AppleScript/date-manipulation-1.applescript create mode 100644 Task/Date-manipulation/AppleScript/date-manipulation-2.applescript create mode 100644 Task/Date-manipulation/AutoHotkey/date-manipulation.ahk create mode 100644 Task/Date-manipulation/BBC-BASIC/date-manipulation.bbc create mode 100644 Task/Date-manipulation/C++/date-manipulation.cpp create mode 100644 Task/Date-manipulation/C/date-manipulation.c create mode 100644 Task/Date-manipulation/Clojure/date-manipulation.clj create mode 100644 Task/Date-manipulation/Delphi/date-manipulation.delphi create mode 100644 Task/Date-manipulation/Euphoria/date-manipulation.euphoria create mode 100644 Task/Date-manipulation/Go/date-manipulation.go create mode 100644 Task/Date-manipulation/Haskell/date-manipulation.hs create mode 100644 Task/Date-manipulation/Java/date-manipulation.java create mode 100644 Task/Date-manipulation/JavaScript/date-manipulation.js create mode 100644 Task/Date-manipulation/Lua/date-manipulation.lua create mode 100644 Task/Date-manipulation/PHP/date-manipulation.php create mode 100644 Task/Date-manipulation/Perl/date-manipulation.pl create mode 100644 Task/Date-manipulation/PicoLisp/date-manipulation.l create mode 100644 Task/Date-manipulation/Python/date-manipulation.py create mode 100644 Task/Date-manipulation/R/date-manipulation.r create mode 100644 Task/Date-manipulation/REXX/date-manipulation.rexx create mode 100644 Task/Date-manipulation/Ruby/date-manipulation-1.rb create mode 100644 Task/Date-manipulation/Ruby/date-manipulation-2.rb create mode 100644 Task/Date-manipulation/Scala/date-manipulation.scala create mode 100644 Task/Date-manipulation/Smalltalk/date-manipulation-1.st create mode 100644 Task/Date-manipulation/Smalltalk/date-manipulation-2.st create mode 100644 Task/Date-manipulation/Tcl/date-manipulation.tcl create mode 100644 Task/Day-of-the-week/0DESCRIPTION create mode 100644 Task/Day-of-the-week/ABAP/day-of-the-week.abap create mode 100644 Task/Day-of-the-week/ALGOL-68/day-of-the-week.alg create mode 100644 Task/Day-of-the-week/AWK/day-of-the-week.awk create mode 100644 Task/Day-of-the-week/Ada/day-of-the-week.ada create mode 100644 Task/Day-of-the-week/AppleScript/day-of-the-week.applescript create mode 100644 Task/Day-of-the-week/AutoHotkey/day-of-the-week.ahk create mode 100644 Task/Day-of-the-week/AutoIt/day-of-the-week.autoit create mode 100644 Task/Day-of-the-week/BBC-BASIC/day-of-the-week.bbc create mode 100644 Task/Day-of-the-week/C++/day-of-the-week.cpp create mode 100644 Task/Day-of-the-week/C/day-of-the-week.c create mode 100644 Task/Day-of-the-week/Clojure/day-of-the-week.clj create mode 100644 Task/Day-of-the-week/CoffeeScript/day-of-the-week-1.coffee create mode 100644 Task/Day-of-the-week/CoffeeScript/day-of-the-week-2.coffee create mode 100644 Task/Day-of-the-week/CoffeeScript/day-of-the-week-3.coffee create mode 100644 Task/Day-of-the-week/ColdFusion/day-of-the-week.cfm create mode 100644 Task/Day-of-the-week/Common-Lisp/day-of-the-week.lisp create mode 100644 Task/Day-of-the-week/D/day-of-the-week.d create mode 100644 Task/Day-of-the-week/Delphi/day-of-the-week.delphi create mode 100644 Task/Day-of-the-week/Euphoria/day-of-the-week.euphoria create mode 100644 Task/Day-of-the-week/Forth/day-of-the-week-1.fth create mode 100644 Task/Day-of-the-week/Forth/day-of-the-week-2.fth create mode 100644 Task/Day-of-the-week/Forth/day-of-the-week-3.fth create mode 100644 Task/Day-of-the-week/Forth/day-of-the-week-4.fth create mode 100644 Task/Day-of-the-week/Fortran/day-of-the-week.f create mode 100644 Task/Day-of-the-week/Go/day-of-the-week.go create mode 100644 Task/Day-of-the-week/Haskell/day-of-the-week-1.hs create mode 100644 Task/Day-of-the-week/Haskell/day-of-the-week-2.hs create mode 100644 Task/Day-of-the-week/Java/day-of-the-week.java create mode 100644 Task/Day-of-the-week/JavaScript/day-of-the-week.js create mode 100644 Task/Day-of-the-week/Lua/day-of-the-week.lua create mode 100644 Task/Day-of-the-week/MATLAB/day-of-the-week.m create mode 100644 Task/Day-of-the-week/PHP/day-of-the-week.php create mode 100644 Task/Day-of-the-week/Perl/day-of-the-week-1.pl create mode 100644 Task/Day-of-the-week/Perl/day-of-the-week-2.pl create mode 100644 Task/Day-of-the-week/Perl/day-of-the-week-3.pl create mode 100644 Task/Day-of-the-week/Perl/day-of-the-week-4.pl create mode 100644 Task/Day-of-the-week/PicoLisp/day-of-the-week.l create mode 100644 Task/Day-of-the-week/Python/day-of-the-week.py create mode 100644 Task/Day-of-the-week/R/day-of-the-week-1.r create mode 100644 Task/Day-of-the-week/R/day-of-the-week-2.r create mode 100644 Task/Day-of-the-week/R/day-of-the-week-3.r create mode 100644 Task/Day-of-the-week/REXX/day-of-the-week-1.rexx create mode 100644 Task/Day-of-the-week/REXX/day-of-the-week-2.rexx create mode 100644 Task/Day-of-the-week/REXX/day-of-the-week-3.rexx create mode 100644 Task/Day-of-the-week/REXX/day-of-the-week-4.rexx create mode 100644 Task/Day-of-the-week/Ruby/day-of-the-week-1.rb create mode 100644 Task/Day-of-the-week/Ruby/day-of-the-week-2.rb create mode 100644 Task/Day-of-the-week/Scala/day-of-the-week.scala create mode 100644 Task/Day-of-the-week/Scheme/day-of-the-week.ss create mode 100644 Task/Day-of-the-week/Smalltalk/day-of-the-week.st create mode 100644 Task/Day-of-the-week/Tcl/day-of-the-week.tcl create mode 100644 Task/Deal-cards-for-FreeCell/0DESCRIPTION create mode 100644 Task/Deal-cards-for-FreeCell/1META.yaml create mode 100644 Task/Deal-cards-for-FreeCell/Ada/deal-cards-for-freecell.ada create mode 100644 Task/Deal-cards-for-FreeCell/BBC-BASIC/deal-cards-for-freecell.bbc create mode 100644 Task/Deal-cards-for-FreeCell/Bracmat/deal-cards-for-freecell.bracmat create mode 100644 Task/Deal-cards-for-FreeCell/C/deal-cards-for-freecell.c create mode 100644 Task/Deal-cards-for-FreeCell/Common-Lisp/deal-cards-for-freecell.lisp create mode 100644 Task/Deal-cards-for-FreeCell/D/deal-cards-for-freecell.d create mode 100644 Task/Deal-cards-for-FreeCell/Go/deal-cards-for-freecell.go create mode 100644 Task/Deal-cards-for-FreeCell/Haskell/deal-cards-for-freecell.hs create mode 100644 Task/Deal-cards-for-FreeCell/JavaScript/deal-cards-for-freecell.js create mode 100644 Task/Deal-cards-for-FreeCell/Perl/deal-cards-for-freecell.pl create mode 100644 Task/Deal-cards-for-FreeCell/PicoLisp/deal-cards-for-freecell.l create mode 100644 Task/Deal-cards-for-FreeCell/Python/deal-cards-for-freecell.py create mode 100644 Task/Deal-cards-for-FreeCell/Ruby/deal-cards-for-freecell.rb create mode 100644 Task/Deal-cards-for-FreeCell/Tcl/deal-cards-for-freecell.tcl create mode 100644 Task/Death-Star/D/death-star.d create mode 100644 Task/Death-Star/DWScript/death-star.dwscript create mode 100644 Task/Deconvolution-1D/0DESCRIPTION create mode 100644 Task/Deconvolution-1D/1META.yaml create mode 100644 Task/Deconvolution-1D/BBC-BASIC/deconvolution-1d.bbc create mode 100644 Task/Deconvolution-1D/C/deconvolution-1d-1.c create mode 100644 Task/Deconvolution-1D/C/deconvolution-1d-2.c create mode 100644 Task/Deconvolution-1D/Common-Lisp/deconvolution-1d-1.lisp create mode 100644 Task/Deconvolution-1D/Common-Lisp/deconvolution-1d-2.lisp create mode 100644 Task/Deconvolution-1D/D/deconvolution-1d.d create mode 100644 Task/Deconvolution-1D/Fortran/deconvolution-1d-1.f create mode 100644 Task/Deconvolution-1D/Fortran/deconvolution-1d-2.f create mode 100644 Task/Deconvolution-1D/Go/deconvolution-1d-1.go create mode 100644 Task/Deconvolution-1D/Go/deconvolution-1d-2.go create mode 100644 Task/Deconvolution-1D/Haskell/deconvolution-1d-1.hs create mode 100644 Task/Deconvolution-1D/Haskell/deconvolution-1d-2.hs create mode 100644 Task/Deconvolution-1D/Java/deconvolution-1d.java create mode 100644 Task/Deconvolution-1D/Lua/deconvolution-1d-1.lua create mode 100644 Task/Deconvolution-1D/Lua/deconvolution-1d-2.lua create mode 100644 Task/Deconvolution-1D/MATLAB/deconvolution-1d.m create mode 100644 Task/Deconvolution-1D/PicoLisp/deconvolution-1d-1.l create mode 100644 Task/Deconvolution-1D/PicoLisp/deconvolution-1d-2.l create mode 100644 Task/Deconvolution-1D/Python/deconvolution-1d.py create mode 100644 Task/Deconvolution-1D/R/deconvolution-1d-1.r create mode 100644 Task/Deconvolution-1D/R/deconvolution-1d-2.r create mode 100644 Task/Deconvolution-1D/R/deconvolution-1d-3.r create mode 100644 Task/Deconvolution-1D/Tcl/deconvolution-1d-1.tcl create mode 100644 Task/Deconvolution-1D/Tcl/deconvolution-1d-2.tcl create mode 100644 Task/Deconvolution-2D+/0DESCRIPTION create mode 100644 Task/Deconvolution-2D+/1META.yaml create mode 100644 Task/Deconvolution-2D+/C/deconvolution-2d+-1.c create mode 100644 Task/Deconvolution-2D+/C/deconvolution-2d+-2.c create mode 100644 Task/Deconvolution-2D+/D/deconvolution-2d+.d create mode 100644 Task/Deconvolution-2D+/Tcl/deconvolution-2d+-1.tcl create mode 100644 Task/Deconvolution-2D+/Tcl/deconvolution-2d+-2.tcl create mode 100644 Task/Deepcopy/0DESCRIPTION create mode 100644 Task/Deepcopy/C-sharp/deepcopy.cs create mode 100644 Task/Deepcopy/Common-Lisp/deepcopy.lisp create mode 100644 Task/Deepcopy/E/deepcopy-1.e create mode 100644 Task/Deepcopy/E/deepcopy-2.e create mode 100644 Task/Deepcopy/Go/deepcopy-1.go create mode 100644 Task/Deepcopy/Go/deepcopy-2.go create mode 100644 Task/Deepcopy/JavaScript/deepcopy-1.js create mode 100644 Task/Deepcopy/JavaScript/deepcopy-2.js create mode 100644 Task/Deepcopy/PHP/deepcopy-1.php create mode 100644 Task/Deepcopy/PHP/deepcopy-2.php create mode 100644 Task/Deepcopy/Perl/deepcopy.pl create mode 100644 Task/Deepcopy/PicoLisp/deepcopy-1.l create mode 100644 Task/Deepcopy/PicoLisp/deepcopy-2.l create mode 100644 Task/Deepcopy/PicoLisp/deepcopy-3.l create mode 100644 Task/Deepcopy/PicoLisp/deepcopy-4.l create mode 100644 Task/Deepcopy/PicoLisp/deepcopy-5.l create mode 100644 Task/Deepcopy/Python/deepcopy.py create mode 100644 Task/Deepcopy/Ruby/deepcopy.rb create mode 100644 Task/Deepcopy/Tcl/deepcopy-1.tcl create mode 100644 Task/Deepcopy/Tcl/deepcopy-2.tcl create mode 100644 Task/Define-a-primitive-data-type/C++/define-a-primitive-data-type.cpp create mode 100644 Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-1.lisp create mode 100644 Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-2.lisp create mode 100644 Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-3.lisp create mode 100644 Task/Define-a-primitive-data-type/D/define-a-primitive-data-type.d create mode 100644 Task/Define-a-primitive-data-type/E/define-a-primitive-data-type.e create mode 100644 Task/Define-a-primitive-data-type/Euphoria/define-a-primitive-data-type.euphoria create mode 100644 Task/Delegates/C++/delegates.cpp create mode 100644 Task/Delegates/C-sharp/delegates.cs create mode 100644 Task/Delegates/Common-Lisp/delegates.lisp create mode 100644 Task/Delegates/D/delegates-1.d create mode 100644 Task/Delegates/D/delegates-2.d create mode 100644 Task/Delegates/Dart/delegates.dart create mode 100644 Task/Delegates/Delphi/delegates-1.delphi create mode 100644 Task/Delegates/Delphi/delegates-2.delphi create mode 100644 Task/Delegates/E/delegates.e create mode 100644 Task/Delete-a-file/C++/delete-a-file.cpp create mode 100644 Task/Delete-a-file/Common-Lisp/delete-a-file-1.lisp create mode 100644 Task/Delete-a-file/Common-Lisp/delete-a-file-2.lisp create mode 100644 Task/Delete-a-file/Common-Lisp/delete-a-file-3.lisp create mode 100644 Task/Delete-a-file/D/delete-a-file-1.d create mode 100644 Task/Delete-a-file/D/delete-a-file-2.d create mode 100644 Task/Delete-a-file/D/delete-a-file-3.d create mode 100644 Task/Delete-a-file/Delphi/delete-a-file.delphi create mode 100644 Task/Delete-a-file/E/delete-a-file.e create mode 100644 Task/Detect-division-by-zero/Common-Lisp/detect-division-by-zero.lisp create mode 100644 Task/Detect-division-by-zero/D/detect-division-by-zero.d create mode 100644 Task/Detect-division-by-zero/Delphi/detect-division-by-zero.delphi create mode 100644 Task/Detect-division-by-zero/E/detect-division-by-zero.e create mode 100644 Task/Detect-division-by-zero/Ela/detect-division-by-zero-1.ela create mode 100644 Task/Detect-division-by-zero/Ela/detect-division-by-zero-2.ela create mode 100644 Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-1.cpp create mode 100644 Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-2.cpp create mode 100644 Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-3.cpp create mode 100644 Task/Determine-if-a-string-is-numeric/ColdFusion/determine-if-a-string-is-numeric.cfm create mode 100644 Task/Determine-if-a-string-is-numeric/Common-Lisp/determine-if-a-string-is-numeric-1.lisp create mode 100644 Task/Determine-if-a-string-is-numeric/Common-Lisp/determine-if-a-string-is-numeric-2.lisp create mode 100644 Task/Determine-if-a-string-is-numeric/D/determine-if-a-string-is-numeric-1.d create mode 100644 Task/Determine-if-a-string-is-numeric/D/determine-if-a-string-is-numeric-2.d create mode 100644 Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-1.delphi create mode 100644 Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-2.delphi create mode 100644 Task/Determine-if-a-string-is-numeric/E/determine-if-a-string-is-numeric.e create mode 100644 Task/Determine-if-a-string-is-numeric/Euphoria/determine-if-a-string-is-numeric.euphoria create mode 100644 Task/Determine-if-only-one-instance-is-running/0DESCRIPTION create mode 100644 Task/Determine-if-only-one-instance-is-running/1META.yaml create mode 100644 Task/Determine-if-only-one-instance-is-running/Ada/determine-if-only-one-instance-is-running.ada create mode 100644 Task/Determine-if-only-one-instance-is-running/BBC-BASIC/determine-if-only-one-instance-is-running.bbc create mode 100644 Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-1.cpp create mode 100644 Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-2.cpp create mode 100644 Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-3.cpp create mode 100644 Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-4.cpp create mode 100644 Task/Determine-if-only-one-instance-is-running/C/determine-if-only-one-instance-is-running-1.c create mode 100644 Task/Determine-if-only-one-instance-is-running/C/determine-if-only-one-instance-is-running-2.c create mode 100644 Task/Determine-if-only-one-instance-is-running/Clojure/determine-if-only-one-instance-is-running.clj create mode 100644 Task/Determine-if-only-one-instance-is-running/Delphi/determine-if-only-one-instance-is-running.delphi create mode 100644 Task/Determine-if-only-one-instance-is-running/Go/determine-if-only-one-instance-is-running.go create mode 100644 Task/Determine-if-only-one-instance-is-running/Haskell/determine-if-only-one-instance-is-running.hs create mode 100644 Task/Determine-if-only-one-instance-is-running/Java/determine-if-only-one-instance-is-running.java create mode 100644 Task/Determine-if-only-one-instance-is-running/Perl/determine-if-only-one-instance-is-running.pl create mode 100644 Task/Determine-if-only-one-instance-is-running/PicoLisp/determine-if-only-one-instance-is-running-1.l create mode 100644 Task/Determine-if-only-one-instance-is-running/PicoLisp/determine-if-only-one-instance-is-running-2.l create mode 100644 Task/Determine-if-only-one-instance-is-running/Python/determine-if-only-one-instance-is-running.py create mode 100644 Task/Determine-if-only-one-instance-is-running/Ruby/determine-if-only-one-instance-is-running.rb create mode 100644 Task/Determine-if-only-one-instance-is-running/Tcl/determine-if-only-one-instance-is-running.tcl create mode 100644 Task/Digital-root/0DESCRIPTION create mode 100644 Task/Digital-root/Ada/digital-root.ada create mode 100644 Task/Digital-root/BASIC/digital-root.bas create mode 100644 Task/Digital-root/BBC-BASIC/digital-root.bbc create mode 100644 Task/Digital-root/C++/digital-root.cpp create mode 100644 Task/Digital-root/C/digital-root.c create mode 100644 Task/Digital-root/D/digital-root.d create mode 100644 Task/Digital-root/Dc/digital-root.dc create mode 100644 Task/Digital-root/Go/digital-root.go create mode 100644 Task/Digital-root/Haskell/digital-root-1.hs create mode 100644 Task/Digital-root/Haskell/digital-root-2.hs create mode 100644 Task/Digital-root/Java/digital-root.java create mode 100644 Task/Digital-root/PicoLisp/digital-root.l create mode 100644 Task/Digital-root/Python/digital-root.py create mode 100644 Task/Digital-root/REXX/digital-root-1.rexx create mode 100644 Task/Digital-root/REXX/digital-root-2.rexx create mode 100644 Task/Digital-root/REXX/digital-root-3.rexx create mode 100644 Task/Digital-root/Racket/digital-root.rkt create mode 100644 Task/Digital-root/Scala/digital-root.scala create mode 100644 Task/Digital-root/Tcl/digital-root.tcl create mode 100644 Task/Dinesmans-multiple-dwelling-problem/0DESCRIPTION create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Ada/dinesmans-multiple-dwelling-problem.ada create mode 100644 Task/Dinesmans-multiple-dwelling-problem/BBC-BASIC/dinesmans-multiple-dwelling-problem.bbc create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Bracmat/dinesmans-multiple-dwelling-problem.bracmat create mode 100644 Task/Dinesmans-multiple-dwelling-problem/C/dinesmans-multiple-dwelling-problem-1.c create mode 100644 Task/Dinesmans-multiple-dwelling-problem/C/dinesmans-multiple-dwelling-problem-2.c create mode 100644 Task/Dinesmans-multiple-dwelling-problem/D/dinesmans-multiple-dwelling-problem-1.d create mode 100644 Task/Dinesmans-multiple-dwelling-problem/D/dinesmans-multiple-dwelling-problem-2.d create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Forth/dinesmans-multiple-dwelling-problem.fth create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Haskell/dinesmans-multiple-dwelling-problem-1.hs create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Haskell/dinesmans-multiple-dwelling-problem-2.hs create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Java/dinesmans-multiple-dwelling-problem.java create mode 100644 Task/Dinesmans-multiple-dwelling-problem/PicoLisp/dinesmans-multiple-dwelling-problem.l create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-1.pro create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-2.pro create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-3.pro create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-1.py create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-2.py create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-3.py create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-4.py create mode 100644 Task/Dinesmans-multiple-dwelling-problem/REXX/dinesmans-multiple-dwelling-problem.rexx create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Ruby/dinesmans-multiple-dwelling-problem.rb create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Scala/dinesmans-multiple-dwelling-problem-1.scala create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Scala/dinesmans-multiple-dwelling-problem-2.scala create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Tcl/dinesmans-multiple-dwelling-problem-1.tcl create mode 100644 Task/Dinesmans-multiple-dwelling-problem/Tcl/dinesmans-multiple-dwelling-problem-2.tcl create mode 100644 Task/Dining-philosophers/0DESCRIPTION create mode 100644 Task/Dining-philosophers/1META.yaml create mode 100644 Task/Dining-philosophers/Ada/dining-philosophers-1.ada create mode 100644 Task/Dining-philosophers/Ada/dining-philosophers-2.ada create mode 100644 Task/Dining-philosophers/Ada/dining-philosophers-3.ada create mode 100644 Task/Dining-philosophers/BBC-BASIC/dining-philosophers.bbc create mode 100644 Task/Dining-philosophers/C++/dining-philosophers.cpp create mode 100644 Task/Dining-philosophers/C/dining-philosophers-1.c create mode 100644 Task/Dining-philosophers/C/dining-philosophers-2.c create mode 100644 Task/Dining-philosophers/Clojure/dining-philosophers-1.clj create mode 100644 Task/Dining-philosophers/Clojure/dining-philosophers-2.clj create mode 100644 Task/Dining-philosophers/Common-Lisp/dining-philosophers.lisp create mode 100644 Task/Dining-philosophers/D/dining-philosophers.d create mode 100644 Task/Dining-philosophers/Eiffel/dining-philosophers-1.e create mode 100644 Task/Dining-philosophers/Eiffel/dining-philosophers-2.e create mode 100644 Task/Dining-philosophers/Eiffel/dining-philosophers-3.e create mode 100644 Task/Dining-philosophers/Erlang/dining-philosophers.erl create mode 100644 Task/Dining-philosophers/Euphoria/dining-philosophers.euphoria create mode 100644 Task/Dining-philosophers/Go/dining-philosophers.go create mode 100644 Task/Dining-philosophers/Haskell/dining-philosophers.hs create mode 100644 Task/Dining-philosophers/Java/dining-philosophers.java create mode 100644 Task/Dining-philosophers/PicoLisp/dining-philosophers.l create mode 100644 Task/Dining-philosophers/Prolog/dining-philosophers.pro create mode 100644 Task/Dining-philosophers/Python/dining-philosophers.py create mode 100644 Task/Dining-philosophers/Ruby/dining-philosophers.rb create mode 100644 Task/Dining-philosophers/Smalltalk/dining-philosophers.st create mode 100644 Task/Dining-philosophers/Tcl/dining-philosophers.tcl create mode 100644 Task/Discordian-date/0DESCRIPTION create mode 100644 Task/Discordian-date/AWK/discordian-date.awk create mode 100644 Task/Discordian-date/Ada/discordian-date.ada create mode 100644 Task/Discordian-date/BASIC/discordian-date.bas create mode 100644 Task/Discordian-date/BBC-BASIC/discordian-date.bbc create mode 100644 Task/Discordian-date/C/discordian-date.c create mode 100644 Task/Discordian-date/D/discordian-date.d create mode 100644 Task/Discordian-date/Euphoria/discordian-date.euphoria create mode 100644 Task/Discordian-date/Go/discordian-date-1.go create mode 100644 Task/Discordian-date/Go/discordian-date-2.go create mode 100644 Task/Discordian-date/Haskell/discordian-date.hs create mode 100644 Task/Discordian-date/JavaScript/discordian-date-1.js create mode 100644 Task/Discordian-date/JavaScript/discordian-date-2.js create mode 100644 Task/Discordian-date/PHP/discordian-date.php create mode 100644 Task/Discordian-date/PicoLisp/discordian-date.l create mode 100644 Task/Discordian-date/Python/discordian-date.py create mode 100644 Task/Discordian-date/REXX/discordian-date.rexx create mode 100644 Task/Discordian-date/Ruby/discordian-date-1.rb create mode 100644 Task/Discordian-date/Ruby/discordian-date-2.rb create mode 100644 Task/Discordian-date/Scala/discordian-date.scala create mode 100644 Task/Discordian-date/Tcl/discordian-date-1.tcl create mode 100644 Task/Discordian-date/Tcl/discordian-date-2.tcl create mode 100644 Task/Distributed-programming/0DESCRIPTION create mode 100644 Task/Distributed-programming/1META.yaml create mode 100644 Task/Distributed-programming/Ada/distributed-programming-1.ada create mode 100644 Task/Distributed-programming/Ada/distributed-programming-2.ada create mode 100644 Task/Distributed-programming/Ada/distributed-programming-3.ada create mode 100644 Task/Distributed-programming/Ada/distributed-programming-4.ada create mode 100644 Task/Distributed-programming/C/distributed-programming-1.c create mode 100644 Task/Distributed-programming/C/distributed-programming-2.c create mode 100644 Task/Distributed-programming/D/distributed-programming-1.d create mode 100644 Task/Distributed-programming/D/distributed-programming-2.d create mode 100644 Task/Distributed-programming/E/distributed-programming-1.e create mode 100644 Task/Distributed-programming/E/distributed-programming-2.e create mode 100644 Task/Distributed-programming/Erlang/distributed-programming-1.erl create mode 100644 Task/Distributed-programming/Erlang/distributed-programming-2.erl create mode 100644 Task/Distributed-programming/Go/distributed-programming-1.go create mode 100644 Task/Distributed-programming/Go/distributed-programming-2.go create mode 100644 Task/Distributed-programming/JavaScript/distributed-programming-1.js create mode 100644 Task/Distributed-programming/JavaScript/distributed-programming-2.js create mode 100644 Task/Distributed-programming/Perl/distributed-programming.pl create mode 100644 Task/Distributed-programming/PicoLisp/distributed-programming-1.l create mode 100644 Task/Distributed-programming/PicoLisp/distributed-programming-2.l create mode 100644 Task/Distributed-programming/Python/distributed-programming-1.py create mode 100644 Task/Distributed-programming/Python/distributed-programming-10.py create mode 100644 Task/Distributed-programming/Python/distributed-programming-2.py create mode 100644 Task/Distributed-programming/Python/distributed-programming-3.py create mode 100644 Task/Distributed-programming/Python/distributed-programming-4.py create mode 100644 Task/Distributed-programming/Python/distributed-programming-5.py create mode 100644 Task/Distributed-programming/Python/distributed-programming-6.py create mode 100644 Task/Distributed-programming/Python/distributed-programming-7.py create mode 100644 Task/Distributed-programming/Python/distributed-programming-8.py create mode 100644 Task/Distributed-programming/Python/distributed-programming-9.py create mode 100644 Task/Distributed-programming/Ruby/distributed-programming-1.rb create mode 100644 Task/Distributed-programming/Ruby/distributed-programming-2.rb create mode 100644 Task/Distributed-programming/Tcl/distributed-programming-1.tcl create mode 100644 Task/Distributed-programming/Tcl/distributed-programming-2.tcl create mode 100644 Task/Documentation/0DESCRIPTION create mode 100644 Task/Documentation/1META.yaml create mode 100644 Task/Documentation/Ada/documentation.ada create mode 100644 Task/Documentation/AutoHotkey/documentation.ahk create mode 100644 Task/Documentation/C/documentation.c create mode 100644 Task/Documentation/Clojure/documentation.clj create mode 100644 Task/Documentation/D/documentation.d create mode 100644 Task/Documentation/Delphi/documentation.delphi create mode 100644 Task/Documentation/E/documentation.e create mode 100644 Task/Documentation/Eiffel/documentation-1.e create mode 100644 Task/Documentation/Eiffel/documentation-2.e create mode 100644 Task/Documentation/Go/documentation.go create mode 100644 Task/Documentation/Haskell/documentation-1.hs create mode 100644 Task/Documentation/Haskell/documentation-2.hs create mode 100644 Task/Documentation/Haskell/documentation-3.hs create mode 100644 Task/Documentation/Java/documentation.java create mode 100644 Task/Documentation/PicoLisp/documentation.l create mode 100644 Task/Documentation/Python/documentation-1.py create mode 100644 Task/Documentation/Python/documentation-2.py create mode 100644 Task/Documentation/R/documentation-1.r create mode 100644 Task/Documentation/R/documentation-2.r create mode 100644 Task/Documentation/REXX/documentation.rexx create mode 100644 Task/Documentation/Racket/documentation.rkt create mode 100644 Task/Documentation/Ruby/documentation.rb create mode 100644 Task/Documentation/Smalltalk/documentation.st create mode 100644 Task/Documentation/Tcl/documentation.tcl create mode 100644 Task/Dot-product/0DESCRIPTION create mode 100644 Task/Dot-product/ABAP/dot-product.abap create mode 100644 Task/Dot-product/ACL2/dot-product.acl2 create mode 100644 Task/Dot-product/ALGOL-68/dot-product.alg create mode 100644 Task/Dot-product/ActionScript/dot-product.as create mode 100644 Task/Dot-product/Ada/dot-product.ada create mode 100644 Task/Dot-product/AutoHotkey/dot-product.ahk create mode 100644 Task/Dot-product/BBC-BASIC/dot-product.bbc create mode 100644 Task/Dot-product/Bracmat/dot-product.bracmat create mode 100644 Task/Dot-product/C++/dot-product.cpp create mode 100644 Task/Dot-product/C/dot-product.c create mode 100644 Task/Dot-product/Clojure/dot-product.clj create mode 100644 Task/Dot-product/CoffeeScript/dot-product.coffee create mode 100644 Task/Dot-product/Common-Lisp/dot-product-1.lisp create mode 100644 Task/Dot-product/Common-Lisp/dot-product-2.lisp create mode 100644 Task/Dot-product/D/dot-product-1.d create mode 100644 Task/Dot-product/D/dot-product-2.d create mode 100644 Task/Dot-product/DWScript/dot-product-1.dwscript create mode 100644 Task/Dot-product/DWScript/dot-product-2.dwscript create mode 100644 Task/Dot-product/Delphi/dot-product.delphi create mode 100644 Task/Dot-product/Ela/dot-product.ela create mode 100644 Task/Dot-product/Erlang/dot-product.erl create mode 100644 Task/Dot-product/Euphoria/dot-product-1.euphoria create mode 100644 Task/Dot-product/Euphoria/dot-product-2.euphoria create mode 100644 Task/Dot-product/Forth/dot-product.fth create mode 100644 Task/Dot-product/Fortran/dot-product.f create mode 100644 Task/Dot-product/Go/dot-product.go create mode 100644 Task/Dot-product/Haskell/dot-product.hs create mode 100644 Task/Dot-product/Java/dot-product.java create mode 100644 Task/Dot-product/JavaScript/dot-product.js create mode 100644 Task/Dot-product/Lua/dot-product.lua create mode 100644 Task/Dot-product/MATLAB/dot-product-1.m create mode 100644 Task/Dot-product/MATLAB/dot-product-2.m create mode 100644 Task/Dot-product/PHP/dot-product.php create mode 100644 Task/Dot-product/Perl/dot-product.pl create mode 100644 Task/Dot-product/PicoLisp/dot-product.l create mode 100644 Task/Dot-product/Prolog/dot-product.pro create mode 100644 Task/Dot-product/Python/dot-product.py create mode 100644 Task/Dot-product/R/dot-product.r create mode 100644 Task/Dot-product/REXX/dot-product.rexx create mode 100644 Task/Dot-product/Racket/dot-product.rkt create mode 100644 Task/Dot-product/Ruby/dot-product-1.rb create mode 100644 Task/Dot-product/Ruby/dot-product-2.rb create mode 100644 Task/Dot-product/Sather/dot-product.sa create mode 100644 Task/Dot-product/Scala/dot-product.scala create mode 100644 Task/Dot-product/Scheme/dot-product.ss create mode 100644 Task/Dot-product/Smalltalk/dot-product.st create mode 100644 Task/Dot-product/Tcl/dot-product.tcl create mode 100644 Task/Doubly-linked-list-Definition/0DESCRIPTION create mode 100644 Task/Doubly-linked-list-Definition/1META.yaml create mode 100644 Task/Doubly-linked-list-Definition/ALGOL-68/doubly-linked-list-definition.alg create mode 100644 Task/Doubly-linked-list-Definition/C-sharp/doubly-linked-list-definition.cs create mode 100644 Task/Doubly-linked-list-Definition/C/doubly-linked-list-definition-1.c create mode 100644 Task/Doubly-linked-list-Definition/C/doubly-linked-list-definition-2.c create mode 100644 Task/Doubly-linked-list-Definition/Clojure/doubly-linked-list-definition-1.clj create mode 100644 Task/Doubly-linked-list-Definition/Clojure/doubly-linked-list-definition-2.clj create mode 100644 Task/Doubly-linked-list-Definition/Common-Lisp/doubly-linked-list-definition-1.lisp create mode 100644 Task/Doubly-linked-list-Definition/Common-Lisp/doubly-linked-list-definition-2.lisp create mode 100644 Task/Doubly-linked-list-Definition/D/doubly-linked-list-definition.d create mode 100644 Task/Doubly-linked-list-Definition/E/doubly-linked-list-definition-1.e create mode 100644 Task/Doubly-linked-list-Definition/E/doubly-linked-list-definition-2.e create mode 100644 Task/Doubly-linked-list-Definition/Fortran/doubly-linked-list-definition.f create mode 100644 Task/Doubly-linked-list-Definition/Go/doubly-linked-list-definition.go create mode 100644 Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-1.hs create mode 100644 Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-2.hs create mode 100644 Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-3.hs create mode 100644 Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-4.hs create mode 100644 Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-5.hs create mode 100644 Task/Doubly-linked-list-Definition/PicoLisp/doubly-linked-list-definition.l create mode 100644 Task/Doubly-linked-list-Definition/REXX/doubly-linked-list-definition.rexx create mode 100644 Task/Doubly-linked-list-Definition/Tcl/doubly-linked-list-definition-1.tcl create mode 100644 Task/Doubly-linked-list-Definition/Tcl/doubly-linked-list-definition-2.tcl create mode 100644 Task/Doubly-linked-list-Element-definition/0DESCRIPTION create mode 100644 Task/Doubly-linked-list-Element-definition/1META.yaml create mode 100644 Task/Doubly-linked-list-Element-definition/ALGOL-68/doubly-linked-list-element-definition.alg create mode 100644 Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-1.ada create mode 100644 Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-2.ada create mode 100644 Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-3.ada create mode 100644 Task/Doubly-linked-list-Element-definition/BBC-BASIC/doubly-linked-list-element-definition.bbc create mode 100644 Task/Doubly-linked-list-Element-definition/C/doubly-linked-list-element-definition.c create mode 100644 Task/Doubly-linked-list-Element-definition/Clojure/doubly-linked-list-element-definition.clj create mode 100644 Task/Doubly-linked-list-Element-definition/Common-Lisp/doubly-linked-list-element-definition.lisp create mode 100644 Task/Doubly-linked-list-Element-definition/D/doubly-linked-list-element-definition.d create mode 100644 Task/Doubly-linked-list-Element-definition/Delphi/doubly-linked-list-element-definition.delphi create mode 100644 Task/Doubly-linked-list-Element-definition/E/doubly-linked-list-element-definition.e create mode 100644 Task/Doubly-linked-list-Element-definition/Fortran/doubly-linked-list-element-definition.f create mode 100644 Task/Doubly-linked-list-Element-definition/Go/doubly-linked-list-element-definition.go create mode 100644 Task/Doubly-linked-list-Element-definition/Haskell/doubly-linked-list-element-definition-1.hs create mode 100644 Task/Doubly-linked-list-Element-definition/Haskell/doubly-linked-list-element-definition-2.hs create mode 100644 Task/Doubly-linked-list-Element-definition/Java/doubly-linked-list-element-definition.java create mode 100644 Task/Doubly-linked-list-Element-definition/JavaScript/doubly-linked-list-element-definition.js create mode 100644 Task/Doubly-linked-list-Element-definition/Perl/doubly-linked-list-element-definition.pl create mode 100644 Task/Doubly-linked-list-Element-definition/PicoLisp/doubly-linked-list-element-definition.l create mode 100644 Task/Doubly-linked-list-Element-definition/Python/doubly-linked-list-element-definition.py create mode 100644 Task/Doubly-linked-list-Element-definition/REXX/doubly-linked-list-element-definition.rexx create mode 100644 Task/Doubly-linked-list-Element-definition/Ruby/doubly-linked-list-element-definition.rb create mode 100644 Task/Doubly-linked-list-Element-definition/Tcl/doubly-linked-list-element-definition.tcl create mode 100644 Task/Doubly-linked-list-Element-insertion/0DESCRIPTION create mode 100644 Task/Doubly-linked-list-Element-insertion/1META.yaml create mode 100644 Task/Doubly-linked-list-Element-insertion/ALGOL-68/doubly-linked-list-element-insertion.alg create mode 100644 Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-1.ada create mode 100644 Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-2.ada create mode 100644 Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-3.ada create mode 100644 Task/Doubly-linked-list-Element-insertion/BBC-BASIC/doubly-linked-list-element-insertion.bbc create mode 100644 Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-1.c create mode 100644 Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-2.c create mode 100644 Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-3.c create mode 100644 Task/Doubly-linked-list-Element-insertion/Clojure/doubly-linked-list-element-insertion.clj create mode 100644 Task/Doubly-linked-list-Element-insertion/D/doubly-linked-list-element-insertion.d create mode 100644 Task/Doubly-linked-list-Element-insertion/E/doubly-linked-list-element-insertion-1.e create mode 100644 Task/Doubly-linked-list-Element-insertion/E/doubly-linked-list-element-insertion-2.e create mode 100644 Task/Doubly-linked-list-Element-insertion/Fortran/doubly-linked-list-element-insertion-1.f create mode 100644 Task/Doubly-linked-list-Element-insertion/Fortran/doubly-linked-list-element-insertion-2.f create mode 100644 Task/Doubly-linked-list-Element-insertion/Go/doubly-linked-list-element-insertion.go create mode 100644 Task/Doubly-linked-list-Element-insertion/Haskell/doubly-linked-list-element-insertion-1.hs create mode 100644 Task/Doubly-linked-list-Element-insertion/Haskell/doubly-linked-list-element-insertion-2.hs create mode 100644 Task/Doubly-linked-list-Element-insertion/JavaScript/doubly-linked-list-element-insertion.js create mode 100644 Task/Doubly-linked-list-Element-insertion/Perl/doubly-linked-list-element-insertion.pl create mode 100644 Task/Doubly-linked-list-Element-insertion/PicoLisp/doubly-linked-list-element-insertion.l create mode 100644 Task/Doubly-linked-list-Element-insertion/Python/doubly-linked-list-element-insertion.py create mode 100644 Task/Doubly-linked-list-Element-insertion/REXX/doubly-linked-list-element-insertion.rexx create mode 100644 Task/Doubly-linked-list-Element-insertion/Ruby/doubly-linked-list-element-insertion.rb create mode 100644 Task/Doubly-linked-list-Element-insertion/Tcl/doubly-linked-list-element-insertion-1.tcl create mode 100644 Task/Doubly-linked-list-Element-insertion/Tcl/doubly-linked-list-element-insertion-2.tcl create mode 100644 Task/Doubly-linked-list-Traversal/0DESCRIPTION create mode 100644 Task/Doubly-linked-list-Traversal/1META.yaml create mode 100644 Task/Doubly-linked-list-Traversal/Ada/doubly-linked-list-traversal.ada create mode 100644 Task/Doubly-linked-list-Traversal/BBC-BASIC/doubly-linked-list-traversal.bbc create mode 100644 Task/Doubly-linked-list-Traversal/C-sharp/doubly-linked-list-traversal.cs create mode 100644 Task/Doubly-linked-list-Traversal/C/doubly-linked-list-traversal.c create mode 100644 Task/Doubly-linked-list-Traversal/Clojure/doubly-linked-list-traversal.clj create mode 100644 Task/Doubly-linked-list-Traversal/D/doubly-linked-list-traversal.d create mode 100644 Task/Doubly-linked-list-Traversal/Delphi/doubly-linked-list-traversal.delphi create mode 100644 Task/Doubly-linked-list-Traversal/E/doubly-linked-list-traversal-1.e create mode 100644 Task/Doubly-linked-list-Traversal/E/doubly-linked-list-traversal-2.e create mode 100644 Task/Doubly-linked-list-Traversal/Fortran/doubly-linked-list-traversal.f create mode 100644 Task/Doubly-linked-list-Traversal/Go/doubly-linked-list-traversal.go create mode 100644 Task/Doubly-linked-list-Traversal/Haskell/doubly-linked-list-traversal.hs create mode 100644 Task/Doubly-linked-list-Traversal/Java/doubly-linked-list-traversal.java create mode 100644 Task/Doubly-linked-list-Traversal/JavaScript/doubly-linked-list-traversal.js create mode 100644 Task/Doubly-linked-list-Traversal/PicoLisp/doubly-linked-list-traversal.l create mode 100644 Task/Doubly-linked-list-Traversal/Python/doubly-linked-list-traversal-1.py create mode 100644 Task/Doubly-linked-list-Traversal/Python/doubly-linked-list-traversal-2.py create mode 100644 Task/Doubly-linked-list-Traversal/REXX/doubly-linked-list-traversal.rexx create mode 100644 Task/Doubly-linked-list-Traversal/Ruby/doubly-linked-list-traversal.rb create mode 100644 Task/Doubly-linked-list-Traversal/Tcl/doubly-linked-list-traversal.tcl create mode 100644 Task/Draw-a-cuboid/0DESCRIPTION create mode 100644 Task/Draw-a-cuboid/1META.yaml create mode 100644 Task/Draw-a-cuboid/Ada/draw-a-cuboid.ada create mode 100644 Task/Draw-a-cuboid/BBC-BASIC/draw-a-cuboid.bbc create mode 100644 Task/Draw-a-cuboid/Brlcad/draw-a-cuboid.brlcad create mode 100644 Task/Draw-a-cuboid/C/draw-a-cuboid-1.c create mode 100644 Task/Draw-a-cuboid/C/draw-a-cuboid-2.c create mode 100644 Task/Draw-a-cuboid/D/draw-a-cuboid.d create mode 100644 Task/Draw-a-cuboid/Go/draw-a-cuboid.go create mode 100644 Task/Draw-a-cuboid/Haskell/draw-a-cuboid.hs create mode 100644 Task/Draw-a-cuboid/Perl/draw-a-cuboid-1.pl create mode 100644 Task/Draw-a-cuboid/Perl/draw-a-cuboid-2.pl create mode 100644 Task/Draw-a-cuboid/PicoLisp/draw-a-cuboid-1.l create mode 100644 Task/Draw-a-cuboid/PicoLisp/draw-a-cuboid-2.l create mode 100644 Task/Draw-a-cuboid/Prolog/draw-a-cuboid.pro create mode 100644 Task/Draw-a-cuboid/Python/draw-a-cuboid.py create mode 100644 Task/Draw-a-cuboid/REXX/draw-a-cuboid.rexx create mode 100644 Task/Draw-a-cuboid/Tcl/draw-a-cuboid-1.tcl create mode 100644 Task/Draw-a-cuboid/Tcl/draw-a-cuboid-2.tcl create mode 100644 Task/Draw-a-sphere/0DESCRIPTION create mode 100644 Task/Draw-a-sphere/1META.yaml create mode 100644 Task/Draw-a-sphere/Ada/draw-a-sphere.ada create mode 100644 Task/Draw-a-sphere/BASIC/draw-a-sphere-1.bas create mode 100644 Task/Draw-a-sphere/BASIC/draw-a-sphere-2.bas create mode 100644 Task/Draw-a-sphere/BBC-BASIC/draw-a-sphere.bbc create mode 100644 Task/Draw-a-sphere/Brlcad/draw-a-sphere.brlcad create mode 100644 Task/Draw-a-sphere/C/draw-a-sphere-1.c create mode 100644 Task/Draw-a-sphere/C/draw-a-sphere-2.c create mode 100644 Task/Draw-a-sphere/C/draw-a-sphere-3.c create mode 100644 Task/Draw-a-sphere/D/draw-a-sphere.d create mode 100644 Task/Draw-a-sphere/DWScript/draw-a-sphere.dwscript create mode 100644 Task/Draw-a-sphere/Delphi/draw-a-sphere.delphi create mode 100644 Task/Draw-a-sphere/Go/draw-a-sphere.go create mode 100644 Task/Draw-a-sphere/Haskell/draw-a-sphere-1.hs create mode 100644 Task/Draw-a-sphere/Haskell/draw-a-sphere-2.hs create mode 100644 Task/Draw-a-sphere/Java/draw-a-sphere.java create mode 100644 Task/Draw-a-sphere/Lua/draw-a-sphere.lua create mode 100644 Task/Draw-a-sphere/PicoLisp/draw-a-sphere-1.l create mode 100644 Task/Draw-a-sphere/PicoLisp/draw-a-sphere-2.l create mode 100644 Task/Draw-a-sphere/Python/draw-a-sphere-1.py create mode 100644 Task/Draw-a-sphere/Python/draw-a-sphere-2.py create mode 100644 Task/Draw-a-sphere/REXX/draw-a-sphere.rexx create mode 100644 Task/Draw-a-sphere/Racket/draw-a-sphere.rkt create mode 100644 Task/Draw-a-sphere/Ruby/draw-a-sphere.rb create mode 100644 Task/Draw-a-sphere/Smalltalk/draw-a-sphere.st create mode 100644 Task/Draw-a-sphere/Tcl/draw-a-sphere.tcl create mode 100644 Task/Dutch-national-flag-problem/0DESCRIPTION create mode 100644 Task/Dutch-national-flag-problem/Ada/dutch-national-flag-problem.ada create mode 100644 Task/Dutch-national-flag-problem/AutoIt/dutch-national-flag-problem.autoit create mode 100644 Task/Dutch-national-flag-problem/BBC-BASIC/dutch-national-flag-problem.bbc create mode 100644 Task/Dutch-national-flag-problem/C++/dutch-national-flag-problem.cpp create mode 100644 Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-1.d create mode 100644 Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-2.d create mode 100644 Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-1.erl create mode 100644 Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-2.erl create mode 100644 Task/Dutch-national-flag-problem/Go/dutch-national-flag-problem.go create mode 100644 Task/Dutch-national-flag-problem/Haskell/dutch-national-flag-problem-1.hs create mode 100644 Task/Dutch-national-flag-problem/Haskell/dutch-national-flag-problem-2.hs create mode 100644 Task/Dutch-national-flag-problem/PicoLisp/dutch-national-flag-problem.l create mode 100644 Task/Dutch-national-flag-problem/Prolog/dutch-national-flag-problem-1.pro create mode 100644 Task/Dutch-national-flag-problem/Prolog/dutch-national-flag-problem-2.pro create mode 100644 Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-1.py create mode 100644 Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-2.py create mode 100644 Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-3.py create mode 100644 Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-4.py create mode 100644 Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-5.py create mode 100644 Task/Dutch-national-flag-problem/REXX/dutch-national-flag-problem-1.rexx create mode 100644 Task/Dutch-national-flag-problem/REXX/dutch-national-flag-problem-2.rexx create mode 100644 Task/Dutch-national-flag-problem/Ruby/dutch-national-flag-problem-1.rb create mode 100644 Task/Dutch-national-flag-problem/Ruby/dutch-national-flag-problem-2.rb create mode 100644 Task/Dutch-national-flag-problem/Tcl/dutch-national-flag-problem.tcl create mode 100644 Task/Dynamic-variable-names/0DESCRIPTION create mode 100644 Task/Dynamic-variable-names/1META.yaml create mode 100644 Task/Dynamic-variable-names/AutoHotkey/dynamic-variable-names.ahk create mode 100644 Task/Dynamic-variable-names/BASIC/dynamic-variable-names.bas create mode 100644 Task/Dynamic-variable-names/BBC-BASIC/dynamic-variable-names.bbc create mode 100644 Task/Dynamic-variable-names/Batch-File/dynamic-variable-names.bat create mode 100644 Task/Dynamic-variable-names/Bracmat/dynamic-variable-names.bracmat create mode 100644 Task/Dynamic-variable-names/Clojure/dynamic-variable-names.clj create mode 100644 Task/Dynamic-variable-names/Common-Lisp/dynamic-variable-names-1.lisp create mode 100644 Task/Dynamic-variable-names/Common-Lisp/dynamic-variable-names-2.lisp create mode 100644 Task/Dynamic-variable-names/E/dynamic-variable-names.e create mode 100644 Task/Dynamic-variable-names/Forth/dynamic-variable-names.fth create mode 100644 Task/Dynamic-variable-names/Haskell/dynamic-variable-names.hs create mode 100644 Task/Dynamic-variable-names/JavaScript/dynamic-variable-names.js create mode 100644 Task/Dynamic-variable-names/Lua/dynamic-variable-names.lua create mode 100644 Task/Dynamic-variable-names/PHP/dynamic-variable-names.php create mode 100644 Task/Dynamic-variable-names/Perl/dynamic-variable-names-1.pl create mode 100644 Task/Dynamic-variable-names/Perl/dynamic-variable-names-2.pl create mode 100644 Task/Dynamic-variable-names/PicoLisp/dynamic-variable-names.l create mode 100644 Task/Dynamic-variable-names/Python/dynamic-variable-names-1.py create mode 100644 Task/Dynamic-variable-names/Python/dynamic-variable-names-2.py create mode 100644 Task/Dynamic-variable-names/R/dynamic-variable-names.r create mode 100644 Task/Dynamic-variable-names/REXX/dynamic-variable-names.rexx create mode 100644 Task/Dynamic-variable-names/Ruby/dynamic-variable-names.rb create mode 100644 Task/Dynamic-variable-names/Scheme/dynamic-variable-names.ss create mode 100644 Task/Dynamic-variable-names/Smalltalk/dynamic-variable-names.st create mode 100644 Task/Dynamic-variable-names/Tcl/dynamic-variable-names-1.tcl create mode 100644 Task/Dynamic-variable-names/Tcl/dynamic-variable-names-2.tcl create mode 100644 Task/Dynamic-variable-names/Tcl/dynamic-variable-names-3.tcl create mode 100644 Task/Echo-server/0DESCRIPTION create mode 100644 Task/Echo-server/1META.yaml create mode 100644 Task/Echo-server/Ada/echo-server.ada create mode 100644 Task/Echo-server/AutoHotkey/echo-server.ahk create mode 100644 Task/Echo-server/BBC-BASIC/echo-server.bbc create mode 100644 Task/Echo-server/C/echo-server.c create mode 100644 Task/Echo-server/Clojure/echo-server.clj create mode 100644 Task/Echo-server/CoffeeScript/echo-server.coffee create mode 100644 Task/Echo-server/Common-Lisp/echo-server-1.lisp create mode 100644 Task/Echo-server/Common-Lisp/echo-server-2.lisp create mode 100644 Task/Echo-server/Common-Lisp/echo-server-3.lisp create mode 100644 Task/Echo-server/D/echo-server-1.d create mode 100644 Task/Echo-server/D/echo-server-2.d create mode 100644 Task/Echo-server/Delphi/echo-server.delphi create mode 100644 Task/Echo-server/Erlang/echo-server.erl create mode 100644 Task/Echo-server/Forth/echo-server.fth create mode 100644 Task/Echo-server/Go/echo-server.go create mode 100644 Task/Echo-server/Haskell/echo-server.hs create mode 100644 Task/Echo-server/Java/echo-server.java create mode 100644 Task/Echo-server/JavaScript/echo-server.js create mode 100644 Task/Echo-server/PHP/echo-server.php create mode 100644 Task/Echo-server/Perl/echo-server-1.pl create mode 100644 Task/Echo-server/Perl/echo-server-2.pl create mode 100644 Task/Echo-server/Perl/echo-server-3.pl create mode 100644 Task/Echo-server/PicoLisp/echo-server.l create mode 100644 Task/Echo-server/Python/echo-server.py create mode 100644 Task/Echo-server/Racket/echo-server.rkt create mode 100644 Task/Echo-server/Ruby/echo-server-1.rb create mode 100644 Task/Echo-server/Ruby/echo-server-2.rb create mode 100644 Task/Echo-server/Scheme/echo-server.ss create mode 100644 Task/Echo-server/Tcl/echo-server-1.tcl create mode 100644 Task/Echo-server/Tcl/echo-server-2.tcl create mode 100644 Task/Element-wise-operations/0DESCRIPTION create mode 100644 Task/Element-wise-operations/1META.yaml create mode 100644 Task/Element-wise-operations/ALGOL-68/element-wise-operations.alg create mode 100644 Task/Element-wise-operations/Ada/element-wise-operations-1.ada create mode 100644 Task/Element-wise-operations/Ada/element-wise-operations-2.ada create mode 100644 Task/Element-wise-operations/Ada/element-wise-operations-3.ada create mode 100644 Task/Element-wise-operations/BBC-BASIC/element-wise-operations.bbc create mode 100644 Task/Element-wise-operations/C/element-wise-operations.c create mode 100644 Task/Element-wise-operations/Clojure/element-wise-operations.clj create mode 100644 Task/Element-wise-operations/Common-Lisp/element-wise-operations-1.lisp create mode 100644 Task/Element-wise-operations/Common-Lisp/element-wise-operations-2.lisp create mode 100644 Task/Element-wise-operations/D/element-wise-operations.d create mode 100644 Task/Element-wise-operations/Go/element-wise-operations-1.go create mode 100644 Task/Element-wise-operations/Go/element-wise-operations-2.go create mode 100644 Task/Element-wise-operations/Perl/element-wise-operations-1.pl create mode 100644 Task/Element-wise-operations/Perl/element-wise-operations-2.pl create mode 100644 Task/Element-wise-operations/PicoLisp/element-wise-operations.l create mode 100644 Task/Element-wise-operations/Python/element-wise-operations.py create mode 100644 Task/Element-wise-operations/R/element-wise-operations.r create mode 100644 Task/Element-wise-operations/REXX/element-wise-operations-1.rexx create mode 100644 Task/Element-wise-operations/REXX/element-wise-operations-2.rexx create mode 100644 Task/Element-wise-operations/Tcl/element-wise-operations.tcl create mode 100644 Task/Empty-directory/0DESCRIPTION create mode 100644 Task/Empty-directory/Ada/empty-directory.ada create mode 100644 Task/Empty-directory/BBC-BASIC/empty-directory.bbc create mode 100644 Task/Empty-directory/C/empty-directory.c create mode 100644 Task/Empty-directory/CoffeeScript/empty-directory.coffee create mode 100644 Task/Empty-directory/D/empty-directory.d create mode 100644 Task/Empty-directory/Go/empty-directory.go create mode 100644 Task/Empty-directory/Haskell/empty-directory-1.hs create mode 100644 Task/Empty-directory/Haskell/empty-directory-2.hs create mode 100644 Task/Empty-directory/Haskell/empty-directory-3.hs create mode 100644 Task/Empty-directory/Java/empty-directory.java create mode 100644 Task/Empty-directory/MATLAB/empty-directory.m create mode 100644 Task/Empty-directory/PHP/empty-directory.php create mode 100644 Task/Empty-directory/Perl/empty-directory-1.pl create mode 100644 Task/Empty-directory/Perl/empty-directory-2.pl create mode 100644 Task/Empty-directory/PicoLisp/empty-directory.l create mode 100644 Task/Empty-directory/Python/empty-directory.py create mode 100644 Task/Empty-directory/Racket/empty-directory.rkt create mode 100644 Task/Empty-directory/Ruby/empty-directory-1.rb create mode 100644 Task/Empty-directory/Ruby/empty-directory-2.rb create mode 100644 Task/Empty-directory/Scala/empty-directory.scala create mode 100644 Task/Empty-directory/Tcl/empty-directory.tcl create mode 100644 Task/Empty-program/0DESCRIPTION create mode 100644 Task/Empty-program/1META.yaml create mode 100644 Task/Empty-program/ALGOL-68/empty-program-1.alg create mode 100644 Task/Empty-program/ALGOL-68/empty-program-2.alg create mode 100644 Task/Empty-program/AWK/empty-program.awk create mode 100644 Task/Empty-program/Ada/empty-program.ada create mode 100644 Task/Empty-program/Agena/empty-program.agena create mode 100644 Task/Empty-program/AmigaE/empty-program.amiga create mode 100644 Task/Empty-program/AppleScript/empty-program.applescript create mode 100644 Task/Empty-program/Argile/empty-program.argile create mode 100644 Task/Empty-program/AutoHotkey/empty-program.ahk create mode 100644 Task/Empty-program/AutoIt/empty-program.autoit create mode 100644 Task/Empty-program/BASIC/empty-program-1.bas create mode 100644 Task/Empty-program/BASIC/empty-program-2.bas create mode 100644 Task/Empty-program/BBC-BASIC/empty-program.bbc create mode 100644 Task/Empty-program/Batch-File/empty-program-1.bat create mode 100644 Task/Empty-program/Batch-File/empty-program-2.bat create mode 100644 Task/Empty-program/Bracmat/empty-program-1.bracmat create mode 100644 Task/Empty-program/Bracmat/empty-program-2.bracmat create mode 100644 Task/Empty-program/Bracmat/empty-program-3.bracmat create mode 100644 Task/Empty-program/Bracmat/empty-program-4.bracmat create mode 100644 Task/Empty-program/Brlcad/empty-program.brlcad create mode 100644 Task/Empty-program/C++/empty-program.cpp create mode 100644 Task/Empty-program/C/empty-program-1.c create mode 100644 Task/Empty-program/C/empty-program-2.c create mode 100644 Task/Empty-program/C/empty-program-3.c create mode 100644 Task/Empty-program/COBOL/empty-program.cobol create mode 100644 Task/Empty-program/Clean/empty-program.clean create mode 100644 Task/Empty-program/CoffeeScript/empty-program.coffee create mode 100644 Task/Empty-program/D/empty-program.d create mode 100644 Task/Empty-program/Dart/empty-program.dart create mode 100644 Task/Empty-program/E/empty-program.e create mode 100644 Task/Empty-program/EGL/empty-program.egl create mode 100644 Task/Empty-program/Eiffel/empty-program.e create mode 100644 Task/Empty-program/Erlang/empty-program-1.erl create mode 100644 Task/Empty-program/Erlang/empty-program-2.erl create mode 100644 Task/Empty-program/Euphoria/empty-program.euphoria create mode 100644 Task/Empty-program/Forth/empty-program-1.fth create mode 100644 Task/Empty-program/Forth/empty-program-2.fth create mode 100644 Task/Empty-program/Fortran/empty-program.f create mode 100644 Task/Empty-program/Go/empty-program.go create mode 100644 Task/Empty-program/Haskell/empty-program-1.hs create mode 100644 Task/Empty-program/Haskell/empty-program-2.hs create mode 100644 Task/Empty-program/Java/empty-program-1.java create mode 100644 Task/Empty-program/Java/empty-program-2.java create mode 100644 Task/Empty-program/Java/empty-program-3.java create mode 100644 Task/Empty-program/Java/empty-program-4.java create mode 100644 Task/Empty-program/Java/empty-program-5.java create mode 100644 Task/Empty-program/LaTeX/empty-program.tex create mode 100644 Task/Empty-program/Lua/empty-program.lua create mode 100644 Task/Empty-program/MATLAB/empty-program.m create mode 100644 Task/Empty-program/PIR/empty-program.pir create mode 100644 Task/Empty-program/Perl/empty-program-1.pl create mode 100644 Task/Empty-program/Perl/empty-program-2.pl create mode 100644 Task/Empty-program/Perl/empty-program-3.pl create mode 100644 Task/Empty-program/Perl/empty-program-4.pl create mode 100644 Task/Empty-program/PicoLisp/empty-program.l create mode 100644 Task/Empty-program/REXX/empty-program-1.rexx create mode 100644 Task/Empty-program/REXX/empty-program-2.rexx create mode 100644 Task/Empty-program/REXX/empty-program-3.rexx create mode 100644 Task/Empty-program/Racket/empty-program.rkt create mode 100644 Task/Empty-program/Ruby/empty-program.rb create mode 100644 Task/Empty-program/Scala/empty-program.scala create mode 100644 Task/Empty-program/Scheme/empty-program.ss create mode 100644 Task/Empty-program/Smalltalk/empty-program.st create mode 100644 Task/Empty-program/Tcl/empty-program.tcl create mode 100644 Task/Empty-string/0DESCRIPTION create mode 100644 Task/Empty-string/ACL2/empty-string.acl2 create mode 100644 Task/Empty-string/AWK/empty-string.awk create mode 100644 Task/Empty-string/Ada/empty-string.ada create mode 100644 Task/Empty-string/AutoHotkey/empty-string.ahk create mode 100644 Task/Empty-string/BASIC/empty-string.bas create mode 100644 Task/Empty-string/BBC-BASIC/empty-string.bbc create mode 100644 Task/Empty-string/Bracmat/empty-string.bracmat create mode 100644 Task/Empty-string/C++/empty-string.cpp create mode 100644 Task/Empty-string/C-sharp/empty-string.cs create mode 100644 Task/Empty-string/C/empty-string.c create mode 100644 Task/Empty-string/Clojure/empty-string.clj create mode 100644 Task/Empty-string/CoffeeScript/empty-string.coffee create mode 100644 Task/Empty-string/Common-Lisp/empty-string.lisp create mode 100644 Task/Empty-string/D/empty-string.d create mode 100644 Task/Empty-string/DWScript/empty-string.dwscript create mode 100644 Task/Empty-string/Delphi/empty-string.delphi create mode 100644 Task/Empty-string/Erlang/empty-string.erl create mode 100644 Task/Empty-string/Euphoria/empty-string.euphoria create mode 100644 Task/Empty-string/Forth/empty-string.fth create mode 100644 Task/Empty-string/Go/empty-string.go create mode 100644 Task/Empty-string/Haskell/empty-string.hs create mode 100644 Task/Empty-string/Java/empty-string.java create mode 100644 Task/Empty-string/Lua/empty-string.lua create mode 100644 Task/Empty-string/MATLAB/empty-string.m create mode 100644 Task/Empty-string/PHP/empty-string.php create mode 100644 Task/Empty-string/Perl/empty-string-1.pl create mode 100644 Task/Empty-string/Perl/empty-string-2.pl create mode 100644 Task/Empty-string/PicoLisp/empty-string.l create mode 100644 Task/Empty-string/Python/empty-string.py create mode 100644 Task/Empty-string/R/empty-string.r create mode 100644 Task/Empty-string/REXX/empty-string.rexx create mode 100644 Task/Empty-string/Racket/empty-string.rkt create mode 100644 Task/Empty-string/Ruby/empty-string-1.rb create mode 100644 Task/Empty-string/Ruby/empty-string-2.rb create mode 100644 Task/Empty-string/Ruby/empty-string-3.rb create mode 100644 Task/Empty-string/Ruby/empty-string-4.rb create mode 100644 Task/Empty-string/Scala/empty-string.scala create mode 100644 Task/Empty-string/Scheme/empty-string.ss create mode 100644 Task/Empty-string/Tcl/empty-string-1.tcl create mode 100644 Task/Empty-string/Tcl/empty-string-2.tcl create mode 100644 Task/Enforced-immutability/0DESCRIPTION create mode 100644 Task/Enforced-immutability/ACL2/enforced-immutability.acl2 create mode 100644 Task/Enforced-immutability/ALGOL-68/enforced-immutability.alg create mode 100644 Task/Enforced-immutability/Ada/enforced-immutability.ada create mode 100644 Task/Enforced-immutability/AutoHotkey/enforced-immutability.ahk create mode 100644 Task/Enforced-immutability/BASIC/enforced-immutability-1.bas create mode 100644 Task/Enforced-immutability/BASIC/enforced-immutability-2.bas create mode 100644 Task/Enforced-immutability/BBC-BASIC/enforced-immutability.bbc create mode 100644 Task/Enforced-immutability/C++/enforced-immutability-1.cpp create mode 100644 Task/Enforced-immutability/C++/enforced-immutability-2.cpp create mode 100644 Task/Enforced-immutability/C/enforced-immutability-1.c create mode 100644 Task/Enforced-immutability/C/enforced-immutability-2.c create mode 100644 Task/Enforced-immutability/Clojure/enforced-immutability.clj create mode 100644 Task/Enforced-immutability/D/enforced-immutability.d create mode 100644 Task/Enforced-immutability/Delphi/enforced-immutability.delphi create mode 100644 Task/Enforced-immutability/E/enforced-immutability-1.e create mode 100644 Task/Enforced-immutability/E/enforced-immutability-2.e create mode 100644 Task/Enforced-immutability/Ela/enforced-immutability-1.ela create mode 100644 Task/Enforced-immutability/Ela/enforced-immutability-2.ela create mode 100644 Task/Enforced-immutability/Ela/enforced-immutability-3.ela create mode 100644 Task/Enforced-immutability/Erlang/enforced-immutability-1.erl create mode 100644 Task/Enforced-immutability/Erlang/enforced-immutability-2.erl create mode 100644 Task/Enforced-immutability/Euphoria/enforced-immutability.euphoria create mode 100644 Task/Enforced-immutability/Go/enforced-immutability.go create mode 100644 Task/Enforced-immutability/Haskell/enforced-immutability.hs create mode 100644 Task/Enforced-immutability/Java/enforced-immutability-1.java create mode 100644 Task/Enforced-immutability/Java/enforced-immutability-2.java create mode 100644 Task/Enforced-immutability/Java/enforced-immutability-3.java create mode 100644 Task/Enforced-immutability/JavaScript/enforced-immutability.js create mode 100644 Task/Enforced-immutability/PHP/enforced-immutability-1.php create mode 100644 Task/Enforced-immutability/PHP/enforced-immutability-2.php create mode 100644 Task/Enforced-immutability/Perl/enforced-immutability-1.pl create mode 100644 Task/Enforced-immutability/Perl/enforced-immutability-2.pl create mode 100644 Task/Enforced-immutability/PicoLisp/enforced-immutability-1.l create mode 100644 Task/Enforced-immutability/PicoLisp/enforced-immutability-2.l create mode 100644 Task/Enforced-immutability/Python/enforced-immutability-1.py create mode 100644 Task/Enforced-immutability/Python/enforced-immutability-2.py create mode 100644 Task/Enforced-immutability/Ruby/enforced-immutability.rb create mode 100644 Task/Enforced-immutability/Scala/enforced-immutability.scala create mode 100644 Task/Enforced-immutability/Tcl/enforced-immutability-1.tcl create mode 100644 Task/Enforced-immutability/Tcl/enforced-immutability-2.tcl create mode 100644 Task/Entropy/D/entropy.d create mode 100644 Task/Entropy/Euler-Math-Toolbox/entropy.euler create mode 100644 Task/Enumerations/0DESCRIPTION create mode 100644 Task/Enumerations/1META.yaml create mode 100644 Task/Enumerations/ACL2/enumerations.acl2 create mode 100644 Task/Enumerations/ALGOL-68/enumerations-1.alg create mode 100644 Task/Enumerations/ALGOL-68/enumerations-2.alg create mode 100644 Task/Enumerations/AWK/enumerations.awk create mode 100644 Task/Enumerations/Ada/enumerations.ada create mode 100644 Task/Enumerations/AmigaE/enumerations.amiga create mode 100644 Task/Enumerations/AutoHotkey/enumerations.ahk create mode 100644 Task/Enumerations/BASIC/enumerations.bas create mode 100644 Task/Enumerations/C++/enumerations.cpp create mode 100644 Task/Enumerations/C/enumerations.c create mode 100644 Task/Enumerations/Clojure/enumerations.clj create mode 100644 Task/Enumerations/Common-Lisp/enumerations-1.lisp create mode 100644 Task/Enumerations/Common-Lisp/enumerations-2.lisp create mode 100644 Task/Enumerations/D/enumerations.d create mode 100644 Task/Enumerations/DWScript/enumerations.dwscript create mode 100644 Task/Enumerations/Delphi/enumerations.delphi create mode 100644 Task/Enumerations/E/enumerations-1.e create mode 100644 Task/Enumerations/E/enumerations-2.e create mode 100644 Task/Enumerations/E/enumerations-3.e create mode 100644 Task/Enumerations/EGL/enumerations-1.egl create mode 100644 Task/Enumerations/EGL/enumerations-2.egl create mode 100644 Task/Enumerations/Forth/enumerations-1.fth create mode 100644 Task/Enumerations/Forth/enumerations-2.fth create mode 100644 Task/Enumerations/Forth/enumerations-3.fth create mode 100644 Task/Enumerations/Forth/enumerations-4.fth create mode 100644 Task/Enumerations/Forth/enumerations-5.fth create mode 100644 Task/Enumerations/Forth/enumerations-6.fth create mode 100644 Task/Enumerations/Forth/enumerations-7.fth create mode 100644 Task/Enumerations/Fortran/enumerations-1.f create mode 100644 Task/Enumerations/Fortran/enumerations-2.f create mode 100644 Task/Enumerations/Go/enumerations-1.go create mode 100644 Task/Enumerations/Go/enumerations-2.go create mode 100644 Task/Enumerations/Haskell/enumerations.hs create mode 100644 Task/Enumerations/Java/enumerations-1.java create mode 100644 Task/Enumerations/Java/enumerations-2.java create mode 100644 Task/Enumerations/JavaScript/enumerations.js create mode 100644 Task/Enumerations/Lua/enumerations-1.lua create mode 100644 Task/Enumerations/Lua/enumerations-2.lua create mode 100644 Task/Enumerations/MATLAB/enumerations.m create mode 100644 Task/Enumerations/PHP/enumerations.php create mode 100644 Task/Enumerations/Perl/enumerations.pl create mode 100644 Task/Enumerations/PicoLisp/enumerations-1.l create mode 100644 Task/Enumerations/PicoLisp/enumerations-2.l create mode 100644 Task/Enumerations/Python/enumerations-1.py create mode 100644 Task/Enumerations/Python/enumerations-2.py create mode 100644 Task/Enumerations/R/enumerations.r create mode 100644 Task/Enumerations/REXX/enumerations.rexx create mode 100644 Task/Enumerations/Ruby/enumerations.rb create mode 100644 Task/Enumerations/Scala/enumerations-1.scala create mode 100644 Task/Enumerations/Scala/enumerations-2.scala create mode 100644 Task/Enumerations/Scheme/enumerations.ss create mode 100644 Task/Enumerations/Tcl/enumerations-1.tcl create mode 100644 Task/Enumerations/Tcl/enumerations-2.tcl create mode 100644 Task/Equilibrium-index/0DESCRIPTION create mode 100644 Task/Equilibrium-index/ALGOL-68/equilibrium-index.alg create mode 100644 Task/Equilibrium-index/Ada/equilibrium-index-1.ada create mode 100644 Task/Equilibrium-index/Ada/equilibrium-index-2.ada create mode 100644 Task/Equilibrium-index/Ada/equilibrium-index-3.ada create mode 100644 Task/Equilibrium-index/Ada/equilibrium-index-4.ada create mode 100644 Task/Equilibrium-index/BBC-BASIC/equilibrium-index.bbc create mode 100644 Task/Equilibrium-index/C++/equilibrium-index.cpp create mode 100644 Task/Equilibrium-index/C/equilibrium-index.c create mode 100644 Task/Equilibrium-index/Clojure/equilibrium-index.clj create mode 100644 Task/Equilibrium-index/D/equilibrium-index-1.d create mode 100644 Task/Equilibrium-index/D/equilibrium-index-2.d create mode 100644 Task/Equilibrium-index/Euphoria/equilibrium-index.euphoria create mode 100644 Task/Equilibrium-index/Fortran/equilibrium-index.f create mode 100644 Task/Equilibrium-index/Go/equilibrium-index.go create mode 100644 Task/Equilibrium-index/Haskell/equilibrium-index-1.hs create mode 100644 Task/Equilibrium-index/Haskell/equilibrium-index-2.hs create mode 100644 Task/Equilibrium-index/Haskell/equilibrium-index-3.hs create mode 100644 Task/Equilibrium-index/Java/equilibrium-index.java create mode 100644 Task/Equilibrium-index/MATLAB/equilibrium-index-1.m create mode 100644 Task/Equilibrium-index/MATLAB/equilibrium-index-2.m create mode 100644 Task/Equilibrium-index/PHP/equilibrium-index.php create mode 100644 Task/Equilibrium-index/Perl/equilibrium-index.pl create mode 100644 Task/Equilibrium-index/PicoLisp/equilibrium-index.l create mode 100644 Task/Equilibrium-index/Python/equilibrium-index-1.py create mode 100644 Task/Equilibrium-index/Python/equilibrium-index-2.py create mode 100644 Task/Equilibrium-index/Python/equilibrium-index-3.py create mode 100644 Task/Equilibrium-index/Python/equilibrium-index-4.py create mode 100644 Task/Equilibrium-index/Python/equilibrium-index-5.py create mode 100644 Task/Equilibrium-index/REXX/equilibrium-index.rexx create mode 100644 Task/Equilibrium-index/Ruby/equilibrium-index-1.rb create mode 100644 Task/Equilibrium-index/Ruby/equilibrium-index-2.rb create mode 100644 Task/Equilibrium-index/Ruby/equilibrium-index-3.rb create mode 100644 Task/Equilibrium-index/Tcl/equilibrium-index-1.tcl create mode 100644 Task/Equilibrium-index/Tcl/equilibrium-index-2.tcl create mode 100644 Task/Ethiopian-multiplication/0DESCRIPTION create mode 100644 Task/Ethiopian-multiplication/1META.yaml create mode 100644 Task/Ethiopian-multiplication/ACL2/ethiopian-multiplication.acl2 create mode 100644 Task/Ethiopian-multiplication/ALGOL-68/ethiopian-multiplication.alg create mode 100644 Task/Ethiopian-multiplication/AWK/ethiopian-multiplication.awk create mode 100644 Task/Ethiopian-multiplication/ActionScript/ethiopian-multiplication-1.as create mode 100644 Task/Ethiopian-multiplication/ActionScript/ethiopian-multiplication-2.as create mode 100644 Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-1.ada create mode 100644 Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-2.ada create mode 100644 Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-3.ada create mode 100644 Task/Ethiopian-multiplication/AutoHotkey/ethiopian-multiplication.ahk create mode 100644 Task/Ethiopian-multiplication/AutoIt/ethiopian-multiplication.autoit create mode 100644 Task/Ethiopian-multiplication/BASIC/ethiopian-multiplication.bas create mode 100644 Task/Ethiopian-multiplication/BBC-BASIC/ethiopian-multiplication.bbc create mode 100644 Task/Ethiopian-multiplication/C++/ethiopian-multiplication.cpp create mode 100644 Task/Ethiopian-multiplication/C/ethiopian-multiplication.c create mode 100644 Task/Ethiopian-multiplication/COBOL/ethiopian-multiplication.cobol create mode 100644 Task/Ethiopian-multiplication/Clojure/ethiopian-multiplication.clj create mode 100644 Task/Ethiopian-multiplication/CoffeeScript/ethiopian-multiplication.coffee create mode 100644 Task/Ethiopian-multiplication/ColdFusion/ethiopian-multiplication-1.cfm create mode 100644 Task/Ethiopian-multiplication/ColdFusion/ethiopian-multiplication-2.cfm create mode 100644 Task/Ethiopian-multiplication/Common-Lisp/ethiopian-multiplication.lisp create mode 100644 Task/Ethiopian-multiplication/D/ethiopian-multiplication.d create mode 100644 Task/Ethiopian-multiplication/E/ethiopian-multiplication.e create mode 100644 Task/Ethiopian-multiplication/Ela/ethiopian-multiplication.ela create mode 100644 Task/Ethiopian-multiplication/Erlang/ethiopian-multiplication.erl create mode 100644 Task/Ethiopian-multiplication/Euphoria/ethiopian-multiplication.euphoria create mode 100644 Task/Ethiopian-multiplication/Forth/ethiopian-multiplication.fth create mode 100644 Task/Ethiopian-multiplication/Fortran/ethiopian-multiplication.f create mode 100644 Task/Ethiopian-multiplication/Go/ethiopian-multiplication.go create mode 100644 Task/Ethiopian-multiplication/Haskell/ethiopian-multiplication.hs create mode 100644 Task/Ethiopian-multiplication/Java/ethiopian-multiplication-1.java create mode 100644 Task/Ethiopian-multiplication/Java/ethiopian-multiplication-2.java create mode 100644 Task/Ethiopian-multiplication/Java/ethiopian-multiplication-3.java create mode 100644 Task/Ethiopian-multiplication/Lua/ethiopian-multiplication.lua create mode 100644 Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-1.m create mode 100644 Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-2.m create mode 100644 Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-3.m create mode 100644 Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-4.m create mode 100644 Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-5.m create mode 100644 Task/Ethiopian-multiplication/PHP/ethiopian-multiplication-1.php create mode 100644 Task/Ethiopian-multiplication/PHP/ethiopian-multiplication-2.php create mode 100644 Task/Ethiopian-multiplication/Perl/ethiopian-multiplication.pl create mode 100644 Task/Ethiopian-multiplication/PicoLisp/ethiopian-multiplication.l create mode 100644 Task/Ethiopian-multiplication/Python/ethiopian-multiplication-1.py create mode 100644 Task/Ethiopian-multiplication/Python/ethiopian-multiplication-2.py create mode 100644 Task/Ethiopian-multiplication/Python/ethiopian-multiplication-3.py create mode 100644 Task/Ethiopian-multiplication/R/ethiopian-multiplication.r create mode 100644 Task/Ethiopian-multiplication/REXX/ethiopian-multiplication.rexx create mode 100644 Task/Ethiopian-multiplication/Ruby/ethiopian-multiplication-1.rb create mode 100644 Task/Ethiopian-multiplication/Ruby/ethiopian-multiplication-2.rb create mode 100644 Task/Ethiopian-multiplication/SNUSP/ethiopian-multiplication.snusp create mode 100644 Task/Ethiopian-multiplication/Scala/ethiopian-multiplication.scala create mode 100644 Task/Ethiopian-multiplication/Scheme/ethiopian-multiplication.ss create mode 100644 Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-1.st create mode 100644 Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-2.st create mode 100644 Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-1.tcl create mode 100644 Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-2.tcl create mode 100644 Task/Euler-method/0DESCRIPTION create mode 100644 Task/Euler-method/1META.yaml create mode 100644 Task/Euler-method/ALGOL-68/euler-method.alg create mode 100644 Task/Euler-method/Ada/euler-method-1.ada create mode 100644 Task/Euler-method/Ada/euler-method-2.ada create mode 100644 Task/Euler-method/Ada/euler-method-3.ada create mode 100644 Task/Euler-method/BBC-BASIC/euler-method.bbc create mode 100644 Task/Euler-method/C++/euler-method.cpp create mode 100644 Task/Euler-method/C-sharp/euler-method.cs create mode 100644 Task/Euler-method/C/euler-method-1.c create mode 100644 Task/Euler-method/C/euler-method-2.c create mode 100644 Task/Euler-method/Clay/euler-method.clay create mode 100644 Task/Euler-method/Common-Lisp/euler-method.lisp create mode 100644 Task/Euler-method/D/euler-method.d create mode 100644 Task/Euler-method/Euler-Math-Toolbox/euler-method.euler create mode 100644 Task/Euler-method/Fortran/euler-method.f create mode 100644 Task/Euler-method/Go/euler-method.go create mode 100644 Task/Euler-method/Haskell/euler-method.hs create mode 100644 Task/Euler-method/Java/euler-method.java create mode 100644 Task/Euler-method/Lua/euler-method.lua create mode 100644 Task/Euler-method/Perl/euler-method.pl create mode 100644 Task/Euler-method/PicoLisp/euler-method.l create mode 100644 Task/Euler-method/Python/euler-method.py create mode 100644 Task/Euler-method/Ruby/euler-method.rb create mode 100644 Task/Euler-method/Scala/euler-method.scala create mode 100644 Task/Euler-method/Tcl/euler-method-1.tcl create mode 100644 Task/Euler-method/Tcl/euler-method-2.tcl create mode 100644 Task/Evaluate-binomial-coefficients/0DESCRIPTION create mode 100644 Task/Evaluate-binomial-coefficients/1META.yaml create mode 100644 Task/Evaluate-binomial-coefficients/ACL2/evaluate-binomial-coefficients.acl2 create mode 100644 Task/Evaluate-binomial-coefficients/ALGOL-68/evaluate-binomial-coefficients.alg create mode 100644 Task/Evaluate-binomial-coefficients/Ada/evaluate-binomial-coefficients.ada create mode 100644 Task/Evaluate-binomial-coefficients/AppleScript/evaluate-binomial-coefficients.applescript create mode 100644 Task/Evaluate-binomial-coefficients/AutoHotkey/evaluate-binomial-coefficients.ahk create mode 100644 Task/Evaluate-binomial-coefficients/BBC-BASIC/evaluate-binomial-coefficients.bbc create mode 100644 Task/Evaluate-binomial-coefficients/Bracmat/evaluate-binomial-coefficients.bracmat create mode 100644 Task/Evaluate-binomial-coefficients/Burlesque/evaluate-binomial-coefficients.blq create mode 100644 Task/Evaluate-binomial-coefficients/C++/evaluate-binomial-coefficients-1.cpp create mode 100644 Task/Evaluate-binomial-coefficients/C++/evaluate-binomial-coefficients-2.cpp create mode 100644 Task/Evaluate-binomial-coefficients/C/evaluate-binomial-coefficients-1.c create mode 100644 Task/Evaluate-binomial-coefficients/C/evaluate-binomial-coefficients-2.c create mode 100644 Task/Evaluate-binomial-coefficients/Clojure/evaluate-binomial-coefficients.clj create mode 100644 Task/Evaluate-binomial-coefficients/CoffeeScript/evaluate-binomial-coefficients-1.coffee create mode 100644 Task/Evaluate-binomial-coefficients/CoffeeScript/evaluate-binomial-coefficients-2.coffee create mode 100644 Task/Evaluate-binomial-coefficients/Common-Lisp/evaluate-binomial-coefficients.lisp create mode 100644 Task/Evaluate-binomial-coefficients/D/evaluate-binomial-coefficients.d create mode 100644 Task/Evaluate-binomial-coefficients/Delphi/evaluate-binomial-coefficients.delphi create mode 100644 Task/Evaluate-binomial-coefficients/Erlang/evaluate-binomial-coefficients.erl create mode 100644 Task/Evaluate-binomial-coefficients/Forth/evaluate-binomial-coefficients.fth create mode 100644 Task/Evaluate-binomial-coefficients/Fortran/evaluate-binomial-coefficients-1.f create mode 100644 Task/Evaluate-binomial-coefficients/Fortran/evaluate-binomial-coefficients-2.f create mode 100644 Task/Evaluate-binomial-coefficients/Go/evaluate-binomial-coefficients.go create mode 100644 Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-1.hs create mode 100644 Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-2.hs create mode 100644 Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-3.hs create mode 100644 Task/Evaluate-binomial-coefficients/Java/evaluate-binomial-coefficients-1.java create mode 100644 Task/Evaluate-binomial-coefficients/Java/evaluate-binomial-coefficients-2.java create mode 100644 Task/Evaluate-binomial-coefficients/JavaScript/evaluate-binomial-coefficients.js create mode 100644 Task/Evaluate-binomial-coefficients/Lua/evaluate-binomial-coefficients.lua create mode 100644 Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-1.m create mode 100644 Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-2.m create mode 100644 Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-3.m create mode 100644 Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-4.m create mode 100644 Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-5.m create mode 100644 Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-6.m create mode 100644 Task/Evaluate-binomial-coefficients/PHP/evaluate-binomial-coefficients-1.php create mode 100644 Task/Evaluate-binomial-coefficients/PHP/evaluate-binomial-coefficients-2.php create mode 100644 Task/Evaluate-binomial-coefficients/Perl/evaluate-binomial-coefficients.pl create mode 100644 Task/Evaluate-binomial-coefficients/PicoLisp/evaluate-binomial-coefficients.l create mode 100644 Task/Evaluate-binomial-coefficients/Python/evaluate-binomial-coefficients-1.py create mode 100644 Task/Evaluate-binomial-coefficients/Python/evaluate-binomial-coefficients-2.py create mode 100644 Task/Evaluate-binomial-coefficients/R/evaluate-binomial-coefficients-1.r create mode 100644 Task/Evaluate-binomial-coefficients/R/evaluate-binomial-coefficients-2.r create mode 100644 Task/Evaluate-binomial-coefficients/REXX/evaluate-binomial-coefficients.rexx create mode 100644 Task/Evaluate-binomial-coefficients/Racket/evaluate-binomial-coefficients.rkt create mode 100644 Task/Evaluate-binomial-coefficients/Ruby/evaluate-binomial-coefficients-1.rb create mode 100644 Task/Evaluate-binomial-coefficients/Ruby/evaluate-binomial-coefficients-2.rb create mode 100644 Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-1.scala create mode 100644 Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-2.scala create mode 100644 Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-3.scala create mode 100644 Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-4.scala create mode 100644 Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-5.scala create mode 100644 Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-6.scala create mode 100644 Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-1.ss create mode 100644 Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-2.ss create mode 100644 Task/Evaluate-binomial-coefficients/Tcl/evaluate-binomial-coefficients-1.tcl create mode 100644 Task/Evaluate-binomial-coefficients/Tcl/evaluate-binomial-coefficients-2.tcl create mode 100644 Task/Even-or-odd/0815/even-or-odd.0815 create mode 100644 Task/Even-or-odd/0DESCRIPTION create mode 100644 Task/Even-or-odd/AWK/even-or-odd.awk create mode 100644 Task/Even-or-odd/Ada/even-or-odd.ada create mode 100644 Task/Even-or-odd/AutoHotkey/even-or-odd.ahk create mode 100644 Task/Even-or-odd/BASIC/even-or-odd.bas create mode 100644 Task/Even-or-odd/BBC-BASIC/even-or-odd.bbc create mode 100644 Task/Even-or-odd/Bracmat/even-or-odd.bracmat create mode 100644 Task/Even-or-odd/Brainf---/even-or-odd-1.bf create mode 100644 Task/Even-or-odd/Brainf---/even-or-odd-2.bf create mode 100644 Task/Even-or-odd/Burlesque/even-or-odd.blq create mode 100644 Task/Even-or-odd/C++/even-or-odd.cpp create mode 100644 Task/Even-or-odd/C/even-or-odd-1.c create mode 100644 Task/Even-or-odd/C/even-or-odd-2.c create mode 100644 Task/Even-or-odd/Clojure/even-or-odd.clj create mode 100644 Task/Even-or-odd/Common-Lisp/even-or-odd.lisp create mode 100644 Task/Even-or-odd/D/even-or-odd.d create mode 100644 Task/Even-or-odd/DWScript/even-or-odd-1.dwscript create mode 100644 Task/Even-or-odd/DWScript/even-or-odd-2.dwscript create mode 100644 Task/Even-or-odd/DWScript/even-or-odd-3.dwscript create mode 100644 Task/Even-or-odd/Euphoria/even-or-odd.euphoria create mode 100644 Task/Even-or-odd/Forth/even-or-odd.fth create mode 100644 Task/Even-or-odd/Go/even-or-odd.go create mode 100644 Task/Even-or-odd/Haskell/even-or-odd.hs create mode 100644 Task/Even-or-odd/Java/even-or-odd-1.java create mode 100644 Task/Even-or-odd/Java/even-or-odd-2.java create mode 100644 Task/Even-or-odd/Java/even-or-odd-3.java create mode 100644 Task/Even-or-odd/Java/even-or-odd-4.java create mode 100644 Task/Even-or-odd/Java/even-or-odd-5.java create mode 100644 Task/Even-or-odd/JavaScript/even-or-odd.js create mode 100644 Task/Even-or-odd/Lua/even-or-odd.lua create mode 100644 Task/Even-or-odd/MATLAB/even-or-odd-1.m create mode 100644 Task/Even-or-odd/MATLAB/even-or-odd-2.m create mode 100644 Task/Even-or-odd/MATLAB/even-or-odd-3.m create mode 100644 Task/Even-or-odd/PHP/even-or-odd.php create mode 100644 Task/Even-or-odd/Perl/even-or-odd-1.pl create mode 100644 Task/Even-or-odd/Perl/even-or-odd-2.pl create mode 100644 Task/Even-or-odd/PicoLisp/even-or-odd.l create mode 100644 Task/Even-or-odd/Python/even-or-odd-1.py create mode 100644 Task/Even-or-odd/Python/even-or-odd-2.py create mode 100644 Task/Even-or-odd/R/even-or-odd.r create mode 100644 Task/Even-or-odd/REXX/even-or-odd.rexx create mode 100644 Task/Even-or-odd/Racket/even-or-odd-1.rkt create mode 100644 Task/Even-or-odd/Racket/even-or-odd-2.rkt create mode 100644 Task/Even-or-odd/Ruby/even-or-odd-1.rb create mode 100644 Task/Even-or-odd/Ruby/even-or-odd-2.rb create mode 100644 Task/Even-or-odd/SNUSP/even-or-odd.snusp create mode 100644 Task/Even-or-odd/Scala/even-or-odd-1.scala create mode 100644 Task/Even-or-odd/Scala/even-or-odd-2.scala create mode 100644 Task/Even-or-odd/Scheme/even-or-odd.ss create mode 100644 Task/Even-or-odd/Tcl/even-or-odd.tcl create mode 100644 Task/Events/0DESCRIPTION create mode 100644 Task/Events/1META.yaml create mode 100644 Task/Events/Ada/events-1.ada create mode 100644 Task/Events/Ada/events-2.ada create mode 100644 Task/Events/Ada/events-3.ada create mode 100644 Task/Events/AutoHotkey/events.ahk create mode 100644 Task/Events/BBC-BASIC/events-1.bbc create mode 100644 Task/Events/BBC-BASIC/events-2.bbc create mode 100644 Task/Events/C/events.c create mode 100644 Task/Events/Delphi/events.delphi create mode 100644 Task/Events/E/events-1.e create mode 100644 Task/Events/E/events-2.e create mode 100644 Task/Events/Erlang/events-1.erl create mode 100644 Task/Events/Erlang/events-2.erl create mode 100644 Task/Events/Go/events.go create mode 100644 Task/Events/Haskell/events-1.hs create mode 100644 Task/Events/Haskell/events-2.hs create mode 100644 Task/Events/JavaScript/events-1.js create mode 100644 Task/Events/JavaScript/events-2.js create mode 100644 Task/Events/Perl/events-1.pl create mode 100644 Task/Events/Perl/events-2.pl create mode 100644 Task/Events/PicoLisp/events.l create mode 100644 Task/Events/Tcl/events-1.tcl create mode 100644 Task/Events/Tcl/events-2.tcl create mode 100644 Task/Evolutionary-algorithm/0DESCRIPTION create mode 100644 Task/Evolutionary-algorithm/ALGOL-68/evolutionary-algorithm.alg create mode 100644 Task/Evolutionary-algorithm/Ada/evolutionary-algorithm.ada create mode 100644 Task/Evolutionary-algorithm/AutoHotkey/evolutionary-algorithm.ahk create mode 100644 Task/Evolutionary-algorithm/BBC-BASIC/evolutionary-algorithm.bbc create mode 100644 Task/Evolutionary-algorithm/C++/evolutionary-algorithm.cpp create mode 100644 Task/Evolutionary-algorithm/C/evolutionary-algorithm-1.c create mode 100644 Task/Evolutionary-algorithm/C/evolutionary-algorithm-2.c create mode 100644 Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-1.clj create mode 100644 Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-2.clj create mode 100644 Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-3.clj create mode 100644 Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-1.lisp create mode 100644 Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-2.lisp create mode 100644 Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-3.lisp create mode 100644 Task/Evolutionary-algorithm/D/evolutionary-algorithm-1.d create mode 100644 Task/Evolutionary-algorithm/D/evolutionary-algorithm-2.d create mode 100644 Task/Evolutionary-algorithm/E/evolutionary-algorithm.e create mode 100644 Task/Evolutionary-algorithm/Erlang/evolutionary-algorithm.erl create mode 100644 Task/Evolutionary-algorithm/Euphoria/evolutionary-algorithm.euphoria create mode 100644 Task/Evolutionary-algorithm/Forth/evolutionary-algorithm.fth create mode 100644 Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-1.f create mode 100644 Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-2.f create mode 100644 Task/Evolutionary-algorithm/Go/evolutionary-algorithm.go create mode 100644 Task/Evolutionary-algorithm/Haskell/evolutionary-algorithm-1.hs create mode 100644 Task/Evolutionary-algorithm/Haskell/evolutionary-algorithm-2.hs create mode 100644 Task/Evolutionary-algorithm/Java/evolutionary-algorithm.java create mode 100644 Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm.js create mode 100644 Task/Evolutionary-algorithm/Lua/evolutionary-algorithm.lua create mode 100644 Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-1.m create mode 100644 Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-2.m create mode 100644 Task/Evolutionary-algorithm/Perl/evolutionary-algorithm.pl create mode 100644 Task/Evolutionary-algorithm/PicoLisp/evolutionary-algorithm.l create mode 100644 Task/Evolutionary-algorithm/Python/evolutionary-algorithm-1.py create mode 100644 Task/Evolutionary-algorithm/Python/evolutionary-algorithm-2.py create mode 100644 Task/Evolutionary-algorithm/R/evolutionary-algorithm.r create mode 100644 Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-1.rexx create mode 100644 Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-2.rexx create mode 100644 Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-3.rexx create mode 100644 Task/Evolutionary-algorithm/Ruby/evolutionary-algorithm.rb create mode 100644 Task/Evolutionary-algorithm/Scala/evolutionary-algorithm.scala create mode 100644 Task/Evolutionary-algorithm/Smalltalk/evolutionary-algorithm.st create mode 100644 Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-1.tcl create mode 100644 Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-2.tcl create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/0DESCRIPTION create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/ALGOL-68/exceptions-catch-an-exception-thrown-in-a-nested-call.alg create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ada/exceptions-catch-an-exception-thrown-in-a-nested-call.ada create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/AutoHotkey/exceptions-catch-an-exception-thrown-in-a-nested-call-1.ahk create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/AutoHotkey/exceptions-catch-an-exception-thrown-in-a-nested-call-2.ahk create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/BBC-BASIC/exceptions-catch-an-exception-thrown-in-a-nested-call.bbc create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C++/exceptions-catch-an-exception-thrown-in-a-nested-call.cpp create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C/exceptions-catch-an-exception-thrown-in-a-nested-call-1.c create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C/exceptions-catch-an-exception-thrown-in-a-nested-call-2.c create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Common-Lisp/exceptions-catch-an-exception-thrown-in-a-nested-call-1.lisp create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Common-Lisp/exceptions-catch-an-exception-thrown-in-a-nested-call-2.lisp create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/D/exceptions-catch-an-exception-thrown-in-a-nested-call.d create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/DWScript/exceptions-catch-an-exception-thrown-in-a-nested-call.dwscript create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Delphi/exceptions-catch-an-exception-thrown-in-a-nested-call.delphi create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/EGL/exceptions-catch-an-exception-thrown-in-a-nested-call.egl create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Eiffel/exceptions-catch-an-exception-thrown-in-a-nested-call.e create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Go/exceptions-catch-an-exception-thrown-in-a-nested-call.go create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Haskell/exceptions-catch-an-exception-thrown-in-a-nested-call-1.hs create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Haskell/exceptions-catch-an-exception-thrown-in-a-nested-call-2.hs create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Java/exceptions-catch-an-exception-thrown-in-a-nested-call.java create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/JavaScript/exceptions-catch-an-exception-thrown-in-a-nested-call.js create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Lua/exceptions-catch-an-exception-thrown-in-a-nested-call.lua create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/MATLAB/exceptions-catch-an-exception-thrown-in-a-nested-call-1.m create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/MATLAB/exceptions-catch-an-exception-thrown-in-a-nested-call-2.m create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Perl/exceptions-catch-an-exception-thrown-in-a-nested-call.pl create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/PicoLisp/exceptions-catch-an-exception-thrown-in-a-nested-call.l create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Python/exceptions-catch-an-exception-thrown-in-a-nested-call.py create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/R/exceptions-catch-an-exception-thrown-in-a-nested-call-1.r create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/R/exceptions-catch-an-exception-thrown-in-a-nested-call-2.r create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-1.rb create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-2.rb create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-3.rb create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Smalltalk/exceptions-catch-an-exception-thrown-in-a-nested-call-1.st create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Smalltalk/exceptions-catch-an-exception-thrown-in-a-nested-call-2.st create mode 100644 Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Tcl/exceptions-catch-an-exception-thrown-in-a-nested-call.tcl create mode 100644 Task/Exceptions/0DESCRIPTION create mode 100644 Task/Exceptions/1META.yaml create mode 100644 Task/Exceptions/ALGOL-68/exceptions-1.alg create mode 100644 Task/Exceptions/ALGOL-68/exceptions-2.alg create mode 100644 Task/Exceptions/ALGOL-68/exceptions-3.alg create mode 100644 Task/Exceptions/ALGOL-68/exceptions-4.alg create mode 100644 Task/Exceptions/Ada/exceptions-1.ada create mode 100644 Task/Exceptions/Ada/exceptions-2.ada create mode 100644 Task/Exceptions/Ada/exceptions-3.ada create mode 100644 Task/Exceptions/Ada/exceptions-4.ada create mode 100644 Task/Exceptions/Ada/exceptions-5.ada create mode 100644 Task/Exceptions/Aikido/exceptions-1.aikido create mode 100644 Task/Exceptions/Aikido/exceptions-2.aikido create mode 100644 Task/Exceptions/AppleScript/exceptions-1.applescript create mode 100644 Task/Exceptions/AppleScript/exceptions-2.applescript create mode 100644 Task/Exceptions/AppleScript/exceptions-3.applescript create mode 100644 Task/Exceptions/AutoHotkey/exceptions-1.ahk create mode 100644 Task/Exceptions/AutoHotkey/exceptions-2.ahk create mode 100644 Task/Exceptions/BBC-BASIC/exceptions.bbc create mode 100644 Task/Exceptions/C++/exceptions-1.cpp create mode 100644 Task/Exceptions/C++/exceptions-2.cpp create mode 100644 Task/Exceptions/C++/exceptions-3.cpp create mode 100644 Task/Exceptions/C++/exceptions-4.cpp create mode 100644 Task/Exceptions/C/exceptions-1.c create mode 100644 Task/Exceptions/C/exceptions-2.c create mode 100644 Task/Exceptions/Clojure/exceptions.clj create mode 100644 Task/Exceptions/ColdFusion/exceptions-1.cfm create mode 100644 Task/Exceptions/ColdFusion/exceptions-2.cfm create mode 100644 Task/Exceptions/Common-Lisp/exceptions.lisp create mode 100644 Task/Exceptions/D/exceptions.d create mode 100644 Task/Exceptions/DWScript/exceptions-1.dwscript create mode 100644 Task/Exceptions/DWScript/exceptions-2.dwscript create mode 100644 Task/Exceptions/DWScript/exceptions-3.dwscript create mode 100644 Task/Exceptions/Delphi/exceptions-1.delphi create mode 100644 Task/Exceptions/Delphi/exceptions-2.delphi create mode 100644 Task/Exceptions/Delphi/exceptions-3.delphi create mode 100644 Task/Exceptions/E/exceptions-1.e create mode 100644 Task/Exceptions/E/exceptions-2.e create mode 100644 Task/Exceptions/E/exceptions-3.e create mode 100644 Task/Exceptions/E/exceptions-4.e create mode 100644 Task/Exceptions/E/exceptions-5.e create mode 100644 Task/Exceptions/Forth/exceptions-1.fth create mode 100644 Task/Exceptions/Forth/exceptions-2.fth create mode 100644 Task/Exceptions/Forth/exceptions-3.fth create mode 100644 Task/Exceptions/Forth/exceptions-4.fth create mode 100644 Task/Exceptions/Go/exceptions.go create mode 100644 Task/Exceptions/Haskell/exceptions-1.hs create mode 100644 Task/Exceptions/Haskell/exceptions-2.hs create mode 100644 Task/Exceptions/Haskell/exceptions-3.hs create mode 100644 Task/Exceptions/Haskell/exceptions-4.hs create mode 100644 Task/Exceptions/Haskell/exceptions-5.hs create mode 100644 Task/Exceptions/Haskell/exceptions-6.hs create mode 100644 Task/Exceptions/Java/exceptions-1.java create mode 100644 Task/Exceptions/Java/exceptions-2.java create mode 100644 Task/Exceptions/Java/exceptions-3.java create mode 100644 Task/Exceptions/Java/exceptions-4.java create mode 100644 Task/Exceptions/JavaScript/exceptions-1.js create mode 100644 Task/Exceptions/JavaScript/exceptions-2.js create mode 100644 Task/Exceptions/Lua/exceptions-1.lua create mode 100644 Task/Exceptions/Lua/exceptions-2.lua create mode 100644 Task/Exceptions/Lua/exceptions-3.lua create mode 100644 Task/Exceptions/Lua/exceptions-4.lua create mode 100644 Task/Exceptions/MATLAB/exceptions.m create mode 100644 Task/Exceptions/PHP/exceptions-1.php create mode 100644 Task/Exceptions/PHP/exceptions-2.php create mode 100644 Task/Exceptions/PHP/exceptions-3.php create mode 100644 Task/Exceptions/Perl/exceptions-1.pl create mode 100644 Task/Exceptions/Perl/exceptions-2.pl create mode 100644 Task/Exceptions/Perl/exceptions-3.pl create mode 100644 Task/Exceptions/Perl/exceptions-4.pl create mode 100644 Task/Exceptions/PicoLisp/exceptions.l create mode 100644 Task/Exceptions/Python/exceptions-1.py create mode 100644 Task/Exceptions/Python/exceptions-2.py create mode 100644 Task/Exceptions/Python/exceptions-3.py create mode 100644 Task/Exceptions/Python/exceptions-4.py create mode 100644 Task/Exceptions/Python/exceptions-5.py create mode 100644 Task/Exceptions/Python/exceptions-6.py create mode 100644 Task/Exceptions/Python/exceptions-7.py create mode 100644 Task/Exceptions/R/exceptions-1.r create mode 100644 Task/Exceptions/R/exceptions-2.r create mode 100644 Task/Exceptions/R/exceptions-3.r create mode 100644 Task/Exceptions/Racket/exceptions.rkt create mode 100644 Task/Exceptions/Ruby/exceptions-1.rb create mode 100644 Task/Exceptions/Ruby/exceptions-2.rb create mode 100644 Task/Exceptions/Ruby/exceptions-3.rb create mode 100644 Task/Exceptions/Ruby/exceptions-4.rb create mode 100644 Task/Exceptions/Ruby/exceptions-5.rb create mode 100644 Task/Exceptions/Ruby/exceptions-6.rb create mode 100644 Task/Exceptions/Scheme/exceptions.ss create mode 100644 Task/Exceptions/Smalltalk/exceptions-1.st create mode 100644 Task/Exceptions/Smalltalk/exceptions-2.st create mode 100644 Task/Exceptions/Smalltalk/exceptions-3.st create mode 100644 Task/Exceptions/Smalltalk/exceptions-4.st create mode 100644 Task/Exceptions/Tcl/exceptions.tcl create mode 100644 Task/Executable-library/0DESCRIPTION create mode 100644 Task/Executable-library/Ada/executable-library-1.ada create mode 100644 Task/Executable-library/Ada/executable-library-2.ada create mode 100644 Task/Executable-library/Ada/executable-library-3.ada create mode 100644 Task/Executable-library/Ada/executable-library-4.ada create mode 100644 Task/Executable-library/AutoHotkey/executable-library-1.ahk create mode 100644 Task/Executable-library/AutoHotkey/executable-library-2.ahk create mode 100644 Task/Executable-library/BBC-BASIC/executable-library-1.bbc create mode 100644 Task/Executable-library/BBC-BASIC/executable-library-2.bbc create mode 100644 Task/Executable-library/C/executable-library-1.c create mode 100644 Task/Executable-library/C/executable-library-2.c create mode 100644 Task/Executable-library/C/executable-library-3.c create mode 100644 Task/Executable-library/Perl/executable-library-1.pl create mode 100644 Task/Executable-library/Perl/executable-library-2.pl create mode 100644 Task/Executable-library/PicoLisp/executable-library-1.l create mode 100644 Task/Executable-library/PicoLisp/executable-library-2.l create mode 100644 Task/Executable-library/Python/executable-library-1.py create mode 100644 Task/Executable-library/Python/executable-library-2.py create mode 100644 Task/Executable-library/REXX/executable-library-1.rexx create mode 100644 Task/Executable-library/REXX/executable-library-2.rexx create mode 100644 Task/Executable-library/REXX/executable-library-3.rexx create mode 100644 Task/Executable-library/Ruby/executable-library-1.rb create mode 100644 Task/Executable-library/Ruby/executable-library-2.rb create mode 100644 Task/Executable-library/Tcl/executable-library-1.tcl create mode 100644 Task/Executable-library/Tcl/executable-library-2.tcl create mode 100644 Task/Executable-library/Tcl/executable-library-3.tcl create mode 100644 Task/Execute-HQ9+/0DESCRIPTION create mode 100644 Task/Execute-HQ9+/AutoHotkey/execute-hq9+.ahk create mode 100644 Task/Execute-HQ9+/BBC-BASIC/execute-hq9+.bbc create mode 100644 Task/Execute-HQ9+/C++/execute-hq9+.cpp create mode 100644 Task/Execute-HQ9+/C-sharp/execute-hq9+.cs create mode 100644 Task/Execute-HQ9+/C/execute-hq9+.c create mode 100644 Task/Execute-HQ9+/Clojure/execute-hq9+.clj create mode 100644 Task/Execute-HQ9+/D/execute-hq9+.d create mode 100644 Task/Execute-HQ9+/DWScript/execute-hq9+.dwscript create mode 100644 Task/Execute-HQ9+/Ela/execute-hq9+-1.ela create mode 100644 Task/Execute-HQ9+/Ela/execute-hq9+-2.ela create mode 100644 Task/Execute-HQ9+/Ela/execute-hq9+-3.ela create mode 100644 Task/Execute-HQ9+/Erlang/execute-hq9+.erl create mode 100644 Task/Execute-HQ9+/Forth/execute-hq9+.fth create mode 100644 Task/Execute-HQ9+/JavaScript/execute-hq9+.js create mode 100644 Task/Execute-HQ9+/PicoLisp/execute-hq9+.l create mode 100644 Task/Execute-HQ9+/REXX/execute-hq9+.rexx create mode 100644 Task/Execute-HQ9+/Scala/execute-hq9+.scala create mode 100644 Task/Execute-a-system-command/0DESCRIPTION create mode 100644 Task/Execute-a-system-command/1META.yaml create mode 100644 Task/Execute-a-system-command/ALGOL-68/execute-a-system-command-1.alg create mode 100644 Task/Execute-a-system-command/ALGOL-68/execute-a-system-command-2.alg create mode 100644 Task/Execute-a-system-command/AWK/execute-a-system-command.awk create mode 100644 Task/Execute-a-system-command/Ada/execute-a-system-command-1.ada create mode 100644 Task/Execute-a-system-command/Ada/execute-a-system-command-2.ada create mode 100644 Task/Execute-a-system-command/Ada/execute-a-system-command-3.ada create mode 100644 Task/Execute-a-system-command/Aikido/execute-a-system-command-1.aikido create mode 100644 Task/Execute-a-system-command/Aikido/execute-a-system-command-2.aikido create mode 100644 Task/Execute-a-system-command/Aikido/execute-a-system-command-3.aikido create mode 100644 Task/Execute-a-system-command/Aime/execute-a-system-command.aime create mode 100644 Task/Execute-a-system-command/AppleScript/execute-a-system-command.applescript create mode 100644 Task/Execute-a-system-command/AutoHotkey/execute-a-system-command.ahk create mode 100644 Task/Execute-a-system-command/BASIC/execute-a-system-command.bas create mode 100644 Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-1.bbc create mode 100644 Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-2.bbc create mode 100644 Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-3.bbc create mode 100644 Task/Execute-a-system-command/Bracmat/execute-a-system-command.bracmat create mode 100644 Task/Execute-a-system-command/Brat/execute-a-system-command.brat create mode 100644 Task/Execute-a-system-command/Brlcad/execute-a-system-command.brlcad create mode 100644 Task/Execute-a-system-command/C++/execute-a-system-command.cpp create mode 100644 Task/Execute-a-system-command/C/execute-a-system-command.c create mode 100644 Task/Execute-a-system-command/CMake/execute-a-system-command-1.cmake create mode 100644 Task/Execute-a-system-command/CMake/execute-a-system-command-2.cmake create mode 100644 Task/Execute-a-system-command/Clojure/execute-a-system-command-1.clj create mode 100644 Task/Execute-a-system-command/Clojure/execute-a-system-command-2.clj create mode 100644 Task/Execute-a-system-command/Clojure/execute-a-system-command-3.clj create mode 100644 Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-1.lisp create mode 100644 Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-2.lisp create mode 100644 Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-3.lisp create mode 100644 Task/Execute-a-system-command/D/execute-a-system-command.d create mode 100644 Task/Execute-a-system-command/DCL/execute-a-system-command-1.dcl create mode 100644 Task/Execute-a-system-command/DCL/execute-a-system-command-2.dcl create mode 100644 Task/Execute-a-system-command/Delphi/execute-a-system-command.delphi create mode 100644 Task/Execute-a-system-command/E/execute-a-system-command.e create mode 100644 Task/Execute-a-system-command/Erlang/execute-a-system-command.erl create mode 100644 Task/Execute-a-system-command/Forth/execute-a-system-command.fth create mode 100644 Task/Execute-a-system-command/Fortran/execute-a-system-command.f create mode 100644 Task/Execute-a-system-command/Go/execute-a-system-command.go create mode 100644 Task/Execute-a-system-command/Haskell/execute-a-system-command.hs create mode 100644 Task/Execute-a-system-command/Java/execute-a-system-command-1.java create mode 100644 Task/Execute-a-system-command/Java/execute-a-system-command-2.java create mode 100644 Task/Execute-a-system-command/Java/execute-a-system-command-3.java create mode 100644 Task/Execute-a-system-command/JavaScript/execute-a-system-command-1.js create mode 100644 Task/Execute-a-system-command/JavaScript/execute-a-system-command-2.js create mode 100644 Task/Execute-a-system-command/Lua/execute-a-system-command.lua create mode 100644 Task/Execute-a-system-command/MATLAB/execute-a-system-command.m create mode 100644 Task/Execute-a-system-command/PHP/execute-a-system-command-1.php create mode 100644 Task/Execute-a-system-command/PHP/execute-a-system-command-2.php create mode 100644 Task/Execute-a-system-command/Perl/execute-a-system-command.pl create mode 100644 Task/Execute-a-system-command/PicoLisp/execute-a-system-command.l create mode 100644 Task/Execute-a-system-command/Prolog/execute-a-system-command.pro create mode 100644 Task/Execute-a-system-command/Python/execute-a-system-command-1.py create mode 100644 Task/Execute-a-system-command/Python/execute-a-system-command-2.py create mode 100644 Task/Execute-a-system-command/Python/execute-a-system-command-3.py create mode 100644 Task/Execute-a-system-command/Python/execute-a-system-command-4.py create mode 100644 Task/Execute-a-system-command/R/execute-a-system-command.r create mode 100644 Task/Execute-a-system-command/REXX/execute-a-system-command.rexx create mode 100644 Task/Execute-a-system-command/Ruby/execute-a-system-command.rb create mode 100644 Task/Execute-a-system-command/Scala/execute-a-system-command.scala create mode 100644 Task/Execute-a-system-command/Scheme/execute-a-system-command.ss create mode 100644 Task/Execute-a-system-command/Smalltalk/execute-a-system-command.st create mode 100644 Task/Execute-a-system-command/Tcl/execute-a-system-command-1.tcl create mode 100644 Task/Execute-a-system-command/Tcl/execute-a-system-command-2.tcl create mode 100644 Task/Execute-a-system-command/Tcl/execute-a-system-command-3.tcl create mode 100644 Task/Execute-a-system-command/Tcl/execute-a-system-command-4.tcl create mode 100644 Task/Exponentiation-operator/0DESCRIPTION create mode 100644 Task/Exponentiation-operator/1META.yaml create mode 100644 Task/Exponentiation-operator/ALGOL-68/exponentiation-operator-1.alg create mode 100644 Task/Exponentiation-operator/ALGOL-68/exponentiation-operator-2.alg create mode 100644 Task/Exponentiation-operator/AWK/exponentiation-operator.awk create mode 100644 Task/Exponentiation-operator/Ada/exponentiation-operator-1.ada create mode 100644 Task/Exponentiation-operator/Ada/exponentiation-operator-2.ada create mode 100644 Task/Exponentiation-operator/Ada/exponentiation-operator-3.ada create mode 100644 Task/Exponentiation-operator/AutoHotkey/exponentiation-operator.ahk create mode 100644 Task/Exponentiation-operator/BASIC/exponentiation-operator.bas create mode 100644 Task/Exponentiation-operator/BBC-BASIC/exponentiation-operator.bbc create mode 100644 Task/Exponentiation-operator/Brat/exponentiation-operator.brat create mode 100644 Task/Exponentiation-operator/C++/exponentiation-operator.cpp create mode 100644 Task/Exponentiation-operator/C/exponentiation-operator.c create mode 100644 Task/Exponentiation-operator/Clojure/exponentiation-operator.clj create mode 100644 Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-1.lisp create mode 100644 Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-2.lisp create mode 100644 Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-3.lisp create mode 100644 Task/Exponentiation-operator/D/exponentiation-operator.d create mode 100644 Task/Exponentiation-operator/E/exponentiation-operator.e create mode 100644 Task/Exponentiation-operator/Erlang/exponentiation-operator-1.erl create mode 100644 Task/Exponentiation-operator/Erlang/exponentiation-operator-2.erl create mode 100644 Task/Exponentiation-operator/Forth/exponentiation-operator-1.fth create mode 100644 Task/Exponentiation-operator/Forth/exponentiation-operator-2.fth create mode 100644 Task/Exponentiation-operator/Fortran/exponentiation-operator.f create mode 100644 Task/Exponentiation-operator/Go/exponentiation-operator.go create mode 100644 Task/Exponentiation-operator/Haskell/exponentiation-operator-1.hs create mode 100644 Task/Exponentiation-operator/Haskell/exponentiation-operator-2.hs create mode 100644 Task/Exponentiation-operator/Haskell/exponentiation-operator-3.hs create mode 100644 Task/Exponentiation-operator/Java/exponentiation-operator.java create mode 100644 Task/Exponentiation-operator/JavaScript/exponentiation-operator.js create mode 100644 Task/Exponentiation-operator/Lua/exponentiation-operator.lua create mode 100644 Task/Exponentiation-operator/Perl/exponentiation-operator.pl create mode 100644 Task/Exponentiation-operator/PicoLisp/exponentiation-operator.l create mode 100644 Task/Exponentiation-operator/Python/exponentiation-operator.py create mode 100644 Task/Exponentiation-operator/R/exponentiation-operator.r create mode 100644 Task/Exponentiation-operator/REXX/exponentiation-operator.rexx create mode 100644 Task/Exponentiation-operator/Ruby/exponentiation-operator-1.rb create mode 100644 Task/Exponentiation-operator/Ruby/exponentiation-operator-2.rb create mode 100644 Task/Exponentiation-operator/Ruby/exponentiation-operator-3.rb create mode 100644 Task/Exponentiation-operator/Scala/exponentiation-operator-1.scala create mode 100644 Task/Exponentiation-operator/Scala/exponentiation-operator-2.scala create mode 100644 Task/Exponentiation-operator/Scheme/exponentiation-operator.ss create mode 100644 Task/Exponentiation-operator/Smalltalk/exponentiation-operator.st create mode 100644 Task/Exponentiation-operator/Tcl/exponentiation-operator.tcl create mode 100644 Task/Extend-your-language/0DESCRIPTION create mode 100644 Task/Extend-your-language/C/extend-your-language-1.c create mode 100644 Task/Extend-your-language/C/extend-your-language-2.c create mode 100644 Task/Extend-your-language/C/extend-your-language-3.c create mode 100644 Task/Extend-your-language/C/extend-your-language-4.c create mode 100644 Task/Extend-your-language/Clay/extend-your-language.clay create mode 100644 Task/Extend-your-language/Clojure/extend-your-language.clj create mode 100644 Task/Extend-your-language/Common-Lisp/extend-your-language.lisp create mode 100644 Task/Extend-your-language/D/extend-your-language.d create mode 100644 Task/Extend-your-language/Delphi/extend-your-language-1.delphi create mode 100644 Task/Extend-your-language/Delphi/extend-your-language-2.delphi create mode 100644 Task/Extend-your-language/E/extend-your-language-1.e create mode 100644 Task/Extend-your-language/E/extend-your-language-2.e create mode 100644 Task/Extend-your-language/Forth/extend-your-language.fth create mode 100644 Task/Extend-your-language/Haskell/extend-your-language.hs create mode 100644 Task/Extend-your-language/Perl/extend-your-language-1.pl create mode 100644 Task/Extend-your-language/Perl/extend-your-language-2.pl create mode 100644 Task/Extend-your-language/PicoLisp/extend-your-language.l create mode 100644 Task/Extend-your-language/R/extend-your-language-1.r create mode 100644 Task/Extend-your-language/R/extend-your-language-2.r create mode 100644 Task/Extend-your-language/R/extend-your-language-3.r create mode 100644 Task/Extend-your-language/R/extend-your-language-4.r create mode 100644 Task/Extend-your-language/Ruby/extend-your-language-1.rb create mode 100644 Task/Extend-your-language/Ruby/extend-your-language-2.rb create mode 100644 Task/Extend-your-language/Scala/extend-your-language-1.scala create mode 100644 Task/Extend-your-language/Scala/extend-your-language-2.scala create mode 100644 Task/Extend-your-language/Scheme/extend-your-language.ss create mode 100644 Task/Extend-your-language/Tcl/extend-your-language-1.tcl create mode 100644 Task/Extend-your-language/Tcl/extend-your-language-2.tcl create mode 100644 Task/Extend-your-language/Tcl/extend-your-language-3.tcl create mode 100644 Task/Extend-your-language/Tcl/extend-your-language-4.tcl create mode 100644 Task/Extend-your-language/Tcl/extend-your-language-5.tcl create mode 100644 Task/Extreme-floating-point-values/0DESCRIPTION create mode 100644 Task/Extreme-floating-point-values/AWK/extreme-floating-point-values.awk create mode 100644 Task/Extreme-floating-point-values/Ada/extreme-floating-point-values-1.ada create mode 100644 Task/Extreme-floating-point-values/Ada/extreme-floating-point-values-2.ada create mode 100644 Task/Extreme-floating-point-values/C/extreme-floating-point-values-1.c create mode 100644 Task/Extreme-floating-point-values/C/extreme-floating-point-values-2.c create mode 100644 Task/Extreme-floating-point-values/D/extreme-floating-point-values-1.d create mode 100644 Task/Extreme-floating-point-values/D/extreme-floating-point-values-2.d create mode 100644 Task/Extreme-floating-point-values/Delphi/extreme-floating-point-values.delphi create mode 100644 Task/Extreme-floating-point-values/Euphoria/extreme-floating-point-values.euphoria create mode 100644 Task/Extreme-floating-point-values/Forth/extreme-floating-point-values.fth create mode 100644 Task/Extreme-floating-point-values/Go/extreme-floating-point-values.go create mode 100644 Task/Extreme-floating-point-values/Java/extreme-floating-point-values.java create mode 100644 Task/Extreme-floating-point-values/Perl/extreme-floating-point-values-1.pl create mode 100644 Task/Extreme-floating-point-values/Perl/extreme-floating-point-values-2.pl create mode 100644 Task/Extreme-floating-point-values/PicoLisp/extreme-floating-point-values.l create mode 100644 Task/Extreme-floating-point-values/Python/extreme-floating-point-values-1.py create mode 100644 Task/Extreme-floating-point-values/Python/extreme-floating-point-values-2.py create mode 100644 Task/Extreme-floating-point-values/R/extreme-floating-point-values.r create mode 100644 Task/Extreme-floating-point-values/Ruby/extreme-floating-point-values.rb create mode 100644 Task/Extreme-floating-point-values/Scheme/extreme-floating-point-values.ss create mode 100644 Task/Extreme-floating-point-values/Tcl/extreme-floating-point-values-1.tcl create mode 100644 Task/Extreme-floating-point-values/Tcl/extreme-floating-point-values-2.tcl create mode 100644 Task/FizzBuzz/C++/fizzbuzz-1.cpp create mode 100644 Task/FizzBuzz/C++/fizzbuzz-2.cpp create mode 100644 Task/FizzBuzz/C++/fizzbuzz-3.cpp create mode 100644 Task/FizzBuzz/C++/fizzbuzz-4.cpp create mode 100644 Task/FizzBuzz/CLIPS/fizzbuzz.clips create mode 100644 Task/FizzBuzz/CMake/fizzbuzz.cmake create mode 100644 Task/FizzBuzz/COBOL/fizzbuzz-1.cobol create mode 100644 Task/FizzBuzz/COBOL/fizzbuzz-2.cobol create mode 100644 Task/FizzBuzz/Cduce/fizzbuzz.cduce create mode 100644 Task/FizzBuzz/Chef/fizzbuzz.chef create mode 100644 Task/FizzBuzz/Clay/fizzbuzz.clay create mode 100644 Task/FizzBuzz/Clipper/fizzbuzz.clipper create mode 100644 Task/FizzBuzz/Common-Lisp/fizzbuzz.lisp create mode 100644 Task/FizzBuzz/D/fizzbuzz.d create mode 100644 Task/FizzBuzz/DWScript/fizzbuzz.dwscript create mode 100644 Task/FizzBuzz/Dart/fizzbuzz.dart create mode 100644 Task/FizzBuzz/Delphi/fizzbuzz.delphi create mode 100644 Task/FizzBuzz/E/fizzbuzz.e create mode 100644 Task/FizzBuzz/Ela/fizzbuzz.ela create mode 100644 Task/FizzBuzz/Elixir/fizzbuzz.elixir create mode 100644 Task/FizzBuzz/Euphoria/fizzbuzz.euphoria create mode 100644 Task/Forest-fire/C-sharp/forest-fire.cs create mode 100644 Task/Forest-fire/Common-Lisp/forest-fire-1.lisp create mode 100644 Task/Forest-fire/Common-Lisp/forest-fire-2.lisp create mode 100644 Task/Forest-fire/D/forest-fire-1.d create mode 100644 Task/Forest-fire/D/forest-fire-2.d create mode 100644 Task/Infinity/C++/infinity.cpp create mode 100644 Task/Infinity/Common-Lisp/infinity.lisp create mode 100644 Task/Infinity/D/infinity.d create mode 100644 Task/Infinity/Delphi/infinity-1.delphi create mode 100644 Task/Infinity/Delphi/infinity-2.delphi create mode 100644 Task/Infinity/E/infinity.e create mode 100644 Task/Infinity/Euphoria/infinity.euphoria create mode 100644 Task/JSON/C++/json.cpp create mode 100644 Task/JSON/C-sharp/json.cs create mode 100644 Task/JSON/Cache-ObjectScript/json.cos create mode 100644 Task/JSON/Common-Lisp/json.lisp create mode 100644 Task/JSON/D/json.d create mode 100644 Task/JSON/EGL/json-1.egl create mode 100644 Task/JSON/EGL/json-2.egl create mode 100644 Task/JSON/EGL/json-3.egl create mode 100644 Task/JSON/EGL/json-4.egl create mode 100644 Task/Knuth-shuffle/C++/knuth-shuffle-1.cpp create mode 100644 Task/Knuth-shuffle/C++/knuth-shuffle-2.cpp create mode 100644 Task/Knuth-shuffle/CMake/knuth-shuffle-1.cmake create mode 100644 Task/Knuth-shuffle/CMake/knuth-shuffle-2.cmake create mode 100644 Task/Knuth-shuffle/Common-Lisp/knuth-shuffle-1.lisp create mode 100644 Task/Knuth-shuffle/Common-Lisp/knuth-shuffle-2.lisp create mode 100644 Task/Knuth-shuffle/D/knuth-shuffle-1.d create mode 100644 Task/Knuth-shuffle/D/knuth-shuffle-2.d create mode 100644 Task/Knuth-shuffle/DWScript/knuth-shuffle.dwscript create mode 100644 Task/Knuth-shuffle/E/knuth-shuffle-1.e create mode 100644 Task/Knuth-shuffle/E/knuth-shuffle-2.e create mode 100644 Task/Knuth-shuffle/Euphoria/knuth-shuffle.euphoria create mode 100644 Task/Narcissist/Common-Lisp/narcissist.lisp create mode 100644 Task/Narcissist/Deja-Vu/narcissist.djv create mode 100644 Task/Ordered-words/C++/ordered-words.cpp create mode 100644 Task/Ordered-words/Common-Lisp/ordered-words.lisp create mode 100644 Task/Ordered-words/D/ordered-words-1.d create mode 100644 Task/Ordered-words/D/ordered-words-2.d create mode 100644 Task/Ordered-words/D/ordered-words-3.d create mode 100644 Task/Ordered-words/D/ordered-words-4.d create mode 100644 Task/Ordered-words/Delphi/ordered-words-1.delphi create mode 100644 Task/Ordered-words/Delphi/ordered-words-2.delphi create mode 100644 Task/Ordered-words/E/ordered-words-1.e create mode 100644 Task/Ordered-words/E/ordered-words-2.e create mode 100644 Task/Ordered-words/Euphoria/ordered-words.euphoria create mode 100644 Task/Pi/C++/pi.cpp create mode 100644 Task/Pi/D/pi-1.d create mode 100644 Task/Pi/D/pi-2.d create mode 100644 Task/Quine/C++/quine.cpp create mode 100644 Task/Quine/C-sharp/quine.cs create mode 100644 Task/Quine/C1R/quine.c1r create mode 100644 Task/Quine/COBOL/quine-1.cobol create mode 100644 Task/Quine/COBOL/quine-2.cobol create mode 100644 Task/Quine/Common-Lisp/quine-1.lisp create mode 100644 Task/Quine/Common-Lisp/quine-2.lisp create mode 100644 Task/Quine/Common-Lisp/quine-3.lisp create mode 100644 Task/Quine/Common-Lisp/quine-4.lisp create mode 100644 Task/Quine/Common-Lisp/quine-5.lisp create mode 100644 Task/Quine/Common-Lisp/quine-6.lisp create mode 100644 Task/Quine/D/quine.d create mode 100644 Task/Quine/Dao/quine.dao create mode 100644 Task/Quine/Deja-Vu/quine.djv create mode 100644 Task/Quine/E/quine.e create mode 100644 Task/Quine/Euphoria/quine.euphoria create mode 100644 Task/Search-a-list/C++/search-a-list.cpp create mode 100644 Task/Search-a-list/Common-Lisp/search-a-list.lisp create mode 100644 Task/Search-a-list/D/search-a-list.d create mode 100644 Task/Search-a-list/DWScript/search-a-list.dwscript create mode 100644 Task/Search-a-list/Delphi/search-a-list.delphi create mode 100644 Task/Search-a-list/E/search-a-list.e create mode 100644 Task/Search-a-list/Euphoria/search-a-list.euphoria diff --git a/.gitignore b/.gitignore index d1899d9e0b..6a7c35e20c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ Cache ToDo +*.swp diff --git a/Conf/.lang.yaml.swp b/Conf/.lang.yaml.swp deleted file mode 100644 index 3230c9f12ad857de3e01bafeefaeb15cf9f60416..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&UuYaf90%}U3kB&P8x#?$4_jN6CT()bHP>^&KYN#?Nqg6vx0ke_6lV8k?>4u$ zyWO3uxq{}U3W}f=v7(3yVo}s5wJ$||Q3U@Wf}p4`7Q}}t6$Pme!S7ryw^tP^eTz)s zGkf=&+1Z)z%>_zhrRHaf+P>j5;b(wo&qaRk)4R@5`8FcgueD|QN$<;PyKmJ+C7=>e z38(~A0xAKOfJ#6mpb}6Cs0363DuFea0IL$6x`yc2jaWSX|9|!0|9@^Jx&S}Hckmg! z2WR07JPVJ)!>|NxXaIxzVIF2-8twrd(y$x0!;P>R*25py68!?_;T!l8K7@DSEqEE8 zhiBjkcnlr{4;U0-3hst|unTs=O)vl(;L;YNi|`|S3tzw|@IJf^Z@?LN37&(~@FY9} zOCVqYj)Do(FadYLI1It9a5LNhn_zh}o(sRh1vn31!{_iZd;ssj>+l-93NOG@a1xF~ z05v!Y^KcL*;0{Q^?XUy3!2oQ8<}G1 z!fv|TXj0Lr6pWlsg;ug$!568(Dm+=(LQDtPac0_)8)9wpb#IP(Ow%lGa1Yb&4|-*X zrh-UBELp50>YZA>HwH_g$w>Y|Z&IR3*Ks)JnrNe=SGNOHIpsT-)pc}tVS5Xd_kx91 zgyi!&t?th9j!~`^c|1PWLQgL8Y*v+5mgH+W^1bUjgM)*eF1smvQM2VOLFCFd*_P$G z;soVnTV#vq^H?m$yAF?h49jtmL?b8XPRp;!sq&=)S{rhCEoYcBSZQ|y788_X!mevm zt|!OJ-m&pa-+*|f*sFvV?yzJ|`0$LyR#UcaATNgxqG^d>CfOycH#(*1Kr}c`ol!B- z#O-D%0)Yp1*D=guRAb(>JUJ*1xh)R#dYK)D-C}-dC@IINnx)}G^3>u5nsQO=n*jQk}x;=WfU-jYE|JPCPDXin7w( z1#7xBMuu!B`-+y!eSvc4TIqam4KI*OGO!Y^75irJYGf4l&la@9$ppPxCi`#2)IW=I z<{Fa^aOLj=!)>@#91)|&eVh@aR%K%=7qr#n)X44IGML_W^94CDXUJ?3d^VNM^aYH! vsmtD`FYneyM{s*4o9Z8x8BdM%-L!XN*3>#jP^Y~UI;AuHgHzejah?7Gbc*Y_ diff --git a/Conf/.task.yaml.swp b/Conf/.task.yaml.swp deleted file mode 100644 index 222d3864dbbcbd2a542553e3b66dbe5babf47cef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2O^6&t6vr#Z5I+(V6$CxR(#2$hZf28JOy=ayY&KcrX20@v@L)}M%}lx7Rh{bU z+3h)Ku4=%$ih?&acnQHvFk%ERqLK*lpdbi>;0FW(dJz1-p5EErB$AL@um*n2bk%!R zum1Jw70Y&G_{hX0e|EJKgJ(?;P5RB z zI00S+lVA&25B|E3u|L2C@F_SA-UTPXQBVg@f&0Nf8yWi*d^H!$`y_!67~C&3$F5j4Ruun+78gJ1)=6a08DW1oTdz)8>r$G|S|2)J?&V?Tgz z!C7z$ybWFhi=Yi=z%-ZwRj?I21lEGfcQf`A_!^u8XTba5b)dl^Z~#052Eit<4*Y!= zW50uMz!%^Qcn5UBaqtp20w%z7paPx%kAlr$Ex3$*`vqJA7r|HHb5QK(ZJ3WfWUqi% zz$@^-Q(*4qKT_DB%>|EC>Z)vj&rTg0+Bs5XGnvw|%BEG7P1#Ud8S({V!?el{!b7EL zX+J4+7&WYM9B<*#053?9@EpTd*#VuoHc#7Gvl(Hm=jWylR@sDZDy>{jw);hrA}ijGJI4q=d0 zg!dOyHD zcw4ie6_(|oGYqU0^L%QGcCI4=Oi(k6kV9f2aROzj0jk2GBchCSt|_;mQprssZ6V@{ zwuz~tKNd;ls8vO>Oixdi2?Iy!n3W=gR9wZPB{7vXS&Pn9q9|Eb8S!hJsUa}BgHu4c z`5)esD(r1{plpCm6;aC|oHo*>9DhG{*|e-!ZW)h^2`N&fU1?N1|3Ozt>~m&2GOf&H zBBT}Lj9lNKo;6l>;$%wQ7V)+eHG_^vKMKwVwv}TPV+F{~iU>n^q@=UL=_xYz>MUA% z?&r`|8MHcouFal)%Zl6?g_zihv@)mS1Y*UeLnT4o$fGDP~VYJihdF*2%&vVjy_cBS!zZc(}EH;xuNDX|a5RQ(=~ z4NN$WXv?86jye;=B1<48W$kF1nm|ET)FxrA$SV^#Q>Dz;cGj_!-WH%wTKY+YkmJ%f z-dSYQ%vpB`JOu^&SN=i!z*|Q7z~=rIj(Ls#_>oqHJ02!>>rSG=zgo zp=X)$Mdj}Zs|0E~tU`F>9Q2-x*myu?9*apG6-175Z8J?-19Myu*j3Yb8COOBaST^t z0Cn){d++9M;))SG!){*32Cu{G(t95FqtKc+GhN&~WF2I2772{To1z#LjSbwLcqlKq l(I;!D!+ZAdnsE-d5G8X>(pS?i?QGp)quS{|ocDPZt0H diff --git a/Conf/lang.yaml b/Conf/lang.yaml index a5d9540a9d..aa700f4d97 100644 --- a/Conf/lang.yaml +++ b/Conf/lang.yaml @@ -62,6 +62,7 @@ AutoIt: AWK: Axiom: Axum: + B: Babel: ext: pb @@ -92,15 +93,91 @@ Burlesque: ext: blq C: +C sharp: + ext: cs +C Shell: + ext: csh +C++: +C++/CLI: + ext: cpp +C0H: +C1R: +Caché ObjectScript: + ext: cos +Caml: +Cat: +CB80: +Cduce: +Cecil: +Chapel: +Chef: +Cilk: +Cilk++: +Clay: +Clean: +Clipper: +Clipper/XBase++: +CLIPS: Clojure: ext: clj +CMake: +COBOL: +Cobra: CoffeeScript: ext: coffee +ColdFusion: + ext: cfm +Common Lisp: + ext: lisp +Component Pascal: + ext: pascal +Coq: +Crack: +Curry: + +D: +Dao: +Dart: +Datalog: +Dc: +DCL: +Delphi: +Deluge: +Diesel: +DMS: +Dodo0: +DWScript: Dylan: +Dylan.NET: + ext: net +Déjà Vu: + ext: djv + +E: +EC: +Efene: +EGL: Eiffel: ext: e +Ela: +Elan: +ElastiC: +Elena: +Elisa: +Elixir: +ELLA: +Emacs Lisp: + ext: l +Epigram: Erlang: ext: erl +Es: +ESQL: +Euler: +Euler Math Toolbox: +Euphoria: +Excel: + Forth: ext: fth Fortran: diff --git a/Conf/task.yaml b/Conf/task.yaml index aa5527aeb8..d5921041e6 100644 --- a/Conf/task.yaml +++ b/Conf/task.yaml @@ -68,34 +68,124 @@ Break OO privacy: Bulls and cows: Bulls and cows/Player: - -# Balanced brackets: -# Balanced ternary: -# Best shuffle: -# # Binary digits: -# Binary search: -# Binary strings: -# Bulls and cows: Caesar cipher: Calendar: +Calendar - for "real" programmers: +Call a foreign-language function: +Call a function: +Call a function in a shared library: +Call an object method: +Canny edge detector: +Carmichael 3 strong pseudoprimes: +Case-sensitivity of identifiers: # Catalan numbers: +Catmull–Clark subdivision surface: +Character codes: +Character matching: +Chat server: +Check Machin-like formulas: Check that file exists: Checkpoint synchronization: -# Cholesky decomposition: +Cholesky decomposition: Classes: Closest-pair problem: Collections: Color of a screen pixel: +Color quantization: +Colour bars/Display: +Colour pinstripe/Display: +Colour pinstripe/Printer: +Combinations: +Combinations with repetitions: +Command-line arguments: Comments: +Compare sorting algorithms' performance: #' +Compile-time calculation: +Compound data type: +Concurrent computing: +Conditional structures: +Constrained genericity: +Constrained random points on a circle: +Continued fraction: +Continued fraction/Arithmetic/Construct from rational number: +Continued fraction/Arithmetic/G(matrix NG, Contined Fraction N): +Continued fraction/Arithmetic/G(matrix NG, Contined Fraction N1, Contined Fraction N2): +Conway's Game of Life: #' +# Copy a string: +Count in factors: +Count in octal: +Count occurrences of a substring: +Count the coins: +CRC-32: +Create a file: +Create a file on magnetic tape: +Create a two-dimensional array at runtime: +Create an HTML table: +Create an object at a given address: +CSV to HTML translation: +Cut a rectangle: + +Date format: +Date manipulation: +Day of the week: +Deal cards for FreeCell: Death Star: -# Deepcopy: +Deconvolution/1D: +Deconvolution/2D+: +Deepcopy: Define a primitive data type: Delegates: Delete a file: Detect division by zero: Determine if a string is numeric: +Determine if only one instance is running: +Digital root: +Dinesman's multiple-dwelling problem: #' +Dining philosophers: +Discordian date: +Distributed programming: +DNS query: +Documentation: +Dot product: +Doubly-linked list/Definition: +Doubly-linked list/Element definition: +Doubly-linked list/Element insertion: +Doubly-linked list/Traversal: +# Dragon curve: +Draw a cuboid: +Draw a sphere: +Dutch national flag problem: +Dynamic variable names: + +Echo server: +Element-wise operations: +Empty directory: +Empty program: +Empty string: +Enforced immutability: Entropy: +Enumerations: +# Environment variables: +Equilibrium index: +Ethiopian multiplication: +Euler method: +Evaluate binomial coefficients: +Even or odd: +Events: +Evolutionary algorithm: +Exceptions: +Exceptions/Catch an exception thrown in a nested call: +Executable library: +# Execute a Markov algorithm: +Execute a system command: +# Execute Brain****: +Execute HQ9+: # Execute SNUSP: +Exponentiation operator: +Extend your language: +Extreme floating point values: + + FizzBuzz: Forest fire: Go Fish: diff --git a/Lang/0815/Count-in-octal b/Lang/0815/Count-in-octal new file mode 120000 index 0000000000..d0eb875b62 --- /dev/null +++ b/Lang/0815/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/0815 \ No newline at end of file diff --git a/Lang/0815/Even-or-odd b/Lang/0815/Even-or-odd new file mode 120000 index 0000000000..c5660bb4ca --- /dev/null +++ b/Lang/0815/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/0815 \ No newline at end of file diff --git a/Lang/4DOS-Batch/Create-a-file b/Lang/4DOS-Batch/Create-a-file new file mode 120000 index 0000000000..5dd056918d --- /dev/null +++ b/Lang/4DOS-Batch/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/4DOS-Batch \ No newline at end of file diff --git a/Lang/6502-Assembly/Conditional-structures b/Lang/6502-Assembly/Conditional-structures new file mode 120000 index 0000000000..1a71df6e53 --- /dev/null +++ b/Lang/6502-Assembly/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/6502-Assembly \ No newline at end of file diff --git a/Lang/6502-Assembly/Conways-Game-of-Life b/Lang/6502-Assembly/Conways-Game-of-Life new file mode 120000 index 0000000000..8bfdd187d2 --- /dev/null +++ b/Lang/6502-Assembly/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/6502-Assembly \ No newline at end of file diff --git a/Lang/6502-Assembly/Create-an-object-at-a-given-address b/Lang/6502-Assembly/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..b5fa9d59ce --- /dev/null +++ b/Lang/6502-Assembly/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/6502-Assembly \ No newline at end of file diff --git a/Lang/ABAP/Character-codes b/Lang/ABAP/Character-codes new file mode 120000 index 0000000000..02b9dc2808 --- /dev/null +++ b/Lang/ABAP/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Date-format b/Lang/ABAP/Date-format new file mode 120000 index 0000000000..ff7cc9cf16 --- /dev/null +++ b/Lang/ABAP/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Day-of-the-week b/Lang/ABAP/Day-of-the-week new file mode 120000 index 0000000000..54d531bfb3 --- /dev/null +++ b/Lang/ABAP/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Dot-product b/Lang/ABAP/Dot-product new file mode 120000 index 0000000000..e69c89da90 --- /dev/null +++ b/Lang/ABAP/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/ABAP \ No newline at end of file diff --git a/Lang/ACL2/Character-codes b/Lang/ACL2/Character-codes new file mode 120000 index 0000000000..107b466d88 --- /dev/null +++ b/Lang/ACL2/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Compound-data-type b/Lang/ACL2/Compound-data-type new file mode 120000 index 0000000000..3825097232 --- /dev/null +++ b/Lang/ACL2/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Conways-Game-of-Life b/Lang/ACL2/Conways-Game-of-Life new file mode 120000 index 0000000000..d2cd04f2dd --- /dev/null +++ b/Lang/ACL2/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Dot-product b/Lang/ACL2/Dot-product new file mode 120000 index 0000000000..445875e18f --- /dev/null +++ b/Lang/ACL2/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Empty-string b/Lang/ACL2/Empty-string new file mode 120000 index 0000000000..b6d4f60a44 --- /dev/null +++ b/Lang/ACL2/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Enforced-immutability b/Lang/ACL2/Enforced-immutability new file mode 120000 index 0000000000..4d3b22a1d3 --- /dev/null +++ b/Lang/ACL2/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Enumerations b/Lang/ACL2/Enumerations new file mode 120000 index 0000000000..d6dd358b1d --- /dev/null +++ b/Lang/ACL2/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Ethiopian-multiplication b/Lang/ACL2/Ethiopian-multiplication new file mode 120000 index 0000000000..d651e91ce0 --- /dev/null +++ b/Lang/ACL2/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Evaluate-binomial-coefficients b/Lang/ACL2/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..812ced43b4 --- /dev/null +++ b/Lang/ACL2/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/ACL2 \ No newline at end of file diff --git a/Lang/ALGOL-68/CSV-to-HTML-translation b/Lang/ALGOL-68/CSV-to-HTML-translation new file mode 120000 index 0000000000..3411ae0f3c --- /dev/null +++ b/Lang/ALGOL-68/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Calendar-for-real-programmers b/Lang/ALGOL-68/Calendar-for-real-programmers new file mode 120000 index 0000000000..4cf5bc4e24 --- /dev/null +++ b/Lang/ALGOL-68/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Character-codes b/Lang/ALGOL-68/Character-codes new file mode 120000 index 0000000000..72d0e543aa --- /dev/null +++ b/Lang/ALGOL-68/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Character-matching b/Lang/ALGOL-68/Character-matching new file mode 120000 index 0000000000..1e794d2bb2 --- /dev/null +++ b/Lang/ALGOL-68/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Cholesky-decomposition b/Lang/ALGOL-68/Cholesky-decomposition new file mode 120000 index 0000000000..e6cd8b9432 --- /dev/null +++ b/Lang/ALGOL-68/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Combinations b/Lang/ALGOL-68/Combinations new file mode 120000 index 0000000000..079bc23312 --- /dev/null +++ b/Lang/ALGOL-68/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Command-line-arguments b/Lang/ALGOL-68/Command-line-arguments new file mode 120000 index 0000000000..3d94103bd5 --- /dev/null +++ b/Lang/ALGOL-68/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Compound-data-type b/Lang/ALGOL-68/Compound-data-type new file mode 120000 index 0000000000..8e6950164e --- /dev/null +++ b/Lang/ALGOL-68/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Concurrent-computing b/Lang/ALGOL-68/Concurrent-computing new file mode 120000 index 0000000000..409daf3037 --- /dev/null +++ b/Lang/ALGOL-68/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Constrained-random-points-on-a-circle b/Lang/ALGOL-68/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..21209470ad --- /dev/null +++ b/Lang/ALGOL-68/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Count-in-octal b/Lang/ALGOL-68/Count-in-octal new file mode 120000 index 0000000000..422e026303 --- /dev/null +++ b/Lang/ALGOL-68/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Count-occurrences-of-a-substring b/Lang/ALGOL-68/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..e748c7baad --- /dev/null +++ b/Lang/ALGOL-68/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Create-a-file b/Lang/ALGOL-68/Create-a-file new file mode 120000 index 0000000000..71b3f26dc8 --- /dev/null +++ b/Lang/ALGOL-68/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Create-a-two-dimensional-array-at-runtime b/Lang/ALGOL-68/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..651a9f0a8c --- /dev/null +++ b/Lang/ALGOL-68/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Date-format b/Lang/ALGOL-68/Date-format new file mode 120000 index 0000000000..e15f210291 --- /dev/null +++ b/Lang/ALGOL-68/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Day-of-the-week b/Lang/ALGOL-68/Day-of-the-week new file mode 120000 index 0000000000..3fb123e57c --- /dev/null +++ b/Lang/ALGOL-68/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Dot-product b/Lang/ALGOL-68/Dot-product new file mode 120000 index 0000000000..8a8bdfb5b0 --- /dev/null +++ b/Lang/ALGOL-68/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Doubly-linked-list-Definition b/Lang/ALGOL-68/Doubly-linked-list-Definition new file mode 120000 index 0000000000..422569f719 --- /dev/null +++ b/Lang/ALGOL-68/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Doubly-linked-list-Element-definition b/Lang/ALGOL-68/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..48e2049cee --- /dev/null +++ b/Lang/ALGOL-68/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Doubly-linked-list-Element-insertion b/Lang/ALGOL-68/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..02ce2a80ca --- /dev/null +++ b/Lang/ALGOL-68/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Element-wise-operations b/Lang/ALGOL-68/Element-wise-operations new file mode 120000 index 0000000000..859984ccf1 --- /dev/null +++ b/Lang/ALGOL-68/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Empty-program b/Lang/ALGOL-68/Empty-program new file mode 120000 index 0000000000..7f0e92d731 --- /dev/null +++ b/Lang/ALGOL-68/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Enforced-immutability b/Lang/ALGOL-68/Enforced-immutability new file mode 120000 index 0000000000..51a1560fe6 --- /dev/null +++ b/Lang/ALGOL-68/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Enumerations b/Lang/ALGOL-68/Enumerations new file mode 120000 index 0000000000..48182e4efc --- /dev/null +++ b/Lang/ALGOL-68/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Equilibrium-index b/Lang/ALGOL-68/Equilibrium-index new file mode 120000 index 0000000000..6be1465e7f --- /dev/null +++ b/Lang/ALGOL-68/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Ethiopian-multiplication b/Lang/ALGOL-68/Ethiopian-multiplication new file mode 120000 index 0000000000..47314da31e --- /dev/null +++ b/Lang/ALGOL-68/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Euler-method b/Lang/ALGOL-68/Euler-method new file mode 120000 index 0000000000..0c9945a567 --- /dev/null +++ b/Lang/ALGOL-68/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Evaluate-binomial-coefficients b/Lang/ALGOL-68/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..033842621e --- /dev/null +++ b/Lang/ALGOL-68/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Evolutionary-algorithm b/Lang/ALGOL-68/Evolutionary-algorithm new file mode 120000 index 0000000000..0c6177d42c --- /dev/null +++ b/Lang/ALGOL-68/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Exceptions b/Lang/ALGOL-68/Exceptions new file mode 120000 index 0000000000..edd573a250 --- /dev/null +++ b/Lang/ALGOL-68/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/ALGOL-68/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..0c29d4c18a --- /dev/null +++ b/Lang/ALGOL-68/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Execute-a-system-command b/Lang/ALGOL-68/Execute-a-system-command new file mode 120000 index 0000000000..7c96334361 --- /dev/null +++ b/Lang/ALGOL-68/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Exponentiation-operator b/Lang/ALGOL-68/Exponentiation-operator new file mode 120000 index 0000000000..c1900e7b92 --- /dev/null +++ b/Lang/ALGOL-68/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/ALGOL-68 \ No newline at end of file diff --git a/Lang/APL/Create-a-file b/Lang/APL/Create-a-file new file mode 120000 index 0000000000..5c5f69f16e --- /dev/null +++ b/Lang/APL/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/APL \ No newline at end of file diff --git a/Lang/APL/Create-a-two-dimensional-array-at-runtime b/Lang/APL/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..242308ae62 --- /dev/null +++ b/Lang/APL/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/APL \ No newline at end of file diff --git a/Lang/ATS/Continued-fraction b/Lang/ATS/Continued-fraction new file mode 120000 index 0000000000..fcfa92b91b --- /dev/null +++ b/Lang/ATS/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/ATS \ No newline at end of file diff --git a/Lang/AWK/CSV-to-HTML-translation b/Lang/AWK/CSV-to-HTML-translation new file mode 120000 index 0000000000..b8f2ca5ae5 --- /dev/null +++ b/Lang/AWK/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/AWK \ No newline at end of file diff --git a/Lang/AWK/Call-a-function b/Lang/AWK/Call-a-function new file mode 120000 index 0000000000..4886bc6d21 --- /dev/null +++ b/Lang/AWK/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/AWK \ No newline at end of file diff --git a/Lang/AWK/Case-sensitivity-of-identifiers b/Lang/AWK/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..d1b6c9ac8e --- /dev/null +++ b/Lang/AWK/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/AWK \ No newline at end of file diff --git a/Lang/AWK/Character-codes b/Lang/AWK/Character-codes new file mode 120000 index 0000000000..0c621a42cc --- /dev/null +++ b/Lang/AWK/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/AWK \ No newline at end of file diff --git a/Lang/AWK/Combinations b/Lang/AWK/Combinations new file mode 120000 index 0000000000..f770c2f22e --- /dev/null +++ b/Lang/AWK/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/AWK \ No newline at end of file diff --git a/Lang/AWK/Command-line-arguments b/Lang/AWK/Command-line-arguments new file mode 120000 index 0000000000..ca252c52aa --- /dev/null +++ b/Lang/AWK/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/AWK \ No newline at end of file diff --git a/Lang/AWK/Compound-data-type b/Lang/AWK/Compound-data-type new file mode 120000 index 0000000000..0ef332f866 --- /dev/null +++ b/Lang/AWK/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/AWK \ No newline at end of file diff --git a/Lang/AWK/Conditional-structures b/Lang/AWK/Conditional-structures new file mode 120000 index 0000000000..448bfd4c40 --- /dev/null +++ b/Lang/AWK/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/AWK \ No newline at end of file diff --git a/Lang/AWK/Conways-Game-of-Life b/Lang/AWK/Conways-Game-of-Life new file mode 120000 index 0000000000..0122637efd --- /dev/null +++ b/Lang/AWK/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/AWK \ No newline at end of file diff --git a/Lang/AWK/Count-in-octal b/Lang/AWK/Count-in-octal new file mode 120000 index 0000000000..347da640ac --- /dev/null +++ b/Lang/AWK/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/AWK \ No newline at end of file diff --git a/Lang/AWK/Count-occurrences-of-a-substring b/Lang/AWK/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..6037edf1b9 --- /dev/null +++ b/Lang/AWK/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/AWK \ No newline at end of file diff --git a/Lang/AWK/Count-the-coins b/Lang/AWK/Count-the-coins new file mode 120000 index 0000000000..8d8e0be6ec --- /dev/null +++ b/Lang/AWK/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/AWK \ No newline at end of file diff --git a/Lang/AWK/Create-a-file b/Lang/AWK/Create-a-file new file mode 120000 index 0000000000..46aaa6d222 --- /dev/null +++ b/Lang/AWK/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/AWK \ No newline at end of file diff --git a/Lang/AWK/Create-a-two-dimensional-array-at-runtime b/Lang/AWK/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..4f4e4da5ef --- /dev/null +++ b/Lang/AWK/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/AWK \ No newline at end of file diff --git a/Lang/AWK/Create-an-HTML-table b/Lang/AWK/Create-an-HTML-table new file mode 120000 index 0000000000..ba14a3375a --- /dev/null +++ b/Lang/AWK/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/AWK \ No newline at end of file diff --git a/Lang/AWK/Date-format b/Lang/AWK/Date-format new file mode 120000 index 0000000000..ff66f5cbca --- /dev/null +++ b/Lang/AWK/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/AWK \ No newline at end of file diff --git a/Lang/AWK/Day-of-the-week b/Lang/AWK/Day-of-the-week new file mode 120000 index 0000000000..7efa6334dc --- /dev/null +++ b/Lang/AWK/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/AWK \ No newline at end of file diff --git a/Lang/AWK/Discordian-date b/Lang/AWK/Discordian-date new file mode 120000 index 0000000000..bbf64034a9 --- /dev/null +++ b/Lang/AWK/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/AWK \ No newline at end of file diff --git a/Lang/AWK/Empty-program b/Lang/AWK/Empty-program new file mode 120000 index 0000000000..16d27f6df2 --- /dev/null +++ b/Lang/AWK/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/AWK \ No newline at end of file diff --git a/Lang/AWK/Empty-string b/Lang/AWK/Empty-string new file mode 120000 index 0000000000..21b2f07f1f --- /dev/null +++ b/Lang/AWK/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/AWK \ No newline at end of file diff --git a/Lang/AWK/Enumerations b/Lang/AWK/Enumerations new file mode 120000 index 0000000000..da8699fcbb --- /dev/null +++ b/Lang/AWK/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/AWK \ No newline at end of file diff --git a/Lang/AWK/Ethiopian-multiplication b/Lang/AWK/Ethiopian-multiplication new file mode 120000 index 0000000000..83ebd7b124 --- /dev/null +++ b/Lang/AWK/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/AWK \ No newline at end of file diff --git a/Lang/AWK/Even-or-odd b/Lang/AWK/Even-or-odd new file mode 120000 index 0000000000..c99e60e7bb --- /dev/null +++ b/Lang/AWK/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/AWK \ No newline at end of file diff --git a/Lang/AWK/Execute-a-system-command b/Lang/AWK/Execute-a-system-command new file mode 120000 index 0000000000..c087f8cb77 --- /dev/null +++ b/Lang/AWK/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/AWK \ No newline at end of file diff --git a/Lang/AWK/Exponentiation-operator b/Lang/AWK/Exponentiation-operator new file mode 120000 index 0000000000..21ad7a134e --- /dev/null +++ b/Lang/AWK/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/AWK \ No newline at end of file diff --git a/Lang/AWK/Extreme-floating-point-values b/Lang/AWK/Extreme-floating-point-values new file mode 120000 index 0000000000..f32acae1a4 --- /dev/null +++ b/Lang/AWK/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/AWK \ No newline at end of file diff --git a/Lang/ActionScript/Call-a-function b/Lang/ActionScript/Call-a-function new file mode 120000 index 0000000000..4cfa91713f --- /dev/null +++ b/Lang/ActionScript/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Call-an-object-method b/Lang/ActionScript/Call-an-object-method new file mode 120000 index 0000000000..47fc5dbfbb --- /dev/null +++ b/Lang/ActionScript/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Character-codes b/Lang/ActionScript/Character-codes new file mode 120000 index 0000000000..3fd17f5338 --- /dev/null +++ b/Lang/ActionScript/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Compound-data-type b/Lang/ActionScript/Compound-data-type new file mode 120000 index 0000000000..3b8bc49b7e --- /dev/null +++ b/Lang/ActionScript/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Dot-product b/Lang/ActionScript/Dot-product new file mode 120000 index 0000000000..09782b9888 --- /dev/null +++ b/Lang/ActionScript/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Ethiopian-multiplication b/Lang/ActionScript/Ethiopian-multiplication new file mode 120000 index 0000000000..e5e13f3f4d --- /dev/null +++ b/Lang/ActionScript/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/ActionScript \ No newline at end of file diff --git a/Lang/Ada/CRC-32 b/Lang/Ada/CRC-32 new file mode 120000 index 0000000000..70fdd69678 --- /dev/null +++ b/Lang/Ada/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Ada \ No newline at end of file diff --git a/Lang/Ada/CSV-to-HTML-translation b/Lang/Ada/CSV-to-HTML-translation new file mode 120000 index 0000000000..554e126620 --- /dev/null +++ b/Lang/Ada/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Ada \ No newline at end of file diff --git a/Lang/Ada/Calendar-for-real-programmers b/Lang/Ada/Calendar-for-real-programmers new file mode 120000 index 0000000000..b080290260 --- /dev/null +++ b/Lang/Ada/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/Ada \ No newline at end of file diff --git a/Lang/Ada/Call-a-foreign-language-function b/Lang/Ada/Call-a-foreign-language-function new file mode 120000 index 0000000000..8523881152 --- /dev/null +++ b/Lang/Ada/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Ada \ No newline at end of file diff --git a/Lang/Ada/Call-a-function b/Lang/Ada/Call-a-function new file mode 120000 index 0000000000..43c5399f5a --- /dev/null +++ b/Lang/Ada/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/Ada \ No newline at end of file diff --git a/Lang/Ada/Call-a-function-in-a-shared-library b/Lang/Ada/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..c8f3f65298 --- /dev/null +++ b/Lang/Ada/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Ada \ No newline at end of file diff --git a/Lang/Ada/Carmichael-3-strong-pseudoprimes b/Lang/Ada/Carmichael-3-strong-pseudoprimes new file mode 120000 index 0000000000..58f909d0d2 --- /dev/null +++ b/Lang/Ada/Carmichael-3-strong-pseudoprimes @@ -0,0 +1 @@ +../../Task/Carmichael-3-strong-pseudoprimes/Ada \ No newline at end of file diff --git a/Lang/Ada/Case-sensitivity-of-identifiers b/Lang/Ada/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..56f526d925 --- /dev/null +++ b/Lang/Ada/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Ada \ No newline at end of file diff --git a/Lang/Ada/Character-codes b/Lang/Ada/Character-codes new file mode 120000 index 0000000000..571077713f --- /dev/null +++ b/Lang/Ada/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Ada \ No newline at end of file diff --git a/Lang/Ada/Character-matching b/Lang/Ada/Character-matching new file mode 120000 index 0000000000..e7b13e9087 --- /dev/null +++ b/Lang/Ada/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Ada \ No newline at end of file diff --git a/Lang/Ada/Chat-server b/Lang/Ada/Chat-server new file mode 120000 index 0000000000..fe784d5710 --- /dev/null +++ b/Lang/Ada/Chat-server @@ -0,0 +1 @@ +../../Task/Chat-server/Ada \ No newline at end of file diff --git a/Lang/Ada/Cholesky-decomposition b/Lang/Ada/Cholesky-decomposition new file mode 120000 index 0000000000..d1462d5ce0 --- /dev/null +++ b/Lang/Ada/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Ada \ No newline at end of file diff --git a/Lang/Ada/Combinations b/Lang/Ada/Combinations new file mode 120000 index 0000000000..e2a9f1812d --- /dev/null +++ b/Lang/Ada/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Ada \ No newline at end of file diff --git a/Lang/Ada/Combinations-with-repetitions b/Lang/Ada/Combinations-with-repetitions new file mode 120000 index 0000000000..05d7e56157 --- /dev/null +++ b/Lang/Ada/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Ada \ No newline at end of file diff --git a/Lang/Ada/Command-line-arguments b/Lang/Ada/Command-line-arguments new file mode 120000 index 0000000000..45f58f9c2f --- /dev/null +++ b/Lang/Ada/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Ada \ No newline at end of file diff --git a/Lang/Ada/Compile-time-calculation b/Lang/Ada/Compile-time-calculation new file mode 120000 index 0000000000..b449f52fa6 --- /dev/null +++ b/Lang/Ada/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Ada \ No newline at end of file diff --git a/Lang/Ada/Compound-data-type b/Lang/Ada/Compound-data-type new file mode 120000 index 0000000000..440b5feac6 --- /dev/null +++ b/Lang/Ada/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Ada \ No newline at end of file diff --git a/Lang/Ada/Concurrent-computing b/Lang/Ada/Concurrent-computing new file mode 120000 index 0000000000..54661ba2ec --- /dev/null +++ b/Lang/Ada/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Ada \ No newline at end of file diff --git a/Lang/Ada/Conditional-structures b/Lang/Ada/Conditional-structures new file mode 120000 index 0000000000..2d8c73c2f3 --- /dev/null +++ b/Lang/Ada/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Ada \ No newline at end of file diff --git a/Lang/Ada/Constrained-genericity b/Lang/Ada/Constrained-genericity new file mode 120000 index 0000000000..242b55418c --- /dev/null +++ b/Lang/Ada/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/Ada \ No newline at end of file diff --git a/Lang/Ada/Constrained-random-points-on-a-circle b/Lang/Ada/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..82ac0b2afd --- /dev/null +++ b/Lang/Ada/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Ada \ No newline at end of file diff --git a/Lang/Ada/Continued-fraction b/Lang/Ada/Continued-fraction new file mode 120000 index 0000000000..38ee403f00 --- /dev/null +++ b/Lang/Ada/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Ada \ No newline at end of file diff --git a/Lang/Ada/Conways-Game-of-Life b/Lang/Ada/Conways-Game-of-Life new file mode 120000 index 0000000000..058a03690b --- /dev/null +++ b/Lang/Ada/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Ada \ No newline at end of file diff --git a/Lang/Ada/Count-in-factors b/Lang/Ada/Count-in-factors new file mode 120000 index 0000000000..407ce82cce --- /dev/null +++ b/Lang/Ada/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Ada \ No newline at end of file diff --git a/Lang/Ada/Count-in-octal b/Lang/Ada/Count-in-octal new file mode 120000 index 0000000000..1a601ae03d --- /dev/null +++ b/Lang/Ada/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Ada \ No newline at end of file diff --git a/Lang/Ada/Count-occurrences-of-a-substring b/Lang/Ada/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..799a1821b9 --- /dev/null +++ b/Lang/Ada/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Ada \ No newline at end of file diff --git a/Lang/Ada/Count-the-coins b/Lang/Ada/Count-the-coins new file mode 120000 index 0000000000..a8ce3a220d --- /dev/null +++ b/Lang/Ada/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Ada \ No newline at end of file diff --git a/Lang/Ada/Create-a-file b/Lang/Ada/Create-a-file new file mode 120000 index 0000000000..c1cd74dab5 --- /dev/null +++ b/Lang/Ada/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Ada \ No newline at end of file diff --git a/Lang/Ada/Create-a-two-dimensional-array-at-runtime b/Lang/Ada/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..eac810423c --- /dev/null +++ b/Lang/Ada/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Ada \ No newline at end of file diff --git a/Lang/Ada/Create-an-HTML-table b/Lang/Ada/Create-an-HTML-table new file mode 120000 index 0000000000..73546dcefb --- /dev/null +++ b/Lang/Ada/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Ada \ No newline at end of file diff --git a/Lang/Ada/Create-an-object-at-a-given-address b/Lang/Ada/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..7799199e7e --- /dev/null +++ b/Lang/Ada/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/Ada \ No newline at end of file diff --git a/Lang/Ada/DNS-query b/Lang/Ada/DNS-query new file mode 120000 index 0000000000..6c7a423f76 --- /dev/null +++ b/Lang/Ada/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/Ada \ No newline at end of file diff --git a/Lang/Ada/Date-format b/Lang/Ada/Date-format new file mode 120000 index 0000000000..0ae8d4d708 --- /dev/null +++ b/Lang/Ada/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Ada \ No newline at end of file diff --git a/Lang/Ada/Date-manipulation b/Lang/Ada/Date-manipulation new file mode 120000 index 0000000000..4fe2ccef3a --- /dev/null +++ b/Lang/Ada/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Ada \ No newline at end of file diff --git a/Lang/Ada/Day-of-the-week b/Lang/Ada/Day-of-the-week new file mode 120000 index 0000000000..4d9ce1a2c8 --- /dev/null +++ b/Lang/Ada/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Ada \ No newline at end of file diff --git a/Lang/Ada/Deal-cards-for-FreeCell b/Lang/Ada/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..1dd9f1dc3a --- /dev/null +++ b/Lang/Ada/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/Ada \ No newline at end of file diff --git a/Lang/Ada/Determine-if-only-one-instance-is-running b/Lang/Ada/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..5dda3f1d06 --- /dev/null +++ b/Lang/Ada/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Ada \ No newline at end of file diff --git a/Lang/Ada/Digital-root b/Lang/Ada/Digital-root new file mode 120000 index 0000000000..1e5f04f987 --- /dev/null +++ b/Lang/Ada/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/Ada \ No newline at end of file diff --git a/Lang/Ada/Dinesmans-multiple-dwelling-problem b/Lang/Ada/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..c9d0323ef7 --- /dev/null +++ b/Lang/Ada/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Ada \ No newline at end of file diff --git a/Lang/Ada/Dining-philosophers b/Lang/Ada/Dining-philosophers new file mode 120000 index 0000000000..5dd511417c --- /dev/null +++ b/Lang/Ada/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Ada \ No newline at end of file diff --git a/Lang/Ada/Discordian-date b/Lang/Ada/Discordian-date new file mode 120000 index 0000000000..647955fbf8 --- /dev/null +++ b/Lang/Ada/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/Ada \ No newline at end of file diff --git a/Lang/Ada/Distributed-programming b/Lang/Ada/Distributed-programming new file mode 120000 index 0000000000..8b5ab2c8c8 --- /dev/null +++ b/Lang/Ada/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/Ada \ No newline at end of file diff --git a/Lang/Ada/Documentation b/Lang/Ada/Documentation new file mode 120000 index 0000000000..d4085fa287 --- /dev/null +++ b/Lang/Ada/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Ada \ No newline at end of file diff --git a/Lang/Ada/Dot-product b/Lang/Ada/Dot-product new file mode 120000 index 0000000000..8a33971c08 --- /dev/null +++ b/Lang/Ada/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Ada \ No newline at end of file diff --git a/Lang/Ada/Doubly-linked-list-Element-definition b/Lang/Ada/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..bc75fbb351 --- /dev/null +++ b/Lang/Ada/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Ada \ No newline at end of file diff --git a/Lang/Ada/Doubly-linked-list-Element-insertion b/Lang/Ada/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..390446719c --- /dev/null +++ b/Lang/Ada/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/Ada \ No newline at end of file diff --git a/Lang/Ada/Doubly-linked-list-Traversal b/Lang/Ada/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..16bc855bb7 --- /dev/null +++ b/Lang/Ada/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Ada \ No newline at end of file diff --git a/Lang/Ada/Draw-a-cuboid b/Lang/Ada/Draw-a-cuboid new file mode 120000 index 0000000000..da3ce55cbb --- /dev/null +++ b/Lang/Ada/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Ada \ No newline at end of file diff --git a/Lang/Ada/Draw-a-sphere b/Lang/Ada/Draw-a-sphere new file mode 120000 index 0000000000..d8d71f4693 --- /dev/null +++ b/Lang/Ada/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Ada \ No newline at end of file diff --git a/Lang/Ada/Dutch-national-flag-problem b/Lang/Ada/Dutch-national-flag-problem new file mode 120000 index 0000000000..bb583a67e7 --- /dev/null +++ b/Lang/Ada/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Ada \ No newline at end of file diff --git a/Lang/Ada/Echo-server b/Lang/Ada/Echo-server new file mode 120000 index 0000000000..e2569c6b46 --- /dev/null +++ b/Lang/Ada/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Ada \ No newline at end of file diff --git a/Lang/Ada/Element-wise-operations b/Lang/Ada/Element-wise-operations new file mode 120000 index 0000000000..dc5cbff574 --- /dev/null +++ b/Lang/Ada/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/Ada \ No newline at end of file diff --git a/Lang/Ada/Empty-directory b/Lang/Ada/Empty-directory new file mode 120000 index 0000000000..ec7640c754 --- /dev/null +++ b/Lang/Ada/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Ada \ No newline at end of file diff --git a/Lang/Ada/Empty-program b/Lang/Ada/Empty-program new file mode 120000 index 0000000000..b9dd482e1e --- /dev/null +++ b/Lang/Ada/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Ada \ No newline at end of file diff --git a/Lang/Ada/Empty-string b/Lang/Ada/Empty-string new file mode 120000 index 0000000000..3e2a8827c5 --- /dev/null +++ b/Lang/Ada/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Ada \ No newline at end of file diff --git a/Lang/Ada/Enforced-immutability b/Lang/Ada/Enforced-immutability new file mode 120000 index 0000000000..59052a9551 --- /dev/null +++ b/Lang/Ada/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Ada \ No newline at end of file diff --git a/Lang/Ada/Enumerations b/Lang/Ada/Enumerations new file mode 120000 index 0000000000..b3dcff6f07 --- /dev/null +++ b/Lang/Ada/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Ada \ No newline at end of file diff --git a/Lang/Ada/Equilibrium-index b/Lang/Ada/Equilibrium-index new file mode 120000 index 0000000000..22cec04ddf --- /dev/null +++ b/Lang/Ada/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Ada \ No newline at end of file diff --git a/Lang/Ada/Ethiopian-multiplication b/Lang/Ada/Ethiopian-multiplication new file mode 120000 index 0000000000..d874a02dfa --- /dev/null +++ b/Lang/Ada/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Ada \ No newline at end of file diff --git a/Lang/Ada/Euler-method b/Lang/Ada/Euler-method new file mode 120000 index 0000000000..0450dcb883 --- /dev/null +++ b/Lang/Ada/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Ada \ No newline at end of file diff --git a/Lang/Ada/Evaluate-binomial-coefficients b/Lang/Ada/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..77172b9186 --- /dev/null +++ b/Lang/Ada/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Ada \ No newline at end of file diff --git a/Lang/Ada/Even-or-odd b/Lang/Ada/Even-or-odd new file mode 120000 index 0000000000..548d1c7754 --- /dev/null +++ b/Lang/Ada/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Ada \ No newline at end of file diff --git a/Lang/Ada/Events b/Lang/Ada/Events new file mode 120000 index 0000000000..ab51c2f39d --- /dev/null +++ b/Lang/Ada/Events @@ -0,0 +1 @@ +../../Task/Events/Ada \ No newline at end of file diff --git a/Lang/Ada/Evolutionary-algorithm b/Lang/Ada/Evolutionary-algorithm new file mode 120000 index 0000000000..5af3436eb4 --- /dev/null +++ b/Lang/Ada/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Ada \ No newline at end of file diff --git a/Lang/Ada/Exceptions b/Lang/Ada/Exceptions new file mode 120000 index 0000000000..1ee56b86e9 --- /dev/null +++ b/Lang/Ada/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Ada \ No newline at end of file diff --git a/Lang/Ada/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Ada/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..c74da15499 --- /dev/null +++ b/Lang/Ada/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ada \ No newline at end of file diff --git a/Lang/Ada/Executable-library b/Lang/Ada/Executable-library new file mode 120000 index 0000000000..3d3d39d8aa --- /dev/null +++ b/Lang/Ada/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/Ada \ No newline at end of file diff --git a/Lang/Ada/Execute-a-system-command b/Lang/Ada/Execute-a-system-command new file mode 120000 index 0000000000..5925e4bc92 --- /dev/null +++ b/Lang/Ada/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Ada \ No newline at end of file diff --git a/Lang/Ada/Exponentiation-operator b/Lang/Ada/Exponentiation-operator new file mode 120000 index 0000000000..41980236e1 --- /dev/null +++ b/Lang/Ada/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Ada \ No newline at end of file diff --git a/Lang/Ada/Extreme-floating-point-values b/Lang/Ada/Extreme-floating-point-values new file mode 120000 index 0000000000..7eff4958dd --- /dev/null +++ b/Lang/Ada/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Ada \ No newline at end of file diff --git a/Lang/Agena/Empty-program b/Lang/Agena/Empty-program new file mode 120000 index 0000000000..582451bb28 --- /dev/null +++ b/Lang/Agena/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Agena \ No newline at end of file diff --git a/Lang/Aikido/Call-a-foreign-language-function b/Lang/Aikido/Call-a-foreign-language-function new file mode 120000 index 0000000000..bff15e1039 --- /dev/null +++ b/Lang/Aikido/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Command-line-arguments b/Lang/Aikido/Command-line-arguments new file mode 120000 index 0000000000..011210fca0 --- /dev/null +++ b/Lang/Aikido/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Conditional-structures b/Lang/Aikido/Conditional-structures new file mode 120000 index 0000000000..8bb5dd0d8a --- /dev/null +++ b/Lang/Aikido/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Create-a-file b/Lang/Aikido/Create-a-file new file mode 120000 index 0000000000..1611dd7b24 --- /dev/null +++ b/Lang/Aikido/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Create-an-object-at-a-given-address b/Lang/Aikido/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..ea1ef48066 --- /dev/null +++ b/Lang/Aikido/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Exceptions b/Lang/Aikido/Exceptions new file mode 120000 index 0000000000..016ca13d77 --- /dev/null +++ b/Lang/Aikido/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Execute-a-system-command b/Lang/Aikido/Execute-a-system-command new file mode 120000 index 0000000000..666d59ec4c --- /dev/null +++ b/Lang/Aikido/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Aikido \ No newline at end of file diff --git a/Lang/Aime/Character-codes b/Lang/Aime/Character-codes new file mode 120000 index 0000000000..9d3286d19f --- /dev/null +++ b/Lang/Aime/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Aime \ No newline at end of file diff --git a/Lang/Aime/Conditional-structures b/Lang/Aime/Conditional-structures new file mode 120000 index 0000000000..0d9968bb58 --- /dev/null +++ b/Lang/Aime/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Aime \ No newline at end of file diff --git a/Lang/Aime/Execute-a-system-command b/Lang/Aime/Execute-a-system-command new file mode 120000 index 0000000000..7f3b1bf9d7 --- /dev/null +++ b/Lang/Aime/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Aime \ No newline at end of file diff --git a/Lang/AmbientTalk/Conditional-structures b/Lang/AmbientTalk/Conditional-structures new file mode 120000 index 0000000000..9efeaaaa3e --- /dev/null +++ b/Lang/AmbientTalk/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/AmbientTalk \ No newline at end of file diff --git a/Lang/AmigaE/Compound-data-type b/Lang/AmigaE/Compound-data-type new file mode 120000 index 0000000000..629566d38b --- /dev/null +++ b/Lang/AmigaE/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Conditional-structures b/Lang/AmigaE/Conditional-structures new file mode 120000 index 0000000000..5fc35860db --- /dev/null +++ b/Lang/AmigaE/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Empty-program b/Lang/AmigaE/Empty-program new file mode 120000 index 0000000000..0c61c8ddb2 --- /dev/null +++ b/Lang/AmigaE/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Enumerations b/Lang/AmigaE/Enumerations new file mode 120000 index 0000000000..f7b7909698 --- /dev/null +++ b/Lang/AmigaE/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/AmigaE \ No newline at end of file diff --git a/Lang/AppleScript/Combinations b/Lang/AppleScript/Combinations new file mode 120000 index 0000000000..63ae92aee8 --- /dev/null +++ b/Lang/AppleScript/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Command-line-arguments b/Lang/AppleScript/Command-line-arguments new file mode 120000 index 0000000000..e403bd1932 --- /dev/null +++ b/Lang/AppleScript/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Conditional-structures b/Lang/AppleScript/Conditional-structures new file mode 120000 index 0000000000..457896e5a3 --- /dev/null +++ b/Lang/AppleScript/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Create-a-file b/Lang/AppleScript/Create-a-file new file mode 120000 index 0000000000..509d83954f --- /dev/null +++ b/Lang/AppleScript/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Create-a-two-dimensional-array-at-runtime b/Lang/AppleScript/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..93689c070c --- /dev/null +++ b/Lang/AppleScript/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Date-manipulation b/Lang/AppleScript/Date-manipulation new file mode 120000 index 0000000000..ce5dba8733 --- /dev/null +++ b/Lang/AppleScript/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Day-of-the-week b/Lang/AppleScript/Day-of-the-week new file mode 120000 index 0000000000..754fe8195c --- /dev/null +++ b/Lang/AppleScript/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Empty-program b/Lang/AppleScript/Empty-program new file mode 120000 index 0000000000..c565b7da63 --- /dev/null +++ b/Lang/AppleScript/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Evaluate-binomial-coefficients b/Lang/AppleScript/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..2ac3838c92 --- /dev/null +++ b/Lang/AppleScript/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Exceptions b/Lang/AppleScript/Exceptions new file mode 120000 index 0000000000..d854887973 --- /dev/null +++ b/Lang/AppleScript/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Execute-a-system-command b/Lang/AppleScript/Execute-a-system-command new file mode 120000 index 0000000000..795afc5150 --- /dev/null +++ b/Lang/AppleScript/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/AppleScript \ No newline at end of file diff --git a/Lang/Argile/Empty-program b/Lang/Argile/Empty-program new file mode 120000 index 0000000000..cd08656e7f --- /dev/null +++ b/Lang/Argile/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Argile \ No newline at end of file diff --git a/Lang/AutoHotkey/CSV-to-HTML-translation b/Lang/AutoHotkey/CSV-to-HTML-translation new file mode 120000 index 0000000000..2adef07619 --- /dev/null +++ b/Lang/AutoHotkey/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Call-a-foreign-language-function b/Lang/AutoHotkey/Call-a-foreign-language-function new file mode 120000 index 0000000000..9046c9a2de --- /dev/null +++ b/Lang/AutoHotkey/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Call-a-function b/Lang/AutoHotkey/Call-a-function new file mode 120000 index 0000000000..99f8847ba6 --- /dev/null +++ b/Lang/AutoHotkey/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Call-a-function-in-a-shared-library b/Lang/AutoHotkey/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..ac6454326d --- /dev/null +++ b/Lang/AutoHotkey/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Call-an-object-method b/Lang/AutoHotkey/Call-an-object-method new file mode 120000 index 0000000000..ae974e9a58 --- /dev/null +++ b/Lang/AutoHotkey/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Case-sensitivity-of-identifiers b/Lang/AutoHotkey/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..1de5a25481 --- /dev/null +++ b/Lang/AutoHotkey/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Character-codes b/Lang/AutoHotkey/Character-codes new file mode 120000 index 0000000000..10ba20ac04 --- /dev/null +++ b/Lang/AutoHotkey/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Character-matching b/Lang/AutoHotkey/Character-matching new file mode 120000 index 0000000000..8c9c3fdc94 --- /dev/null +++ b/Lang/AutoHotkey/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Colour-bars-Display b/Lang/AutoHotkey/Colour-bars-Display new file mode 120000 index 0000000000..269687cd18 --- /dev/null +++ b/Lang/AutoHotkey/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Colour-pinstripe-Display b/Lang/AutoHotkey/Colour-pinstripe-Display new file mode 120000 index 0000000000..2773a0f5c0 --- /dev/null +++ b/Lang/AutoHotkey/Colour-pinstripe-Display @@ -0,0 +1 @@ +../../Task/Colour-pinstripe-Display/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Combinations b/Lang/AutoHotkey/Combinations new file mode 120000 index 0000000000..8ea2f8bb49 --- /dev/null +++ b/Lang/AutoHotkey/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Command-line-arguments b/Lang/AutoHotkey/Command-line-arguments new file mode 120000 index 0000000000..dd95eae370 --- /dev/null +++ b/Lang/AutoHotkey/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Compare-sorting-algorithms-performance b/Lang/AutoHotkey/Compare-sorting-algorithms-performance new file mode 120000 index 0000000000..bd160ef705 --- /dev/null +++ b/Lang/AutoHotkey/Compare-sorting-algorithms-performance @@ -0,0 +1 @@ +../../Task/Compare-sorting-algorithms-performance/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Compound-data-type b/Lang/AutoHotkey/Compound-data-type new file mode 120000 index 0000000000..c19907c8ce --- /dev/null +++ b/Lang/AutoHotkey/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Conditional-structures b/Lang/AutoHotkey/Conditional-structures new file mode 120000 index 0000000000..28f59b5bf9 --- /dev/null +++ b/Lang/AutoHotkey/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Constrained-random-points-on-a-circle b/Lang/AutoHotkey/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..d03e12d1c2 --- /dev/null +++ b/Lang/AutoHotkey/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Conways-Game-of-Life b/Lang/AutoHotkey/Conways-Game-of-Life new file mode 120000 index 0000000000..c9537295d7 --- /dev/null +++ b/Lang/AutoHotkey/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Count-in-factors b/Lang/AutoHotkey/Count-in-factors new file mode 120000 index 0000000000..69b024d76e --- /dev/null +++ b/Lang/AutoHotkey/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Count-in-octal b/Lang/AutoHotkey/Count-in-octal new file mode 120000 index 0000000000..6c13ea8f4e --- /dev/null +++ b/Lang/AutoHotkey/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Count-occurrences-of-a-substring b/Lang/AutoHotkey/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..e283d94ae2 --- /dev/null +++ b/Lang/AutoHotkey/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Count-the-coins b/Lang/AutoHotkey/Count-the-coins new file mode 120000 index 0000000000..89883f9c75 --- /dev/null +++ b/Lang/AutoHotkey/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Create-a-file b/Lang/AutoHotkey/Create-a-file new file mode 120000 index 0000000000..c610581d84 --- /dev/null +++ b/Lang/AutoHotkey/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Create-a-two-dimensional-array-at-runtime b/Lang/AutoHotkey/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..192d931a02 --- /dev/null +++ b/Lang/AutoHotkey/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Create-an-HTML-table b/Lang/AutoHotkey/Create-an-HTML-table new file mode 120000 index 0000000000..3aa06bc5b8 --- /dev/null +++ b/Lang/AutoHotkey/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Create-an-object-at-a-given-address b/Lang/AutoHotkey/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..c1a3df0f11 --- /dev/null +++ b/Lang/AutoHotkey/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Date-format b/Lang/AutoHotkey/Date-format new file mode 120000 index 0000000000..f6997aebcf --- /dev/null +++ b/Lang/AutoHotkey/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Date-manipulation b/Lang/AutoHotkey/Date-manipulation new file mode 120000 index 0000000000..8b4b288dfe --- /dev/null +++ b/Lang/AutoHotkey/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Day-of-the-week b/Lang/AutoHotkey/Day-of-the-week new file mode 120000 index 0000000000..391e3b07f1 --- /dev/null +++ b/Lang/AutoHotkey/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Documentation b/Lang/AutoHotkey/Documentation new file mode 120000 index 0000000000..0ed597dc14 --- /dev/null +++ b/Lang/AutoHotkey/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Dot-product b/Lang/AutoHotkey/Dot-product new file mode 120000 index 0000000000..38b5575ae4 --- /dev/null +++ b/Lang/AutoHotkey/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Dynamic-variable-names b/Lang/AutoHotkey/Dynamic-variable-names new file mode 120000 index 0000000000..0a873897aa --- /dev/null +++ b/Lang/AutoHotkey/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Echo-server b/Lang/AutoHotkey/Echo-server new file mode 120000 index 0000000000..7ee25ac726 --- /dev/null +++ b/Lang/AutoHotkey/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Empty-program b/Lang/AutoHotkey/Empty-program new file mode 120000 index 0000000000..62adf9827c --- /dev/null +++ b/Lang/AutoHotkey/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Empty-string b/Lang/AutoHotkey/Empty-string new file mode 120000 index 0000000000..f7c9b92e7f --- /dev/null +++ b/Lang/AutoHotkey/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Enforced-immutability b/Lang/AutoHotkey/Enforced-immutability new file mode 120000 index 0000000000..7571a9f421 --- /dev/null +++ b/Lang/AutoHotkey/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Enumerations b/Lang/AutoHotkey/Enumerations new file mode 120000 index 0000000000..2c618266ee --- /dev/null +++ b/Lang/AutoHotkey/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Ethiopian-multiplication b/Lang/AutoHotkey/Ethiopian-multiplication new file mode 120000 index 0000000000..18b5345f51 --- /dev/null +++ b/Lang/AutoHotkey/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Evaluate-binomial-coefficients b/Lang/AutoHotkey/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..00a2db5ad4 --- /dev/null +++ b/Lang/AutoHotkey/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Even-or-odd b/Lang/AutoHotkey/Even-or-odd new file mode 120000 index 0000000000..bbf87889b2 --- /dev/null +++ b/Lang/AutoHotkey/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Events b/Lang/AutoHotkey/Events new file mode 120000 index 0000000000..9e69857927 --- /dev/null +++ b/Lang/AutoHotkey/Events @@ -0,0 +1 @@ +../../Task/Events/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Evolutionary-algorithm b/Lang/AutoHotkey/Evolutionary-algorithm new file mode 120000 index 0000000000..6e3c5dcef7 --- /dev/null +++ b/Lang/AutoHotkey/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Exceptions b/Lang/AutoHotkey/Exceptions new file mode 120000 index 0000000000..759c59de1b --- /dev/null +++ b/Lang/AutoHotkey/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/AutoHotkey/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..99544e2136 --- /dev/null +++ b/Lang/AutoHotkey/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Executable-library b/Lang/AutoHotkey/Executable-library new file mode 120000 index 0000000000..377940fb98 --- /dev/null +++ b/Lang/AutoHotkey/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Execute-HQ9+ b/Lang/AutoHotkey/Execute-HQ9+ new file mode 120000 index 0000000000..764d29bf8a --- /dev/null +++ b/Lang/AutoHotkey/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Execute-a-system-command b/Lang/AutoHotkey/Execute-a-system-command new file mode 120000 index 0000000000..57ff124c2f --- /dev/null +++ b/Lang/AutoHotkey/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Exponentiation-operator b/Lang/AutoHotkey/Exponentiation-operator new file mode 120000 index 0000000000..669c469ec6 --- /dev/null +++ b/Lang/AutoHotkey/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoIt/CSV-to-HTML-translation b/Lang/AutoIt/CSV-to-HTML-translation new file mode 120000 index 0000000000..bfb0b429d4 --- /dev/null +++ b/Lang/AutoIt/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Character-matching b/Lang/AutoIt/Character-matching new file mode 120000 index 0000000000..d22ba39a43 --- /dev/null +++ b/Lang/AutoIt/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Create-a-two-dimensional-array-at-runtime b/Lang/AutoIt/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..e75fe84ee7 --- /dev/null +++ b/Lang/AutoIt/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Day-of-the-week b/Lang/AutoIt/Day-of-the-week new file mode 120000 index 0000000000..c7d5aeea4a --- /dev/null +++ b/Lang/AutoIt/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Dutch-national-flag-problem b/Lang/AutoIt/Dutch-national-flag-problem new file mode 120000 index 0000000000..74d1c7ba9d --- /dev/null +++ b/Lang/AutoIt/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Empty-program b/Lang/AutoIt/Empty-program new file mode 120000 index 0000000000..30bd171f84 --- /dev/null +++ b/Lang/AutoIt/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Ethiopian-multiplication b/Lang/AutoIt/Ethiopian-multiplication new file mode 120000 index 0000000000..e5910cddde --- /dev/null +++ b/Lang/AutoIt/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/AutoIt \ No newline at end of file diff --git a/Lang/Axiom/Continued-fraction b/Lang/Axiom/Continued-fraction new file mode 120000 index 0000000000..c05b783be5 --- /dev/null +++ b/Lang/Axiom/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Axiom \ No newline at end of file diff --git a/Lang/BASIC/Character-codes b/Lang/BASIC/Character-codes new file mode 120000 index 0000000000..a9a36e9319 --- /dev/null +++ b/Lang/BASIC/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Character-matching b/Lang/BASIC/Character-matching new file mode 120000 index 0000000000..c685afa92d --- /dev/null +++ b/Lang/BASIC/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Command-line-arguments b/Lang/BASIC/Command-line-arguments new file mode 120000 index 0000000000..2cb8b02285 --- /dev/null +++ b/Lang/BASIC/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Compile-time-calculation b/Lang/BASIC/Compile-time-calculation new file mode 120000 index 0000000000..14d44490e7 --- /dev/null +++ b/Lang/BASIC/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Compound-data-type b/Lang/BASIC/Compound-data-type new file mode 120000 index 0000000000..edfe32b305 --- /dev/null +++ b/Lang/BASIC/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Conditional-structures b/Lang/BASIC/Conditional-structures new file mode 120000 index 0000000000..ee71212a96 --- /dev/null +++ b/Lang/BASIC/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Count-in-octal b/Lang/BASIC/Count-in-octal new file mode 120000 index 0000000000..ae6d9f81e0 --- /dev/null +++ b/Lang/BASIC/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Count-occurrences-of-a-substring b/Lang/BASIC/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..2f890850a0 --- /dev/null +++ b/Lang/BASIC/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Create-a-file b/Lang/BASIC/Create-a-file new file mode 120000 index 0000000000..0cdfd7aea2 --- /dev/null +++ b/Lang/BASIC/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Date-format b/Lang/BASIC/Date-format new file mode 120000 index 0000000000..e062f36016 --- /dev/null +++ b/Lang/BASIC/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Digital-root b/Lang/BASIC/Digital-root new file mode 120000 index 0000000000..8de34cbd9b --- /dev/null +++ b/Lang/BASIC/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Discordian-date b/Lang/BASIC/Discordian-date new file mode 120000 index 0000000000..00be27020c --- /dev/null +++ b/Lang/BASIC/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Draw-a-sphere b/Lang/BASIC/Draw-a-sphere new file mode 120000 index 0000000000..f408c5e3c7 --- /dev/null +++ b/Lang/BASIC/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Dynamic-variable-names b/Lang/BASIC/Dynamic-variable-names new file mode 120000 index 0000000000..47313540e4 --- /dev/null +++ b/Lang/BASIC/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Empty-program b/Lang/BASIC/Empty-program new file mode 120000 index 0000000000..b77acd37eb --- /dev/null +++ b/Lang/BASIC/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Empty-string b/Lang/BASIC/Empty-string new file mode 120000 index 0000000000..7391494748 --- /dev/null +++ b/Lang/BASIC/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Enforced-immutability b/Lang/BASIC/Enforced-immutability new file mode 120000 index 0000000000..cb0d1a7696 --- /dev/null +++ b/Lang/BASIC/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Enumerations b/Lang/BASIC/Enumerations new file mode 120000 index 0000000000..31cc5def23 --- /dev/null +++ b/Lang/BASIC/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Ethiopian-multiplication b/Lang/BASIC/Ethiopian-multiplication new file mode 120000 index 0000000000..94be458bb2 --- /dev/null +++ b/Lang/BASIC/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Even-or-odd b/Lang/BASIC/Even-or-odd new file mode 120000 index 0000000000..6abc779b43 --- /dev/null +++ b/Lang/BASIC/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Execute-a-system-command b/Lang/BASIC/Execute-a-system-command new file mode 120000 index 0000000000..3524d9a372 --- /dev/null +++ b/Lang/BASIC/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Exponentiation-operator b/Lang/BASIC/Exponentiation-operator new file mode 120000 index 0000000000..2a5f0c078b --- /dev/null +++ b/Lang/BASIC/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/BASIC \ No newline at end of file diff --git a/Lang/BASIC256/Conways-Game-of-Life b/Lang/BASIC256/Conways-Game-of-Life new file mode 120000 index 0000000000..eb5e0bfb2a --- /dev/null +++ b/Lang/BASIC256/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/BASIC256 \ No newline at end of file diff --git a/Lang/BBC-BASIC/CSV-to-HTML-translation b/Lang/BBC-BASIC/CSV-to-HTML-translation new file mode 120000 index 0000000000..e28b48522c --- /dev/null +++ b/Lang/BBC-BASIC/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Calendar-for-real-programmers b/Lang/BBC-BASIC/Calendar-for-real-programmers new file mode 120000 index 0000000000..e970caf6e2 --- /dev/null +++ b/Lang/BBC-BASIC/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Call-a-foreign-language-function b/Lang/BBC-BASIC/Call-a-foreign-language-function new file mode 120000 index 0000000000..0af3540bb1 --- /dev/null +++ b/Lang/BBC-BASIC/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Call-a-function-in-a-shared-library b/Lang/BBC-BASIC/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..2034616947 --- /dev/null +++ b/Lang/BBC-BASIC/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Case-sensitivity-of-identifiers b/Lang/BBC-BASIC/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..e1780e6ba1 --- /dev/null +++ b/Lang/BBC-BASIC/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Character-codes b/Lang/BBC-BASIC/Character-codes new file mode 120000 index 0000000000..a09c8f4711 --- /dev/null +++ b/Lang/BBC-BASIC/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Character-matching b/Lang/BBC-BASIC/Character-matching new file mode 120000 index 0000000000..c281710c7f --- /dev/null +++ b/Lang/BBC-BASIC/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Cholesky-decomposition b/Lang/BBC-BASIC/Cholesky-decomposition new file mode 120000 index 0000000000..9ee56d9371 --- /dev/null +++ b/Lang/BBC-BASIC/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Colour-bars-Display b/Lang/BBC-BASIC/Colour-bars-Display new file mode 120000 index 0000000000..2bab2092e9 --- /dev/null +++ b/Lang/BBC-BASIC/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Colour-pinstripe-Display b/Lang/BBC-BASIC/Colour-pinstripe-Display new file mode 120000 index 0000000000..d4c44631b6 --- /dev/null +++ b/Lang/BBC-BASIC/Colour-pinstripe-Display @@ -0,0 +1 @@ +../../Task/Colour-pinstripe-Display/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Colour-pinstripe-Printer b/Lang/BBC-BASIC/Colour-pinstripe-Printer new file mode 120000 index 0000000000..5bb3c25856 --- /dev/null +++ b/Lang/BBC-BASIC/Colour-pinstripe-Printer @@ -0,0 +1 @@ +../../Task/Colour-pinstripe-Printer/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Combinations b/Lang/BBC-BASIC/Combinations new file mode 120000 index 0000000000..6b7d034c95 --- /dev/null +++ b/Lang/BBC-BASIC/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Combinations-with-repetitions b/Lang/BBC-BASIC/Combinations-with-repetitions new file mode 120000 index 0000000000..58dd9d80be --- /dev/null +++ b/Lang/BBC-BASIC/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Command-line-arguments b/Lang/BBC-BASIC/Command-line-arguments new file mode 120000 index 0000000000..58e6169986 --- /dev/null +++ b/Lang/BBC-BASIC/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Compare-sorting-algorithms-performance b/Lang/BBC-BASIC/Compare-sorting-algorithms-performance new file mode 120000 index 0000000000..1730d91e14 --- /dev/null +++ b/Lang/BBC-BASIC/Compare-sorting-algorithms-performance @@ -0,0 +1 @@ +../../Task/Compare-sorting-algorithms-performance/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Compound-data-type b/Lang/BBC-BASIC/Compound-data-type new file mode 120000 index 0000000000..66355486f1 --- /dev/null +++ b/Lang/BBC-BASIC/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Concurrent-computing b/Lang/BBC-BASIC/Concurrent-computing new file mode 120000 index 0000000000..4ee46f8d32 --- /dev/null +++ b/Lang/BBC-BASIC/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Conditional-structures b/Lang/BBC-BASIC/Conditional-structures new file mode 120000 index 0000000000..bc0d5c83d3 --- /dev/null +++ b/Lang/BBC-BASIC/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Constrained-random-points-on-a-circle b/Lang/BBC-BASIC/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..8a32de444b --- /dev/null +++ b/Lang/BBC-BASIC/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Continued-fraction b/Lang/BBC-BASIC/Continued-fraction new file mode 120000 index 0000000000..a2c167fccd --- /dev/null +++ b/Lang/BBC-BASIC/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Conways-Game-of-Life b/Lang/BBC-BASIC/Conways-Game-of-Life new file mode 120000 index 0000000000..c1a3803646 --- /dev/null +++ b/Lang/BBC-BASIC/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Count-in-factors b/Lang/BBC-BASIC/Count-in-factors new file mode 120000 index 0000000000..c160ba2a75 --- /dev/null +++ b/Lang/BBC-BASIC/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Count-in-octal b/Lang/BBC-BASIC/Count-in-octal new file mode 120000 index 0000000000..deace67645 --- /dev/null +++ b/Lang/BBC-BASIC/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Count-occurrences-of-a-substring b/Lang/BBC-BASIC/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..47e7a5048c --- /dev/null +++ b/Lang/BBC-BASIC/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Count-the-coins b/Lang/BBC-BASIC/Count-the-coins new file mode 120000 index 0000000000..463ea8345e --- /dev/null +++ b/Lang/BBC-BASIC/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Create-a-file b/Lang/BBC-BASIC/Create-a-file new file mode 120000 index 0000000000..4a2f9f340a --- /dev/null +++ b/Lang/BBC-BASIC/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Create-a-two-dimensional-array-at-runtime b/Lang/BBC-BASIC/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..e199dc63ca --- /dev/null +++ b/Lang/BBC-BASIC/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Create-an-HTML-table b/Lang/BBC-BASIC/Create-an-HTML-table new file mode 120000 index 0000000000..7f7f5cd770 --- /dev/null +++ b/Lang/BBC-BASIC/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Create-an-object-at-a-given-address b/Lang/BBC-BASIC/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..d775989d4e --- /dev/null +++ b/Lang/BBC-BASIC/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/DNS-query b/Lang/BBC-BASIC/DNS-query new file mode 120000 index 0000000000..1eb3e9d666 --- /dev/null +++ b/Lang/BBC-BASIC/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Date-format b/Lang/BBC-BASIC/Date-format new file mode 120000 index 0000000000..878e65f133 --- /dev/null +++ b/Lang/BBC-BASIC/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Date-manipulation b/Lang/BBC-BASIC/Date-manipulation new file mode 120000 index 0000000000..8a0023cae9 --- /dev/null +++ b/Lang/BBC-BASIC/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Day-of-the-week b/Lang/BBC-BASIC/Day-of-the-week new file mode 120000 index 0000000000..f1dc6e27e8 --- /dev/null +++ b/Lang/BBC-BASIC/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Deal-cards-for-FreeCell b/Lang/BBC-BASIC/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..62509c4e4e --- /dev/null +++ b/Lang/BBC-BASIC/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Deconvolution-1D b/Lang/BBC-BASIC/Deconvolution-1D new file mode 120000 index 0000000000..bf077c2775 --- /dev/null +++ b/Lang/BBC-BASIC/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Determine-if-only-one-instance-is-running b/Lang/BBC-BASIC/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..4ba8905f57 --- /dev/null +++ b/Lang/BBC-BASIC/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Digital-root b/Lang/BBC-BASIC/Digital-root new file mode 120000 index 0000000000..b5eb363669 --- /dev/null +++ b/Lang/BBC-BASIC/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Dinesmans-multiple-dwelling-problem b/Lang/BBC-BASIC/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..6cdc3b0024 --- /dev/null +++ b/Lang/BBC-BASIC/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Dining-philosophers b/Lang/BBC-BASIC/Dining-philosophers new file mode 120000 index 0000000000..136371d279 --- /dev/null +++ b/Lang/BBC-BASIC/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Discordian-date b/Lang/BBC-BASIC/Discordian-date new file mode 120000 index 0000000000..a040ccc519 --- /dev/null +++ b/Lang/BBC-BASIC/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Dot-product b/Lang/BBC-BASIC/Dot-product new file mode 120000 index 0000000000..633bae9732 --- /dev/null +++ b/Lang/BBC-BASIC/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Doubly-linked-list-Element-definition b/Lang/BBC-BASIC/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..e5cb6a5eca --- /dev/null +++ b/Lang/BBC-BASIC/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Doubly-linked-list-Element-insertion b/Lang/BBC-BASIC/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..fc293fcd3a --- /dev/null +++ b/Lang/BBC-BASIC/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Doubly-linked-list-Traversal b/Lang/BBC-BASIC/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..23c10770b6 --- /dev/null +++ b/Lang/BBC-BASIC/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Draw-a-cuboid b/Lang/BBC-BASIC/Draw-a-cuboid new file mode 120000 index 0000000000..30e68f2545 --- /dev/null +++ b/Lang/BBC-BASIC/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Draw-a-sphere b/Lang/BBC-BASIC/Draw-a-sphere new file mode 120000 index 0000000000..9b98fd11f1 --- /dev/null +++ b/Lang/BBC-BASIC/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Dutch-national-flag-problem b/Lang/BBC-BASIC/Dutch-national-flag-problem new file mode 120000 index 0000000000..fed2b1393d --- /dev/null +++ b/Lang/BBC-BASIC/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Dynamic-variable-names b/Lang/BBC-BASIC/Dynamic-variable-names new file mode 120000 index 0000000000..ac5c6c76ef --- /dev/null +++ b/Lang/BBC-BASIC/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Echo-server b/Lang/BBC-BASIC/Echo-server new file mode 120000 index 0000000000..e6685c8bb5 --- /dev/null +++ b/Lang/BBC-BASIC/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Element-wise-operations b/Lang/BBC-BASIC/Element-wise-operations new file mode 120000 index 0000000000..157bd2c268 --- /dev/null +++ b/Lang/BBC-BASIC/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Empty-directory b/Lang/BBC-BASIC/Empty-directory new file mode 120000 index 0000000000..2efc36e0ee --- /dev/null +++ b/Lang/BBC-BASIC/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Empty-program b/Lang/BBC-BASIC/Empty-program new file mode 120000 index 0000000000..2453735ba7 --- /dev/null +++ b/Lang/BBC-BASIC/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Empty-string b/Lang/BBC-BASIC/Empty-string new file mode 120000 index 0000000000..0fb6b727de --- /dev/null +++ b/Lang/BBC-BASIC/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Enforced-immutability b/Lang/BBC-BASIC/Enforced-immutability new file mode 120000 index 0000000000..cb02eca9dd --- /dev/null +++ b/Lang/BBC-BASIC/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Equilibrium-index b/Lang/BBC-BASIC/Equilibrium-index new file mode 120000 index 0000000000..dfb677776b --- /dev/null +++ b/Lang/BBC-BASIC/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Ethiopian-multiplication b/Lang/BBC-BASIC/Ethiopian-multiplication new file mode 120000 index 0000000000..4c8585062b --- /dev/null +++ b/Lang/BBC-BASIC/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Euler-method b/Lang/BBC-BASIC/Euler-method new file mode 120000 index 0000000000..955665ab10 --- /dev/null +++ b/Lang/BBC-BASIC/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Evaluate-binomial-coefficients b/Lang/BBC-BASIC/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..19e10e5d56 --- /dev/null +++ b/Lang/BBC-BASIC/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Even-or-odd b/Lang/BBC-BASIC/Even-or-odd new file mode 120000 index 0000000000..5287e5f7bf --- /dev/null +++ b/Lang/BBC-BASIC/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Events b/Lang/BBC-BASIC/Events new file mode 120000 index 0000000000..6ff8cc556a --- /dev/null +++ b/Lang/BBC-BASIC/Events @@ -0,0 +1 @@ +../../Task/Events/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Evolutionary-algorithm b/Lang/BBC-BASIC/Evolutionary-algorithm new file mode 120000 index 0000000000..e1480da10c --- /dev/null +++ b/Lang/BBC-BASIC/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Exceptions b/Lang/BBC-BASIC/Exceptions new file mode 120000 index 0000000000..d7f620b824 --- /dev/null +++ b/Lang/BBC-BASIC/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/BBC-BASIC/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..047ae6aec0 --- /dev/null +++ b/Lang/BBC-BASIC/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Executable-library b/Lang/BBC-BASIC/Executable-library new file mode 120000 index 0000000000..099318e3b7 --- /dev/null +++ b/Lang/BBC-BASIC/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Execute-HQ9+ b/Lang/BBC-BASIC/Execute-HQ9+ new file mode 120000 index 0000000000..1f31d2b842 --- /dev/null +++ b/Lang/BBC-BASIC/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Execute-a-system-command b/Lang/BBC-BASIC/Execute-a-system-command new file mode 120000 index 0000000000..1b01d38060 --- /dev/null +++ b/Lang/BBC-BASIC/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Exponentiation-operator b/Lang/BBC-BASIC/Exponentiation-operator new file mode 120000 index 0000000000..8de03527ea --- /dev/null +++ b/Lang/BBC-BASIC/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/BBC-BASIC \ No newline at end of file diff --git a/Lang/Batch-File/Command-line-arguments b/Lang/Batch-File/Command-line-arguments new file mode 120000 index 0000000000..08bc78fff3 --- /dev/null +++ b/Lang/Batch-File/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Create-a-file b/Lang/Batch-File/Create-a-file new file mode 120000 index 0000000000..375d0ca207 --- /dev/null +++ b/Lang/Batch-File/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Dynamic-variable-names b/Lang/Batch-File/Dynamic-variable-names new file mode 120000 index 0000000000..98413e84b4 --- /dev/null +++ b/Lang/Batch-File/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Empty-program b/Lang/Batch-File/Empty-program new file mode 120000 index 0000000000..9bfe5cb2c5 --- /dev/null +++ b/Lang/Batch-File/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Batch-File \ No newline at end of file diff --git a/Lang/Befunge/Character-codes b/Lang/Befunge/Character-codes new file mode 120000 index 0000000000..da77a29466 --- /dev/null +++ b/Lang/Befunge/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Conditional-structures b/Lang/Befunge/Conditional-structures new file mode 120000 index 0000000000..20e0a1754b --- /dev/null +++ b/Lang/Befunge/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Befunge \ No newline at end of file diff --git a/Lang/Bori/Conditional-structures b/Lang/Bori/Conditional-structures new file mode 120000 index 0000000000..8a75947df4 --- /dev/null +++ b/Lang/Bori/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Bori \ No newline at end of file diff --git a/Lang/Bracmat/Character-matching b/Lang/Bracmat/Character-matching new file mode 120000 index 0000000000..2dd0079e40 --- /dev/null +++ b/Lang/Bracmat/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Combinations b/Lang/Bracmat/Combinations new file mode 120000 index 0000000000..0f9bf047fd --- /dev/null +++ b/Lang/Bracmat/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Command-line-arguments b/Lang/Bracmat/Command-line-arguments new file mode 120000 index 0000000000..6949a683ea --- /dev/null +++ b/Lang/Bracmat/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Compound-data-type b/Lang/Bracmat/Compound-data-type new file mode 120000 index 0000000000..82bc8ddad6 --- /dev/null +++ b/Lang/Bracmat/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Conditional-structures b/Lang/Bracmat/Conditional-structures new file mode 120000 index 0000000000..cd3b69249b --- /dev/null +++ b/Lang/Bracmat/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Count-in-octal b/Lang/Bracmat/Count-in-octal new file mode 120000 index 0000000000..7f415220d0 --- /dev/null +++ b/Lang/Bracmat/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Count-occurrences-of-a-substring b/Lang/Bracmat/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..f6d33c0977 --- /dev/null +++ b/Lang/Bracmat/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Create-a-file b/Lang/Bracmat/Create-a-file new file mode 120000 index 0000000000..8d785b08b8 --- /dev/null +++ b/Lang/Bracmat/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Deal-cards-for-FreeCell b/Lang/Bracmat/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..1c4c42771f --- /dev/null +++ b/Lang/Bracmat/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Dinesmans-multiple-dwelling-problem b/Lang/Bracmat/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..73b914d434 --- /dev/null +++ b/Lang/Bracmat/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Dot-product b/Lang/Bracmat/Dot-product new file mode 120000 index 0000000000..41e98e7974 --- /dev/null +++ b/Lang/Bracmat/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Dynamic-variable-names b/Lang/Bracmat/Dynamic-variable-names new file mode 120000 index 0000000000..bb78c3be48 --- /dev/null +++ b/Lang/Bracmat/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Empty-program b/Lang/Bracmat/Empty-program new file mode 120000 index 0000000000..2b0fc29e9f --- /dev/null +++ b/Lang/Bracmat/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Empty-string b/Lang/Bracmat/Empty-string new file mode 120000 index 0000000000..f947f3b75a --- /dev/null +++ b/Lang/Bracmat/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Evaluate-binomial-coefficients b/Lang/Bracmat/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..fd27192584 --- /dev/null +++ b/Lang/Bracmat/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Even-or-odd b/Lang/Bracmat/Even-or-odd new file mode 120000 index 0000000000..b1f2ed5484 --- /dev/null +++ b/Lang/Bracmat/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Execute-a-system-command b/Lang/Bracmat/Execute-a-system-command new file mode 120000 index 0000000000..14adc43500 --- /dev/null +++ b/Lang/Bracmat/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Bracmat \ No newline at end of file diff --git a/Lang/Brainf---/Conditional-structures b/Lang/Brainf---/Conditional-structures new file mode 120000 index 0000000000..35f6570cca --- /dev/null +++ b/Lang/Brainf---/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Count-in-octal b/Lang/Brainf---/Count-in-octal new file mode 120000 index 0000000000..189d4177a4 --- /dev/null +++ b/Lang/Brainf---/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Even-or-odd b/Lang/Brainf---/Even-or-odd new file mode 120000 index 0000000000..8ec68735b4 --- /dev/null +++ b/Lang/Brainf---/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Brainf--- \ No newline at end of file diff --git a/Lang/Brat/Execute-a-system-command b/Lang/Brat/Execute-a-system-command new file mode 120000 index 0000000000..7eb82e55c6 --- /dev/null +++ b/Lang/Brat/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Brat \ No newline at end of file diff --git a/Lang/Brat/Exponentiation-operator b/Lang/Brat/Exponentiation-operator new file mode 120000 index 0000000000..57e8817a42 --- /dev/null +++ b/Lang/Brat/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Brat \ No newline at end of file diff --git a/Lang/Brlcad/Case-sensitivity-of-identifiers b/Lang/Brlcad/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..e4956e4325 --- /dev/null +++ b/Lang/Brlcad/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Brlcad \ No newline at end of file diff --git a/Lang/Brlcad/Draw-a-cuboid b/Lang/Brlcad/Draw-a-cuboid new file mode 120000 index 0000000000..91ccd1e272 --- /dev/null +++ b/Lang/Brlcad/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Brlcad \ No newline at end of file diff --git a/Lang/Brlcad/Draw-a-sphere b/Lang/Brlcad/Draw-a-sphere new file mode 120000 index 0000000000..850fab02cc --- /dev/null +++ b/Lang/Brlcad/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Brlcad \ No newline at end of file diff --git a/Lang/Brlcad/Empty-program b/Lang/Brlcad/Empty-program new file mode 120000 index 0000000000..5ed5873831 --- /dev/null +++ b/Lang/Brlcad/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Brlcad \ No newline at end of file diff --git a/Lang/Brlcad/Execute-a-system-command b/Lang/Brlcad/Execute-a-system-command new file mode 120000 index 0000000000..a9a7e902de --- /dev/null +++ b/Lang/Brlcad/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Brlcad \ No newline at end of file diff --git a/Lang/Burlesque/Conditional-structures b/Lang/Burlesque/Conditional-structures new file mode 120000 index 0000000000..44b7b5bdba --- /dev/null +++ b/Lang/Burlesque/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Evaluate-binomial-coefficients b/Lang/Burlesque/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..dcfcee8e53 --- /dev/null +++ b/Lang/Burlesque/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Even-or-odd b/Lang/Burlesque/Even-or-odd new file mode 120000 index 0000000000..b653bcc483 --- /dev/null +++ b/Lang/Burlesque/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Burlesque \ No newline at end of file diff --git a/Lang/C++-CLI/0DESCRIPTION b/Lang/C++-CLI/0DESCRIPTION new file mode 100644 index 0000000000..2b5a6ed4f2 --- /dev/null +++ b/Lang/C++-CLI/0DESCRIPTION @@ -0,0 +1,2 @@ +{{language}}{{stub}} +C++/CLI is a language created by Microsoft which extends C++ (similar to how C++ extends C) to support the CLI (.NET) framework. \ No newline at end of file diff --git a/Lang/C++-CLI/Color-of-a-screen-pixel b/Lang/C++-CLI/Color-of-a-screen-pixel new file mode 120000 index 0000000000..1df27310c6 --- /dev/null +++ b/Lang/C++-CLI/Color-of-a-screen-pixel @@ -0,0 +1 @@ +../../Task/Color-of-a-screen-pixel/C++-CLI \ No newline at end of file diff --git a/Lang/C++/0DESCRIPTION b/Lang/C++/0DESCRIPTION new file mode 100644 index 0000000000..a40d989057 --- /dev/null +++ b/Lang/C++/0DESCRIPTION @@ -0,0 +1,30 @@ +{{language|C++ +|exec=machine +|safety=both +|gc=no +|parampass=both +|checking=both +|express=explicit +|strength=strong +|compat=both +|tags=cpp +|hopl id=1202 +|LCT=yes +|bnf=http://cpp.comsci.us/syntax/statement/index.html}}{{codepad}}{{allows|Network access}}{{allows|Database access +}}{{allows|Concurrency}}{{provides|Run time polymorphism}}{{provides|Compile time polymorphism}}{{allows|Windowing UI}}{{allows|Graphics}}{{allows|OpenGL}}{{allows|Dynamic linking}}{{provides|File access}}{{allows|File system access}}{{provides|Objects}}{{allows|Signal handling}}{{provides|Mutable state}} +'''C++''' is named after the [[derived from::compatible with::C]] language, from which it is derived. C++ extends C into becoming an [[object-oriented language]]. However, unlike other object-oriented languages, it doesn't try to force you into [[object-oriented programming]], but is a multi-[[:Category:Programming Paradigms|paradigm]] language. Besides conventional [[procedural programming]] and object-oriented programming, it also supports [[generic programming]]. + +The ++ in C++ is some what of an inside joke, in that C++ is C with a Post Increment operator attached, thus C++ is C + 1; however, this interpretation has the flaw that post-increment increments the value ''after'' returning the value, so the post-increment expression still evaluates to the value before the increment. + +If you can't find an implementation for your task in the C++ category below, please look in the [[C]] category, as many of the tasks can be implemented identically in C and C++. + +==Versions== +* '''C++98''' is the version of C++ standardized by ISO in 1998. It is the most commonly used and supported version of the language. The term "C++" usually refers to C++98. +* '''C++03''' is a minor improvement to C++98, standardized by ISO in 2003. +* '''TR1''' (Technical Report 1) is a proposal for extensions to the C++ standard library. It was published in 2007. Many of its proposals made it into C++11. Many compilers support it, but put its headers in a different directory. +* '''C++11''' (formerly called '''C++0x''') is a significant improvement, adding many new language features and libraries. It was standardized by ISO in 2011. It is not completely supported by many, if any, compilers, but most of its features are available in [[GCC]] [http://gcc.gnu.org/projects/cxx0x.html] and [[Clang]] [http://clang.llvm.org/cxx_status.html]. + +{{language programming paradigm|Imperative}} +{{language programming paradigm|Object-oriented}} +{{language programming paradigm|Generic}} +
\ No newline at end of file diff --git a/Lang/C++/100-doors b/Lang/C++/100-doors new file mode 120000 index 0000000000..96df4a761e --- /dev/null +++ b/Lang/C++/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/C++ \ No newline at end of file diff --git a/Lang/C++/24-game b/Lang/C++/24-game new file mode 120000 index 0000000000..5353966124 --- /dev/null +++ b/Lang/C++/24-game @@ -0,0 +1 @@ +../../Task/24-game/C++ \ No newline at end of file diff --git a/Lang/C++/99-Bottles-of-Beer b/Lang/C++/99-Bottles-of-Beer new file mode 120000 index 0000000000..e0a12a71f2 --- /dev/null +++ b/Lang/C++/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/C++ \ No newline at end of file diff --git a/Lang/C++/A+B b/Lang/C++/A+B new file mode 120000 index 0000000000..2d82269630 --- /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..5a66f8b092 --- /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..2865f9f91c --- /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++/Ackermann-function b/Lang/C++/Ackermann-function new file mode 120000 index 0000000000..de471fb697 --- /dev/null +++ b/Lang/C++/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/C++ \ No newline at end of file diff --git a/Lang/C++/Anagrams b/Lang/C++/Anagrams new file mode 120000 index 0000000000..6621a70ef3 --- /dev/null +++ b/Lang/C++/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/C++ \ No newline at end of file diff --git a/Lang/C++/Animate-a-pendulum b/Lang/C++/Animate-a-pendulum new file mode 120000 index 0000000000..4f46f900e2 --- /dev/null +++ b/Lang/C++/Animate-a-pendulum @@ -0,0 +1 @@ +../../Task/Animate-a-pendulum/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..b13b7af1d8 --- /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..ccb8852fb4 --- /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++/Arena-storage-pool b/Lang/C++/Arena-storage-pool new file mode 120000 index 0000000000..2397f917c6 --- /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..6c32243a82 --- /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-Integer b/Lang/C++/Arithmetic-Integer new file mode 120000 index 0000000000..f96e1d233c --- /dev/null +++ b/Lang/C++/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/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..1e97dd14e4 --- /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-evaluation b/Lang/C++/Arithmetic-evaluation new file mode 120000 index 0000000000..275eaddb58 --- /dev/null +++ b/Lang/C++/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/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..86e37727bb --- /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..5bd2765b16 --- /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++/Arrays b/Lang/C++/Arrays new file mode 120000 index 0000000000..01cdbf0a03 --- /dev/null +++ b/Lang/C++/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/C++ \ No newline at end of file diff --git a/Lang/C++/Assertions b/Lang/C++/Assertions new file mode 120000 index 0000000000..5a5dd4a460 --- /dev/null +++ b/Lang/C++/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/C++ \ No newline at end of file diff --git a/Lang/C++/Associative-array-Creation b/Lang/C++/Associative-array-Creation new file mode 120000 index 0000000000..3934ef985d --- /dev/null +++ b/Lang/C++/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/C++ \ No newline at end of file diff --git a/Lang/C++/Associative-array-Iteration b/Lang/C++/Associative-array-Iteration new file mode 120000 index 0000000000..4b10b8efc0 --- /dev/null +++ b/Lang/C++/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/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..e9d5a71beb --- /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-Median b/Lang/C++/Averages-Median new file mode 120000 index 0000000000..7fad8fa076 --- /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-Mode b/Lang/C++/Averages-Mode new file mode 120000 index 0000000000..06b97a5f92 --- /dev/null +++ b/Lang/C++/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/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..0d6943c9a7 --- /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..1491f928b7 --- /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..fd8428c094 --- /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/C++/Balanced-brackets b/Lang/C++/Balanced-brackets new file mode 120000 index 0000000000..6180e022c7 --- /dev/null +++ b/Lang/C++/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/C++ \ No newline at end of file diff --git a/Lang/C++/Binary-search b/Lang/C++/Binary-search new file mode 120000 index 0000000000..768c2e64ec --- /dev/null +++ b/Lang/C++/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/C++ \ No newline at end of file diff --git a/Lang/C++/Bitmap b/Lang/C++/Bitmap new file mode 120000 index 0000000000..f9b19598de --- /dev/null +++ b/Lang/C++/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/C++ \ No newline at end of file diff --git a/Lang/C++/Bitmap-Bresenhams-line-algorithm b/Lang/C++/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..2553a18aef --- /dev/null +++ b/Lang/C++/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/C++ \ No newline at end of file diff --git a/Lang/C++/Bitwise-operations b/Lang/C++/Bitwise-operations new file mode 120000 index 0000000000..4a89defb5b --- /dev/null +++ b/Lang/C++/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/C++ \ No newline at end of file diff --git a/Lang/C++/Box-the-compass b/Lang/C++/Box-the-compass new file mode 120000 index 0000000000..a1e03d3a67 --- /dev/null +++ b/Lang/C++/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/C++ \ No newline at end of file diff --git a/Lang/C++/Break-OO-privacy b/Lang/C++/Break-OO-privacy new file mode 120000 index 0000000000..815ee77a22 --- /dev/null +++ b/Lang/C++/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/C++ \ No newline at end of file diff --git a/Lang/C++/Bulls-and-cows b/Lang/C++/Bulls-and-cows new file mode 120000 index 0000000000..949d1b468e --- /dev/null +++ b/Lang/C++/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/C++ \ No newline at end of file diff --git a/Lang/C++/CSV-to-HTML-translation b/Lang/C++/CSV-to-HTML-translation new file mode 120000 index 0000000000..114b8631c8 --- /dev/null +++ b/Lang/C++/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/C++ \ No newline at end of file diff --git a/Lang/C++/Caesar-cipher b/Lang/C++/Caesar-cipher new file mode 120000 index 0000000000..500989457d --- /dev/null +++ b/Lang/C++/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/C++ \ No newline at end of file diff --git a/Lang/C++/Call-a-foreign-language-function b/Lang/C++/Call-a-foreign-language-function new file mode 120000 index 0000000000..93cbde9113 --- /dev/null +++ b/Lang/C++/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/C++ \ No newline at end of file diff --git a/Lang/C++/Call-an-object-method b/Lang/C++/Call-an-object-method new file mode 120000 index 0000000000..8042ad59ed --- /dev/null +++ b/Lang/C++/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/C++ \ No newline at end of file diff --git a/Lang/C++/Character-codes b/Lang/C++/Character-codes new file mode 120000 index 0000000000..5ebe2488c8 --- /dev/null +++ b/Lang/C++/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/C++ \ No newline at end of file diff --git a/Lang/C++/Character-matching b/Lang/C++/Character-matching new file mode 120000 index 0000000000..3c821871c8 --- /dev/null +++ b/Lang/C++/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/C++ \ No newline at end of file diff --git a/Lang/C++/Check-that-file-exists b/Lang/C++/Check-that-file-exists new file mode 120000 index 0000000000..63fc9d7c3d --- /dev/null +++ b/Lang/C++/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/C++ \ No newline at end of file diff --git a/Lang/C++/Classes b/Lang/C++/Classes new file mode 120000 index 0000000000..9592402a36 --- /dev/null +++ b/Lang/C++/Classes @@ -0,0 +1 @@ +../../Task/Classes/C++ \ No newline at end of file diff --git a/Lang/C++/Collections b/Lang/C++/Collections new file mode 120000 index 0000000000..415b1020da --- /dev/null +++ b/Lang/C++/Collections @@ -0,0 +1 @@ +../../Task/Collections/C++ \ No newline at end of file diff --git a/Lang/C++/Colour-bars-Display b/Lang/C++/Colour-bars-Display new file mode 120000 index 0000000000..4156f38cd5 --- /dev/null +++ b/Lang/C++/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/C++ \ No newline at end of file diff --git a/Lang/C++/Combinations b/Lang/C++/Combinations new file mode 120000 index 0000000000..9a2091f15b --- /dev/null +++ b/Lang/C++/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/C++ \ No newline at end of file diff --git a/Lang/C++/Command-line-arguments b/Lang/C++/Command-line-arguments new file mode 120000 index 0000000000..e4679f055d --- /dev/null +++ b/Lang/C++/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/C++ \ No newline at end of file diff --git a/Lang/C++/Comments b/Lang/C++/Comments new file mode 120000 index 0000000000..593e7e94c9 --- /dev/null +++ b/Lang/C++/Comments @@ -0,0 +1 @@ +../../Task/Comments/C++ \ No newline at end of file diff --git a/Lang/C++/Compile-time-calculation b/Lang/C++/Compile-time-calculation new file mode 120000 index 0000000000..bbf5519940 --- /dev/null +++ b/Lang/C++/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/C++ \ No newline at end of file diff --git a/Lang/C++/Compound-data-type b/Lang/C++/Compound-data-type new file mode 120000 index 0000000000..596e7b28ee --- /dev/null +++ b/Lang/C++/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/C++ \ No newline at end of file diff --git a/Lang/C++/Concurrent-computing b/Lang/C++/Concurrent-computing new file mode 120000 index 0000000000..0588af0066 --- /dev/null +++ b/Lang/C++/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/C++ \ No newline at end of file diff --git a/Lang/C++/Conditional-structures b/Lang/C++/Conditional-structures new file mode 120000 index 0000000000..6b7f865533 --- /dev/null +++ b/Lang/C++/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/C++ \ No newline at end of file diff --git a/Lang/C++/Continued-fraction b/Lang/C++/Continued-fraction new file mode 120000 index 0000000000..52f67e8b5a --- /dev/null +++ b/Lang/C++/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/C++ \ No newline at end of file diff --git a/Lang/C++/Continued-fraction-Arithmetic-Construct-from-rational-number b/Lang/C++/Continued-fraction-Arithmetic-Construct-from-rational-number new file mode 120000 index 0000000000..581e3c7a69 --- /dev/null +++ b/Lang/C++/Continued-fraction-Arithmetic-Construct-from-rational-number @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++ \ No newline at end of file diff --git a/Lang/C++/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) b/Lang/C++/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) new file mode 120000 index 0000000000..0588cbbce9 --- /dev/null +++ b/Lang/C++/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++ \ No newline at end of file diff --git a/Lang/C++/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2) b/Lang/C++/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2) new file mode 120000 index 0000000000..ba452b8bd0 --- /dev/null +++ b/Lang/C++/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2) @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++ \ No newline at end of file diff --git a/Lang/C++/Conways-Game-of-Life b/Lang/C++/Conways-Game-of-Life new file mode 120000 index 0000000000..3a820231d4 --- /dev/null +++ b/Lang/C++/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/C++ \ No newline at end of file diff --git a/Lang/C++/Count-in-octal b/Lang/C++/Count-in-octal new file mode 120000 index 0000000000..3756ff3c9c --- /dev/null +++ b/Lang/C++/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/C++ \ No newline at end of file diff --git a/Lang/C++/Count-occurrences-of-a-substring b/Lang/C++/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..0af85a902a --- /dev/null +++ b/Lang/C++/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/C++ \ No newline at end of file diff --git a/Lang/C++/Create-a-file b/Lang/C++/Create-a-file new file mode 120000 index 0000000000..0bbb582a6b --- /dev/null +++ b/Lang/C++/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/C++ \ No newline at end of file diff --git a/Lang/C++/Create-a-two-dimensional-array-at-runtime b/Lang/C++/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..a69d2a9b3b --- /dev/null +++ b/Lang/C++/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/C++ \ No newline at end of file diff --git a/Lang/C++/Create-an-HTML-table b/Lang/C++/Create-an-HTML-table new file mode 120000 index 0000000000..13b56f1c14 --- /dev/null +++ b/Lang/C++/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/C++ \ No newline at end of file diff --git a/Lang/C++/Create-an-object-at-a-given-address b/Lang/C++/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..da0b6c7933 --- /dev/null +++ b/Lang/C++/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/C++ \ No newline at end of file diff --git a/Lang/C++/Date-format b/Lang/C++/Date-format new file mode 120000 index 0000000000..ac52a7dd58 --- /dev/null +++ b/Lang/C++/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/C++ \ No newline at end of file diff --git a/Lang/C++/Date-manipulation b/Lang/C++/Date-manipulation new file mode 120000 index 0000000000..e2487f1deb --- /dev/null +++ b/Lang/C++/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/C++ \ No newline at end of file diff --git a/Lang/C++/Day-of-the-week b/Lang/C++/Day-of-the-week new file mode 120000 index 0000000000..9d942a0990 --- /dev/null +++ b/Lang/C++/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/C++ \ No newline at end of file diff --git a/Lang/C++/Define-a-primitive-data-type b/Lang/C++/Define-a-primitive-data-type new file mode 120000 index 0000000000..adacd9c880 --- /dev/null +++ b/Lang/C++/Define-a-primitive-data-type @@ -0,0 +1 @@ +../../Task/Define-a-primitive-data-type/C++ \ No newline at end of file diff --git a/Lang/C++/Delegates b/Lang/C++/Delegates new file mode 120000 index 0000000000..a66f222acb --- /dev/null +++ b/Lang/C++/Delegates @@ -0,0 +1 @@ +../../Task/Delegates/C++ \ No newline at end of file diff --git a/Lang/C++/Delete-a-file b/Lang/C++/Delete-a-file new file mode 120000 index 0000000000..0691641dd9 --- /dev/null +++ b/Lang/C++/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/C++ \ No newline at end of file diff --git a/Lang/C++/Determine-if-a-string-is-numeric b/Lang/C++/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..92a166821a --- /dev/null +++ b/Lang/C++/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/C++ \ No newline at end of file diff --git a/Lang/C++/Determine-if-only-one-instance-is-running b/Lang/C++/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..96003c84b0 --- /dev/null +++ b/Lang/C++/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/C++ \ No newline at end of file diff --git a/Lang/C++/Digital-root b/Lang/C++/Digital-root new file mode 120000 index 0000000000..705e6a8ba8 --- /dev/null +++ b/Lang/C++/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/C++ \ No newline at end of file diff --git a/Lang/C++/Dining-philosophers b/Lang/C++/Dining-philosophers new file mode 120000 index 0000000000..eecbd1488d --- /dev/null +++ b/Lang/C++/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/C++ \ No newline at end of file diff --git a/Lang/C++/Dot-product b/Lang/C++/Dot-product new file mode 120000 index 0000000000..10a069b9e3 --- /dev/null +++ b/Lang/C++/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/C++ \ No newline at end of file diff --git a/Lang/C++/Dutch-national-flag-problem b/Lang/C++/Dutch-national-flag-problem new file mode 120000 index 0000000000..afa8b38a70 --- /dev/null +++ b/Lang/C++/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/C++ \ No newline at end of file diff --git a/Lang/C++/Empty-program b/Lang/C++/Empty-program new file mode 120000 index 0000000000..ce72963617 --- /dev/null +++ b/Lang/C++/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/C++ \ No newline at end of file diff --git a/Lang/C++/Empty-string b/Lang/C++/Empty-string new file mode 120000 index 0000000000..7a3b403ef9 --- /dev/null +++ b/Lang/C++/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/C++ \ No newline at end of file diff --git a/Lang/C++/Enforced-immutability b/Lang/C++/Enforced-immutability new file mode 120000 index 0000000000..7f974a54e8 --- /dev/null +++ b/Lang/C++/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/C++ \ No newline at end of file diff --git a/Lang/C++/Enumerations b/Lang/C++/Enumerations new file mode 120000 index 0000000000..d6df46c7f3 --- /dev/null +++ b/Lang/C++/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/C++ \ No newline at end of file diff --git a/Lang/C++/Equilibrium-index b/Lang/C++/Equilibrium-index new file mode 120000 index 0000000000..10ba9782d9 --- /dev/null +++ b/Lang/C++/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/C++ \ No newline at end of file diff --git a/Lang/C++/Ethiopian-multiplication b/Lang/C++/Ethiopian-multiplication new file mode 120000 index 0000000000..6c8b7f84c4 --- /dev/null +++ b/Lang/C++/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/C++ \ No newline at end of file diff --git a/Lang/C++/Euler-method b/Lang/C++/Euler-method new file mode 120000 index 0000000000..c0294c291e --- /dev/null +++ b/Lang/C++/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/C++ \ No newline at end of file diff --git a/Lang/C++/Evaluate-binomial-coefficients b/Lang/C++/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..ca9e000e3a --- /dev/null +++ b/Lang/C++/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/C++ \ No newline at end of file diff --git a/Lang/C++/Even-or-odd b/Lang/C++/Even-or-odd new file mode 120000 index 0000000000..e5b4a2cc5b --- /dev/null +++ b/Lang/C++/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/C++ \ No newline at end of file diff --git a/Lang/C++/Evolutionary-algorithm b/Lang/C++/Evolutionary-algorithm new file mode 120000 index 0000000000..bfaaaddfd3 --- /dev/null +++ b/Lang/C++/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/C++ \ No newline at end of file diff --git a/Lang/C++/Exceptions b/Lang/C++/Exceptions new file mode 120000 index 0000000000..339fd0bd98 --- /dev/null +++ b/Lang/C++/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/C++ \ No newline at end of file diff --git a/Lang/C++/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/C++/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..18dba36595 --- /dev/null +++ b/Lang/C++/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C++ \ No newline at end of file diff --git a/Lang/C++/Execute-HQ9+ b/Lang/C++/Execute-HQ9+ new file mode 120000 index 0000000000..d4878b9809 --- /dev/null +++ b/Lang/C++/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/C++ \ No newline at end of file diff --git a/Lang/C++/Execute-a-system-command b/Lang/C++/Execute-a-system-command new file mode 120000 index 0000000000..2d545c92a2 --- /dev/null +++ b/Lang/C++/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/C++ \ No newline at end of file diff --git a/Lang/C++/Exponentiation-operator b/Lang/C++/Exponentiation-operator new file mode 120000 index 0000000000..86371aee83 --- /dev/null +++ b/Lang/C++/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/C++ \ No newline at end of file diff --git a/Lang/C++/FizzBuzz b/Lang/C++/FizzBuzz new file mode 120000 index 0000000000..e1ba1c442a --- /dev/null +++ b/Lang/C++/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/C++ \ No newline at end of file diff --git a/Lang/C++/Infinity b/Lang/C++/Infinity new file mode 120000 index 0000000000..8fcfcb622b --- /dev/null +++ b/Lang/C++/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/C++ \ No newline at end of file diff --git a/Lang/C++/JSON b/Lang/C++/JSON new file mode 120000 index 0000000000..22c772d81f --- /dev/null +++ b/Lang/C++/JSON @@ -0,0 +1 @@ +../../Task/JSON/C++ \ No newline at end of file diff --git a/Lang/C++/Knuth-shuffle b/Lang/C++/Knuth-shuffle new file mode 120000 index 0000000000..3adf7553c9 --- /dev/null +++ b/Lang/C++/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/C++ \ No newline at end of file diff --git a/Lang/C++/Ordered-words b/Lang/C++/Ordered-words new file mode 120000 index 0000000000..ccbe3d514b --- /dev/null +++ b/Lang/C++/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/C++ \ No newline at end of file diff --git a/Lang/C++/Pi b/Lang/C++/Pi new file mode 120000 index 0000000000..1d87dd0375 --- /dev/null +++ b/Lang/C++/Pi @@ -0,0 +1 @@ +../../Task/Pi/C++ \ No newline at end of file diff --git a/Lang/C++/Quine b/Lang/C++/Quine new file mode 120000 index 0000000000..886120aa65 --- /dev/null +++ b/Lang/C++/Quine @@ -0,0 +1 @@ +../../Task/Quine/C++ \ No newline at end of file diff --git a/Lang/C++/Search-a-list b/Lang/C++/Search-a-list new file mode 120000 index 0000000000..df0dd05760 --- /dev/null +++ b/Lang/C++/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/C++ \ No newline at end of file diff --git a/Lang/C-Shell/0DESCRIPTION b/Lang/C-Shell/0DESCRIPTION new file mode 100644 index 0000000000..f15c7c3fa6 --- /dev/null +++ b/Lang/C-Shell/0DESCRIPTION @@ -0,0 +1,108 @@ +{{language +|exec=interpreted +|tags=csh +|hopl id=1936 +}}{{implementation|UNIX Shell}} +'''csh''' was the shell that William Joy wrote for [[BSD]]. '''csh''' accepted the same [[Unix]] commands as other shells, but had a very different syntax (for variable assignments, control flow, and such). '''csh''' is not compatible with the [[Bourne Shell]]. + +BSD keeps the C Shell at /bin/csh. [[Hashbang]] lines should use the -f option: + +#!/bin/csh -f + +== Reputation == +C Shell is obsolete. Most scriptwriters prefer a Bourne-compatible shell, and few users want to learn two flavors of shells. C Shell introduced tilde expansion (ls ~), job control, command history, and aliases, but POSIX shells now have all of those. + +[http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ Csh Programming Considered Harmful] and [http://www.grymoire.com/Unix/CshTop10.txt Top Ten Reasons not to use the C shell] give multiple reasons to avoid C Shell. + +== Syntax == +[http://www.openbsd.org/cgi-bin/man.cgi?query=csh&apropos=0&sektion=1&manpath=OpenBSD+Current&arch=i386&format=html The manual for csh(1)] claims that C Shell has "a C-like syntax". Several other languages have a C-like syntax, including [[Java]] and [[Pike]], and Unix utilities [[AWK]] and [[bc]]. C Shell is less like [[C]] than those other languages. + +This example prints a [[Hailstone sequence]] from 13. + +{| class="wikitable" +! C +! C Shell +|- +|| #include + +int +main() +{ + int n; + + n = 13; + printf("%d\n", n); + while (n != 1) { + if (n % 2) + n = 3 * n + 1; + else + n /= 2; + + printf("%d\n", n); + } + + return 0; +} +|| + + + + + + +@ n = 13 +echo $n +while ($n != 1) + if ($n % 2) then + @ n = 3 * $n + 1 + else + @ n /= 2 + endif + echo $n +end + + + +|} + +C Shell has no braces {} to group the commands. Strange keywords are then, endif and end. Expressions have $n instead of n. Assignments use @ n. + +C Shell has "a C-like syntax" because C Shell is more like C than [[Bourne Shell]]. + +{| class="wikitable" +! Bourne Shell +! C Shell +|- +|| n=13 +echo $n +while test $n -ne 1; do + if expr $n % 2 >/dev/null; then + n=`expr 3 \* $n + 1` + else + n=`expr $n / 2` + fi + echo $n +done +|| @ n = 13 +echo $n +while ($n != 1) + if ($n % 2) then + @ n = 3 * $n + 1 + else + @ n /= 2 + endif + echo $n +end +|} + +Bourne Shell requires test or expr to evaluate expressions. C Shell has built-in expressions, so the Hailstone sequence comes more easily. These expressions have a stupid quirk: all operators are right-associative, so 10 - 3 - 2 acts like 10 - (3 - 2). The fix is to use parentheses. + +% @ n = 10 - 3 - 2 +% echo $n +9 +% @ n = (10 - 3) - 2 +% echo $n +5 + +== Links == +* [[OpenBSD]] has [http://www.openbsd.org/cgi-bin/man.cgi?query=csh&apropos=0&sektion=1&manpath=OpenBSD+Current&arch=i386&format=html csh(1) manual] and [http://www.openbsd.org/cgi-bin/cvsweb/src/bin/csh/ source code]. \ No newline at end of file diff --git a/Lang/C-sharp/0DESCRIPTION b/Lang/C-sharp/0DESCRIPTION new file mode 100644 index 0000000000..f9abd37fde --- /dev/null +++ b/Lang/C-sharp/0DESCRIPTION @@ -0,0 +1,23 @@ +
Due to technical limitations, the link [[C sharp|C#]] points to the [[C]] [[programming language]] in some articles. To correct this issue, replace [[C#]] with [[C sharp|C#]], and {{header|C#}} with {{header|C sharp|C#}}
+{{language|C sharp +|exec=bytecode +|gc=yes +|strength=strong +|checking=static +|compat=nominative +|express=implicit +|safety=both +|tags=csharp +|hopl id=3445 +|LCT=yes +|bnf=http://csharp.comsci.us/syntax/expression/ebnf.html}}[[runs on vm::common language runtime| ]] + +'''C#''' is an [[object-oriented language|object-oriented programming language]] developed by Microsoft as part of their .NET initiative, and later approved as a standard by [[wp:ECMA|ECMA]] and [[ISO]]. C# has a procedural, [[object-oriented language|object-oriented]] syntax based on [[C++]] that includes aspects of several other programming languages (most notably [[Delphi]] and [[Java]]) with a particular emphasis on simplification (fewer symbolic requirements than [[C++]], fewer declarative requirements than [[Java]]). + +==Citations== +*[[wp:C_sharp|Wikipedia:C#]] + +{{language programming paradigm|Imperative}} +{{language programming paradigm|Object-oriented}} +{{language programming paradigm|Generic}} +{{language programming paradigm|Reflective}} \ No newline at end of file diff --git a/Lang/C-sharp/100-doors b/Lang/C-sharp/100-doors new file mode 120000 index 0000000000..b561b92b6e --- /dev/null +++ b/Lang/C-sharp/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/99-Bottles-of-Beer b/Lang/C-sharp/99-Bottles-of-Beer new file mode 120000 index 0000000000..2338fb9478 --- /dev/null +++ b/Lang/C-sharp/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Abstract-type b/Lang/C-sharp/Abstract-type new file mode 120000 index 0000000000..d22d69c09c --- /dev/null +++ b/Lang/C-sharp/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Ackermann-function b/Lang/C-sharp/Ackermann-function new file mode 120000 index 0000000000..a0a547230f --- /dev/null +++ b/Lang/C-sharp/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Address-of-a-variable b/Lang/C-sharp/Address-of-a-variable new file mode 120000 index 0000000000..65df5a9933 --- /dev/null +++ b/Lang/C-sharp/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Align-columns b/Lang/C-sharp/Align-columns new file mode 120000 index 0000000000..b3e8aede08 --- /dev/null +++ b/Lang/C-sharp/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Animate-a-pendulum b/Lang/C-sharp/Animate-a-pendulum new file mode 120000 index 0000000000..e380ea22b2 --- /dev/null +++ b/Lang/C-sharp/Animate-a-pendulum @@ -0,0 +1 @@ +../../Task/Animate-a-pendulum/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Animation b/Lang/C-sharp/Animation new file mode 120000 index 0000000000..4c97d6dfed --- /dev/null +++ b/Lang/C-sharp/Animation @@ -0,0 +1 @@ +../../Task/Animation/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Apply-a-callback-to-an-array b/Lang/C-sharp/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..4b62967633 --- /dev/null +++ b/Lang/C-sharp/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Arbitrary-precision-integers-(included) b/Lang/C-sharp/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..2eaa17c3fa --- /dev/null +++ b/Lang/C-sharp/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Arithmetic-Complex b/Lang/C-sharp/Arithmetic-Complex new file mode 120000 index 0000000000..d6ae239ee4 --- /dev/null +++ b/Lang/C-sharp/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Arithmetic-geometric-mean b/Lang/C-sharp/Arithmetic-geometric-mean new file mode 120000 index 0000000000..da4c2f3ead --- /dev/null +++ b/Lang/C-sharp/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Array-concatenation b/Lang/C-sharp/Array-concatenation new file mode 120000 index 0000000000..7c31b28cfb --- /dev/null +++ b/Lang/C-sharp/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Arrays b/Lang/C-sharp/Arrays new file mode 120000 index 0000000000..5f87a03cc4 --- /dev/null +++ b/Lang/C-sharp/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Assertions b/Lang/C-sharp/Assertions new file mode 120000 index 0000000000..e519b49c4b --- /dev/null +++ b/Lang/C-sharp/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Associative-array-Creation b/Lang/C-sharp/Associative-array-Creation new file mode 120000 index 0000000000..01936b5a2c --- /dev/null +++ b/Lang/C-sharp/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Associative-array-Iteration b/Lang/C-sharp/Associative-array-Iteration new file mode 120000 index 0000000000..49361a1916 --- /dev/null +++ b/Lang/C-sharp/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Atomic-updates b/Lang/C-sharp/Atomic-updates new file mode 120000 index 0000000000..f09e61c710 --- /dev/null +++ b/Lang/C-sharp/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Averages-Arithmetic-mean b/Lang/C-sharp/Averages-Arithmetic-mean new file mode 120000 index 0000000000..b059d5b128 --- /dev/null +++ b/Lang/C-sharp/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Break-OO-privacy b/Lang/C-sharp/Break-OO-privacy new file mode 120000 index 0000000000..d53942d2fe --- /dev/null +++ b/Lang/C-sharp/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/CSV-to-HTML-translation b/Lang/C-sharp/CSV-to-HTML-translation new file mode 120000 index 0000000000..a07a4f1ca8 --- /dev/null +++ b/Lang/C-sharp/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Case-sensitivity-of-identifiers b/Lang/C-sharp/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..fd3b40189e --- /dev/null +++ b/Lang/C-sharp/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Conways-Game-of-Life b/Lang/C-sharp/Conways-Game-of-Life new file mode 120000 index 0000000000..a85a094b2b --- /dev/null +++ b/Lang/C-sharp/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Count-occurrences-of-a-substring b/Lang/C-sharp/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..e0ff754c3e --- /dev/null +++ b/Lang/C-sharp/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Create-an-HTML-table b/Lang/C-sharp/Create-an-HTML-table new file mode 120000 index 0000000000..9897268837 --- /dev/null +++ b/Lang/C-sharp/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/DNS-query b/Lang/C-sharp/DNS-query new file mode 120000 index 0000000000..abc5f9260b --- /dev/null +++ b/Lang/C-sharp/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Deepcopy b/Lang/C-sharp/Deepcopy new file mode 120000 index 0000000000..2ab911d397 --- /dev/null +++ b/Lang/C-sharp/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Delegates b/Lang/C-sharp/Delegates new file mode 120000 index 0000000000..7183cb2d0c --- /dev/null +++ b/Lang/C-sharp/Delegates @@ -0,0 +1 @@ +../../Task/Delegates/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Doubly-linked-list-Definition b/Lang/C-sharp/Doubly-linked-list-Definition new file mode 120000 index 0000000000..fbb812ac18 --- /dev/null +++ b/Lang/C-sharp/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Doubly-linked-list-Traversal b/Lang/C-sharp/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..e3989d09d0 --- /dev/null +++ b/Lang/C-sharp/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Empty-string b/Lang/C-sharp/Empty-string new file mode 120000 index 0000000000..f0e357d897 --- /dev/null +++ b/Lang/C-sharp/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Euler-method b/Lang/C-sharp/Euler-method new file mode 120000 index 0000000000..e3dc279a6b --- /dev/null +++ b/Lang/C-sharp/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Execute-HQ9+ b/Lang/C-sharp/Execute-HQ9+ new file mode 120000 index 0000000000..496e56ca85 --- /dev/null +++ b/Lang/C-sharp/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Forest-fire b/Lang/C-sharp/Forest-fire new file mode 120000 index 0000000000..836abe8c21 --- /dev/null +++ b/Lang/C-sharp/Forest-fire @@ -0,0 +1 @@ +../../Task/Forest-fire/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/JSON b/Lang/C-sharp/JSON new file mode 120000 index 0000000000..0a10bf9331 --- /dev/null +++ b/Lang/C-sharp/JSON @@ -0,0 +1 @@ +../../Task/JSON/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Quine b/Lang/C-sharp/Quine new file mode 120000 index 0000000000..a80020a284 --- /dev/null +++ b/Lang/C-sharp/Quine @@ -0,0 +1 @@ +../../Task/Quine/C-sharp \ No newline at end of file diff --git a/Lang/C/CRC-32 b/Lang/C/CRC-32 new file mode 120000 index 0000000000..c8f2b3c5a1 --- /dev/null +++ b/Lang/C/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/C \ No newline at end of file diff --git a/Lang/C/CSV-to-HTML-translation b/Lang/C/CSV-to-HTML-translation new file mode 120000 index 0000000000..e5903ea60d --- /dev/null +++ b/Lang/C/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/C \ No newline at end of file diff --git a/Lang/C/Call-a-function b/Lang/C/Call-a-function new file mode 120000 index 0000000000..34574dead5 --- /dev/null +++ b/Lang/C/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/C \ No newline at end of file diff --git a/Lang/C/Call-a-function-in-a-shared-library b/Lang/C/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..29e6de7532 --- /dev/null +++ b/Lang/C/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/C \ No newline at end of file diff --git a/Lang/C/Canny-edge-detector b/Lang/C/Canny-edge-detector new file mode 120000 index 0000000000..82d1cf4c1e --- /dev/null +++ b/Lang/C/Canny-edge-detector @@ -0,0 +1 @@ +../../Task/Canny-edge-detector/C \ No newline at end of file diff --git a/Lang/C/Case-sensitivity-of-identifiers b/Lang/C/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..f4c8987581 --- /dev/null +++ b/Lang/C/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/C \ No newline at end of file diff --git a/Lang/C/Catmull-Clark-subdivision-surface b/Lang/C/Catmull-Clark-subdivision-surface new file mode 120000 index 0000000000..82cfcc7ff1 --- /dev/null +++ b/Lang/C/Catmull-Clark-subdivision-surface @@ -0,0 +1 @@ +../../Task/Catmull-Clark-subdivision-surface/C \ No newline at end of file diff --git a/Lang/C/Character-codes b/Lang/C/Character-codes new file mode 120000 index 0000000000..303730f005 --- /dev/null +++ b/Lang/C/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/C \ No newline at end of file diff --git a/Lang/C/Character-matching b/Lang/C/Character-matching new file mode 120000 index 0000000000..f7db89c9cd --- /dev/null +++ b/Lang/C/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/C \ No newline at end of file diff --git a/Lang/C/Chat-server b/Lang/C/Chat-server new file mode 120000 index 0000000000..2fb2767af2 --- /dev/null +++ b/Lang/C/Chat-server @@ -0,0 +1 @@ +../../Task/Chat-server/C \ No newline at end of file diff --git a/Lang/C/Cholesky-decomposition b/Lang/C/Cholesky-decomposition new file mode 120000 index 0000000000..892b09c20b --- /dev/null +++ b/Lang/C/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/C \ No newline at end of file diff --git a/Lang/C/Color-quantization b/Lang/C/Color-quantization new file mode 120000 index 0000000000..1a7379f139 --- /dev/null +++ b/Lang/C/Color-quantization @@ -0,0 +1 @@ +../../Task/Color-quantization/C \ No newline at end of file diff --git a/Lang/C/Combinations b/Lang/C/Combinations new file mode 120000 index 0000000000..1059d645bc --- /dev/null +++ b/Lang/C/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/C \ No newline at end of file diff --git a/Lang/C/Combinations-with-repetitions b/Lang/C/Combinations-with-repetitions new file mode 120000 index 0000000000..759f1adcef --- /dev/null +++ b/Lang/C/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/C \ No newline at end of file diff --git a/Lang/C/Command-line-arguments b/Lang/C/Command-line-arguments new file mode 120000 index 0000000000..9e21892e3e --- /dev/null +++ b/Lang/C/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/C \ No newline at end of file diff --git a/Lang/C/Compare-sorting-algorithms-performance b/Lang/C/Compare-sorting-algorithms-performance new file mode 120000 index 0000000000..60d1f4e72b --- /dev/null +++ b/Lang/C/Compare-sorting-algorithms-performance @@ -0,0 +1 @@ +../../Task/Compare-sorting-algorithms-performance/C \ No newline at end of file diff --git a/Lang/C/Compile-time-calculation b/Lang/C/Compile-time-calculation new file mode 120000 index 0000000000..9a831917ed --- /dev/null +++ b/Lang/C/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/C \ No newline at end of file diff --git a/Lang/C/Compound-data-type b/Lang/C/Compound-data-type new file mode 120000 index 0000000000..dda4c6d7ca --- /dev/null +++ b/Lang/C/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/C \ No newline at end of file diff --git a/Lang/C/Concurrent-computing b/Lang/C/Concurrent-computing new file mode 120000 index 0000000000..0acfa2bc80 --- /dev/null +++ b/Lang/C/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/C \ No newline at end of file diff --git a/Lang/C/Constrained-random-points-on-a-circle b/Lang/C/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..68f5e68dc0 --- /dev/null +++ b/Lang/C/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/C \ No newline at end of file diff --git a/Lang/C/Continued-fraction b/Lang/C/Continued-fraction new file mode 120000 index 0000000000..e881e95121 --- /dev/null +++ b/Lang/C/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/C \ No newline at end of file diff --git a/Lang/C/Conways-Game-of-Life b/Lang/C/Conways-Game-of-Life new file mode 120000 index 0000000000..94d51ff797 --- /dev/null +++ b/Lang/C/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/C \ No newline at end of file diff --git a/Lang/C/Count-in-factors b/Lang/C/Count-in-factors new file mode 120000 index 0000000000..5e868ef1ba --- /dev/null +++ b/Lang/C/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/C \ No newline at end of file diff --git a/Lang/C/Count-in-octal b/Lang/C/Count-in-octal new file mode 120000 index 0000000000..5bb3e42c97 --- /dev/null +++ b/Lang/C/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/C \ No newline at end of file diff --git a/Lang/C/Count-occurrences-of-a-substring b/Lang/C/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..e224f7ff94 --- /dev/null +++ b/Lang/C/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/C \ No newline at end of file diff --git a/Lang/C/Count-the-coins b/Lang/C/Count-the-coins new file mode 120000 index 0000000000..10ed2f5bd1 --- /dev/null +++ b/Lang/C/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/C \ No newline at end of file diff --git a/Lang/C/Create-a-file b/Lang/C/Create-a-file new file mode 120000 index 0000000000..32ddffa93c --- /dev/null +++ b/Lang/C/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/C \ No newline at end of file diff --git a/Lang/C/Create-a-two-dimensional-array-at-runtime b/Lang/C/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..2eb97b5932 --- /dev/null +++ b/Lang/C/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/C \ No newline at end of file diff --git a/Lang/C/Create-an-HTML-table b/Lang/C/Create-an-HTML-table new file mode 120000 index 0000000000..9759d50fd8 --- /dev/null +++ b/Lang/C/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/C \ No newline at end of file diff --git a/Lang/C/Create-an-object-at-a-given-address b/Lang/C/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..3759a8110e --- /dev/null +++ b/Lang/C/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/C \ No newline at end of file diff --git a/Lang/C/Cut-a-rectangle b/Lang/C/Cut-a-rectangle new file mode 120000 index 0000000000..10a715baad --- /dev/null +++ b/Lang/C/Cut-a-rectangle @@ -0,0 +1 @@ +../../Task/Cut-a-rectangle/C \ No newline at end of file diff --git a/Lang/C/Date-format b/Lang/C/Date-format new file mode 120000 index 0000000000..19e7613974 --- /dev/null +++ b/Lang/C/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/C \ No newline at end of file diff --git a/Lang/C/Date-manipulation b/Lang/C/Date-manipulation new file mode 120000 index 0000000000..00b42589c0 --- /dev/null +++ b/Lang/C/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/C \ No newline at end of file diff --git a/Lang/C/Day-of-the-week b/Lang/C/Day-of-the-week new file mode 120000 index 0000000000..8e20aa59b7 --- /dev/null +++ b/Lang/C/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/C \ No newline at end of file diff --git a/Lang/C/Deal-cards-for-FreeCell b/Lang/C/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..6efbeeb277 --- /dev/null +++ b/Lang/C/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/C \ No newline at end of file diff --git a/Lang/C/Deconvolution-1D b/Lang/C/Deconvolution-1D new file mode 120000 index 0000000000..c0163bf7cd --- /dev/null +++ b/Lang/C/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/C \ No newline at end of file diff --git a/Lang/C/Deconvolution-2D+ b/Lang/C/Deconvolution-2D+ new file mode 120000 index 0000000000..436585e4c0 --- /dev/null +++ b/Lang/C/Deconvolution-2D+ @@ -0,0 +1 @@ +../../Task/Deconvolution-2D+/C \ No newline at end of file diff --git a/Lang/C/Determine-if-only-one-instance-is-running b/Lang/C/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..58be00ed34 --- /dev/null +++ b/Lang/C/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/C \ No newline at end of file diff --git a/Lang/C/Digital-root b/Lang/C/Digital-root new file mode 120000 index 0000000000..2995ed84f3 --- /dev/null +++ b/Lang/C/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/C \ No newline at end of file diff --git a/Lang/C/Dinesmans-multiple-dwelling-problem b/Lang/C/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..bc43904f54 --- /dev/null +++ b/Lang/C/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/C \ No newline at end of file diff --git a/Lang/C/Dining-philosophers b/Lang/C/Dining-philosophers new file mode 120000 index 0000000000..0271c50134 --- /dev/null +++ b/Lang/C/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/C \ No newline at end of file diff --git a/Lang/C/Discordian-date b/Lang/C/Discordian-date new file mode 120000 index 0000000000..ce18fc6609 --- /dev/null +++ b/Lang/C/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/C \ No newline at end of file diff --git a/Lang/C/Distributed-programming b/Lang/C/Distributed-programming new file mode 120000 index 0000000000..037f25db5d --- /dev/null +++ b/Lang/C/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/C \ No newline at end of file diff --git a/Lang/C/Documentation b/Lang/C/Documentation new file mode 120000 index 0000000000..e8c6bad81e --- /dev/null +++ b/Lang/C/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/C \ No newline at end of file diff --git a/Lang/C/Dot-product b/Lang/C/Dot-product new file mode 120000 index 0000000000..a43f3f948b --- /dev/null +++ b/Lang/C/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/C \ No newline at end of file diff --git a/Lang/C/Doubly-linked-list-Definition b/Lang/C/Doubly-linked-list-Definition new file mode 120000 index 0000000000..3032efe462 --- /dev/null +++ b/Lang/C/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/C \ No newline at end of file diff --git a/Lang/C/Doubly-linked-list-Element-definition b/Lang/C/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..896d88c803 --- /dev/null +++ b/Lang/C/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/C \ No newline at end of file diff --git a/Lang/C/Doubly-linked-list-Element-insertion b/Lang/C/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..dd28df9621 --- /dev/null +++ b/Lang/C/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/C \ No newline at end of file diff --git a/Lang/C/Doubly-linked-list-Traversal b/Lang/C/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..ea148e92fc --- /dev/null +++ b/Lang/C/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/C \ No newline at end of file diff --git a/Lang/C/Draw-a-cuboid b/Lang/C/Draw-a-cuboid new file mode 120000 index 0000000000..fa59cd0cfe --- /dev/null +++ b/Lang/C/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/C \ No newline at end of file diff --git a/Lang/C/Draw-a-sphere b/Lang/C/Draw-a-sphere new file mode 120000 index 0000000000..97013e8833 --- /dev/null +++ b/Lang/C/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/C \ No newline at end of file diff --git a/Lang/C/Echo-server b/Lang/C/Echo-server new file mode 120000 index 0000000000..59cc9eeebe --- /dev/null +++ b/Lang/C/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/C \ No newline at end of file diff --git a/Lang/C/Element-wise-operations b/Lang/C/Element-wise-operations new file mode 120000 index 0000000000..db21f240da --- /dev/null +++ b/Lang/C/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/C \ No newline at end of file diff --git a/Lang/C/Empty-directory b/Lang/C/Empty-directory new file mode 120000 index 0000000000..a72b5981c1 --- /dev/null +++ b/Lang/C/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/C \ No newline at end of file diff --git a/Lang/C/Empty-program b/Lang/C/Empty-program new file mode 120000 index 0000000000..c7e22b13a5 --- /dev/null +++ b/Lang/C/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/C \ No newline at end of file diff --git a/Lang/C/Empty-string b/Lang/C/Empty-string new file mode 120000 index 0000000000..c3476a092f --- /dev/null +++ b/Lang/C/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/C \ No newline at end of file diff --git a/Lang/C/Enforced-immutability b/Lang/C/Enforced-immutability new file mode 120000 index 0000000000..ce8924eb5d --- /dev/null +++ b/Lang/C/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/C \ No newline at end of file diff --git a/Lang/C/Enumerations b/Lang/C/Enumerations new file mode 120000 index 0000000000..b349ea6311 --- /dev/null +++ b/Lang/C/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/C \ No newline at end of file diff --git a/Lang/C/Equilibrium-index b/Lang/C/Equilibrium-index new file mode 120000 index 0000000000..601ef68605 --- /dev/null +++ b/Lang/C/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/C \ No newline at end of file diff --git a/Lang/C/Ethiopian-multiplication b/Lang/C/Ethiopian-multiplication new file mode 120000 index 0000000000..98ccf2d595 --- /dev/null +++ b/Lang/C/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/C \ No newline at end of file diff --git a/Lang/C/Euler-method b/Lang/C/Euler-method new file mode 120000 index 0000000000..20d5a805d3 --- /dev/null +++ b/Lang/C/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/C \ No newline at end of file diff --git a/Lang/C/Evaluate-binomial-coefficients b/Lang/C/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..a7b6e0c665 --- /dev/null +++ b/Lang/C/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/C \ No newline at end of file diff --git a/Lang/C/Even-or-odd b/Lang/C/Even-or-odd new file mode 120000 index 0000000000..873e6932ce --- /dev/null +++ b/Lang/C/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/C \ No newline at end of file diff --git a/Lang/C/Events b/Lang/C/Events new file mode 120000 index 0000000000..882637ab28 --- /dev/null +++ b/Lang/C/Events @@ -0,0 +1 @@ +../../Task/Events/C \ No newline at end of file diff --git a/Lang/C/Evolutionary-algorithm b/Lang/C/Evolutionary-algorithm new file mode 120000 index 0000000000..4c70ab341f --- /dev/null +++ b/Lang/C/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/C \ No newline at end of file diff --git a/Lang/C/Exceptions b/Lang/C/Exceptions new file mode 120000 index 0000000000..e22b19d23a --- /dev/null +++ b/Lang/C/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/C \ No newline at end of file diff --git a/Lang/C/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/C/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..3b4642daa8 --- /dev/null +++ b/Lang/C/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C \ No newline at end of file diff --git a/Lang/C/Executable-library b/Lang/C/Executable-library new file mode 120000 index 0000000000..ddc683af5a --- /dev/null +++ b/Lang/C/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/C \ No newline at end of file diff --git a/Lang/C/Execute-HQ9+ b/Lang/C/Execute-HQ9+ new file mode 120000 index 0000000000..952ddfbf16 --- /dev/null +++ b/Lang/C/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/C \ No newline at end of file diff --git a/Lang/C/Execute-a-system-command b/Lang/C/Execute-a-system-command new file mode 120000 index 0000000000..82d82b75cb --- /dev/null +++ b/Lang/C/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/C \ No newline at end of file diff --git a/Lang/C/Exponentiation-operator b/Lang/C/Exponentiation-operator new file mode 120000 index 0000000000..810c3afb64 --- /dev/null +++ b/Lang/C/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/C \ No newline at end of file diff --git a/Lang/C/Extend-your-language b/Lang/C/Extend-your-language new file mode 120000 index 0000000000..dd475238e6 --- /dev/null +++ b/Lang/C/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/C \ No newline at end of file diff --git a/Lang/C/Extreme-floating-point-values b/Lang/C/Extreme-floating-point-values new file mode 120000 index 0000000000..f308162911 --- /dev/null +++ b/Lang/C/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/C \ No newline at end of file diff --git a/Lang/C0H/0DESCRIPTION b/Lang/C0H/0DESCRIPTION new file mode 100644 index 0000000000..c11d86a01b --- /dev/null +++ b/Lang/C0H/0DESCRIPTION @@ -0,0 +1,26 @@ +{{language +|exec=machine +|gc=no +|safety=unsafe +|parampass=value +|checking=static +|compat=nominative +|express=explicit +|strength=weak +|hopl=no}}{{language programming paradigm|Imperative}} +'''C0H''' is a general-purpose, [[procedural programming|procedural]], [[imperative programming|imperative]] computer programming language, partially developed by André van Delft in 2011. It is a small extension to the well known [[derived from::compatible with::C]] programming language, allowing for the smallest "Hello World" program that one can think of. + +The development of C0H has been inspired on the [[HQ9+]] programming language, which accepts "H" in its source to print "Hello World!". However, HQ9+ is not a general purpose programming language; in fact it has very limited capabilities. C0H improves over HQ9+ by offering the full power of the C language; moreover, C0H offers a shorter path to writing a Hello World program: just create an empty file! + +C0H has been followed up by [[C1R]], a C extension aimed at short solutions for tasks that are implemented by C programs at RosettaCode.org. +==Versions== +* version 0.99 existed for about 35 minutes. An empty input source file would result in a program printing "Hello World!". +* version 1.00 quickly followed up version 0.99, after the creator of the language found out to his great surprise that the web site Rosetta Code required a "Hello World" program to print "Goodbye, World!" + +==Implementation== +See [[C0H Implementation]] + +==Documentation== +To get a reference document on C0H, it is advised to upgrade a reference document on the "C" programming language, and attach a Post-it note stating C0H is like C, except that an empty input file yields "Goodbye, World". + +{{language programming paradigm|Imperative}} \ No newline at end of file diff --git a/Lang/C1R/0DESCRIPTION b/Lang/C1R/0DESCRIPTION new file mode 100644 index 0000000000..89488b5363 --- /dev/null +++ b/Lang/C1R/0DESCRIPTION @@ -0,0 +1,32 @@ +{{language +|exec=machine +|gc=no +|safety=unsafe +|parampass=value +|checking=static +|compat=nominative +|express=explicit +|strength=weak +|hopl=no}}{{language programming paradigm|Imperative}} +'''C1R''' is a general-purpose, [[procedural programming|procedural]], [[imperative programming|imperative]] computer programming language, partially developed by André van Delft in 2011. It is a small extension to the well known [[derived from::compatible with::C]] programming language, allowing for very small programs that implement tasks that are implemented by C programs at RosettaCode.org. + +C1R can also be regarded as an [[adaptive]] language, as the set of valid C1R programs varies with the C implementations for tasks at Rosetta Code. + +The development of C1R has been inspired on the [[HQ9+]] and [[C0H]] programming languages. HQ9+ accepts "H" in its source to print "Hello World!". C0H improves over HQ9+ by offering the full power of the C language; moreover, C0H offers a shorter path to writing a Hello World program: just create an empty file. C1R allows the user to submit a text file with just a simple reference of a task implemented in C at Rosetta Code; that reference is the implementation of the task in C1R. +E.g., the following C1R program + +Hello_world/Text + +does exactly the same as the C program listed at the "[[Hello_world/Text]]" page, namely print "Goodbye world!". + +==Implementation== +C1R is implemented using a Shell script that calls the C compiler. The script starts by testing whether C code should be downloaded from the Rosetta Code site. The Quine task is treated as a special case. +See [[C1R Implementation]] + +==Acknowledgement== +When hearing of C0H, Jelle van Zeijl suggested to make a similar language based on downloading C code from the Rosetta Code site. + +==Documentation== +To get a reference document on C1R, it is advised to upgrade a reference document on the "C" programming language, and attach a Post-it note stating C1R is like C, except that in case it contains just 1 line that directs to a Rosetta Code URL with a valid C implementation. + +{{language programming paradigm|Imperative}} \ No newline at end of file diff --git a/Lang/C1R/100-doors b/Lang/C1R/100-doors new file mode 120000 index 0000000000..e9e58d4c58 --- /dev/null +++ b/Lang/C1R/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/C1R \ No newline at end of file diff --git a/Lang/C1R/Quine b/Lang/C1R/Quine new file mode 120000 index 0000000000..e2681b7153 --- /dev/null +++ b/Lang/C1R/Quine @@ -0,0 +1 @@ +../../Task/Quine/C1R \ No newline at end of file diff --git a/Lang/CB80/0DESCRIPTION b/Lang/CB80/0DESCRIPTION new file mode 100644 index 0000000000..96b8bf005c --- /dev/null +++ b/Lang/CB80/0DESCRIPTION @@ -0,0 +1 @@ +{{language}}{{Stub}} \ No newline at end of file diff --git a/Lang/CLIPS/0DESCRIPTION b/Lang/CLIPS/0DESCRIPTION new file mode 100644 index 0000000000..1d7b1d1738 --- /dev/null +++ b/Lang/CLIPS/0DESCRIPTION @@ -0,0 +1,10 @@ +{{language|CLIPS +|site=http://clipsrules.sourceforge.net/ +}} + +CLIPS is a productive development and delivery expert system tool which provides a complete environment for the construction of rule and/or object based expert systems. Created in 1985, CLIPS is now widely used throughout the government, industry, and academia. The name is an acronym for "C Language Integrated Production System." + +CLIPS is probably the most widely used expert system tool because it is fast, efficient and free. Although it is now in the public domain, it is still updated and supported by the original author, Gary Riley. CLIPS incorporates a complete object-oriented language COOL for writing expert systems. Though it is written in C, its interface more closely resembles that of the programming language LISP. Extensions can be written in C, and CLIPS can be called from C. + +==See Also== +*[[wp:CLIPS|Wikipedia:CLIPS]] \ No newline at end of file diff --git a/Lang/CLIPS/100-doors b/Lang/CLIPS/100-doors new file mode 120000 index 0000000000..312237b16a --- /dev/null +++ b/Lang/CLIPS/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/CLIPS \ No newline at end of file diff --git a/Lang/CLIPS/99-Bottles-of-Beer b/Lang/CLIPS/99-Bottles-of-Beer new file mode 120000 index 0000000000..f9c1fd1a37 --- /dev/null +++ b/Lang/CLIPS/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/CLIPS \ No newline at end of file diff --git a/Lang/CLIPS/Ackermann-function b/Lang/CLIPS/Ackermann-function new file mode 120000 index 0000000000..2ae31206e3 --- /dev/null +++ b/Lang/CLIPS/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/CLIPS \ No newline at end of file diff --git a/Lang/CLIPS/FizzBuzz b/Lang/CLIPS/FizzBuzz new file mode 120000 index 0000000000..283e9989ad --- /dev/null +++ b/Lang/CLIPS/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/CLIPS \ No newline at end of file diff --git a/Lang/CMake/0DESCRIPTION b/Lang/CMake/0DESCRIPTION new file mode 100644 index 0000000000..4bfb8f4457 --- /dev/null +++ b/Lang/CMake/0DESCRIPTION @@ -0,0 +1,98 @@ +{{language +|exec=interpreted +|site=http://www.cmake.org/ +|hopl=no +|tags=cmake}} + +CMake is a cross-platform make system, for compiling [[C]], [[C++]] or [[Fortran]] programs. CMake uses a configuration file (CMakeLists.txt) to run configure tests, find libraries, create targets, and generate a build system for [[make|Unix make]] or another build tool. This configuration file runs commands in CMake's own scripting language. + +For Rosetta Code, most examples work with ''CMake 2.6'' or later in ''process script mode'' (cmake -P myscript.cmake). Many examples use features from 2.6, especially function(). In cmake -P mode, CMake runs the script but never creates a project. So there are no configure tests and no targets. + +==Simple project== +This example builds a small C program after checking if #include provides clock_gettime() or gettimeofday(). + +===CMakeLists.txt=== +# CMakeLists.txt +cmake_minimum_required(VERSION 2.6) +project(simpletime C) # This project will use the C compiler. + +# Check if this system has clock_gettime() or gettimeofday(), +# then generate config.h with the results. +include(CheckSymbolExists) +check_symbol_exists(clock_gettime sys/time.h HAVE_CLOCK_GETTIME) +check_symbol_exists(gettimeofday sys/time.h HAVE_GETTIMEOFDAY) +configure_file(config.h.in config.h) + +# Allow C to #include , if doing out-of-source build. +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +# This target will make an executable from the given +# source files and any included header files. +add_executable(simpletime simpletime.c) + +# The install target will install the executable +# to ${CMAKE_INSTALL_PREFIX}/bin. +install(TARGETS simpletime DESTINATION bin) + +===config.h.in=== +/* config.h, generated from config.h.in by CMake ${CMAKE_VERSION} */ +#cmakedefine HAVE_CLOCK_GETTIME +#cmakedefine HAVE_GETTIMEOFDAY + +===simpletime.c=== +/* simpletime.c */ +#include "config.h" + +#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETTIMEOFDAY) +#include +#endif +#include +#include + +/* + * Simply print the current time. + */ +int +main() +{ +#if defined(HAVE_CLOCK_GETTIME) + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + printf("The time is %s" "and %ld nanoseconds.\n", + ctime(&ts.tv_sec), ts.tv_nsec); +#elif defined(HAVE_GETTIMEOFDAY) + struct timeval tv; + gettimeofday(&tv, NULL); + printf("The time is %s" "and %ld microseconds.\n", + ctime(&tv.tv_sec), tv.tv_usec); +#else + time_t sec; + sec = time(NULL); + printf("The time is %s", ctime(&sec)); +#endif + return 0; +} + +If the three files CMakeLists.txt, config.h.in and simpletime.c are in .., then cmake .. configures the project. + + $ cmake .. + -- The C compiler identification is GNU + -- Check for working C compiler: /usr/bin/gcc + -- Check for working C compiler: /usr/bin/gcc -- works + -- Detecting C compiler ABI info + -- Detecting C compiler ABI info - done + -- Looking for clock_gettime + -- Looking for clock_gettime - found + -- Looking for gettimeofday + -- Looking for gettimeofday - found + -- Configuring done + -- Generating done + -- Build files have been written to: /home/kernigh/field/rc/simpletime/work + $ make + Scanning dependencies of target simpletime + [100%] Building C object CMakeFiles/simpletime.dir/simpletime.c.o + Linking C executable simpletime + [100%] Built target simpletime + $ ./simpletime + The time is Wed Sep 7 17:10:55 2011 + and 993848603 nanoseconds. \ No newline at end of file diff --git a/Lang/CMake/Boolean-values b/Lang/CMake/Boolean-values new file mode 120000 index 0000000000..9ef9fc72ef --- /dev/null +++ b/Lang/CMake/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/CMake \ No newline at end of file diff --git a/Lang/CMake/Call-a-foreign-language-function b/Lang/CMake/Call-a-foreign-language-function new file mode 120000 index 0000000000..fb3e8ce795 --- /dev/null +++ b/Lang/CMake/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/CMake \ No newline at end of file diff --git a/Lang/CMake/Conditional-structures b/Lang/CMake/Conditional-structures new file mode 120000 index 0000000000..e4a993f544 --- /dev/null +++ b/Lang/CMake/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/CMake \ No newline at end of file diff --git a/Lang/CMake/Execute-a-system-command b/Lang/CMake/Execute-a-system-command new file mode 120000 index 0000000000..e18b312959 --- /dev/null +++ b/Lang/CMake/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/CMake \ No newline at end of file diff --git a/Lang/CMake/FizzBuzz b/Lang/CMake/FizzBuzz new file mode 120000 index 0000000000..dd85668466 --- /dev/null +++ b/Lang/CMake/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/CMake \ No newline at end of file diff --git a/Lang/CMake/Knuth-shuffle b/Lang/CMake/Knuth-shuffle new file mode 120000 index 0000000000..4691c9a0a5 --- /dev/null +++ b/Lang/CMake/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/CMake \ No newline at end of file diff --git a/Lang/COBOL/0DESCRIPTION b/Lang/COBOL/0DESCRIPTION new file mode 100644 index 0000000000..3306d9f996 --- /dev/null +++ b/Lang/COBOL/0DESCRIPTION @@ -0,0 +1,7 @@ +{{stub}}{{language|COBOL +|strength=strong +|checking=static +|gc=no +|LCT=yes +|bnf=http://www.cs.vu.nl/~x/grammars/cobol/}} +COmmon Business Oriented Language \ No newline at end of file diff --git a/Lang/COBOL/100-doors b/Lang/COBOL/100-doors new file mode 120000 index 0000000000..1fc5a07e7b --- /dev/null +++ b/Lang/COBOL/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/COBOL \ No newline at end of file diff --git a/Lang/COBOL/99-Bottles-of-Beer b/Lang/COBOL/99-Bottles-of-Beer new file mode 120000 index 0000000000..e673f89f04 --- /dev/null +++ b/Lang/COBOL/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Address-of-a-variable b/Lang/COBOL/Address-of-a-variable new file mode 120000 index 0000000000..0fda778d46 --- /dev/null +++ b/Lang/COBOL/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Case-sensitivity-of-identifiers b/Lang/COBOL/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..d6c235898a --- /dev/null +++ b/Lang/COBOL/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Comments b/Lang/COBOL/Comments new file mode 120000 index 0000000000..1771f874d9 --- /dev/null +++ b/Lang/COBOL/Comments @@ -0,0 +1 @@ +../../Task/Comments/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Conditional-structures b/Lang/COBOL/Conditional-structures new file mode 120000 index 0000000000..e58e188561 --- /dev/null +++ b/Lang/COBOL/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Create-an-object-at-a-given-address b/Lang/COBOL/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..1b730b9394 --- /dev/null +++ b/Lang/COBOL/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Empty-program b/Lang/COBOL/Empty-program new file mode 120000 index 0000000000..c1fbaf0b02 --- /dev/null +++ b/Lang/COBOL/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Ethiopian-multiplication b/Lang/COBOL/Ethiopian-multiplication new file mode 120000 index 0000000000..5b685b5def --- /dev/null +++ b/Lang/COBOL/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/COBOL \ No newline at end of file diff --git a/Lang/COBOL/FizzBuzz b/Lang/COBOL/FizzBuzz new file mode 120000 index 0000000000..870319a812 --- /dev/null +++ b/Lang/COBOL/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Quine b/Lang/COBOL/Quine new file mode 120000 index 0000000000..c0935d700b --- /dev/null +++ b/Lang/COBOL/Quine @@ -0,0 +1 @@ +../../Task/Quine/COBOL \ No newline at end of file diff --git a/Lang/Cache-ObjectScript/0DESCRIPTION b/Lang/Cache-ObjectScript/0DESCRIPTION new file mode 100644 index 0000000000..059dfee753 --- /dev/null +++ b/Lang/Cache-ObjectScript/0DESCRIPTION @@ -0,0 +1,18 @@ +{{language|COS +|checking=dynamic}} +{{language programming paradigm|Dynamic}} +{{language programming paradigm|Object-oriented}} + +

Visit the [https://groups.google.com/forum/?fromgroups#!forum/intersystems-public-cache Google group] for discussions about this language.

+ +

Visit [[wp:Caché_ObjectScript|Wikipedia]] for a general description.

+ +

Caché ObjectScript (COS) is a part of the Caché database system sold by InterSystems. The language is a functional superset of the ANSI-standard M (i.e. MUMPS) programming language. MUMPS programmers can run existing MUMPS routines under Caché with little or no change. The original scripting language for Caché, Caché ObjectScript is an object-oriented language. One interesting feature of Caché ObjectScript is that it enables the intermixing of data access methods – developers may view data as objects, as relational tables (using SQL), or as multidimensional arrays. +

+ +==Documentation== +''InterSystems Documentation''
+http://docs.intersystems.com + +''InterSystems Class Reference (Caché 2012.2)''
+http://docs.intersystems.com/cache20122/csp/documatic/%25CSP.Documatic.cls \ No newline at end of file diff --git a/Lang/Cache-ObjectScript/DNS-query b/Lang/Cache-ObjectScript/DNS-query new file mode 120000 index 0000000000..2299f15497 --- /dev/null +++ b/Lang/Cache-ObjectScript/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/Cache-ObjectScript \ No newline at end of file diff --git a/Lang/Cache-ObjectScript/JSON b/Lang/Cache-ObjectScript/JSON new file mode 120000 index 0000000000..e34e673978 --- /dev/null +++ b/Lang/Cache-ObjectScript/JSON @@ -0,0 +1 @@ +../../Task/JSON/Cache-ObjectScript \ No newline at end of file diff --git a/Lang/Caml/0DESCRIPTION b/Lang/Caml/0DESCRIPTION new file mode 100644 index 0000000000..d94f7c82fd --- /dev/null +++ b/Lang/Caml/0DESCRIPTION @@ -0,0 +1,2 @@ +{{language|Caml}}{{stub}} +Relative of [[Standard ML]] that took a different path from the foundational [[derived from::ML]] language. It's derived language, [[OCaml]], is more well-known. \ No newline at end of file diff --git a/Lang/Cat/0DESCRIPTION b/Lang/Cat/0DESCRIPTION new file mode 100644 index 0000000000..5d85d8943a --- /dev/null +++ b/Lang/Cat/0DESCRIPTION @@ -0,0 +1,9 @@ +{{language +|site=http://www.cat-language.com/ +}} +Cat is a functional stack-based programming language inspired by the [[Joy]] programming language. Cat provides a static type system with type inferencing (like [[ML]] or [[Haskell]]), and a term rewriting macro language extension language called MetaCat. Cat uses static typing, and is somewhat less flexibility but safer than Joy. + +All constructs in Cat (atomic programs, user defined programs, operators, literals, lists) behave as functions which takes a single stack as input and returns a new stack. In Cat the concatenation of two functions (e.g. [f g]) has the effect of composition of both functions (e.g. g(f(x))). All new user defined functions are defined as lists of functions. Cat not only has no variable declaration, there are no argument declarations. Cat also lends itself to the higher order functional programming: the lambda operation in Cat is the list construction operator "[...]" and currying can be achieved used basic operations such as "cons". + +==See Also== +[[wp:Cat_(programming_language)|Cat (programming language)]] \ No newline at end of file diff --git a/Lang/Cduce/0DESCRIPTION b/Lang/Cduce/0DESCRIPTION new file mode 100644 index 0000000000..0733d4d1ec --- /dev/null +++ b/Lang/Cduce/0DESCRIPTION @@ -0,0 +1,3 @@ +{{stub}}{{language +|site=http://www.cduce.org/ +}} \ No newline at end of file diff --git a/Lang/Cduce/FizzBuzz b/Lang/Cduce/FizzBuzz new file mode 120000 index 0000000000..2e2118972d --- /dev/null +++ b/Lang/Cduce/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Cduce \ No newline at end of file diff --git a/Lang/Cecil/0DESCRIPTION b/Lang/Cecil/0DESCRIPTION new file mode 100644 index 0000000000..af88b119f7 --- /dev/null +++ b/Lang/Cecil/0DESCRIPTION @@ -0,0 +1,13 @@ +{{language|Cecil +|site=http://www.cs.washington.edu/research/projects/cecil/ +}} + +Cecil is a pure object-oriented programming language. Cecil has many similarities to other object-oriented languages, most notably [[Objective-C]], [[Modula-3]], and [[Self]]. The main goals of the project were extensibility, orthogonality, efficiency, and ease-of-use. + +The language supports multiple dispatch and multimethods, dynamic inheritance, and optional static type checking. Unlike most other OOP systems, Cecil allows subtyping and code inheritance to be used separately, allowing run-time or external extension of object classes or instances. Like [[Objective-C]], all object services in Cecil are invoked by message passing, and the language supports run-time class identification. These features allow Cecil to support dynamic, exploratory programming styles. Parameterized types and methods (generics, polymorphism), garbage collection, and delegation are also supported. Cecil also supports a module mechanism for isolating independent libraries or packages. + +The [[Diesel]] language is the successor of Cecil.[[#Citation|[1]]] + + +==Citations== +#[[wp:Cecil (programming language)|Wikipedia: Cecil]] \ No newline at end of file diff --git a/Lang/Chapel/0DESCRIPTION b/Lang/Chapel/0DESCRIPTION new file mode 100644 index 0000000000..7a627fdeb4 --- /dev/null +++ b/Lang/Chapel/0DESCRIPTION @@ -0,0 +1,7 @@ +{{stub}}{{language|Chapel +|site=http://chapel.cray.com/ +}} + +Chapel is an emerging parallel programming language whose design and development is being led by Cray Inc. Chapel is being developed as an open-source effort with contributions from academia, industry, and scientific computing centers. Chapel emerged from Cray's entry in the DARPA-led High Productivity Computing Systems program (HPCS). + +Chapel is designed to improve the productivity of high-end computer users while also serving as a portable parallel programming model that can be used on commodity clusters or desktop multicore systems. Chapel strives to vastly improve the programmability of large-scale parallel computers while matching or beating the performance and portability of current programming models like MPI. \ No newline at end of file diff --git a/Lang/Chapel/99-Bottles-of-Beer b/Lang/Chapel/99-Bottles-of-Beer new file mode 120000 index 0000000000..a29e1fd59d --- /dev/null +++ b/Lang/Chapel/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Chapel \ No newline at end of file diff --git a/Lang/Chef/0DESCRIPTION b/Lang/Chef/0DESCRIPTION new file mode 100644 index 0000000000..f4c7e4698d --- /dev/null +++ b/Lang/Chef/0DESCRIPTION @@ -0,0 +1,8 @@ +{{stub}}{{language|Chef +|site=http://www.dangermouse.net/esoteric/chef.html}}[[Category:Esoteric Languages]] +'''Chef''' is an esoteric programming language designed by David Morgan-Mar. It is based on the manipulation of data values in a number of [[stack]]s (the same idea is used in assembly programming languages). The joke is that the variables tend to be named after basic foodstuffs, the stacks are called 'mixing bowls' and the instructions for manipulating them 'mix', 'stir', etc.. A program, then, reads much like a cooking recipe. + +==External links== +*[http://www.dangermouse.net/esoteric/ DM's Esoteric Programming Languages] +*[http://search.cpan.org/dist/Acme-Chef An interpreter for Chef written in Perl] +*[[eso:Chef|Chef on Esolangs]] \ No newline at end of file diff --git a/Lang/Chef/99-Bottles-of-Beer b/Lang/Chef/99-Bottles-of-Beer new file mode 120000 index 0000000000..0a81826598 --- /dev/null +++ b/Lang/Chef/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Chef \ No newline at end of file diff --git a/Lang/Chef/Arithmetic-Integer b/Lang/Chef/Arithmetic-Integer new file mode 120000 index 0000000000..ee54166651 --- /dev/null +++ b/Lang/Chef/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Chef \ No newline at end of file diff --git a/Lang/Chef/Averages-Arithmetic-mean b/Lang/Chef/Averages-Arithmetic-mean new file mode 120000 index 0000000000..71d181d9a2 --- /dev/null +++ b/Lang/Chef/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Chef \ No newline at end of file diff --git a/Lang/Chef/Comments b/Lang/Chef/Comments new file mode 120000 index 0000000000..110d8e0d38 --- /dev/null +++ b/Lang/Chef/Comments @@ -0,0 +1 @@ +../../Task/Comments/Chef \ No newline at end of file diff --git a/Lang/Chef/FizzBuzz b/Lang/Chef/FizzBuzz new file mode 120000 index 0000000000..c94a46f378 --- /dev/null +++ b/Lang/Chef/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Chef \ No newline at end of file diff --git a/Lang/Cilk++/0DESCRIPTION b/Lang/Cilk++/0DESCRIPTION new file mode 100644 index 0000000000..e84522db5a --- /dev/null +++ b/Lang/Cilk++/0DESCRIPTION @@ -0,0 +1,13 @@ +{{language|Cilk++ +|site=http://software.intel.com/en-us/articles/intel-cilk/ +}} + +Cilk++ is an extension to C++ that offers a quick, easy and reliable way to improve the performance of C++ programs on multi-core processors. + +It introduces three new key words: + +* The cilk_spawn keyword modifies a function call statement to tell the Cilk++ runtime system that the function may (but is not required to) run in parallel with the caller + +* The cilk_sync statement indicates that the current function cannot run in parallel with its spawned children. After the children all complete, the current function can continue. + +* A cilk_for loop is a replacement for the normal C++ for loop that permits loop iterations to run in parallel. The Cilk++ compiler converts a cilk_for loop into an efficient divide-and-conquer recursive traversal over the loop iterations. \ No newline at end of file diff --git a/Lang/Cilk/0DESCRIPTION b/Lang/Cilk/0DESCRIPTION new file mode 100644 index 0000000000..e58181304a --- /dev/null +++ b/Lang/Cilk/0DESCRIPTION @@ -0,0 +1,24 @@ +{{wikipedia|Cilk}} + + +{{language|Cilk +|exec=machine +|site=http://supertech.csail.mit.edu/cilk/ +|gc=no +|safety=unsafe +|parampass=both +|checking=static +|compat=nominative +|express=explicit +|strength=weak +|tags=cilk +|altsite=http://www.cilk.com/}} +[[derived from::C| ]] + +'''Cilk''' (pronounced ''silk'') is a general-purpose programming language designed for multithreaded [[wp:parallel computing|parallel computing]]. + +The Cilk language has been developed since 1994 at the [[wp:Massachusetts Institute of Technology|MIT Laboratory for Computer Science]]. It is based on [[:Category:C|ANSI C]], with the addition of a handful of Cilk-specific keywords. When the Cilk keywords are removed from Cilk source code, the result is a valid C program, called the ''serial elision'' (or ''C elision'') of the full Cilk program. Cilk is a faithful extension of C and the serial elision of any Cilk program is always a valid serial implementation in C of the semantics of the parallel Cilk program. + +==See also== +*[http://supertech.csail.mit.edu/cilk/ Cilk page at MIT] +*[[wp:Cilk|Cilk on Wikipedia]] \ No newline at end of file diff --git a/Lang/Clay/0DESCRIPTION b/Lang/Clay/0DESCRIPTION new file mode 100644 index 0000000000..213e3b6f94 --- /dev/null +++ b/Lang/Clay/0DESCRIPTION @@ -0,0 +1,10 @@ +{{stub}} +{{language +|site=http://tachyon.in/clay/ +}} +Clay is a systems programming language with whole program type propagation designed to support Generic programming. +It supports Multiple dispatch and compile time meta-programming. It does not have garbage collection + +There is little documentation, but the following discussions may be of help: +* [http://lambda-the-ultimate.org/node/4023 Discussion of Clay on Lambda the Ultimate] +* [http://www.reddit.com/r/programming/comments/ctmxx/the_clay_programming_language/ Discussion of Clay on on Reddit] \ No newline at end of file diff --git a/Lang/Clay/99-Bottles-of-Beer b/Lang/Clay/99-Bottles-of-Beer new file mode 120000 index 0000000000..431d0f5cef --- /dev/null +++ b/Lang/Clay/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Clay \ No newline at end of file diff --git a/Lang/Clay/Accumulator-factory b/Lang/Clay/Accumulator-factory new file mode 120000 index 0000000000..9a71754d02 --- /dev/null +++ b/Lang/Clay/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Clay \ No newline at end of file diff --git a/Lang/Clay/Ackermann-function b/Lang/Clay/Ackermann-function new file mode 120000 index 0000000000..c153d61e8a --- /dev/null +++ b/Lang/Clay/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Clay \ No newline at end of file diff --git a/Lang/Clay/Euler-method b/Lang/Clay/Euler-method new file mode 120000 index 0000000000..178dbb1ac1 --- /dev/null +++ b/Lang/Clay/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Clay \ No newline at end of file diff --git a/Lang/Clay/Extend-your-language b/Lang/Clay/Extend-your-language new file mode 120000 index 0000000000..e347fa8135 --- /dev/null +++ b/Lang/Clay/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Clay \ No newline at end of file diff --git a/Lang/Clay/FizzBuzz b/Lang/Clay/FizzBuzz new file mode 120000 index 0000000000..7c29e40abd --- /dev/null +++ b/Lang/Clay/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Clay \ No newline at end of file diff --git a/Lang/Clean/0DESCRIPTION b/Lang/Clean/0DESCRIPTION new file mode 100644 index 0000000000..f8df15c3ef --- /dev/null +++ b/Lang/Clean/0DESCRIPTION @@ -0,0 +1,12 @@ +{{language|Clean +|strength=strong +|express=implicit +|checking=static +|gc=yes +|LCT=yes}} +{{language programming paradigm|Declarative}} +'''Clean''' is a pure and lazy functional [[programming language]]. + +==Citations== +* [http://clean.cs.ru.nl/ The Clean web site] +* [[wp:Clean_%28programming_language%29|Wikipedia:Clean (programming language)]] \ No newline at end of file diff --git a/Lang/Clean/Apply-a-callback-to-an-array b/Lang/Clean/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..ea6e71c8d5 --- /dev/null +++ b/Lang/Clean/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Clean \ No newline at end of file diff --git a/Lang/Clean/Boolean-values b/Lang/Clean/Boolean-values new file mode 120000 index 0000000000..378a14df2e --- /dev/null +++ b/Lang/Clean/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Clean \ No newline at end of file diff --git a/Lang/Clean/Command-line-arguments b/Lang/Clean/Command-line-arguments new file mode 120000 index 0000000000..5bf5b55a3e --- /dev/null +++ b/Lang/Clean/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Clean \ No newline at end of file diff --git a/Lang/Clean/Comments b/Lang/Clean/Comments new file mode 120000 index 0000000000..29401d5693 --- /dev/null +++ b/Lang/Clean/Comments @@ -0,0 +1 @@ +../../Task/Comments/Clean \ No newline at end of file diff --git a/Lang/Clean/Compound-data-type b/Lang/Clean/Compound-data-type new file mode 120000 index 0000000000..5acc9c714a --- /dev/null +++ b/Lang/Clean/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Clean \ No newline at end of file diff --git a/Lang/Clean/Conditional-structures b/Lang/Clean/Conditional-structures new file mode 120000 index 0000000000..97b0a365f2 --- /dev/null +++ b/Lang/Clean/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Clean \ No newline at end of file diff --git a/Lang/Clean/Create-a-two-dimensional-array-at-runtime b/Lang/Clean/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..ea3674afb1 --- /dev/null +++ b/Lang/Clean/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Clean \ No newline at end of file diff --git a/Lang/Clean/Empty-program b/Lang/Clean/Empty-program new file mode 120000 index 0000000000..e6023bb378 --- /dev/null +++ b/Lang/Clean/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Clean \ No newline at end of file diff --git a/Lang/Clipper-XBase++/0DESCRIPTION b/Lang/Clipper-XBase++/0DESCRIPTION new file mode 100644 index 0000000000..b2896f085c --- /dev/null +++ b/Lang/Clipper-XBase++/0DESCRIPTION @@ -0,0 +1,19 @@ +{{language}}The Clipper Language was written originally to create executable .EXE files out of the code written for dBase III from Ashton-Tate, which was an interpretative language. + +The original writers of Clipper were Ashton-Tate employees that formed a company named Nantucket. The story goes, while sitting in a bar on the island of Nantucket, in MA, and looking at a painting of a Clipper Ship. + +Later on, Nantucket was bought by Computer Associates who discontinued maintaining Clipper (last version was 5.3) in 1997. + +I believe it was the most powerful relational database language of it's time and it is still in use by some large corporations because of it's simplicity and reliability. When the [[Windows]] world came into the scenery, several companies wrote languages that are near 100% compatible with Clipper. Two very well use are XBase++ and xHarbour. + +Before dBase came about, to find a record in a table you had to do a binary sort. One of the big features, among others, of dBase was that it could find one record out of a billion by doing only 3 comparisons (on a 4.7 MHz computer) that took less than one second using index files as reference. They also invented the DBF file structure which carries the structure of the table internally in record # 0, also known as the phantom or ghost record. + +[http://www.clippersolutions.com Clipper Solutions] + +[http://www.alaska-software.com Alaska Software] + +[http://www.xharbour.org xHarbour] + +[http://www.xailer.com Xailer] + +[http://www.donnay-software.com Donnay Software] \ No newline at end of file diff --git a/Lang/Clipper/0DESCRIPTION b/Lang/Clipper/0DESCRIPTION new file mode 100644 index 0000000000..96b8bf005c --- /dev/null +++ b/Lang/Clipper/0DESCRIPTION @@ -0,0 +1 @@ +{{language}}{{Stub}} \ No newline at end of file diff --git a/Lang/Clipper/FizzBuzz b/Lang/Clipper/FizzBuzz new file mode 120000 index 0000000000..6daa8d1dfb --- /dev/null +++ b/Lang/Clipper/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Clipper \ No newline at end of file diff --git a/Lang/Clojure/Character-codes b/Lang/Clojure/Character-codes new file mode 120000 index 0000000000..e29f87a09e --- /dev/null +++ b/Lang/Clojure/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Character-matching b/Lang/Clojure/Character-matching new file mode 120000 index 0000000000..ca5eff8664 --- /dev/null +++ b/Lang/Clojure/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Combinations b/Lang/Clojure/Combinations new file mode 120000 index 0000000000..9e7433ddbe --- /dev/null +++ b/Lang/Clojure/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Combinations-with-repetitions b/Lang/Clojure/Combinations-with-repetitions new file mode 120000 index 0000000000..d326f19d27 --- /dev/null +++ b/Lang/Clojure/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Command-line-arguments b/Lang/Clojure/Command-line-arguments new file mode 120000 index 0000000000..3ad5cfaba9 --- /dev/null +++ b/Lang/Clojure/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Compile-time-calculation b/Lang/Clojure/Compile-time-calculation new file mode 120000 index 0000000000..e55f888533 --- /dev/null +++ b/Lang/Clojure/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Compound-data-type b/Lang/Clojure/Compound-data-type new file mode 120000 index 0000000000..cf71cc21e3 --- /dev/null +++ b/Lang/Clojure/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Concurrent-computing b/Lang/Clojure/Concurrent-computing new file mode 120000 index 0000000000..c5c65bb044 --- /dev/null +++ b/Lang/Clojure/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Conditional-structures b/Lang/Clojure/Conditional-structures new file mode 120000 index 0000000000..5a00167cc8 --- /dev/null +++ b/Lang/Clojure/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Constrained-random-points-on-a-circle b/Lang/Clojure/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..ebfd95a465 --- /dev/null +++ b/Lang/Clojure/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Conways-Game-of-Life b/Lang/Clojure/Conways-Game-of-Life new file mode 120000 index 0000000000..0fb22cfad0 --- /dev/null +++ b/Lang/Clojure/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Count-in-octal b/Lang/Clojure/Count-in-octal new file mode 120000 index 0000000000..76bd165d60 --- /dev/null +++ b/Lang/Clojure/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Create-a-file b/Lang/Clojure/Create-a-file new file mode 120000 index 0000000000..ee08225f5e --- /dev/null +++ b/Lang/Clojure/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Create-a-two-dimensional-array-at-runtime b/Lang/Clojure/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..0b3831696f --- /dev/null +++ b/Lang/Clojure/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Clojure \ No newline at end of file diff --git a/Lang/Clojure/DNS-query b/Lang/Clojure/DNS-query new file mode 120000 index 0000000000..81b386eaa7 --- /dev/null +++ b/Lang/Clojure/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Date-format b/Lang/Clojure/Date-format new file mode 120000 index 0000000000..238f507c5b --- /dev/null +++ b/Lang/Clojure/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Date-manipulation b/Lang/Clojure/Date-manipulation new file mode 120000 index 0000000000..5d8db1a480 --- /dev/null +++ b/Lang/Clojure/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Day-of-the-week b/Lang/Clojure/Day-of-the-week new file mode 120000 index 0000000000..1a7bc4a673 --- /dev/null +++ b/Lang/Clojure/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Determine-if-only-one-instance-is-running b/Lang/Clojure/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..ee91ab21d5 --- /dev/null +++ b/Lang/Clojure/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Dining-philosophers b/Lang/Clojure/Dining-philosophers new file mode 120000 index 0000000000..dfcc6de534 --- /dev/null +++ b/Lang/Clojure/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Documentation b/Lang/Clojure/Documentation new file mode 120000 index 0000000000..834e9992d0 --- /dev/null +++ b/Lang/Clojure/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Dot-product b/Lang/Clojure/Dot-product new file mode 120000 index 0000000000..6c8cd06ff3 --- /dev/null +++ b/Lang/Clojure/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Doubly-linked-list-Definition b/Lang/Clojure/Doubly-linked-list-Definition new file mode 120000 index 0000000000..eff2154cde --- /dev/null +++ b/Lang/Clojure/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Doubly-linked-list-Element-definition b/Lang/Clojure/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..16f9862278 --- /dev/null +++ b/Lang/Clojure/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Doubly-linked-list-Element-insertion b/Lang/Clojure/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..0354e58e87 --- /dev/null +++ b/Lang/Clojure/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Doubly-linked-list-Traversal b/Lang/Clojure/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..42920cae8b --- /dev/null +++ b/Lang/Clojure/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Dynamic-variable-names b/Lang/Clojure/Dynamic-variable-names new file mode 120000 index 0000000000..90c2c70a64 --- /dev/null +++ b/Lang/Clojure/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Echo-server b/Lang/Clojure/Echo-server new file mode 120000 index 0000000000..4fc248689c --- /dev/null +++ b/Lang/Clojure/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Element-wise-operations b/Lang/Clojure/Element-wise-operations new file mode 120000 index 0000000000..e61b9cb1ab --- /dev/null +++ b/Lang/Clojure/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Empty-string b/Lang/Clojure/Empty-string new file mode 120000 index 0000000000..447d4d575a --- /dev/null +++ b/Lang/Clojure/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Enforced-immutability b/Lang/Clojure/Enforced-immutability new file mode 120000 index 0000000000..6cfc906b94 --- /dev/null +++ b/Lang/Clojure/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Enumerations b/Lang/Clojure/Enumerations new file mode 120000 index 0000000000..210ea8aa65 --- /dev/null +++ b/Lang/Clojure/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Equilibrium-index b/Lang/Clojure/Equilibrium-index new file mode 120000 index 0000000000..e7f3b5829b --- /dev/null +++ b/Lang/Clojure/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Ethiopian-multiplication b/Lang/Clojure/Ethiopian-multiplication new file mode 120000 index 0000000000..face27fd5d --- /dev/null +++ b/Lang/Clojure/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Evaluate-binomial-coefficients b/Lang/Clojure/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..b02f5c31b7 --- /dev/null +++ b/Lang/Clojure/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Even-or-odd b/Lang/Clojure/Even-or-odd new file mode 120000 index 0000000000..546cb55840 --- /dev/null +++ b/Lang/Clojure/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Evolutionary-algorithm b/Lang/Clojure/Evolutionary-algorithm new file mode 120000 index 0000000000..6a10238869 --- /dev/null +++ b/Lang/Clojure/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Exceptions b/Lang/Clojure/Exceptions new file mode 120000 index 0000000000..8c4af768e9 --- /dev/null +++ b/Lang/Clojure/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Execute-HQ9+ b/Lang/Clojure/Execute-HQ9+ new file mode 120000 index 0000000000..53f444a95d --- /dev/null +++ b/Lang/Clojure/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Execute-a-system-command b/Lang/Clojure/Execute-a-system-command new file mode 120000 index 0000000000..16b055c74a --- /dev/null +++ b/Lang/Clojure/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Exponentiation-operator b/Lang/Clojure/Exponentiation-operator new file mode 120000 index 0000000000..09e5212430 --- /dev/null +++ b/Lang/Clojure/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Extend-your-language b/Lang/Clojure/Extend-your-language new file mode 120000 index 0000000000..ee02cf0314 --- /dev/null +++ b/Lang/Clojure/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Clojure \ No newline at end of file diff --git a/Lang/Cobra/0DESCRIPTION b/Lang/Cobra/0DESCRIPTION new file mode 100644 index 0000000000..4684555963 --- /dev/null +++ b/Lang/Cobra/0DESCRIPTION @@ -0,0 +1,6 @@ +{{stub}} +{{language +|site=http://cobra-language.com/ +}} +Cobra is an object-oriented programming language produced by Cobra Language LLC. +It supports both static and dynamic typing and has first class support for contracts and unit testing. It is strongly influenced by [[Python]], [[C#]], [[Eiffel]] and [[Objective-C]]. \ No newline at end of file diff --git a/Lang/Cobra/Averages-Arithmetic-mean b/Lang/Cobra/Averages-Arithmetic-mean new file mode 120000 index 0000000000..11b184c26b --- /dev/null +++ b/Lang/Cobra/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Cobra \ No newline at end of file diff --git a/Lang/CoffeeScript/CSV-to-HTML-translation b/Lang/CoffeeScript/CSV-to-HTML-translation new file mode 120000 index 0000000000..2a1dc0453c --- /dev/null +++ b/Lang/CoffeeScript/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Case-sensitivity-of-identifiers b/Lang/CoffeeScript/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..6839271161 --- /dev/null +++ b/Lang/CoffeeScript/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Character-codes b/Lang/CoffeeScript/Character-codes new file mode 120000 index 0000000000..25dc086cde --- /dev/null +++ b/Lang/CoffeeScript/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Character-matching b/Lang/CoffeeScript/Character-matching new file mode 120000 index 0000000000..cb8521a139 --- /dev/null +++ b/Lang/CoffeeScript/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Chat-server b/Lang/CoffeeScript/Chat-server new file mode 120000 index 0000000000..54b012e300 --- /dev/null +++ b/Lang/CoffeeScript/Chat-server @@ -0,0 +1 @@ +../../Task/Chat-server/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Combinations b/Lang/CoffeeScript/Combinations new file mode 120000 index 0000000000..44653bd716 --- /dev/null +++ b/Lang/CoffeeScript/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Combinations-with-repetitions b/Lang/CoffeeScript/Combinations-with-repetitions new file mode 120000 index 0000000000..9f0e2b6bf5 --- /dev/null +++ b/Lang/CoffeeScript/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Compound-data-type b/Lang/CoffeeScript/Compound-data-type new file mode 120000 index 0000000000..21d53e0d27 --- /dev/null +++ b/Lang/CoffeeScript/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Concurrent-computing b/Lang/CoffeeScript/Concurrent-computing new file mode 120000 index 0000000000..f62d0acfbd --- /dev/null +++ b/Lang/CoffeeScript/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Conditional-structures b/Lang/CoffeeScript/Conditional-structures new file mode 120000 index 0000000000..d87bdc87a8 --- /dev/null +++ b/Lang/CoffeeScript/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Constrained-random-points-on-a-circle b/Lang/CoffeeScript/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..154a288b01 --- /dev/null +++ b/Lang/CoffeeScript/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Continued-fraction b/Lang/CoffeeScript/Continued-fraction new file mode 120000 index 0000000000..629bbb2cd5 --- /dev/null +++ b/Lang/CoffeeScript/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Count-in-factors b/Lang/CoffeeScript/Count-in-factors new file mode 120000 index 0000000000..2f1bb90b53 --- /dev/null +++ b/Lang/CoffeeScript/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Count-in-octal b/Lang/CoffeeScript/Count-in-octal new file mode 120000 index 0000000000..69c4b294b0 --- /dev/null +++ b/Lang/CoffeeScript/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Count-occurrences-of-a-substring b/Lang/CoffeeScript/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..513d1ba7af --- /dev/null +++ b/Lang/CoffeeScript/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Create-an-HTML-table b/Lang/CoffeeScript/Create-an-HTML-table new file mode 120000 index 0000000000..65bbfbb1cf --- /dev/null +++ b/Lang/CoffeeScript/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/DNS-query b/Lang/CoffeeScript/DNS-query new file mode 120000 index 0000000000..1c484763bc --- /dev/null +++ b/Lang/CoffeeScript/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Date-format b/Lang/CoffeeScript/Date-format new file mode 120000 index 0000000000..f97cdfd8ff --- /dev/null +++ b/Lang/CoffeeScript/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Day-of-the-week b/Lang/CoffeeScript/Day-of-the-week new file mode 120000 index 0000000000..2830dff321 --- /dev/null +++ b/Lang/CoffeeScript/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Dot-product b/Lang/CoffeeScript/Dot-product new file mode 120000 index 0000000000..c836558ced --- /dev/null +++ b/Lang/CoffeeScript/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Echo-server b/Lang/CoffeeScript/Echo-server new file mode 120000 index 0000000000..08d0d4b579 --- /dev/null +++ b/Lang/CoffeeScript/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Empty-directory b/Lang/CoffeeScript/Empty-directory new file mode 120000 index 0000000000..d1248e13a4 --- /dev/null +++ b/Lang/CoffeeScript/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Empty-program b/Lang/CoffeeScript/Empty-program new file mode 120000 index 0000000000..c325b31ffa --- /dev/null +++ b/Lang/CoffeeScript/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Empty-string b/Lang/CoffeeScript/Empty-string new file mode 120000 index 0000000000..07895e4adf --- /dev/null +++ b/Lang/CoffeeScript/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Ethiopian-multiplication b/Lang/CoffeeScript/Ethiopian-multiplication new file mode 120000 index 0000000000..6cc0429a76 --- /dev/null +++ b/Lang/CoffeeScript/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Evaluate-binomial-coefficients b/Lang/CoffeeScript/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..87e62a12ee --- /dev/null +++ b/Lang/CoffeeScript/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/CoffeeScript \ No newline at end of file diff --git a/Lang/ColdFusion/0DESCRIPTION b/Lang/ColdFusion/0DESCRIPTION new file mode 100644 index 0000000000..7ed3c1cc66 --- /dev/null +++ b/Lang/ColdFusion/0DESCRIPTION @@ -0,0 +1,11 @@ +{{language|ColdFusion +|strength=weak +|express=implicit +|checking=dynamic +|site=http://www.adobe.com/products/coldfusion +|LCT=yes}}'''ColdFusion''' is an application server and software development framework used for the development of computer software in general, and dynamic web sites in particular. In this regard, ColdFusion is a similar product to [[Microsoft]] [[ASP|ASP.NET]] or [[Java|Java Enterprise Edition]]. + +The primary feature of ColdFusion is its associated scripting language, ColdFusion Markup Language (CFML), which compares to [[Java Server Pages|JSP]], [[C sharp|C#]], or [[PHP]] and resembles [[HTML]] in syntax. "ColdFusion" is often used synonymously with "CFML", but it should be noted that there are additional CFML application servers besides ColdFusion, and that ColdFusion supports programming languages other than CFML, such as server-side [[ActionScript]]. + +==Citations== +* [[wp:ColdFusion|Wikipedia:Coldfusion]] \ No newline at end of file diff --git a/Lang/ColdFusion/100-doors b/Lang/ColdFusion/100-doors new file mode 120000 index 0000000000..d00f5f4c73 --- /dev/null +++ b/Lang/ColdFusion/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/99-Bottles-of-Beer b/Lang/ColdFusion/99-Bottles-of-Beer new file mode 120000 index 0000000000..95aaeab71f --- /dev/null +++ b/Lang/ColdFusion/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Associative-array-Creation b/Lang/ColdFusion/Associative-array-Creation new file mode 120000 index 0000000000..6e033d4116 --- /dev/null +++ b/Lang/ColdFusion/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Comments b/Lang/ColdFusion/Comments new file mode 120000 index 0000000000..449bad5fbb --- /dev/null +++ b/Lang/ColdFusion/Comments @@ -0,0 +1 @@ +../../Task/Comments/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Conditional-structures b/Lang/ColdFusion/Conditional-structures new file mode 120000 index 0000000000..d67b5fc705 --- /dev/null +++ b/Lang/ColdFusion/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Date-format b/Lang/ColdFusion/Date-format new file mode 120000 index 0000000000..eca256c4c0 --- /dev/null +++ b/Lang/ColdFusion/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Day-of-the-week b/Lang/ColdFusion/Day-of-the-week new file mode 120000 index 0000000000..58258519f2 --- /dev/null +++ b/Lang/ColdFusion/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Determine-if-a-string-is-numeric b/Lang/ColdFusion/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..fb1934cbdd --- /dev/null +++ b/Lang/ColdFusion/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Ethiopian-multiplication b/Lang/ColdFusion/Ethiopian-multiplication new file mode 120000 index 0000000000..5edcca8b6c --- /dev/null +++ b/Lang/ColdFusion/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Exceptions b/Lang/ColdFusion/Exceptions new file mode 120000 index 0000000000..23dbab67cf --- /dev/null +++ b/Lang/ColdFusion/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/ColdFusion \ No newline at end of file diff --git a/Lang/Common-Lisp/0DESCRIPTION b/Lang/Common-Lisp/0DESCRIPTION new file mode 100644 index 0000000000..5ab01e735c --- /dev/null +++ b/Lang/Common-Lisp/0DESCRIPTION @@ -0,0 +1,21 @@ +{{language +|exec=machine +|strength=strong +|safety=safe +|checking=both +|gc=yes +|LCT=yes}} +{{implementation|Lisp}} +{{language programming paradigm|functional}} +{{language programming paradigm|procedural}} +{{language programming paradigm|object-oriented}} +{{language programming paradigm|reflective}} + +'''Common Lisp''', commonly abbreviated '''CL''', is a dialect of the [[derived from::Lisp]] programming language, standardised by [[ANSI]] X3.226-1994. Developed as a common successor to Maclisp and Lisp Machine Lisp, it is not an implementation but a language specification. Several implementations of the Common Lisp standard are available, including commercial products and [[open source]] software. + +Common Lisp is a general-purpose programming language, in contrast to Lisp variants such as [[Emacs Lisp]] and AutoLISP which are embedded extension languages in particular products. Unlike many earlier Lisps, Common Lisp (like [[derived from::Scheme]]) uses lexical variable scope. + +The "CL-USER> " prompt seen in front of some examples shows that the code was run in a Lisp [[read-eval-print loop]], or REPL, running interactively in an environment such as [[SLIME]]. + +==Citations== +* [[wp:Common_lisp|Wikipedia:Common Lisp]] \ No newline at end of file diff --git a/Lang/Common-Lisp/100-doors b/Lang/Common-Lisp/100-doors new file mode 120000 index 0000000000..d242b6d0a8 --- /dev/null +++ b/Lang/Common-Lisp/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/24-game b/Lang/Common-Lisp/24-game new file mode 120000 index 0000000000..0feaeb0543 --- /dev/null +++ b/Lang/Common-Lisp/24-game @@ -0,0 +1 @@ +../../Task/24-game/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/99-Bottles-of-Beer b/Lang/Common-Lisp/99-Bottles-of-Beer new file mode 120000 index 0000000000..ff0505e107 --- /dev/null +++ b/Lang/Common-Lisp/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/A+B b/Lang/Common-Lisp/A+B new file mode 120000 index 0000000000..a181ad5d19 --- /dev/null +++ b/Lang/Common-Lisp/A+B @@ -0,0 +1 @@ +../../Task/A+B/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Abstract-type b/Lang/Common-Lisp/Abstract-type new file mode 120000 index 0000000000..8f98fd3324 --- /dev/null +++ b/Lang/Common-Lisp/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Accumulator-factory b/Lang/Common-Lisp/Accumulator-factory new file mode 120000 index 0000000000..9d316cb805 --- /dev/null +++ b/Lang/Common-Lisp/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Ackermann-function b/Lang/Common-Lisp/Ackermann-function new file mode 120000 index 0000000000..ab6a668d58 --- /dev/null +++ b/Lang/Common-Lisp/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Common-Lisp/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..22b667889b --- /dev/null +++ b/Lang/Common-Lisp/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Address-of-a-variable b/Lang/Common-Lisp/Address-of-a-variable new file mode 120000 index 0000000000..efd1981bae --- /dev/null +++ b/Lang/Common-Lisp/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Align-columns b/Lang/Common-Lisp/Align-columns new file mode 120000 index 0000000000..cad987516c --- /dev/null +++ b/Lang/Common-Lisp/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Anagrams b/Lang/Common-Lisp/Anagrams new file mode 120000 index 0000000000..fb611d7517 --- /dev/null +++ b/Lang/Common-Lisp/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Anagrams-Deranged-anagrams b/Lang/Common-Lisp/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..b3085a29f3 --- /dev/null +++ b/Lang/Common-Lisp/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Animation b/Lang/Common-Lisp/Animation new file mode 120000 index 0000000000..ea32b5546f --- /dev/null +++ b/Lang/Common-Lisp/Animation @@ -0,0 +1 @@ +../../Task/Animation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Anonymous-recursion b/Lang/Common-Lisp/Anonymous-recursion new file mode 120000 index 0000000000..48f8252c9e --- /dev/null +++ b/Lang/Common-Lisp/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Apply-a-callback-to-an-array b/Lang/Common-Lisp/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..be967c175d --- /dev/null +++ b/Lang/Common-Lisp/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Arbitrary-precision-integers-(included) b/Lang/Common-Lisp/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..ecef923ba4 --- /dev/null +++ b/Lang/Common-Lisp/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Arithmetic-Complex b/Lang/Common-Lisp/Arithmetic-Complex new file mode 120000 index 0000000000..f0ad17cb84 --- /dev/null +++ b/Lang/Common-Lisp/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Arithmetic-Integer b/Lang/Common-Lisp/Arithmetic-Integer new file mode 120000 index 0000000000..8b18244630 --- /dev/null +++ b/Lang/Common-Lisp/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Arithmetic-Rational b/Lang/Common-Lisp/Arithmetic-Rational new file mode 120000 index 0000000000..46786d5844 --- /dev/null +++ b/Lang/Common-Lisp/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Arithmetic-evaluation b/Lang/Common-Lisp/Arithmetic-evaluation new file mode 120000 index 0000000000..a538f098c9 --- /dev/null +++ b/Lang/Common-Lisp/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Arithmetic-geometric-mean b/Lang/Common-Lisp/Arithmetic-geometric-mean new file mode 120000 index 0000000000..09f8e5f851 --- /dev/null +++ b/Lang/Common-Lisp/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Array-concatenation b/Lang/Common-Lisp/Array-concatenation new file mode 120000 index 0000000000..deecea21de --- /dev/null +++ b/Lang/Common-Lisp/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Arrays b/Lang/Common-Lisp/Arrays new file mode 120000 index 0000000000..38fa36efee --- /dev/null +++ b/Lang/Common-Lisp/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Assertions b/Lang/Common-Lisp/Assertions new file mode 120000 index 0000000000..7deab47712 --- /dev/null +++ b/Lang/Common-Lisp/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Associative-array-Creation b/Lang/Common-Lisp/Associative-array-Creation new file mode 120000 index 0000000000..2bffaf59f2 --- /dev/null +++ b/Lang/Common-Lisp/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Associative-array-Iteration b/Lang/Common-Lisp/Associative-array-Iteration new file mode 120000 index 0000000000..5ece7776df --- /dev/null +++ b/Lang/Common-Lisp/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Averages-Arithmetic-mean b/Lang/Common-Lisp/Averages-Arithmetic-mean new file mode 120000 index 0000000000..033b00d662 --- /dev/null +++ b/Lang/Common-Lisp/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Averages-Mean-angle b/Lang/Common-Lisp/Averages-Mean-angle new file mode 120000 index 0000000000..fc4b57ac8f --- /dev/null +++ b/Lang/Common-Lisp/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Averages-Median b/Lang/Common-Lisp/Averages-Median new file mode 120000 index 0000000000..6bf03023c8 --- /dev/null +++ b/Lang/Common-Lisp/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Averages-Pythagorean-means b/Lang/Common-Lisp/Averages-Pythagorean-means new file mode 120000 index 0000000000..f6fd8e4f18 --- /dev/null +++ b/Lang/Common-Lisp/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Averages-Root-mean-square b/Lang/Common-Lisp/Averages-Root-mean-square new file mode 120000 index 0000000000..1379cc597b --- /dev/null +++ b/Lang/Common-Lisp/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Averages-Simple-moving-average b/Lang/Common-Lisp/Averages-Simple-moving-average new file mode 120000 index 0000000000..67a9862702 --- /dev/null +++ b/Lang/Common-Lisp/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Balanced-brackets b/Lang/Common-Lisp/Balanced-brackets new file mode 120000 index 0000000000..9183eaf151 --- /dev/null +++ b/Lang/Common-Lisp/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Balanced-ternary b/Lang/Common-Lisp/Balanced-ternary new file mode 120000 index 0000000000..ba27452e76 --- /dev/null +++ b/Lang/Common-Lisp/Balanced-ternary @@ -0,0 +1 @@ +../../Task/Balanced-ternary/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Best-shuffle b/Lang/Common-Lisp/Best-shuffle new file mode 120000 index 0000000000..a186ba6479 --- /dev/null +++ b/Lang/Common-Lisp/Best-shuffle @@ -0,0 +1 @@ +../../Task/Best-shuffle/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Binary-search b/Lang/Common-Lisp/Binary-search new file mode 120000 index 0000000000..b4a0d629d5 --- /dev/null +++ b/Lang/Common-Lisp/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Binary-strings b/Lang/Common-Lisp/Binary-strings new file mode 120000 index 0000000000..60c2cd0656 --- /dev/null +++ b/Lang/Common-Lisp/Binary-strings @@ -0,0 +1 @@ +../../Task/Binary-strings/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Bitmap b/Lang/Common-Lisp/Bitmap new file mode 120000 index 0000000000..ee6ccab38f --- /dev/null +++ b/Lang/Common-Lisp/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Bitmap-Bresenhams-line-algorithm b/Lang/Common-Lisp/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..0d77d53ccf --- /dev/null +++ b/Lang/Common-Lisp/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Bitmap-Midpoint-circle-algorithm b/Lang/Common-Lisp/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..a96e0c5fb8 --- /dev/null +++ b/Lang/Common-Lisp/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Bitmap-Read-a-PPM-file b/Lang/Common-Lisp/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..35eaf891e5 --- /dev/null +++ b/Lang/Common-Lisp/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Bitmap-Write-a-PPM-file b/Lang/Common-Lisp/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..65768b439c --- /dev/null +++ b/Lang/Common-Lisp/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Bitwise-operations b/Lang/Common-Lisp/Bitwise-operations new file mode 120000 index 0000000000..07229b5830 --- /dev/null +++ b/Lang/Common-Lisp/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Break-OO-privacy b/Lang/Common-Lisp/Break-OO-privacy new file mode 120000 index 0000000000..bf5e1866f1 --- /dev/null +++ b/Lang/Common-Lisp/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Bulls-and-cows b/Lang/Common-Lisp/Bulls-and-cows new file mode 120000 index 0000000000..68b031396d --- /dev/null +++ b/Lang/Common-Lisp/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/CRC-32 b/Lang/Common-Lisp/CRC-32 new file mode 120000 index 0000000000..d0b08bd913 --- /dev/null +++ b/Lang/Common-Lisp/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/CSV-to-HTML-translation b/Lang/Common-Lisp/CSV-to-HTML-translation new file mode 120000 index 0000000000..8678b64ed4 --- /dev/null +++ b/Lang/Common-Lisp/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Caesar-cipher b/Lang/Common-Lisp/Caesar-cipher new file mode 120000 index 0000000000..43055cba18 --- /dev/null +++ b/Lang/Common-Lisp/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Call-a-foreign-language-function b/Lang/Common-Lisp/Call-a-foreign-language-function new file mode 120000 index 0000000000..c94afc643d --- /dev/null +++ b/Lang/Common-Lisp/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Call-a-function-in-a-shared-library b/Lang/Common-Lisp/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..5448faaac0 --- /dev/null +++ b/Lang/Common-Lisp/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Case-sensitivity-of-identifiers b/Lang/Common-Lisp/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..bd47c8b99d --- /dev/null +++ b/Lang/Common-Lisp/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Character-codes b/Lang/Common-Lisp/Character-codes new file mode 120000 index 0000000000..0dfcb8c5d6 --- /dev/null +++ b/Lang/Common-Lisp/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Check-that-file-exists b/Lang/Common-Lisp/Check-that-file-exists new file mode 120000 index 0000000000..b8db61705a --- /dev/null +++ b/Lang/Common-Lisp/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Cholesky-decomposition b/Lang/Common-Lisp/Cholesky-decomposition new file mode 120000 index 0000000000..37a6e7e1bb --- /dev/null +++ b/Lang/Common-Lisp/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Classes b/Lang/Common-Lisp/Classes new file mode 120000 index 0000000000..ae1755c352 --- /dev/null +++ b/Lang/Common-Lisp/Classes @@ -0,0 +1 @@ +../../Task/Classes/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Closest-pair-problem b/Lang/Common-Lisp/Closest-pair-problem new file mode 120000 index 0000000000..0a31306727 --- /dev/null +++ b/Lang/Common-Lisp/Closest-pair-problem @@ -0,0 +1 @@ +../../Task/Closest-pair-problem/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Collections b/Lang/Common-Lisp/Collections new file mode 120000 index 0000000000..dc7a30d25c --- /dev/null +++ b/Lang/Common-Lisp/Collections @@ -0,0 +1 @@ +../../Task/Collections/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Combinations b/Lang/Common-Lisp/Combinations new file mode 120000 index 0000000000..7898ac337f --- /dev/null +++ b/Lang/Common-Lisp/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Command-line-arguments b/Lang/Common-Lisp/Command-line-arguments new file mode 120000 index 0000000000..11426e0bd8 --- /dev/null +++ b/Lang/Common-Lisp/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Comments b/Lang/Common-Lisp/Comments new file mode 120000 index 0000000000..979fc91055 --- /dev/null +++ b/Lang/Common-Lisp/Comments @@ -0,0 +1 @@ +../../Task/Comments/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Compile-time-calculation b/Lang/Common-Lisp/Compile-time-calculation new file mode 120000 index 0000000000..f7989845bf --- /dev/null +++ b/Lang/Common-Lisp/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Compound-data-type b/Lang/Common-Lisp/Compound-data-type new file mode 120000 index 0000000000..b9e12e0e4f --- /dev/null +++ b/Lang/Common-Lisp/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Concurrent-computing b/Lang/Common-Lisp/Concurrent-computing new file mode 120000 index 0000000000..f10b901463 --- /dev/null +++ b/Lang/Common-Lisp/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Conditional-structures b/Lang/Common-Lisp/Conditional-structures new file mode 120000 index 0000000000..3b264d7b8e --- /dev/null +++ b/Lang/Common-Lisp/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Constrained-genericity b/Lang/Common-Lisp/Constrained-genericity new file mode 120000 index 0000000000..e891819289 --- /dev/null +++ b/Lang/Common-Lisp/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Constrained-random-points-on-a-circle b/Lang/Common-Lisp/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..11f6571148 --- /dev/null +++ b/Lang/Common-Lisp/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Continued-fraction b/Lang/Common-Lisp/Continued-fraction new file mode 120000 index 0000000000..59f5aef25e --- /dev/null +++ b/Lang/Common-Lisp/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Conways-Game-of-Life b/Lang/Common-Lisp/Conways-Game-of-Life new file mode 120000 index 0000000000..5e7cd2bc05 --- /dev/null +++ b/Lang/Common-Lisp/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Count-in-factors b/Lang/Common-Lisp/Count-in-factors new file mode 120000 index 0000000000..2895204413 --- /dev/null +++ b/Lang/Common-Lisp/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Count-in-octal b/Lang/Common-Lisp/Count-in-octal new file mode 120000 index 0000000000..1983cfd5ac --- /dev/null +++ b/Lang/Common-Lisp/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Count-occurrences-of-a-substring b/Lang/Common-Lisp/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..a3ebeb7e71 --- /dev/null +++ b/Lang/Common-Lisp/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Count-the-coins b/Lang/Common-Lisp/Count-the-coins new file mode 120000 index 0000000000..f891f158cf --- /dev/null +++ b/Lang/Common-Lisp/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Create-a-file b/Lang/Common-Lisp/Create-a-file new file mode 120000 index 0000000000..c2330f0310 --- /dev/null +++ b/Lang/Common-Lisp/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Create-a-two-dimensional-array-at-runtime b/Lang/Common-Lisp/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..615c75e1a7 --- /dev/null +++ b/Lang/Common-Lisp/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Cut-a-rectangle b/Lang/Common-Lisp/Cut-a-rectangle new file mode 120000 index 0000000000..2b00aa714d --- /dev/null +++ b/Lang/Common-Lisp/Cut-a-rectangle @@ -0,0 +1 @@ +../../Task/Cut-a-rectangle/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/DNS-query b/Lang/Common-Lisp/DNS-query new file mode 120000 index 0000000000..0e0d8dcf26 --- /dev/null +++ b/Lang/Common-Lisp/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Date-format b/Lang/Common-Lisp/Date-format new file mode 120000 index 0000000000..908e2e846e --- /dev/null +++ b/Lang/Common-Lisp/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Day-of-the-week b/Lang/Common-Lisp/Day-of-the-week new file mode 120000 index 0000000000..d752884832 --- /dev/null +++ b/Lang/Common-Lisp/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Deal-cards-for-FreeCell b/Lang/Common-Lisp/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..558c35f3dd --- /dev/null +++ b/Lang/Common-Lisp/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Deconvolution-1D b/Lang/Common-Lisp/Deconvolution-1D new file mode 120000 index 0000000000..b8e3bbbfd4 --- /dev/null +++ b/Lang/Common-Lisp/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Deepcopy b/Lang/Common-Lisp/Deepcopy new file mode 120000 index 0000000000..6901285800 --- /dev/null +++ b/Lang/Common-Lisp/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Define-a-primitive-data-type b/Lang/Common-Lisp/Define-a-primitive-data-type new file mode 120000 index 0000000000..788b66818d --- /dev/null +++ b/Lang/Common-Lisp/Define-a-primitive-data-type @@ -0,0 +1 @@ +../../Task/Define-a-primitive-data-type/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Delegates b/Lang/Common-Lisp/Delegates new file mode 120000 index 0000000000..5d2d12c2f4 --- /dev/null +++ b/Lang/Common-Lisp/Delegates @@ -0,0 +1 @@ +../../Task/Delegates/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Delete-a-file b/Lang/Common-Lisp/Delete-a-file new file mode 120000 index 0000000000..86eb45dfbe --- /dev/null +++ b/Lang/Common-Lisp/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Detect-division-by-zero b/Lang/Common-Lisp/Detect-division-by-zero new file mode 120000 index 0000000000..766b3f91fc --- /dev/null +++ b/Lang/Common-Lisp/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Determine-if-a-string-is-numeric b/Lang/Common-Lisp/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..67012b6e35 --- /dev/null +++ b/Lang/Common-Lisp/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Dining-philosophers b/Lang/Common-Lisp/Dining-philosophers new file mode 120000 index 0000000000..0e683f776c --- /dev/null +++ b/Lang/Common-Lisp/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Dot-product b/Lang/Common-Lisp/Dot-product new file mode 120000 index 0000000000..a06a077cf1 --- /dev/null +++ b/Lang/Common-Lisp/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Doubly-linked-list-Definition b/Lang/Common-Lisp/Doubly-linked-list-Definition new file mode 120000 index 0000000000..0d4ebaa29d --- /dev/null +++ b/Lang/Common-Lisp/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Doubly-linked-list-Element-definition b/Lang/Common-Lisp/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..c1cd359655 --- /dev/null +++ b/Lang/Common-Lisp/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Dynamic-variable-names b/Lang/Common-Lisp/Dynamic-variable-names new file mode 120000 index 0000000000..baf9374390 --- /dev/null +++ b/Lang/Common-Lisp/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Echo-server b/Lang/Common-Lisp/Echo-server new file mode 120000 index 0000000000..0c2ffe5473 --- /dev/null +++ b/Lang/Common-Lisp/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Element-wise-operations b/Lang/Common-Lisp/Element-wise-operations new file mode 120000 index 0000000000..1bf70d04c3 --- /dev/null +++ b/Lang/Common-Lisp/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Empty-string b/Lang/Common-Lisp/Empty-string new file mode 120000 index 0000000000..7192d9d1bd --- /dev/null +++ b/Lang/Common-Lisp/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Enumerations b/Lang/Common-Lisp/Enumerations new file mode 120000 index 0000000000..982cd31b87 --- /dev/null +++ b/Lang/Common-Lisp/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Ethiopian-multiplication b/Lang/Common-Lisp/Ethiopian-multiplication new file mode 120000 index 0000000000..b31ddde568 --- /dev/null +++ b/Lang/Common-Lisp/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Euler-method b/Lang/Common-Lisp/Euler-method new file mode 120000 index 0000000000..ef87771c07 --- /dev/null +++ b/Lang/Common-Lisp/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Evaluate-binomial-coefficients b/Lang/Common-Lisp/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..c82eb87374 --- /dev/null +++ b/Lang/Common-Lisp/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Even-or-odd b/Lang/Common-Lisp/Even-or-odd new file mode 120000 index 0000000000..24a4241ed4 --- /dev/null +++ b/Lang/Common-Lisp/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Evolutionary-algorithm b/Lang/Common-Lisp/Evolutionary-algorithm new file mode 120000 index 0000000000..28973cfd26 --- /dev/null +++ b/Lang/Common-Lisp/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Exceptions b/Lang/Common-Lisp/Exceptions new file mode 120000 index 0000000000..682c139b4a --- /dev/null +++ b/Lang/Common-Lisp/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Common-Lisp/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..98cced88d7 --- /dev/null +++ b/Lang/Common-Lisp/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Execute-a-system-command b/Lang/Common-Lisp/Execute-a-system-command new file mode 120000 index 0000000000..e5d2337e70 --- /dev/null +++ b/Lang/Common-Lisp/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Exponentiation-operator b/Lang/Common-Lisp/Exponentiation-operator new file mode 120000 index 0000000000..3117564730 --- /dev/null +++ b/Lang/Common-Lisp/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Extend-your-language b/Lang/Common-Lisp/Extend-your-language new file mode 120000 index 0000000000..4afd11c2e2 --- /dev/null +++ b/Lang/Common-Lisp/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/FizzBuzz b/Lang/Common-Lisp/FizzBuzz new file mode 120000 index 0000000000..b008e8b0a8 --- /dev/null +++ b/Lang/Common-Lisp/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Forest-fire b/Lang/Common-Lisp/Forest-fire new file mode 120000 index 0000000000..9a7ae31bed --- /dev/null +++ b/Lang/Common-Lisp/Forest-fire @@ -0,0 +1 @@ +../../Task/Forest-fire/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Infinity b/Lang/Common-Lisp/Infinity new file mode 120000 index 0000000000..880e47acb4 --- /dev/null +++ b/Lang/Common-Lisp/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/JSON b/Lang/Common-Lisp/JSON new file mode 120000 index 0000000000..2bc74060ad --- /dev/null +++ b/Lang/Common-Lisp/JSON @@ -0,0 +1 @@ +../../Task/JSON/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Knuth-shuffle b/Lang/Common-Lisp/Knuth-shuffle new file mode 120000 index 0000000000..d4e377f43a --- /dev/null +++ b/Lang/Common-Lisp/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Narcissist b/Lang/Common-Lisp/Narcissist new file mode 120000 index 0000000000..4edccf7856 --- /dev/null +++ b/Lang/Common-Lisp/Narcissist @@ -0,0 +1 @@ +../../Task/Narcissist/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Ordered-words b/Lang/Common-Lisp/Ordered-words new file mode 120000 index 0000000000..8f9859692e --- /dev/null +++ b/Lang/Common-Lisp/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Quine b/Lang/Common-Lisp/Quine new file mode 120000 index 0000000000..c33dfa673b --- /dev/null +++ b/Lang/Common-Lisp/Quine @@ -0,0 +1 @@ +../../Task/Quine/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Search-a-list b/Lang/Common-Lisp/Search-a-list new file mode 120000 index 0000000000..5650e4a765 --- /dev/null +++ b/Lang/Common-Lisp/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Common-Lisp \ No newline at end of file diff --git a/Lang/Component-Pascal/0DESCRIPTION b/Lang/Component-Pascal/0DESCRIPTION new file mode 100644 index 0000000000..a83cc2b2e7 --- /dev/null +++ b/Lang/Component-Pascal/0DESCRIPTION @@ -0,0 +1,4 @@ +{{language|Component Pascal}}'''Component Pascal''' is a programming language in the tradition of Oberon and [[Oberon-2]], the last language Niklaus Wirth designed before he retired in 1999. It bears the name of the [[Pascal]] programming language but is incompatible with it. Instead, it is a minor variant and refinement of Oberon-2, designed and supported by a small ETH Zürich spin-off company called Oberon microsystems. Their [[IDE]] is called BlackBox Component Builder. At the time the first version was released (1994) it presented a novel approach to graphical user interface ([[GUI]]) construction based on editable forms, where fields and command buttons are linked to exported variables and executable procedures. This approach bears some similarity to the code-behind way used in [[Microsoft]]'s [[.NET]] 3.0 to access code in XAML. + +==Citations== +* [http://en.wikipedia.org/wiki/Component_Pascal Wikipedia:Component Pascal] \ No newline at end of file diff --git a/Lang/Component-Pascal/Arrays b/Lang/Component-Pascal/Arrays new file mode 120000 index 0000000000..ca2888d8bb --- /dev/null +++ b/Lang/Component-Pascal/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Component-Pascal \ No newline at end of file diff --git a/Lang/Component-Pascal/Assertions b/Lang/Component-Pascal/Assertions new file mode 120000 index 0000000000..765a2c9e43 --- /dev/null +++ b/Lang/Component-Pascal/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Component-Pascal \ No newline at end of file diff --git a/Lang/Component-Pascal/Create-a-two-dimensional-array-at-runtime b/Lang/Component-Pascal/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..deddbb5704 --- /dev/null +++ b/Lang/Component-Pascal/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Component-Pascal \ No newline at end of file diff --git a/Lang/Coq/0DESCRIPTION b/Lang/Coq/0DESCRIPTION new file mode 100644 index 0000000000..f366dcaecc --- /dev/null +++ b/Lang/Coq/0DESCRIPTION @@ -0,0 +1,6 @@ +{{language|Coq}}In computer science, Coq is a proof assistant application. It allows the expression of mathematical assertions, mechanically checks proofs of these assertions, helps to find formal proofs, and extracts a certified program from the constructive proof of its formal specification. Coq works within the theory of the calculus of inductive constructions, a derivative of the calculus of constructions. Coq is not an automated [[wp:Theorem_prover|theorem prover]] but includes automatic theorem proving tactics and various decision procedures. + +==Citations== +* [[wp:Coq|Coq]] + +[[Category:Mathematical programming languages]] \ No newline at end of file diff --git a/Lang/Coq/Ackermann-function b/Lang/Coq/Ackermann-function new file mode 120000 index 0000000000..03a0752c76 --- /dev/null +++ b/Lang/Coq/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Coq \ No newline at end of file diff --git a/Lang/Crack/0DESCRIPTION b/Lang/Crack/0DESCRIPTION new file mode 100644 index 0000000000..0f046e3a6b --- /dev/null +++ b/Lang/Crack/0DESCRIPTION @@ -0,0 +1,14 @@ +{{language|Crack +|exec=machine +|site=http://code.google.com/p/crack-language/ +|gc=yes +|parampass=both +|safety=safe +|checking=static +|strength=strong +|LCT=yes}} +{{language programming paradigm|Object-oriented}} + +Crack aims to provide the ease of development of a scripting language with the performance of a compiled language. The crack language itself derives concepts from [[C++]], [[Java]] and [[Python]], incorporating [[object-oriented programming]], operator overloading and strong typing. + +The "crack" program is a "script executor" that compiles source to machine code [[JIT|on the fly]] (it will cache the code to intermediate formats as appropriate). A static (ahead of time) compiler is also in development. \ No newline at end of file diff --git a/Lang/Crack/Conditional-structures b/Lang/Crack/Conditional-structures new file mode 120000 index 0000000000..ba994c516c --- /dev/null +++ b/Lang/Crack/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Crack \ No newline at end of file diff --git a/Lang/Curry/0DESCRIPTION b/Lang/Curry/0DESCRIPTION new file mode 100644 index 0000000000..5cbad8ae8e --- /dev/null +++ b/Lang/Curry/0DESCRIPTION @@ -0,0 +1,11 @@ +{{stub}}{{language|Curry +|site=http://www-ps.informatik.uni-kiel.de/currywiki/ +}} +{{language programming paradigm|Declarative}} +{{language programming paradigm|functional}} +{{language programming paradigm|Logic_Programming}} + +Curry is a functional logic programming language, based on the Haskell language. + +==See Also== +*[[wp:Curry_(programming_language)|Wikipedia:Curry (programming language)]] \ No newline at end of file diff --git a/Lang/D/0DESCRIPTION b/Lang/D/0DESCRIPTION new file mode 100644 index 0000000000..67d713611f --- /dev/null +++ b/Lang/D/0DESCRIPTION @@ -0,0 +1,19 @@ +{{language|D +|strength=strong +|gc=yes +|safety=both +|express=explicit +|compat=both +|checking=both +|parampass=both +|site=http://dlang.org/ +|LCT=yes}}{{codepad}} +{{language programming paradigm|Imperative}} +{{language programming paradigm|procedural}} +{{language programming paradigm|object-oriented}} +{{language programming paradigm|Functional}} +{{language programming paradigm|generic}} +'''D''' is an [[object-oriented]], [[imperative programming|imperative]], multi-[[:Category:Programming Paradigms|paradigm]] system programming language by Walter Bright of Digital Mars. It originated as a re-engineering of [[C++]], but even though it is predominantly influenced by that language, it is not a variant of C++. D has redesigned some C++ features and has been influenced by concepts used in other programming languages, such as [[Python]], [[Java]], [[C sharp|C#]] and [[Eiffel]]. A stable version, 1.0, was released on January 2, 2007. + +==Citations== +* [[wp:D (programming language)|Wikipedia:D (programming language)]] \ No newline at end of file diff --git a/Lang/D/100-doors b/Lang/D/100-doors new file mode 120000 index 0000000000..93e8ecae82 --- /dev/null +++ b/Lang/D/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/D \ No newline at end of file diff --git a/Lang/D/24-game b/Lang/D/24-game new file mode 120000 index 0000000000..aec7abcc31 --- /dev/null +++ b/Lang/D/24-game @@ -0,0 +1 @@ +../../Task/24-game/D \ No newline at end of file diff --git a/Lang/D/99-Bottles-of-Beer b/Lang/D/99-Bottles-of-Beer new file mode 120000 index 0000000000..dd70a5706d --- /dev/null +++ b/Lang/D/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/D \ No newline at end of file diff --git a/Lang/D/A+B b/Lang/D/A+B new file mode 120000 index 0000000000..b596c542e2 --- /dev/null +++ b/Lang/D/A+B @@ -0,0 +1 @@ +../../Task/A+B/D \ No newline at end of file diff --git a/Lang/D/Abstract-type b/Lang/D/Abstract-type new file mode 120000 index 0000000000..cbcbc60ab6 --- /dev/null +++ b/Lang/D/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/D \ No newline at end of file diff --git a/Lang/D/Accumulator-factory b/Lang/D/Accumulator-factory new file mode 120000 index 0000000000..5bc916c79d --- /dev/null +++ b/Lang/D/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/D \ No newline at end of file diff --git a/Lang/D/Ackermann-function b/Lang/D/Ackermann-function new file mode 120000 index 0000000000..b13205c208 --- /dev/null +++ b/Lang/D/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/D \ No newline at end of file diff --git a/Lang/D/Add-a-variable-to-a-class-instance-at-runtime b/Lang/D/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..06c3751658 --- /dev/null +++ b/Lang/D/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/D \ No newline at end of file diff --git a/Lang/D/Address-of-a-variable b/Lang/D/Address-of-a-variable new file mode 120000 index 0000000000..20b01e6faf --- /dev/null +++ b/Lang/D/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/D \ No newline at end of file diff --git a/Lang/D/Align-columns b/Lang/D/Align-columns new file mode 120000 index 0000000000..513271d497 --- /dev/null +++ b/Lang/D/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/D \ No newline at end of file diff --git a/Lang/D/Anagrams-Deranged-anagrams b/Lang/D/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..201ff8d1bd --- /dev/null +++ b/Lang/D/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/D \ No newline at end of file diff --git a/Lang/D/Animation b/Lang/D/Animation new file mode 120000 index 0000000000..36a5e56e12 --- /dev/null +++ b/Lang/D/Animation @@ -0,0 +1 @@ +../../Task/Animation/D \ No newline at end of file diff --git a/Lang/D/Anonymous-recursion b/Lang/D/Anonymous-recursion new file mode 120000 index 0000000000..26d1e95d3d --- /dev/null +++ b/Lang/D/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/D \ No newline at end of file diff --git a/Lang/D/Apply-a-callback-to-an-array b/Lang/D/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..bc59ea9bc2 --- /dev/null +++ b/Lang/D/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/D \ No newline at end of file diff --git a/Lang/D/Arbitrary-precision-integers-(included) b/Lang/D/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..671b355fe3 --- /dev/null +++ b/Lang/D/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/D \ No newline at end of file diff --git a/Lang/D/Arithmetic-Complex b/Lang/D/Arithmetic-Complex new file mode 120000 index 0000000000..eee2f702be --- /dev/null +++ b/Lang/D/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/D \ No newline at end of file diff --git a/Lang/D/Arithmetic-Integer b/Lang/D/Arithmetic-Integer new file mode 120000 index 0000000000..1363e0004c --- /dev/null +++ b/Lang/D/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/D \ No newline at end of file diff --git a/Lang/D/Arithmetic-Rational b/Lang/D/Arithmetic-Rational new file mode 120000 index 0000000000..f0abbae98e --- /dev/null +++ b/Lang/D/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/D \ No newline at end of file diff --git a/Lang/D/Arithmetic-evaluation b/Lang/D/Arithmetic-evaluation new file mode 120000 index 0000000000..f226fbc3a0 --- /dev/null +++ b/Lang/D/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/D \ No newline at end of file diff --git a/Lang/D/Arithmetic-geometric-mean b/Lang/D/Arithmetic-geometric-mean new file mode 120000 index 0000000000..42c280f9c1 --- /dev/null +++ b/Lang/D/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/D \ No newline at end of file diff --git a/Lang/D/Array-concatenation b/Lang/D/Array-concatenation new file mode 120000 index 0000000000..82611998de --- /dev/null +++ b/Lang/D/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/D \ No newline at end of file diff --git a/Lang/D/Arrays b/Lang/D/Arrays new file mode 120000 index 0000000000..50246534c0 --- /dev/null +++ b/Lang/D/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/D \ No newline at end of file diff --git a/Lang/D/Assertions b/Lang/D/Assertions new file mode 120000 index 0000000000..e006976712 --- /dev/null +++ b/Lang/D/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/D \ No newline at end of file diff --git a/Lang/D/Associative-array-Creation b/Lang/D/Associative-array-Creation new file mode 120000 index 0000000000..877bc1e04b --- /dev/null +++ b/Lang/D/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/D \ No newline at end of file diff --git a/Lang/D/Associative-array-Iteration b/Lang/D/Associative-array-Iteration new file mode 120000 index 0000000000..6e9da8be46 --- /dev/null +++ b/Lang/D/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/D \ No newline at end of file diff --git a/Lang/D/Atomic-updates b/Lang/D/Atomic-updates new file mode 120000 index 0000000000..5e2dd0c55a --- /dev/null +++ b/Lang/D/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/D \ No newline at end of file diff --git a/Lang/D/Average-loop-length b/Lang/D/Average-loop-length new file mode 120000 index 0000000000..8af792e43a --- /dev/null +++ b/Lang/D/Average-loop-length @@ -0,0 +1 @@ +../../Task/Average-loop-length/D \ No newline at end of file diff --git a/Lang/D/Averages-Arithmetic-mean b/Lang/D/Averages-Arithmetic-mean new file mode 120000 index 0000000000..2e776dc6a1 --- /dev/null +++ b/Lang/D/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/D \ No newline at end of file diff --git a/Lang/D/Averages-Mean-angle b/Lang/D/Averages-Mean-angle new file mode 120000 index 0000000000..89cec9493b --- /dev/null +++ b/Lang/D/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/D \ No newline at end of file diff --git a/Lang/D/Averages-Median b/Lang/D/Averages-Median new file mode 120000 index 0000000000..a9ac74d03d --- /dev/null +++ b/Lang/D/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/D \ No newline at end of file diff --git a/Lang/D/Averages-Mode b/Lang/D/Averages-Mode new file mode 120000 index 0000000000..61b91916a3 --- /dev/null +++ b/Lang/D/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/D \ No newline at end of file diff --git a/Lang/D/Averages-Pythagorean-means b/Lang/D/Averages-Pythagorean-means new file mode 120000 index 0000000000..59b091531f --- /dev/null +++ b/Lang/D/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/D \ No newline at end of file diff --git a/Lang/D/Averages-Root-mean-square b/Lang/D/Averages-Root-mean-square new file mode 120000 index 0000000000..348cff278e --- /dev/null +++ b/Lang/D/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/D \ No newline at end of file diff --git a/Lang/D/Averages-Simple-moving-average b/Lang/D/Averages-Simple-moving-average new file mode 120000 index 0000000000..c7da3c4dee --- /dev/null +++ b/Lang/D/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/D \ No newline at end of file diff --git a/Lang/D/Balanced-brackets b/Lang/D/Balanced-brackets new file mode 120000 index 0000000000..6a2ad1c1e2 --- /dev/null +++ b/Lang/D/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/D \ No newline at end of file diff --git a/Lang/D/Balanced-ternary b/Lang/D/Balanced-ternary new file mode 120000 index 0000000000..ef07733aa4 --- /dev/null +++ b/Lang/D/Balanced-ternary @@ -0,0 +1 @@ +../../Task/Balanced-ternary/D \ No newline at end of file diff --git a/Lang/D/Best-shuffle b/Lang/D/Best-shuffle new file mode 120000 index 0000000000..fac00aae80 --- /dev/null +++ b/Lang/D/Best-shuffle @@ -0,0 +1 @@ +../../Task/Best-shuffle/D \ No newline at end of file diff --git a/Lang/D/Binary-search b/Lang/D/Binary-search new file mode 120000 index 0000000000..bc4ae9b4ac --- /dev/null +++ b/Lang/D/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/D \ No newline at end of file diff --git a/Lang/D/Binary-strings b/Lang/D/Binary-strings new file mode 120000 index 0000000000..894326e801 --- /dev/null +++ b/Lang/D/Binary-strings @@ -0,0 +1 @@ +../../Task/Binary-strings/D \ No newline at end of file diff --git a/Lang/D/Bitmap b/Lang/D/Bitmap new file mode 120000 index 0000000000..bf04f67250 --- /dev/null +++ b/Lang/D/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/D \ No newline at end of file diff --git a/Lang/D/Bitmap-B-zier-curves-Cubic b/Lang/D/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..a7243f68a4 --- /dev/null +++ b/Lang/D/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/D \ No newline at end of file diff --git a/Lang/D/Bitmap-B-zier-curves-Quadratic b/Lang/D/Bitmap-B-zier-curves-Quadratic new file mode 120000 index 0000000000..f914b40744 --- /dev/null +++ b/Lang/D/Bitmap-B-zier-curves-Quadratic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Quadratic/D \ No newline at end of file diff --git a/Lang/D/Bitmap-Bresenhams-line-algorithm b/Lang/D/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..841cdf7d60 --- /dev/null +++ b/Lang/D/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/D \ No newline at end of file diff --git a/Lang/D/Bitmap-Flood-fill b/Lang/D/Bitmap-Flood-fill new file mode 120000 index 0000000000..cb4f00fef5 --- /dev/null +++ b/Lang/D/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/D \ No newline at end of file diff --git a/Lang/D/Bitmap-Histogram b/Lang/D/Bitmap-Histogram new file mode 120000 index 0000000000..7a072e1236 --- /dev/null +++ b/Lang/D/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/D \ No newline at end of file diff --git a/Lang/D/Bitmap-Midpoint-circle-algorithm b/Lang/D/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..feee40920b --- /dev/null +++ b/Lang/D/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/D \ No newline at end of file diff --git a/Lang/D/Bitwise-IO b/Lang/D/Bitwise-IO new file mode 120000 index 0000000000..70c58ac0cd --- /dev/null +++ b/Lang/D/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/D \ No newline at end of file diff --git a/Lang/D/Bitwise-operations b/Lang/D/Bitwise-operations new file mode 120000 index 0000000000..d48b98da4d --- /dev/null +++ b/Lang/D/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/D \ No newline at end of file diff --git a/Lang/D/Box-the-compass b/Lang/D/Box-the-compass new file mode 120000 index 0000000000..74a1ff94e8 --- /dev/null +++ b/Lang/D/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/D \ No newline at end of file diff --git a/Lang/D/Bulls-and-cows b/Lang/D/Bulls-and-cows new file mode 120000 index 0000000000..679bce17cc --- /dev/null +++ b/Lang/D/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/D \ No newline at end of file diff --git a/Lang/D/Bulls-and-cows-Player b/Lang/D/Bulls-and-cows-Player new file mode 120000 index 0000000000..48e89d3525 --- /dev/null +++ b/Lang/D/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/D \ No newline at end of file diff --git a/Lang/D/CRC-32 b/Lang/D/CRC-32 new file mode 120000 index 0000000000..ef52dc85e3 --- /dev/null +++ b/Lang/D/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/D \ No newline at end of file diff --git a/Lang/D/CSV-to-HTML-translation b/Lang/D/CSV-to-HTML-translation new file mode 120000 index 0000000000..55095f0ce6 --- /dev/null +++ b/Lang/D/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/D \ No newline at end of file diff --git a/Lang/D/Caesar-cipher b/Lang/D/Caesar-cipher new file mode 120000 index 0000000000..7eb2e6d352 --- /dev/null +++ b/Lang/D/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/D \ No newline at end of file diff --git a/Lang/D/Calendar b/Lang/D/Calendar new file mode 120000 index 0000000000..47d7b13ad8 --- /dev/null +++ b/Lang/D/Calendar @@ -0,0 +1 @@ +../../Task/Calendar/D \ No newline at end of file diff --git a/Lang/D/Call-a-foreign-language-function b/Lang/D/Call-a-foreign-language-function new file mode 120000 index 0000000000..ada36e2a25 --- /dev/null +++ b/Lang/D/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/D \ No newline at end of file diff --git a/Lang/D/Call-a-function-in-a-shared-library b/Lang/D/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..0a78941cfb --- /dev/null +++ b/Lang/D/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/D \ No newline at end of file diff --git a/Lang/D/Call-an-object-method b/Lang/D/Call-an-object-method new file mode 120000 index 0000000000..6f6f9a8e50 --- /dev/null +++ b/Lang/D/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/D \ No newline at end of file diff --git a/Lang/D/Canny-edge-detector b/Lang/D/Canny-edge-detector new file mode 120000 index 0000000000..987d5038fc --- /dev/null +++ b/Lang/D/Canny-edge-detector @@ -0,0 +1 @@ +../../Task/Canny-edge-detector/D \ No newline at end of file diff --git a/Lang/D/Carmichael-3-strong-pseudoprimes b/Lang/D/Carmichael-3-strong-pseudoprimes new file mode 120000 index 0000000000..a55bdb3c50 --- /dev/null +++ b/Lang/D/Carmichael-3-strong-pseudoprimes @@ -0,0 +1 @@ +../../Task/Carmichael-3-strong-pseudoprimes/D \ No newline at end of file diff --git a/Lang/D/Case-sensitivity-of-identifiers b/Lang/D/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..c983b717c3 --- /dev/null +++ b/Lang/D/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/D \ No newline at end of file diff --git a/Lang/D/Character-codes b/Lang/D/Character-codes new file mode 120000 index 0000000000..82433cd2e4 --- /dev/null +++ b/Lang/D/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/D \ No newline at end of file diff --git a/Lang/D/Character-matching b/Lang/D/Character-matching new file mode 120000 index 0000000000..a177ce7f32 --- /dev/null +++ b/Lang/D/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/D \ No newline at end of file diff --git a/Lang/D/Check-Machin-like-formulas b/Lang/D/Check-Machin-like-formulas new file mode 120000 index 0000000000..376a7249a3 --- /dev/null +++ b/Lang/D/Check-Machin-like-formulas @@ -0,0 +1 @@ +../../Task/Check-Machin-like-formulas/D \ No newline at end of file diff --git a/Lang/D/Check-that-file-exists b/Lang/D/Check-that-file-exists new file mode 120000 index 0000000000..8cf6a9d3d6 --- /dev/null +++ b/Lang/D/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/D \ No newline at end of file diff --git a/Lang/D/Checkpoint-synchronization b/Lang/D/Checkpoint-synchronization new file mode 120000 index 0000000000..bd53b1a50c --- /dev/null +++ b/Lang/D/Checkpoint-synchronization @@ -0,0 +1 @@ +../../Task/Checkpoint-synchronization/D \ No newline at end of file diff --git a/Lang/D/Cholesky-decomposition b/Lang/D/Cholesky-decomposition new file mode 120000 index 0000000000..356653aa53 --- /dev/null +++ b/Lang/D/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/D \ No newline at end of file diff --git a/Lang/D/Classes b/Lang/D/Classes new file mode 120000 index 0000000000..b1e1077c1c --- /dev/null +++ b/Lang/D/Classes @@ -0,0 +1 @@ +../../Task/Classes/D \ No newline at end of file diff --git a/Lang/D/Closest-pair-problem b/Lang/D/Closest-pair-problem new file mode 120000 index 0000000000..c195b8803c --- /dev/null +++ b/Lang/D/Closest-pair-problem @@ -0,0 +1 @@ +../../Task/Closest-pair-problem/D \ No newline at end of file diff --git a/Lang/D/Collections b/Lang/D/Collections new file mode 120000 index 0000000000..56cb52cab0 --- /dev/null +++ b/Lang/D/Collections @@ -0,0 +1 @@ +../../Task/Collections/D \ No newline at end of file diff --git a/Lang/D/Color-quantization b/Lang/D/Color-quantization new file mode 120000 index 0000000000..147076572b --- /dev/null +++ b/Lang/D/Color-quantization @@ -0,0 +1 @@ +../../Task/Color-quantization/D \ No newline at end of file diff --git a/Lang/D/Combinations b/Lang/D/Combinations new file mode 120000 index 0000000000..b3c7d7492d --- /dev/null +++ b/Lang/D/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/D \ No newline at end of file diff --git a/Lang/D/Combinations-with-repetitions b/Lang/D/Combinations-with-repetitions new file mode 120000 index 0000000000..e49831bc4a --- /dev/null +++ b/Lang/D/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/D \ No newline at end of file diff --git a/Lang/D/Command-line-arguments b/Lang/D/Command-line-arguments new file mode 120000 index 0000000000..5cdbb86b56 --- /dev/null +++ b/Lang/D/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/D \ No newline at end of file diff --git a/Lang/D/Comments b/Lang/D/Comments new file mode 120000 index 0000000000..25d30b9c48 --- /dev/null +++ b/Lang/D/Comments @@ -0,0 +1 @@ +../../Task/Comments/D \ No newline at end of file diff --git a/Lang/D/Compare-sorting-algorithms-performance b/Lang/D/Compare-sorting-algorithms-performance new file mode 120000 index 0000000000..29d7e137e5 --- /dev/null +++ b/Lang/D/Compare-sorting-algorithms-performance @@ -0,0 +1 @@ +../../Task/Compare-sorting-algorithms-performance/D \ No newline at end of file diff --git a/Lang/D/Compile-time-calculation b/Lang/D/Compile-time-calculation new file mode 120000 index 0000000000..9be3efb836 --- /dev/null +++ b/Lang/D/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/D \ No newline at end of file diff --git a/Lang/D/Compound-data-type b/Lang/D/Compound-data-type new file mode 120000 index 0000000000..4065084658 --- /dev/null +++ b/Lang/D/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/D \ No newline at end of file diff --git a/Lang/D/Concurrent-computing b/Lang/D/Concurrent-computing new file mode 120000 index 0000000000..6eaa308608 --- /dev/null +++ b/Lang/D/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/D \ No newline at end of file diff --git a/Lang/D/Conditional-structures b/Lang/D/Conditional-structures new file mode 120000 index 0000000000..19c378338e --- /dev/null +++ b/Lang/D/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/D \ No newline at end of file diff --git a/Lang/D/Constrained-genericity b/Lang/D/Constrained-genericity new file mode 120000 index 0000000000..faade326c4 --- /dev/null +++ b/Lang/D/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/D \ No newline at end of file diff --git a/Lang/D/Constrained-random-points-on-a-circle b/Lang/D/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..653494b5e8 --- /dev/null +++ b/Lang/D/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/D \ No newline at end of file diff --git a/Lang/D/Continued-fraction b/Lang/D/Continued-fraction new file mode 120000 index 0000000000..a1167310a8 --- /dev/null +++ b/Lang/D/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/D \ No newline at end of file diff --git a/Lang/D/Conways-Game-of-Life b/Lang/D/Conways-Game-of-Life new file mode 120000 index 0000000000..fbc476bdac --- /dev/null +++ b/Lang/D/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/D \ No newline at end of file diff --git a/Lang/D/Count-in-factors b/Lang/D/Count-in-factors new file mode 120000 index 0000000000..896005e214 --- /dev/null +++ b/Lang/D/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/D \ No newline at end of file diff --git a/Lang/D/Count-in-octal b/Lang/D/Count-in-octal new file mode 120000 index 0000000000..5c20637d63 --- /dev/null +++ b/Lang/D/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/D \ No newline at end of file diff --git a/Lang/D/Count-occurrences-of-a-substring b/Lang/D/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..2f8180d46c --- /dev/null +++ b/Lang/D/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/D \ No newline at end of file diff --git a/Lang/D/Count-the-coins b/Lang/D/Count-the-coins new file mode 120000 index 0000000000..a9a53204f6 --- /dev/null +++ b/Lang/D/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/D \ No newline at end of file diff --git a/Lang/D/Create-a-file b/Lang/D/Create-a-file new file mode 120000 index 0000000000..1851cafefb --- /dev/null +++ b/Lang/D/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/D \ No newline at end of file diff --git a/Lang/D/Create-a-two-dimensional-array-at-runtime b/Lang/D/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..17b20e2733 --- /dev/null +++ b/Lang/D/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/D \ No newline at end of file diff --git a/Lang/D/Create-an-HTML-table b/Lang/D/Create-an-HTML-table new file mode 120000 index 0000000000..0c0e676bde --- /dev/null +++ b/Lang/D/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/D \ No newline at end of file diff --git a/Lang/D/Create-an-object-at-a-given-address b/Lang/D/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..8ebc70adba --- /dev/null +++ b/Lang/D/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/D \ No newline at end of file diff --git a/Lang/D/Cut-a-rectangle b/Lang/D/Cut-a-rectangle new file mode 120000 index 0000000000..da5b746353 --- /dev/null +++ b/Lang/D/Cut-a-rectangle @@ -0,0 +1 @@ +../../Task/Cut-a-rectangle/D \ No newline at end of file diff --git a/Lang/D/DNS-query b/Lang/D/DNS-query new file mode 120000 index 0000000000..f14a853312 --- /dev/null +++ b/Lang/D/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/D \ No newline at end of file diff --git a/Lang/D/Date-format b/Lang/D/Date-format new file mode 120000 index 0000000000..c5431488f3 --- /dev/null +++ b/Lang/D/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/D \ No newline at end of file diff --git a/Lang/D/Day-of-the-week b/Lang/D/Day-of-the-week new file mode 120000 index 0000000000..51aa815633 --- /dev/null +++ b/Lang/D/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/D \ No newline at end of file diff --git a/Lang/D/Deal-cards-for-FreeCell b/Lang/D/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..bdfb0db2f9 --- /dev/null +++ b/Lang/D/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/D \ No newline at end of file diff --git a/Lang/D/Death-Star b/Lang/D/Death-Star new file mode 120000 index 0000000000..6f3d441194 --- /dev/null +++ b/Lang/D/Death-Star @@ -0,0 +1 @@ +../../Task/Death-Star/D \ No newline at end of file diff --git a/Lang/D/Deconvolution-1D b/Lang/D/Deconvolution-1D new file mode 120000 index 0000000000..a76fe65140 --- /dev/null +++ b/Lang/D/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/D \ No newline at end of file diff --git a/Lang/D/Deconvolution-2D+ b/Lang/D/Deconvolution-2D+ new file mode 120000 index 0000000000..bad0e403b1 --- /dev/null +++ b/Lang/D/Deconvolution-2D+ @@ -0,0 +1 @@ +../../Task/Deconvolution-2D+/D \ No newline at end of file diff --git a/Lang/D/Define-a-primitive-data-type b/Lang/D/Define-a-primitive-data-type new file mode 120000 index 0000000000..485e48ecd3 --- /dev/null +++ b/Lang/D/Define-a-primitive-data-type @@ -0,0 +1 @@ +../../Task/Define-a-primitive-data-type/D \ No newline at end of file diff --git a/Lang/D/Delegates b/Lang/D/Delegates new file mode 120000 index 0000000000..c297a419d0 --- /dev/null +++ b/Lang/D/Delegates @@ -0,0 +1 @@ +../../Task/Delegates/D \ No newline at end of file diff --git a/Lang/D/Delete-a-file b/Lang/D/Delete-a-file new file mode 120000 index 0000000000..860af2beb8 --- /dev/null +++ b/Lang/D/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/D \ No newline at end of file diff --git a/Lang/D/Detect-division-by-zero b/Lang/D/Detect-division-by-zero new file mode 120000 index 0000000000..b751e6ef6d --- /dev/null +++ b/Lang/D/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/D \ No newline at end of file diff --git a/Lang/D/Determine-if-a-string-is-numeric b/Lang/D/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..6cd7c3899d --- /dev/null +++ b/Lang/D/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/D \ No newline at end of file diff --git a/Lang/D/Digital-root b/Lang/D/Digital-root new file mode 120000 index 0000000000..bd86ad19c9 --- /dev/null +++ b/Lang/D/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/D \ No newline at end of file diff --git a/Lang/D/Dinesmans-multiple-dwelling-problem b/Lang/D/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..4d8c96148e --- /dev/null +++ b/Lang/D/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/D \ No newline at end of file diff --git a/Lang/D/Dining-philosophers b/Lang/D/Dining-philosophers new file mode 120000 index 0000000000..9db99586d4 --- /dev/null +++ b/Lang/D/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/D \ No newline at end of file diff --git a/Lang/D/Discordian-date b/Lang/D/Discordian-date new file mode 120000 index 0000000000..2606e46492 --- /dev/null +++ b/Lang/D/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/D \ No newline at end of file diff --git a/Lang/D/Distributed-programming b/Lang/D/Distributed-programming new file mode 120000 index 0000000000..50de9bf87f --- /dev/null +++ b/Lang/D/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/D \ No newline at end of file diff --git a/Lang/D/Documentation b/Lang/D/Documentation new file mode 120000 index 0000000000..722f372944 --- /dev/null +++ b/Lang/D/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/D \ No newline at end of file diff --git a/Lang/D/Dot-product b/Lang/D/Dot-product new file mode 120000 index 0000000000..5b53dbded9 --- /dev/null +++ b/Lang/D/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/D \ No newline at end of file diff --git a/Lang/D/Doubly-linked-list-Definition b/Lang/D/Doubly-linked-list-Definition new file mode 120000 index 0000000000..7644424412 --- /dev/null +++ b/Lang/D/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/D \ No newline at end of file diff --git a/Lang/D/Doubly-linked-list-Element-definition b/Lang/D/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..8dc9730497 --- /dev/null +++ b/Lang/D/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/D \ No newline at end of file diff --git a/Lang/D/Doubly-linked-list-Element-insertion b/Lang/D/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..56149154b5 --- /dev/null +++ b/Lang/D/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/D \ No newline at end of file diff --git a/Lang/D/Doubly-linked-list-Traversal b/Lang/D/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..275b50f09d --- /dev/null +++ b/Lang/D/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/D \ No newline at end of file diff --git a/Lang/D/Draw-a-cuboid b/Lang/D/Draw-a-cuboid new file mode 120000 index 0000000000..afd094ecaf --- /dev/null +++ b/Lang/D/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/D \ No newline at end of file diff --git a/Lang/D/Draw-a-sphere b/Lang/D/Draw-a-sphere new file mode 120000 index 0000000000..44b6cca63b --- /dev/null +++ b/Lang/D/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/D \ No newline at end of file diff --git a/Lang/D/Dutch-national-flag-problem b/Lang/D/Dutch-national-flag-problem new file mode 120000 index 0000000000..f4f86fe5ef --- /dev/null +++ b/Lang/D/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/D \ No newline at end of file diff --git a/Lang/D/Echo-server b/Lang/D/Echo-server new file mode 120000 index 0000000000..afa648df6b --- /dev/null +++ b/Lang/D/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/D \ No newline at end of file diff --git a/Lang/D/Element-wise-operations b/Lang/D/Element-wise-operations new file mode 120000 index 0000000000..fa3bdcd7f9 --- /dev/null +++ b/Lang/D/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/D \ No newline at end of file diff --git a/Lang/D/Empty-directory b/Lang/D/Empty-directory new file mode 120000 index 0000000000..11d352a0c5 --- /dev/null +++ b/Lang/D/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/D \ No newline at end of file diff --git a/Lang/D/Empty-program b/Lang/D/Empty-program new file mode 120000 index 0000000000..3d28348682 --- /dev/null +++ b/Lang/D/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/D \ No newline at end of file diff --git a/Lang/D/Empty-string b/Lang/D/Empty-string new file mode 120000 index 0000000000..82c1a7dcd9 --- /dev/null +++ b/Lang/D/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/D \ No newline at end of file diff --git a/Lang/D/Enforced-immutability b/Lang/D/Enforced-immutability new file mode 120000 index 0000000000..4e78f8b43a --- /dev/null +++ b/Lang/D/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/D \ No newline at end of file diff --git a/Lang/D/Entropy b/Lang/D/Entropy new file mode 120000 index 0000000000..7ea47bd863 --- /dev/null +++ b/Lang/D/Entropy @@ -0,0 +1 @@ +../../Task/Entropy/D \ No newline at end of file diff --git a/Lang/D/Enumerations b/Lang/D/Enumerations new file mode 120000 index 0000000000..b59dfdf058 --- /dev/null +++ b/Lang/D/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/D \ No newline at end of file diff --git a/Lang/D/Equilibrium-index b/Lang/D/Equilibrium-index new file mode 120000 index 0000000000..52eb7597cc --- /dev/null +++ b/Lang/D/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/D \ No newline at end of file diff --git a/Lang/D/Ethiopian-multiplication b/Lang/D/Ethiopian-multiplication new file mode 120000 index 0000000000..5af9240732 --- /dev/null +++ b/Lang/D/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/D \ No newline at end of file diff --git a/Lang/D/Euler-method b/Lang/D/Euler-method new file mode 120000 index 0000000000..046f471f7b --- /dev/null +++ b/Lang/D/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/D \ No newline at end of file diff --git a/Lang/D/Evaluate-binomial-coefficients b/Lang/D/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..6854d3704f --- /dev/null +++ b/Lang/D/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/D \ No newline at end of file diff --git a/Lang/D/Even-or-odd b/Lang/D/Even-or-odd new file mode 120000 index 0000000000..d17c8e627c --- /dev/null +++ b/Lang/D/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/D \ No newline at end of file diff --git a/Lang/D/Evolutionary-algorithm b/Lang/D/Evolutionary-algorithm new file mode 120000 index 0000000000..cfc220615d --- /dev/null +++ b/Lang/D/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/D \ No newline at end of file diff --git a/Lang/D/Exceptions b/Lang/D/Exceptions new file mode 120000 index 0000000000..ded6152ed8 --- /dev/null +++ b/Lang/D/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/D \ No newline at end of file diff --git a/Lang/D/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/D/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..768f791088 --- /dev/null +++ b/Lang/D/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/D \ No newline at end of file diff --git a/Lang/D/Execute-HQ9+ b/Lang/D/Execute-HQ9+ new file mode 120000 index 0000000000..8c3d865788 --- /dev/null +++ b/Lang/D/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/D \ No newline at end of file diff --git a/Lang/D/Execute-a-system-command b/Lang/D/Execute-a-system-command new file mode 120000 index 0000000000..cd38166adb --- /dev/null +++ b/Lang/D/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/D \ No newline at end of file diff --git a/Lang/D/Exponentiation-operator b/Lang/D/Exponentiation-operator new file mode 120000 index 0000000000..0267c4d428 --- /dev/null +++ b/Lang/D/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/D \ No newline at end of file diff --git a/Lang/D/Extend-your-language b/Lang/D/Extend-your-language new file mode 120000 index 0000000000..588250aa68 --- /dev/null +++ b/Lang/D/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/D \ No newline at end of file diff --git a/Lang/D/Extreme-floating-point-values b/Lang/D/Extreme-floating-point-values new file mode 120000 index 0000000000..c10feddda2 --- /dev/null +++ b/Lang/D/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/D \ No newline at end of file diff --git a/Lang/D/FizzBuzz b/Lang/D/FizzBuzz new file mode 120000 index 0000000000..37d1a27820 --- /dev/null +++ b/Lang/D/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/D \ No newline at end of file diff --git a/Lang/D/Forest-fire b/Lang/D/Forest-fire new file mode 120000 index 0000000000..5d8035ffac --- /dev/null +++ b/Lang/D/Forest-fire @@ -0,0 +1 @@ +../../Task/Forest-fire/D \ No newline at end of file diff --git a/Lang/D/Infinity b/Lang/D/Infinity new file mode 120000 index 0000000000..ff71d26739 --- /dev/null +++ b/Lang/D/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/D \ No newline at end of file diff --git a/Lang/D/JSON b/Lang/D/JSON new file mode 120000 index 0000000000..d982efb967 --- /dev/null +++ b/Lang/D/JSON @@ -0,0 +1 @@ +../../Task/JSON/D \ No newline at end of file diff --git a/Lang/D/Knuth-shuffle b/Lang/D/Knuth-shuffle new file mode 120000 index 0000000000..7b2ebcc8e9 --- /dev/null +++ b/Lang/D/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/D \ No newline at end of file diff --git a/Lang/D/Ordered-words b/Lang/D/Ordered-words new file mode 120000 index 0000000000..bb9bd29b16 --- /dev/null +++ b/Lang/D/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/D \ No newline at end of file diff --git a/Lang/D/Pi b/Lang/D/Pi new file mode 120000 index 0000000000..864f7125c4 --- /dev/null +++ b/Lang/D/Pi @@ -0,0 +1 @@ +../../Task/Pi/D \ No newline at end of file diff --git a/Lang/D/Quine b/Lang/D/Quine new file mode 120000 index 0000000000..e6cdcb99be --- /dev/null +++ b/Lang/D/Quine @@ -0,0 +1 @@ +../../Task/Quine/D \ No newline at end of file diff --git a/Lang/D/Search-a-list b/Lang/D/Search-a-list new file mode 120000 index 0000000000..f14ffa1c84 --- /dev/null +++ b/Lang/D/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/D \ No newline at end of file diff --git a/Lang/DCL/0DESCRIPTION b/Lang/DCL/0DESCRIPTION new file mode 100644 index 0000000000..4d3d27c049 --- /dev/null +++ b/Lang/DCL/0DESCRIPTION @@ -0,0 +1 @@ +{{stub}}{{language}} \ No newline at end of file diff --git a/Lang/DCL/Create-a-file b/Lang/DCL/Create-a-file new file mode 120000 index 0000000000..6b67174e2e --- /dev/null +++ b/Lang/DCL/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/DCL \ No newline at end of file diff --git a/Lang/DCL/Execute-a-system-command b/Lang/DCL/Execute-a-system-command new file mode 120000 index 0000000000..1cba4b4b73 --- /dev/null +++ b/Lang/DCL/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/DCL \ No newline at end of file diff --git a/Lang/DMS/0DESCRIPTION b/Lang/DMS/0DESCRIPTION new file mode 100644 index 0000000000..7d2c349f63 --- /dev/null +++ b/Lang/DMS/0DESCRIPTION @@ -0,0 +1,4 @@ +{{language|site=http://www.gatan.com/resources/scripting/}} +DigitalMicrograph Script is a language supported by the [http://www.gatan.com Gatan] DigitalMicrograph (DM) application. [http://www.gatan.com/resources/scripting/demo/index.php DigitalMicrograph] was developed in the early 1990's to provide an environment in which Gatan's customers could control hardware and interact with applications developed to exploit this hardware. Through DMS customers can easily interact with images and hardware to create their own applications. + +DMS resembles C/C++ and is partly interpreted and partly compiled. Single line expressions that manipulate image data are compiled for speed. \ No newline at end of file diff --git a/Lang/DMS/A+B b/Lang/DMS/A+B new file mode 120000 index 0000000000..ced45866b4 --- /dev/null +++ b/Lang/DMS/A+B @@ -0,0 +1 @@ +../../Task/A+B/DMS \ No newline at end of file diff --git a/Lang/DWScript/0DESCRIPTION b/Lang/DWScript/0DESCRIPTION new file mode 100644 index 0000000000..60859f7de7 --- /dev/null +++ b/Lang/DWScript/0DESCRIPTION @@ -0,0 +1,18 @@ +{{stub}}{{language|DWScript +|strength=strong +|safety=both +|gc=yes +|parampass=both +|express=explicit +|compat=nominative +|checking=static +}} +{{language programming paradigm|object-oriented}} +{{language programming paradigm|imperative}} +{{implementation|Object Pascal}} + +DWScript (DelphiWebScript) is a strongly-typed [[Object-oriented language|object-oriented]] scripting language based on the [[Delphi]] language, with extensions borrowed from other Object Pascal dialects. + +==See Also== +* [[wp:Object_Pascal|Wikipedia: Object Pascal]] +* DWScript at Google Code: [http://code.google.com/p/dwscript/] \ No newline at end of file diff --git a/Lang/DWScript/100-doors b/Lang/DWScript/100-doors new file mode 120000 index 0000000000..df32d03de0 --- /dev/null +++ b/Lang/DWScript/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/DWScript \ No newline at end of file diff --git a/Lang/DWScript/A+B b/Lang/DWScript/A+B new file mode 120000 index 0000000000..2bfee56920 --- /dev/null +++ b/Lang/DWScript/A+B @@ -0,0 +1 @@ +../../Task/A+B/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Ackermann-function b/Lang/DWScript/Ackermann-function new file mode 120000 index 0000000000..1e5afe2896 --- /dev/null +++ b/Lang/DWScript/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Arithmetic-Integer b/Lang/DWScript/Arithmetic-Integer new file mode 120000 index 0000000000..833abbc890 --- /dev/null +++ b/Lang/DWScript/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Arrays b/Lang/DWScript/Arrays new file mode 120000 index 0000000000..6942678b3d --- /dev/null +++ b/Lang/DWScript/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Assertions b/Lang/DWScript/Assertions new file mode 120000 index 0000000000..7f81446684 --- /dev/null +++ b/Lang/DWScript/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Bitwise-operations b/Lang/DWScript/Bitwise-operations new file mode 120000 index 0000000000..97269722b3 --- /dev/null +++ b/Lang/DWScript/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Case-sensitivity-of-identifiers b/Lang/DWScript/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..225122acd1 --- /dev/null +++ b/Lang/DWScript/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Character-codes b/Lang/DWScript/Character-codes new file mode 120000 index 0000000000..a56181d5dd --- /dev/null +++ b/Lang/DWScript/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Cholesky-decomposition b/Lang/DWScript/Cholesky-decomposition new file mode 120000 index 0000000000..aaf44aedb6 --- /dev/null +++ b/Lang/DWScript/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Classes b/Lang/DWScript/Classes new file mode 120000 index 0000000000..a2db8d8a99 --- /dev/null +++ b/Lang/DWScript/Classes @@ -0,0 +1 @@ +../../Task/Classes/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Comments b/Lang/DWScript/Comments new file mode 120000 index 0000000000..17da16d41a --- /dev/null +++ b/Lang/DWScript/Comments @@ -0,0 +1 @@ +../../Task/Comments/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Compile-time-calculation b/Lang/DWScript/Compile-time-calculation new file mode 120000 index 0000000000..82393d77a6 --- /dev/null +++ b/Lang/DWScript/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Count-in-factors b/Lang/DWScript/Count-in-factors new file mode 120000 index 0000000000..2c3e87acbb --- /dev/null +++ b/Lang/DWScript/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Death-Star b/Lang/DWScript/Death-Star new file mode 120000 index 0000000000..0cab6f1ff8 --- /dev/null +++ b/Lang/DWScript/Death-Star @@ -0,0 +1 @@ +../../Task/Death-Star/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Dot-product b/Lang/DWScript/Dot-product new file mode 120000 index 0000000000..20e14dc47e --- /dev/null +++ b/Lang/DWScript/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Draw-a-sphere b/Lang/DWScript/Draw-a-sphere new file mode 120000 index 0000000000..2cea3c63e5 --- /dev/null +++ b/Lang/DWScript/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Empty-string b/Lang/DWScript/Empty-string new file mode 120000 index 0000000000..272f3a0b93 --- /dev/null +++ b/Lang/DWScript/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Enumerations b/Lang/DWScript/Enumerations new file mode 120000 index 0000000000..a05443cfec --- /dev/null +++ b/Lang/DWScript/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Even-or-odd b/Lang/DWScript/Even-or-odd new file mode 120000 index 0000000000..171cdec446 --- /dev/null +++ b/Lang/DWScript/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Exceptions b/Lang/DWScript/Exceptions new file mode 120000 index 0000000000..d36aef3106 --- /dev/null +++ b/Lang/DWScript/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/DWScript/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..9ca02c03ed --- /dev/null +++ b/Lang/DWScript/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Execute-HQ9+ b/Lang/DWScript/Execute-HQ9+ new file mode 120000 index 0000000000..6eccb46ba3 --- /dev/null +++ b/Lang/DWScript/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/DWScript \ No newline at end of file diff --git a/Lang/DWScript/FizzBuzz b/Lang/DWScript/FizzBuzz new file mode 120000 index 0000000000..1c5ab02e3b --- /dev/null +++ b/Lang/DWScript/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Knuth-shuffle b/Lang/DWScript/Knuth-shuffle new file mode 120000 index 0000000000..ff4fdc496d --- /dev/null +++ b/Lang/DWScript/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Search-a-list b/Lang/DWScript/Search-a-list new file mode 120000 index 0000000000..9d2551de85 --- /dev/null +++ b/Lang/DWScript/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/DWScript \ No newline at end of file diff --git a/Lang/Dao/0DESCRIPTION b/Lang/Dao/0DESCRIPTION new file mode 100644 index 0000000000..f8e38f30cd --- /dev/null +++ b/Lang/Dao/0DESCRIPTION @@ -0,0 +1,15 @@ +{{stub}} +{{language| +|exec=bytecode +|strength=strong +|safety=safe +|express=both +|checking=both +|gc=yes +|site=http://www.daovm.net +|LCT=yes}} +{{language programming paradigm|Object-oriented}} + +Dao is a lightweight object-oriented programming language +with optional typing. It has a rich set of features with +simple and transparent interface to C/C++ programming language. \ No newline at end of file diff --git a/Lang/Dao/Arrays b/Lang/Dao/Arrays new file mode 120000 index 0000000000..c076824a19 --- /dev/null +++ b/Lang/Dao/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Dao \ No newline at end of file diff --git a/Lang/Dao/Associative-array-Creation b/Lang/Dao/Associative-array-Creation new file mode 120000 index 0000000000..c64445965a --- /dev/null +++ b/Lang/Dao/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Dao \ No newline at end of file diff --git a/Lang/Dao/Associative-array-Iteration b/Lang/Dao/Associative-array-Iteration new file mode 120000 index 0000000000..4ec3ceadb8 --- /dev/null +++ b/Lang/Dao/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Dao \ No newline at end of file diff --git a/Lang/Dao/Conditional-structures b/Lang/Dao/Conditional-structures new file mode 120000 index 0000000000..56780449f9 --- /dev/null +++ b/Lang/Dao/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Dao \ No newline at end of file diff --git a/Lang/Dao/Quine b/Lang/Dao/Quine new file mode 120000 index 0000000000..671933cd5f --- /dev/null +++ b/Lang/Dao/Quine @@ -0,0 +1 @@ +../../Task/Quine/Dao \ No newline at end of file diff --git a/Lang/Dart/0DESCRIPTION b/Lang/Dart/0DESCRIPTION new file mode 100644 index 0000000000..564d5b95db --- /dev/null +++ b/Lang/Dart/0DESCRIPTION @@ -0,0 +1,2 @@ +{{stub}}{{language +|site=http://www.dartlang.org/}} \ No newline at end of file diff --git a/Lang/Dart/100-doors b/Lang/Dart/100-doors new file mode 120000 index 0000000000..a5a16072dd --- /dev/null +++ b/Lang/Dart/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Dart \ No newline at end of file diff --git a/Lang/Dart/99-Bottles-of-Beer b/Lang/Dart/99-Bottles-of-Beer new file mode 120000 index 0000000000..ed277c5d60 --- /dev/null +++ b/Lang/Dart/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Dart \ No newline at end of file diff --git a/Lang/Dart/Ackermann-function b/Lang/Dart/Ackermann-function new file mode 120000 index 0000000000..65f70608d7 --- /dev/null +++ b/Lang/Dart/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Dart \ No newline at end of file diff --git a/Lang/Dart/Assertions b/Lang/Dart/Assertions new file mode 120000 index 0000000000..45fac13766 --- /dev/null +++ b/Lang/Dart/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Dart \ No newline at end of file diff --git a/Lang/Dart/Caesar-cipher b/Lang/Dart/Caesar-cipher new file mode 120000 index 0000000000..4092485657 --- /dev/null +++ b/Lang/Dart/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Dart \ No newline at end of file diff --git a/Lang/Dart/Conways-Game-of-Life b/Lang/Dart/Conways-Game-of-Life new file mode 120000 index 0000000000..a00bf0bde1 --- /dev/null +++ b/Lang/Dart/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Dart \ No newline at end of file diff --git a/Lang/Dart/Delegates b/Lang/Dart/Delegates new file mode 120000 index 0000000000..74b20fc65c --- /dev/null +++ b/Lang/Dart/Delegates @@ -0,0 +1 @@ +../../Task/Delegates/Dart \ No newline at end of file diff --git a/Lang/Dart/Empty-program b/Lang/Dart/Empty-program new file mode 120000 index 0000000000..99c5b555dd --- /dev/null +++ b/Lang/Dart/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Dart \ No newline at end of file diff --git a/Lang/Dart/FizzBuzz b/Lang/Dart/FizzBuzz new file mode 120000 index 0000000000..0e0f7997b8 --- /dev/null +++ b/Lang/Dart/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Dart \ No newline at end of file diff --git a/Lang/Datalog/0DESCRIPTION b/Lang/Datalog/0DESCRIPTION new file mode 100644 index 0000000000..19edd63da3 --- /dev/null +++ b/Lang/Datalog/0DESCRIPTION @@ -0,0 +1,16 @@ +{{language +}} +Datalog is a query and rule language for deductive databases that syntactically is a subset of [[Prolog]]. + +In contrast to Prolog: +* it disallows complex terms as arguments of predicates, e.g. p(1, 2) is admissible but not p(f1(1), 2), +* imposes certain stratification restrictions on the use of negation and recursion, and +* only allows range-restricted variables, i.e. each variable in the conclusion of a rule must also appear in a not negated clause in the premise of this rule. + +These rules make the set of all possible proofs finite, with the consequence that all datalog programs terminate (unlike Prolog programs). As a consequence, statements and predicates of a program can be stated in any order (unlike Prolog). + +== See Also == +* [[wp:Datalog|Wikipedia:Datalog]] +* [https://bitbucket.org/pcarbonn/pydatalog pyDatalog] +* [http://www.ccs.neu.edu/home/ramsdell/tools/datalog/ Datalog] +* [http://www.ccs.neu.edu/home/ramsdell/tools/datalog/datalog.html Datalog User Manual] \ No newline at end of file diff --git a/Lang/Dc/0DESCRIPTION b/Lang/Dc/0DESCRIPTION new file mode 100644 index 0000000000..c5626dd439 --- /dev/null +++ b/Lang/Dc/0DESCRIPTION @@ -0,0 +1,63 @@ +{{language +|exec=interpreted +|checking=dynamic +|hopl id=1957 +}} +{{language programming paradigm|concatenative}} +dc is the unix desktop calculator. It uses a reverse polish notation and is turing complete. + +== Quick reference == +Commands in [[AT&T dc]] + number : push a number (0-9A-F digits, _ negative, . radix point) + [...] : push a string + + - * / % ^ : arithmetic operations: add sub mul div mod pow + v : square root + c : clear stack + d : duplicate top of the stack + f : show stack + p : print value with a newline, leave it on the stack + P : print string, or print number as ASCII string + sx : store to register x + lx : load from register x + Sx : push to register x + Lx : pop register x + 1 2 :x : store x[2] = 1 (x is register) + 2 ;x : retrieve x[2] + x =x : compare top 2 values: if true, then execute register x + !>x !xey : comparisons with an else branch: if true, + =xey !xey !=xey : else execute register y + 1 2 G : equality: push 1 if 2 == 1, else push 0 + 1 2 ( : less than: push 1 if 2 < 1, else push 0 + 3 N : boolean not: push 1 if 3 == 0, else push 0 \ No newline at end of file diff --git a/Lang/Dc/Count-in-octal b/Lang/Dc/Count-in-octal new file mode 120000 index 0000000000..52fedeb299 --- /dev/null +++ b/Lang/Dc/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Dc \ No newline at end of file diff --git a/Lang/Dc/Digital-root b/Lang/Dc/Digital-root new file mode 120000 index 0000000000..f0942d5aff --- /dev/null +++ b/Lang/Dc/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/Dc \ No newline at end of file diff --git a/Lang/Deja-Vu/0DESCRIPTION b/Lang/Deja-Vu/0DESCRIPTION new file mode 100644 index 0000000000..4d3d27c049 --- /dev/null +++ b/Lang/Deja-Vu/0DESCRIPTION @@ -0,0 +1 @@ +{{stub}}{{language}} \ No newline at end of file diff --git a/Lang/Deja-Vu/A+B b/Lang/Deja-Vu/A+B new file mode 120000 index 0000000000..60b50f676d --- /dev/null +++ b/Lang/Deja-Vu/A+B @@ -0,0 +1 @@ +../../Task/A+B/Deja-Vu \ No newline at end of file diff --git a/Lang/Deja-Vu/Anonymous-recursion b/Lang/Deja-Vu/Anonymous-recursion new file mode 120000 index 0000000000..47cd620969 --- /dev/null +++ b/Lang/Deja-Vu/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Deja-Vu \ No newline at end of file diff --git a/Lang/Deja-Vu/Command-line-arguments b/Lang/Deja-Vu/Command-line-arguments new file mode 120000 index 0000000000..88fad34cfb --- /dev/null +++ b/Lang/Deja-Vu/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Deja-Vu \ No newline at end of file diff --git a/Lang/Deja-Vu/Conditional-structures b/Lang/Deja-Vu/Conditional-structures new file mode 120000 index 0000000000..45627a6cb4 --- /dev/null +++ b/Lang/Deja-Vu/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Deja-Vu \ No newline at end of file diff --git a/Lang/Deja-Vu/Narcissist b/Lang/Deja-Vu/Narcissist new file mode 120000 index 0000000000..267a22b944 --- /dev/null +++ b/Lang/Deja-Vu/Narcissist @@ -0,0 +1 @@ +../../Task/Narcissist/Deja-Vu \ No newline at end of file diff --git a/Lang/Deja-Vu/Quine b/Lang/Deja-Vu/Quine new file mode 120000 index 0000000000..847ac2e0fe --- /dev/null +++ b/Lang/Deja-Vu/Quine @@ -0,0 +1 @@ +../../Task/Quine/Deja-Vu \ No newline at end of file diff --git a/Lang/Delphi/0DESCRIPTION b/Lang/Delphi/0DESCRIPTION new file mode 100644 index 0000000000..5a14d212a8 --- /dev/null +++ b/Lang/Delphi/0DESCRIPTION @@ -0,0 +1,33 @@ +{{language|Delphi +|strength=strong +|safety=both +|express=explicit +|compat=nominative +|checking=static +|LCT=yes +|bnf=http://www.felix-colibri.com/papers/compilers/delphi_5_grammar/delphi_5_grammar.html +}} +{{language programming paradigm|object-oriented}} +{{language programming paradigm|imperative}} +{{implementation|Object Pascal}} + +'''Delphi''' is a language for rapid development of Windows applications. The name also refers to the Delphi IDE, which is used to help edit and debug Delphi projects more efficiently. It is sold by [[wp:Embarcadero Technologies|Embarcadero Technologies]], as a standalone product or included in RAD Studio, which includes other languages as well. + +Delphi is a "personality" for RAD Studio. It uses [[:Category:Object Pascal|Object Pascal]] as the programming language. Object Pascal is an enhancement of [[wp:Niklaus Wirth|Niklaus Wirth's]] language [[:Category:Pascal|Pascal]]. + +Delphi originated in 1995 at Borland, evolving from Turbo Pascal. It's original focus was database application development. It is currently owned by Embarcadero. + +Among Delphi's strengths are its easy learning curve, consistent language architecture, a blazingly fast compiler, great execution speed, modern language constructs, its extensive Visual Component Library (VCL), and the associated visual form designer. + +The Delphi XE2 version added support for 64-bit applications. It also added a cross platform compiler and component library allowing it to create cross platform applications for Mac OS X and iOS. The iOS support is actually achieved using the Free Pascal compiler. + +==Variants== +* [[Free Pascal]] is an open source version of Delphi that implements most of the language. The Lazarus IDE and libraries emulates the RTL ([[wp:runtime library|runtime library]]) and VCL. +* Embarcadero, and Borland before it, experimented with using the "Delphi" name to brand tools based on other languages. Examples include Delphi for [[:Category:PHP|PHP]] which was renamed RAD PHP, and Delphi Prism, which was renamed Embarcadero Prism. The latter makes use of the [[wp:Oxygene (programming language)|Oxygene]] dialect of Pascal provided by RemObjects Software, to build cross platform .NET and Mono applications. +* There is also Delphi/400 which is actually the main Embarcadero Delphi product repackaged with AS/400 and sold by SystemObjects. +* [[DWScript]] is a Delphi-hosted script engine that implements most of the Delphi language, along with FreePascal/Oxygene extensions. + +==See Also== +* [[wp:Embarcadero Delphi|Delphi on Wikipedia]] +* [http://www.embarcadero.com/products/delphi Delphi page at Embarcadero.com] +* [[wp:Oxygene (programming language)|Oxygene on Wikipedia]] \ No newline at end of file diff --git a/Lang/Delphi/99-Bottles-of-Beer b/Lang/Delphi/99-Bottles-of-Beer new file mode 120000 index 0000000000..1712f9b8e3 --- /dev/null +++ b/Lang/Delphi/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Delphi \ No newline at end of file diff --git a/Lang/Delphi/A+B b/Lang/Delphi/A+B new file mode 120000 index 0000000000..956e04a723 --- /dev/null +++ b/Lang/Delphi/A+B @@ -0,0 +1 @@ +../../Task/A+B/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Abstract-type b/Lang/Delphi/Abstract-type new file mode 120000 index 0000000000..8fbd763514 --- /dev/null +++ b/Lang/Delphi/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Ackermann-function b/Lang/Delphi/Ackermann-function new file mode 120000 index 0000000000..df95c80aef --- /dev/null +++ b/Lang/Delphi/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Align-columns b/Lang/Delphi/Align-columns new file mode 120000 index 0000000000..3eeed5f0f8 --- /dev/null +++ b/Lang/Delphi/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Apply-a-callback-to-an-array b/Lang/Delphi/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..fe9f82fdf2 --- /dev/null +++ b/Lang/Delphi/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Arithmetic-Integer b/Lang/Delphi/Arithmetic-Integer new file mode 120000 index 0000000000..a4e671a8c7 --- /dev/null +++ b/Lang/Delphi/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Array-concatenation b/Lang/Delphi/Array-concatenation new file mode 120000 index 0000000000..243cbd87be --- /dev/null +++ b/Lang/Delphi/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Arrays b/Lang/Delphi/Arrays new file mode 120000 index 0000000000..ca8b9fc782 --- /dev/null +++ b/Lang/Delphi/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Assertions b/Lang/Delphi/Assertions new file mode 120000 index 0000000000..bd2d12f06d --- /dev/null +++ b/Lang/Delphi/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Associative-array-Creation b/Lang/Delphi/Associative-array-Creation new file mode 120000 index 0000000000..1c0de59261 --- /dev/null +++ b/Lang/Delphi/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Associative-array-Iteration b/Lang/Delphi/Associative-array-Iteration new file mode 120000 index 0000000000..4e53b53717 --- /dev/null +++ b/Lang/Delphi/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Averages-Arithmetic-mean b/Lang/Delphi/Averages-Arithmetic-mean new file mode 120000 index 0000000000..b34aa16997 --- /dev/null +++ b/Lang/Delphi/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Averages-Median b/Lang/Delphi/Averages-Median new file mode 120000 index 0000000000..c2affa8776 --- /dev/null +++ b/Lang/Delphi/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Averages-Pythagorean-means b/Lang/Delphi/Averages-Pythagorean-means new file mode 120000 index 0000000000..aa311e540e --- /dev/null +++ b/Lang/Delphi/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Averages-Root-mean-square b/Lang/Delphi/Averages-Root-mean-square new file mode 120000 index 0000000000..987ecaffda --- /dev/null +++ b/Lang/Delphi/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Balanced-brackets b/Lang/Delphi/Balanced-brackets new file mode 120000 index 0000000000..afb5f3fc45 --- /dev/null +++ b/Lang/Delphi/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Bitwise-operations b/Lang/Delphi/Bitwise-operations new file mode 120000 index 0000000000..91d39ec595 --- /dev/null +++ b/Lang/Delphi/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Delphi \ No newline at end of file diff --git a/Lang/Delphi/CSV-to-HTML-translation b/Lang/Delphi/CSV-to-HTML-translation new file mode 120000 index 0000000000..40e1cd0ac7 --- /dev/null +++ b/Lang/Delphi/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Call-a-foreign-language-function b/Lang/Delphi/Call-a-foreign-language-function new file mode 120000 index 0000000000..99cdc02762 --- /dev/null +++ b/Lang/Delphi/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Call-a-function-in-a-shared-library b/Lang/Delphi/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..1ad674fb42 --- /dev/null +++ b/Lang/Delphi/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Case-sensitivity-of-identifiers b/Lang/Delphi/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..776ff3eb31 --- /dev/null +++ b/Lang/Delphi/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Character-codes b/Lang/Delphi/Character-codes new file mode 120000 index 0000000000..9e2596ea9d --- /dev/null +++ b/Lang/Delphi/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Character-matching b/Lang/Delphi/Character-matching new file mode 120000 index 0000000000..0db34575de --- /dev/null +++ b/Lang/Delphi/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Check-that-file-exists b/Lang/Delphi/Check-that-file-exists new file mode 120000 index 0000000000..3096ab34d6 --- /dev/null +++ b/Lang/Delphi/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Classes b/Lang/Delphi/Classes new file mode 120000 index 0000000000..4a50148f15 --- /dev/null +++ b/Lang/Delphi/Classes @@ -0,0 +1 @@ +../../Task/Classes/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Color-of-a-screen-pixel b/Lang/Delphi/Color-of-a-screen-pixel new file mode 120000 index 0000000000..683f4471f2 --- /dev/null +++ b/Lang/Delphi/Color-of-a-screen-pixel @@ -0,0 +1 @@ +../../Task/Color-of-a-screen-pixel/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Command-line-arguments b/Lang/Delphi/Command-line-arguments new file mode 120000 index 0000000000..51239079a1 --- /dev/null +++ b/Lang/Delphi/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Comments b/Lang/Delphi/Comments new file mode 120000 index 0000000000..83dae6148a --- /dev/null +++ b/Lang/Delphi/Comments @@ -0,0 +1 @@ +../../Task/Comments/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Compound-data-type b/Lang/Delphi/Compound-data-type new file mode 120000 index 0000000000..d673db0d47 --- /dev/null +++ b/Lang/Delphi/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Concurrent-computing b/Lang/Delphi/Concurrent-computing new file mode 120000 index 0000000000..ca131d5fa0 --- /dev/null +++ b/Lang/Delphi/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Count-in-octal b/Lang/Delphi/Count-in-octal new file mode 120000 index 0000000000..72ccf18249 --- /dev/null +++ b/Lang/Delphi/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Count-occurrences-of-a-substring b/Lang/Delphi/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..df93fafd93 --- /dev/null +++ b/Lang/Delphi/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Create-a-file b/Lang/Delphi/Create-a-file new file mode 120000 index 0000000000..433e1ef302 --- /dev/null +++ b/Lang/Delphi/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Create-a-two-dimensional-array-at-runtime b/Lang/Delphi/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..833133289f --- /dev/null +++ b/Lang/Delphi/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Create-an-HTML-table b/Lang/Delphi/Create-an-HTML-table new file mode 120000 index 0000000000..d55b26c89e --- /dev/null +++ b/Lang/Delphi/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Delphi \ No newline at end of file diff --git a/Lang/Delphi/DNS-query b/Lang/Delphi/DNS-query new file mode 120000 index 0000000000..cd9fcee74d --- /dev/null +++ b/Lang/Delphi/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Date-format b/Lang/Delphi/Date-format new file mode 120000 index 0000000000..6e1c942a24 --- /dev/null +++ b/Lang/Delphi/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Date-manipulation b/Lang/Delphi/Date-manipulation new file mode 120000 index 0000000000..9bb852ce5d --- /dev/null +++ b/Lang/Delphi/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Day-of-the-week b/Lang/Delphi/Day-of-the-week new file mode 120000 index 0000000000..3e0f94badd --- /dev/null +++ b/Lang/Delphi/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Delegates b/Lang/Delphi/Delegates new file mode 120000 index 0000000000..430a387a0d --- /dev/null +++ b/Lang/Delphi/Delegates @@ -0,0 +1 @@ +../../Task/Delegates/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Delete-a-file b/Lang/Delphi/Delete-a-file new file mode 120000 index 0000000000..d54dc967c4 --- /dev/null +++ b/Lang/Delphi/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Detect-division-by-zero b/Lang/Delphi/Detect-division-by-zero new file mode 120000 index 0000000000..3d03051bc1 --- /dev/null +++ b/Lang/Delphi/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Determine-if-a-string-is-numeric b/Lang/Delphi/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..43ecbb6e56 --- /dev/null +++ b/Lang/Delphi/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Determine-if-only-one-instance-is-running b/Lang/Delphi/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..b242291125 --- /dev/null +++ b/Lang/Delphi/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Documentation b/Lang/Delphi/Documentation new file mode 120000 index 0000000000..1287853958 --- /dev/null +++ b/Lang/Delphi/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Dot-product b/Lang/Delphi/Dot-product new file mode 120000 index 0000000000..523e69c97d --- /dev/null +++ b/Lang/Delphi/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Doubly-linked-list-Element-definition b/Lang/Delphi/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..5476d42f80 --- /dev/null +++ b/Lang/Delphi/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Doubly-linked-list-Traversal b/Lang/Delphi/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..2eb00f2a7e --- /dev/null +++ b/Lang/Delphi/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Draw-a-sphere b/Lang/Delphi/Draw-a-sphere new file mode 120000 index 0000000000..5a8d850b2d --- /dev/null +++ b/Lang/Delphi/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Echo-server b/Lang/Delphi/Echo-server new file mode 120000 index 0000000000..caf88e8a56 --- /dev/null +++ b/Lang/Delphi/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Empty-string b/Lang/Delphi/Empty-string new file mode 120000 index 0000000000..b6ba51661c --- /dev/null +++ b/Lang/Delphi/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Enforced-immutability b/Lang/Delphi/Enforced-immutability new file mode 120000 index 0000000000..5d20a94658 --- /dev/null +++ b/Lang/Delphi/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Enumerations b/Lang/Delphi/Enumerations new file mode 120000 index 0000000000..2fb26ce5ae --- /dev/null +++ b/Lang/Delphi/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Evaluate-binomial-coefficients b/Lang/Delphi/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..ab4226fbe6 --- /dev/null +++ b/Lang/Delphi/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Events b/Lang/Delphi/Events new file mode 120000 index 0000000000..ae27f20c5c --- /dev/null +++ b/Lang/Delphi/Events @@ -0,0 +1 @@ +../../Task/Events/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Exceptions b/Lang/Delphi/Exceptions new file mode 120000 index 0000000000..274d8a3fae --- /dev/null +++ b/Lang/Delphi/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Delphi/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..bef21f17dd --- /dev/null +++ b/Lang/Delphi/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Execute-a-system-command b/Lang/Delphi/Execute-a-system-command new file mode 120000 index 0000000000..237207c509 --- /dev/null +++ b/Lang/Delphi/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Extend-your-language b/Lang/Delphi/Extend-your-language new file mode 120000 index 0000000000..54d5aeec01 --- /dev/null +++ b/Lang/Delphi/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Extreme-floating-point-values b/Lang/Delphi/Extreme-floating-point-values new file mode 120000 index 0000000000..40abb4f9e2 --- /dev/null +++ b/Lang/Delphi/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Delphi \ No newline at end of file diff --git a/Lang/Delphi/FizzBuzz b/Lang/Delphi/FizzBuzz new file mode 120000 index 0000000000..3d350da0cb --- /dev/null +++ b/Lang/Delphi/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Infinity b/Lang/Delphi/Infinity new file mode 120000 index 0000000000..fd57bf11a0 --- /dev/null +++ b/Lang/Delphi/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Ordered-words b/Lang/Delphi/Ordered-words new file mode 120000 index 0000000000..fce8e4f0b6 --- /dev/null +++ b/Lang/Delphi/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Search-a-list b/Lang/Delphi/Search-a-list new file mode 120000 index 0000000000..cee0744901 --- /dev/null +++ b/Lang/Delphi/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Delphi \ No newline at end of file diff --git a/Lang/Deluge/0DESCRIPTION b/Lang/Deluge/0DESCRIPTION new file mode 100644 index 0000000000..22b58175e0 --- /dev/null +++ b/Lang/Deluge/0DESCRIPTION @@ -0,0 +1,7 @@ +{{stub}}{{language}} + +Deluge (or ''Data Enriched Language for the Universal Grid Environment'') is an online scripting language integrated with [http://creator.zoho.com Zoho Creator]. It enables users of Zoho to add logic to the application in order to extend it. The entire database layer is abstracted; a user will only speak in terms of forms and fields when scripting in Deluge. + +For more information, read the Zoho [https://help.creator.zoho.com/Deluge-Reference---Overview.html Deluge information page]. + +For a main page of where and how one can use the language, see [https://help.creator.zoho.com/Deluge-Reference.html here]. \ No newline at end of file diff --git a/Lang/Deluge/Comments b/Lang/Deluge/Comments new file mode 120000 index 0000000000..7f64ccca06 --- /dev/null +++ b/Lang/Deluge/Comments @@ -0,0 +1 @@ +../../Task/Comments/Deluge \ No newline at end of file diff --git a/Lang/Deluge/Conditional-structures b/Lang/Deluge/Conditional-structures new file mode 120000 index 0000000000..7d68a29752 --- /dev/null +++ b/Lang/Deluge/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Deluge \ No newline at end of file diff --git a/Lang/Diesel/0DESCRIPTION b/Lang/Diesel/0DESCRIPTION new file mode 100644 index 0000000000..5437cfc93e --- /dev/null +++ b/Lang/Diesel/0DESCRIPTION @@ -0,0 +1,5 @@ +{{language|diesel +|site=http://wasp.cs.washington.edu/wasp_diesel.html +}} + +Diesel is an advanced object-oriented programming language. It is a successor to the [[Cecil]] language, which included multiply dispatched methods, a flexible classless object model, and a constraint-based polymorphic static type system. Diesel adds a module system and simplifies the object model. \ No newline at end of file diff --git a/Lang/Dodo0/0DESCRIPTION b/Lang/Dodo0/0DESCRIPTION new file mode 100644 index 0000000000..e645f45e55 --- /dev/null +++ b/Lang/Dodo0/0DESCRIPTION @@ -0,0 +1,3 @@ +{{language}}The dodo0 language is a dialect based on a subset of dodo [http://dodo.sourceforge.net]. Dodo is an object-oriented prototype- and continuation-based language with an emphasis on parallelism and concurrency. + +Project home: http://sourceforge.net/projects/dodo \ No newline at end of file diff --git a/Lang/Dylan.NET/0DESCRIPTION b/Lang/Dylan.NET/0DESCRIPTION new file mode 100644 index 0000000000..4d3d27c049 --- /dev/null +++ b/Lang/Dylan.NET/0DESCRIPTION @@ -0,0 +1 @@ +{{stub}}{{language}} \ No newline at end of file diff --git a/Lang/E/0DESCRIPTION b/Lang/E/0DESCRIPTION new file mode 100644 index 0000000000..b614401b9f --- /dev/null +++ b/Lang/E/0DESCRIPTION @@ -0,0 +1,48 @@ +{{language +|strength=strong +|safety=safe +|express=explicit +|compat=duck +|checking=dynamic +|parampass=value +|gc=yes +|hopl id=1990 +|LCT=yes +}} +E is a programming language designed around object-capability security and event-loop concurrency, in order to support creation of highly robust and secure programs. + +Using the [[Java]] implementation of E, Java libraries can be used from E code, and its REPL (e.g. [[Creating a Window]]). + +==Trying E== + +[http://www.erights.org/download/ The current recommended E implementation ("E-on-Java") may be downloaded from erights.org]. + +To run an E program: + + $ rune program.e + +To get a [[REPL]] (aka prompt, shell, interactive interpreter): + + $ rune + +An online REPL is also available at [[Help:IRC|Rosetta Code IRC]] or [irc://chat.freenode.net/erights #erights] on chat.[http://freenode.net/ freenode.net]. + +==Syntax of examples== + +While most of the examples on Rosetta Code are E expressions (programs), some may be written like this: + + ? ''expression'' + # value: ''print representation'' + +This is both the format of a transcript at an E [[REPL]], and the format employed by [http://wiki.erights.org/wiki/Updoc Updoc], a test framework for E. “?” is a prompt for user input (“>” indicates multi-line input) and “# foo:” indicates responses. +* # value: the return value of the ''expression'', printed +* # problem: an exception thrown by evaluation of the ''expression'' +* # syntax error: an exception thrown by parsing of the ''expression'' +* # stdout: or # stderr: text written to the stdout or stderr streams. It is typically only used in test scripts and not in ordinary interactive sessions. + +To try out these examples for yourself, just install E and run the rune command to get the “?” prompt. Multi-line input is automatic for unbalanced brackets/parens and can be indicated in other cases by a trailing backslash. + +==See Also== + +* [http://www.erights.org erights.org] — Home page of E +* [http://wiki.erights.org E Wiki] \ No newline at end of file diff --git a/Lang/E/100-doors b/Lang/E/100-doors new file mode 120000 index 0000000000..dd8808ae00 --- /dev/null +++ b/Lang/E/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/E \ No newline at end of file diff --git a/Lang/E/99-Bottles-of-Beer b/Lang/E/99-Bottles-of-Beer new file mode 120000 index 0000000000..bf67561f45 --- /dev/null +++ b/Lang/E/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/E \ No newline at end of file diff --git a/Lang/E/Abstract-type b/Lang/E/Abstract-type new file mode 120000 index 0000000000..7cc70075fa --- /dev/null +++ b/Lang/E/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/E \ No newline at end of file diff --git a/Lang/E/Accumulator-factory b/Lang/E/Accumulator-factory new file mode 120000 index 0000000000..07538fab10 --- /dev/null +++ b/Lang/E/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/E \ No newline at end of file diff --git a/Lang/E/Ackermann-function b/Lang/E/Ackermann-function new file mode 120000 index 0000000000..ac091a6b79 --- /dev/null +++ b/Lang/E/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/E \ No newline at end of file diff --git a/Lang/E/Active-object b/Lang/E/Active-object new file mode 120000 index 0000000000..bbda61f08a --- /dev/null +++ b/Lang/E/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/E \ No newline at end of file diff --git a/Lang/E/Align-columns b/Lang/E/Align-columns new file mode 120000 index 0000000000..5cdcd1173b --- /dev/null +++ b/Lang/E/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/E \ No newline at end of file diff --git a/Lang/E/Anagrams b/Lang/E/Anagrams new file mode 120000 index 0000000000..7f45ceaa18 --- /dev/null +++ b/Lang/E/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/E \ No newline at end of file diff --git a/Lang/E/Animate-a-pendulum b/Lang/E/Animate-a-pendulum new file mode 120000 index 0000000000..f738a972e4 --- /dev/null +++ b/Lang/E/Animate-a-pendulum @@ -0,0 +1 @@ +../../Task/Animate-a-pendulum/E \ No newline at end of file diff --git a/Lang/E/Animation b/Lang/E/Animation new file mode 120000 index 0000000000..3290c8baa0 --- /dev/null +++ b/Lang/E/Animation @@ -0,0 +1 @@ +../../Task/Animation/E \ No newline at end of file diff --git a/Lang/E/Apply-a-callback-to-an-array b/Lang/E/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..97eb27939b --- /dev/null +++ b/Lang/E/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/E \ No newline at end of file diff --git a/Lang/E/Arbitrary-precision-integers-(included) b/Lang/E/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..e7eab2c630 --- /dev/null +++ b/Lang/E/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/E \ No newline at end of file diff --git a/Lang/E/Arithmetic-Integer b/Lang/E/Arithmetic-Integer new file mode 120000 index 0000000000..bbfa7f952f --- /dev/null +++ b/Lang/E/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/E \ No newline at end of file diff --git a/Lang/E/Arithmetic-evaluation b/Lang/E/Arithmetic-evaluation new file mode 120000 index 0000000000..637bbe0a93 --- /dev/null +++ b/Lang/E/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/E \ No newline at end of file diff --git a/Lang/E/Array-concatenation b/Lang/E/Array-concatenation new file mode 120000 index 0000000000..d1862b8122 --- /dev/null +++ b/Lang/E/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/E \ No newline at end of file diff --git a/Lang/E/Arrays b/Lang/E/Arrays new file mode 120000 index 0000000000..bee6e3bb02 --- /dev/null +++ b/Lang/E/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/E \ No newline at end of file diff --git a/Lang/E/Assertions b/Lang/E/Assertions new file mode 120000 index 0000000000..925c5e5ab3 --- /dev/null +++ b/Lang/E/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/E \ No newline at end of file diff --git a/Lang/E/Associative-array-Creation b/Lang/E/Associative-array-Creation new file mode 120000 index 0000000000..b8f3612048 --- /dev/null +++ b/Lang/E/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/E \ No newline at end of file diff --git a/Lang/E/Associative-array-Iteration b/Lang/E/Associative-array-Iteration new file mode 120000 index 0000000000..5cad696d56 --- /dev/null +++ b/Lang/E/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/E \ No newline at end of file diff --git a/Lang/E/Atomic-updates b/Lang/E/Atomic-updates new file mode 120000 index 0000000000..381339f621 --- /dev/null +++ b/Lang/E/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/E \ No newline at end of file diff --git a/Lang/E/Averages-Arithmetic-mean b/Lang/E/Averages-Arithmetic-mean new file mode 120000 index 0000000000..4a8ce2050f --- /dev/null +++ b/Lang/E/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/E \ No newline at end of file diff --git a/Lang/E/Averages-Median b/Lang/E/Averages-Median new file mode 120000 index 0000000000..69c7eb0a13 --- /dev/null +++ b/Lang/E/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/E \ No newline at end of file diff --git a/Lang/E/Averages-Mode b/Lang/E/Averages-Mode new file mode 120000 index 0000000000..4f9876bb17 --- /dev/null +++ b/Lang/E/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/E \ No newline at end of file diff --git a/Lang/E/Averages-Pythagorean-means b/Lang/E/Averages-Pythagorean-means new file mode 120000 index 0000000000..5edbc404ad --- /dev/null +++ b/Lang/E/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/E \ No newline at end of file diff --git a/Lang/E/Averages-Root-mean-square b/Lang/E/Averages-Root-mean-square new file mode 120000 index 0000000000..edd42d5577 --- /dev/null +++ b/Lang/E/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/E \ No newline at end of file diff --git a/Lang/E/Averages-Simple-moving-average b/Lang/E/Averages-Simple-moving-average new file mode 120000 index 0000000000..96fcfb1b5a --- /dev/null +++ b/Lang/E/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/E \ No newline at end of file diff --git a/Lang/E/Binary-search b/Lang/E/Binary-search new file mode 120000 index 0000000000..dbdeb4fd9b --- /dev/null +++ b/Lang/E/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/E \ No newline at end of file diff --git a/Lang/E/Binary-strings b/Lang/E/Binary-strings new file mode 120000 index 0000000000..5290892058 --- /dev/null +++ b/Lang/E/Binary-strings @@ -0,0 +1 @@ +../../Task/Binary-strings/E \ No newline at end of file diff --git a/Lang/E/Bitmap b/Lang/E/Bitmap new file mode 120000 index 0000000000..dafdbf2dc6 --- /dev/null +++ b/Lang/E/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/E \ No newline at end of file diff --git a/Lang/E/Bitmap-Bresenhams-line-algorithm b/Lang/E/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..7e19d9faed --- /dev/null +++ b/Lang/E/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/E \ No newline at end of file diff --git a/Lang/E/Bitmap-Flood-fill b/Lang/E/Bitmap-Flood-fill new file mode 120000 index 0000000000..e6ef8a3e67 --- /dev/null +++ b/Lang/E/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/E \ No newline at end of file diff --git a/Lang/E/Bitmap-Read-a-PPM-file b/Lang/E/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..b4813ee2e5 --- /dev/null +++ b/Lang/E/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/E \ No newline at end of file diff --git a/Lang/E/Bitwise-operations b/Lang/E/Bitwise-operations new file mode 120000 index 0000000000..e4daaa9854 --- /dev/null +++ b/Lang/E/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/E \ No newline at end of file diff --git a/Lang/E/Boolean-values b/Lang/E/Boolean-values new file mode 120000 index 0000000000..802d76f42c --- /dev/null +++ b/Lang/E/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/E \ No newline at end of file diff --git a/Lang/E/Bulls-and-cows b/Lang/E/Bulls-and-cows new file mode 120000 index 0000000000..00d3452099 --- /dev/null +++ b/Lang/E/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/E \ No newline at end of file diff --git a/Lang/E/Call-an-object-method b/Lang/E/Call-an-object-method new file mode 120000 index 0000000000..e113a1f2c2 --- /dev/null +++ b/Lang/E/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/E \ No newline at end of file diff --git a/Lang/E/Character-codes b/Lang/E/Character-codes new file mode 120000 index 0000000000..f37767f9b9 --- /dev/null +++ b/Lang/E/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/E \ No newline at end of file diff --git a/Lang/E/Character-matching b/Lang/E/Character-matching new file mode 120000 index 0000000000..b0aea42ad3 --- /dev/null +++ b/Lang/E/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/E \ No newline at end of file diff --git a/Lang/E/Check-that-file-exists b/Lang/E/Check-that-file-exists new file mode 120000 index 0000000000..542093a587 --- /dev/null +++ b/Lang/E/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/E \ No newline at end of file diff --git a/Lang/E/Checkpoint-synchronization b/Lang/E/Checkpoint-synchronization new file mode 120000 index 0000000000..36ea846292 --- /dev/null +++ b/Lang/E/Checkpoint-synchronization @@ -0,0 +1 @@ +../../Task/Checkpoint-synchronization/E \ No newline at end of file diff --git a/Lang/E/Classes b/Lang/E/Classes new file mode 120000 index 0000000000..eb3dc0c2fe --- /dev/null +++ b/Lang/E/Classes @@ -0,0 +1 @@ +../../Task/Classes/E \ No newline at end of file diff --git a/Lang/E/Collections b/Lang/E/Collections new file mode 120000 index 0000000000..c77f025e4c --- /dev/null +++ b/Lang/E/Collections @@ -0,0 +1 @@ +../../Task/Collections/E \ No newline at end of file diff --git a/Lang/E/Combinations b/Lang/E/Combinations new file mode 120000 index 0000000000..26c501db4d --- /dev/null +++ b/Lang/E/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/E \ No newline at end of file diff --git a/Lang/E/Command-line-arguments b/Lang/E/Command-line-arguments new file mode 120000 index 0000000000..8dbfc21610 --- /dev/null +++ b/Lang/E/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/E \ No newline at end of file diff --git a/Lang/E/Comments b/Lang/E/Comments new file mode 120000 index 0000000000..039967682d --- /dev/null +++ b/Lang/E/Comments @@ -0,0 +1 @@ +../../Task/Comments/E \ No newline at end of file diff --git a/Lang/E/Compound-data-type b/Lang/E/Compound-data-type new file mode 120000 index 0000000000..d639d8d583 --- /dev/null +++ b/Lang/E/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/E \ No newline at end of file diff --git a/Lang/E/Concurrent-computing b/Lang/E/Concurrent-computing new file mode 120000 index 0000000000..1e4cbee0bd --- /dev/null +++ b/Lang/E/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/E \ No newline at end of file diff --git a/Lang/E/Conditional-structures b/Lang/E/Conditional-structures new file mode 120000 index 0000000000..8542d207b0 --- /dev/null +++ b/Lang/E/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/E \ No newline at end of file diff --git a/Lang/E/Constrained-genericity b/Lang/E/Constrained-genericity new file mode 120000 index 0000000000..fb5c6f495e --- /dev/null +++ b/Lang/E/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/E \ No newline at end of file diff --git a/Lang/E/Conways-Game-of-Life b/Lang/E/Conways-Game-of-Life new file mode 120000 index 0000000000..9d04a55e81 --- /dev/null +++ b/Lang/E/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/E \ No newline at end of file diff --git a/Lang/E/Create-a-file b/Lang/E/Create-a-file new file mode 120000 index 0000000000..f80112f784 --- /dev/null +++ b/Lang/E/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/E \ No newline at end of file diff --git a/Lang/E/Deepcopy b/Lang/E/Deepcopy new file mode 120000 index 0000000000..b423a07761 --- /dev/null +++ b/Lang/E/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/E \ No newline at end of file diff --git a/Lang/E/Define-a-primitive-data-type b/Lang/E/Define-a-primitive-data-type new file mode 120000 index 0000000000..df0247a20c --- /dev/null +++ b/Lang/E/Define-a-primitive-data-type @@ -0,0 +1 @@ +../../Task/Define-a-primitive-data-type/E \ No newline at end of file diff --git a/Lang/E/Delegates b/Lang/E/Delegates new file mode 120000 index 0000000000..53c387ee69 --- /dev/null +++ b/Lang/E/Delegates @@ -0,0 +1 @@ +../../Task/Delegates/E \ No newline at end of file diff --git a/Lang/E/Delete-a-file b/Lang/E/Delete-a-file new file mode 120000 index 0000000000..c9bb921924 --- /dev/null +++ b/Lang/E/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/E \ No newline at end of file diff --git a/Lang/E/Detect-division-by-zero b/Lang/E/Detect-division-by-zero new file mode 120000 index 0000000000..3cd08aea4f --- /dev/null +++ b/Lang/E/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/E \ No newline at end of file diff --git a/Lang/E/Determine-if-a-string-is-numeric b/Lang/E/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..36ce6ffe3d --- /dev/null +++ b/Lang/E/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/E \ No newline at end of file diff --git a/Lang/E/Distributed-programming b/Lang/E/Distributed-programming new file mode 120000 index 0000000000..e49860d2d1 --- /dev/null +++ b/Lang/E/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/E \ No newline at end of file diff --git a/Lang/E/Documentation b/Lang/E/Documentation new file mode 120000 index 0000000000..2c6b03ce74 --- /dev/null +++ b/Lang/E/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/E \ No newline at end of file diff --git a/Lang/E/Doubly-linked-list-Definition b/Lang/E/Doubly-linked-list-Definition new file mode 120000 index 0000000000..7b30e7416e --- /dev/null +++ b/Lang/E/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/E \ No newline at end of file diff --git a/Lang/E/Doubly-linked-list-Element-definition b/Lang/E/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..0ecc0d9625 --- /dev/null +++ b/Lang/E/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/E \ No newline at end of file diff --git a/Lang/E/Doubly-linked-list-Element-insertion b/Lang/E/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..28f60675c2 --- /dev/null +++ b/Lang/E/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/E \ No newline at end of file diff --git a/Lang/E/Doubly-linked-list-Traversal b/Lang/E/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..27c633cceb --- /dev/null +++ b/Lang/E/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/E \ No newline at end of file diff --git a/Lang/E/Dynamic-variable-names b/Lang/E/Dynamic-variable-names new file mode 120000 index 0000000000..b06eaefb81 --- /dev/null +++ b/Lang/E/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/E \ No newline at end of file diff --git a/Lang/E/Empty-program b/Lang/E/Empty-program new file mode 120000 index 0000000000..35847509c5 --- /dev/null +++ b/Lang/E/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/E \ No newline at end of file diff --git a/Lang/E/Enforced-immutability b/Lang/E/Enforced-immutability new file mode 120000 index 0000000000..4d0a30be01 --- /dev/null +++ b/Lang/E/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/E \ No newline at end of file diff --git a/Lang/E/Enumerations b/Lang/E/Enumerations new file mode 120000 index 0000000000..bebcd53840 --- /dev/null +++ b/Lang/E/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/E \ No newline at end of file diff --git a/Lang/E/Ethiopian-multiplication b/Lang/E/Ethiopian-multiplication new file mode 120000 index 0000000000..44584b7e76 --- /dev/null +++ b/Lang/E/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/E \ No newline at end of file diff --git a/Lang/E/Events b/Lang/E/Events new file mode 120000 index 0000000000..b496a49434 --- /dev/null +++ b/Lang/E/Events @@ -0,0 +1 @@ +../../Task/Events/E \ No newline at end of file diff --git a/Lang/E/Evolutionary-algorithm b/Lang/E/Evolutionary-algorithm new file mode 120000 index 0000000000..3fd0243963 --- /dev/null +++ b/Lang/E/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/E \ No newline at end of file diff --git a/Lang/E/Exceptions b/Lang/E/Exceptions new file mode 120000 index 0000000000..416a693193 --- /dev/null +++ b/Lang/E/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/E \ No newline at end of file diff --git a/Lang/E/Execute-a-system-command b/Lang/E/Execute-a-system-command new file mode 120000 index 0000000000..db378f057c --- /dev/null +++ b/Lang/E/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/E \ No newline at end of file diff --git a/Lang/E/Exponentiation-operator b/Lang/E/Exponentiation-operator new file mode 120000 index 0000000000..6d66eeef6f --- /dev/null +++ b/Lang/E/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/E \ No newline at end of file diff --git a/Lang/E/Extend-your-language b/Lang/E/Extend-your-language new file mode 120000 index 0000000000..e349929430 --- /dev/null +++ b/Lang/E/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/E \ No newline at end of file diff --git a/Lang/E/FizzBuzz b/Lang/E/FizzBuzz new file mode 120000 index 0000000000..dd46ad2021 --- /dev/null +++ b/Lang/E/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/E \ No newline at end of file diff --git a/Lang/E/Infinity b/Lang/E/Infinity new file mode 120000 index 0000000000..9976ae182b --- /dev/null +++ b/Lang/E/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/E \ No newline at end of file diff --git a/Lang/E/Knuth-shuffle b/Lang/E/Knuth-shuffle new file mode 120000 index 0000000000..907dfd4950 --- /dev/null +++ b/Lang/E/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/E \ No newline at end of file diff --git a/Lang/E/Ordered-words b/Lang/E/Ordered-words new file mode 120000 index 0000000000..0e2d25355f --- /dev/null +++ b/Lang/E/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/E \ No newline at end of file diff --git a/Lang/E/Quine b/Lang/E/Quine new file mode 120000 index 0000000000..51bdeb52ea --- /dev/null +++ b/Lang/E/Quine @@ -0,0 +1 @@ +../../Task/Quine/E \ No newline at end of file diff --git a/Lang/E/Search-a-list b/Lang/E/Search-a-list new file mode 120000 index 0000000000..3656d654f3 --- /dev/null +++ b/Lang/E/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/E \ No newline at end of file diff --git a/Lang/EC/0DESCRIPTION b/Lang/EC/0DESCRIPTION new file mode 100644 index 0000000000..da088ab50c --- /dev/null +++ b/Lang/EC/0DESCRIPTION @@ -0,0 +1,56 @@ +{{language|eC +|strength=weak +|safety=unsafe +|express=explicit +|compat=nominative +|checking=both +|parampass=both +|gc=no +|LCT=yes}} +eC (Ecere C) is an [[object-oriented]] language derived from and compatible with [[derived from::compatible with::C]] designed and developed by Ecere Corporation. It aims at being fast, light and easy to write. + +It is supported by a cross-[[platform]] runtime [[Ecere|library]] including its own [[GUI]] toolkit, 2D/3D graphics engine as well as networking support. + +The Ecere SDK is completely free and includes a full-featured [[Ecere IDE|Integrated Development Environment]] as well as a compiling tools for the eC language. + +''Some of eC Features'' + +* Full C compatibility (Only exception: few additional reserved keywords such as 'class') +* Object-oriented class definitions supporting single inheritance +* Per instance virtual methods +* Import feature removing the need for header files +* Properties +* Automatic conversions +* Context sensitive enumerations +* Component object model enabling dynamic lookup of classes, methods, objects serialization and broking, runtime code class aggregation + +== Sample Code == +''Properties & Conversions in eC'' + + '''class''' Pen + { + Color color; + '''public''' '''property''' Color color + { + '''get''' { '''return''' color; } + '''set''' { color = value; } + } + } + + // Example Usage + Pen pen { red }; + Pen pen { color = red }; + pen.color = ~pen.color; + pen.color += 10; + pen.color.r = 255; + pen.color = 0xFF0000; + pen.color = { 255, 0, 0 }; + pen.color = ColorHSV { 0, 100, 100 }; + pen.color = ColorLab { 53, 79, 66 }; + pen.color = ColorCMYK { 0, 100, 100, 0 }; + +==External links== +*[http://www.ecere.com/technologies.html#eC Description of eC language on official web site] +*[http://www.ecere.com/ Ecere Corporation's web site] +*[http://zerotri.net/wiki/doku.php?id=ecere_review Review of eC language and SDK by zerotri] +*[http://freshmeat.net/projects/ecere/ Ecere SDK project on FreshMeat] \ No newline at end of file diff --git a/Lang/EGL/0DESCRIPTION b/Lang/EGL/0DESCRIPTION new file mode 100644 index 0000000000..f55eab0114 --- /dev/null +++ b/Lang/EGL/0DESCRIPTION @@ -0,0 +1,7 @@ +{{language +|site=http://www.eclipse.org/edt/ +}} +{{Wikipedia|EGL_(programming_language)}} +EGL (Enterprise Generation Language), originally developed by IBM and now available as the EDT (EGL Development Tools) Open Source project under the EPL (Eclipse Public License), is a programming technology designed to meet the challenges of modern, multi-platform application development by providing a common language and programming model across languages, frameworks, and runtime platforms. The language borrows concepts familiar to anyone using statically typed languages like Java, COBOL, C, etc. However, it borrows the concept of Stereotype from UML (Universal Modeling Language) that is not typically found in statically typed programming languages. + +EGL is similar in syntax to other common languages so it can be learned by application developers with similar previous programming background. EGL application development abstractions shield programmers from the technical interfaces of systems and middleware allowing them to focus on building business functionality. EGL applications and services are written, tested and debugged at the EGL source level, and once they are satisfactorily functionally tested they can be compiled into Java or JavaScript code. \ No newline at end of file diff --git a/Lang/EGL/100-doors b/Lang/EGL/100-doors new file mode 120000 index 0000000000..73434cf4f2 --- /dev/null +++ b/Lang/EGL/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/EGL \ No newline at end of file diff --git a/Lang/EGL/99-Bottles-of-Beer b/Lang/EGL/99-Bottles-of-Beer new file mode 120000 index 0000000000..21c6a8218b --- /dev/null +++ b/Lang/EGL/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/EGL \ No newline at end of file diff --git a/Lang/EGL/A+B b/Lang/EGL/A+B new file mode 120000 index 0000000000..2769f4bd44 --- /dev/null +++ b/Lang/EGL/A+B @@ -0,0 +1 @@ +../../Task/A+B/EGL \ No newline at end of file diff --git a/Lang/EGL/Apply-a-callback-to-an-array b/Lang/EGL/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..f89619b930 --- /dev/null +++ b/Lang/EGL/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/EGL \ No newline at end of file diff --git a/Lang/EGL/Array-concatenation b/Lang/EGL/Array-concatenation new file mode 120000 index 0000000000..dc912ace33 --- /dev/null +++ b/Lang/EGL/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/EGL \ No newline at end of file diff --git a/Lang/EGL/Arrays b/Lang/EGL/Arrays new file mode 120000 index 0000000000..522e5bedea --- /dev/null +++ b/Lang/EGL/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/EGL \ No newline at end of file diff --git a/Lang/EGL/Boolean-values b/Lang/EGL/Boolean-values new file mode 120000 index 0000000000..8987c82d20 --- /dev/null +++ b/Lang/EGL/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/EGL \ No newline at end of file diff --git a/Lang/EGL/Count-occurrences-of-a-substring b/Lang/EGL/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..3529a9ff2e --- /dev/null +++ b/Lang/EGL/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/EGL \ No newline at end of file diff --git a/Lang/EGL/Date-format b/Lang/EGL/Date-format new file mode 120000 index 0000000000..cd92ff2a8c --- /dev/null +++ b/Lang/EGL/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/EGL \ No newline at end of file diff --git a/Lang/EGL/Empty-program b/Lang/EGL/Empty-program new file mode 120000 index 0000000000..c897ecd173 --- /dev/null +++ b/Lang/EGL/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/EGL \ No newline at end of file diff --git a/Lang/EGL/Enumerations b/Lang/EGL/Enumerations new file mode 120000 index 0000000000..5df513f81a --- /dev/null +++ b/Lang/EGL/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/EGL \ No newline at end of file diff --git a/Lang/EGL/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/EGL/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..0e6057c9b7 --- /dev/null +++ b/Lang/EGL/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/EGL \ No newline at end of file diff --git a/Lang/EGL/JSON b/Lang/EGL/JSON new file mode 120000 index 0000000000..41a6fba16a --- /dev/null +++ b/Lang/EGL/JSON @@ -0,0 +1 @@ +../../Task/JSON/EGL \ No newline at end of file diff --git a/Lang/ELLA/0DESCRIPTION b/Lang/ELLA/0DESCRIPTION new file mode 100644 index 0000000000..8a21efa982 --- /dev/null +++ b/Lang/ELLA/0DESCRIPTION @@ -0,0 +1,11 @@ +{{language}}{{stub}} +VLSI Hardware Description Language ELLA is a hardware engineers support toolset used to design and verify hardware design. Developed by the UK Ministry of Defence. + +Includes tools to perform: +* design transformation +* symbolic simulations +* formal verification + +== See also == +* Ella 2000: A Language for Electronic System Design - by J. D. Morison, A. S. Clarke +* A design and verification environment for ELLA - Barringer, Gough, Monahan, Williams, Arcus, Armstrong & Hill. - IEEE Xplore, Volume , Issue , 29 Aug-1 Sep 1995 Page(s):685 - 690 \ No newline at end of file diff --git a/Lang/ESQL/0DESCRIPTION b/Lang/ESQL/0DESCRIPTION new file mode 100644 index 0000000000..7c03f1131b --- /dev/null +++ b/Lang/ESQL/0DESCRIPTION @@ -0,0 +1,2 @@ +{{language|ESQL}}{{implementation|SQL}} +{{stub}} \ No newline at end of file diff --git a/Lang/Efene/0DESCRIPTION b/Lang/Efene/0DESCRIPTION new file mode 100644 index 0000000000..e0c97510b6 --- /dev/null +++ b/Lang/Efene/0DESCRIPTION @@ -0,0 +1,21 @@ +{{language +|site=http://marianoguerra.com.ar/efene}}{{DISPLAYTITLE:Category:efene}} + +efene is a programming language that runs on the Erlang virtual machine. + +The idea is to provide an alternative syntax to Erlang that is most suitable for people coming from languages like Java, C, C++, C#, or JavaScript. + +The language is almost 100% compatible with Erlang (and will be); the compiler allows to translate an efene source file into a readable Erlang one. It also adds some syntactic sugar in some places to make some tasks easier. + +To see how it looks you can go to the [http://github.com/marianoguerra/efene/tree/master/examples/ examples directory]. + +==Participate== + +A mailing list is available at librelist: just send a mail to [mailto:efene@librelist.com efene@librelist.com] to subscribe. + +As first email you may send a hello world program in efene and present yourself by saying your name, where you are, how you heard about efene, and anything else you would like to say. + +==Useful links== +* [http://efene.tumblr.com/ Blog] +* [http://github.com/marianoguerra/efene Central repo (fork this one)] +* [http://github.com/marianoguerra/efene/issues Issue tracker] \ No newline at end of file diff --git a/Lang/Efene/Apply-a-callback-to-an-array b/Lang/Efene/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..d7d745f70b --- /dev/null +++ b/Lang/Efene/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Efene \ No newline at end of file diff --git a/Lang/Efene/Arithmetic-Integer b/Lang/Efene/Arithmetic-Integer new file mode 120000 index 0000000000..5e32c926f9 --- /dev/null +++ b/Lang/Efene/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Efene \ No newline at end of file diff --git a/Lang/Efene/Array-concatenation b/Lang/Efene/Array-concatenation new file mode 120000 index 0000000000..d8c3a37201 --- /dev/null +++ b/Lang/Efene/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Efene \ No newline at end of file diff --git a/Lang/Efene/Conditional-structures b/Lang/Efene/Conditional-structures new file mode 120000 index 0000000000..c1765cc7f6 --- /dev/null +++ b/Lang/Efene/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Efene \ No newline at end of file diff --git a/Lang/Eiffel/Command-line-arguments b/Lang/Eiffel/Command-line-arguments new file mode 120000 index 0000000000..925b00c899 --- /dev/null +++ b/Lang/Eiffel/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Constrained-genericity b/Lang/Eiffel/Constrained-genericity new file mode 120000 index 0000000000..5965900a59 --- /dev/null +++ b/Lang/Eiffel/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Count-occurrences-of-a-substring b/Lang/Eiffel/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..e355893166 --- /dev/null +++ b/Lang/Eiffel/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Dining-philosophers b/Lang/Eiffel/Dining-philosophers new file mode 120000 index 0000000000..d9c7ed9849 --- /dev/null +++ b/Lang/Eiffel/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Documentation b/Lang/Eiffel/Documentation new file mode 120000 index 0000000000..59670c0c20 --- /dev/null +++ b/Lang/Eiffel/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Empty-program b/Lang/Eiffel/Empty-program new file mode 120000 index 0000000000..ca8bbeedb8 --- /dev/null +++ b/Lang/Eiffel/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Eiffel/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..226de06281 --- /dev/null +++ b/Lang/Eiffel/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Eiffel \ No newline at end of file diff --git a/Lang/Ela/0DESCRIPTION b/Lang/Ela/0DESCRIPTION new file mode 100644 index 0000000000..d60e29e01a --- /dev/null +++ b/Lang/Ela/0DESCRIPTION @@ -0,0 +1,14 @@ +{{language|Ela +|exec=bytecode +|site=http://code.google.com/p/elalang/ +|gc=yes +|strength=strong +|safety=safe +|checking=dynamic +|express=implicit +|compat=duck +|parampass=value +}} +{{language programming paradigm|functional}} +Ela is a pure functional language. Ela supports both strict and non-strict evaluation but is strict by default. Ela has a layout based, [[Haskell]] style syntax. Features supported by Ela include first class functions, pattern matching, lazy evaluation, algebraic data types (including open algebraic data types), type classes. +Ela runs on its own virtual machine but currently requires [[.NET]] or [[Mono]]. \ No newline at end of file diff --git a/Lang/Ela/100-doors b/Lang/Ela/100-doors new file mode 120000 index 0000000000..314ef7135a --- /dev/null +++ b/Lang/Ela/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Ela \ No newline at end of file diff --git a/Lang/Ela/99-Bottles-of-Beer b/Lang/Ela/99-Bottles-of-Beer new file mode 120000 index 0000000000..04aadcd7de --- /dev/null +++ b/Lang/Ela/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Ela \ No newline at end of file diff --git a/Lang/Ela/A+B b/Lang/Ela/A+B new file mode 120000 index 0000000000..5b42eebaeb --- /dev/null +++ b/Lang/Ela/A+B @@ -0,0 +1 @@ +../../Task/A+B/Ela \ No newline at end of file diff --git a/Lang/Ela/Ackermann-function b/Lang/Ela/Ackermann-function new file mode 120000 index 0000000000..333452b05c --- /dev/null +++ b/Lang/Ela/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Ela \ No newline at end of file diff --git a/Lang/Ela/Anonymous-recursion b/Lang/Ela/Anonymous-recursion new file mode 120000 index 0000000000..dc1e70d567 --- /dev/null +++ b/Lang/Ela/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Ela \ No newline at end of file diff --git a/Lang/Ela/Comments b/Lang/Ela/Comments new file mode 120000 index 0000000000..20d2debfe2 --- /dev/null +++ b/Lang/Ela/Comments @@ -0,0 +1 @@ +../../Task/Comments/Ela \ No newline at end of file diff --git a/Lang/Ela/Compound-data-type b/Lang/Ela/Compound-data-type new file mode 120000 index 0000000000..e679261dd5 --- /dev/null +++ b/Lang/Ela/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Ela \ No newline at end of file diff --git a/Lang/Ela/Conditional-structures b/Lang/Ela/Conditional-structures new file mode 120000 index 0000000000..62565c82aa --- /dev/null +++ b/Lang/Ela/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Ela \ No newline at end of file diff --git a/Lang/Ela/Detect-division-by-zero b/Lang/Ela/Detect-division-by-zero new file mode 120000 index 0000000000..703c7f8d37 --- /dev/null +++ b/Lang/Ela/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/Ela \ No newline at end of file diff --git a/Lang/Ela/Dot-product b/Lang/Ela/Dot-product new file mode 120000 index 0000000000..bbbcb020f6 --- /dev/null +++ b/Lang/Ela/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Ela \ No newline at end of file diff --git a/Lang/Ela/Enforced-immutability b/Lang/Ela/Enforced-immutability new file mode 120000 index 0000000000..f901100c74 --- /dev/null +++ b/Lang/Ela/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Ela \ No newline at end of file diff --git a/Lang/Ela/Ethiopian-multiplication b/Lang/Ela/Ethiopian-multiplication new file mode 120000 index 0000000000..721d28da10 --- /dev/null +++ b/Lang/Ela/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Ela \ No newline at end of file diff --git a/Lang/Ela/Execute-HQ9+ b/Lang/Ela/Execute-HQ9+ new file mode 120000 index 0000000000..5c6c3c554f --- /dev/null +++ b/Lang/Ela/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/Ela \ No newline at end of file diff --git a/Lang/Ela/FizzBuzz b/Lang/Ela/FizzBuzz new file mode 120000 index 0000000000..b7ab6c9e21 --- /dev/null +++ b/Lang/Ela/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Ela \ No newline at end of file diff --git a/Lang/Elan/0DESCRIPTION b/Lang/Elan/0DESCRIPTION new file mode 100644 index 0000000000..0fa3ef820b --- /dev/null +++ b/Lang/Elan/0DESCRIPTION @@ -0,0 +1,4 @@ +{{language +|site=http://www.loria.fr/equipes/protheo/SOFTWARES/ELAN/elan.html +}} +The ELAN system provides an environment for specifying and prototyping deduction systems in a language based on rules controlled by strategies. Its purpose is to support the design of theorem provers, logic programming languages, constraints solvers and decision procedures and to offer a modular framework for studying their combination. \ No newline at end of file diff --git a/Lang/ElastiC/0DESCRIPTION b/Lang/ElastiC/0DESCRIPTION new file mode 100644 index 0000000000..584a1971a8 --- /dev/null +++ b/Lang/ElastiC/0DESCRIPTION @@ -0,0 +1,26 @@ +{{stub}} +{{language| +|site=http://www.elasticworld.org/ +|exec=bytecode +|gc=yes +|checking=dynamic +}} +{{language programming paradigm|object-oriented}} + +elastiC is a portable high-level object-oriented interpreted language with a [[C]]-like syntax. Its main characteristics are: +*Open Source, freely available, even for commercial purposes. +*Interpreted. +*Portable [[bytecode]] compilation. +*Familiar C-like syntax. +*Dynamic typing. +*Automatic real, very fast, Garbage Collection. +*Object Oriented with meta-programming support (a la [[Smalltalk]]). +*Functional programming support (Scheme like closures with lexical scoping, and eval-like functionality). +*Hierarchical Namespaces. +*Rich set of useful built-in types (dynamic arrays, dictionaries, symbols, ...). +*Extensibile with C (you can add functions, types, classes, methods, packages, ...). +*Embeddable in C. +*Small footprint, making it ideal also in embedded systems. + + +elastiC has been strongly influenced by C, Smalltalk, [[Scheme]] and [[Python]] and tries to merge the best characteristics of all these languages, while still coherently maintaining its unique personality. \ No newline at end of file diff --git a/Lang/Elena/0DESCRIPTION b/Lang/Elena/0DESCRIPTION new file mode 100644 index 0000000000..015c207823 --- /dev/null +++ b/Lang/Elena/0DESCRIPTION @@ -0,0 +1,39 @@ +{{language|Elena +|exec=bytecode +|strength=strong +|safety=safe +|express=implicit +|checking=dynamic +|gc=yes +|LCT=yes}} +{{language programming paradigm|Object-oriented}}{{language programming paradigm|dynamic}} + +== Overview == + +ELENA is a general-purpose, object-oriented, polymorphic language with late binding. It features multiple dispatching, context-dependent roles, dynamic inheritance and group object support. + +The language treats any program as a set of objects (class instances). The program flow is a process of interaction between objects by sending each other messages. A message may have attached information (a message parameter). An object may react on message if it has an appropriate message handler (a method). If the object reacts on the message it is treated as successful otherwise unsuccessful. In its turn the method may send messages to other objects and so on until the flow reaches the method written by external tools (meta method). If the message is unsuccessful the flow is considered to be broken. It's possible to declare alternative flow which are executed if previous ones are broken. The method has only one input parameter and one output parameter (the method may return itself). + +Every object may be formed up with other objects characterizing its internal state. They in turn may be formed with others and so on until meta objects which internal states are considered as raw data. + +All referring entities in the language are objects. A variable is a reference to the object allocated in the program heap. The literal and numeric constants are references to the objects allocated in the static memory. + +== Object model == + +Any object is an instance of one or another class. The classes form the hierarchy tree on the principle of inheritance. There is the common super class - Object. The class parent may be explicitly declared. When the parent is not specified, the class inherits Object. + +A class is an abstract concept which means that no operations can be done with it except a declaration. So to create the object its symbol should be referenced. There are explicit and implicit, static and dynamic symbols. + +When a new class is declared simultaneously the appropriate explicit symbol is declared as well. The implicit symbol should be declared implicitly. In general the explicit symbol is the object in the initial state and the explicit one is the object in the particular state. + +A static symbol is the class instance which state is preserved. A static symbol is always implicit one. There could be only one instance of static symbol. + +The class declaration can be named or unnamed (inline declaration) public or private (when the class name is a private name). Its body contains member declarations: fields, roles and methods. + +The fields can be accessed only within the class and its descendants. They can be a normal ones (references to another objects) or meta ones (raw data). + +The roles are alternative sets of methods which could be used to implement context-dependant object behavior. When it is applied the role overrides the appropriate object methods with its own ones (static mutation). + +Methods maybe private or public depending on their name (public or private). All class methods are considered to be polymorphic. It is possible to dispatch the method call depending on its parameter (declarative multi-dispatching). The method has only one input (or nil) and output (or it should return itself) parameters. If the method requires several parameters a special proxy argument list object can be used. + +It is possible to declare a special "Any" handler. It is a method which redirects any unhandled message (i.e. messages which are not mapped in the class or its base classes) to the specified target. The target could be a single object (actually mutation) or collection (group object). A group object is a collection of the objects accessible through the common instance reference. The content of the group can be changed dynamically during the object life time (self-modification). The member objects can be a part of different groups or be single. The group can be persistent or temporally created to solve the particular task. The group objects are treated like "normal" ones and no special routines are required to work with them. If two or more members have duplicate methods either the first message mapping is resolved (exclusive mode) or all duplicate methods are executed (broadcast mode) depending on the group type. \ No newline at end of file diff --git a/Lang/Elena/A+B b/Lang/Elena/A+B new file mode 120000 index 0000000000..e81a98bc59 --- /dev/null +++ b/Lang/Elena/A+B @@ -0,0 +1 @@ +../../Task/A+B/Elena \ No newline at end of file diff --git a/Lang/Elena/Accumulator-factory b/Lang/Elena/Accumulator-factory new file mode 120000 index 0000000000..a1b47c46ee --- /dev/null +++ b/Lang/Elena/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Elena \ No newline at end of file diff --git a/Lang/Elena/Ackermann-function b/Lang/Elena/Ackermann-function new file mode 120000 index 0000000000..22370ca2f4 --- /dev/null +++ b/Lang/Elena/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Elena \ No newline at end of file diff --git a/Lang/Elena/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Elena/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..a4bb976ae0 --- /dev/null +++ b/Lang/Elena/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Elena \ No newline at end of file diff --git a/Lang/Elena/Anagrams b/Lang/Elena/Anagrams new file mode 120000 index 0000000000..04e71f74e9 --- /dev/null +++ b/Lang/Elena/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/Elena \ No newline at end of file diff --git a/Lang/Elena/Anonymous-recursion b/Lang/Elena/Anonymous-recursion new file mode 120000 index 0000000000..a86cbf6718 --- /dev/null +++ b/Lang/Elena/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Elena \ No newline at end of file diff --git a/Lang/Elena/Apply-a-callback-to-an-array b/Lang/Elena/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..7c56f7d950 --- /dev/null +++ b/Lang/Elena/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Elena \ No newline at end of file diff --git a/Lang/Elena/Arithmetic-Integer b/Lang/Elena/Arithmetic-Integer new file mode 120000 index 0000000000..0f6ca4dda7 --- /dev/null +++ b/Lang/Elena/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Elena \ No newline at end of file diff --git a/Lang/Elena/Arithmetic-evaluation b/Lang/Elena/Arithmetic-evaluation new file mode 120000 index 0000000000..5fc1665860 --- /dev/null +++ b/Lang/Elena/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Elena \ No newline at end of file diff --git a/Lang/Elena/Array-concatenation b/Lang/Elena/Array-concatenation new file mode 120000 index 0000000000..d9b5e1081f --- /dev/null +++ b/Lang/Elena/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Elena \ No newline at end of file diff --git a/Lang/Elena/Arrays b/Lang/Elena/Arrays new file mode 120000 index 0000000000..faff73be07 --- /dev/null +++ b/Lang/Elena/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Elena \ No newline at end of file diff --git a/Lang/Elena/Associative-array-Creation b/Lang/Elena/Associative-array-Creation new file mode 120000 index 0000000000..15c0e0ef85 --- /dev/null +++ b/Lang/Elena/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Elena \ No newline at end of file diff --git a/Lang/Elena/Associative-array-Iteration b/Lang/Elena/Associative-array-Iteration new file mode 120000 index 0000000000..bd2b42001c --- /dev/null +++ b/Lang/Elena/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Elena \ No newline at end of file diff --git a/Lang/Elena/Averages-Arithmetic-mean b/Lang/Elena/Averages-Arithmetic-mean new file mode 120000 index 0000000000..1efa9b7e56 --- /dev/null +++ b/Lang/Elena/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Elena \ No newline at end of file diff --git a/Lang/Elena/Averages-Median b/Lang/Elena/Averages-Median new file mode 120000 index 0000000000..41268da2d3 --- /dev/null +++ b/Lang/Elena/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Elena \ No newline at end of file diff --git a/Lang/Elena/Averages-Mode b/Lang/Elena/Averages-Mode new file mode 120000 index 0000000000..df6d683b5b --- /dev/null +++ b/Lang/Elena/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/Elena \ No newline at end of file diff --git a/Lang/Elena/Averages-Simple-moving-average b/Lang/Elena/Averages-Simple-moving-average new file mode 120000 index 0000000000..283f696c6f --- /dev/null +++ b/Lang/Elena/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Elena \ No newline at end of file diff --git a/Lang/Elena/Balanced-brackets b/Lang/Elena/Balanced-brackets new file mode 120000 index 0000000000..f6e8feaf43 --- /dev/null +++ b/Lang/Elena/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Elena \ No newline at end of file diff --git a/Lang/Elena/Bitwise-operations b/Lang/Elena/Bitwise-operations new file mode 120000 index 0000000000..b8c6128683 --- /dev/null +++ b/Lang/Elena/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Elena \ No newline at end of file diff --git a/Lang/Elena/Bulls-and-cows b/Lang/Elena/Bulls-and-cows new file mode 120000 index 0000000000..b728bf9120 --- /dev/null +++ b/Lang/Elena/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/Elena \ No newline at end of file diff --git a/Lang/Elena/Caesar-cipher b/Lang/Elena/Caesar-cipher new file mode 120000 index 0000000000..f22d9e6ba6 --- /dev/null +++ b/Lang/Elena/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Elena \ No newline at end of file diff --git a/Lang/Elena/Character-codes b/Lang/Elena/Character-codes new file mode 120000 index 0000000000..3a007f7350 --- /dev/null +++ b/Lang/Elena/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Elena \ No newline at end of file diff --git a/Lang/Elena/Character-matching b/Lang/Elena/Character-matching new file mode 120000 index 0000000000..842017d3ac --- /dev/null +++ b/Lang/Elena/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Elena \ No newline at end of file diff --git a/Lang/Elisa/0DESCRIPTION b/Lang/Elisa/0DESCRIPTION new file mode 100644 index 0000000000..9879fb2930 --- /dev/null +++ b/Lang/Elisa/0DESCRIPTION @@ -0,0 +1,6 @@ +{{language +|site=http://www.xs4all.nl/~jklunder/}} +{{language programming paradigm|procedural}}{{language programming paradigm|functional}}{{language programming paradigm|object-oriented}} +Elisa is a multiparadigm programming language. It combines the best features of procedural programming, functional programming, object-oriented programming and logic programming into one coherent framework. + +The language is described in [http://www.xs4all.nl/~jklunder/ Elisa] \ No newline at end of file diff --git a/Lang/Elisa/Arithmetic-Rational b/Lang/Elisa/Arithmetic-Rational new file mode 120000 index 0000000000..cdcf1dd540 --- /dev/null +++ b/Lang/Elisa/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Elisa \ No newline at end of file diff --git a/Lang/Elixir/0DESCRIPTION b/Lang/Elixir/0DESCRIPTION new file mode 100644 index 0000000000..4d3d27c049 --- /dev/null +++ b/Lang/Elixir/0DESCRIPTION @@ -0,0 +1 @@ +{{stub}}{{language}} \ No newline at end of file diff --git a/Lang/Elixir/FizzBuzz b/Lang/Elixir/FizzBuzz new file mode 120000 index 0000000000..7470c48fb3 --- /dev/null +++ b/Lang/Elixir/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Elixir \ No newline at end of file diff --git a/Lang/Emacs-Lisp/0DESCRIPTION b/Lang/Emacs-Lisp/0DESCRIPTION new file mode 100644 index 0000000000..a669984935 --- /dev/null +++ b/Lang/Emacs-Lisp/0DESCRIPTION @@ -0,0 +1,10 @@ +{{language +|exec=bytecode +}}{{implementation|Lisp}}{{provides|Windowing UI}}{{provides|First class functions}}{{provides|File access}}{{provides|File system access}}{{provides|Database access}} +Emacs Lisp (often abbreviated to elisp) is the [[Lisp]] implementation used by the [[Emacs]] text editor. It doesn't provide all features of [[Common Lisp]] (e.g. its optional arguments always default to nil), but it contains special types which are specific for the use in the editor, like buffers (which is where you actually edit the text), windows, events etc. + +[[Lisp]] expressions can be executed directly from within Emacs editor buffers, or loaded from files which optionally can be compiled into bytecode. + +Emacs configuration files actually are Emacs Lisp source files. + +Emacs Lisp can be used as a general programming language with the emacs "-batch" or "--script" command line arguments. [http://www.emacswiki.org/emacs/BatchMode] \ No newline at end of file diff --git a/Lang/Emacs-Lisp/100-doors b/Lang/Emacs-Lisp/100-doors new file mode 120000 index 0000000000..05c85edc90 --- /dev/null +++ b/Lang/Emacs-Lisp/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Arbitrary-precision-integers-(included) b/Lang/Emacs-Lisp/Arbitrary-precision-integers-(included) new file mode 120000 index 0000000000..a225b1170d --- /dev/null +++ b/Lang/Emacs-Lisp/Arbitrary-precision-integers-(included) @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-(included)/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Assertions b/Lang/Emacs-Lisp/Assertions new file mode 120000 index 0000000000..c4de44c264 --- /dev/null +++ b/Lang/Emacs-Lisp/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Averages-Arithmetic-mean b/Lang/Emacs-Lisp/Averages-Arithmetic-mean new file mode 120000 index 0000000000..f3f811f07e --- /dev/null +++ b/Lang/Emacs-Lisp/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Command-line-arguments b/Lang/Emacs-Lisp/Command-line-arguments new file mode 120000 index 0000000000..9558d430f8 --- /dev/null +++ b/Lang/Emacs-Lisp/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Comments b/Lang/Emacs-Lisp/Comments new file mode 120000 index 0000000000..72e291718d --- /dev/null +++ b/Lang/Emacs-Lisp/Comments @@ -0,0 +1 @@ +../../Task/Comments/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Count-in-octal b/Lang/Emacs-Lisp/Count-in-octal new file mode 120000 index 0000000000..47a8eafa7b --- /dev/null +++ b/Lang/Emacs-Lisp/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Epigram/0DESCRIPTION b/Lang/Epigram/0DESCRIPTION new file mode 100644 index 0000000000..eb6dcdcef9 --- /dev/null +++ b/Lang/Epigram/0DESCRIPTION @@ -0,0 +1,3 @@ +{{stub}}{{language|Epigram +|site=http://www.e-pig.org/darcs/Pig09/web/}} +Epigram 2 is an experimental dependently typed functional programming language. \ No newline at end of file diff --git a/Lang/Erlang/CRC-32 b/Lang/Erlang/CRC-32 new file mode 120000 index 0000000000..2046db1de7 --- /dev/null +++ b/Lang/Erlang/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Character-codes b/Lang/Erlang/Character-codes new file mode 120000 index 0000000000..6dd2ed4a22 --- /dev/null +++ b/Lang/Erlang/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Character-matching b/Lang/Erlang/Character-matching new file mode 120000 index 0000000000..bccd441830 --- /dev/null +++ b/Lang/Erlang/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Chat-server b/Lang/Erlang/Chat-server new file mode 120000 index 0000000000..95f608fb4c --- /dev/null +++ b/Lang/Erlang/Chat-server @@ -0,0 +1 @@ +../../Task/Chat-server/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Combinations b/Lang/Erlang/Combinations new file mode 120000 index 0000000000..035b0cddb0 --- /dev/null +++ b/Lang/Erlang/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Combinations-with-repetitions b/Lang/Erlang/Combinations-with-repetitions new file mode 120000 index 0000000000..b047dc96e0 --- /dev/null +++ b/Lang/Erlang/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Command-line-arguments b/Lang/Erlang/Command-line-arguments new file mode 120000 index 0000000000..925cdf70f0 --- /dev/null +++ b/Lang/Erlang/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Compound-data-type b/Lang/Erlang/Compound-data-type new file mode 120000 index 0000000000..9fe16eb920 --- /dev/null +++ b/Lang/Erlang/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Concurrent-computing b/Lang/Erlang/Concurrent-computing new file mode 120000 index 0000000000..944b4cbf45 --- /dev/null +++ b/Lang/Erlang/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Conditional-structures b/Lang/Erlang/Conditional-structures new file mode 120000 index 0000000000..6a4c7137fb --- /dev/null +++ b/Lang/Erlang/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Conways-Game-of-Life b/Lang/Erlang/Conways-Game-of-Life new file mode 120000 index 0000000000..8ed29e37b7 --- /dev/null +++ b/Lang/Erlang/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Count-occurrences-of-a-substring b/Lang/Erlang/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..5d4477610c --- /dev/null +++ b/Lang/Erlang/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Count-the-coins b/Lang/Erlang/Count-the-coins new file mode 120000 index 0000000000..7937a3c1fe --- /dev/null +++ b/Lang/Erlang/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Date-format b/Lang/Erlang/Date-format new file mode 120000 index 0000000000..e774383a71 --- /dev/null +++ b/Lang/Erlang/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Dining-philosophers b/Lang/Erlang/Dining-philosophers new file mode 120000 index 0000000000..67c8c96e49 --- /dev/null +++ b/Lang/Erlang/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Distributed-programming b/Lang/Erlang/Distributed-programming new file mode 120000 index 0000000000..ec8543d54f --- /dev/null +++ b/Lang/Erlang/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Dot-product b/Lang/Erlang/Dot-product new file mode 120000 index 0000000000..29c90a42cc --- /dev/null +++ b/Lang/Erlang/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Dutch-national-flag-problem b/Lang/Erlang/Dutch-national-flag-problem new file mode 120000 index 0000000000..ee72f2483c --- /dev/null +++ b/Lang/Erlang/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Echo-server b/Lang/Erlang/Echo-server new file mode 120000 index 0000000000..1ce59d5093 --- /dev/null +++ b/Lang/Erlang/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Empty-program b/Lang/Erlang/Empty-program new file mode 120000 index 0000000000..4ec8753db9 --- /dev/null +++ b/Lang/Erlang/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Empty-string b/Lang/Erlang/Empty-string new file mode 120000 index 0000000000..64df8d8686 --- /dev/null +++ b/Lang/Erlang/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Enforced-immutability b/Lang/Erlang/Enforced-immutability new file mode 120000 index 0000000000..7eef766baa --- /dev/null +++ b/Lang/Erlang/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Ethiopian-multiplication b/Lang/Erlang/Ethiopian-multiplication new file mode 120000 index 0000000000..de4043fa33 --- /dev/null +++ b/Lang/Erlang/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Evaluate-binomial-coefficients b/Lang/Erlang/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..3af6e24993 --- /dev/null +++ b/Lang/Erlang/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Events b/Lang/Erlang/Events new file mode 120000 index 0000000000..638555b1fa --- /dev/null +++ b/Lang/Erlang/Events @@ -0,0 +1 @@ +../../Task/Events/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Evolutionary-algorithm b/Lang/Erlang/Evolutionary-algorithm new file mode 120000 index 0000000000..9edbe67b49 --- /dev/null +++ b/Lang/Erlang/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Execute-HQ9+ b/Lang/Erlang/Execute-HQ9+ new file mode 120000 index 0000000000..6202c9ea9e --- /dev/null +++ b/Lang/Erlang/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Execute-a-system-command b/Lang/Erlang/Execute-a-system-command new file mode 120000 index 0000000000..9a425b418d --- /dev/null +++ b/Lang/Erlang/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Exponentiation-operator b/Lang/Erlang/Exponentiation-operator new file mode 120000 index 0000000000..eb9df5db19 --- /dev/null +++ b/Lang/Erlang/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Erlang \ No newline at end of file diff --git a/Lang/Es/0DESCRIPTION b/Lang/Es/0DESCRIPTION new file mode 100644 index 0000000000..36a73932ff --- /dev/null +++ b/Lang/Es/0DESCRIPTION @@ -0,0 +1,10 @@ +{{stub}} +{{language +|hopl id=1729 +}} +{{implementation|UNIX Shell}} +es - extensible shell by Paul Haahr and Byron Rakitzis + +== Links == +* [http://192.220.96.201/es/es-usenix-winter93.html Es: A shell with higher-order functions] (Usenix paper with errata) +* [ftp://ftp.sys.utoronto.ca/pub/es/ FTP site] \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/0DESCRIPTION b/Lang/Euler-Math-Toolbox/0DESCRIPTION new file mode 100644 index 0000000000..114c13967e --- /dev/null +++ b/Lang/Euler-Math-Toolbox/0DESCRIPTION @@ -0,0 +1,6 @@ +{{language +|site=http://www.euler-math-toolbox.de/ +}} +The Euler Mathematical Toolbox is a powerful, versatile, mature software for numerical and symbolic computations written and maintained by R. Grothmann, associate professor of mathmetics at the University of Eichstätt. Euler is similar to [[MATLAB]], but has an own style, and a slightly different syntax. Symbolic mathematics is supported in Euler using the open algebra system [[Maxima]]. It contains a matrix language, a graphical notebook style interface, a plot window and can handle real, complex and interval numbers, vectors and matrices, it can produce 2D/3D plots + +[[Category:Mathematical programming languages]] \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/100-doors b/Lang/Euler-Math-Toolbox/100-doors new file mode 120000 index 0000000000..967e47b372 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/A+B b/Lang/Euler-Math-Toolbox/A+B new file mode 120000 index 0000000000..74fb7db6d0 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/A+B @@ -0,0 +1 @@ +../../Task/A+B/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Ackermann-function b/Lang/Euler-Math-Toolbox/Ackermann-function new file mode 120000 index 0000000000..d7923b6978 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Arithmetic-Complex b/Lang/Euler-Math-Toolbox/Arithmetic-Complex new file mode 120000 index 0000000000..bb88673bc9 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Averages-Mean-angle b/Lang/Euler-Math-Toolbox/Averages-Mean-angle new file mode 120000 index 0000000000..a886552325 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Averages-Median b/Lang/Euler-Math-Toolbox/Averages-Median new file mode 120000 index 0000000000..f5ec858bf0 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Averages-Pythagorean-means b/Lang/Euler-Math-Toolbox/Averages-Pythagorean-means new file mode 120000 index 0000000000..19f6a55274 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Averages-Simple-moving-average b/Lang/Euler-Math-Toolbox/Averages-Simple-moving-average new file mode 120000 index 0000000000..c357585309 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Entropy b/Lang/Euler-Math-Toolbox/Entropy new file mode 120000 index 0000000000..9871187a7a --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Entropy @@ -0,0 +1 @@ +../../Task/Entropy/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Euler-method b/Lang/Euler-Math-Toolbox/Euler-method new file mode 120000 index 0000000000..0a27140c2f --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler/0DESCRIPTION b/Lang/Euler/0DESCRIPTION new file mode 100644 index 0000000000..cd97574392 --- /dev/null +++ b/Lang/Euler/0DESCRIPTION @@ -0,0 +1,4 @@ +{{stub}} +{{language}} + +Euler is a dynamically typed programming language created by Niklaus Wirth (the creator of [[Pascal]], ALGOL W, Modula, [[Modula-2]], Oberon & [[Oberon-2]]) and Helmut Weber, conceived as an extension and generalization of [[ALGOL 60]]. \ No newline at end of file diff --git a/Lang/Euphoria/0DESCRIPTION b/Lang/Euphoria/0DESCRIPTION new file mode 100644 index 0000000000..bcb9823ab8 --- /dev/null +++ b/Lang/Euphoria/0DESCRIPTION @@ -0,0 +1,22 @@ +{{Stub}} +{{language +|exec=interpreted +|site=http://www.openeuphoria.org/ +|gc=yes +|parampass=copy-on-write +|safety=safe +|strength=weak +|express=explicit +|checking=both +|tags=euphoria, Euphoria +|altsite=http://www.rapideuphoria.com/ +|altexec=translated +|alt2exec=bound +|bnf=http://openeuphoria.org/docs/syntax.html +}} +Euphoria is a powerful yet simple programming language, developed by Robert Craig at Rapid Deployment Software in 1993. It is very easy to use, and it has good support, which makes it an excellent language for novice programmers. Euphoria is an interpreted language, just like AWK or QBasic. Although Euphoria does not claim to be object-oriented, some disagree by stating that its scope rules and flexible data structures allow you to simulate any method of programming, including object-oriented. 'Euphoria is a small, fast, cheap programming language and a true gift to young programmers.', states Paul Smith in a August 1997 article in the Monitor. + +==See also== +* [[wp:Euphoria (programming language)|Euphoria on Wikipedia]] +* [http://rapideuphoria.com/ RapidEuphoria site] +* [http://openeuphoria.org/ openEuphoria site] \ No newline at end of file diff --git a/Lang/Euphoria/100-doors b/Lang/Euphoria/100-doors new file mode 120000 index 0000000000..23be3e29b9 --- /dev/null +++ b/Lang/Euphoria/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/99-Bottles-of-Beer b/Lang/Euphoria/99-Bottles-of-Beer new file mode 120000 index 0000000000..25d9613c86 --- /dev/null +++ b/Lang/Euphoria/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/A+B b/Lang/Euphoria/A+B new file mode 120000 index 0000000000..9f49e4a496 --- /dev/null +++ b/Lang/Euphoria/A+B @@ -0,0 +1 @@ +../../Task/A+B/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Ackermann-function b/Lang/Euphoria/Ackermann-function new file mode 120000 index 0000000000..6e2f768ff7 --- /dev/null +++ b/Lang/Euphoria/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Align-columns b/Lang/Euphoria/Align-columns new file mode 120000 index 0000000000..4e38eb0565 --- /dev/null +++ b/Lang/Euphoria/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Anagrams b/Lang/Euphoria/Anagrams new file mode 120000 index 0000000000..5ee94938e6 --- /dev/null +++ b/Lang/Euphoria/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Animate-a-pendulum b/Lang/Euphoria/Animate-a-pendulum new file mode 120000 index 0000000000..b5abf1c836 --- /dev/null +++ b/Lang/Euphoria/Animate-a-pendulum @@ -0,0 +1 @@ +../../Task/Animate-a-pendulum/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Apply-a-callback-to-an-array b/Lang/Euphoria/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..a6e02372c2 --- /dev/null +++ b/Lang/Euphoria/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Arithmetic-Complex b/Lang/Euphoria/Arithmetic-Complex new file mode 120000 index 0000000000..177c5f6177 --- /dev/null +++ b/Lang/Euphoria/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Arithmetic-Integer b/Lang/Euphoria/Arithmetic-Integer new file mode 120000 index 0000000000..9be89eb6d0 --- /dev/null +++ b/Lang/Euphoria/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Array-concatenation b/Lang/Euphoria/Array-concatenation new file mode 120000 index 0000000000..73f7560b3a --- /dev/null +++ b/Lang/Euphoria/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Arrays b/Lang/Euphoria/Arrays new file mode 120000 index 0000000000..3237d59125 --- /dev/null +++ b/Lang/Euphoria/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Assertions b/Lang/Euphoria/Assertions new file mode 120000 index 0000000000..9eb343a11c --- /dev/null +++ b/Lang/Euphoria/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Atomic-updates b/Lang/Euphoria/Atomic-updates new file mode 120000 index 0000000000..890def532e --- /dev/null +++ b/Lang/Euphoria/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Averages-Arithmetic-mean b/Lang/Euphoria/Averages-Arithmetic-mean new file mode 120000 index 0000000000..969de9818f --- /dev/null +++ b/Lang/Euphoria/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Averages-Median b/Lang/Euphoria/Averages-Median new file mode 120000 index 0000000000..7bdd7c5394 --- /dev/null +++ b/Lang/Euphoria/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Averages-Mode b/Lang/Euphoria/Averages-Mode new file mode 120000 index 0000000000..9fdfd0c5dc --- /dev/null +++ b/Lang/Euphoria/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Averages-Pythagorean-means b/Lang/Euphoria/Averages-Pythagorean-means new file mode 120000 index 0000000000..0abf7e56c7 --- /dev/null +++ b/Lang/Euphoria/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Averages-Root-mean-square b/Lang/Euphoria/Averages-Root-mean-square new file mode 120000 index 0000000000..a6e3656fe7 --- /dev/null +++ b/Lang/Euphoria/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Balanced-brackets b/Lang/Euphoria/Balanced-brackets new file mode 120000 index 0000000000..4551e2c660 --- /dev/null +++ b/Lang/Euphoria/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Binary-search b/Lang/Euphoria/Binary-search new file mode 120000 index 0000000000..c0538a9ac0 --- /dev/null +++ b/Lang/Euphoria/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Bitmap b/Lang/Euphoria/Bitmap new file mode 120000 index 0000000000..b9d093c484 --- /dev/null +++ b/Lang/Euphoria/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Bitmap-Bresenhams-line-algorithm b/Lang/Euphoria/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..5d64d806ba --- /dev/null +++ b/Lang/Euphoria/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Bitmap-Read-a-PPM-file b/Lang/Euphoria/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..1eaf1c0652 --- /dev/null +++ b/Lang/Euphoria/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Bitmap-Write-a-PPM-file b/Lang/Euphoria/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..1751918b1d --- /dev/null +++ b/Lang/Euphoria/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Box-the-compass b/Lang/Euphoria/Box-the-compass new file mode 120000 index 0000000000..05c20e5f57 --- /dev/null +++ b/Lang/Euphoria/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Bulls-and-cows b/Lang/Euphoria/Bulls-and-cows new file mode 120000 index 0000000000..efd62f9807 --- /dev/null +++ b/Lang/Euphoria/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Bulls-and-cows-Player b/Lang/Euphoria/Bulls-and-cows-Player new file mode 120000 index 0000000000..75b7682bf1 --- /dev/null +++ b/Lang/Euphoria/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/CSV-to-HTML-translation b/Lang/Euphoria/CSV-to-HTML-translation new file mode 120000 index 0000000000..baa072187c --- /dev/null +++ b/Lang/Euphoria/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Caesar-cipher b/Lang/Euphoria/Caesar-cipher new file mode 120000 index 0000000000..1cf56b5850 --- /dev/null +++ b/Lang/Euphoria/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Case-sensitivity-of-identifiers b/Lang/Euphoria/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..1e11599c23 --- /dev/null +++ b/Lang/Euphoria/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Character-codes b/Lang/Euphoria/Character-codes new file mode 120000 index 0000000000..b10055a7ef --- /dev/null +++ b/Lang/Euphoria/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Character-matching b/Lang/Euphoria/Character-matching new file mode 120000 index 0000000000..14fdab0dd4 --- /dev/null +++ b/Lang/Euphoria/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Check-that-file-exists b/Lang/Euphoria/Check-that-file-exists new file mode 120000 index 0000000000..9847edf351 --- /dev/null +++ b/Lang/Euphoria/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Command-line-arguments b/Lang/Euphoria/Command-line-arguments new file mode 120000 index 0000000000..6603e2a305 --- /dev/null +++ b/Lang/Euphoria/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Comments b/Lang/Euphoria/Comments new file mode 120000 index 0000000000..2006325e46 --- /dev/null +++ b/Lang/Euphoria/Comments @@ -0,0 +1 @@ +../../Task/Comments/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Concurrent-computing b/Lang/Euphoria/Concurrent-computing new file mode 120000 index 0000000000..0971318e13 --- /dev/null +++ b/Lang/Euphoria/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Constrained-random-points-on-a-circle b/Lang/Euphoria/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..c686cd70f2 --- /dev/null +++ b/Lang/Euphoria/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Count-in-factors b/Lang/Euphoria/Count-in-factors new file mode 120000 index 0000000000..27763d56e4 --- /dev/null +++ b/Lang/Euphoria/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Count-in-octal b/Lang/Euphoria/Count-in-octal new file mode 120000 index 0000000000..c09f3cf981 --- /dev/null +++ b/Lang/Euphoria/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Count-occurrences-of-a-substring b/Lang/Euphoria/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..7f2a8951ed --- /dev/null +++ b/Lang/Euphoria/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Create-a-file b/Lang/Euphoria/Create-a-file new file mode 120000 index 0000000000..ed10aa2595 --- /dev/null +++ b/Lang/Euphoria/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Create-a-two-dimensional-array-at-runtime b/Lang/Euphoria/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..a2b5fadef9 --- /dev/null +++ b/Lang/Euphoria/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Create-an-HTML-table b/Lang/Euphoria/Create-an-HTML-table new file mode 120000 index 0000000000..deb80ae82a --- /dev/null +++ b/Lang/Euphoria/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Date-format b/Lang/Euphoria/Date-format new file mode 120000 index 0000000000..f27762115d --- /dev/null +++ b/Lang/Euphoria/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Date-manipulation b/Lang/Euphoria/Date-manipulation new file mode 120000 index 0000000000..5f5d1e7c96 --- /dev/null +++ b/Lang/Euphoria/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Day-of-the-week b/Lang/Euphoria/Day-of-the-week new file mode 120000 index 0000000000..3fe9125cba --- /dev/null +++ b/Lang/Euphoria/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Define-a-primitive-data-type b/Lang/Euphoria/Define-a-primitive-data-type new file mode 120000 index 0000000000..94bef14404 --- /dev/null +++ b/Lang/Euphoria/Define-a-primitive-data-type @@ -0,0 +1 @@ +../../Task/Define-a-primitive-data-type/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Determine-if-a-string-is-numeric b/Lang/Euphoria/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..102f1a5763 --- /dev/null +++ b/Lang/Euphoria/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Dining-philosophers b/Lang/Euphoria/Dining-philosophers new file mode 120000 index 0000000000..bd22012649 --- /dev/null +++ b/Lang/Euphoria/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Discordian-date b/Lang/Euphoria/Discordian-date new file mode 120000 index 0000000000..54fb6edb54 --- /dev/null +++ b/Lang/Euphoria/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Dot-product b/Lang/Euphoria/Dot-product new file mode 120000 index 0000000000..427ed93bf7 --- /dev/null +++ b/Lang/Euphoria/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Empty-program b/Lang/Euphoria/Empty-program new file mode 120000 index 0000000000..241cd5711b --- /dev/null +++ b/Lang/Euphoria/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Empty-string b/Lang/Euphoria/Empty-string new file mode 120000 index 0000000000..cf9b7c1847 --- /dev/null +++ b/Lang/Euphoria/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Enforced-immutability b/Lang/Euphoria/Enforced-immutability new file mode 120000 index 0000000000..6d8348253d --- /dev/null +++ b/Lang/Euphoria/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Equilibrium-index b/Lang/Euphoria/Equilibrium-index new file mode 120000 index 0000000000..012c291c98 --- /dev/null +++ b/Lang/Euphoria/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Ethiopian-multiplication b/Lang/Euphoria/Ethiopian-multiplication new file mode 120000 index 0000000000..662f6d8b1e --- /dev/null +++ b/Lang/Euphoria/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Even-or-odd b/Lang/Euphoria/Even-or-odd new file mode 120000 index 0000000000..d30a6d6f70 --- /dev/null +++ b/Lang/Euphoria/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Evolutionary-algorithm b/Lang/Euphoria/Evolutionary-algorithm new file mode 120000 index 0000000000..908e698352 --- /dev/null +++ b/Lang/Euphoria/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Extreme-floating-point-values b/Lang/Euphoria/Extreme-floating-point-values new file mode 120000 index 0000000000..057b09da7a --- /dev/null +++ b/Lang/Euphoria/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/FizzBuzz b/Lang/Euphoria/FizzBuzz new file mode 120000 index 0000000000..95f595d020 --- /dev/null +++ b/Lang/Euphoria/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Infinity b/Lang/Euphoria/Infinity new file mode 120000 index 0000000000..07c52eab23 --- /dev/null +++ b/Lang/Euphoria/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Knuth-shuffle b/Lang/Euphoria/Knuth-shuffle new file mode 120000 index 0000000000..a8a415341a --- /dev/null +++ b/Lang/Euphoria/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Ordered-words b/Lang/Euphoria/Ordered-words new file mode 120000 index 0000000000..a824cd87d2 --- /dev/null +++ b/Lang/Euphoria/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Quine b/Lang/Euphoria/Quine new file mode 120000 index 0000000000..2c95ebcf43 --- /dev/null +++ b/Lang/Euphoria/Quine @@ -0,0 +1 @@ +../../Task/Quine/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Search-a-list b/Lang/Euphoria/Search-a-list new file mode 120000 index 0000000000..8f851166a7 --- /dev/null +++ b/Lang/Euphoria/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Euphoria \ No newline at end of file diff --git a/Lang/Excel/0DESCRIPTION b/Lang/Excel/0DESCRIPTION new file mode 100644 index 0000000000..60e1826780 --- /dev/null +++ b/Lang/Excel/0DESCRIPTION @@ -0,0 +1,2 @@ +{{stub}}{{language}} +'''Excel''' isn't actual language, but certain problems can be solved using it. \ No newline at end of file diff --git a/Lang/Forth/Call-a-foreign-language-function b/Lang/Forth/Call-a-foreign-language-function new file mode 120000 index 0000000000..8ad4c29318 --- /dev/null +++ b/Lang/Forth/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Forth \ No newline at end of file diff --git a/Lang/Forth/Call-an-object-method b/Lang/Forth/Call-an-object-method new file mode 120000 index 0000000000..cfb2e97898 --- /dev/null +++ b/Lang/Forth/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/Forth \ No newline at end of file diff --git a/Lang/Forth/Character-codes b/Lang/Forth/Character-codes new file mode 120000 index 0000000000..50bfe4057f --- /dev/null +++ b/Lang/Forth/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Forth \ No newline at end of file diff --git a/Lang/Forth/Character-matching b/Lang/Forth/Character-matching new file mode 120000 index 0000000000..67aa24411a --- /dev/null +++ b/Lang/Forth/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Forth \ No newline at end of file diff --git a/Lang/Forth/Command-line-arguments b/Lang/Forth/Command-line-arguments new file mode 120000 index 0000000000..f76b2ccef2 --- /dev/null +++ b/Lang/Forth/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Forth \ No newline at end of file diff --git a/Lang/Forth/Compile-time-calculation b/Lang/Forth/Compile-time-calculation new file mode 120000 index 0000000000..f9e697b08f --- /dev/null +++ b/Lang/Forth/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Forth \ No newline at end of file diff --git a/Lang/Forth/Compound-data-type b/Lang/Forth/Compound-data-type new file mode 120000 index 0000000000..438eb5fdd8 --- /dev/null +++ b/Lang/Forth/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Forth \ No newline at end of file diff --git a/Lang/Forth/Concurrent-computing b/Lang/Forth/Concurrent-computing new file mode 120000 index 0000000000..10d1bb2b11 --- /dev/null +++ b/Lang/Forth/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Forth \ No newline at end of file diff --git a/Lang/Forth/Conditional-structures b/Lang/Forth/Conditional-structures new file mode 120000 index 0000000000..32b6660d8a --- /dev/null +++ b/Lang/Forth/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Forth \ No newline at end of file diff --git a/Lang/Forth/Continued-fraction b/Lang/Forth/Continued-fraction new file mode 120000 index 0000000000..babccf78a3 --- /dev/null +++ b/Lang/Forth/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Forth \ No newline at end of file diff --git a/Lang/Forth/Conways-Game-of-Life b/Lang/Forth/Conways-Game-of-Life new file mode 120000 index 0000000000..324276411f --- /dev/null +++ b/Lang/Forth/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Forth \ No newline at end of file diff --git a/Lang/Forth/Count-in-factors b/Lang/Forth/Count-in-factors new file mode 120000 index 0000000000..c2442d4645 --- /dev/null +++ b/Lang/Forth/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Forth \ No newline at end of file diff --git a/Lang/Forth/Count-in-octal b/Lang/Forth/Count-in-octal new file mode 120000 index 0000000000..8e9df37e52 --- /dev/null +++ b/Lang/Forth/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Forth \ No newline at end of file diff --git a/Lang/Forth/Count-occurrences-of-a-substring b/Lang/Forth/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..ad3616d30a --- /dev/null +++ b/Lang/Forth/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Forth \ No newline at end of file diff --git a/Lang/Forth/Count-the-coins b/Lang/Forth/Count-the-coins new file mode 120000 index 0000000000..a3f8c2852f --- /dev/null +++ b/Lang/Forth/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Forth \ No newline at end of file diff --git a/Lang/Forth/Create-a-file b/Lang/Forth/Create-a-file new file mode 120000 index 0000000000..7898d1efd2 --- /dev/null +++ b/Lang/Forth/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Forth \ No newline at end of file diff --git a/Lang/Forth/Create-a-two-dimensional-array-at-runtime b/Lang/Forth/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..5b0c8add18 --- /dev/null +++ b/Lang/Forth/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Forth \ No newline at end of file diff --git a/Lang/Forth/Create-an-object-at-a-given-address b/Lang/Forth/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..87aacaaf7d --- /dev/null +++ b/Lang/Forth/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/Forth \ No newline at end of file diff --git a/Lang/Forth/Date-format b/Lang/Forth/Date-format new file mode 120000 index 0000000000..2af2a3ee5a --- /dev/null +++ b/Lang/Forth/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Forth \ No newline at end of file diff --git a/Lang/Forth/Day-of-the-week b/Lang/Forth/Day-of-the-week new file mode 120000 index 0000000000..98ee8fee0f --- /dev/null +++ b/Lang/Forth/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Forth \ No newline at end of file diff --git a/Lang/Forth/Dinesmans-multiple-dwelling-problem b/Lang/Forth/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..4d2a7ead78 --- /dev/null +++ b/Lang/Forth/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Forth \ No newline at end of file diff --git a/Lang/Forth/Dot-product b/Lang/Forth/Dot-product new file mode 120000 index 0000000000..e3cddeaab6 --- /dev/null +++ b/Lang/Forth/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Forth \ No newline at end of file diff --git a/Lang/Forth/Dynamic-variable-names b/Lang/Forth/Dynamic-variable-names new file mode 120000 index 0000000000..5933c546c3 --- /dev/null +++ b/Lang/Forth/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Forth \ No newline at end of file diff --git a/Lang/Forth/Echo-server b/Lang/Forth/Echo-server new file mode 120000 index 0000000000..e902af4b6c --- /dev/null +++ b/Lang/Forth/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Forth \ No newline at end of file diff --git a/Lang/Forth/Empty-program b/Lang/Forth/Empty-program new file mode 120000 index 0000000000..33421873fd --- /dev/null +++ b/Lang/Forth/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Forth \ No newline at end of file diff --git a/Lang/Forth/Empty-string b/Lang/Forth/Empty-string new file mode 120000 index 0000000000..97b86dac1d --- /dev/null +++ b/Lang/Forth/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Forth \ No newline at end of file diff --git a/Lang/Forth/Enumerations b/Lang/Forth/Enumerations new file mode 120000 index 0000000000..f4bd439a5b --- /dev/null +++ b/Lang/Forth/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Forth \ No newline at end of file diff --git a/Lang/Forth/Ethiopian-multiplication b/Lang/Forth/Ethiopian-multiplication new file mode 120000 index 0000000000..0d54dcfda5 --- /dev/null +++ b/Lang/Forth/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Forth \ No newline at end of file diff --git a/Lang/Forth/Evaluate-binomial-coefficients b/Lang/Forth/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..5b74ea40ce --- /dev/null +++ b/Lang/Forth/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Forth \ No newline at end of file diff --git a/Lang/Forth/Even-or-odd b/Lang/Forth/Even-or-odd new file mode 120000 index 0000000000..30b95645c2 --- /dev/null +++ b/Lang/Forth/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Forth \ No newline at end of file diff --git a/Lang/Forth/Evolutionary-algorithm b/Lang/Forth/Evolutionary-algorithm new file mode 120000 index 0000000000..17489f0ea4 --- /dev/null +++ b/Lang/Forth/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Forth \ No newline at end of file diff --git a/Lang/Forth/Exceptions b/Lang/Forth/Exceptions new file mode 120000 index 0000000000..df6f00f4bf --- /dev/null +++ b/Lang/Forth/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Forth \ No newline at end of file diff --git a/Lang/Forth/Execute-HQ9+ b/Lang/Forth/Execute-HQ9+ new file mode 120000 index 0000000000..8187c3bd4d --- /dev/null +++ b/Lang/Forth/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/Forth \ No newline at end of file diff --git a/Lang/Forth/Execute-a-system-command b/Lang/Forth/Execute-a-system-command new file mode 120000 index 0000000000..316bc59780 --- /dev/null +++ b/Lang/Forth/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Forth \ No newline at end of file diff --git a/Lang/Forth/Exponentiation-operator b/Lang/Forth/Exponentiation-operator new file mode 120000 index 0000000000..21e0952dfb --- /dev/null +++ b/Lang/Forth/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Forth \ No newline at end of file diff --git a/Lang/Forth/Extend-your-language b/Lang/Forth/Extend-your-language new file mode 120000 index 0000000000..3ee4ec33dd --- /dev/null +++ b/Lang/Forth/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Forth \ No newline at end of file diff --git a/Lang/Forth/Extreme-floating-point-values b/Lang/Forth/Extreme-floating-point-values new file mode 120000 index 0000000000..bae70c7bf9 --- /dev/null +++ b/Lang/Forth/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Forth \ No newline at end of file diff --git a/Lang/Fortran/Case-sensitivity-of-identifiers b/Lang/Fortran/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..13cf622a69 --- /dev/null +++ b/Lang/Fortran/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Character-codes b/Lang/Fortran/Character-codes new file mode 120000 index 0000000000..7248d47d4b --- /dev/null +++ b/Lang/Fortran/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Combinations b/Lang/Fortran/Combinations new file mode 120000 index 0000000000..81c81e6c11 --- /dev/null +++ b/Lang/Fortran/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Combinations-with-repetitions b/Lang/Fortran/Combinations-with-repetitions new file mode 120000 index 0000000000..28c8a5733c --- /dev/null +++ b/Lang/Fortran/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Command-line-arguments b/Lang/Fortran/Command-line-arguments new file mode 120000 index 0000000000..bea14d060c --- /dev/null +++ b/Lang/Fortran/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Compile-time-calculation b/Lang/Fortran/Compile-time-calculation new file mode 120000 index 0000000000..9643b651f6 --- /dev/null +++ b/Lang/Fortran/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Compound-data-type b/Lang/Fortran/Compound-data-type new file mode 120000 index 0000000000..ac839ca9fc --- /dev/null +++ b/Lang/Fortran/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Concurrent-computing b/Lang/Fortran/Concurrent-computing new file mode 120000 index 0000000000..fadc1c9824 --- /dev/null +++ b/Lang/Fortran/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Conditional-structures b/Lang/Fortran/Conditional-structures new file mode 120000 index 0000000000..a351aa294d --- /dev/null +++ b/Lang/Fortran/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Constrained-random-points-on-a-circle b/Lang/Fortran/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..8f936c390d --- /dev/null +++ b/Lang/Fortran/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Conways-Game-of-Life b/Lang/Fortran/Conways-Game-of-Life new file mode 120000 index 0000000000..0bc7fd1081 --- /dev/null +++ b/Lang/Fortran/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Count-in-octal b/Lang/Fortran/Count-in-octal new file mode 120000 index 0000000000..6f2d172026 --- /dev/null +++ b/Lang/Fortran/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Count-occurrences-of-a-substring b/Lang/Fortran/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..35f71fe131 --- /dev/null +++ b/Lang/Fortran/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Create-a-file b/Lang/Fortran/Create-a-file new file mode 120000 index 0000000000..fd3d0e5614 --- /dev/null +++ b/Lang/Fortran/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Create-a-two-dimensional-array-at-runtime b/Lang/Fortran/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..e4065922d4 --- /dev/null +++ b/Lang/Fortran/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Date-format b/Lang/Fortran/Date-format new file mode 120000 index 0000000000..82ac731f4f --- /dev/null +++ b/Lang/Fortran/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Day-of-the-week b/Lang/Fortran/Day-of-the-week new file mode 120000 index 0000000000..c3ca1fb5ee --- /dev/null +++ b/Lang/Fortran/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Deconvolution-1D b/Lang/Fortran/Deconvolution-1D new file mode 120000 index 0000000000..09e7162bc8 --- /dev/null +++ b/Lang/Fortran/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Dot-product b/Lang/Fortran/Dot-product new file mode 120000 index 0000000000..9a87fa57f9 --- /dev/null +++ b/Lang/Fortran/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Doubly-linked-list-Definition b/Lang/Fortran/Doubly-linked-list-Definition new file mode 120000 index 0000000000..350e12073f --- /dev/null +++ b/Lang/Fortran/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Doubly-linked-list-Element-definition b/Lang/Fortran/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..c3348999c4 --- /dev/null +++ b/Lang/Fortran/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Doubly-linked-list-Element-insertion b/Lang/Fortran/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..c371d3d0ba --- /dev/null +++ b/Lang/Fortran/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Doubly-linked-list-Traversal b/Lang/Fortran/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..1053e2832b --- /dev/null +++ b/Lang/Fortran/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Empty-program b/Lang/Fortran/Empty-program new file mode 120000 index 0000000000..6cacb303e3 --- /dev/null +++ b/Lang/Fortran/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Enumerations b/Lang/Fortran/Enumerations new file mode 120000 index 0000000000..fde849b4ca --- /dev/null +++ b/Lang/Fortran/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Equilibrium-index b/Lang/Fortran/Equilibrium-index new file mode 120000 index 0000000000..2e44d6021b --- /dev/null +++ b/Lang/Fortran/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Ethiopian-multiplication b/Lang/Fortran/Ethiopian-multiplication new file mode 120000 index 0000000000..ac37484ab9 --- /dev/null +++ b/Lang/Fortran/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Euler-method b/Lang/Fortran/Euler-method new file mode 120000 index 0000000000..8eecf694ab --- /dev/null +++ b/Lang/Fortran/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Evaluate-binomial-coefficients b/Lang/Fortran/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..79492675fd --- /dev/null +++ b/Lang/Fortran/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Evolutionary-algorithm b/Lang/Fortran/Evolutionary-algorithm new file mode 120000 index 0000000000..404b11d9a7 --- /dev/null +++ b/Lang/Fortran/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Execute-a-system-command b/Lang/Fortran/Execute-a-system-command new file mode 120000 index 0000000000..27d84c3bda --- /dev/null +++ b/Lang/Fortran/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Exponentiation-operator b/Lang/Fortran/Exponentiation-operator new file mode 120000 index 0000000000..b718964b99 --- /dev/null +++ b/Lang/Fortran/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Fortran \ No newline at end of file diff --git a/Lang/Go/CRC-32 b/Lang/Go/CRC-32 new file mode 120000 index 0000000000..1e60f02dd3 --- /dev/null +++ b/Lang/Go/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Go \ No newline at end of file diff --git a/Lang/Go/CSV-to-HTML-translation b/Lang/Go/CSV-to-HTML-translation new file mode 120000 index 0000000000..84d58e2c6b --- /dev/null +++ b/Lang/Go/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Go \ No newline at end of file diff --git a/Lang/Go/Call-a-foreign-language-function b/Lang/Go/Call-a-foreign-language-function new file mode 120000 index 0000000000..ddb772af06 --- /dev/null +++ b/Lang/Go/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Go \ No newline at end of file diff --git a/Lang/Go/Call-an-object-method b/Lang/Go/Call-an-object-method new file mode 120000 index 0000000000..1361a2a729 --- /dev/null +++ b/Lang/Go/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/Go \ No newline at end of file diff --git a/Lang/Go/Case-sensitivity-of-identifiers b/Lang/Go/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..de9440328b --- /dev/null +++ b/Lang/Go/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Go \ No newline at end of file diff --git a/Lang/Go/Character-codes b/Lang/Go/Character-codes new file mode 120000 index 0000000000..aead13192e --- /dev/null +++ b/Lang/Go/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Go \ No newline at end of file diff --git a/Lang/Go/Character-matching b/Lang/Go/Character-matching new file mode 120000 index 0000000000..52bbff82cc --- /dev/null +++ b/Lang/Go/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Go \ No newline at end of file diff --git a/Lang/Go/Chat-server b/Lang/Go/Chat-server new file mode 120000 index 0000000000..1c01d6bc16 --- /dev/null +++ b/Lang/Go/Chat-server @@ -0,0 +1 @@ +../../Task/Chat-server/Go \ No newline at end of file diff --git a/Lang/Go/Check-Machin-like-formulas b/Lang/Go/Check-Machin-like-formulas new file mode 120000 index 0000000000..a306f238b4 --- /dev/null +++ b/Lang/Go/Check-Machin-like-formulas @@ -0,0 +1 @@ +../../Task/Check-Machin-like-formulas/Go \ No newline at end of file diff --git a/Lang/Go/Cholesky-decomposition b/Lang/Go/Cholesky-decomposition new file mode 120000 index 0000000000..6a2bcff9d5 --- /dev/null +++ b/Lang/Go/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Go \ No newline at end of file diff --git a/Lang/Go/Combinations b/Lang/Go/Combinations new file mode 120000 index 0000000000..f13b2f084a --- /dev/null +++ b/Lang/Go/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Go \ No newline at end of file diff --git a/Lang/Go/Combinations-with-repetitions b/Lang/Go/Combinations-with-repetitions new file mode 120000 index 0000000000..d2b1e58ee3 --- /dev/null +++ b/Lang/Go/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Go \ No newline at end of file diff --git a/Lang/Go/Command-line-arguments b/Lang/Go/Command-line-arguments new file mode 120000 index 0000000000..7722a8693e --- /dev/null +++ b/Lang/Go/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Go \ No newline at end of file diff --git a/Lang/Go/Compile-time-calculation b/Lang/Go/Compile-time-calculation new file mode 120000 index 0000000000..bc1652a5e5 --- /dev/null +++ b/Lang/Go/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Go \ No newline at end of file diff --git a/Lang/Go/Compound-data-type b/Lang/Go/Compound-data-type new file mode 120000 index 0000000000..3441a4cd22 --- /dev/null +++ b/Lang/Go/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Go \ No newline at end of file diff --git a/Lang/Go/Concurrent-computing b/Lang/Go/Concurrent-computing new file mode 120000 index 0000000000..4863cd35a6 --- /dev/null +++ b/Lang/Go/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Go \ No newline at end of file diff --git a/Lang/Go/Conditional-structures b/Lang/Go/Conditional-structures new file mode 120000 index 0000000000..522e889257 --- /dev/null +++ b/Lang/Go/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Go \ No newline at end of file diff --git a/Lang/Go/Constrained-genericity b/Lang/Go/Constrained-genericity new file mode 120000 index 0000000000..b533c52d94 --- /dev/null +++ b/Lang/Go/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/Go \ No newline at end of file diff --git a/Lang/Go/Constrained-random-points-on-a-circle b/Lang/Go/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..d47fc653f6 --- /dev/null +++ b/Lang/Go/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Go \ No newline at end of file diff --git a/Lang/Go/Continued-fraction b/Lang/Go/Continued-fraction new file mode 120000 index 0000000000..2454f94a40 --- /dev/null +++ b/Lang/Go/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Go \ No newline at end of file diff --git a/Lang/Go/Conways-Game-of-Life b/Lang/Go/Conways-Game-of-Life new file mode 120000 index 0000000000..aacacd439b --- /dev/null +++ b/Lang/Go/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Go \ No newline at end of file diff --git a/Lang/Go/Count-in-factors b/Lang/Go/Count-in-factors new file mode 120000 index 0000000000..95bcfa56a6 --- /dev/null +++ b/Lang/Go/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Go \ No newline at end of file diff --git a/Lang/Go/Count-in-octal b/Lang/Go/Count-in-octal new file mode 120000 index 0000000000..99ef25800c --- /dev/null +++ b/Lang/Go/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Go \ No newline at end of file diff --git a/Lang/Go/Count-occurrences-of-a-substring b/Lang/Go/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..0946ce2548 --- /dev/null +++ b/Lang/Go/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Go \ No newline at end of file diff --git a/Lang/Go/Count-the-coins b/Lang/Go/Count-the-coins new file mode 120000 index 0000000000..b0e6b9817c --- /dev/null +++ b/Lang/Go/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Go \ No newline at end of file diff --git a/Lang/Go/Create-a-file b/Lang/Go/Create-a-file new file mode 120000 index 0000000000..2f514fd33d --- /dev/null +++ b/Lang/Go/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Go \ No newline at end of file diff --git a/Lang/Go/Create-a-two-dimensional-array-at-runtime b/Lang/Go/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..95a2de315c --- /dev/null +++ b/Lang/Go/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Go \ No newline at end of file diff --git a/Lang/Go/Create-an-HTML-table b/Lang/Go/Create-an-HTML-table new file mode 120000 index 0000000000..f80beb1e8f --- /dev/null +++ b/Lang/Go/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Go \ No newline at end of file diff --git a/Lang/Go/Create-an-object-at-a-given-address b/Lang/Go/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..493b67aa0e --- /dev/null +++ b/Lang/Go/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/Go \ No newline at end of file diff --git a/Lang/Go/DNS-query b/Lang/Go/DNS-query new file mode 120000 index 0000000000..500748254c --- /dev/null +++ b/Lang/Go/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/Go \ No newline at end of file diff --git a/Lang/Go/Date-format b/Lang/Go/Date-format new file mode 120000 index 0000000000..ce1596f7ee --- /dev/null +++ b/Lang/Go/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Go \ No newline at end of file diff --git a/Lang/Go/Date-manipulation b/Lang/Go/Date-manipulation new file mode 120000 index 0000000000..ac505658ef --- /dev/null +++ b/Lang/Go/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Go \ No newline at end of file diff --git a/Lang/Go/Day-of-the-week b/Lang/Go/Day-of-the-week new file mode 120000 index 0000000000..adc51d975c --- /dev/null +++ b/Lang/Go/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Go \ No newline at end of file diff --git a/Lang/Go/Deal-cards-for-FreeCell b/Lang/Go/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..18117489bd --- /dev/null +++ b/Lang/Go/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/Go \ No newline at end of file diff --git a/Lang/Go/Deconvolution-1D b/Lang/Go/Deconvolution-1D new file mode 120000 index 0000000000..6151271b5c --- /dev/null +++ b/Lang/Go/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Go \ No newline at end of file diff --git a/Lang/Go/Deepcopy b/Lang/Go/Deepcopy new file mode 120000 index 0000000000..a7a6c1ed9e --- /dev/null +++ b/Lang/Go/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/Go \ No newline at end of file diff --git a/Lang/Go/Determine-if-only-one-instance-is-running b/Lang/Go/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..982f5c47df --- /dev/null +++ b/Lang/Go/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Go \ No newline at end of file diff --git a/Lang/Go/Digital-root b/Lang/Go/Digital-root new file mode 120000 index 0000000000..26d2af3656 --- /dev/null +++ b/Lang/Go/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/Go \ No newline at end of file diff --git a/Lang/Go/Dining-philosophers b/Lang/Go/Dining-philosophers new file mode 120000 index 0000000000..d79e0bae79 --- /dev/null +++ b/Lang/Go/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Go \ No newline at end of file diff --git a/Lang/Go/Discordian-date b/Lang/Go/Discordian-date new file mode 120000 index 0000000000..6f37490765 --- /dev/null +++ b/Lang/Go/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/Go \ No newline at end of file diff --git a/Lang/Go/Distributed-programming b/Lang/Go/Distributed-programming new file mode 120000 index 0000000000..00c5affefe --- /dev/null +++ b/Lang/Go/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/Go \ No newline at end of file diff --git a/Lang/Go/Documentation b/Lang/Go/Documentation new file mode 120000 index 0000000000..2e39f80f83 --- /dev/null +++ b/Lang/Go/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Go \ No newline at end of file diff --git a/Lang/Go/Dot-product b/Lang/Go/Dot-product new file mode 120000 index 0000000000..bae8f9092f --- /dev/null +++ b/Lang/Go/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Go \ No newline at end of file diff --git a/Lang/Go/Doubly-linked-list-Definition b/Lang/Go/Doubly-linked-list-Definition new file mode 120000 index 0000000000..42c9da28a8 --- /dev/null +++ b/Lang/Go/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/Go \ No newline at end of file diff --git a/Lang/Go/Doubly-linked-list-Element-definition b/Lang/Go/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..851f04b046 --- /dev/null +++ b/Lang/Go/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Go \ No newline at end of file diff --git a/Lang/Go/Doubly-linked-list-Element-insertion b/Lang/Go/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..d8991349c1 --- /dev/null +++ b/Lang/Go/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/Go \ No newline at end of file diff --git a/Lang/Go/Doubly-linked-list-Traversal b/Lang/Go/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..974e2341e7 --- /dev/null +++ b/Lang/Go/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Go \ No newline at end of file diff --git a/Lang/Go/Draw-a-cuboid b/Lang/Go/Draw-a-cuboid new file mode 120000 index 0000000000..a4a1556c9c --- /dev/null +++ b/Lang/Go/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Go \ No newline at end of file diff --git a/Lang/Go/Draw-a-sphere b/Lang/Go/Draw-a-sphere new file mode 120000 index 0000000000..ad3c7928d3 --- /dev/null +++ b/Lang/Go/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Go \ No newline at end of file diff --git a/Lang/Go/Dutch-national-flag-problem b/Lang/Go/Dutch-national-flag-problem new file mode 120000 index 0000000000..22ee4e067b --- /dev/null +++ b/Lang/Go/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Go \ No newline at end of file diff --git a/Lang/Go/Echo-server b/Lang/Go/Echo-server new file mode 120000 index 0000000000..4a74cd34e8 --- /dev/null +++ b/Lang/Go/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Go \ No newline at end of file diff --git a/Lang/Go/Element-wise-operations b/Lang/Go/Element-wise-operations new file mode 120000 index 0000000000..ef3fd0549a --- /dev/null +++ b/Lang/Go/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/Go \ No newline at end of file diff --git a/Lang/Go/Empty-directory b/Lang/Go/Empty-directory new file mode 120000 index 0000000000..4202e9e567 --- /dev/null +++ b/Lang/Go/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Go \ No newline at end of file diff --git a/Lang/Go/Empty-program b/Lang/Go/Empty-program new file mode 120000 index 0000000000..2e150edf08 --- /dev/null +++ b/Lang/Go/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Go \ No newline at end of file diff --git a/Lang/Go/Empty-string b/Lang/Go/Empty-string new file mode 120000 index 0000000000..aa0f65bf20 --- /dev/null +++ b/Lang/Go/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Go \ No newline at end of file diff --git a/Lang/Go/Enforced-immutability b/Lang/Go/Enforced-immutability new file mode 120000 index 0000000000..00c8cc371b --- /dev/null +++ b/Lang/Go/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Go \ No newline at end of file diff --git a/Lang/Go/Enumerations b/Lang/Go/Enumerations new file mode 120000 index 0000000000..63d9d516fe --- /dev/null +++ b/Lang/Go/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Go \ No newline at end of file diff --git a/Lang/Go/Equilibrium-index b/Lang/Go/Equilibrium-index new file mode 120000 index 0000000000..be067f0719 --- /dev/null +++ b/Lang/Go/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Go \ No newline at end of file diff --git a/Lang/Go/Ethiopian-multiplication b/Lang/Go/Ethiopian-multiplication new file mode 120000 index 0000000000..523e70042e --- /dev/null +++ b/Lang/Go/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Go \ No newline at end of file diff --git a/Lang/Go/Euler-method b/Lang/Go/Euler-method new file mode 120000 index 0000000000..acf0f2e6b0 --- /dev/null +++ b/Lang/Go/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Go \ No newline at end of file diff --git a/Lang/Go/Evaluate-binomial-coefficients b/Lang/Go/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..141fd70d4a --- /dev/null +++ b/Lang/Go/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Go \ No newline at end of file diff --git a/Lang/Go/Even-or-odd b/Lang/Go/Even-or-odd new file mode 120000 index 0000000000..5c1a934edd --- /dev/null +++ b/Lang/Go/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Go \ No newline at end of file diff --git a/Lang/Go/Events b/Lang/Go/Events new file mode 120000 index 0000000000..50526b47ec --- /dev/null +++ b/Lang/Go/Events @@ -0,0 +1 @@ +../../Task/Events/Go \ No newline at end of file diff --git a/Lang/Go/Evolutionary-algorithm b/Lang/Go/Evolutionary-algorithm new file mode 120000 index 0000000000..edc408818b --- /dev/null +++ b/Lang/Go/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Go \ No newline at end of file diff --git a/Lang/Go/Exceptions b/Lang/Go/Exceptions new file mode 120000 index 0000000000..3dc2d6c374 --- /dev/null +++ b/Lang/Go/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Go \ No newline at end of file diff --git a/Lang/Go/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Go/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..db12154d3e --- /dev/null +++ b/Lang/Go/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Go \ No newline at end of file diff --git a/Lang/Go/Execute-a-system-command b/Lang/Go/Execute-a-system-command new file mode 120000 index 0000000000..337bf5e487 --- /dev/null +++ b/Lang/Go/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Go \ No newline at end of file diff --git a/Lang/Go/Exponentiation-operator b/Lang/Go/Exponentiation-operator new file mode 120000 index 0000000000..db0c14ab2f --- /dev/null +++ b/Lang/Go/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Go \ No newline at end of file diff --git a/Lang/Go/Extreme-floating-point-values b/Lang/Go/Extreme-floating-point-values new file mode 120000 index 0000000000..4b8db0f680 --- /dev/null +++ b/Lang/Go/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Go \ No newline at end of file diff --git a/Lang/Haskell/CSV-to-HTML-translation b/Lang/Haskell/CSV-to-HTML-translation new file mode 120000 index 0000000000..6c67531477 --- /dev/null +++ b/Lang/Haskell/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Call-a-foreign-language-function b/Lang/Haskell/Call-a-foreign-language-function new file mode 120000 index 0000000000..56ba651a53 --- /dev/null +++ b/Lang/Haskell/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Carmichael-3-strong-pseudoprimes b/Lang/Haskell/Carmichael-3-strong-pseudoprimes new file mode 120000 index 0000000000..aac9801a94 --- /dev/null +++ b/Lang/Haskell/Carmichael-3-strong-pseudoprimes @@ -0,0 +1 @@ +../../Task/Carmichael-3-strong-pseudoprimes/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Case-sensitivity-of-identifiers b/Lang/Haskell/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..02ae95c77f --- /dev/null +++ b/Lang/Haskell/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Character-codes b/Lang/Haskell/Character-codes new file mode 120000 index 0000000000..17f88dcc2c --- /dev/null +++ b/Lang/Haskell/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Character-matching b/Lang/Haskell/Character-matching new file mode 120000 index 0000000000..e322b4e9f9 --- /dev/null +++ b/Lang/Haskell/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Check-Machin-like-formulas b/Lang/Haskell/Check-Machin-like-formulas new file mode 120000 index 0000000000..4af3ab8427 --- /dev/null +++ b/Lang/Haskell/Check-Machin-like-formulas @@ -0,0 +1 @@ +../../Task/Check-Machin-like-formulas/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Cholesky-decomposition b/Lang/Haskell/Cholesky-decomposition new file mode 120000 index 0000000000..6e179948da --- /dev/null +++ b/Lang/Haskell/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Combinations b/Lang/Haskell/Combinations new file mode 120000 index 0000000000..da3df46788 --- /dev/null +++ b/Lang/Haskell/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Combinations-with-repetitions b/Lang/Haskell/Combinations-with-repetitions new file mode 120000 index 0000000000..c337bda766 --- /dev/null +++ b/Lang/Haskell/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Command-line-arguments b/Lang/Haskell/Command-line-arguments new file mode 120000 index 0000000000..25ce61a3d1 --- /dev/null +++ b/Lang/Haskell/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Compile-time-calculation b/Lang/Haskell/Compile-time-calculation new file mode 120000 index 0000000000..5b6496fa65 --- /dev/null +++ b/Lang/Haskell/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Compound-data-type b/Lang/Haskell/Compound-data-type new file mode 120000 index 0000000000..f1178a195f --- /dev/null +++ b/Lang/Haskell/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Concurrent-computing b/Lang/Haskell/Concurrent-computing new file mode 120000 index 0000000000..d29e93ae51 --- /dev/null +++ b/Lang/Haskell/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Conditional-structures b/Lang/Haskell/Conditional-structures new file mode 120000 index 0000000000..972dbe9294 --- /dev/null +++ b/Lang/Haskell/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Constrained-genericity b/Lang/Haskell/Constrained-genericity new file mode 120000 index 0000000000..795e6687c7 --- /dev/null +++ b/Lang/Haskell/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Constrained-random-points-on-a-circle b/Lang/Haskell/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..5f5aee99e2 --- /dev/null +++ b/Lang/Haskell/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Continued-fraction b/Lang/Haskell/Continued-fraction new file mode 120000 index 0000000000..0e7c8317cb --- /dev/null +++ b/Lang/Haskell/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Continued-fraction-Arithmetic-Construct-from-rational-number b/Lang/Haskell/Continued-fraction-Arithmetic-Construct-from-rational-number new file mode 120000 index 0000000000..5dacadac93 --- /dev/null +++ b/Lang/Haskell/Continued-fraction-Arithmetic-Construct-from-rational-number @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Conways-Game-of-Life b/Lang/Haskell/Conways-Game-of-Life new file mode 120000 index 0000000000..975c1dc976 --- /dev/null +++ b/Lang/Haskell/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Count-in-factors b/Lang/Haskell/Count-in-factors new file mode 120000 index 0000000000..430e72e037 --- /dev/null +++ b/Lang/Haskell/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Count-in-octal b/Lang/Haskell/Count-in-octal new file mode 120000 index 0000000000..ca1b1e8063 --- /dev/null +++ b/Lang/Haskell/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Count-occurrences-of-a-substring b/Lang/Haskell/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..124f91460d --- /dev/null +++ b/Lang/Haskell/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Count-the-coins b/Lang/Haskell/Count-the-coins new file mode 120000 index 0000000000..8897ebb8e0 --- /dev/null +++ b/Lang/Haskell/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Create-a-file b/Lang/Haskell/Create-a-file new file mode 120000 index 0000000000..86625f0989 --- /dev/null +++ b/Lang/Haskell/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Create-a-two-dimensional-array-at-runtime b/Lang/Haskell/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..e2febf931d --- /dev/null +++ b/Lang/Haskell/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Create-an-HTML-table b/Lang/Haskell/Create-an-HTML-table new file mode 120000 index 0000000000..256e935664 --- /dev/null +++ b/Lang/Haskell/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Cut-a-rectangle b/Lang/Haskell/Cut-a-rectangle new file mode 120000 index 0000000000..b29a273787 --- /dev/null +++ b/Lang/Haskell/Cut-a-rectangle @@ -0,0 +1 @@ +../../Task/Cut-a-rectangle/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Date-format b/Lang/Haskell/Date-format new file mode 120000 index 0000000000..2b4ea617e3 --- /dev/null +++ b/Lang/Haskell/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Date-manipulation b/Lang/Haskell/Date-manipulation new file mode 120000 index 0000000000..94bcde669a --- /dev/null +++ b/Lang/Haskell/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Day-of-the-week b/Lang/Haskell/Day-of-the-week new file mode 120000 index 0000000000..7e8795d628 --- /dev/null +++ b/Lang/Haskell/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Deal-cards-for-FreeCell b/Lang/Haskell/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..dcfb533eb3 --- /dev/null +++ b/Lang/Haskell/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Deconvolution-1D b/Lang/Haskell/Deconvolution-1D new file mode 120000 index 0000000000..fe592d5ce2 --- /dev/null +++ b/Lang/Haskell/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Determine-if-only-one-instance-is-running b/Lang/Haskell/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..0d1335d8b0 --- /dev/null +++ b/Lang/Haskell/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Digital-root b/Lang/Haskell/Digital-root new file mode 120000 index 0000000000..474291dba9 --- /dev/null +++ b/Lang/Haskell/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Dinesmans-multiple-dwelling-problem b/Lang/Haskell/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..024b7ecd9c --- /dev/null +++ b/Lang/Haskell/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Dining-philosophers b/Lang/Haskell/Dining-philosophers new file mode 120000 index 0000000000..328fc2834a --- /dev/null +++ b/Lang/Haskell/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Discordian-date b/Lang/Haskell/Discordian-date new file mode 120000 index 0000000000..21f31c62f5 --- /dev/null +++ b/Lang/Haskell/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Documentation b/Lang/Haskell/Documentation new file mode 120000 index 0000000000..57a7e9243f --- /dev/null +++ b/Lang/Haskell/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Dot-product b/Lang/Haskell/Dot-product new file mode 120000 index 0000000000..9f2cdeb55a --- /dev/null +++ b/Lang/Haskell/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Doubly-linked-list-Definition b/Lang/Haskell/Doubly-linked-list-Definition new file mode 120000 index 0000000000..aa3e4ac148 --- /dev/null +++ b/Lang/Haskell/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Doubly-linked-list-Element-definition b/Lang/Haskell/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..c867228574 --- /dev/null +++ b/Lang/Haskell/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Doubly-linked-list-Element-insertion b/Lang/Haskell/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..26357464af --- /dev/null +++ b/Lang/Haskell/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Doubly-linked-list-Traversal b/Lang/Haskell/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..ed5334c0d5 --- /dev/null +++ b/Lang/Haskell/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Draw-a-cuboid b/Lang/Haskell/Draw-a-cuboid new file mode 120000 index 0000000000..d5272a3844 --- /dev/null +++ b/Lang/Haskell/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Draw-a-sphere b/Lang/Haskell/Draw-a-sphere new file mode 120000 index 0000000000..9cf0c993af --- /dev/null +++ b/Lang/Haskell/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Dutch-national-flag-problem b/Lang/Haskell/Dutch-national-flag-problem new file mode 120000 index 0000000000..7bb9b9fb68 --- /dev/null +++ b/Lang/Haskell/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Dynamic-variable-names b/Lang/Haskell/Dynamic-variable-names new file mode 120000 index 0000000000..58d028eaaa --- /dev/null +++ b/Lang/Haskell/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Echo-server b/Lang/Haskell/Echo-server new file mode 120000 index 0000000000..fc94c41235 --- /dev/null +++ b/Lang/Haskell/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Empty-directory b/Lang/Haskell/Empty-directory new file mode 120000 index 0000000000..bdfce6acdf --- /dev/null +++ b/Lang/Haskell/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Empty-program b/Lang/Haskell/Empty-program new file mode 120000 index 0000000000..db133520ff --- /dev/null +++ b/Lang/Haskell/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Empty-string b/Lang/Haskell/Empty-string new file mode 120000 index 0000000000..5ea61b5399 --- /dev/null +++ b/Lang/Haskell/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Enforced-immutability b/Lang/Haskell/Enforced-immutability new file mode 120000 index 0000000000..330f8e56ce --- /dev/null +++ b/Lang/Haskell/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Enumerations b/Lang/Haskell/Enumerations new file mode 120000 index 0000000000..471be268c0 --- /dev/null +++ b/Lang/Haskell/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Equilibrium-index b/Lang/Haskell/Equilibrium-index new file mode 120000 index 0000000000..65289cb522 --- /dev/null +++ b/Lang/Haskell/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Ethiopian-multiplication b/Lang/Haskell/Ethiopian-multiplication new file mode 120000 index 0000000000..946cd32a5d --- /dev/null +++ b/Lang/Haskell/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Euler-method b/Lang/Haskell/Euler-method new file mode 120000 index 0000000000..ea1d9f8526 --- /dev/null +++ b/Lang/Haskell/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Evaluate-binomial-coefficients b/Lang/Haskell/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..54aff0ddfc --- /dev/null +++ b/Lang/Haskell/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Even-or-odd b/Lang/Haskell/Even-or-odd new file mode 120000 index 0000000000..4507393514 --- /dev/null +++ b/Lang/Haskell/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Events b/Lang/Haskell/Events new file mode 120000 index 0000000000..f0e576b7be --- /dev/null +++ b/Lang/Haskell/Events @@ -0,0 +1 @@ +../../Task/Events/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Evolutionary-algorithm b/Lang/Haskell/Evolutionary-algorithm new file mode 120000 index 0000000000..42f3d259ea --- /dev/null +++ b/Lang/Haskell/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Exceptions b/Lang/Haskell/Exceptions new file mode 120000 index 0000000000..bfc43e2ced --- /dev/null +++ b/Lang/Haskell/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Haskell/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..8229e6f4ce --- /dev/null +++ b/Lang/Haskell/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Execute-a-system-command b/Lang/Haskell/Execute-a-system-command new file mode 120000 index 0000000000..82c2f311e7 --- /dev/null +++ b/Lang/Haskell/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Exponentiation-operator b/Lang/Haskell/Exponentiation-operator new file mode 120000 index 0000000000..6bfc572d2f --- /dev/null +++ b/Lang/Haskell/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Extend-your-language b/Lang/Haskell/Extend-your-language new file mode 120000 index 0000000000..414d5373de --- /dev/null +++ b/Lang/Haskell/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Haskell \ No newline at end of file diff --git a/Lang/Java/CRC-32 b/Lang/Java/CRC-32 new file mode 120000 index 0000000000..6bf9905d02 --- /dev/null +++ b/Lang/Java/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Java \ No newline at end of file diff --git a/Lang/Java/CSV-to-HTML-translation b/Lang/Java/CSV-to-HTML-translation new file mode 120000 index 0000000000..804fe6c10d --- /dev/null +++ b/Lang/Java/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Java \ No newline at end of file diff --git a/Lang/Java/Call-a-foreign-language-function b/Lang/Java/Call-a-foreign-language-function new file mode 120000 index 0000000000..bf16cccee3 --- /dev/null +++ b/Lang/Java/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Java \ No newline at end of file diff --git a/Lang/Java/Call-a-function-in-a-shared-library b/Lang/Java/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..5c8b413eda --- /dev/null +++ b/Lang/Java/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Java \ No newline at end of file diff --git a/Lang/Java/Call-an-object-method b/Lang/Java/Call-an-object-method new file mode 120000 index 0000000000..81339becf6 --- /dev/null +++ b/Lang/Java/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/Java \ No newline at end of file diff --git a/Lang/Java/Case-sensitivity-of-identifiers b/Lang/Java/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..02a73602c6 --- /dev/null +++ b/Lang/Java/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Java \ No newline at end of file diff --git a/Lang/Java/Character-codes b/Lang/Java/Character-codes new file mode 120000 index 0000000000..7b6d1a7c38 --- /dev/null +++ b/Lang/Java/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Java \ No newline at end of file diff --git a/Lang/Java/Character-matching b/Lang/Java/Character-matching new file mode 120000 index 0000000000..6c0faea249 --- /dev/null +++ b/Lang/Java/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Java \ No newline at end of file diff --git a/Lang/Java/Chat-server b/Lang/Java/Chat-server new file mode 120000 index 0000000000..ad26d3a786 --- /dev/null +++ b/Lang/Java/Chat-server @@ -0,0 +1 @@ +../../Task/Chat-server/Java \ No newline at end of file diff --git a/Lang/Java/Cholesky-decomposition b/Lang/Java/Cholesky-decomposition new file mode 120000 index 0000000000..64b2d4b6cd --- /dev/null +++ b/Lang/Java/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Java \ No newline at end of file diff --git a/Lang/Java/Colour-bars-Display b/Lang/Java/Colour-bars-Display new file mode 120000 index 0000000000..e5593a41a8 --- /dev/null +++ b/Lang/Java/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/Java \ No newline at end of file diff --git a/Lang/Java/Combinations b/Lang/Java/Combinations new file mode 120000 index 0000000000..f69a8417a0 --- /dev/null +++ b/Lang/Java/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Java \ No newline at end of file diff --git a/Lang/Java/Combinations-with-repetitions b/Lang/Java/Combinations-with-repetitions new file mode 120000 index 0000000000..05dbe2e27b --- /dev/null +++ b/Lang/Java/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Java \ No newline at end of file diff --git a/Lang/Java/Command-line-arguments b/Lang/Java/Command-line-arguments new file mode 120000 index 0000000000..502c5f6288 --- /dev/null +++ b/Lang/Java/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Java \ No newline at end of file diff --git a/Lang/Java/Compound-data-type b/Lang/Java/Compound-data-type new file mode 120000 index 0000000000..361a8ca67a --- /dev/null +++ b/Lang/Java/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Java \ No newline at end of file diff --git a/Lang/Java/Concurrent-computing b/Lang/Java/Concurrent-computing new file mode 120000 index 0000000000..f4c5b02aef --- /dev/null +++ b/Lang/Java/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Java \ No newline at end of file diff --git a/Lang/Java/Conditional-structures b/Lang/Java/Conditional-structures new file mode 120000 index 0000000000..6a5e56b0ff --- /dev/null +++ b/Lang/Java/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Java \ No newline at end of file diff --git a/Lang/Java/Constrained-genericity b/Lang/Java/Constrained-genericity new file mode 120000 index 0000000000..e6d21dd9df --- /dev/null +++ b/Lang/Java/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/Java \ No newline at end of file diff --git a/Lang/Java/Constrained-random-points-on-a-circle b/Lang/Java/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..e5b1ac3a0d --- /dev/null +++ b/Lang/Java/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Java \ No newline at end of file diff --git a/Lang/Java/Conways-Game-of-Life b/Lang/Java/Conways-Game-of-Life new file mode 120000 index 0000000000..ed2a4ae2d8 --- /dev/null +++ b/Lang/Java/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Java \ No newline at end of file diff --git a/Lang/Java/Count-in-factors b/Lang/Java/Count-in-factors new file mode 120000 index 0000000000..e8b2aae6f7 --- /dev/null +++ b/Lang/Java/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Java \ No newline at end of file diff --git a/Lang/Java/Count-in-octal b/Lang/Java/Count-in-octal new file mode 120000 index 0000000000..403d47cc27 --- /dev/null +++ b/Lang/Java/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Java \ No newline at end of file diff --git a/Lang/Java/Count-occurrences-of-a-substring b/Lang/Java/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..06c4e7f33c --- /dev/null +++ b/Lang/Java/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Java \ No newline at end of file diff --git a/Lang/Java/Count-the-coins b/Lang/Java/Count-the-coins new file mode 120000 index 0000000000..4b77e8918e --- /dev/null +++ b/Lang/Java/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Java \ No newline at end of file diff --git a/Lang/Java/Create-a-file b/Lang/Java/Create-a-file new file mode 120000 index 0000000000..dc7be96a40 --- /dev/null +++ b/Lang/Java/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Java \ No newline at end of file diff --git a/Lang/Java/Create-a-two-dimensional-array-at-runtime b/Lang/Java/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..1ebe94ccfe --- /dev/null +++ b/Lang/Java/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Java \ No newline at end of file diff --git a/Lang/Java/Create-an-HTML-table b/Lang/Java/Create-an-HTML-table new file mode 120000 index 0000000000..23bbd2d932 --- /dev/null +++ b/Lang/Java/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Java \ No newline at end of file diff --git a/Lang/Java/Date-format b/Lang/Java/Date-format new file mode 120000 index 0000000000..7431c671fd --- /dev/null +++ b/Lang/Java/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Java \ No newline at end of file diff --git a/Lang/Java/Date-manipulation b/Lang/Java/Date-manipulation new file mode 120000 index 0000000000..b4246b4efb --- /dev/null +++ b/Lang/Java/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Java \ No newline at end of file diff --git a/Lang/Java/Day-of-the-week b/Lang/Java/Day-of-the-week new file mode 120000 index 0000000000..0b3e938605 --- /dev/null +++ b/Lang/Java/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Java \ No newline at end of file diff --git a/Lang/Java/Deconvolution-1D b/Lang/Java/Deconvolution-1D new file mode 120000 index 0000000000..15681c985c --- /dev/null +++ b/Lang/Java/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Java \ No newline at end of file diff --git a/Lang/Java/Determine-if-only-one-instance-is-running b/Lang/Java/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..bac10c1ce8 --- /dev/null +++ b/Lang/Java/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Java \ No newline at end of file diff --git a/Lang/Java/Digital-root b/Lang/Java/Digital-root new file mode 120000 index 0000000000..357152bf30 --- /dev/null +++ b/Lang/Java/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/Java \ No newline at end of file diff --git a/Lang/Java/Dinesmans-multiple-dwelling-problem b/Lang/Java/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..03ae98287c --- /dev/null +++ b/Lang/Java/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Java \ No newline at end of file diff --git a/Lang/Java/Dining-philosophers b/Lang/Java/Dining-philosophers new file mode 120000 index 0000000000..08a07b06df --- /dev/null +++ b/Lang/Java/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Java \ No newline at end of file diff --git a/Lang/Java/Documentation b/Lang/Java/Documentation new file mode 120000 index 0000000000..c98a80104f --- /dev/null +++ b/Lang/Java/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Java \ No newline at end of file diff --git a/Lang/Java/Dot-product b/Lang/Java/Dot-product new file mode 120000 index 0000000000..20efa56242 --- /dev/null +++ b/Lang/Java/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Java \ No newline at end of file diff --git a/Lang/Java/Doubly-linked-list-Element-definition b/Lang/Java/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..0c69892b2e --- /dev/null +++ b/Lang/Java/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Java \ No newline at end of file diff --git a/Lang/Java/Doubly-linked-list-Traversal b/Lang/Java/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..aa3d6e9da8 --- /dev/null +++ b/Lang/Java/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Java \ No newline at end of file diff --git a/Lang/Java/Draw-a-sphere b/Lang/Java/Draw-a-sphere new file mode 120000 index 0000000000..04ba801c6c --- /dev/null +++ b/Lang/Java/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Java \ No newline at end of file diff --git a/Lang/Java/Echo-server b/Lang/Java/Echo-server new file mode 120000 index 0000000000..bee0810672 --- /dev/null +++ b/Lang/Java/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Java \ No newline at end of file diff --git a/Lang/Java/Empty-directory b/Lang/Java/Empty-directory new file mode 120000 index 0000000000..15e0e3e510 --- /dev/null +++ b/Lang/Java/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Java \ No newline at end of file diff --git a/Lang/Java/Empty-program b/Lang/Java/Empty-program new file mode 120000 index 0000000000..51f8ce06df --- /dev/null +++ b/Lang/Java/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Java \ No newline at end of file diff --git a/Lang/Java/Empty-string b/Lang/Java/Empty-string new file mode 120000 index 0000000000..1b422a15d4 --- /dev/null +++ b/Lang/Java/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Java \ No newline at end of file diff --git a/Lang/Java/Enforced-immutability b/Lang/Java/Enforced-immutability new file mode 120000 index 0000000000..7b1b3f3105 --- /dev/null +++ b/Lang/Java/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Java \ No newline at end of file diff --git a/Lang/Java/Enumerations b/Lang/Java/Enumerations new file mode 120000 index 0000000000..824767eb79 --- /dev/null +++ b/Lang/Java/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Java \ No newline at end of file diff --git a/Lang/Java/Equilibrium-index b/Lang/Java/Equilibrium-index new file mode 120000 index 0000000000..06c685b29c --- /dev/null +++ b/Lang/Java/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Java \ No newline at end of file diff --git a/Lang/Java/Ethiopian-multiplication b/Lang/Java/Ethiopian-multiplication new file mode 120000 index 0000000000..6e668fde80 --- /dev/null +++ b/Lang/Java/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Java \ No newline at end of file diff --git a/Lang/Java/Euler-method b/Lang/Java/Euler-method new file mode 120000 index 0000000000..27411ef936 --- /dev/null +++ b/Lang/Java/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Java \ No newline at end of file diff --git a/Lang/Java/Evaluate-binomial-coefficients b/Lang/Java/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..24e108a10b --- /dev/null +++ b/Lang/Java/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Java \ No newline at end of file diff --git a/Lang/Java/Even-or-odd b/Lang/Java/Even-or-odd new file mode 120000 index 0000000000..53b0095bdc --- /dev/null +++ b/Lang/Java/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Java \ No newline at end of file diff --git a/Lang/Java/Evolutionary-algorithm b/Lang/Java/Evolutionary-algorithm new file mode 120000 index 0000000000..74b93cbe44 --- /dev/null +++ b/Lang/Java/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Java \ No newline at end of file diff --git a/Lang/Java/Exceptions b/Lang/Java/Exceptions new file mode 120000 index 0000000000..b2360a68a4 --- /dev/null +++ b/Lang/Java/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Java \ No newline at end of file diff --git a/Lang/Java/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Java/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..f5a1459d9d --- /dev/null +++ b/Lang/Java/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Java \ No newline at end of file diff --git a/Lang/Java/Execute-a-system-command b/Lang/Java/Execute-a-system-command new file mode 120000 index 0000000000..1d980781ff --- /dev/null +++ b/Lang/Java/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Java \ No newline at end of file diff --git a/Lang/Java/Exponentiation-operator b/Lang/Java/Exponentiation-operator new file mode 120000 index 0000000000..183d3a770f --- /dev/null +++ b/Lang/Java/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Java \ No newline at end of file diff --git a/Lang/Java/Extreme-floating-point-values b/Lang/Java/Extreme-floating-point-values new file mode 120000 index 0000000000..c1ff50f875 --- /dev/null +++ b/Lang/Java/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Java \ No newline at end of file diff --git a/Lang/JavaScript/CSV-to-HTML-translation b/Lang/JavaScript/CSV-to-HTML-translation new file mode 120000 index 0000000000..a7e0faa9ac --- /dev/null +++ b/Lang/JavaScript/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Call-a-function b/Lang/JavaScript/Call-a-function new file mode 120000 index 0000000000..1e35875e69 --- /dev/null +++ b/Lang/JavaScript/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Case-sensitivity-of-identifiers b/Lang/JavaScript/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..5a8b8f98cc --- /dev/null +++ b/Lang/JavaScript/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Character-codes b/Lang/JavaScript/Character-codes new file mode 120000 index 0000000000..7f944ef95c --- /dev/null +++ b/Lang/JavaScript/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Character-matching b/Lang/JavaScript/Character-matching new file mode 120000 index 0000000000..ffe8cb3d81 --- /dev/null +++ b/Lang/JavaScript/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Chat-server b/Lang/JavaScript/Chat-server new file mode 120000 index 0000000000..81f9297bf4 --- /dev/null +++ b/Lang/JavaScript/Chat-server @@ -0,0 +1 @@ +../../Task/Chat-server/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Combinations b/Lang/JavaScript/Combinations new file mode 120000 index 0000000000..f9e267c1bb --- /dev/null +++ b/Lang/JavaScript/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Combinations-with-repetitions b/Lang/JavaScript/Combinations-with-repetitions new file mode 120000 index 0000000000..83f418de5b --- /dev/null +++ b/Lang/JavaScript/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Command-line-arguments b/Lang/JavaScript/Command-line-arguments new file mode 120000 index 0000000000..78227fc73a --- /dev/null +++ b/Lang/JavaScript/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Compound-data-type b/Lang/JavaScript/Compound-data-type new file mode 120000 index 0000000000..e8c8b1daaa --- /dev/null +++ b/Lang/JavaScript/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Concurrent-computing b/Lang/JavaScript/Concurrent-computing new file mode 120000 index 0000000000..22c890c959 --- /dev/null +++ b/Lang/JavaScript/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Conditional-structures b/Lang/JavaScript/Conditional-structures new file mode 120000 index 0000000000..65593fef98 --- /dev/null +++ b/Lang/JavaScript/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Constrained-random-points-on-a-circle b/Lang/JavaScript/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..c93889bf98 --- /dev/null +++ b/Lang/JavaScript/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Conways-Game-of-Life b/Lang/JavaScript/Conways-Game-of-Life new file mode 120000 index 0000000000..4796e9bcce --- /dev/null +++ b/Lang/JavaScript/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Count-in-factors b/Lang/JavaScript/Count-in-factors new file mode 120000 index 0000000000..ada5d66831 --- /dev/null +++ b/Lang/JavaScript/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Count-in-octal b/Lang/JavaScript/Count-in-octal new file mode 120000 index 0000000000..79cd18a3cc --- /dev/null +++ b/Lang/JavaScript/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Count-occurrences-of-a-substring b/Lang/JavaScript/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..418fa9172d --- /dev/null +++ b/Lang/JavaScript/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Count-the-coins b/Lang/JavaScript/Count-the-coins new file mode 120000 index 0000000000..c633fb0234 --- /dev/null +++ b/Lang/JavaScript/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Create-a-two-dimensional-array-at-runtime b/Lang/JavaScript/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..ee4c6d005d --- /dev/null +++ b/Lang/JavaScript/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Create-an-HTML-table b/Lang/JavaScript/Create-an-HTML-table new file mode 120000 index 0000000000..4bfe236eaf --- /dev/null +++ b/Lang/JavaScript/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Date-format b/Lang/JavaScript/Date-format new file mode 120000 index 0000000000..da48a881e0 --- /dev/null +++ b/Lang/JavaScript/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Date-manipulation b/Lang/JavaScript/Date-manipulation new file mode 120000 index 0000000000..2800a27969 --- /dev/null +++ b/Lang/JavaScript/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Day-of-the-week b/Lang/JavaScript/Day-of-the-week new file mode 120000 index 0000000000..68df92c53f --- /dev/null +++ b/Lang/JavaScript/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Deal-cards-for-FreeCell b/Lang/JavaScript/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..f6b5316169 --- /dev/null +++ b/Lang/JavaScript/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Deepcopy b/Lang/JavaScript/Deepcopy new file mode 120000 index 0000000000..47197fe6cb --- /dev/null +++ b/Lang/JavaScript/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Discordian-date b/Lang/JavaScript/Discordian-date new file mode 120000 index 0000000000..11f07163f4 --- /dev/null +++ b/Lang/JavaScript/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Distributed-programming b/Lang/JavaScript/Distributed-programming new file mode 120000 index 0000000000..e42117d644 --- /dev/null +++ b/Lang/JavaScript/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Dot-product b/Lang/JavaScript/Dot-product new file mode 120000 index 0000000000..75d36ede6a --- /dev/null +++ b/Lang/JavaScript/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Doubly-linked-list-Element-definition b/Lang/JavaScript/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..29f843e837 --- /dev/null +++ b/Lang/JavaScript/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Doubly-linked-list-Element-insertion b/Lang/JavaScript/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..467f7b6e3c --- /dev/null +++ b/Lang/JavaScript/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Doubly-linked-list-Traversal b/Lang/JavaScript/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..9445f5b70f --- /dev/null +++ b/Lang/JavaScript/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Dynamic-variable-names b/Lang/JavaScript/Dynamic-variable-names new file mode 120000 index 0000000000..e81feb18c5 --- /dev/null +++ b/Lang/JavaScript/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Echo-server b/Lang/JavaScript/Echo-server new file mode 120000 index 0000000000..0119e73e6a --- /dev/null +++ b/Lang/JavaScript/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Enforced-immutability b/Lang/JavaScript/Enforced-immutability new file mode 120000 index 0000000000..86c54d206d --- /dev/null +++ b/Lang/JavaScript/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Enumerations b/Lang/JavaScript/Enumerations new file mode 120000 index 0000000000..73fe9f8c58 --- /dev/null +++ b/Lang/JavaScript/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Evaluate-binomial-coefficients b/Lang/JavaScript/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..363e5fbcb3 --- /dev/null +++ b/Lang/JavaScript/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Even-or-odd b/Lang/JavaScript/Even-or-odd new file mode 120000 index 0000000000..d3c8893509 --- /dev/null +++ b/Lang/JavaScript/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Events b/Lang/JavaScript/Events new file mode 120000 index 0000000000..ab94651376 --- /dev/null +++ b/Lang/JavaScript/Events @@ -0,0 +1 @@ +../../Task/Events/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Evolutionary-algorithm b/Lang/JavaScript/Evolutionary-algorithm new file mode 120000 index 0000000000..8bfafba31e --- /dev/null +++ b/Lang/JavaScript/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Exceptions b/Lang/JavaScript/Exceptions new file mode 120000 index 0000000000..0d98c40fcd --- /dev/null +++ b/Lang/JavaScript/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/JavaScript/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..52647d4234 --- /dev/null +++ b/Lang/JavaScript/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Execute-HQ9+ b/Lang/JavaScript/Execute-HQ9+ new file mode 120000 index 0000000000..4c05699b25 --- /dev/null +++ b/Lang/JavaScript/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Execute-a-system-command b/Lang/JavaScript/Execute-a-system-command new file mode 120000 index 0000000000..f999b317b4 --- /dev/null +++ b/Lang/JavaScript/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Exponentiation-operator b/Lang/JavaScript/Exponentiation-operator new file mode 120000 index 0000000000..d1bae969f1 --- /dev/null +++ b/Lang/JavaScript/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/JavaScript \ No newline at end of file diff --git a/Lang/LaTeX/Empty-program b/Lang/LaTeX/Empty-program new file mode 120000 index 0000000000..b3546f5147 --- /dev/null +++ b/Lang/LaTeX/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/LaTeX \ No newline at end of file diff --git a/Lang/Lua/CSV-to-HTML-translation b/Lang/Lua/CSV-to-HTML-translation new file mode 120000 index 0000000000..d84aca6d29 --- /dev/null +++ b/Lang/Lua/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Lua \ No newline at end of file diff --git a/Lang/Lua/Case-sensitivity-of-identifiers b/Lang/Lua/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..7967241ce7 --- /dev/null +++ b/Lang/Lua/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Lua \ No newline at end of file diff --git a/Lang/Lua/Character-codes b/Lang/Lua/Character-codes new file mode 120000 index 0000000000..8f67280ab4 --- /dev/null +++ b/Lang/Lua/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Lua \ No newline at end of file diff --git a/Lang/Lua/Character-matching b/Lang/Lua/Character-matching new file mode 120000 index 0000000000..b6e2b08ca5 --- /dev/null +++ b/Lang/Lua/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Lua \ No newline at end of file diff --git a/Lang/Lua/Combinations b/Lang/Lua/Combinations new file mode 120000 index 0000000000..bf5226a244 --- /dev/null +++ b/Lang/Lua/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Lua \ No newline at end of file diff --git a/Lang/Lua/Command-line-arguments b/Lang/Lua/Command-line-arguments new file mode 120000 index 0000000000..15e12cd1ae --- /dev/null +++ b/Lang/Lua/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Lua \ No newline at end of file diff --git a/Lang/Lua/Compound-data-type b/Lang/Lua/Compound-data-type new file mode 120000 index 0000000000..64a90895cb --- /dev/null +++ b/Lang/Lua/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Lua \ No newline at end of file diff --git a/Lang/Lua/Concurrent-computing b/Lang/Lua/Concurrent-computing new file mode 120000 index 0000000000..8c829867c4 --- /dev/null +++ b/Lang/Lua/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Lua \ No newline at end of file diff --git a/Lang/Lua/Conditional-structures b/Lang/Lua/Conditional-structures new file mode 120000 index 0000000000..1a014aa343 --- /dev/null +++ b/Lang/Lua/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Lua \ No newline at end of file diff --git a/Lang/Lua/Conways-Game-of-Life b/Lang/Lua/Conways-Game-of-Life new file mode 120000 index 0000000000..15a131414b --- /dev/null +++ b/Lang/Lua/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Lua \ No newline at end of file diff --git a/Lang/Lua/Count-in-factors b/Lang/Lua/Count-in-factors new file mode 120000 index 0000000000..9a40dc2f61 --- /dev/null +++ b/Lang/Lua/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Lua \ No newline at end of file diff --git a/Lang/Lua/Count-in-octal b/Lang/Lua/Count-in-octal new file mode 120000 index 0000000000..c3dd25cc51 --- /dev/null +++ b/Lang/Lua/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Lua \ No newline at end of file diff --git a/Lang/Lua/Count-occurrences-of-a-substring b/Lang/Lua/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..0e875ca445 --- /dev/null +++ b/Lang/Lua/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Lua \ No newline at end of file diff --git a/Lang/Lua/Create-a-file b/Lang/Lua/Create-a-file new file mode 120000 index 0000000000..5a827db16e --- /dev/null +++ b/Lang/Lua/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Lua \ No newline at end of file diff --git a/Lang/Lua/Create-a-two-dimensional-array-at-runtime b/Lang/Lua/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..b0a8dda821 --- /dev/null +++ b/Lang/Lua/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Lua \ No newline at end of file diff --git a/Lang/Lua/Date-format b/Lang/Lua/Date-format new file mode 120000 index 0000000000..461d1d0f46 --- /dev/null +++ b/Lang/Lua/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Lua \ No newline at end of file diff --git a/Lang/Lua/Date-manipulation b/Lang/Lua/Date-manipulation new file mode 120000 index 0000000000..5a76a66042 --- /dev/null +++ b/Lang/Lua/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Lua \ No newline at end of file diff --git a/Lang/Lua/Day-of-the-week b/Lang/Lua/Day-of-the-week new file mode 120000 index 0000000000..619fd81ce2 --- /dev/null +++ b/Lang/Lua/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Lua \ No newline at end of file diff --git a/Lang/Lua/Deconvolution-1D b/Lang/Lua/Deconvolution-1D new file mode 120000 index 0000000000..1daec539ee --- /dev/null +++ b/Lang/Lua/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Lua \ No newline at end of file diff --git a/Lang/Lua/Dot-product b/Lang/Lua/Dot-product new file mode 120000 index 0000000000..9f1985ed32 --- /dev/null +++ b/Lang/Lua/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Lua \ No newline at end of file diff --git a/Lang/Lua/Draw-a-sphere b/Lang/Lua/Draw-a-sphere new file mode 120000 index 0000000000..841ab3aa78 --- /dev/null +++ b/Lang/Lua/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Lua \ No newline at end of file diff --git a/Lang/Lua/Dynamic-variable-names b/Lang/Lua/Dynamic-variable-names new file mode 120000 index 0000000000..b1b8ff7b38 --- /dev/null +++ b/Lang/Lua/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Lua \ No newline at end of file diff --git a/Lang/Lua/Empty-program b/Lang/Lua/Empty-program new file mode 120000 index 0000000000..451d4b192d --- /dev/null +++ b/Lang/Lua/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Lua \ No newline at end of file diff --git a/Lang/Lua/Empty-string b/Lang/Lua/Empty-string new file mode 120000 index 0000000000..b47938433e --- /dev/null +++ b/Lang/Lua/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Lua \ No newline at end of file diff --git a/Lang/Lua/Enumerations b/Lang/Lua/Enumerations new file mode 120000 index 0000000000..07de3a6a49 --- /dev/null +++ b/Lang/Lua/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Lua \ No newline at end of file diff --git a/Lang/Lua/Ethiopian-multiplication b/Lang/Lua/Ethiopian-multiplication new file mode 120000 index 0000000000..7034fb0686 --- /dev/null +++ b/Lang/Lua/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Lua \ No newline at end of file diff --git a/Lang/Lua/Euler-method b/Lang/Lua/Euler-method new file mode 120000 index 0000000000..59912f5045 --- /dev/null +++ b/Lang/Lua/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Lua \ No newline at end of file diff --git a/Lang/Lua/Evaluate-binomial-coefficients b/Lang/Lua/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..4f4acc470e --- /dev/null +++ b/Lang/Lua/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Lua \ No newline at end of file diff --git a/Lang/Lua/Even-or-odd b/Lang/Lua/Even-or-odd new file mode 120000 index 0000000000..9b7d1347af --- /dev/null +++ b/Lang/Lua/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Lua \ No newline at end of file diff --git a/Lang/Lua/Evolutionary-algorithm b/Lang/Lua/Evolutionary-algorithm new file mode 120000 index 0000000000..0439bc263d --- /dev/null +++ b/Lang/Lua/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Lua \ No newline at end of file diff --git a/Lang/Lua/Exceptions b/Lang/Lua/Exceptions new file mode 120000 index 0000000000..fda87d55b4 --- /dev/null +++ b/Lang/Lua/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Lua \ No newline at end of file diff --git a/Lang/Lua/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Lua/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..466c56b6a0 --- /dev/null +++ b/Lang/Lua/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Lua \ No newline at end of file diff --git a/Lang/Lua/Execute-a-system-command b/Lang/Lua/Execute-a-system-command new file mode 120000 index 0000000000..f56dbfe50d --- /dev/null +++ b/Lang/Lua/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Lua \ No newline at end of file diff --git a/Lang/Lua/Exponentiation-operator b/Lang/Lua/Exponentiation-operator new file mode 120000 index 0000000000..55c985ff0c --- /dev/null +++ b/Lang/Lua/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Lua \ No newline at end of file diff --git a/Lang/MATLAB/CSV-to-HTML-translation b/Lang/MATLAB/CSV-to-HTML-translation new file mode 120000 index 0000000000..df1e684ceb --- /dev/null +++ b/Lang/MATLAB/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Call-a-function b/Lang/MATLAB/Call-a-function new file mode 120000 index 0000000000..b21eb06a03 --- /dev/null +++ b/Lang/MATLAB/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Case-sensitivity-of-identifiers b/Lang/MATLAB/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..fdb0b777a0 --- /dev/null +++ b/Lang/MATLAB/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Character-codes b/Lang/MATLAB/Character-codes new file mode 120000 index 0000000000..fa78a29d3b --- /dev/null +++ b/Lang/MATLAB/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Character-matching b/Lang/MATLAB/Character-matching new file mode 120000 index 0000000000..aacc0c8fa7 --- /dev/null +++ b/Lang/MATLAB/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Cholesky-decomposition b/Lang/MATLAB/Cholesky-decomposition new file mode 120000 index 0000000000..3018be939b --- /dev/null +++ b/Lang/MATLAB/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Combinations b/Lang/MATLAB/Combinations new file mode 120000 index 0000000000..cb35730530 --- /dev/null +++ b/Lang/MATLAB/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Conditional-structures b/Lang/MATLAB/Conditional-structures new file mode 120000 index 0000000000..ec46f0acc5 --- /dev/null +++ b/Lang/MATLAB/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Constrained-random-points-on-a-circle b/Lang/MATLAB/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..9d617273ba --- /dev/null +++ b/Lang/MATLAB/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Conways-Game-of-Life b/Lang/MATLAB/Conways-Game-of-Life new file mode 120000 index 0000000000..716482fad5 --- /dev/null +++ b/Lang/MATLAB/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Count-in-octal b/Lang/MATLAB/Count-in-octal new file mode 120000 index 0000000000..eb0ba09b20 --- /dev/null +++ b/Lang/MATLAB/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Count-occurrences-of-a-substring b/Lang/MATLAB/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..baa3b269c4 --- /dev/null +++ b/Lang/MATLAB/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Create-a-file b/Lang/MATLAB/Create-a-file new file mode 120000 index 0000000000..8e174ad892 --- /dev/null +++ b/Lang/MATLAB/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Create-a-two-dimensional-array-at-runtime b/Lang/MATLAB/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..4c4e8e1fdf --- /dev/null +++ b/Lang/MATLAB/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Create-an-HTML-table b/Lang/MATLAB/Create-an-HTML-table new file mode 120000 index 0000000000..37cff656b3 --- /dev/null +++ b/Lang/MATLAB/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Date-format b/Lang/MATLAB/Date-format new file mode 120000 index 0000000000..b571c6c63c --- /dev/null +++ b/Lang/MATLAB/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Day-of-the-week b/Lang/MATLAB/Day-of-the-week new file mode 120000 index 0000000000..dc3c5b966e --- /dev/null +++ b/Lang/MATLAB/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Deconvolution-1D b/Lang/MATLAB/Deconvolution-1D new file mode 120000 index 0000000000..c6682550ae --- /dev/null +++ b/Lang/MATLAB/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Dot-product b/Lang/MATLAB/Dot-product new file mode 120000 index 0000000000..0f946ba7c3 --- /dev/null +++ b/Lang/MATLAB/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Empty-directory b/Lang/MATLAB/Empty-directory new file mode 120000 index 0000000000..fa0c8ec57e --- /dev/null +++ b/Lang/MATLAB/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Empty-program b/Lang/MATLAB/Empty-program new file mode 120000 index 0000000000..c965bf4e52 --- /dev/null +++ b/Lang/MATLAB/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Empty-string b/Lang/MATLAB/Empty-string new file mode 120000 index 0000000000..acbb7829e6 --- /dev/null +++ b/Lang/MATLAB/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Enumerations b/Lang/MATLAB/Enumerations new file mode 120000 index 0000000000..b8b56424cd --- /dev/null +++ b/Lang/MATLAB/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Equilibrium-index b/Lang/MATLAB/Equilibrium-index new file mode 120000 index 0000000000..b28dfd8dd7 --- /dev/null +++ b/Lang/MATLAB/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Ethiopian-multiplication b/Lang/MATLAB/Ethiopian-multiplication new file mode 120000 index 0000000000..f4c06d23e7 --- /dev/null +++ b/Lang/MATLAB/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Evaluate-binomial-coefficients b/Lang/MATLAB/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..8b6183033f --- /dev/null +++ b/Lang/MATLAB/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Even-or-odd b/Lang/MATLAB/Even-or-odd new file mode 120000 index 0000000000..91949a5cf0 --- /dev/null +++ b/Lang/MATLAB/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Evolutionary-algorithm b/Lang/MATLAB/Evolutionary-algorithm new file mode 120000 index 0000000000..9f434bf030 --- /dev/null +++ b/Lang/MATLAB/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Exceptions b/Lang/MATLAB/Exceptions new file mode 120000 index 0000000000..a083b7620c --- /dev/null +++ b/Lang/MATLAB/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/MATLAB/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..27e26bd5a1 --- /dev/null +++ b/Lang/MATLAB/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Execute-a-system-command b/Lang/MATLAB/Execute-a-system-command new file mode 120000 index 0000000000..996b1d0763 --- /dev/null +++ b/Lang/MATLAB/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/MATLAB \ No newline at end of file diff --git a/Lang/PHP/CRC-32 b/Lang/PHP/CRC-32 new file mode 120000 index 0000000000..bd8acf6eda --- /dev/null +++ b/Lang/PHP/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/PHP \ No newline at end of file diff --git a/Lang/PHP/Calendar-for-real-programmers b/Lang/PHP/Calendar-for-real-programmers new file mode 120000 index 0000000000..d07c5a38f9 --- /dev/null +++ b/Lang/PHP/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/PHP \ No newline at end of file diff --git a/Lang/PHP/Call-an-object-method b/Lang/PHP/Call-an-object-method new file mode 120000 index 0000000000..2058458793 --- /dev/null +++ b/Lang/PHP/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/PHP \ No newline at end of file diff --git a/Lang/PHP/Character-codes b/Lang/PHP/Character-codes new file mode 120000 index 0000000000..b914a14e99 --- /dev/null +++ b/Lang/PHP/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/PHP \ No newline at end of file diff --git a/Lang/PHP/Colour-bars-Display b/Lang/PHP/Colour-bars-Display new file mode 120000 index 0000000000..e293ea4783 --- /dev/null +++ b/Lang/PHP/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/PHP \ No newline at end of file diff --git a/Lang/PHP/Combinations-with-repetitions b/Lang/PHP/Combinations-with-repetitions new file mode 120000 index 0000000000..5ea670fe1a --- /dev/null +++ b/Lang/PHP/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/PHP \ No newline at end of file diff --git a/Lang/PHP/Command-line-arguments b/Lang/PHP/Command-line-arguments new file mode 120000 index 0000000000..8eb998fc74 --- /dev/null +++ b/Lang/PHP/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/PHP \ No newline at end of file diff --git a/Lang/PHP/Compound-data-type b/Lang/PHP/Compound-data-type new file mode 120000 index 0000000000..c62635f3a2 --- /dev/null +++ b/Lang/PHP/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/PHP \ No newline at end of file diff --git a/Lang/PHP/Conditional-structures b/Lang/PHP/Conditional-structures new file mode 120000 index 0000000000..e7125c6aab --- /dev/null +++ b/Lang/PHP/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/PHP \ No newline at end of file diff --git a/Lang/PHP/Count-in-octal b/Lang/PHP/Count-in-octal new file mode 120000 index 0000000000..be0d50cf88 --- /dev/null +++ b/Lang/PHP/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/PHP \ No newline at end of file diff --git a/Lang/PHP/Count-occurrences-of-a-substring b/Lang/PHP/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..5c88292c45 --- /dev/null +++ b/Lang/PHP/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/PHP \ No newline at end of file diff --git a/Lang/PHP/Create-a-file b/Lang/PHP/Create-a-file new file mode 120000 index 0000000000..6c3483a2a1 --- /dev/null +++ b/Lang/PHP/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/PHP \ No newline at end of file diff --git a/Lang/PHP/Create-an-HTML-table b/Lang/PHP/Create-an-HTML-table new file mode 120000 index 0000000000..156dfef0b6 --- /dev/null +++ b/Lang/PHP/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/PHP \ No newline at end of file diff --git a/Lang/PHP/DNS-query b/Lang/PHP/DNS-query new file mode 120000 index 0000000000..8942e43c98 --- /dev/null +++ b/Lang/PHP/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/PHP \ No newline at end of file diff --git a/Lang/PHP/Date-format b/Lang/PHP/Date-format new file mode 120000 index 0000000000..a4c5f1f633 --- /dev/null +++ b/Lang/PHP/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/PHP \ No newline at end of file diff --git a/Lang/PHP/Date-manipulation b/Lang/PHP/Date-manipulation new file mode 120000 index 0000000000..0632d26a7c --- /dev/null +++ b/Lang/PHP/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/PHP \ No newline at end of file diff --git a/Lang/PHP/Day-of-the-week b/Lang/PHP/Day-of-the-week new file mode 120000 index 0000000000..818ec00862 --- /dev/null +++ b/Lang/PHP/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/PHP \ No newline at end of file diff --git a/Lang/PHP/Deepcopy b/Lang/PHP/Deepcopy new file mode 120000 index 0000000000..3c7f37540e --- /dev/null +++ b/Lang/PHP/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/PHP \ No newline at end of file diff --git a/Lang/PHP/Discordian-date b/Lang/PHP/Discordian-date new file mode 120000 index 0000000000..4773874d6e --- /dev/null +++ b/Lang/PHP/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/PHP \ No newline at end of file diff --git a/Lang/PHP/Dot-product b/Lang/PHP/Dot-product new file mode 120000 index 0000000000..f2624154b2 --- /dev/null +++ b/Lang/PHP/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/PHP \ No newline at end of file diff --git a/Lang/PHP/Dynamic-variable-names b/Lang/PHP/Dynamic-variable-names new file mode 120000 index 0000000000..a41f592a06 --- /dev/null +++ b/Lang/PHP/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/PHP \ No newline at end of file diff --git a/Lang/PHP/Echo-server b/Lang/PHP/Echo-server new file mode 120000 index 0000000000..4dd6b974a1 --- /dev/null +++ b/Lang/PHP/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/PHP \ No newline at end of file diff --git a/Lang/PHP/Empty-directory b/Lang/PHP/Empty-directory new file mode 120000 index 0000000000..2f3d6054a1 --- /dev/null +++ b/Lang/PHP/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/PHP \ No newline at end of file diff --git a/Lang/PHP/Empty-string b/Lang/PHP/Empty-string new file mode 120000 index 0000000000..74964845d5 --- /dev/null +++ b/Lang/PHP/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/PHP \ No newline at end of file diff --git a/Lang/PHP/Enforced-immutability b/Lang/PHP/Enforced-immutability new file mode 120000 index 0000000000..82f5819dc0 --- /dev/null +++ b/Lang/PHP/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/PHP \ No newline at end of file diff --git a/Lang/PHP/Enumerations b/Lang/PHP/Enumerations new file mode 120000 index 0000000000..d054294a61 --- /dev/null +++ b/Lang/PHP/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/PHP \ No newline at end of file diff --git a/Lang/PHP/Equilibrium-index b/Lang/PHP/Equilibrium-index new file mode 120000 index 0000000000..cb9e973a48 --- /dev/null +++ b/Lang/PHP/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/PHP \ No newline at end of file diff --git a/Lang/PHP/Ethiopian-multiplication b/Lang/PHP/Ethiopian-multiplication new file mode 120000 index 0000000000..6c06d76ba9 --- /dev/null +++ b/Lang/PHP/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/PHP \ No newline at end of file diff --git a/Lang/PHP/Evaluate-binomial-coefficients b/Lang/PHP/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..1e799564a8 --- /dev/null +++ b/Lang/PHP/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/PHP \ No newline at end of file diff --git a/Lang/PHP/Even-or-odd b/Lang/PHP/Even-or-odd new file mode 120000 index 0000000000..55755f1aec --- /dev/null +++ b/Lang/PHP/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/PHP \ No newline at end of file diff --git a/Lang/PHP/Exceptions b/Lang/PHP/Exceptions new file mode 120000 index 0000000000..11851fd954 --- /dev/null +++ b/Lang/PHP/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/PHP \ No newline at end of file diff --git a/Lang/PHP/Execute-a-system-command b/Lang/PHP/Execute-a-system-command new file mode 120000 index 0000000000..213d368af9 --- /dev/null +++ b/Lang/PHP/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/PHP \ No newline at end of file diff --git a/Lang/PIR/Empty-program b/Lang/PIR/Empty-program new file mode 120000 index 0000000000..5202cc3a2a --- /dev/null +++ b/Lang/PIR/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/PIR \ No newline at end of file diff --git a/Lang/Perl/CRC-32 b/Lang/Perl/CRC-32 new file mode 120000 index 0000000000..429afcb4af --- /dev/null +++ b/Lang/Perl/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Perl \ No newline at end of file diff --git a/Lang/Perl/CSV-to-HTML-translation b/Lang/Perl/CSV-to-HTML-translation new file mode 120000 index 0000000000..073ac479ab --- /dev/null +++ b/Lang/Perl/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Perl \ No newline at end of file diff --git a/Lang/Perl/Calendar-for-real-programmers b/Lang/Perl/Calendar-for-real-programmers new file mode 120000 index 0000000000..d78355e212 --- /dev/null +++ b/Lang/Perl/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/Perl \ No newline at end of file diff --git a/Lang/Perl/Call-a-foreign-language-function b/Lang/Perl/Call-a-foreign-language-function new file mode 120000 index 0000000000..34899df0d1 --- /dev/null +++ b/Lang/Perl/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Perl \ No newline at end of file diff --git a/Lang/Perl/Call-an-object-method b/Lang/Perl/Call-an-object-method new file mode 120000 index 0000000000..4ff226fe97 --- /dev/null +++ b/Lang/Perl/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/Perl \ No newline at end of file diff --git a/Lang/Perl/Case-sensitivity-of-identifiers b/Lang/Perl/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..64b203e1a0 --- /dev/null +++ b/Lang/Perl/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Perl \ No newline at end of file diff --git a/Lang/Perl/Character-codes b/Lang/Perl/Character-codes new file mode 120000 index 0000000000..273163eecd --- /dev/null +++ b/Lang/Perl/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Perl \ No newline at end of file diff --git a/Lang/Perl/Character-matching b/Lang/Perl/Character-matching new file mode 120000 index 0000000000..d16ad0cf7a --- /dev/null +++ b/Lang/Perl/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Perl \ No newline at end of file diff --git a/Lang/Perl/Colour-bars-Display b/Lang/Perl/Colour-bars-Display new file mode 120000 index 0000000000..9b94a55d24 --- /dev/null +++ b/Lang/Perl/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/Perl \ No newline at end of file diff --git a/Lang/Perl/Colour-pinstripe-Display b/Lang/Perl/Colour-pinstripe-Display new file mode 120000 index 0000000000..e1c6036381 --- /dev/null +++ b/Lang/Perl/Colour-pinstripe-Display @@ -0,0 +1 @@ +../../Task/Colour-pinstripe-Display/Perl \ No newline at end of file diff --git a/Lang/Perl/Combinations b/Lang/Perl/Combinations new file mode 120000 index 0000000000..10eb55b085 --- /dev/null +++ b/Lang/Perl/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Perl \ No newline at end of file diff --git a/Lang/Perl/Combinations-with-repetitions b/Lang/Perl/Combinations-with-repetitions new file mode 120000 index 0000000000..0a27bda808 --- /dev/null +++ b/Lang/Perl/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Perl \ No newline at end of file diff --git a/Lang/Perl/Command-line-arguments b/Lang/Perl/Command-line-arguments new file mode 120000 index 0000000000..073bb2e0ea --- /dev/null +++ b/Lang/Perl/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Perl \ No newline at end of file diff --git a/Lang/Perl/Compile-time-calculation b/Lang/Perl/Compile-time-calculation new file mode 120000 index 0000000000..08ef80f9c6 --- /dev/null +++ b/Lang/Perl/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Perl \ No newline at end of file diff --git a/Lang/Perl/Compound-data-type b/Lang/Perl/Compound-data-type new file mode 120000 index 0000000000..2530366031 --- /dev/null +++ b/Lang/Perl/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Perl \ No newline at end of file diff --git a/Lang/Perl/Concurrent-computing b/Lang/Perl/Concurrent-computing new file mode 120000 index 0000000000..bcc4c2579d --- /dev/null +++ b/Lang/Perl/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Perl \ No newline at end of file diff --git a/Lang/Perl/Conditional-structures b/Lang/Perl/Conditional-structures new file mode 120000 index 0000000000..b802aa7ebe --- /dev/null +++ b/Lang/Perl/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Perl \ No newline at end of file diff --git a/Lang/Perl/Constrained-random-points-on-a-circle b/Lang/Perl/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..a64f36d726 --- /dev/null +++ b/Lang/Perl/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Perl \ No newline at end of file diff --git a/Lang/Perl/Continued-fraction b/Lang/Perl/Continued-fraction new file mode 120000 index 0000000000..b466f0a46a --- /dev/null +++ b/Lang/Perl/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Perl \ No newline at end of file diff --git a/Lang/Perl/Conways-Game-of-Life b/Lang/Perl/Conways-Game-of-Life new file mode 120000 index 0000000000..6488e9e2a5 --- /dev/null +++ b/Lang/Perl/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Perl \ No newline at end of file diff --git a/Lang/Perl/Count-in-factors b/Lang/Perl/Count-in-factors new file mode 120000 index 0000000000..539e150a02 --- /dev/null +++ b/Lang/Perl/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Perl \ No newline at end of file diff --git a/Lang/Perl/Count-in-octal b/Lang/Perl/Count-in-octal new file mode 120000 index 0000000000..35f315041e --- /dev/null +++ b/Lang/Perl/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Perl \ No newline at end of file diff --git a/Lang/Perl/Count-occurrences-of-a-substring b/Lang/Perl/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..bb1a1299b2 --- /dev/null +++ b/Lang/Perl/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Perl \ No newline at end of file diff --git a/Lang/Perl/Create-a-file b/Lang/Perl/Create-a-file new file mode 120000 index 0000000000..3d576d1433 --- /dev/null +++ b/Lang/Perl/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Perl \ No newline at end of file diff --git a/Lang/Perl/Create-a-two-dimensional-array-at-runtime b/Lang/Perl/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..83df3300f8 --- /dev/null +++ b/Lang/Perl/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Perl \ No newline at end of file diff --git a/Lang/Perl/Create-an-HTML-table b/Lang/Perl/Create-an-HTML-table new file mode 120000 index 0000000000..02c5492f1c --- /dev/null +++ b/Lang/Perl/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Perl \ No newline at end of file diff --git a/Lang/Perl/DNS-query b/Lang/Perl/DNS-query new file mode 120000 index 0000000000..cad3190a6f --- /dev/null +++ b/Lang/Perl/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/Perl \ No newline at end of file diff --git a/Lang/Perl/Date-format b/Lang/Perl/Date-format new file mode 120000 index 0000000000..db5056a8ab --- /dev/null +++ b/Lang/Perl/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Perl \ No newline at end of file diff --git a/Lang/Perl/Date-manipulation b/Lang/Perl/Date-manipulation new file mode 120000 index 0000000000..c808ec39b7 --- /dev/null +++ b/Lang/Perl/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Perl \ No newline at end of file diff --git a/Lang/Perl/Day-of-the-week b/Lang/Perl/Day-of-the-week new file mode 120000 index 0000000000..edc553e739 --- /dev/null +++ b/Lang/Perl/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Perl \ No newline at end of file diff --git a/Lang/Perl/Deal-cards-for-FreeCell b/Lang/Perl/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..c6ee22ef40 --- /dev/null +++ b/Lang/Perl/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/Perl \ No newline at end of file diff --git a/Lang/Perl/Deepcopy b/Lang/Perl/Deepcopy new file mode 120000 index 0000000000..13ad6077f9 --- /dev/null +++ b/Lang/Perl/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/Perl \ No newline at end of file diff --git a/Lang/Perl/Determine-if-only-one-instance-is-running b/Lang/Perl/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..8b5e660266 --- /dev/null +++ b/Lang/Perl/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Perl \ No newline at end of file diff --git a/Lang/Perl/Distributed-programming b/Lang/Perl/Distributed-programming new file mode 120000 index 0000000000..0513f6dc80 --- /dev/null +++ b/Lang/Perl/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/Perl \ No newline at end of file diff --git a/Lang/Perl/Dot-product b/Lang/Perl/Dot-product new file mode 120000 index 0000000000..61bdf0305f --- /dev/null +++ b/Lang/Perl/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Perl \ No newline at end of file diff --git a/Lang/Perl/Doubly-linked-list-Element-definition b/Lang/Perl/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..14df401d0c --- /dev/null +++ b/Lang/Perl/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Perl \ No newline at end of file diff --git a/Lang/Perl/Doubly-linked-list-Element-insertion b/Lang/Perl/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..f87831af52 --- /dev/null +++ b/Lang/Perl/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/Perl \ No newline at end of file diff --git a/Lang/Perl/Draw-a-cuboid b/Lang/Perl/Draw-a-cuboid new file mode 120000 index 0000000000..8700415128 --- /dev/null +++ b/Lang/Perl/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Perl \ No newline at end of file diff --git a/Lang/Perl/Dynamic-variable-names b/Lang/Perl/Dynamic-variable-names new file mode 120000 index 0000000000..ee96cb4200 --- /dev/null +++ b/Lang/Perl/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Perl \ No newline at end of file diff --git a/Lang/Perl/Echo-server b/Lang/Perl/Echo-server new file mode 120000 index 0000000000..c988c52fff --- /dev/null +++ b/Lang/Perl/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Perl \ No newline at end of file diff --git a/Lang/Perl/Element-wise-operations b/Lang/Perl/Element-wise-operations new file mode 120000 index 0000000000..5451f79cf1 --- /dev/null +++ b/Lang/Perl/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/Perl \ No newline at end of file diff --git a/Lang/Perl/Empty-directory b/Lang/Perl/Empty-directory new file mode 120000 index 0000000000..6d623d2a63 --- /dev/null +++ b/Lang/Perl/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Perl \ No newline at end of file diff --git a/Lang/Perl/Empty-program b/Lang/Perl/Empty-program new file mode 120000 index 0000000000..6a87dc080c --- /dev/null +++ b/Lang/Perl/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Perl \ No newline at end of file diff --git a/Lang/Perl/Empty-string b/Lang/Perl/Empty-string new file mode 120000 index 0000000000..582ea73744 --- /dev/null +++ b/Lang/Perl/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Perl \ No newline at end of file diff --git a/Lang/Perl/Enforced-immutability b/Lang/Perl/Enforced-immutability new file mode 120000 index 0000000000..58b03c7fac --- /dev/null +++ b/Lang/Perl/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Perl \ No newline at end of file diff --git a/Lang/Perl/Enumerations b/Lang/Perl/Enumerations new file mode 120000 index 0000000000..58791cbd15 --- /dev/null +++ b/Lang/Perl/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Perl \ No newline at end of file diff --git a/Lang/Perl/Equilibrium-index b/Lang/Perl/Equilibrium-index new file mode 120000 index 0000000000..286c414328 --- /dev/null +++ b/Lang/Perl/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Perl \ No newline at end of file diff --git a/Lang/Perl/Ethiopian-multiplication b/Lang/Perl/Ethiopian-multiplication new file mode 120000 index 0000000000..a6483b5052 --- /dev/null +++ b/Lang/Perl/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Perl \ No newline at end of file diff --git a/Lang/Perl/Euler-method b/Lang/Perl/Euler-method new file mode 120000 index 0000000000..edc73dc334 --- /dev/null +++ b/Lang/Perl/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Perl \ No newline at end of file diff --git a/Lang/Perl/Evaluate-binomial-coefficients b/Lang/Perl/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..d623c045ce --- /dev/null +++ b/Lang/Perl/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Perl \ No newline at end of file diff --git a/Lang/Perl/Even-or-odd b/Lang/Perl/Even-or-odd new file mode 120000 index 0000000000..8653e78b4c --- /dev/null +++ b/Lang/Perl/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Perl \ No newline at end of file diff --git a/Lang/Perl/Events b/Lang/Perl/Events new file mode 120000 index 0000000000..10b1f16a78 --- /dev/null +++ b/Lang/Perl/Events @@ -0,0 +1 @@ +../../Task/Events/Perl \ No newline at end of file diff --git a/Lang/Perl/Evolutionary-algorithm b/Lang/Perl/Evolutionary-algorithm new file mode 120000 index 0000000000..d37af2c242 --- /dev/null +++ b/Lang/Perl/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Perl \ No newline at end of file diff --git a/Lang/Perl/Exceptions b/Lang/Perl/Exceptions new file mode 120000 index 0000000000..c09707378d --- /dev/null +++ b/Lang/Perl/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Perl \ No newline at end of file diff --git a/Lang/Perl/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Perl/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..e0d26a31cd --- /dev/null +++ b/Lang/Perl/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Perl \ No newline at end of file diff --git a/Lang/Perl/Executable-library b/Lang/Perl/Executable-library new file mode 120000 index 0000000000..bdf9e6195f --- /dev/null +++ b/Lang/Perl/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/Perl \ No newline at end of file diff --git a/Lang/Perl/Execute-a-system-command b/Lang/Perl/Execute-a-system-command new file mode 120000 index 0000000000..7b5ac6b527 --- /dev/null +++ b/Lang/Perl/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Perl \ No newline at end of file diff --git a/Lang/Perl/Exponentiation-operator b/Lang/Perl/Exponentiation-operator new file mode 120000 index 0000000000..2f5afad4cc --- /dev/null +++ b/Lang/Perl/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Perl \ No newline at end of file diff --git a/Lang/Perl/Extend-your-language b/Lang/Perl/Extend-your-language new file mode 120000 index 0000000000..b861c3feaf --- /dev/null +++ b/Lang/Perl/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Perl \ No newline at end of file diff --git a/Lang/Perl/Extreme-floating-point-values b/Lang/Perl/Extreme-floating-point-values new file mode 120000 index 0000000000..13cdba69e7 --- /dev/null +++ b/Lang/Perl/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Perl \ No newline at end of file diff --git a/Lang/PicoLisp/CSV-to-HTML-translation b/Lang/PicoLisp/CSV-to-HTML-translation new file mode 120000 index 0000000000..f377f09514 --- /dev/null +++ b/Lang/PicoLisp/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Calendar-for-real-programmers b/Lang/PicoLisp/Calendar-for-real-programmers new file mode 120000 index 0000000000..cf80e6361b --- /dev/null +++ b/Lang/PicoLisp/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Call-a-foreign-language-function b/Lang/PicoLisp/Call-a-foreign-language-function new file mode 120000 index 0000000000..5be6de2177 --- /dev/null +++ b/Lang/PicoLisp/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Call-a-function b/Lang/PicoLisp/Call-a-function new file mode 120000 index 0000000000..4a0a8eadfe --- /dev/null +++ b/Lang/PicoLisp/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Call-a-function-in-a-shared-library b/Lang/PicoLisp/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..1c15074ecd --- /dev/null +++ b/Lang/PicoLisp/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Call-an-object-method b/Lang/PicoLisp/Call-an-object-method new file mode 120000 index 0000000000..132cce2711 --- /dev/null +++ b/Lang/PicoLisp/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Case-sensitivity-of-identifiers b/Lang/PicoLisp/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..7b5a928f7e --- /dev/null +++ b/Lang/PicoLisp/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Character-codes b/Lang/PicoLisp/Character-codes new file mode 120000 index 0000000000..e5e828e676 --- /dev/null +++ b/Lang/PicoLisp/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Character-matching b/Lang/PicoLisp/Character-matching new file mode 120000 index 0000000000..0c515809a4 --- /dev/null +++ b/Lang/PicoLisp/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Chat-server b/Lang/PicoLisp/Chat-server new file mode 120000 index 0000000000..53d276fb00 --- /dev/null +++ b/Lang/PicoLisp/Chat-server @@ -0,0 +1 @@ +../../Task/Chat-server/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Cholesky-decomposition b/Lang/PicoLisp/Cholesky-decomposition new file mode 120000 index 0000000000..30057b63a4 --- /dev/null +++ b/Lang/PicoLisp/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Colour-bars-Display b/Lang/PicoLisp/Colour-bars-Display new file mode 120000 index 0000000000..09828aedb8 --- /dev/null +++ b/Lang/PicoLisp/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Colour-pinstripe-Display b/Lang/PicoLisp/Colour-pinstripe-Display new file mode 120000 index 0000000000..8bb52c4e5c --- /dev/null +++ b/Lang/PicoLisp/Colour-pinstripe-Display @@ -0,0 +1 @@ +../../Task/Colour-pinstripe-Display/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Colour-pinstripe-Printer b/Lang/PicoLisp/Colour-pinstripe-Printer new file mode 120000 index 0000000000..d14212d573 --- /dev/null +++ b/Lang/PicoLisp/Colour-pinstripe-Printer @@ -0,0 +1 @@ +../../Task/Colour-pinstripe-Printer/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Combinations b/Lang/PicoLisp/Combinations new file mode 120000 index 0000000000..71cf28d1e4 --- /dev/null +++ b/Lang/PicoLisp/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Combinations-with-repetitions b/Lang/PicoLisp/Combinations-with-repetitions new file mode 120000 index 0000000000..3269b9d740 --- /dev/null +++ b/Lang/PicoLisp/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Command-line-arguments b/Lang/PicoLisp/Command-line-arguments new file mode 120000 index 0000000000..1b8783dc5f --- /dev/null +++ b/Lang/PicoLisp/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Compile-time-calculation b/Lang/PicoLisp/Compile-time-calculation new file mode 120000 index 0000000000..4e6c3a2820 --- /dev/null +++ b/Lang/PicoLisp/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Compound-data-type b/Lang/PicoLisp/Compound-data-type new file mode 120000 index 0000000000..174ccae6dd --- /dev/null +++ b/Lang/PicoLisp/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Concurrent-computing b/Lang/PicoLisp/Concurrent-computing new file mode 120000 index 0000000000..a6ff94c813 --- /dev/null +++ b/Lang/PicoLisp/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Conditional-structures b/Lang/PicoLisp/Conditional-structures new file mode 120000 index 0000000000..acb3cff1db --- /dev/null +++ b/Lang/PicoLisp/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Constrained-genericity b/Lang/PicoLisp/Constrained-genericity new file mode 120000 index 0000000000..9c6a1e18f9 --- /dev/null +++ b/Lang/PicoLisp/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Constrained-random-points-on-a-circle b/Lang/PicoLisp/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..e03b918787 --- /dev/null +++ b/Lang/PicoLisp/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Conways-Game-of-Life b/Lang/PicoLisp/Conways-Game-of-Life new file mode 120000 index 0000000000..e6e7cf2e2e --- /dev/null +++ b/Lang/PicoLisp/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Count-in-factors b/Lang/PicoLisp/Count-in-factors new file mode 120000 index 0000000000..a47e0156d9 --- /dev/null +++ b/Lang/PicoLisp/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Count-in-octal b/Lang/PicoLisp/Count-in-octal new file mode 120000 index 0000000000..e437c5fcdd --- /dev/null +++ b/Lang/PicoLisp/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Count-occurrences-of-a-substring b/Lang/PicoLisp/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..004a4474ac --- /dev/null +++ b/Lang/PicoLisp/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Count-the-coins b/Lang/PicoLisp/Count-the-coins new file mode 120000 index 0000000000..a8126c5a6b --- /dev/null +++ b/Lang/PicoLisp/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Create-a-file b/Lang/PicoLisp/Create-a-file new file mode 120000 index 0000000000..50a41ab08e --- /dev/null +++ b/Lang/PicoLisp/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Create-a-two-dimensional-array-at-runtime b/Lang/PicoLisp/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..883792151b --- /dev/null +++ b/Lang/PicoLisp/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Create-an-HTML-table b/Lang/PicoLisp/Create-an-HTML-table new file mode 120000 index 0000000000..a3c5aa5185 --- /dev/null +++ b/Lang/PicoLisp/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Create-an-object-at-a-given-address b/Lang/PicoLisp/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..05753d925e --- /dev/null +++ b/Lang/PicoLisp/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/DNS-query b/Lang/PicoLisp/DNS-query new file mode 120000 index 0000000000..13ed564f16 --- /dev/null +++ b/Lang/PicoLisp/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Date-format b/Lang/PicoLisp/Date-format new file mode 120000 index 0000000000..f76a438763 --- /dev/null +++ b/Lang/PicoLisp/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Date-manipulation b/Lang/PicoLisp/Date-manipulation new file mode 120000 index 0000000000..19fc280a77 --- /dev/null +++ b/Lang/PicoLisp/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Day-of-the-week b/Lang/PicoLisp/Day-of-the-week new file mode 120000 index 0000000000..69028a4751 --- /dev/null +++ b/Lang/PicoLisp/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Deal-cards-for-FreeCell b/Lang/PicoLisp/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..2c21c822de --- /dev/null +++ b/Lang/PicoLisp/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Deconvolution-1D b/Lang/PicoLisp/Deconvolution-1D new file mode 120000 index 0000000000..d69167cb89 --- /dev/null +++ b/Lang/PicoLisp/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Deepcopy b/Lang/PicoLisp/Deepcopy new file mode 120000 index 0000000000..080385db80 --- /dev/null +++ b/Lang/PicoLisp/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Determine-if-only-one-instance-is-running b/Lang/PicoLisp/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..3a78577bd1 --- /dev/null +++ b/Lang/PicoLisp/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Digital-root b/Lang/PicoLisp/Digital-root new file mode 120000 index 0000000000..ddb09af1f5 --- /dev/null +++ b/Lang/PicoLisp/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Dinesmans-multiple-dwelling-problem b/Lang/PicoLisp/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..c4530a9e03 --- /dev/null +++ b/Lang/PicoLisp/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Dining-philosophers b/Lang/PicoLisp/Dining-philosophers new file mode 120000 index 0000000000..7ff9aea892 --- /dev/null +++ b/Lang/PicoLisp/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Discordian-date b/Lang/PicoLisp/Discordian-date new file mode 120000 index 0000000000..a9e128ed75 --- /dev/null +++ b/Lang/PicoLisp/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Distributed-programming b/Lang/PicoLisp/Distributed-programming new file mode 120000 index 0000000000..5f328a953e --- /dev/null +++ b/Lang/PicoLisp/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Documentation b/Lang/PicoLisp/Documentation new file mode 120000 index 0000000000..f32c013075 --- /dev/null +++ b/Lang/PicoLisp/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Dot-product b/Lang/PicoLisp/Dot-product new file mode 120000 index 0000000000..5314c33119 --- /dev/null +++ b/Lang/PicoLisp/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Doubly-linked-list-Definition b/Lang/PicoLisp/Doubly-linked-list-Definition new file mode 120000 index 0000000000..73e9a74466 --- /dev/null +++ b/Lang/PicoLisp/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Doubly-linked-list-Element-definition b/Lang/PicoLisp/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..edb072ae28 --- /dev/null +++ b/Lang/PicoLisp/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Doubly-linked-list-Element-insertion b/Lang/PicoLisp/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..99c6787aa1 --- /dev/null +++ b/Lang/PicoLisp/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Doubly-linked-list-Traversal b/Lang/PicoLisp/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..e2177d15b5 --- /dev/null +++ b/Lang/PicoLisp/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Draw-a-cuboid b/Lang/PicoLisp/Draw-a-cuboid new file mode 120000 index 0000000000..54bd372660 --- /dev/null +++ b/Lang/PicoLisp/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Draw-a-sphere b/Lang/PicoLisp/Draw-a-sphere new file mode 120000 index 0000000000..e660b65fcb --- /dev/null +++ b/Lang/PicoLisp/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Dutch-national-flag-problem b/Lang/PicoLisp/Dutch-national-flag-problem new file mode 120000 index 0000000000..2ef0286b1c --- /dev/null +++ b/Lang/PicoLisp/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Dynamic-variable-names b/Lang/PicoLisp/Dynamic-variable-names new file mode 120000 index 0000000000..32dad55574 --- /dev/null +++ b/Lang/PicoLisp/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Echo-server b/Lang/PicoLisp/Echo-server new file mode 120000 index 0000000000..aa11550378 --- /dev/null +++ b/Lang/PicoLisp/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Element-wise-operations b/Lang/PicoLisp/Element-wise-operations new file mode 120000 index 0000000000..9c7ca01e90 --- /dev/null +++ b/Lang/PicoLisp/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Empty-directory b/Lang/PicoLisp/Empty-directory new file mode 120000 index 0000000000..e1af129fdd --- /dev/null +++ b/Lang/PicoLisp/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Empty-program b/Lang/PicoLisp/Empty-program new file mode 120000 index 0000000000..0b7f9ac06f --- /dev/null +++ b/Lang/PicoLisp/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Empty-string b/Lang/PicoLisp/Empty-string new file mode 120000 index 0000000000..874860a90b --- /dev/null +++ b/Lang/PicoLisp/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Enforced-immutability b/Lang/PicoLisp/Enforced-immutability new file mode 120000 index 0000000000..af3e5af552 --- /dev/null +++ b/Lang/PicoLisp/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Enumerations b/Lang/PicoLisp/Enumerations new file mode 120000 index 0000000000..97255fa15d --- /dev/null +++ b/Lang/PicoLisp/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Equilibrium-index b/Lang/PicoLisp/Equilibrium-index new file mode 120000 index 0000000000..86ff36e0b3 --- /dev/null +++ b/Lang/PicoLisp/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Ethiopian-multiplication b/Lang/PicoLisp/Ethiopian-multiplication new file mode 120000 index 0000000000..c52e830e4c --- /dev/null +++ b/Lang/PicoLisp/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Euler-method b/Lang/PicoLisp/Euler-method new file mode 120000 index 0000000000..5e22cfc078 --- /dev/null +++ b/Lang/PicoLisp/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Evaluate-binomial-coefficients b/Lang/PicoLisp/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..39bb3fb7c3 --- /dev/null +++ b/Lang/PicoLisp/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Even-or-odd b/Lang/PicoLisp/Even-or-odd new file mode 120000 index 0000000000..5ec5d9d9d2 --- /dev/null +++ b/Lang/PicoLisp/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Events b/Lang/PicoLisp/Events new file mode 120000 index 0000000000..5b4803fd4b --- /dev/null +++ b/Lang/PicoLisp/Events @@ -0,0 +1 @@ +../../Task/Events/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Evolutionary-algorithm b/Lang/PicoLisp/Evolutionary-algorithm new file mode 120000 index 0000000000..71cb19b09b --- /dev/null +++ b/Lang/PicoLisp/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Exceptions b/Lang/PicoLisp/Exceptions new file mode 120000 index 0000000000..3e415f7ba1 --- /dev/null +++ b/Lang/PicoLisp/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/PicoLisp/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..cdb1e8ff95 --- /dev/null +++ b/Lang/PicoLisp/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Executable-library b/Lang/PicoLisp/Executable-library new file mode 120000 index 0000000000..ae8a71d3cb --- /dev/null +++ b/Lang/PicoLisp/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Execute-HQ9+ b/Lang/PicoLisp/Execute-HQ9+ new file mode 120000 index 0000000000..fb4d7abd34 --- /dev/null +++ b/Lang/PicoLisp/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Execute-a-system-command b/Lang/PicoLisp/Execute-a-system-command new file mode 120000 index 0000000000..618f301734 --- /dev/null +++ b/Lang/PicoLisp/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Exponentiation-operator b/Lang/PicoLisp/Exponentiation-operator new file mode 120000 index 0000000000..28dc7fb084 --- /dev/null +++ b/Lang/PicoLisp/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Extend-your-language b/Lang/PicoLisp/Extend-your-language new file mode 120000 index 0000000000..d7712a6a5b --- /dev/null +++ b/Lang/PicoLisp/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Extreme-floating-point-values b/Lang/PicoLisp/Extreme-floating-point-values new file mode 120000 index 0000000000..31d16a64ab --- /dev/null +++ b/Lang/PicoLisp/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/PicoLisp \ No newline at end of file diff --git a/Lang/Prolog/CSV-to-HTML-translation b/Lang/Prolog/CSV-to-HTML-translation new file mode 120000 index 0000000000..18e9ce276c --- /dev/null +++ b/Lang/Prolog/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Case-sensitivity-of-identifiers b/Lang/Prolog/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..a6630f76fa --- /dev/null +++ b/Lang/Prolog/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Combinations b/Lang/Prolog/Combinations new file mode 120000 index 0000000000..4b0556f0e9 --- /dev/null +++ b/Lang/Prolog/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Constrained-random-points-on-a-circle b/Lang/Prolog/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..736f964934 --- /dev/null +++ b/Lang/Prolog/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Continued-fraction b/Lang/Prolog/Continued-fraction new file mode 120000 index 0000000000..4431039772 --- /dev/null +++ b/Lang/Prolog/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Conways-Game-of-Life b/Lang/Prolog/Conways-Game-of-Life new file mode 120000 index 0000000000..5fa66ff350 --- /dev/null +++ b/Lang/Prolog/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Dinesmans-multiple-dwelling-problem b/Lang/Prolog/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..b9a8b9bab2 --- /dev/null +++ b/Lang/Prolog/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Dining-philosophers b/Lang/Prolog/Dining-philosophers new file mode 120000 index 0000000000..a2273d2d56 --- /dev/null +++ b/Lang/Prolog/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Dot-product b/Lang/Prolog/Dot-product new file mode 120000 index 0000000000..fa5be12f38 --- /dev/null +++ b/Lang/Prolog/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Draw-a-cuboid b/Lang/Prolog/Draw-a-cuboid new file mode 120000 index 0000000000..29c00389e4 --- /dev/null +++ b/Lang/Prolog/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Dutch-national-flag-problem b/Lang/Prolog/Dutch-national-flag-problem new file mode 120000 index 0000000000..ec6626f0db --- /dev/null +++ b/Lang/Prolog/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Execute-a-system-command b/Lang/Prolog/Execute-a-system-command new file mode 120000 index 0000000000..3c639d97d9 --- /dev/null +++ b/Lang/Prolog/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Prolog \ No newline at end of file diff --git a/Lang/Python/CRC-32 b/Lang/Python/CRC-32 new file mode 120000 index 0000000000..2b9a3bb2c1 --- /dev/null +++ b/Lang/Python/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Python \ No newline at end of file diff --git a/Lang/Python/CSV-to-HTML-translation b/Lang/Python/CSV-to-HTML-translation new file mode 120000 index 0000000000..5d9751f0fa --- /dev/null +++ b/Lang/Python/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Python \ No newline at end of file diff --git a/Lang/Python/Call-a-foreign-language-function b/Lang/Python/Call-a-foreign-language-function new file mode 120000 index 0000000000..f2ee13f0f1 --- /dev/null +++ b/Lang/Python/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Python \ No newline at end of file diff --git a/Lang/Python/Call-a-function b/Lang/Python/Call-a-function new file mode 120000 index 0000000000..872bf537ab --- /dev/null +++ b/Lang/Python/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/Python \ No newline at end of file diff --git a/Lang/Python/Call-a-function-in-a-shared-library b/Lang/Python/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..eaf029b3b7 --- /dev/null +++ b/Lang/Python/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Python \ No newline at end of file diff --git a/Lang/Python/Call-an-object-method b/Lang/Python/Call-an-object-method new file mode 120000 index 0000000000..7d60c0f729 --- /dev/null +++ b/Lang/Python/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/Python \ No newline at end of file diff --git a/Lang/Python/Carmichael-3-strong-pseudoprimes b/Lang/Python/Carmichael-3-strong-pseudoprimes new file mode 120000 index 0000000000..e88c8f0ab7 --- /dev/null +++ b/Lang/Python/Carmichael-3-strong-pseudoprimes @@ -0,0 +1 @@ +../../Task/Carmichael-3-strong-pseudoprimes/Python \ No newline at end of file diff --git a/Lang/Python/Case-sensitivity-of-identifiers b/Lang/Python/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..816aff85b3 --- /dev/null +++ b/Lang/Python/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Python \ No newline at end of file diff --git a/Lang/Python/Character-codes b/Lang/Python/Character-codes new file mode 120000 index 0000000000..aefe1f18de --- /dev/null +++ b/Lang/Python/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Python \ No newline at end of file diff --git a/Lang/Python/Character-matching b/Lang/Python/Character-matching new file mode 120000 index 0000000000..e05232ed0b --- /dev/null +++ b/Lang/Python/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Python \ No newline at end of file diff --git a/Lang/Python/Chat-server b/Lang/Python/Chat-server new file mode 120000 index 0000000000..54b7670939 --- /dev/null +++ b/Lang/Python/Chat-server @@ -0,0 +1 @@ +../../Task/Chat-server/Python \ No newline at end of file diff --git a/Lang/Python/Check-Machin-like-formulas b/Lang/Python/Check-Machin-like-formulas new file mode 120000 index 0000000000..d354965222 --- /dev/null +++ b/Lang/Python/Check-Machin-like-formulas @@ -0,0 +1 @@ +../../Task/Check-Machin-like-formulas/Python \ No newline at end of file diff --git a/Lang/Python/Cholesky-decomposition b/Lang/Python/Cholesky-decomposition new file mode 120000 index 0000000000..29d9a3be80 --- /dev/null +++ b/Lang/Python/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Python \ No newline at end of file diff --git a/Lang/Python/Colour-bars-Display b/Lang/Python/Colour-bars-Display new file mode 120000 index 0000000000..ebd7eb6e7d --- /dev/null +++ b/Lang/Python/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/Python \ No newline at end of file diff --git a/Lang/Python/Combinations b/Lang/Python/Combinations new file mode 120000 index 0000000000..f0e62cd7c7 --- /dev/null +++ b/Lang/Python/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Python \ No newline at end of file diff --git a/Lang/Python/Combinations-with-repetitions b/Lang/Python/Combinations-with-repetitions new file mode 120000 index 0000000000..18ddab610a --- /dev/null +++ b/Lang/Python/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Python \ No newline at end of file diff --git a/Lang/Python/Command-line-arguments b/Lang/Python/Command-line-arguments new file mode 120000 index 0000000000..52fda2ffd8 --- /dev/null +++ b/Lang/Python/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Python \ No newline at end of file diff --git a/Lang/Python/Compare-sorting-algorithms-performance b/Lang/Python/Compare-sorting-algorithms-performance new file mode 120000 index 0000000000..866d6e26dc --- /dev/null +++ b/Lang/Python/Compare-sorting-algorithms-performance @@ -0,0 +1 @@ +../../Task/Compare-sorting-algorithms-performance/Python \ No newline at end of file diff --git a/Lang/Python/Compound-data-type b/Lang/Python/Compound-data-type new file mode 120000 index 0000000000..d6e2762d66 --- /dev/null +++ b/Lang/Python/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Python \ No newline at end of file diff --git a/Lang/Python/Concurrent-computing b/Lang/Python/Concurrent-computing new file mode 120000 index 0000000000..982db4388b --- /dev/null +++ b/Lang/Python/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Python \ No newline at end of file diff --git a/Lang/Python/Conditional-structures b/Lang/Python/Conditional-structures new file mode 120000 index 0000000000..ba93daae7f --- /dev/null +++ b/Lang/Python/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Python \ No newline at end of file diff --git a/Lang/Python/Constrained-random-points-on-a-circle b/Lang/Python/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..11492569c4 --- /dev/null +++ b/Lang/Python/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Python \ No newline at end of file diff --git a/Lang/Python/Continued-fraction b/Lang/Python/Continued-fraction new file mode 120000 index 0000000000..668c285614 --- /dev/null +++ b/Lang/Python/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Python \ No newline at end of file diff --git a/Lang/Python/Continued-fraction-Arithmetic-Construct-from-rational-number b/Lang/Python/Continued-fraction-Arithmetic-Construct-from-rational-number new file mode 120000 index 0000000000..bb22b10d84 --- /dev/null +++ b/Lang/Python/Continued-fraction-Arithmetic-Construct-from-rational-number @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Python \ No newline at end of file diff --git a/Lang/Python/Conways-Game-of-Life b/Lang/Python/Conways-Game-of-Life new file mode 120000 index 0000000000..909e5cfaa0 --- /dev/null +++ b/Lang/Python/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Python \ No newline at end of file diff --git a/Lang/Python/Count-in-factors b/Lang/Python/Count-in-factors new file mode 120000 index 0000000000..a010187c20 --- /dev/null +++ b/Lang/Python/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Python \ No newline at end of file diff --git a/Lang/Python/Count-in-octal b/Lang/Python/Count-in-octal new file mode 120000 index 0000000000..81e48eaa56 --- /dev/null +++ b/Lang/Python/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Python \ No newline at end of file diff --git a/Lang/Python/Count-occurrences-of-a-substring b/Lang/Python/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..146fe537f9 --- /dev/null +++ b/Lang/Python/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Python \ No newline at end of file diff --git a/Lang/Python/Count-the-coins b/Lang/Python/Count-the-coins new file mode 120000 index 0000000000..3ba8d71ff0 --- /dev/null +++ b/Lang/Python/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Python \ No newline at end of file diff --git a/Lang/Python/Create-a-file b/Lang/Python/Create-a-file new file mode 120000 index 0000000000..86591766c6 --- /dev/null +++ b/Lang/Python/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Python \ No newline at end of file diff --git a/Lang/Python/Create-a-two-dimensional-array-at-runtime b/Lang/Python/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..8b424e2231 --- /dev/null +++ b/Lang/Python/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Python \ No newline at end of file diff --git a/Lang/Python/Create-an-HTML-table b/Lang/Python/Create-an-HTML-table new file mode 120000 index 0000000000..dfe2ac7b3f --- /dev/null +++ b/Lang/Python/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Python \ No newline at end of file diff --git a/Lang/Python/Cut-a-rectangle b/Lang/Python/Cut-a-rectangle new file mode 120000 index 0000000000..9e7a71e7f9 --- /dev/null +++ b/Lang/Python/Cut-a-rectangle @@ -0,0 +1 @@ +../../Task/Cut-a-rectangle/Python \ No newline at end of file diff --git a/Lang/Python/Date-format b/Lang/Python/Date-format new file mode 120000 index 0000000000..20f11436e7 --- /dev/null +++ b/Lang/Python/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Python \ No newline at end of file diff --git a/Lang/Python/Date-manipulation b/Lang/Python/Date-manipulation new file mode 120000 index 0000000000..6d3128f27c --- /dev/null +++ b/Lang/Python/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Python \ No newline at end of file diff --git a/Lang/Python/Day-of-the-week b/Lang/Python/Day-of-the-week new file mode 120000 index 0000000000..c131f26ff6 --- /dev/null +++ b/Lang/Python/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Python \ No newline at end of file diff --git a/Lang/Python/Deal-cards-for-FreeCell b/Lang/Python/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..d5a0c725c2 --- /dev/null +++ b/Lang/Python/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/Python \ No newline at end of file diff --git a/Lang/Python/Deconvolution-1D b/Lang/Python/Deconvolution-1D new file mode 120000 index 0000000000..c4ad7a2d05 --- /dev/null +++ b/Lang/Python/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Python \ No newline at end of file diff --git a/Lang/Python/Deepcopy b/Lang/Python/Deepcopy new file mode 120000 index 0000000000..f32d7620d7 --- /dev/null +++ b/Lang/Python/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/Python \ No newline at end of file diff --git a/Lang/Python/Determine-if-only-one-instance-is-running b/Lang/Python/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..d9e51ca896 --- /dev/null +++ b/Lang/Python/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Python \ No newline at end of file diff --git a/Lang/Python/Digital-root b/Lang/Python/Digital-root new file mode 120000 index 0000000000..cedb730520 --- /dev/null +++ b/Lang/Python/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/Python \ No newline at end of file diff --git a/Lang/Python/Dinesmans-multiple-dwelling-problem b/Lang/Python/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..e588a88e3a --- /dev/null +++ b/Lang/Python/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Python \ No newline at end of file diff --git a/Lang/Python/Dining-philosophers b/Lang/Python/Dining-philosophers new file mode 120000 index 0000000000..bb830022b5 --- /dev/null +++ b/Lang/Python/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Python \ No newline at end of file diff --git a/Lang/Python/Discordian-date b/Lang/Python/Discordian-date new file mode 120000 index 0000000000..0210ee0603 --- /dev/null +++ b/Lang/Python/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/Python \ No newline at end of file diff --git a/Lang/Python/Distributed-programming b/Lang/Python/Distributed-programming new file mode 120000 index 0000000000..a5f793ab5c --- /dev/null +++ b/Lang/Python/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/Python \ No newline at end of file diff --git a/Lang/Python/Documentation b/Lang/Python/Documentation new file mode 120000 index 0000000000..30c37f5833 --- /dev/null +++ b/Lang/Python/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Python \ No newline at end of file diff --git a/Lang/Python/Dot-product b/Lang/Python/Dot-product new file mode 120000 index 0000000000..dd63116735 --- /dev/null +++ b/Lang/Python/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Python \ No newline at end of file diff --git a/Lang/Python/Doubly-linked-list-Element-definition b/Lang/Python/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..61d95357b0 --- /dev/null +++ b/Lang/Python/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Python \ No newline at end of file diff --git a/Lang/Python/Doubly-linked-list-Element-insertion b/Lang/Python/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..57869e1e79 --- /dev/null +++ b/Lang/Python/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/Python \ No newline at end of file diff --git a/Lang/Python/Doubly-linked-list-Traversal b/Lang/Python/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..e06def2e0a --- /dev/null +++ b/Lang/Python/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Python \ No newline at end of file diff --git a/Lang/Python/Draw-a-cuboid b/Lang/Python/Draw-a-cuboid new file mode 120000 index 0000000000..15c8059ab3 --- /dev/null +++ b/Lang/Python/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Python \ No newline at end of file diff --git a/Lang/Python/Draw-a-sphere b/Lang/Python/Draw-a-sphere new file mode 120000 index 0000000000..fec38ee05a --- /dev/null +++ b/Lang/Python/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Python \ No newline at end of file diff --git a/Lang/Python/Dutch-national-flag-problem b/Lang/Python/Dutch-national-flag-problem new file mode 120000 index 0000000000..29766dcfc4 --- /dev/null +++ b/Lang/Python/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Python \ No newline at end of file diff --git a/Lang/Python/Dynamic-variable-names b/Lang/Python/Dynamic-variable-names new file mode 120000 index 0000000000..4e8a827463 --- /dev/null +++ b/Lang/Python/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Python \ No newline at end of file diff --git a/Lang/Python/Echo-server b/Lang/Python/Echo-server new file mode 120000 index 0000000000..240feb9d93 --- /dev/null +++ b/Lang/Python/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Python \ No newline at end of file diff --git a/Lang/Python/Element-wise-operations b/Lang/Python/Element-wise-operations new file mode 120000 index 0000000000..79817fd650 --- /dev/null +++ b/Lang/Python/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/Python \ No newline at end of file diff --git a/Lang/Python/Empty-directory b/Lang/Python/Empty-directory new file mode 120000 index 0000000000..404cfbfb55 --- /dev/null +++ b/Lang/Python/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Python \ No newline at end of file diff --git a/Lang/Python/Empty-string b/Lang/Python/Empty-string new file mode 120000 index 0000000000..e35e3127a9 --- /dev/null +++ b/Lang/Python/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Python \ No newline at end of file diff --git a/Lang/Python/Enforced-immutability b/Lang/Python/Enforced-immutability new file mode 120000 index 0000000000..3b536663df --- /dev/null +++ b/Lang/Python/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Python \ No newline at end of file diff --git a/Lang/Python/Enumerations b/Lang/Python/Enumerations new file mode 120000 index 0000000000..0f3d377a61 --- /dev/null +++ b/Lang/Python/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Python \ No newline at end of file diff --git a/Lang/Python/Equilibrium-index b/Lang/Python/Equilibrium-index new file mode 120000 index 0000000000..3ceb0e45ce --- /dev/null +++ b/Lang/Python/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Python \ No newline at end of file diff --git a/Lang/Python/Ethiopian-multiplication b/Lang/Python/Ethiopian-multiplication new file mode 120000 index 0000000000..ee611ce8c1 --- /dev/null +++ b/Lang/Python/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Python \ No newline at end of file diff --git a/Lang/Python/Euler-method b/Lang/Python/Euler-method new file mode 120000 index 0000000000..759448faac --- /dev/null +++ b/Lang/Python/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Python \ No newline at end of file diff --git a/Lang/Python/Evaluate-binomial-coefficients b/Lang/Python/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..d1acf49978 --- /dev/null +++ b/Lang/Python/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Python \ No newline at end of file diff --git a/Lang/Python/Even-or-odd b/Lang/Python/Even-or-odd new file mode 120000 index 0000000000..c65df28143 --- /dev/null +++ b/Lang/Python/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Python \ No newline at end of file diff --git a/Lang/Python/Evolutionary-algorithm b/Lang/Python/Evolutionary-algorithm new file mode 120000 index 0000000000..bca31dfb8e --- /dev/null +++ b/Lang/Python/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Python \ No newline at end of file diff --git a/Lang/Python/Exceptions b/Lang/Python/Exceptions new file mode 120000 index 0000000000..b182d0a715 --- /dev/null +++ b/Lang/Python/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Python \ No newline at end of file diff --git a/Lang/Python/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Python/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..76ab50ff28 --- /dev/null +++ b/Lang/Python/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Python \ No newline at end of file diff --git a/Lang/Python/Executable-library b/Lang/Python/Executable-library new file mode 120000 index 0000000000..3dce514a32 --- /dev/null +++ b/Lang/Python/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/Python \ No newline at end of file diff --git a/Lang/Python/Execute-a-system-command b/Lang/Python/Execute-a-system-command new file mode 120000 index 0000000000..8e22c9083a --- /dev/null +++ b/Lang/Python/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Python \ No newline at end of file diff --git a/Lang/Python/Exponentiation-operator b/Lang/Python/Exponentiation-operator new file mode 120000 index 0000000000..14bc621be5 --- /dev/null +++ b/Lang/Python/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Python \ No newline at end of file diff --git a/Lang/Python/Extreme-floating-point-values b/Lang/Python/Extreme-floating-point-values new file mode 120000 index 0000000000..bb5d41726b --- /dev/null +++ b/Lang/Python/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Python \ No newline at end of file diff --git a/Lang/R/Case-sensitivity-of-identifiers b/Lang/R/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..35cdec642b --- /dev/null +++ b/Lang/R/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/R \ No newline at end of file diff --git a/Lang/R/Character-codes b/Lang/R/Character-codes new file mode 120000 index 0000000000..48b5da4356 --- /dev/null +++ b/Lang/R/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/R \ No newline at end of file diff --git a/Lang/R/Cholesky-decomposition b/Lang/R/Cholesky-decomposition new file mode 120000 index 0000000000..144cf5badc --- /dev/null +++ b/Lang/R/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/R \ No newline at end of file diff --git a/Lang/R/Colour-bars-Display b/Lang/R/Colour-bars-Display new file mode 120000 index 0000000000..af6b1d0798 --- /dev/null +++ b/Lang/R/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/R \ No newline at end of file diff --git a/Lang/R/Combinations b/Lang/R/Combinations new file mode 120000 index 0000000000..b8a3106334 --- /dev/null +++ b/Lang/R/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/R \ No newline at end of file diff --git a/Lang/R/Command-line-arguments b/Lang/R/Command-line-arguments new file mode 120000 index 0000000000..1042d94fa3 --- /dev/null +++ b/Lang/R/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/R \ No newline at end of file diff --git a/Lang/R/Compound-data-type b/Lang/R/Compound-data-type new file mode 120000 index 0000000000..5ecb44f0d6 --- /dev/null +++ b/Lang/R/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/R \ No newline at end of file diff --git a/Lang/R/Conditional-structures b/Lang/R/Conditional-structures new file mode 120000 index 0000000000..093bde197a --- /dev/null +++ b/Lang/R/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/R \ No newline at end of file diff --git a/Lang/R/Constrained-random-points-on-a-circle b/Lang/R/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..e4cf0c440b --- /dev/null +++ b/Lang/R/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/R \ No newline at end of file diff --git a/Lang/R/Conways-Game-of-Life b/Lang/R/Conways-Game-of-Life new file mode 120000 index 0000000000..55145c3d31 --- /dev/null +++ b/Lang/R/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/R \ No newline at end of file diff --git a/Lang/R/Create-a-file b/Lang/R/Create-a-file new file mode 120000 index 0000000000..6c11dc5cab --- /dev/null +++ b/Lang/R/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/R \ No newline at end of file diff --git a/Lang/R/Create-a-two-dimensional-array-at-runtime b/Lang/R/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..7073603fef --- /dev/null +++ b/Lang/R/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/R \ No newline at end of file diff --git a/Lang/R/Date-format b/Lang/R/Date-format new file mode 120000 index 0000000000..59fa33e2d2 --- /dev/null +++ b/Lang/R/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/R \ No newline at end of file diff --git a/Lang/R/Date-manipulation b/Lang/R/Date-manipulation new file mode 120000 index 0000000000..81f121a0fd --- /dev/null +++ b/Lang/R/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/R \ No newline at end of file diff --git a/Lang/R/Day-of-the-week b/Lang/R/Day-of-the-week new file mode 120000 index 0000000000..4669f39105 --- /dev/null +++ b/Lang/R/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/R \ No newline at end of file diff --git a/Lang/R/Deconvolution-1D b/Lang/R/Deconvolution-1D new file mode 120000 index 0000000000..20888f27fc --- /dev/null +++ b/Lang/R/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/R \ No newline at end of file diff --git a/Lang/R/Documentation b/Lang/R/Documentation new file mode 120000 index 0000000000..4676f0d93e --- /dev/null +++ b/Lang/R/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/R \ No newline at end of file diff --git a/Lang/R/Dot-product b/Lang/R/Dot-product new file mode 120000 index 0000000000..975ebe11c6 --- /dev/null +++ b/Lang/R/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/R \ No newline at end of file diff --git a/Lang/R/Dynamic-variable-names b/Lang/R/Dynamic-variable-names new file mode 120000 index 0000000000..8c76b14340 --- /dev/null +++ b/Lang/R/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/R \ No newline at end of file diff --git a/Lang/R/Element-wise-operations b/Lang/R/Element-wise-operations new file mode 120000 index 0000000000..7774efa2d7 --- /dev/null +++ b/Lang/R/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/R \ No newline at end of file diff --git a/Lang/R/Empty-string b/Lang/R/Empty-string new file mode 120000 index 0000000000..e4066a42cb --- /dev/null +++ b/Lang/R/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/R \ No newline at end of file diff --git a/Lang/R/Enumerations b/Lang/R/Enumerations new file mode 120000 index 0000000000..1dabf715e0 --- /dev/null +++ b/Lang/R/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/R \ No newline at end of file diff --git a/Lang/R/Ethiopian-multiplication b/Lang/R/Ethiopian-multiplication new file mode 120000 index 0000000000..9732026f09 --- /dev/null +++ b/Lang/R/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/R \ No newline at end of file diff --git a/Lang/R/Evaluate-binomial-coefficients b/Lang/R/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..ba3985b460 --- /dev/null +++ b/Lang/R/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/R \ No newline at end of file diff --git a/Lang/R/Even-or-odd b/Lang/R/Even-or-odd new file mode 120000 index 0000000000..f50216835f --- /dev/null +++ b/Lang/R/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/R \ No newline at end of file diff --git a/Lang/R/Evolutionary-algorithm b/Lang/R/Evolutionary-algorithm new file mode 120000 index 0000000000..c9f1217ba4 --- /dev/null +++ b/Lang/R/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/R \ No newline at end of file diff --git a/Lang/R/Exceptions b/Lang/R/Exceptions new file mode 120000 index 0000000000..2f864fc3fc --- /dev/null +++ b/Lang/R/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/R \ No newline at end of file diff --git a/Lang/R/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/R/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..8699af5139 --- /dev/null +++ b/Lang/R/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/R \ No newline at end of file diff --git a/Lang/R/Execute-a-system-command b/Lang/R/Execute-a-system-command new file mode 120000 index 0000000000..9dc479021d --- /dev/null +++ b/Lang/R/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/R \ No newline at end of file diff --git a/Lang/R/Exponentiation-operator b/Lang/R/Exponentiation-operator new file mode 120000 index 0000000000..a0d6b8fdcc --- /dev/null +++ b/Lang/R/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/R \ No newline at end of file diff --git a/Lang/R/Extend-your-language b/Lang/R/Extend-your-language new file mode 120000 index 0000000000..14e97a8a19 --- /dev/null +++ b/Lang/R/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/R \ No newline at end of file diff --git a/Lang/R/Extreme-floating-point-values b/Lang/R/Extreme-floating-point-values new file mode 120000 index 0000000000..82def8ec91 --- /dev/null +++ b/Lang/R/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/R \ No newline at end of file diff --git a/Lang/REXX/CRC-32 b/Lang/REXX/CRC-32 new file mode 120000 index 0000000000..b5903463ae --- /dev/null +++ b/Lang/REXX/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/REXX \ No newline at end of file diff --git a/Lang/REXX/CSV-to-HTML-translation b/Lang/REXX/CSV-to-HTML-translation new file mode 120000 index 0000000000..153ec5beca --- /dev/null +++ b/Lang/REXX/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/REXX \ No newline at end of file diff --git a/Lang/REXX/Calendar-for-real-programmers b/Lang/REXX/Calendar-for-real-programmers new file mode 120000 index 0000000000..958d1bcc9b --- /dev/null +++ b/Lang/REXX/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/REXX \ No newline at end of file diff --git a/Lang/REXX/Call-a-function b/Lang/REXX/Call-a-function new file mode 120000 index 0000000000..703fe968e0 --- /dev/null +++ b/Lang/REXX/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/REXX \ No newline at end of file diff --git a/Lang/REXX/Carmichael-3-strong-pseudoprimes b/Lang/REXX/Carmichael-3-strong-pseudoprimes new file mode 120000 index 0000000000..a96a2192a8 --- /dev/null +++ b/Lang/REXX/Carmichael-3-strong-pseudoprimes @@ -0,0 +1 @@ +../../Task/Carmichael-3-strong-pseudoprimes/REXX \ No newline at end of file diff --git a/Lang/REXX/Case-sensitivity-of-identifiers b/Lang/REXX/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..1088497ddc --- /dev/null +++ b/Lang/REXX/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/REXX \ No newline at end of file diff --git a/Lang/REXX/Character-codes b/Lang/REXX/Character-codes new file mode 120000 index 0000000000..73292e770d --- /dev/null +++ b/Lang/REXX/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/REXX \ No newline at end of file diff --git a/Lang/REXX/Character-matching b/Lang/REXX/Character-matching new file mode 120000 index 0000000000..5803a04a0f --- /dev/null +++ b/Lang/REXX/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/REXX \ No newline at end of file diff --git a/Lang/REXX/Cholesky-decomposition b/Lang/REXX/Cholesky-decomposition new file mode 120000 index 0000000000..33a9747066 --- /dev/null +++ b/Lang/REXX/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/REXX \ No newline at end of file diff --git a/Lang/REXX/Combinations b/Lang/REXX/Combinations new file mode 120000 index 0000000000..4ade0c93b7 --- /dev/null +++ b/Lang/REXX/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/REXX \ No newline at end of file diff --git a/Lang/REXX/Combinations-with-repetitions b/Lang/REXX/Combinations-with-repetitions new file mode 120000 index 0000000000..af8e85ce2e --- /dev/null +++ b/Lang/REXX/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/REXX \ No newline at end of file diff --git a/Lang/REXX/Command-line-arguments b/Lang/REXX/Command-line-arguments new file mode 120000 index 0000000000..78d94cf95a --- /dev/null +++ b/Lang/REXX/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/REXX \ No newline at end of file diff --git a/Lang/REXX/Compile-time-calculation b/Lang/REXX/Compile-time-calculation new file mode 120000 index 0000000000..aeabafd186 --- /dev/null +++ b/Lang/REXX/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/REXX \ No newline at end of file diff --git a/Lang/REXX/Compound-data-type b/Lang/REXX/Compound-data-type new file mode 120000 index 0000000000..d275c7047c --- /dev/null +++ b/Lang/REXX/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/REXX \ No newline at end of file diff --git a/Lang/REXX/Conditional-structures b/Lang/REXX/Conditional-structures new file mode 120000 index 0000000000..55f5041846 --- /dev/null +++ b/Lang/REXX/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/REXX \ No newline at end of file diff --git a/Lang/REXX/Constrained-random-points-on-a-circle b/Lang/REXX/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..dcf2f12d48 --- /dev/null +++ b/Lang/REXX/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/REXX \ No newline at end of file diff --git a/Lang/REXX/Continued-fraction b/Lang/REXX/Continued-fraction new file mode 120000 index 0000000000..8e60a65966 --- /dev/null +++ b/Lang/REXX/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/REXX \ No newline at end of file diff --git a/Lang/REXX/Continued-fraction-Arithmetic-Construct-from-rational-number b/Lang/REXX/Continued-fraction-Arithmetic-Construct-from-rational-number new file mode 120000 index 0000000000..f99c46a191 --- /dev/null +++ b/Lang/REXX/Continued-fraction-Arithmetic-Construct-from-rational-number @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-Construct-from-rational-number/REXX \ No newline at end of file diff --git a/Lang/REXX/Conways-Game-of-Life b/Lang/REXX/Conways-Game-of-Life new file mode 120000 index 0000000000..51d8241bf3 --- /dev/null +++ b/Lang/REXX/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/REXX \ No newline at end of file diff --git a/Lang/REXX/Count-in-factors b/Lang/REXX/Count-in-factors new file mode 120000 index 0000000000..18ab7bc01e --- /dev/null +++ b/Lang/REXX/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/REXX \ No newline at end of file diff --git a/Lang/REXX/Count-in-octal b/Lang/REXX/Count-in-octal new file mode 120000 index 0000000000..ae2396a59d --- /dev/null +++ b/Lang/REXX/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/REXX \ No newline at end of file diff --git a/Lang/REXX/Count-occurrences-of-a-substring b/Lang/REXX/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..41682f9482 --- /dev/null +++ b/Lang/REXX/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/REXX \ No newline at end of file diff --git a/Lang/REXX/Count-the-coins b/Lang/REXX/Count-the-coins new file mode 120000 index 0000000000..3101255fd4 --- /dev/null +++ b/Lang/REXX/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/REXX \ No newline at end of file diff --git a/Lang/REXX/Create-a-file b/Lang/REXX/Create-a-file new file mode 120000 index 0000000000..2e78523d5f --- /dev/null +++ b/Lang/REXX/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/REXX \ No newline at end of file diff --git a/Lang/REXX/Create-a-two-dimensional-array-at-runtime b/Lang/REXX/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..5ba8beb66c --- /dev/null +++ b/Lang/REXX/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/REXX \ No newline at end of file diff --git a/Lang/REXX/Create-an-HTML-table b/Lang/REXX/Create-an-HTML-table new file mode 120000 index 0000000000..a1d876e0f1 --- /dev/null +++ b/Lang/REXX/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/REXX \ No newline at end of file diff --git a/Lang/REXX/Cut-a-rectangle b/Lang/REXX/Cut-a-rectangle new file mode 120000 index 0000000000..03bd7a1f1d --- /dev/null +++ b/Lang/REXX/Cut-a-rectangle @@ -0,0 +1 @@ +../../Task/Cut-a-rectangle/REXX \ No newline at end of file diff --git a/Lang/REXX/Date-format b/Lang/REXX/Date-format new file mode 120000 index 0000000000..585e48988b --- /dev/null +++ b/Lang/REXX/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/REXX \ No newline at end of file diff --git a/Lang/REXX/Date-manipulation b/Lang/REXX/Date-manipulation new file mode 120000 index 0000000000..bc9439b1a7 --- /dev/null +++ b/Lang/REXX/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/REXX \ No newline at end of file diff --git a/Lang/REXX/Day-of-the-week b/Lang/REXX/Day-of-the-week new file mode 120000 index 0000000000..7f3b2f8d77 --- /dev/null +++ b/Lang/REXX/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/REXX \ No newline at end of file diff --git a/Lang/REXX/Digital-root b/Lang/REXX/Digital-root new file mode 120000 index 0000000000..e1ec1979af --- /dev/null +++ b/Lang/REXX/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/REXX \ No newline at end of file diff --git a/Lang/REXX/Dinesmans-multiple-dwelling-problem b/Lang/REXX/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..9ba2ccd99e --- /dev/null +++ b/Lang/REXX/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/REXX \ No newline at end of file diff --git a/Lang/REXX/Discordian-date b/Lang/REXX/Discordian-date new file mode 120000 index 0000000000..fb26312f27 --- /dev/null +++ b/Lang/REXX/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/REXX \ No newline at end of file diff --git a/Lang/REXX/Documentation b/Lang/REXX/Documentation new file mode 120000 index 0000000000..66eac9b6b6 --- /dev/null +++ b/Lang/REXX/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/REXX \ No newline at end of file diff --git a/Lang/REXX/Dot-product b/Lang/REXX/Dot-product new file mode 120000 index 0000000000..e18f3922fa --- /dev/null +++ b/Lang/REXX/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/REXX \ No newline at end of file diff --git a/Lang/REXX/Doubly-linked-list-Definition b/Lang/REXX/Doubly-linked-list-Definition new file mode 120000 index 0000000000..a53cde7eb2 --- /dev/null +++ b/Lang/REXX/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/REXX \ No newline at end of file diff --git a/Lang/REXX/Doubly-linked-list-Element-definition b/Lang/REXX/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..723a17743c --- /dev/null +++ b/Lang/REXX/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/REXX \ No newline at end of file diff --git a/Lang/REXX/Doubly-linked-list-Element-insertion b/Lang/REXX/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..f065698a05 --- /dev/null +++ b/Lang/REXX/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/REXX \ No newline at end of file diff --git a/Lang/REXX/Doubly-linked-list-Traversal b/Lang/REXX/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..d56352da7b --- /dev/null +++ b/Lang/REXX/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/REXX \ No newline at end of file diff --git a/Lang/REXX/Draw-a-cuboid b/Lang/REXX/Draw-a-cuboid new file mode 120000 index 0000000000..5e7b3cfbde --- /dev/null +++ b/Lang/REXX/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/REXX \ No newline at end of file diff --git a/Lang/REXX/Draw-a-sphere b/Lang/REXX/Draw-a-sphere new file mode 120000 index 0000000000..bd3fa49c58 --- /dev/null +++ b/Lang/REXX/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/REXX \ No newline at end of file diff --git a/Lang/REXX/Dutch-national-flag-problem b/Lang/REXX/Dutch-national-flag-problem new file mode 120000 index 0000000000..d853a24449 --- /dev/null +++ b/Lang/REXX/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/REXX \ No newline at end of file diff --git a/Lang/REXX/Dynamic-variable-names b/Lang/REXX/Dynamic-variable-names new file mode 120000 index 0000000000..3624a123d3 --- /dev/null +++ b/Lang/REXX/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/REXX \ No newline at end of file diff --git a/Lang/REXX/Element-wise-operations b/Lang/REXX/Element-wise-operations new file mode 120000 index 0000000000..d9b9fc89d2 --- /dev/null +++ b/Lang/REXX/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/REXX \ No newline at end of file diff --git a/Lang/REXX/Empty-program b/Lang/REXX/Empty-program new file mode 120000 index 0000000000..2c90dd6866 --- /dev/null +++ b/Lang/REXX/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/REXX \ No newline at end of file diff --git a/Lang/REXX/Empty-string b/Lang/REXX/Empty-string new file mode 120000 index 0000000000..9a33d94e27 --- /dev/null +++ b/Lang/REXX/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/REXX \ No newline at end of file diff --git a/Lang/REXX/Enumerations b/Lang/REXX/Enumerations new file mode 120000 index 0000000000..ed6c27301d --- /dev/null +++ b/Lang/REXX/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/REXX \ No newline at end of file diff --git a/Lang/REXX/Equilibrium-index b/Lang/REXX/Equilibrium-index new file mode 120000 index 0000000000..373b8079aa --- /dev/null +++ b/Lang/REXX/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/REXX \ No newline at end of file diff --git a/Lang/REXX/Ethiopian-multiplication b/Lang/REXX/Ethiopian-multiplication new file mode 120000 index 0000000000..507913245f --- /dev/null +++ b/Lang/REXX/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/REXX \ No newline at end of file diff --git a/Lang/REXX/Evaluate-binomial-coefficients b/Lang/REXX/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..f378d0afd0 --- /dev/null +++ b/Lang/REXX/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/REXX \ No newline at end of file diff --git a/Lang/REXX/Even-or-odd b/Lang/REXX/Even-or-odd new file mode 120000 index 0000000000..d3559fe1a0 --- /dev/null +++ b/Lang/REXX/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/REXX \ No newline at end of file diff --git a/Lang/REXX/Evolutionary-algorithm b/Lang/REXX/Evolutionary-algorithm new file mode 120000 index 0000000000..ecdc5b9d4e --- /dev/null +++ b/Lang/REXX/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/REXX \ No newline at end of file diff --git a/Lang/REXX/Executable-library b/Lang/REXX/Executable-library new file mode 120000 index 0000000000..cff9c58c93 --- /dev/null +++ b/Lang/REXX/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/REXX \ No newline at end of file diff --git a/Lang/REXX/Execute-HQ9+ b/Lang/REXX/Execute-HQ9+ new file mode 120000 index 0000000000..35c2ffd5f7 --- /dev/null +++ b/Lang/REXX/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/REXX \ No newline at end of file diff --git a/Lang/REXX/Execute-a-system-command b/Lang/REXX/Execute-a-system-command new file mode 120000 index 0000000000..1bce5e0f67 --- /dev/null +++ b/Lang/REXX/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/REXX \ No newline at end of file diff --git a/Lang/REXX/Exponentiation-operator b/Lang/REXX/Exponentiation-operator new file mode 120000 index 0000000000..22200afd39 --- /dev/null +++ b/Lang/REXX/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/REXX \ No newline at end of file diff --git a/Lang/Racket/CSV-to-HTML-translation b/Lang/Racket/CSV-to-HTML-translation new file mode 120000 index 0000000000..59b0d79e42 --- /dev/null +++ b/Lang/Racket/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Racket \ No newline at end of file diff --git a/Lang/Racket/Call-a-foreign-language-function b/Lang/Racket/Call-a-foreign-language-function new file mode 120000 index 0000000000..421885367f --- /dev/null +++ b/Lang/Racket/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Racket \ No newline at end of file diff --git a/Lang/Racket/Call-a-function-in-a-shared-library b/Lang/Racket/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..f879c653e5 --- /dev/null +++ b/Lang/Racket/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Racket \ No newline at end of file diff --git a/Lang/Racket/Call-an-object-method b/Lang/Racket/Call-an-object-method new file mode 120000 index 0000000000..42f09aa54c --- /dev/null +++ b/Lang/Racket/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/Racket \ No newline at end of file diff --git a/Lang/Racket/Case-sensitivity-of-identifiers b/Lang/Racket/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..d92faf4fa6 --- /dev/null +++ b/Lang/Racket/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Racket \ No newline at end of file diff --git a/Lang/Racket/Character-matching b/Lang/Racket/Character-matching new file mode 120000 index 0000000000..6aa960b01e --- /dev/null +++ b/Lang/Racket/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Racket \ No newline at end of file diff --git a/Lang/Racket/Color-quantization b/Lang/Racket/Color-quantization new file mode 120000 index 0000000000..be2e2e60ad --- /dev/null +++ b/Lang/Racket/Color-quantization @@ -0,0 +1 @@ +../../Task/Color-quantization/Racket \ No newline at end of file diff --git a/Lang/Racket/Command-line-arguments b/Lang/Racket/Command-line-arguments new file mode 120000 index 0000000000..3b3a638d6f --- /dev/null +++ b/Lang/Racket/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Racket \ No newline at end of file diff --git a/Lang/Racket/Compile-time-calculation b/Lang/Racket/Compile-time-calculation new file mode 120000 index 0000000000..8820122954 --- /dev/null +++ b/Lang/Racket/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Racket \ No newline at end of file diff --git a/Lang/Racket/Compound-data-type b/Lang/Racket/Compound-data-type new file mode 120000 index 0000000000..0220e4f07b --- /dev/null +++ b/Lang/Racket/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Racket \ No newline at end of file diff --git a/Lang/Racket/Concurrent-computing b/Lang/Racket/Concurrent-computing new file mode 120000 index 0000000000..c23003c44b --- /dev/null +++ b/Lang/Racket/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Racket \ No newline at end of file diff --git a/Lang/Racket/Conways-Game-of-Life b/Lang/Racket/Conways-Game-of-Life new file mode 120000 index 0000000000..8431bcf514 --- /dev/null +++ b/Lang/Racket/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Racket \ No newline at end of file diff --git a/Lang/Racket/Count-in-factors b/Lang/Racket/Count-in-factors new file mode 120000 index 0000000000..eb090f372b --- /dev/null +++ b/Lang/Racket/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Racket \ No newline at end of file diff --git a/Lang/Racket/Count-in-octal b/Lang/Racket/Count-in-octal new file mode 120000 index 0000000000..efa2e271ec --- /dev/null +++ b/Lang/Racket/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Racket \ No newline at end of file diff --git a/Lang/Racket/Create-a-file b/Lang/Racket/Create-a-file new file mode 120000 index 0000000000..0c3239a3e9 --- /dev/null +++ b/Lang/Racket/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Racket \ No newline at end of file diff --git a/Lang/Racket/Create-an-HTML-table b/Lang/Racket/Create-an-HTML-table new file mode 120000 index 0000000000..2ff34f2241 --- /dev/null +++ b/Lang/Racket/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Racket \ No newline at end of file diff --git a/Lang/Racket/DNS-query b/Lang/Racket/DNS-query new file mode 120000 index 0000000000..0392c5468a --- /dev/null +++ b/Lang/Racket/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/Racket \ No newline at end of file diff --git a/Lang/Racket/Date-format b/Lang/Racket/Date-format new file mode 120000 index 0000000000..3165c6b840 --- /dev/null +++ b/Lang/Racket/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Racket \ No newline at end of file diff --git a/Lang/Racket/Digital-root b/Lang/Racket/Digital-root new file mode 120000 index 0000000000..5380f3a7bc --- /dev/null +++ b/Lang/Racket/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/Racket \ No newline at end of file diff --git a/Lang/Racket/Documentation b/Lang/Racket/Documentation new file mode 120000 index 0000000000..54b7609535 --- /dev/null +++ b/Lang/Racket/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Racket \ No newline at end of file diff --git a/Lang/Racket/Dot-product b/Lang/Racket/Dot-product new file mode 120000 index 0000000000..832916d1c7 --- /dev/null +++ b/Lang/Racket/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Racket \ No newline at end of file diff --git a/Lang/Racket/Draw-a-sphere b/Lang/Racket/Draw-a-sphere new file mode 120000 index 0000000000..82e913d0b3 --- /dev/null +++ b/Lang/Racket/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Racket \ No newline at end of file diff --git a/Lang/Racket/Echo-server b/Lang/Racket/Echo-server new file mode 120000 index 0000000000..413641084b --- /dev/null +++ b/Lang/Racket/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Racket \ No newline at end of file diff --git a/Lang/Racket/Empty-directory b/Lang/Racket/Empty-directory new file mode 120000 index 0000000000..7bc60c8f25 --- /dev/null +++ b/Lang/Racket/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Racket \ No newline at end of file diff --git a/Lang/Racket/Empty-program b/Lang/Racket/Empty-program new file mode 120000 index 0000000000..f52cd607cc --- /dev/null +++ b/Lang/Racket/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Racket \ No newline at end of file diff --git a/Lang/Racket/Empty-string b/Lang/Racket/Empty-string new file mode 120000 index 0000000000..7faad7e4f4 --- /dev/null +++ b/Lang/Racket/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Racket \ No newline at end of file diff --git a/Lang/Racket/Evaluate-binomial-coefficients b/Lang/Racket/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..e6f617fe31 --- /dev/null +++ b/Lang/Racket/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Racket \ No newline at end of file diff --git a/Lang/Racket/Even-or-odd b/Lang/Racket/Even-or-odd new file mode 120000 index 0000000000..e7ecc11148 --- /dev/null +++ b/Lang/Racket/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Racket \ No newline at end of file diff --git a/Lang/Racket/Exceptions b/Lang/Racket/Exceptions new file mode 120000 index 0000000000..23c762bfda --- /dev/null +++ b/Lang/Racket/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Racket \ No newline at end of file diff --git a/Lang/Ruby/CRC-32 b/Lang/Ruby/CRC-32 new file mode 120000 index 0000000000..9bf2bbe4d8 --- /dev/null +++ b/Lang/Ruby/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Ruby \ No newline at end of file diff --git a/Lang/Ruby/CSV-to-HTML-translation b/Lang/Ruby/CSV-to-HTML-translation new file mode 120000 index 0000000000..f13a0452ca --- /dev/null +++ b/Lang/Ruby/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Calendar-for-real-programmers b/Lang/Ruby/Calendar-for-real-programmers new file mode 120000 index 0000000000..3da8978d69 --- /dev/null +++ b/Lang/Ruby/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Call-a-foreign-language-function b/Lang/Ruby/Call-a-foreign-language-function new file mode 120000 index 0000000000..9f48eb7470 --- /dev/null +++ b/Lang/Ruby/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Call-a-function-in-a-shared-library b/Lang/Ruby/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..9e2f408350 --- /dev/null +++ b/Lang/Ruby/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Call-an-object-method b/Lang/Ruby/Call-an-object-method new file mode 120000 index 0000000000..a90abebf2a --- /dev/null +++ b/Lang/Ruby/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Carmichael-3-strong-pseudoprimes b/Lang/Ruby/Carmichael-3-strong-pseudoprimes new file mode 120000 index 0000000000..a2ca8953c1 --- /dev/null +++ b/Lang/Ruby/Carmichael-3-strong-pseudoprimes @@ -0,0 +1 @@ +../../Task/Carmichael-3-strong-pseudoprimes/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Case-sensitivity-of-identifiers b/Lang/Ruby/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..21eb108f72 --- /dev/null +++ b/Lang/Ruby/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Character-codes b/Lang/Ruby/Character-codes new file mode 120000 index 0000000000..eb45df112f --- /dev/null +++ b/Lang/Ruby/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Character-matching b/Lang/Ruby/Character-matching new file mode 120000 index 0000000000..34ddb8d8a7 --- /dev/null +++ b/Lang/Ruby/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Chat-server b/Lang/Ruby/Chat-server new file mode 120000 index 0000000000..a22d47a467 --- /dev/null +++ b/Lang/Ruby/Chat-server @@ -0,0 +1 @@ +../../Task/Chat-server/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Cholesky-decomposition b/Lang/Ruby/Cholesky-decomposition new file mode 120000 index 0000000000..dcfd1c4bed --- /dev/null +++ b/Lang/Ruby/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Combinations b/Lang/Ruby/Combinations new file mode 120000 index 0000000000..7044845158 --- /dev/null +++ b/Lang/Ruby/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Combinations-with-repetitions b/Lang/Ruby/Combinations-with-repetitions new file mode 120000 index 0000000000..07fccb4891 --- /dev/null +++ b/Lang/Ruby/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Command-line-arguments b/Lang/Ruby/Command-line-arguments new file mode 120000 index 0000000000..985edf9041 --- /dev/null +++ b/Lang/Ruby/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Compound-data-type b/Lang/Ruby/Compound-data-type new file mode 120000 index 0000000000..ff9c2dd57e --- /dev/null +++ b/Lang/Ruby/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Concurrent-computing b/Lang/Ruby/Concurrent-computing new file mode 120000 index 0000000000..22742061a0 --- /dev/null +++ b/Lang/Ruby/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Constrained-random-points-on-a-circle b/Lang/Ruby/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..19f7c310ec --- /dev/null +++ b/Lang/Ruby/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Continued-fraction b/Lang/Ruby/Continued-fraction new file mode 120000 index 0000000000..a700ce9579 --- /dev/null +++ b/Lang/Ruby/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Continued-fraction-Arithmetic-Construct-from-rational-number b/Lang/Ruby/Continued-fraction-Arithmetic-Construct-from-rational-number new file mode 120000 index 0000000000..568e3346e5 --- /dev/null +++ b/Lang/Ruby/Continued-fraction-Arithmetic-Construct-from-rational-number @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) b/Lang/Ruby/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) new file mode 120000 index 0000000000..d5c43ece95 --- /dev/null +++ b/Lang/Ruby/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Conways-Game-of-Life b/Lang/Ruby/Conways-Game-of-Life new file mode 120000 index 0000000000..50f8f50c84 --- /dev/null +++ b/Lang/Ruby/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Count-in-factors b/Lang/Ruby/Count-in-factors new file mode 120000 index 0000000000..475291f054 --- /dev/null +++ b/Lang/Ruby/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Count-in-octal b/Lang/Ruby/Count-in-octal new file mode 120000 index 0000000000..d204950a95 --- /dev/null +++ b/Lang/Ruby/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Count-occurrences-of-a-substring b/Lang/Ruby/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..9efb3b3692 --- /dev/null +++ b/Lang/Ruby/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Count-the-coins b/Lang/Ruby/Count-the-coins new file mode 120000 index 0000000000..b8f487434f --- /dev/null +++ b/Lang/Ruby/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Create-a-file b/Lang/Ruby/Create-a-file new file mode 120000 index 0000000000..9aad09719d --- /dev/null +++ b/Lang/Ruby/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Create-a-two-dimensional-array-at-runtime b/Lang/Ruby/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..92bd7bb35a --- /dev/null +++ b/Lang/Ruby/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Create-an-HTML-table b/Lang/Ruby/Create-an-HTML-table new file mode 120000 index 0000000000..1cd1cdbc36 --- /dev/null +++ b/Lang/Ruby/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Date-format b/Lang/Ruby/Date-format new file mode 120000 index 0000000000..3ec214955a --- /dev/null +++ b/Lang/Ruby/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Date-manipulation b/Lang/Ruby/Date-manipulation new file mode 120000 index 0000000000..cc8dbcd82c --- /dev/null +++ b/Lang/Ruby/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Day-of-the-week b/Lang/Ruby/Day-of-the-week new file mode 120000 index 0000000000..17ba1e7b20 --- /dev/null +++ b/Lang/Ruby/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Deal-cards-for-FreeCell b/Lang/Ruby/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..0143f29eaf --- /dev/null +++ b/Lang/Ruby/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Deepcopy b/Lang/Ruby/Deepcopy new file mode 120000 index 0000000000..74dcc5af17 --- /dev/null +++ b/Lang/Ruby/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Determine-if-only-one-instance-is-running b/Lang/Ruby/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..c83e2ff65a --- /dev/null +++ b/Lang/Ruby/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Dinesmans-multiple-dwelling-problem b/Lang/Ruby/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..8dec5b64ae --- /dev/null +++ b/Lang/Ruby/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Dining-philosophers b/Lang/Ruby/Dining-philosophers new file mode 120000 index 0000000000..98b6023e2c --- /dev/null +++ b/Lang/Ruby/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Discordian-date b/Lang/Ruby/Discordian-date new file mode 120000 index 0000000000..9f51aa48e5 --- /dev/null +++ b/Lang/Ruby/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Distributed-programming b/Lang/Ruby/Distributed-programming new file mode 120000 index 0000000000..d6074359fb --- /dev/null +++ b/Lang/Ruby/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Documentation b/Lang/Ruby/Documentation new file mode 120000 index 0000000000..e27aabc452 --- /dev/null +++ b/Lang/Ruby/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Dot-product b/Lang/Ruby/Dot-product new file mode 120000 index 0000000000..ecb0368135 --- /dev/null +++ b/Lang/Ruby/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Doubly-linked-list-Element-definition b/Lang/Ruby/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..48d84d38b7 --- /dev/null +++ b/Lang/Ruby/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Doubly-linked-list-Element-insertion b/Lang/Ruby/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..405ddbf0c1 --- /dev/null +++ b/Lang/Ruby/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Doubly-linked-list-Traversal b/Lang/Ruby/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..dd024d4f2b --- /dev/null +++ b/Lang/Ruby/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Draw-a-sphere b/Lang/Ruby/Draw-a-sphere new file mode 120000 index 0000000000..b18e548177 --- /dev/null +++ b/Lang/Ruby/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Dutch-national-flag-problem b/Lang/Ruby/Dutch-national-flag-problem new file mode 120000 index 0000000000..b500277e2d --- /dev/null +++ b/Lang/Ruby/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Dynamic-variable-names b/Lang/Ruby/Dynamic-variable-names new file mode 120000 index 0000000000..ad7a9c8011 --- /dev/null +++ b/Lang/Ruby/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Echo-server b/Lang/Ruby/Echo-server new file mode 120000 index 0000000000..e59d0f62b4 --- /dev/null +++ b/Lang/Ruby/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Empty-directory b/Lang/Ruby/Empty-directory new file mode 120000 index 0000000000..23dd97b7e1 --- /dev/null +++ b/Lang/Ruby/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Empty-program b/Lang/Ruby/Empty-program new file mode 120000 index 0000000000..c1f1d0f264 --- /dev/null +++ b/Lang/Ruby/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Empty-string b/Lang/Ruby/Empty-string new file mode 120000 index 0000000000..5284ddb251 --- /dev/null +++ b/Lang/Ruby/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Enforced-immutability b/Lang/Ruby/Enforced-immutability new file mode 120000 index 0000000000..378ebe9f66 --- /dev/null +++ b/Lang/Ruby/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Enumerations b/Lang/Ruby/Enumerations new file mode 120000 index 0000000000..dfdfa66f9d --- /dev/null +++ b/Lang/Ruby/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Equilibrium-index b/Lang/Ruby/Equilibrium-index new file mode 120000 index 0000000000..6fc319d7e9 --- /dev/null +++ b/Lang/Ruby/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Ethiopian-multiplication b/Lang/Ruby/Ethiopian-multiplication new file mode 120000 index 0000000000..4d72a488b6 --- /dev/null +++ b/Lang/Ruby/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Euler-method b/Lang/Ruby/Euler-method new file mode 120000 index 0000000000..fc5f18b156 --- /dev/null +++ b/Lang/Ruby/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Evaluate-binomial-coefficients b/Lang/Ruby/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..2c618b4c0e --- /dev/null +++ b/Lang/Ruby/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Even-or-odd b/Lang/Ruby/Even-or-odd new file mode 120000 index 0000000000..71795ef0a3 --- /dev/null +++ b/Lang/Ruby/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Evolutionary-algorithm b/Lang/Ruby/Evolutionary-algorithm new file mode 120000 index 0000000000..72e3d3fdb7 --- /dev/null +++ b/Lang/Ruby/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Exceptions b/Lang/Ruby/Exceptions new file mode 120000 index 0000000000..9a9639c03c --- /dev/null +++ b/Lang/Ruby/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Ruby/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..51830c6681 --- /dev/null +++ b/Lang/Ruby/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Executable-library b/Lang/Ruby/Executable-library new file mode 120000 index 0000000000..ac6e9e3fb4 --- /dev/null +++ b/Lang/Ruby/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Execute-a-system-command b/Lang/Ruby/Execute-a-system-command new file mode 120000 index 0000000000..44862e88a9 --- /dev/null +++ b/Lang/Ruby/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Exponentiation-operator b/Lang/Ruby/Exponentiation-operator new file mode 120000 index 0000000000..76cb70cf1d --- /dev/null +++ b/Lang/Ruby/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Extend-your-language b/Lang/Ruby/Extend-your-language new file mode 120000 index 0000000000..4053ef696b --- /dev/null +++ b/Lang/Ruby/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Extreme-floating-point-values b/Lang/Ruby/Extreme-floating-point-values new file mode 120000 index 0000000000..7c085258bc --- /dev/null +++ b/Lang/Ruby/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Ruby \ No newline at end of file diff --git a/Lang/SNUSP/Conditional-structures b/Lang/SNUSP/Conditional-structures new file mode 120000 index 0000000000..d07ab1fd83 --- /dev/null +++ b/Lang/SNUSP/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/SNUSP \ No newline at end of file diff --git a/Lang/SNUSP/Ethiopian-multiplication b/Lang/SNUSP/Ethiopian-multiplication new file mode 120000 index 0000000000..47162585ea --- /dev/null +++ b/Lang/SNUSP/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/SNUSP \ No newline at end of file diff --git a/Lang/SNUSP/Even-or-odd b/Lang/SNUSP/Even-or-odd new file mode 120000 index 0000000000..44a903eafa --- /dev/null +++ b/Lang/SNUSP/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/SNUSP \ No newline at end of file diff --git a/Lang/Sather/Case-sensitivity-of-identifiers b/Lang/Sather/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..93681ae670 --- /dev/null +++ b/Lang/Sather/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Sather \ No newline at end of file diff --git a/Lang/Sather/Character-codes b/Lang/Sather/Character-codes new file mode 120000 index 0000000000..abc5d89dac --- /dev/null +++ b/Lang/Sather/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Sather \ No newline at end of file diff --git a/Lang/Sather/Command-line-arguments b/Lang/Sather/Command-line-arguments new file mode 120000 index 0000000000..237726b586 --- /dev/null +++ b/Lang/Sather/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Sather \ No newline at end of file diff --git a/Lang/Sather/Conditional-structures b/Lang/Sather/Conditional-structures new file mode 120000 index 0000000000..15c9537fb5 --- /dev/null +++ b/Lang/Sather/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Sather \ No newline at end of file diff --git a/Lang/Sather/Constrained-genericity b/Lang/Sather/Constrained-genericity new file mode 120000 index 0000000000..8d08ed445b --- /dev/null +++ b/Lang/Sather/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/Sather \ No newline at end of file diff --git a/Lang/Sather/Dot-product b/Lang/Sather/Dot-product new file mode 120000 index 0000000000..217a861296 --- /dev/null +++ b/Lang/Sather/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Sather \ No newline at end of file diff --git a/Lang/Scala/CSV-to-HTML-translation b/Lang/Scala/CSV-to-HTML-translation new file mode 120000 index 0000000000..d8589b7a8c --- /dev/null +++ b/Lang/Scala/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Scala \ No newline at end of file diff --git a/Lang/Scala/Case-sensitivity-of-identifiers b/Lang/Scala/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..3398c9d6f7 --- /dev/null +++ b/Lang/Scala/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Scala \ No newline at end of file diff --git a/Lang/Scala/Character-codes b/Lang/Scala/Character-codes new file mode 120000 index 0000000000..e82bda89eb --- /dev/null +++ b/Lang/Scala/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Scala \ No newline at end of file diff --git a/Lang/Scala/Character-matching b/Lang/Scala/Character-matching new file mode 120000 index 0000000000..05767cdec2 --- /dev/null +++ b/Lang/Scala/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Scala \ No newline at end of file diff --git a/Lang/Scala/Colour-bars-Display b/Lang/Scala/Colour-bars-Display new file mode 120000 index 0000000000..61a4c75156 --- /dev/null +++ b/Lang/Scala/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/Scala \ No newline at end of file diff --git a/Lang/Scala/Combinations b/Lang/Scala/Combinations new file mode 120000 index 0000000000..3fc9c4fe2e --- /dev/null +++ b/Lang/Scala/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Scala \ No newline at end of file diff --git a/Lang/Scala/Combinations-with-repetitions b/Lang/Scala/Combinations-with-repetitions new file mode 120000 index 0000000000..f2a01f0acf --- /dev/null +++ b/Lang/Scala/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Scala \ No newline at end of file diff --git a/Lang/Scala/Command-line-arguments b/Lang/Scala/Command-line-arguments new file mode 120000 index 0000000000..6202858cef --- /dev/null +++ b/Lang/Scala/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Scala \ No newline at end of file diff --git a/Lang/Scala/Compound-data-type b/Lang/Scala/Compound-data-type new file mode 120000 index 0000000000..0e5880daa5 --- /dev/null +++ b/Lang/Scala/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Scala \ No newline at end of file diff --git a/Lang/Scala/Concurrent-computing b/Lang/Scala/Concurrent-computing new file mode 120000 index 0000000000..972abf43db --- /dev/null +++ b/Lang/Scala/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Scala \ No newline at end of file diff --git a/Lang/Scala/Constrained-genericity b/Lang/Scala/Constrained-genericity new file mode 120000 index 0000000000..0a401acbac --- /dev/null +++ b/Lang/Scala/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/Scala \ No newline at end of file diff --git a/Lang/Scala/Continued-fraction b/Lang/Scala/Continued-fraction new file mode 120000 index 0000000000..1c70bed51f --- /dev/null +++ b/Lang/Scala/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Scala \ No newline at end of file diff --git a/Lang/Scala/Count-in-octal b/Lang/Scala/Count-in-octal new file mode 120000 index 0000000000..aadff8481e --- /dev/null +++ b/Lang/Scala/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Scala \ No newline at end of file diff --git a/Lang/Scala/Count-occurrences-of-a-substring b/Lang/Scala/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..bbc55e78bb --- /dev/null +++ b/Lang/Scala/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Scala \ No newline at end of file diff --git a/Lang/Scala/Count-the-coins b/Lang/Scala/Count-the-coins new file mode 120000 index 0000000000..bb4e81e6ba --- /dev/null +++ b/Lang/Scala/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Scala \ No newline at end of file diff --git a/Lang/Scala/Create-a-two-dimensional-array-at-runtime b/Lang/Scala/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..4abdc07820 --- /dev/null +++ b/Lang/Scala/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Scala \ No newline at end of file diff --git a/Lang/Scala/Date-format b/Lang/Scala/Date-format new file mode 120000 index 0000000000..a726c8bac7 --- /dev/null +++ b/Lang/Scala/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Scala \ No newline at end of file diff --git a/Lang/Scala/Date-manipulation b/Lang/Scala/Date-manipulation new file mode 120000 index 0000000000..6ff6d66173 --- /dev/null +++ b/Lang/Scala/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Scala \ No newline at end of file diff --git a/Lang/Scala/Day-of-the-week b/Lang/Scala/Day-of-the-week new file mode 120000 index 0000000000..5502b15457 --- /dev/null +++ b/Lang/Scala/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Scala \ No newline at end of file diff --git a/Lang/Scala/Digital-root b/Lang/Scala/Digital-root new file mode 120000 index 0000000000..62eb815d90 --- /dev/null +++ b/Lang/Scala/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/Scala \ No newline at end of file diff --git a/Lang/Scala/Dinesmans-multiple-dwelling-problem b/Lang/Scala/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..31e2826c26 --- /dev/null +++ b/Lang/Scala/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Scala \ No newline at end of file diff --git a/Lang/Scala/Discordian-date b/Lang/Scala/Discordian-date new file mode 120000 index 0000000000..a6abccd665 --- /dev/null +++ b/Lang/Scala/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/Scala \ No newline at end of file diff --git a/Lang/Scala/Dot-product b/Lang/Scala/Dot-product new file mode 120000 index 0000000000..bed785d33d --- /dev/null +++ b/Lang/Scala/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Scala \ No newline at end of file diff --git a/Lang/Scala/Empty-directory b/Lang/Scala/Empty-directory new file mode 120000 index 0000000000..117112d31b --- /dev/null +++ b/Lang/Scala/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Scala \ No newline at end of file diff --git a/Lang/Scala/Empty-program b/Lang/Scala/Empty-program new file mode 120000 index 0000000000..69b5c89b44 --- /dev/null +++ b/Lang/Scala/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Scala \ No newline at end of file diff --git a/Lang/Scala/Empty-string b/Lang/Scala/Empty-string new file mode 120000 index 0000000000..8a77c07de2 --- /dev/null +++ b/Lang/Scala/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Scala \ No newline at end of file diff --git a/Lang/Scala/Enforced-immutability b/Lang/Scala/Enforced-immutability new file mode 120000 index 0000000000..18836ead4c --- /dev/null +++ b/Lang/Scala/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Scala \ No newline at end of file diff --git a/Lang/Scala/Enumerations b/Lang/Scala/Enumerations new file mode 120000 index 0000000000..04f7b624e1 --- /dev/null +++ b/Lang/Scala/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Scala \ No newline at end of file diff --git a/Lang/Scala/Ethiopian-multiplication b/Lang/Scala/Ethiopian-multiplication new file mode 120000 index 0000000000..0bb7b64231 --- /dev/null +++ b/Lang/Scala/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Scala \ No newline at end of file diff --git a/Lang/Scala/Euler-method b/Lang/Scala/Euler-method new file mode 120000 index 0000000000..e3f94418d5 --- /dev/null +++ b/Lang/Scala/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Scala \ No newline at end of file diff --git a/Lang/Scala/Evaluate-binomial-coefficients b/Lang/Scala/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..9ead31d9c7 --- /dev/null +++ b/Lang/Scala/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Scala \ No newline at end of file diff --git a/Lang/Scala/Even-or-odd b/Lang/Scala/Even-or-odd new file mode 120000 index 0000000000..c447c4af42 --- /dev/null +++ b/Lang/Scala/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Scala \ No newline at end of file diff --git a/Lang/Scala/Evolutionary-algorithm b/Lang/Scala/Evolutionary-algorithm new file mode 120000 index 0000000000..5423c588d6 --- /dev/null +++ b/Lang/Scala/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Scala \ No newline at end of file diff --git a/Lang/Scala/Execute-HQ9+ b/Lang/Scala/Execute-HQ9+ new file mode 120000 index 0000000000..403b643bfd --- /dev/null +++ b/Lang/Scala/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/Scala \ No newline at end of file diff --git a/Lang/Scala/Execute-a-system-command b/Lang/Scala/Execute-a-system-command new file mode 120000 index 0000000000..657e06b610 --- /dev/null +++ b/Lang/Scala/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Scala \ No newline at end of file diff --git a/Lang/Scala/Exponentiation-operator b/Lang/Scala/Exponentiation-operator new file mode 120000 index 0000000000..50c424ea52 --- /dev/null +++ b/Lang/Scala/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Scala \ No newline at end of file diff --git a/Lang/Scala/Extend-your-language b/Lang/Scala/Extend-your-language new file mode 120000 index 0000000000..7bb2189567 --- /dev/null +++ b/Lang/Scala/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Scala \ No newline at end of file diff --git a/Lang/Scheme/Case-sensitivity-of-identifiers b/Lang/Scheme/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..840e1a7dbc --- /dev/null +++ b/Lang/Scheme/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Character-codes b/Lang/Scheme/Character-codes new file mode 120000 index 0000000000..5aeda2896c --- /dev/null +++ b/Lang/Scheme/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Combinations b/Lang/Scheme/Combinations new file mode 120000 index 0000000000..9c729434ec --- /dev/null +++ b/Lang/Scheme/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Combinations-with-repetitions b/Lang/Scheme/Combinations-with-repetitions new file mode 120000 index 0000000000..78b18b6921 --- /dev/null +++ b/Lang/Scheme/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Command-line-arguments b/Lang/Scheme/Command-line-arguments new file mode 120000 index 0000000000..c2aa874f81 --- /dev/null +++ b/Lang/Scheme/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Compound-data-type b/Lang/Scheme/Compound-data-type new file mode 120000 index 0000000000..a429dc1080 --- /dev/null +++ b/Lang/Scheme/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Concurrent-computing b/Lang/Scheme/Concurrent-computing new file mode 120000 index 0000000000..af684210c4 --- /dev/null +++ b/Lang/Scheme/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Conditional-structures b/Lang/Scheme/Conditional-structures new file mode 120000 index 0000000000..9cb8f61c64 --- /dev/null +++ b/Lang/Scheme/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Conways-Game-of-Life b/Lang/Scheme/Conways-Game-of-Life new file mode 120000 index 0000000000..4f7a5a1c3d --- /dev/null +++ b/Lang/Scheme/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Count-in-factors b/Lang/Scheme/Count-in-factors new file mode 120000 index 0000000000..23f183c073 --- /dev/null +++ b/Lang/Scheme/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Count-in-octal b/Lang/Scheme/Count-in-octal new file mode 120000 index 0000000000..a4e82db656 --- /dev/null +++ b/Lang/Scheme/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Count-the-coins b/Lang/Scheme/Count-the-coins new file mode 120000 index 0000000000..d5b7db36aa --- /dev/null +++ b/Lang/Scheme/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Create-a-file b/Lang/Scheme/Create-a-file new file mode 120000 index 0000000000..277ce6f45e --- /dev/null +++ b/Lang/Scheme/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Create-an-HTML-table b/Lang/Scheme/Create-an-HTML-table new file mode 120000 index 0000000000..7d0c8dce02 --- /dev/null +++ b/Lang/Scheme/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Scheme \ No newline at end of file diff --git a/Lang/Scheme/DNS-query b/Lang/Scheme/DNS-query new file mode 120000 index 0000000000..f1bee3dfcb --- /dev/null +++ b/Lang/Scheme/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Day-of-the-week b/Lang/Scheme/Day-of-the-week new file mode 120000 index 0000000000..a0dfe2ecd7 --- /dev/null +++ b/Lang/Scheme/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Dot-product b/Lang/Scheme/Dot-product new file mode 120000 index 0000000000..6c4df7bd5a --- /dev/null +++ b/Lang/Scheme/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Dynamic-variable-names b/Lang/Scheme/Dynamic-variable-names new file mode 120000 index 0000000000..887054e242 --- /dev/null +++ b/Lang/Scheme/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Echo-server b/Lang/Scheme/Echo-server new file mode 120000 index 0000000000..997950c156 --- /dev/null +++ b/Lang/Scheme/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Empty-program b/Lang/Scheme/Empty-program new file mode 120000 index 0000000000..ee1ee662be --- /dev/null +++ b/Lang/Scheme/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Empty-string b/Lang/Scheme/Empty-string new file mode 120000 index 0000000000..1f67844140 --- /dev/null +++ b/Lang/Scheme/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Enumerations b/Lang/Scheme/Enumerations new file mode 120000 index 0000000000..9707291ac3 --- /dev/null +++ b/Lang/Scheme/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Ethiopian-multiplication b/Lang/Scheme/Ethiopian-multiplication new file mode 120000 index 0000000000..a92a9ae88c --- /dev/null +++ b/Lang/Scheme/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Evaluate-binomial-coefficients b/Lang/Scheme/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..ec4caf3cd6 --- /dev/null +++ b/Lang/Scheme/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Even-or-odd b/Lang/Scheme/Even-or-odd new file mode 120000 index 0000000000..dcf2ada4fb --- /dev/null +++ b/Lang/Scheme/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Exceptions b/Lang/Scheme/Exceptions new file mode 120000 index 0000000000..4869d2b1ae --- /dev/null +++ b/Lang/Scheme/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Execute-a-system-command b/Lang/Scheme/Execute-a-system-command new file mode 120000 index 0000000000..baf6bf1abd --- /dev/null +++ b/Lang/Scheme/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Exponentiation-operator b/Lang/Scheme/Exponentiation-operator new file mode 120000 index 0000000000..65a25e47dc --- /dev/null +++ b/Lang/Scheme/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Extend-your-language b/Lang/Scheme/Extend-your-language new file mode 120000 index 0000000000..7a90d3e566 --- /dev/null +++ b/Lang/Scheme/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Extreme-floating-point-values b/Lang/Scheme/Extreme-floating-point-values new file mode 120000 index 0000000000..f52aafe7a0 --- /dev/null +++ b/Lang/Scheme/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Scheme \ No newline at end of file diff --git a/Lang/Smalltalk/CRC-32 b/Lang/Smalltalk/CRC-32 new file mode 120000 index 0000000000..c9260d1c6e --- /dev/null +++ b/Lang/Smalltalk/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Call-a-function b/Lang/Smalltalk/Call-a-function new file mode 120000 index 0000000000..61f8a27ab4 --- /dev/null +++ b/Lang/Smalltalk/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Call-a-function-in-a-shared-library b/Lang/Smalltalk/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..1d7daa0b28 --- /dev/null +++ b/Lang/Smalltalk/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Call-an-object-method b/Lang/Smalltalk/Call-an-object-method new file mode 120000 index 0000000000..e1bd0938d7 --- /dev/null +++ b/Lang/Smalltalk/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Case-sensitivity-of-identifiers b/Lang/Smalltalk/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..9edb7329e2 --- /dev/null +++ b/Lang/Smalltalk/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Character-codes b/Lang/Smalltalk/Character-codes new file mode 120000 index 0000000000..1029e98cf4 --- /dev/null +++ b/Lang/Smalltalk/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Character-matching b/Lang/Smalltalk/Character-matching new file mode 120000 index 0000000000..9b9ab21c46 --- /dev/null +++ b/Lang/Smalltalk/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Combinations b/Lang/Smalltalk/Combinations new file mode 120000 index 0000000000..f192189e5b --- /dev/null +++ b/Lang/Smalltalk/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Command-line-arguments b/Lang/Smalltalk/Command-line-arguments new file mode 120000 index 0000000000..a580b9ced7 --- /dev/null +++ b/Lang/Smalltalk/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Conditional-structures b/Lang/Smalltalk/Conditional-structures new file mode 120000 index 0000000000..03680ab08e --- /dev/null +++ b/Lang/Smalltalk/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Create-a-file b/Lang/Smalltalk/Create-a-file new file mode 120000 index 0000000000..81eadd62de --- /dev/null +++ b/Lang/Smalltalk/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Create-a-two-dimensional-array-at-runtime b/Lang/Smalltalk/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..15afee71ed --- /dev/null +++ b/Lang/Smalltalk/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Date-manipulation b/Lang/Smalltalk/Date-manipulation new file mode 120000 index 0000000000..0a6808466c --- /dev/null +++ b/Lang/Smalltalk/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Day-of-the-week b/Lang/Smalltalk/Day-of-the-week new file mode 120000 index 0000000000..5d4ee397c4 --- /dev/null +++ b/Lang/Smalltalk/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Dining-philosophers b/Lang/Smalltalk/Dining-philosophers new file mode 120000 index 0000000000..7f8005f23b --- /dev/null +++ b/Lang/Smalltalk/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Documentation b/Lang/Smalltalk/Documentation new file mode 120000 index 0000000000..32e0d77a13 --- /dev/null +++ b/Lang/Smalltalk/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Dot-product b/Lang/Smalltalk/Dot-product new file mode 120000 index 0000000000..0c176775b7 --- /dev/null +++ b/Lang/Smalltalk/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Draw-a-sphere b/Lang/Smalltalk/Draw-a-sphere new file mode 120000 index 0000000000..533ee5572a --- /dev/null +++ b/Lang/Smalltalk/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Dynamic-variable-names b/Lang/Smalltalk/Dynamic-variable-names new file mode 120000 index 0000000000..dd4319a0ff --- /dev/null +++ b/Lang/Smalltalk/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Empty-program b/Lang/Smalltalk/Empty-program new file mode 120000 index 0000000000..69d5b5b00f --- /dev/null +++ b/Lang/Smalltalk/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Ethiopian-multiplication b/Lang/Smalltalk/Ethiopian-multiplication new file mode 120000 index 0000000000..d7cb1de94e --- /dev/null +++ b/Lang/Smalltalk/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Evolutionary-algorithm b/Lang/Smalltalk/Evolutionary-algorithm new file mode 120000 index 0000000000..7f736b614d --- /dev/null +++ b/Lang/Smalltalk/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Exceptions b/Lang/Smalltalk/Exceptions new file mode 120000 index 0000000000..7f300c88ac --- /dev/null +++ b/Lang/Smalltalk/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Smalltalk/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..b392cae425 --- /dev/null +++ b/Lang/Smalltalk/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Execute-a-system-command b/Lang/Smalltalk/Execute-a-system-command new file mode 120000 index 0000000000..39b35da4cd --- /dev/null +++ b/Lang/Smalltalk/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Exponentiation-operator b/Lang/Smalltalk/Exponentiation-operator new file mode 120000 index 0000000000..4217e289e4 --- /dev/null +++ b/Lang/Smalltalk/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Smalltalk \ No newline at end of file diff --git a/Lang/Tcl/CRC-32 b/Lang/Tcl/CRC-32 new file mode 120000 index 0000000000..b8b0bd7088 --- /dev/null +++ b/Lang/Tcl/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Tcl \ No newline at end of file diff --git a/Lang/Tcl/CSV-to-HTML-translation b/Lang/Tcl/CSV-to-HTML-translation new file mode 120000 index 0000000000..7ce46916c9 --- /dev/null +++ b/Lang/Tcl/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Calendar-for-real-programmers b/Lang/Tcl/Calendar-for-real-programmers new file mode 120000 index 0000000000..97e97724d3 --- /dev/null +++ b/Lang/Tcl/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Call-a-foreign-language-function b/Lang/Tcl/Call-a-foreign-language-function new file mode 120000 index 0000000000..96aa348f6f --- /dev/null +++ b/Lang/Tcl/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Call-a-function b/Lang/Tcl/Call-a-function new file mode 120000 index 0000000000..2521cc9766 --- /dev/null +++ b/Lang/Tcl/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Call-a-function-in-a-shared-library b/Lang/Tcl/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..c1eb070255 --- /dev/null +++ b/Lang/Tcl/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Call-an-object-method b/Lang/Tcl/Call-an-object-method new file mode 120000 index 0000000000..4cfe3e3bc7 --- /dev/null +++ b/Lang/Tcl/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Canny-edge-detector b/Lang/Tcl/Canny-edge-detector new file mode 120000 index 0000000000..f4bf5c0045 --- /dev/null +++ b/Lang/Tcl/Canny-edge-detector @@ -0,0 +1 @@ +../../Task/Canny-edge-detector/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Carmichael-3-strong-pseudoprimes b/Lang/Tcl/Carmichael-3-strong-pseudoprimes new file mode 120000 index 0000000000..e67410bda8 --- /dev/null +++ b/Lang/Tcl/Carmichael-3-strong-pseudoprimes @@ -0,0 +1 @@ +../../Task/Carmichael-3-strong-pseudoprimes/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Case-sensitivity-of-identifiers b/Lang/Tcl/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..0821a83c11 --- /dev/null +++ b/Lang/Tcl/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Catmull-Clark-subdivision-surface b/Lang/Tcl/Catmull-Clark-subdivision-surface new file mode 120000 index 0000000000..039c891da2 --- /dev/null +++ b/Lang/Tcl/Catmull-Clark-subdivision-surface @@ -0,0 +1 @@ +../../Task/Catmull-Clark-subdivision-surface/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Character-codes b/Lang/Tcl/Character-codes new file mode 120000 index 0000000000..3f7702eaa9 --- /dev/null +++ b/Lang/Tcl/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Character-matching b/Lang/Tcl/Character-matching new file mode 120000 index 0000000000..6b64a025e3 --- /dev/null +++ b/Lang/Tcl/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Chat-server b/Lang/Tcl/Chat-server new file mode 120000 index 0000000000..531f6a159e --- /dev/null +++ b/Lang/Tcl/Chat-server @@ -0,0 +1 @@ +../../Task/Chat-server/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Check-Machin-like-formulas b/Lang/Tcl/Check-Machin-like-formulas new file mode 120000 index 0000000000..f39bc7d0da --- /dev/null +++ b/Lang/Tcl/Check-Machin-like-formulas @@ -0,0 +1 @@ +../../Task/Check-Machin-like-formulas/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Cholesky-decomposition b/Lang/Tcl/Cholesky-decomposition new file mode 120000 index 0000000000..69e3b8ec80 --- /dev/null +++ b/Lang/Tcl/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Color-quantization b/Lang/Tcl/Color-quantization new file mode 120000 index 0000000000..375b62b75c --- /dev/null +++ b/Lang/Tcl/Color-quantization @@ -0,0 +1 @@ +../../Task/Color-quantization/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Colour-bars-Display b/Lang/Tcl/Colour-bars-Display new file mode 120000 index 0000000000..b388133eba --- /dev/null +++ b/Lang/Tcl/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Colour-pinstripe-Display b/Lang/Tcl/Colour-pinstripe-Display new file mode 120000 index 0000000000..087a1d8dc4 --- /dev/null +++ b/Lang/Tcl/Colour-pinstripe-Display @@ -0,0 +1 @@ +../../Task/Colour-pinstripe-Display/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Colour-pinstripe-Printer b/Lang/Tcl/Colour-pinstripe-Printer new file mode 120000 index 0000000000..8f3a1c6e4f --- /dev/null +++ b/Lang/Tcl/Colour-pinstripe-Printer @@ -0,0 +1 @@ +../../Task/Colour-pinstripe-Printer/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Combinations b/Lang/Tcl/Combinations new file mode 120000 index 0000000000..2ebcec29d0 --- /dev/null +++ b/Lang/Tcl/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Combinations-with-repetitions b/Lang/Tcl/Combinations-with-repetitions new file mode 120000 index 0000000000..c7e13e64c0 --- /dev/null +++ b/Lang/Tcl/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Command-line-arguments b/Lang/Tcl/Command-line-arguments new file mode 120000 index 0000000000..4bf1e4e5d5 --- /dev/null +++ b/Lang/Tcl/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Compare-sorting-algorithms-performance b/Lang/Tcl/Compare-sorting-algorithms-performance new file mode 120000 index 0000000000..4e0357cec5 --- /dev/null +++ b/Lang/Tcl/Compare-sorting-algorithms-performance @@ -0,0 +1 @@ +../../Task/Compare-sorting-algorithms-performance/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Compile-time-calculation b/Lang/Tcl/Compile-time-calculation new file mode 120000 index 0000000000..0d210420ab --- /dev/null +++ b/Lang/Tcl/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Compound-data-type b/Lang/Tcl/Compound-data-type new file mode 120000 index 0000000000..8fd72eeb1a --- /dev/null +++ b/Lang/Tcl/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Concurrent-computing b/Lang/Tcl/Concurrent-computing new file mode 120000 index 0000000000..79caca324e --- /dev/null +++ b/Lang/Tcl/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Conditional-structures b/Lang/Tcl/Conditional-structures new file mode 120000 index 0000000000..ea614a26a2 --- /dev/null +++ b/Lang/Tcl/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Constrained-random-points-on-a-circle b/Lang/Tcl/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..245e964ad4 --- /dev/null +++ b/Lang/Tcl/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Continued-fraction b/Lang/Tcl/Continued-fraction new file mode 120000 index 0000000000..c538230b12 --- /dev/null +++ b/Lang/Tcl/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Continued-fraction-Arithmetic-Construct-from-rational-number b/Lang/Tcl/Continued-fraction-Arithmetic-Construct-from-rational-number new file mode 120000 index 0000000000..a72871a5de --- /dev/null +++ b/Lang/Tcl/Continued-fraction-Arithmetic-Construct-from-rational-number @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) b/Lang/Tcl/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) new file mode 120000 index 0000000000..0b535b33df --- /dev/null +++ b/Lang/Tcl/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2) b/Lang/Tcl/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2) new file mode 120000 index 0000000000..752393920c --- /dev/null +++ b/Lang/Tcl/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2) @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Conways-Game-of-Life b/Lang/Tcl/Conways-Game-of-Life new file mode 120000 index 0000000000..0dada3c798 --- /dev/null +++ b/Lang/Tcl/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Count-in-factors b/Lang/Tcl/Count-in-factors new file mode 120000 index 0000000000..bb99dbdccf --- /dev/null +++ b/Lang/Tcl/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Count-in-octal b/Lang/Tcl/Count-in-octal new file mode 120000 index 0000000000..4c2942d621 --- /dev/null +++ b/Lang/Tcl/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Count-occurrences-of-a-substring b/Lang/Tcl/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..aaf8c0e17a --- /dev/null +++ b/Lang/Tcl/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Count-the-coins b/Lang/Tcl/Count-the-coins new file mode 120000 index 0000000000..8ecc405f4c --- /dev/null +++ b/Lang/Tcl/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Create-a-file b/Lang/Tcl/Create-a-file new file mode 120000 index 0000000000..79df58bb60 --- /dev/null +++ b/Lang/Tcl/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Create-a-file-on-magnetic-tape b/Lang/Tcl/Create-a-file-on-magnetic-tape new file mode 120000 index 0000000000..e5e59d7d1d --- /dev/null +++ b/Lang/Tcl/Create-a-file-on-magnetic-tape @@ -0,0 +1 @@ +../../Task/Create-a-file-on-magnetic-tape/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Create-a-two-dimensional-array-at-runtime b/Lang/Tcl/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..e79cefde87 --- /dev/null +++ b/Lang/Tcl/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Create-an-HTML-table b/Lang/Tcl/Create-an-HTML-table new file mode 120000 index 0000000000..bf7a87078a --- /dev/null +++ b/Lang/Tcl/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Create-an-object-at-a-given-address b/Lang/Tcl/Create-an-object-at-a-given-address new file mode 120000 index 0000000000..1b8c67b87d --- /dev/null +++ b/Lang/Tcl/Create-an-object-at-a-given-address @@ -0,0 +1 @@ +../../Task/Create-an-object-at-a-given-address/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Cut-a-rectangle b/Lang/Tcl/Cut-a-rectangle new file mode 120000 index 0000000000..ee32516bd8 --- /dev/null +++ b/Lang/Tcl/Cut-a-rectangle @@ -0,0 +1 @@ +../../Task/Cut-a-rectangle/Tcl \ No newline at end of file diff --git a/Lang/Tcl/DNS-query b/Lang/Tcl/DNS-query new file mode 120000 index 0000000000..9f2fa230e7 --- /dev/null +++ b/Lang/Tcl/DNS-query @@ -0,0 +1 @@ +../../Task/DNS-query/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Date-format b/Lang/Tcl/Date-format new file mode 120000 index 0000000000..c836da1fda --- /dev/null +++ b/Lang/Tcl/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Date-manipulation b/Lang/Tcl/Date-manipulation new file mode 120000 index 0000000000..1c226b3228 --- /dev/null +++ b/Lang/Tcl/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Day-of-the-week b/Lang/Tcl/Day-of-the-week new file mode 120000 index 0000000000..1e9715489e --- /dev/null +++ b/Lang/Tcl/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Deal-cards-for-FreeCell b/Lang/Tcl/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..c19c09865a --- /dev/null +++ b/Lang/Tcl/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Deconvolution-1D b/Lang/Tcl/Deconvolution-1D new file mode 120000 index 0000000000..e10f425a3b --- /dev/null +++ b/Lang/Tcl/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Deconvolution-2D+ b/Lang/Tcl/Deconvolution-2D+ new file mode 120000 index 0000000000..b9203b3372 --- /dev/null +++ b/Lang/Tcl/Deconvolution-2D+ @@ -0,0 +1 @@ +../../Task/Deconvolution-2D+/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Deepcopy b/Lang/Tcl/Deepcopy new file mode 120000 index 0000000000..4ce386ee4d --- /dev/null +++ b/Lang/Tcl/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Determine-if-only-one-instance-is-running b/Lang/Tcl/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..b1e6fae4f7 --- /dev/null +++ b/Lang/Tcl/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Digital-root b/Lang/Tcl/Digital-root new file mode 120000 index 0000000000..dd106c5acc --- /dev/null +++ b/Lang/Tcl/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Dinesmans-multiple-dwelling-problem b/Lang/Tcl/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..72018d76a3 --- /dev/null +++ b/Lang/Tcl/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Dining-philosophers b/Lang/Tcl/Dining-philosophers new file mode 120000 index 0000000000..9e2607573c --- /dev/null +++ b/Lang/Tcl/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Discordian-date b/Lang/Tcl/Discordian-date new file mode 120000 index 0000000000..5380c62d4e --- /dev/null +++ b/Lang/Tcl/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Distributed-programming b/Lang/Tcl/Distributed-programming new file mode 120000 index 0000000000..4293b549b2 --- /dev/null +++ b/Lang/Tcl/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Documentation b/Lang/Tcl/Documentation new file mode 120000 index 0000000000..a8762cb112 --- /dev/null +++ b/Lang/Tcl/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Dot-product b/Lang/Tcl/Dot-product new file mode 120000 index 0000000000..a57f390aaf --- /dev/null +++ b/Lang/Tcl/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Doubly-linked-list-Definition b/Lang/Tcl/Doubly-linked-list-Definition new file mode 120000 index 0000000000..082066b801 --- /dev/null +++ b/Lang/Tcl/Doubly-linked-list-Definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Definition/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Doubly-linked-list-Element-definition b/Lang/Tcl/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..eadbd0de95 --- /dev/null +++ b/Lang/Tcl/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Doubly-linked-list-Element-insertion b/Lang/Tcl/Doubly-linked-list-Element-insertion new file mode 120000 index 0000000000..d7e04e1654 --- /dev/null +++ b/Lang/Tcl/Doubly-linked-list-Element-insertion @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-insertion/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Doubly-linked-list-Traversal b/Lang/Tcl/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..5f25ce334c --- /dev/null +++ b/Lang/Tcl/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Draw-a-cuboid b/Lang/Tcl/Draw-a-cuboid new file mode 120000 index 0000000000..46bb524f76 --- /dev/null +++ b/Lang/Tcl/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Draw-a-sphere b/Lang/Tcl/Draw-a-sphere new file mode 120000 index 0000000000..a2e6ec4c17 --- /dev/null +++ b/Lang/Tcl/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Dutch-national-flag-problem b/Lang/Tcl/Dutch-national-flag-problem new file mode 120000 index 0000000000..43243538bd --- /dev/null +++ b/Lang/Tcl/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Dynamic-variable-names b/Lang/Tcl/Dynamic-variable-names new file mode 120000 index 0000000000..bd68cb9118 --- /dev/null +++ b/Lang/Tcl/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Echo-server b/Lang/Tcl/Echo-server new file mode 120000 index 0000000000..517d139165 --- /dev/null +++ b/Lang/Tcl/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Element-wise-operations b/Lang/Tcl/Element-wise-operations new file mode 120000 index 0000000000..7b017f8e0b --- /dev/null +++ b/Lang/Tcl/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Empty-directory b/Lang/Tcl/Empty-directory new file mode 120000 index 0000000000..6561b8dfd0 --- /dev/null +++ b/Lang/Tcl/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Empty-program b/Lang/Tcl/Empty-program new file mode 120000 index 0000000000..48a3dfcc9f --- /dev/null +++ b/Lang/Tcl/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Empty-string b/Lang/Tcl/Empty-string new file mode 120000 index 0000000000..ba4fcfb469 --- /dev/null +++ b/Lang/Tcl/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Enforced-immutability b/Lang/Tcl/Enforced-immutability new file mode 120000 index 0000000000..d424a2f1a4 --- /dev/null +++ b/Lang/Tcl/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Enumerations b/Lang/Tcl/Enumerations new file mode 120000 index 0000000000..e1e78b8ef5 --- /dev/null +++ b/Lang/Tcl/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Equilibrium-index b/Lang/Tcl/Equilibrium-index new file mode 120000 index 0000000000..0b45bea60d --- /dev/null +++ b/Lang/Tcl/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Ethiopian-multiplication b/Lang/Tcl/Ethiopian-multiplication new file mode 120000 index 0000000000..5a09267925 --- /dev/null +++ b/Lang/Tcl/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Euler-method b/Lang/Tcl/Euler-method new file mode 120000 index 0000000000..102f5d57d2 --- /dev/null +++ b/Lang/Tcl/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Evaluate-binomial-coefficients b/Lang/Tcl/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..33a5072c62 --- /dev/null +++ b/Lang/Tcl/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Even-or-odd b/Lang/Tcl/Even-or-odd new file mode 120000 index 0000000000..02fb31afa0 --- /dev/null +++ b/Lang/Tcl/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Events b/Lang/Tcl/Events new file mode 120000 index 0000000000..a2cbf0c788 --- /dev/null +++ b/Lang/Tcl/Events @@ -0,0 +1 @@ +../../Task/Events/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Evolutionary-algorithm b/Lang/Tcl/Evolutionary-algorithm new file mode 120000 index 0000000000..afb95da152 --- /dev/null +++ b/Lang/Tcl/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Exceptions b/Lang/Tcl/Exceptions new file mode 120000 index 0000000000..46a1ad9999 --- /dev/null +++ b/Lang/Tcl/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Tcl/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..0d8bbf8763 --- /dev/null +++ b/Lang/Tcl/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Executable-library b/Lang/Tcl/Executable-library new file mode 120000 index 0000000000..0f7a6e70f1 --- /dev/null +++ b/Lang/Tcl/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Execute-a-system-command b/Lang/Tcl/Execute-a-system-command new file mode 120000 index 0000000000..f866ef8d15 --- /dev/null +++ b/Lang/Tcl/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Exponentiation-operator b/Lang/Tcl/Exponentiation-operator new file mode 120000 index 0000000000..fb0157f401 --- /dev/null +++ b/Lang/Tcl/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Extend-your-language b/Lang/Tcl/Extend-your-language new file mode 120000 index 0000000000..7a8c767bbf --- /dev/null +++ b/Lang/Tcl/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Extreme-floating-point-values b/Lang/Tcl/Extreme-floating-point-values new file mode 120000 index 0000000000..29795b158e --- /dev/null +++ b/Lang/Tcl/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Tcl \ No newline at end of file diff --git a/Meta/Lang.yaml b/Meta/Lang.yaml index 9660da9f45..52eda8b49f 100644 --- a/Meta/Lang.yaml +++ b/Meta/Lang.yaml @@ -50,7 +50,7 @@ path: 8086-Assembly url: 8086_Assembly A+: - ext: a+ + ext: ap name: A+ path: A+ url: A+ @@ -364,31 +364,346 @@ C: name: C path: C url: C +C Shell: + ext: csh + name: C Shell + path: C-Shell + url: C_Shell +C sharp: + ext: cs + name: C sharp + path: C-sharp + url: C_sharp +C++: + ext: cpp + name: C++ + path: C++ + url: C++ +C++/CLI: + ext: cpp + name: C++/CLI + path: C++-CLI + url: C++/CLI +C0H: + ext: c0h + name: C0H + path: C0H + url: C0H +C1R: + ext: c1r + name: C1R + path: C1R + url: C1R +CB80: + ext: cb80 + name: CB80 + path: CB80 + url: CB80 +CLIPS: + ext: clips + name: CLIPS + path: CLIPS + url: CLIPS +CMake: + ext: cmake + name: CMake + path: CMake + url: CMake +COBOL: + ext: cobol + name: COBOL + path: COBOL + url: COBOL +Caché ObjectScript: + ext: cos + name: Caché ObjectScript + path: Cache-ObjectScript + url: Caché_ObjectScript +Caml: + ext: caml + name: Caml + path: Caml + url: Caml +Cat: + ext: cat + name: Cat + path: Cat + url: Cat +Cduce: + ext: cduce + name: Cduce + path: Cduce + url: Cduce +Cecil: + ext: cecil + name: Cecil + path: Cecil + url: Cecil +Chapel: + ext: chapel + name: Chapel + path: Chapel + url: Chapel +Chef: + ext: chef + name: Chef + path: Chef + url: Chef +Cilk: + ext: cilk + name: Cilk + path: Cilk + url: Cilk +Cilk++: + ext: cilkpp + name: Cilk++ + path: Cilk++ + url: Cilk++ +Clay: + ext: clay + name: Clay + path: Clay + url: Clay +Clean: + ext: clean + name: Clean + path: Clean + url: Clean +Clipper: + ext: clipper + name: Clipper + path: Clipper + url: Clipper +Clipper/XBase++: + ext: clipper + name: Clipper/XBase++ + path: Clipper-XBase++ + url: Clipper/XBase++ Clojure: ext: clj name: Clojure path: Clojure url: Clojure +Cobra: + ext: cobra + name: Cobra + path: Cobra + url: Cobra CoffeeScript: ext: coffee name: CoffeeScript path: CoffeeScript url: CoffeeScript +ColdFusion: + ext: cfm + name: ColdFusion + path: ColdFusion + url: ColdFusion +Common Lisp: + ext: lisp + name: Common Lisp + path: Common-Lisp + url: Common_Lisp +Component Pascal: + ext: pascal + name: Component Pascal + path: Component-Pascal + url: Component_Pascal +Coq: + ext: coq + name: Coq + path: Coq + url: Coq +Crack: + ext: crack + name: Crack + path: Crack + url: Crack +Curry: + ext: curry + name: Curry + path: Curry + url: Curry +D: + ext: d + name: D + path: D + url: D +DCL: + ext: dcl + name: DCL + path: DCL + url: DCL +DMS: + ext: dms + name: DMS + path: DMS + url: DMS +DWScript: + ext: dwscript + name: DWScript + path: DWScript + url: DWScript +Dao: + ext: dao + name: Dao + path: Dao + url: Dao +Dart: + ext: dart + name: Dart + path: Dart + url: Dart +Datalog: + ext: datalog + name: Datalog + path: Datalog + url: Datalog +Dc: + ext: dc + name: Dc + path: Dc + url: Dc +Delphi: + ext: delphi + name: Delphi + path: Delphi + url: Delphi +Deluge: + ext: deluge + name: Deluge + path: Deluge + url: Deluge +Diesel: + ext: diesel + name: Diesel + path: Diesel + url: Diesel +Dodo0: + ext: dodo0 + name: Dodo0 + path: Dodo0 + url: Dodo0 Dylan: ext: dylan name: Dylan path: Dylan url: Dylan +Dylan.NET: + ext: net + name: Dylan.NET + path: Dylan.NET + url: Dylan.NET +Déjà Vu: + ext: djv + name: Déjà Vu + path: Deja-Vu + url: Déjà_Vu +E: + ext: e + name: E + path: E + url: E +EC: + ext: ec + name: EC + path: EC + url: EC +EGL: + ext: egl + name: EGL + path: EGL + url: EGL +ELLA: + ext: ella + name: ELLA + path: ELLA + url: ELLA +ESQL: + ext: esql + name: ESQL + path: ESQL + url: ESQL +Efene: + ext: efene + name: Efene + path: Efene + url: Efene Eiffel: ext: e name: Eiffel path: Eiffel url: Eiffel +Ela: + ext: ela + name: Ela + path: Ela + url: Ela +Elan: + ext: elan + name: Elan + path: Elan + url: Elan +ElastiC: + ext: elastic + name: ElastiC + path: ElastiC + url: ElastiC +Elena: + ext: elena + name: Elena + path: Elena + url: Elena +Elisa: + ext: elisa + name: Elisa + path: Elisa + url: Elisa +Elixir: + ext: elixir + name: Elixir + path: Elixir + url: Elixir +Emacs Lisp: + ext: l + name: Emacs Lisp + path: Emacs-Lisp + url: Emacs_Lisp +Epigram: + ext: epigram + name: Epigram + path: Epigram + url: Epigram Erlang: ext: erl name: Erlang path: Erlang url: Erlang +Es: + ext: es + name: Es + path: Es + url: Es +Euler: + ext: euler + name: Euler + path: Euler + url: Euler +Euler Math Toolbox: + ext: euler + name: Euler Math Toolbox + path: Euler-Math-Toolbox + url: Euler_Math_Toolbox +Euphoria: + ext: euphoria + name: Euphoria + path: Euphoria + url: Euphoria +Excel: + ext: excel + name: Excel + path: Excel + url: Excel Forth: ext: fth name: Forth diff --git a/Meta/Task.yaml b/Meta/Task.yaml index 21d3b49627..ffdd0eb5fb 100644 --- a/Meta/Task.yaml +++ b/Meta/Task.yaml @@ -259,6 +259,14 @@ Bulls and cows/Player: name: Bulls and cows/Player path: Bulls-and-cows-Player url: Bulls_and_cows/Player +CRC-32: + name: CRC-32 + path: CRC-32 + url: CRC-32 +CSV to HTML translation: + name: CSV to HTML translation + path: CSV-to-HTML-translation + url: CSV_to_HTML_translation Caesar cipher: name: Caesar cipher path: Caesar-cipher @@ -267,6 +275,58 @@ Calendar: name: Calendar path: Calendar url: Calendar +Calendar - for "real" programmers: + name: Calendar - for "real" programmers + path: Calendar-for-real-programmers + url: Calendar_-_for_"real"_programmers +Call a foreign-language function: + name: Call a foreign-language function + path: Call-a-foreign-language-function + url: Call_a_foreign-language_function +Call a function: + name: Call a function + path: Call-a-function + url: Call_a_function +Call a function in a shared library: + name: Call a function in a shared library + path: Call-a-function-in-a-shared-library + url: Call_a_function_in_a_shared_library +Call an object method: + name: Call an object method + path: Call-an-object-method + url: Call_an_object_method +Canny edge detector: + name: Canny edge detector + path: Canny-edge-detector + url: Canny_edge_detector +Carmichael 3 strong pseudoprimes: + name: Carmichael 3 strong pseudoprimes + path: Carmichael-3-strong-pseudoprimes + url: Carmichael_3_strong_pseudoprimes +Case-sensitivity of identifiers: + name: Case-sensitivity of identifiers + path: Case-sensitivity-of-identifiers + url: Case-sensitivity_of_identifiers +Catmull–Clark subdivision surface: + name: Catmull–Clark subdivision surface + path: Catmull-Clark-subdivision-surface + url: Catmull–Clark_subdivision_surface +Character codes: + name: Character codes + path: Character-codes + url: Character_codes +Character matching: + name: Character matching + path: Character-matching + url: Character_matching +Chat server: + name: Chat server + path: Chat-server + url: Chat_server +Check Machin-like formulas: + name: Check Machin-like formulas + path: Check-Machin-like-formulas + url: Check_Machin-like_formulas Check that file exists: name: Check that file exists path: Check-that-file-exists @@ -275,6 +335,10 @@ Checkpoint synchronization: name: Checkpoint synchronization path: Checkpoint-synchronization url: Checkpoint_synchronization +Cholesky decomposition: + name: Cholesky decomposition + path: Cholesky-decomposition + url: Cholesky_decomposition Classes: name: Classes path: Classes @@ -291,14 +355,163 @@ Color of a screen pixel: name: Color of a screen pixel path: Color-of-a-screen-pixel url: Color_of_a_screen_pixel +Color quantization: + name: Color quantization + path: Color-quantization + url: Color_quantization +Colour bars/Display: + name: Colour bars/Display + path: Colour-bars-Display + url: Colour_bars/Display +Colour pinstripe/Display: + name: Colour pinstripe/Display + path: Colour-pinstripe-Display + url: Colour_pinstripe/Display +Colour pinstripe/Printer: + name: Colour pinstripe/Printer + path: Colour-pinstripe-Printer + url: Colour_pinstripe/Printer +Combinations: + name: Combinations + path: Combinations + url: Combinations +Combinations with repetitions: + name: Combinations with repetitions + path: Combinations-with-repetitions + url: Combinations_with_repetitions +Command-line arguments: + name: Command-line arguments + path: Command-line-arguments + url: Command-line_arguments Comments: name: Comments path: Comments url: Comments +Compare sorting algorithms' performance: + name: Compare sorting algorithms' performance + path: Compare-sorting-algorithms-performance + url: Compare_sorting_algorithms'_performance +Compile-time calculation: + name: Compile-time calculation + path: Compile-time-calculation + url: Compile-time_calculation +Compound data type: + name: Compound data type + path: Compound-data-type + url: Compound_data_type +Concurrent computing: + name: Concurrent computing + path: Concurrent-computing + url: Concurrent_computing +Conditional structures: + name: Conditional structures + path: Conditional-structures + url: Conditional_structures +Constrained genericity: + name: Constrained genericity + path: Constrained-genericity + url: Constrained_genericity +Constrained random points on a circle: + name: Constrained random points on a circle + path: Constrained-random-points-on-a-circle + url: Constrained_random_points_on_a_circle +Continued fraction: + name: Continued fraction + path: Continued-fraction + url: Continued_fraction +Continued fraction/Arithmetic/Construct from rational number: + name: Continued fraction/Arithmetic/Construct from rational number + path: Continued-fraction-Arithmetic-Construct-from-rational-number + url: Continued_fraction/Arithmetic/Construct_from_rational_number +Continued fraction/Arithmetic/G(matrix NG, Contined Fraction N): + name: Continued fraction/Arithmetic/G(matrix NG, Contined Fraction N) + path: Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) + url: Continued_fraction/Arithmetic/G(matrix_NG,_Contined_Fraction_N) +Continued fraction/Arithmetic/G(matrix NG, Contined Fraction N1, Contined Fraction N2): + name: Continued fraction/Arithmetic/G(matrix NG, Contined Fraction N1, Contined + Fraction N2) + path: Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2) + url: Continued_fraction/Arithmetic/G(matrix_NG,_Contined_Fraction_N1,_Contined_Fraction_N2) +Conway's Game of Life: + name: Conway's Game of Life + path: Conways-Game-of-Life + url: Conway's_Game_of_Life +Count in factors: + name: Count in factors + path: Count-in-factors + url: Count_in_factors +Count in octal: + name: Count in octal + path: Count-in-octal + url: Count_in_octal +Count occurrences of a substring: + name: Count occurrences of a substring + path: Count-occurrences-of-a-substring + url: Count_occurrences_of_a_substring +Count the coins: + name: Count the coins + path: Count-the-coins + url: Count_the_coins +Create a file: + name: Create a file + path: Create-a-file + url: Create_a_file +Create a file on magnetic tape: + name: Create a file on magnetic tape + path: Create-a-file-on-magnetic-tape + url: Create_a_file_on_magnetic_tape +Create a two-dimensional array at runtime: + name: Create a two-dimensional array at runtime + path: Create-a-two-dimensional-array-at-runtime + url: Create_a_two-dimensional_array_at_runtime +Create an HTML table: + name: Create an HTML table + path: Create-an-HTML-table + url: Create_an_HTML_table +Create an object at a given address: + name: Create an object at a given address + path: Create-an-object-at-a-given-address + url: Create_an_object_at_a_given_address +Cut a rectangle: + name: Cut a rectangle + path: Cut-a-rectangle + url: Cut_a_rectangle +DNS query: + name: DNS query + path: DNS-query + url: DNS_query +Date format: + name: Date format + path: Date-format + url: Date_format +Date manipulation: + name: Date manipulation + path: Date-manipulation + url: Date_manipulation +Day of the week: + name: Day of the week + path: Day-of-the-week + url: Day_of_the_week +Deal cards for FreeCell: + name: Deal cards for FreeCell + path: Deal-cards-for-FreeCell + url: Deal_cards_for_FreeCell Death Star: name: Death Star path: Death-Star url: Death_Star +Deconvolution/1D: + name: Deconvolution/1D + path: Deconvolution-1D + url: Deconvolution/1D +Deconvolution/2D+: + name: Deconvolution/2D+ + path: Deconvolution-2D+ + url: Deconvolution/2D+ +Deepcopy: + name: Deepcopy + path: Deepcopy + url: Deepcopy Define a primitive data type: name: Define a primitive data type path: Define-a-primitive-data-type @@ -319,10 +532,162 @@ Determine if a string is numeric: name: Determine if a string is numeric path: Determine-if-a-string-is-numeric url: Determine_if_a_string_is_numeric +Determine if only one instance is running: + name: Determine if only one instance is running + path: Determine-if-only-one-instance-is-running + url: Determine_if_only_one_instance_is_running +Digital root: + name: Digital root + path: Digital-root + url: Digital_root +Dinesman's multiple-dwelling problem: + name: Dinesman's multiple-dwelling problem + path: Dinesmans-multiple-dwelling-problem + url: Dinesman's_multiple-dwelling_problem +Dining philosophers: + name: Dining philosophers + path: Dining-philosophers + url: Dining_philosophers +Discordian date: + name: Discordian date + path: Discordian-date + url: Discordian_date +Distributed programming: + name: Distributed programming + path: Distributed-programming + url: Distributed_programming +Documentation: + name: Documentation + path: Documentation + url: Documentation +Dot product: + name: Dot product + path: Dot-product + url: Dot_product +Doubly-linked list/Definition: + name: Doubly-linked list/Definition + path: Doubly-linked-list-Definition + url: Doubly-linked_list/Definition +Doubly-linked list/Element definition: + name: Doubly-linked list/Element definition + path: Doubly-linked-list-Element-definition + url: Doubly-linked_list/Element_definition +Doubly-linked list/Element insertion: + name: Doubly-linked list/Element insertion + path: Doubly-linked-list-Element-insertion + url: Doubly-linked_list/Element_insertion +Doubly-linked list/Traversal: + name: Doubly-linked list/Traversal + path: Doubly-linked-list-Traversal + url: Doubly-linked_list/Traversal +Draw a cuboid: + name: Draw a cuboid + path: Draw-a-cuboid + url: Draw_a_cuboid +Draw a sphere: + name: Draw a sphere + path: Draw-a-sphere + url: Draw_a_sphere +Dutch national flag problem: + name: Dutch national flag problem + path: Dutch-national-flag-problem + url: Dutch_national_flag_problem +Dynamic variable names: + name: Dynamic variable names + path: Dynamic-variable-names + url: Dynamic_variable_names +Echo server: + name: Echo server + path: Echo-server + url: Echo_server +Element-wise operations: + name: Element-wise operations + path: Element-wise-operations + url: Element-wise_operations +Empty directory: + name: Empty directory + path: Empty-directory + url: Empty_directory +Empty program: + name: Empty program + path: Empty-program + url: Empty_program +Empty string: + name: Empty string + path: Empty-string + url: Empty_string +Enforced immutability: + name: Enforced immutability + path: Enforced-immutability + url: Enforced_immutability Entropy: name: Entropy path: Entropy url: Entropy +Enumerations: + name: Enumerations + path: Enumerations + url: Enumerations +Equilibrium index: + name: Equilibrium index + path: Equilibrium-index + url: Equilibrium_index +Ethiopian multiplication: + name: Ethiopian multiplication + path: Ethiopian-multiplication + url: Ethiopian_multiplication +Euler method: + name: Euler method + path: Euler-method + url: Euler_method +Evaluate binomial coefficients: + name: Evaluate binomial coefficients + path: Evaluate-binomial-coefficients + url: Evaluate_binomial_coefficients +Even or odd: + name: Even or odd + path: Even-or-odd + url: Even_or_odd +Events: + name: Events + path: Events + url: Events +Evolutionary algorithm: + name: Evolutionary algorithm + path: Evolutionary-algorithm + url: Evolutionary_algorithm +Exceptions: + name: Exceptions + path: Exceptions + url: Exceptions +Exceptions/Catch an exception thrown in a nested call: + name: Exceptions/Catch an exception thrown in a nested call + path: Exceptions-Catch-an-exception-thrown-in-a-nested-call + url: Exceptions/Catch_an_exception_thrown_in_a_nested_call +Executable library: + name: Executable library + path: Executable-library + url: Executable_library +Execute HQ9+: + name: Execute HQ9+ + path: Execute-HQ9+ + url: Execute_HQ9+ +Execute a system command: + name: Execute a system command + path: Execute-a-system-command + url: Execute_a_system_command +Exponentiation operator: + name: Exponentiation operator + path: Exponentiation-operator + url: Exponentiation_operator +Extend your language: + name: Extend your language + path: Extend-your-language + url: Extend_your_language +Extreme floating point values: + name: Extreme floating point values + path: Extreme-floating-point-values + url: Extreme_floating_point_values FizzBuzz: name: FizzBuzz path: FizzBuzz diff --git a/Task/100-doors/C++/100-doors-1.cpp b/Task/100-doors/C++/100-doors-1.cpp new file mode 100644 index 0000000000..5c18347043 --- /dev/null +++ b/Task/100-doors/C++/100-doors-1.cpp @@ -0,0 +1,16 @@ +#include + +int main() +{ + bool is_open[100] = { false }; + + // do the 100 passes + for (int pass = 0; pass < 100; ++pass) + for (int door = pass; door < 100; door += pass+1) + is_open[door] = !is_open[door]; + + // output the result + for (int door = 0; door < 100; ++door) + std::cout << "door #" << door+1 << (is_open[door]? " is open." : " is closed.") << std::endl; + return 0; +} diff --git a/Task/100-doors/C++/100-doors-2.cpp b/Task/100-doors/C++/100-doors-2.cpp new file mode 100644 index 0000000000..8f56214c81 --- /dev/null +++ b/Task/100-doors/C++/100-doors-2.cpp @@ -0,0 +1,19 @@ +#include + +int main() +{ + int square = 1, increment = 3; + for (int door = 1; door <= 100; ++door) + { + std::cout << "door #" << door; + if (door == square) + { + std::cout << " is open." << std::endl; + square += increment; + increment += 2; + } + else + std::cout << " is closed." << std::endl; + } + return 0; +} diff --git a/Task/100-doors/C++/100-doors-3.cpp b/Task/100-doors/C++/100-doors-3.cpp new file mode 100644 index 0000000000..d7b1b3263c --- /dev/null +++ b/Task/100-doors/C++/100-doors-3.cpp @@ -0,0 +1,7 @@ +#include //compiled with "Dev-C++" , from RaptorOne + +int main() +{ + for(int i=1; i*i<=100; i++) + std::cout<<"Door "< + (loop-for-count (?num 1 ?count) do + (assert (door ?num "closed")) + (assert (visit-from ?num ?num)) + ) + (assert (doors initialized)) +) + +(defrule visit + (door-count ?max) + ?visit <- (visit-from ?num ?step) + ?door <- (door ?num ?state) + => + (retract ?visit) + (retract ?door) + (assert (door ?num (toggle ?state))) + (if + (<= (+ ?num ?step) ?max) + then + (assert (visit-from (+ ?num ?step) ?step)) + ) +) + +(defrule start-printing + (doors initialized) + (not (visit-from ? ?)) + => + (printout t "These doors are open:" crlf) + (assert (print-from 1)) +) + +(defrule print-door + (door-count ?max) + ?pf <- (print-from ?num) + (door ?num ?state) + => + (retract ?pf) + (if + (= 0 (str-compare "open" ?state)) + then + (printout t ?num " ") + ) + (if + (< ?num ?max) + then + (assert (print-from (+ ?num 1))) + else + (printout t crlf "All other doors are closed." crlf) + ) +) diff --git a/Task/100-doors/CLIPS/100-doors-2.clips b/Task/100-doors/CLIPS/100-doors-2.clips new file mode 100644 index 0000000000..7cd844f270 --- /dev/null +++ b/Task/100-doors/CLIPS/100-doors-2.clips @@ -0,0 +1,20 @@ +(deffacts initial-state + (door-count 100) +) + +(deffunction is-square + (?num) + (= (sqrt ?num) (integer (sqrt ?num))) +) + +(defrule check-doors + (door-count ?count) + => + (printout t "These doors are open:" crlf) + (loop-for-count (?num 1 ?count) do + (if (is-square ?num) then + (printout t ?num " ") + ) + ) + (printout t crlf "All other doors are closed." crlf) +) diff --git a/Task/100-doors/COBOL/100-doors.cobol b/Task/100-doors/COBOL/100-doors.cobol new file mode 100644 index 0000000000..3045ecac3f --- /dev/null +++ b/Task/100-doors/COBOL/100-doors.cobol @@ -0,0 +1,31 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. 100Doors. + + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 Current PIC 9(3) VALUE ZEROES. + 01 StepSize PIC 9(3) VALUE ZEROES. + 01 DoorTable. + 02 Doors PIC 9(1) OCCURS 100 TIMES. + 01 Idx PIC 9(3). + + PROCEDURE DIVISION. + Begin. + MOVE 1 TO StepSize + PERFORM 100 TIMES + MOVE StepSize TO Current + PERFORM UNTIL Current > 100 + SUBTRACT Doors(Current) FROM 1 GIVING Doors(Current) + ADD StepSize TO Current GIVING Current + END-PERFORM + ADD 1 TO StepSize GIVING StepSize + END-PERFORM + PERFORM VARYING Idx FROM 1 BY 1 + UNTIL Idx > 100 + IF Doors(Idx) = 0 + DISPLAY Idx " is closed." + ELSE + DISPLAY Idx " is open." + END-IF + END-PERFORM + STOP RUN. diff --git a/Task/100-doors/ColdFusion/100-doors-1.cfm b/Task/100-doors/ColdFusion/100-doors-1.cfm new file mode 100644 index 0000000000..f8f95af25d --- /dev/null +++ b/Task/100-doors/ColdFusion/100-doors-1.cfm @@ -0,0 +1,25 @@ + doorCount = 1; + doorList = ""; + // create all doors and set all doors to open + while (doorCount LTE 100) { + doorList = ListAppend(doorList,"1"); + doorCount = doorCount + 1; + } + loopCount = 2; + doorListLen = ListLen(doorList); + while (loopCount LTE 100) { + loopDoorListCount = 1; + while (loopDoorListCount LTE 100) { + testDoor = loopDoorListCount / loopCount; + if (testDoor EQ Int(testDoor)) { + checkOpen = ListGetAt(doorList,loopDoorListCount); + if (checkOpen EQ 1) { + doorList = ListSetAt(doorList,loopDoorListCount,"0"); + } else { + doorList = ListSetAt(doorList,loopDoorListCount,"1"); + } + } + loopDoorListCount = loopDoorListCount + 1; + } + loopCount = loopCount + 1; + } diff --git a/Task/100-doors/ColdFusion/100-doors-2.cfm b/Task/100-doors/ColdFusion/100-doors-2.cfm new file mode 100644 index 0000000000..f08b1ff57e --- /dev/null +++ b/Task/100-doors/ColdFusion/100-doors-2.cfm @@ -0,0 +1,11 @@ + doorCount = 1; + doorList = ""; + loopCount = 1; + while (loopCount LTE 100) { + if (Sqr(loopCount) NEQ Int(Sqr(loopCount))) { + doorList = ListAppend(doorList,0); + } else { + doorList = ListAppend(doorList,1); + } + loopCount = loopCount + 1; + } diff --git a/Task/100-doors/ColdFusion/100-doors-3.cfm b/Task/100-doors/ColdFusion/100-doors-3.cfm new file mode 100644 index 0000000000..b622ac1256 --- /dev/null +++ b/Task/100-doors/ColdFusion/100-doors-3.cfm @@ -0,0 +1,11 @@ + // Display all doors + + Door #x# Open: #YesNoFormat(ListGetAt(doorList,x))#
+
+ + // Output only open doors + + + #x#
+
+
diff --git a/Task/100-doors/Common-Lisp/100-doors-1.lisp b/Task/100-doors/Common-Lisp/100-doors-1.lisp new file mode 100644 index 0000000000..8d15fb97ef --- /dev/null +++ b/Task/100-doors/Common-Lisp/100-doors-1.lisp @@ -0,0 +1,38 @@ +(defun visit-door (doors doornum value1 value2) + "visits a door, swapping the value1 to value2 or vice-versa" + (let ((d (copy-list doors)) + (n (- doornum 1))) + (if (eql (nth n d) value1) + (setf (nth n d) value2) + (setf (nth n d) value1)) + d)) + +(defun visit-every (doors num iter value1 value2) + "visits every 'num' door in the list" + (if (> (* iter num) (length doors)) + doors + (visit-every (visit-door doors (* num iter) value1 value2) + num + (+ 1 iter) + value1 + value2))) + +(defun do-all-visits (doors cnt value1 value2) + "Visits all doors changing the values accordingly" + (if (< cnt 1) + doors + (do-all-visits (visit-every doors cnt 1 value1 value2) + (- cnt 1) + value1 + value2))) + +(defun print-doors (doors) + "Pretty prints the doors list" + (format T "~{~A ~A ~A ~A ~A ~A ~A ~A ~A ~A~%~}~%" doors)) + +(defun start (&optional (size 100)) + "Start the program" + (let* ((open "_") + (shut "#") + (doors (make-list size :initial-element shut))) + (print-doors (do-all-visits doors size open shut)))) diff --git a/Task/100-doors/Common-Lisp/100-doors-2.lisp b/Task/100-doors/Common-Lisp/100-doors-2.lisp new file mode 100644 index 0000000000..973d3f0b46 --- /dev/null +++ b/Task/100-doors/Common-Lisp/100-doors-2.lisp @@ -0,0 +1,9 @@ +(define-modify-macro toggle () not) + +(defun 100-doors () + (let ((doors (make-array 100 :initial-element nil))) + (dotimes (i 100) + (loop for j from i below 100 by (1+ i) + do (toggle (svref doors j)))) + (dotimes (i 100) + (format t "door ~a: ~:[closed~;open~]~%" (1+ i) (svref doors i))))) diff --git a/Task/100-doors/Common-Lisp/100-doors-3.lisp b/Task/100-doors/Common-Lisp/100-doors-3.lisp new file mode 100644 index 0000000000..3fa15ab328 --- /dev/null +++ b/Task/100-doors/Common-Lisp/100-doors-3.lisp @@ -0,0 +1,21 @@ +(defun perfect-square-list (n) + "Generates a list of perfect squares from 0 up to n" + (loop for i from 1 to (sqrt n) collect (expt i 2))) + +(defun open-door (doors num open) + "Sets door at num to open" + (setf (nth (- num 1) doors) open) + doors) + +(defun visit-all (doors vlist open) + "Visits and opens all the doors indicated in vlist" + (if (null vlist) + doors + (visit-all (open-door doors (car vlist) open) + (cdr vlist) + open))) + +(defun start2 (&optional (size 100)) + "Start the program" + (print-doors (visit-all (make-list size :initial-element "#") + (perfect-square-list size) "_"))) diff --git a/Task/100-doors/Common-Lisp/100-doors-4.lisp b/Task/100-doors/Common-Lisp/100-doors-4.lisp new file mode 100644 index 0000000000..b791c006f2 --- /dev/null +++ b/Task/100-doors/Common-Lisp/100-doors-4.lisp @@ -0,0 +1,5 @@ +(let ((i 0)) + (mapcar (lambda (x) + (if (zerop (mod (sqrt (incf i)) 1)) + "_" "#")) + (make-list 100))) diff --git a/Task/100-doors/D/100-doors.d b/Task/100-doors/D/100-doors.d new file mode 100644 index 0000000000..36a6d0204c --- /dev/null +++ b/Task/100-doors/D/100-doors.d @@ -0,0 +1,36 @@ +import std.stdio; + +enum DoorState { Closed, Open } +alias DoorState[] Doors; + +Doors flipUnoptimized(Doors doors) { + doors[] = DoorState.Closed; + foreach (i; 0 .. doors.length) + for (int j = i; j < doors.length; j += i+1) + if (doors[j] == DoorState.Open) + doors[j] = DoorState.Closed; + else + doors[j] = DoorState.Open; + return doors; +} + +Doors flipOptimized(Doors doors) { + doors[] = DoorState.Closed; + for (int i = 1; i*i <= doors.length; i++) + doors[i*i - 1] = DoorState.Open; + return doors; +} + +// test program +void main() { + auto doors = new Doors(100); + foreach (i, door; flipUnoptimized(doors)) + if (door == DoorState.Open) + write(i+1, " "); + writeln(); + + foreach (i, door; flipOptimized(doors)) + if (door == DoorState.Open) + write(i+1, " "); + writeln(); +} diff --git a/Task/100-doors/DWScript/100-doors.dwscript b/Task/100-doors/DWScript/100-doors.dwscript new file mode 100644 index 0000000000..f55e6a854b --- /dev/null +++ b/Task/100-doors/DWScript/100-doors.dwscript @@ -0,0 +1,11 @@ +var doors : array [1..100] of Boolean; +var i, j : Integer; + +for i := 1 to 100 do + for j := i to 100 do + if (j mod i) = 0 then + doors[j] := not doors[j]; + +for i := 1 to 100 do + if doors[i] then + PrintLn('Door '+IntToStr(i)+' is open'); diff --git a/Task/100-doors/Dart/100-doors-1.dart b/Task/100-doors/Dart/100-doors-1.dart new file mode 100644 index 0000000000..956ebd918c --- /dev/null +++ b/Task/100-doors/Dart/100-doors-1.dart @@ -0,0 +1,7 @@ +main() { + for (var k = 1, x = new List(101); k <= 100; k++) { + for (int i = k; i <= 100; i += k) + x[i] = !x[i]; + if (x[k]) print("$k open"); + } +} diff --git a/Task/100-doors/Dart/100-doors-2.dart b/Task/100-doors/Dart/100-doors-2.dart new file mode 100644 index 0000000000..ef8b007c89 --- /dev/null +++ b/Task/100-doors/Dart/100-doors-2.dart @@ -0,0 +1,4 @@ +main() { + for(int i=1,s=3;i<=100;i+=s,s+=2) + print("door $i is open"); +} diff --git a/Task/100-doors/E/100-doors.e b/Task/100-doors/E/100-doors.e new file mode 100644 index 0000000000..b881023fd6 --- /dev/null +++ b/Task/100-doors/E/100-doors.e @@ -0,0 +1,45 @@ +#!/usr/bin/env rune + +var toggles := [] +var gets := [] + +# Set up GUI (and data model) +def frame := ("100 doors") +frame.getContentPane().setLayout((10, 10)) +for i in 1..100 { + def component := (E.toString(i)) + toggles with= fn { component.setSelected(!component.isSelected()) } + gets with= fn { component.isSelected() } + frame.getContentPane().add(component) +} + +# Set up termination condition +def done +frame.addWindowListener(def _ { + to windowClosing(event) { + bind done := true + } + match _ {} +}) + +# Open and close doors +def loop(step, i) { + toggles[i] <- () + def next := i + step + timer.whenPast(timer.now() + 10, fn { + if (next >= 100) { + if (step >= 100) { + # Done. + } else { + loop <- (step + 1, step) + } + } else { + loop <- (step, i + step) + } + }) +} +loop(1, 0) + +frame.pack() +frame.show() +interp.waitAtTop(done) diff --git a/Task/100-doors/EGL/100-doors.egl b/Task/100-doors/EGL/100-doors.egl new file mode 100644 index 0000000000..763e65c956 --- /dev/null +++ b/Task/100-doors/EGL/100-doors.egl @@ -0,0 +1,22 @@ +program OneHundredDoors + + function main() + + doors boolean[] = new boolean[100]; + n int = 100; + + for (i int from 1 to n) + for (j int from i to n by i) + doors[j] = !doors[j]; + end + end + + for (i int from 1 to n) + if (doors[i]) + SysLib.writeStdout( "Door " + i + " is open" ); + end + end + + end + +end diff --git a/Task/100-doors/Ela/100-doors-1.ela b/Task/100-doors/Ela/100-doors-1.ela new file mode 100644 index 0000000000..c129f787eb --- /dev/null +++ b/Task/100-doors/Ela/100-doors-1.ela @@ -0,0 +1,11 @@ +open generic + +type Door = Open | Closed + deriving Show + +gate [] _ = [] +gate (x::xs) (y::ys) + | x == y = Open :: gate xs ys + | else = Closed :: gate xs ys + +run n = gate [1..n] [& k*k \\ k <- [1..]] diff --git a/Task/100-doors/Ela/100-doors-2.ela b/Task/100-doors/Ela/100-doors-2.ela new file mode 100644 index 0000000000..0ca4360e86 --- /dev/null +++ b/Task/100-doors/Ela/100-doors-2.ela @@ -0,0 +1,2 @@ +open list +run n = takeWhile (function Doors () ... +$ doors:=zeros(1,100); +$ for i=1 to 100 +$ for j=i to 100 step i +$ doors[j]=!doors[j]; +$ end; +$ end; +$ return doors +$endfunction +>nonzeros(Doors()) + [ 1 4 9 16 25 36 49 64 81 100 ] diff --git a/Task/100-doors/Euphoria/100-doors.euphoria b/Task/100-doors/Euphoria/100-doors.euphoria new file mode 100644 index 0000000000..989e2a7ae4 --- /dev/null +++ b/Task/100-doors/Euphoria/100-doors.euphoria @@ -0,0 +1,23 @@ +-- doors.ex +include std/console.e +sequence doors +doors = repeat( 0, 100 ) -- 1 to 100, initialised to false + +for pass = 1 to 100 do + for door = pass to 100 by pass do + --printf( 1, "%d", doors[door] ) + --printf( 1, "%d", not doors[door] ) + doors[door] = not doors[door] + end for +end for + +sequence oc + +for i = 1 to 100 do + if doors[i] then + oc = "open" + else + oc = "closed" + end if + printf( 1, "door %d is %s\n", { i, oc } ) +end for diff --git a/Task/24-game/C++/24-game.cpp b/Task/24-game/C++/24-game.cpp new file mode 100644 index 0000000000..9ac471eda3 --- /dev/null +++ b/Task/24-game/C++/24-game.cpp @@ -0,0 +1,98 @@ +#include +#include +#include +#include +#include +#include +using namespace std; + +class RPNParse +{ +public: + stack stk; + multiset digits; + + void op(function f) + { + if(stk.size() < 2) + throw "Improperly written expression"; + int b = stk.top(); stk.pop(); + int a = stk.top(); stk.pop(); + stk.push(f(a, b)); + } + + void parse(char c) + { + if(c >= '0' && c <= '9') + { + stk.push(c - '0'); + digits.insert(c - '0'); + } + else if(c == '+') + op([](double a, double b) {return a+b;}); + else if(c == '-') + op([](double a, double b) {return a-b;}); + else if(c == '*') + op([](double a, double b) {return a*b;}); + else if(c == '/') + op([](double a, double b) {return a/b;}); + } + + void parse(string s) + { + for(int i = 0; i < s.size(); ++i) + parse(s[i]); + } + + double getResult() + { + if(stk.size() != 1) + throw "Improperly written expression"; + return stk.top(); + } +}; + +int main() +{ + random_device seed; + mt19937 engine(seed()); + uniform_int_distribution<> distribution(1, 9); + auto rnd = bind(distribution, engine); + + multiset digits; + cout << "Make 24 with the digits: "; + for(int i = 0; i < 4; ++i) + { + int n = rnd(); + cout << " " << n; + digits.insert(n); + } + cout << endl; + + RPNParse parser; + + try + { + string input; + getline(cin, input); + parser.parse(input); + + if(digits != parser.digits) + cout << "Error: Not using the given digits" << endl; + else + { + double r = parser.getResult(); + cout << "Result: " << r << endl; + + if(r > 23.999 && r < 24.001) + cout << "Good job!" << endl; + else + cout << "Try again." << endl; + } + } + catch(char* e) + { + cout << "Error: " << e << endl; + } + return 0; +} diff --git a/Task/24-game/Common-Lisp/24-game-1.lisp b/Task/24-game/Common-Lisp/24-game-1.lisp new file mode 100644 index 0000000000..89aacc0051 --- /dev/null +++ b/Task/24-game/Common-Lisp/24-game-1.lisp @@ -0,0 +1,36 @@ +(define-condition choose-digits () ()) +(define-condition bad-equation (error) ()) + +(defun 24-game () + (let (chosen-digits) + (labels ((prompt () + (format t "Chosen digits: ~{~D~^, ~}~%~ + Enter expression (or `bye' to quit, `!' to choose new digits): " + chosen-digits) + (read)) + (lose () (error 'bad-equation)) + (choose () (setf chosen-digits (loop repeat 4 collecting (random 10)))) + (check (e) + (typecase e + ((eql bye) (return-from 24-game)) + ((eql !) (signal 'choose-digits)) + (atom (lose)) + (cons (check-sub (car e) (check-sub (cdr e) chosen-digits)) e))) + (check-sub (sub allowed-digits) + (typecase sub + ((member nil + - * /) allowed-digits) + (integer + (if (member sub allowed-digits) + (remove sub allowed-digits :count 1) + (lose))) + (cons (check-sub (car sub) (check-sub (cdr sub) allowed-digits))) + (t (lose)))) + (win () + (format t "You win.~%") + (return-from 24-game))) + (choose) + (loop + (handler-case + (if (= 24 (eval (check (prompt)))) (win) (lose)) + (error () (format t "Bad equation, try again.~%")) + (choose-digits () (choose))))))) diff --git a/Task/24-game/Common-Lisp/24-game-2.lisp b/Task/24-game/Common-Lisp/24-game-2.lisp new file mode 100644 index 0000000000..03d46f0d94 --- /dev/null +++ b/Task/24-game/Common-Lisp/24-game-2.lisp @@ -0,0 +1,104 @@ +(defconstant +ops+ '(* / + -)) + +(defun expr-numbers (e &optional acc) + "Return all the numbers in argument positions in the expression." + (cond + ((numberp e) (cons e acc)) + ((consp e) + (append (apply #'append + (mapcar #'expr-numbers (cdr e))) + acc)))) + +(defun expr-well-formed-p (e) + "Return non-nil if the given expression is well-formed." + (cond + ((numberp e) t) + ((consp e) + (and (member (car e) +ops+) + (every #'expr-well-formed-p (cdr e)))) + (t nil))) + +(defun expr-valid-p (e available-digits) + "Return non-nil if the expression is well-formed and uses exactly +the digits specified." + (and (expr-well-formed-p e) + (equalp (sort (copy-seq available-digits) #'<) + (sort (expr-numbers e) #'<)))) + +(defun expr-get (&optional using) + (emit "Enter lisp form~@[ using the digit~P ~{~D~^ ~}~]: " + (when using + (length using)) using) + (let (*read-eval*) + (read))) + +(defun digits () + (sort (loop repeat 4 collect (1+ (random 9))) #'<)) + +(defun emit (fmt &rest args) + (format t "~&~?" fmt args)) + +(defun prompt (digits) + (emit "Using only these operators:~%~%~ + ~2T~{~A~^ ~}~%~%~ + And exactly these numbers \(no repetition\):~%~%~ + ~2T~{~D~^ ~}~%~%~ + ~A" + +ops+ digits (secondary-prompt))) + +(defun secondary-prompt () + (fill-to 50 "Enter a lisp form which evaluates to ~ + the integer 24, or \"!\" to get fresh ~ + digits, or \"q\" to abort.")) + +(defun fill-to (n fmt &rest args) + "Poor-man's text filling mechanism." + (loop with s = (format nil "~?" fmt args) + for c across s + and i from 0 + and j = 0 then (1+ j) ; since-last-newline ctr + + when (char= c #\Newline) + do (setq j 0) + + else when (and (not (zerop j)) + (zerop (mod j n))) + do (loop for k from i below (length s) + when (char= #\Space (schar s k)) + do (progn + (setf (schar s k) #\Newline + j 0) + (loop-finish))) + finally (return s))) + +(defun 24-game () + (loop with playing-p = t + and initial-digits = (digits) + + for attempts from 0 + and digits = initial-digits then (digits) + + while playing-p + + do (loop for e = (expr-get (unless (zerop attempts) + digits)) + do + (case e + (! (loop-finish)) + (Q (setq playing-p nil) + (loop-finish)) + (R (emit "Current digits: ~S" digits)) + (t + (if (expr-valid-p e digits) + (let ((v (eval e))) + (if (eql v 24) + (progn + (emit "~%~%---> A winner is you! <---~%~%") + (setq playing-p nil) + (loop-finish)) + (emit "Sorry, the form you entered ~ + computes to ~S, not 24.~%~%" + v))) + (emit "Sorry, the form you entered did not ~ + compute.~%~%"))))) + initially (prompt initial-digits))) diff --git a/Task/24-game/D/24-game.d b/Task/24-game/D/24-game.d new file mode 100644 index 0000000000..f3ee779f0b --- /dev/null +++ b/Task/24-game/D/24-game.d @@ -0,0 +1,37 @@ +import std.stdio, std.random, std.math, std.algorithm, std.range, + std.typetuple; + +void main() { + void op(char c)() { + if (stack.length < 2) + throw new Exception("Wrong expression."); + stack[$ - 2] = mixin("stack[$ - 2]" ~ c ~ "stack[$ - 1]"); + stack.popBack(); + } + + const problem = iota(4).map!(_ => uniform(1, 10))().array(); + writeln("Make 24 with the digits: ", problem); + + double[] stack; + int[] digits; + foreach (const char c; readln()) + switch (c) { + case ' ', '\t', '\n': break; + case '1': .. case '9': + stack ~= c - '0'; + digits ~= c - '0'; + break; + foreach (o; TypeTuple!('+', '-', '*', '/')) { + case o: op!o(); break; + } + break; + default: throw new Exception("Wrong char: " ~ c); + } + + if (!digits.sort().equal(problem.dup.sort())) + throw new Exception("Not using the given digits."); + if (stack.length != 1) + throw new Exception("Wrong expression."); + writeln("Result: ", stack[0]); + writeln(abs(stack[0] - 24) < 0.001 ? "Good job!" : "Try again."); +} diff --git a/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-1.cpp b/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-1.cpp new file mode 100644 index 0000000000..f69026e06f --- /dev/null +++ b/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-1.cpp @@ -0,0 +1,13 @@ +#include +using namespace std; + +int main() +{ + int bottles = 99; + do { + cout << bottles << " bottles of beer on the wall" << endl; + cout << bottles << " bottles of beer" << endl; + cout << "Take one down, pass it around" << endl; + cout << --bottles << " bottles of beer on the wall\n" << endl; + } while (bottles > 0); +} diff --git a/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-2.cpp b/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-2.cpp new file mode 100644 index 0000000000..4fd5341069 --- /dev/null +++ b/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-2.cpp @@ -0,0 +1,28 @@ +#include + +template struct bottle_countdown +{ + static const int middle = (min + max)/2; + static void print() + { + bottle_countdown::print(); + bottle_countdown::print(); + } +}; + +template struct bottle_countdown +{ + static void print() + { + std::cout << value << " bottles of beer on the wall\n" + << value << " bottles of beer\n" + << "Take one down, pass it around\n" + << value-1 << " bottles of beer\n\n"; + } +}; + +int main() +{ + bottle_countdown<100, 1>::print(); + return 0; +} diff --git a/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-3.cpp b/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-3.cpp new file mode 100644 index 0000000000..ccd7a2151f --- /dev/null +++ b/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-3.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; +void rec(int bottles) +{ +if ( bottles!=0) + { + cout << bottles << " bottles of beer on the wall" << endl; + cout << bottles << " bottles of beer" << endl; + cout << "Take one down, pass it around" << endl; + cout << --bottles << " bottles of beer on the wall\n" << endl; + rec(bottles); + } +} + +int main() + { +rec(99); +system("pause"); +return 0; +} diff --git a/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-4.cpp b/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-4.cpp new file mode 100644 index 0000000000..ca2386a207 --- /dev/null +++ b/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-4.cpp @@ -0,0 +1,30 @@ +#include +#include + +#define BOTTLE(nstr) nstr " bottles of beer" + +#define WALL(nstr) BOTTLE(nstr) " on the wall" + +#define PART1(nstr) WALL(nstr) "\n" BOTTLE(nstr) \ + "\nTake one down, pass it around\n" + +#define PART2(nstr) WALL(nstr) "\n\n" + +#define MIDDLE(nstr) PART2(nstr) PART1(nstr) + +#define SONG PART1("100") CD2 PART2("0") + +#define CD2 CD3("9") CD3("8") CD3("7") CD3("6") CD3("5") \ + CD3("4") CD3("3") CD3("2") CD3("1") CD4("") + +#define CD3(pre) CD4(pre) MIDDLE(pre "0") + +#define CD4(pre) MIDDLE(pre "9") MIDDLE(pre "8") MIDDLE(pre "7") \ + MIDDLE(pre "6") MIDDLE(pre "5") MIDDLE(pre "4") MIDDLE(pre "3") \ + MIDDLE(pre "2") MIDDLE(pre "1") + +int main() +{ + std::cout << SONG; + return 0; +} diff --git a/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-5.cpp b/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-5.cpp new file mode 100644 index 0000000000..64d050a7a7 --- /dev/null +++ b/Task/99-Bottles-of-Beer/C++/99-bottles-of-beer-5.cpp @@ -0,0 +1,37 @@ + //>,_ + //Beer Song>,_ + #include + using namespace std; + int main(){ for( int + b=-1; b<99; cout << + '\n') for ( int w=0; + w<3; cout << ".\n"){ + if (w==2) cout << (( + b--) ?"Take one dow" + "n and pass it arou" + "nd":"Go to the sto" + "re and buy some mo" + "re"); if (b<0) b=99 + ; do{ if (w) cout << + ", "; if (b) cout << + b; else cout << ( + (w) ? 'n' : 'N') << + "o more"; cout << + " bottle" ; if + (b!=1) cout << + 's' ; cout << + " of beer"; + if (w!=1) + cout << + " on th" + "e wall" + ;} while + (!w++);} + return + 0 + ; + } + // + // by barrym 2011-05-01 + // no bottles were harmed in the + // making of this program!!! diff --git a/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-1.cs b/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-1.cs new file mode 100644 index 0000000000..5b8c096f4a --- /dev/null +++ b/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-1.cs @@ -0,0 +1,29 @@ +using System; + +class Program +{ + static void Main(string[] args) + { + for (int i = 99; i > -1; i--) + { + if (i == 0) + { + Console.WriteLine("No more bottles of beer on the wall, no more bottles of beer."); + Console.WriteLine("Go to the store and buy some more, 99 bottles of beer on the wall."); + break; + } + if (i == 1) + { + Console.WriteLine("1 bottle of beer on the wall, 1 bottle of beer."); + Console.WriteLine("Take one down and pass it around, no more bottles of beer on the wall."); + Console.WriteLine(); + } + else + { + Console.WriteLine("{0} bottles of beer on the wall, {0} bottles of beer.", i); + Console.WriteLine("Take one down and pass it around, {0} bottles of beer on the wall.", i - 1); + Console.WriteLine(); + } + } + } +} diff --git a/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-2.cs b/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-2.cs new file mode 100644 index 0000000000..0c8b560b4e --- /dev/null +++ b/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-2.cs @@ -0,0 +1,18 @@ +using System; +using System.Linq; + +class Program +{ + static void Main() + { + var query = from total in Enumerable.Range(0,100).Reverse() + select (total > 0) + ? string.Format("{0} bottles of beer on the wall\n{0} bottles of beer\nTake one down, pass it around", total) + : string.Format("{0} bottles left", total); + + foreach (var item in query) + { + Console.WriteLine(item); + } + } +} diff --git a/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-3.cs b/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-3.cs new file mode 100644 index 0000000000..df76d8ce8e --- /dev/null +++ b/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-3.cs @@ -0,0 +1,28 @@ +class songs +{ + static void Main(string[] args) + { + beer(5); + } + + private static void beer(int bottles) + { + for (int i = bottles; i > 0; i--) + { + if (i > 1) + { + Console.Write("{0}\n{1}\n{2}\n{3}\n\n", + i + " bottles of beer on the wall", + i + " bottles of beer", + "Take one down, pass it around", + (i - 1) + " bottles of beer on the wall"); + } + else + Console.Write("{0}\n{1}\n{2}\n{3}\n\n", + i + " bottle of beer on the wall", + i + " bottle of beer", + "Take one down, pass it around", + (i - 1) + " bottles of beer on the wall...."); + } + } +} diff --git a/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-4.cs b/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-4.cs new file mode 100644 index 0000000000..87df3fd53e --- /dev/null +++ b/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-4.cs @@ -0,0 +1,21 @@ +using System; +using System.Linq; + +class Program +{ + static void Main() + { + BeerBottles().Take(99).ToList().ForEach(Console.WriteLine); + } + + static IEnumerable BeerBottles() + { + int i = 100; + String f = "{0}, {1}. Take one down, pass it around, {2}"; + Func booze = (c , b) => + String.Format("{0} bottle{1} of beer{2}", c > 0 ? c.ToString() : "no more", (c == 1 ? "" : "s"), b ? " on the wall" : ""); + + while (--i >= 1) + yield return String.Format(f, booze(i, true), booze(i, false), booze(i - 1, true)); + } +} diff --git a/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-5.cs b/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-5.cs new file mode 100644 index 0000000000..f087b131bd --- /dev/null +++ b/Task/99-Bottles-of-Beer/C-sharp/99-bottles-of-beer-5.cs @@ -0,0 +1,131 @@ +string[] bottles = { "80 Shilling", + "Abita Amber", + "Adams Broadside Ale", + "Altenmünster Premium", + "August Schell's SnowStorm", + "Bah Humbug! Christmas Ale", + "Beck's Oktoberfest", + "Belhaven Wee Heavy", + "Bison Chocolate Stout", + "Blue Star Wheat Beer", + "Bridgeport Black Strap Stout", + "Brother Thelonius Belgian-Style Abbey Ale", + "Capital Blonde Doppelbock", + "Carta Blanca", + "Celis Raspberry Wheat", + "Christian Moerlein Select Lager", + "Corona", + "Czechvar", + "Delirium Tremens", + "Diamond Bear Southern Blonde", + "Don De Dieu", + "Eastside Dark", + "Eliot Ness", + "Flying Dog K-9 Cruiser Altitude Ale", + "Fuller's London Porter", + "Gaffel Kölsch", + "Golden Horseshoe", + "Guinness Pub Draught", + "Hacker-Pschorr Weisse", + "Hereford & Hops Black Spring Double Stout", + "Highland Oatmeal Porter", + "Ipswich Ale", + "Iron City", + "Jack Daniel's Amber Lager", + "Jamaica Sunset India Pale Ale", + "Killian's Red", + "König Ludwig Weiss", + "Kronenbourg 1664", + "Lagunitas Hairy Eyball Ale", + "Left Hand Juju Ginger", + "Locktender Lager", + "Magic Hat Blind Faith", + "Missing Elf Double Bock", + "Muskoka Cream Ale ", + "New Glarus Cherry Stout", + "Nostradamus Bruin", + "Old Devil", + "Ommegang Three Philosophers", + "Paulaner Hefe-Weizen Dunkel", + "Perla Chmielowa Pils", + "Pete's Wicked Springfest", + "Point White Biere", + "Prostel Alkoholfrei", + "Quilmes", + "Rahr's Red", + "Rebel Garnet", + "Rickard's Red", + "Rio Grande Elfego Bock", + "Rogue Brutal Bitter", + "Roswell Alien Amber Ale", + "Russian River Pliny The Elder", + "Samuel Adams Blackberry Witbier", + "Samuel Smith's Taddy Porter", + "Schlafly Pilsner", + "Sea Dog Wild Blueberry Wheat Ale", + "Sharp's", + "Shiner 99", + "Sierra Dorada", + "Skullsplitter Orkney Ale", + "Snake Chaser Irish Style Stout", + "St. Arnold Bock", + "St. Peter's Cream Stout", + "Stag", + "Stella Artois", + "Stone Russian Imperial Stout", + "Sweetwater Happy Ending Imperial Stout", + "Taiwan Gold Medal", + "Terrapin Big Hoppy Monster", + "Thomas Hooker American Pale Ale", + "Tie Die Red Ale", + "Toohey's Premium", + "Tsingtao", + "Ugly Pug Black Lager", + "Unibroue Qatre-Centieme", + "Victoria Bitter", + "Voll-Damm Doble Malta", + "Wailing Wench Ale", + "Warsteiner Dunkel", + "Wellhead Crude Oil Stout", + "Weyerbacher Blithering Idiot Barley-Wine Style Ale", + "Wild Boar Amber", + "Würzburger Oktoberfest", + "Xingu Black Beer", + "Yanjing", + "Younger's Tartan Special", + "Yuengling Black & Tan", + "Zagorka Special", + "Zig Zag River Lager", + "Zywiec" }; + + +int bottlesLeft = 99; +const int FIRST_LINE_SINGULAR = 98; +const int FINAL_LINE_SINGULAR = 97; +string firstLine = ""; +string finalLine = ""; + + +for (int i = 0; i < 99; i++) +{ + firstLine = bottlesLeft.ToString() + " bottle"; + if (i != FIRST_LINE_SINGULAR) + firstLine += "s"; + firstLine += " of beer on the wall, " + bottlesLeft.ToString() + " bottle"; + if (i != FIRST_LINE_SINGULAR) + firstLine += "s"; + firstLine += " of beer"; + + Console.WriteLine(firstLine); + Console.WriteLine("Take the " + bottles[i] + " down, pass it around,"); + bottlesLeft--; + + finalLine = bottlesLeft.ToString() + " bottle"; + if (i != FINAL_LINE_SINGULAR) + finalLine += "s"; + finalLine += " of beer on the wall!"; + + Console.WriteLine(finalLine); + Console.WriteLine(); + Console.ReadLine(); +} diff --git a/Task/99-Bottles-of-Beer/CLIPS/99-bottles-of-beer.clips b/Task/99-Bottles-of-Beer/CLIPS/99-bottles-of-beer.clips new file mode 100644 index 0000000000..b2a5acec46 --- /dev/null +++ b/Task/99-Bottles-of-Beer/CLIPS/99-bottles-of-beer.clips @@ -0,0 +1,19 @@ +(deffacts beer-bottles + (bottles 99)) + +(deffunction bottle-count + (?count) + (switch ?count + (case 0 then "No more bottles of beer") + (case 1 then "1 more bottle of beer") + (default (str-cat ?count " bottles of beer")))) + +(defrule stanza + ?bottles <- (bottles ?count) + => + (retract ?bottles) + (printout t (bottle-count ?count) " on the wall," crlf) + (printout t (bottle-count ?count) "." crlf) + (printout t "Take one down, pass it around," crlf) + (printout t (bottle-count (- ?count 1)) " on the wall." crlf crlf) + (if (> ?count 1) then (assert (bottles (- ?count 1))))) diff --git a/Task/99-Bottles-of-Beer/COBOL/99-bottles-of-beer-1.cobol b/Task/99-Bottles-of-Beer/COBOL/99-bottles-of-beer-1.cobol new file mode 100644 index 0000000000..3da47d3761 --- /dev/null +++ b/Task/99-Bottles-of-Beer/COBOL/99-bottles-of-beer-1.cobol @@ -0,0 +1,122 @@ +identification division. +program-id. ninety-nine. +environment division. +data division. +working-storage section. +01 counter pic 99. + 88 no-bottles-left value 0. + 88 one-bottle-left value 1. + +01 parts-of-counter redefines counter. + 05 tens pic 9. + 05 digits pic 9. + +01 after-ten-words. + 05 filler pic x(7) value spaces. + 05 filler pic x(7) value "Twenty". + 05 filler pic x(7) value "Thirty". + 05 filler pic x(7) value "Forty". + 05 filler pic x(7) value "Fifty". + 05 filler pic x(7) value "Sixty". + 05 filler pic x(7) value "Seventy". + 05 filler pic x(7) value "Eighty". + 05 filler pic x(7) value "Ninety". + 05 filler pic x(7) value spaces. + +01 after-ten-array redefines after-ten-words. + 05 atens occurs 10 times pic x(7). + +01 digit-words. + 05 filler pic x(9) value "One". + 05 filler pic x(9) value "Two". + 05 filler pic x(9) value "Three". + 05 filler pic x(9) value "Four". + 05 filler pic x(9) value "Five". + 05 filler pic x(9) value "Six". + 05 filler pic x(9) value "Seven". + 05 filler pic x(9) value "Eight". + 05 filler pic x(9) value "Nine". + 05 filler pic x(9) value "Ten". + 05 filler pic x(9) value "Eleven". + 05 filler pic x(9) value "Twelve". + 05 filler pic x(9) value "Thirteen". + 05 filler pic x(9) value "Fourteen". + 05 filler pic x(9) value "Fifteen". + 05 filler pic x(9) value "Sixteen". + 05 filler pic x(9) value "Seventeen". + 05 filler pic x(9) value "Eighteen". + 05 filler pic x(9) value "Nineteen". + 05 filler pic x(9) value spaces. + +01 digit-array redefines digit-words. + 05 adigits occurs 20 times pic x(9). + +01 number-name pic x(15). + +01 stringified pic x(30). +01 outline pic x(50). +01 other-numbers. + 03 n pic 999. + 03 r pic 999. + +procedure division. +100-main section. +100-setup. + perform varying counter from 99 by -1 until no-bottles-left + move spaces to outline + perform 100-show-number + string stringified delimited by "|", space, "of beer on the wall" into outline end-string + display outline end-display + move spaces to outline + string stringified delimited by "|", space, "of beer" into outline end-string + display outline end-display + move spaces to outline + move "Take" to outline + if one-bottle-left + string outline delimited by space, space, "it" delimited by size, space, "|" into outline end-string + else + string outline delimited by space, space, "one" delimited by size, space, "|" into outline end-string + end-if + string outline delimited by "|", "down and pass it round" delimited by size into outline end-string + display outline end-display + move spaces to outline + subtract 1 from counter giving counter end-subtract + perform 100-show-number + string stringified delimited by "|", space, "of beer on the wall" into outline end-string + display outline end-display + add 1 to counter giving counter end-add + display space end-display + end-perform. + display "No more bottles of beer on the wall" + display "No more bottles of beer" + display "Go to the store and buy some more" + display "Ninety-Nine bottles of beer on the wall" + stop run. + +100-show-number. + if no-bottles-left + move "No more|" to stringified + else + if counter < 20 + string function trim( adigits( counter ) ), "|" into stringified + else + if counter < 100 + move spaces to number-name + string atens( tens ) delimited by space, space delimited by size, adigits( digits ) delimited by space into number-name end-string + move function trim( number-name) to stringified + divide counter by 10 giving n remainder r end-divide + if r not = zero + inspect stringified replacing first space by "-" + end-if + inspect stringified replacing first space by "|" + end-if + end-if + end-if. + if one-bottle-left + string stringified delimited by "|", space, "bottle|" delimited by size into stringified end-string + else + string stringified delimited by "|", space, "bottles|" delimited by size into stringified end-string + end-if. + +100-end. +end-program. diff --git a/Task/99-Bottles-of-Beer/COBOL/99-bottles-of-beer-2.cobol b/Task/99-Bottles-of-Beer/COBOL/99-bottles-of-beer-2.cobol new file mode 100644 index 0000000000..6dd44ed15c --- /dev/null +++ b/Task/99-Bottles-of-Beer/COBOL/99-bottles-of-beer-2.cobol @@ -0,0 +1,104 @@ +identification division. +program-id. ninety-nine. +environment division. +data division. +working-storage section. +01 counter pic 99. + 88 no-bottles-left value 0. + 88 one-bottle-left value 1. + +01 parts-of-counter redefines counter. + 05 tens pic 9. + 05 digits pic 9. + +01 after-ten-words. + 05 filler pic x(7) value spaces. + 05 filler pic x(7) value "Twenty". + 05 filler pic x(7) value "Thirty". + 05 filler pic x(7) value "Forty". + 05 filler pic x(7) value "Fifty". + 05 filler pic x(7) value "Sixty". + 05 filler pic x(7) value "Seventy". + 05 filler pic x(7) value "Eighty". + 05 filler pic x(7) value "Ninety". + 05 filler pic x(7) value spaces. + +01 after-ten-array redefines after-ten-words. + 05 atens occurs 10 times pic x(7). + +01 digit-words. + 05 filler pic x(9) value "One". + 05 filler pic x(9) value "Two". + 05 filler pic x(9) value "Three". + 05 filler pic x(9) value "Four". + 05 filler pic x(9) value "Five". + 05 filler pic x(9) value "Six". + 05 filler pic x(9) value "Seven". + 05 filler pic x(9) value "Eight". + 05 filler pic x(9) value "Nine". + 05 filler pic x(9) value "Ten". + 05 filler pic x(9) value "Eleven". + 05 filler pic x(9) value "Twelve". + 05 filler pic x(9) value "Thirteen". + 05 filler pic x(9) value "Fourteen". + 05 filler pic x(9) value "Fifteen". + 05 filler pic x(9) value "Sixteen". + 05 filler pic x(9) value "Seventeen". + 05 filler pic x(9) value "Eighteen". + 05 filler pic x(9) value "Nineteen". + 05 filler pic x(9) value spaces. + +01 digit-array redefines digit-words. + 05 adigits occurs 20 times pic x(9). + +01 number-name pic x(15). + +procedure division. +100-main section. +100-setup. + perform varying counter from 99 by -1 until no-bottles-left + perform 100-show-number + display " of beer on the wall" + perform 100-show-number + display " of beer" + display "Take " with no advancing + if one-bottle-left + display "it " with no advancing + else + display "one " with no advancing + end-if + display "down and pass it round" + subtract 1 from counter giving counter + perform 100-show-number + display " of beer on the wall" + add 1 to counter giving counter + display space + end-perform. + display "No more bottles of beer on the wall" + display "No more bottles of beer" + display "Go to the store and buy some more" + display "Ninety Nine bottles of beer on the wall" + stop run. + +100-show-number. + if no-bottles-left + display "No more" with no advancing + else + if counter < 20 + display function trim( adigits( counter ) ) with no advancing + else + if counter < 100 + move spaces to number-name + string atens( tens ) delimited by space, space delimited by size, adigits( digits ) delimited by space into number-name + display function trim( number-name) with no advancing + end-if + end-if + end-if. + if one-bottle-left + display " bottle" with no advancing + else + display " bottles" with no advancing + end-if. + +100-end. +end-program. diff --git a/Task/99-Bottles-of-Beer/Chapel/99-bottles-of-beer.chapel b/Task/99-Bottles-of-Beer/Chapel/99-bottles-of-beer.chapel new file mode 100644 index 0000000000..235950df37 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Chapel/99-bottles-of-beer.chapel @@ -0,0 +1,68 @@ +/*********************************************************************** + * Chapel implementation of "99 bottles of beer" + * + * by Brad Chamberlain and Steve Deitz + * 07/13/2006 in Knoxville airport while waiting for flight home from + * HPLS workshop + * compiles and runs with chpl compiler version 0.3.3211 + * for more information, contact: chapel_info@cray.com + * + * + * Notes: + * o as in all good parallel computations, boundary conditions + * constitute the vast bulk of complexity in this code (invite Brad to + * tell you about his zany boundary condition simplification scheme) + * o uses type inference for variables, arguments + * o relies on integer->string coercions + * o uses named argument passing (for documentation purposes only) + ***********************************************************************/ + +// allow executable command-line specification of number of bottles +// (e.g., ./a.out -snumBottles=999999) +config const numBottles = 99; +const numVerses = numBottles+1; + +// a domain to describe the space of lyrics +var LyricsSpace: domain(1) = [1..numVerses]; + +// array of lyrics +var Lyrics: [LyricsSpace] string; + +// parallel computation of lyrics array +[verse in LyricsSpace] Lyrics(verse) = computeLyric(verse); + +// as in any good parallel language, I/O to stdout is serialized. +// (Note that I/O to a file could be parallelized using a parallel +// prefix computation on the verse strings' lengths with file seeking) +writeln(Lyrics); + + +// HELPER FUNCTIONS: + +fun computeLyric(verseNum) { + var bottleNum = numBottles - (verseNum - 1); + var nextBottle = (bottleNum + numVerses - 1)%numVerses; + return "\n" // disguise space used to separate elements in array I/O + + describeBottles(bottleNum, startOfVerse=true) + " on the wall, " + + describeBottles(bottleNum) + ".\n" + + computeAction(bottleNum) + + describeBottles(nextBottle) + " on the wall.\n"; +} + + +fun describeBottles(bottleNum, startOfVerse:bool = false) { +// NOTE: bool should not be necessary here (^^^^); working around bug + var bottleDescription = if (bottleNum) then bottleNum:string + else (if startOfVerse then "N" + else "n") + + "o more"; + return bottleDescription + + " bottle" + (if (bottleNum == 1) then "" else "s") + + " of beer"; +} + + +fun computeAction(bottleNum) { + return if (bottleNum == 0) then "Go to the store and buy some more, " + else "Take one down and pass it around, "; +} diff --git a/Task/99-Bottles-of-Beer/Chef/99-bottles-of-beer.chef b/Task/99-Bottles-of-Beer/Chef/99-bottles-of-beer.chef new file mode 100644 index 0000000000..6e4597b805 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Chef/99-bottles-of-beer.chef @@ -0,0 +1,225 @@ +99 Bottles Of Beer. + +Ingredients. +99 bottles + +Method. +Loop the bottles. + Put bottles into 1st mixing bowl. + Serve with bottles of beer on the wall. + Clean 1st mixing bowl. + Put bottles into 1st mixing bowl. + Serve with bottles of beer. + Clean 1st mixing bowl. + Serve with Take one down and pass it around. + Clean 1st mixing bowl. +Loop the bottles until looped. +Serve with No more bottles of beer. +Clean 1st mixing bowl. +Pour contents of the 3rd mixing bowl into the 1st baking dish. + +Serves 1. + +bottles of beer on the wall. + +Prints out "n" bottles of beer on the wall. + +Ingredients. +108 g lime +97 cups asparagus +119 pinches watercress +32 tablespoons pickles +101 pinches eggplant +104 g huckleberry +116 teaspoons turnip +110 tablespoons nannyberry +111 tablespoons onion +114 tablespoons raspberry +98 g broccoli +102 g feijoa +115 teaspoons squach +10 ml new line + +Method. +Put new line into 1st mixing bowl. +Put lime into 2nd mixing bowl. +Put lime into 2nd mixing bowl. +Put asparagus into 2nd mixing bowl. +Put watercress into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put huckleberry into 2nd mixing bowl. +Put turnip into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put nannyberry into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put raspberry into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put broccoli into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put feijoa into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put squach into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put lime into 2nd mixing bowl. +Put turnip into 2nd mixing bowl. +Put turnip into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put broccoli into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Liquify contents of the 2nd mixing bowl. +Pour contents of the 2nd mixing bowl into the baking dish. +Pour contents of the mixing bowl into the baking dish. +Refrigerate for 1 hour. + +bottles of beer. + +Prints out "n" bottles of beer. + +Ingredients. +114 tablespoons raspberry +101 pinches eggplant +98 teaspoons broccoli +32 pinches pickles +102 tablespoons feijoa +111 teaspoons onion +115 cups squach +108 cups lime +116 teaspoons turnip +10 ml new line + +Method. +Put new line into 1st mixing bowl. +Put raspberry into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put broccoli into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put feijoa into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put squach into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put lime into 2nd mixing bowl. +Put turnip into 2nd mixing bowl. +Put turnip into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put broccoli into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Liquify contents of the 2nd mixing bowl. +Pour contents of the 2nd mixing bowl into the baking dish. +Pour contents of the mixing bowl into the baking dish. +Refrigerate for 1 hour. + +Take one down and pass it around. + +Prints out "Take one down and pass it around". + +Ingredients. +100 cups dandelion +110 g nannyberry +117 pinches cucumber +111 pinches onion +114 pinches raspberry +97 g asparagus +32 tablespoons pickles +116 pinches turnip +105 g chestnut +115 g squach +112 g pumpkin +119 cups watercress +101 g eggplant +107 g kale +84 cups tomatoe +10 ml new line + +Method. +Put new line into 3rd mixing bowl. +Put dandelion into 2nd mixing bowl. +Put nannyberry into 2nd mixing bowl. +Put cucumber into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put raspberry into 2nd mixing bowl. +Put asparagus into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put turnip into 2nd mixing bowl. +Put chestnut into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put squach into 2nd mixing bowl. +Put squach into 2nd mixing bowl. +Put asparagus into 2nd mixing bowl. +Put pumpkin into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put dandelion into 2nd mixing bowl. +Put nannyberry into 2nd mixing bowl. +Put asparagus into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put nannyberry into 2nd mixing bowl. +Put watercress into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put dandelion into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put nannyberry into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put kale into 2nd mixing bowl. +Put asparagus into 2nd mixing bowl. +Put tomatoe into 2nd mixing bowl. +Liquify contents of the 2nd mixing bowl. +Pour contents of the 2nd mixing bowl into the baking dish. +Pour contents of the 3rd mixing bowl into the baking dish. +Refrigerate for 1 hour. + +No more bottles of beer. + +Prints out "No more bottles of beer". + +Ingredients. +114 pinches raspberry +101 teaspoons eggplant +98 cups broccoli +32 tablespoons pickles +102 pinches feijoa +111 cups onion +115 tablespoons squach +108 tablespoons lime +116 pinches turnip +109 cups mushrooms +78 g nectarine +10 ml new line + +Method. +Put new line into 3rd mixing bowl. +Put new line into 2nd mixing bowl. +Put raspberry into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put broccoli into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put feijoa into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put squach into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put lime into 2nd mixing bowl. +Put turnip into 2nd mixing bowl. +Put turnip into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put broccoli into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put eggplant into 2nd mixing bowl. +Put raspberry into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put mushrooms into 2nd mixing bowl. +Put pickles into 2nd mixing bowl. +Put onion into 2nd mixing bowl. +Put nectarine into 2nd mixing bowl. +Liquify contents of the 2nd mixing bowl. +Pour contents of the 2nd mixing bowl into the baking dish. +Pour contents of the 3rd mixing bowl into the baking dish. +Refrigerate for 1 hour. diff --git a/Task/99-Bottles-of-Beer/Clay/99-bottles-of-beer.clay b/Task/99-Bottles-of-Beer/Clay/99-bottles-of-beer.clay new file mode 100644 index 0000000000..64036ceb41 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Clay/99-bottles-of-beer.clay @@ -0,0 +1,20 @@ +/* A few options here: I could give n type Int; or specify that n is of any + numeric type; but here I just let it go -- that way it'll work with anything + that compares with 1 and that printTo knows how to convert to a string. And + all checked at compile time, remember. */ +getRound(n) { + var s = String(); + var bottle = if (n == 1) " bottle " else " bottles "; + + printTo(s, + n, bottle, "of beer on the wall\n", + n, bottle, "of beer\n", + "take one down, pass it around\n", + n, bottle, "of beer on the wall!\n"); + + return s; +} + +main() { + println(join("\n", mapped(getRound, reversed(range(100))))); +} diff --git a/Task/99-Bottles-of-Beer/ColdFusion/99-bottles-of-beer-1.cfm b/Task/99-Bottles-of-Beer/ColdFusion/99-bottles-of-beer-1.cfm new file mode 100644 index 0000000000..20e5093535 --- /dev/null +++ b/Task/99-Bottles-of-Beer/ColdFusion/99-bottles-of-beer-1.cfm @@ -0,0 +1,9 @@ + + + + #x# bottle#plur# of beer on the wall
+ #x# bottle#plur# of beer
+ Take one down, pass it around
+ #iif(x is 1,DE("No more"),"x-1")# bottle#iif(x is 2,"",DE("s"))# of beer on the wall

+
+
diff --git a/Task/99-Bottles-of-Beer/ColdFusion/99-bottles-of-beer-2.cfm b/Task/99-Bottles-of-Beer/ColdFusion/99-bottles-of-beer-2.cfm new file mode 100644 index 0000000000..bde70e7f6e --- /dev/null +++ b/Task/99-Bottles-of-Beer/ColdFusion/99-bottles-of-beer-2.cfm @@ -0,0 +1,6 @@ + + for (x=99; x gte 1; x--) { + plur = iif(x==1,'',DE('s')); + WriteOutput("#x# bottle#plur# of beer on the wall
#x# bottle#plur# of beer
Take one down, pass it around
#iif(x is 1,DE('No more'),'x-1')# bottle#iif(x is 2,'',DE('s'))# of beer on the wall

"); + } +
diff --git a/Task/99-Bottles-of-Beer/Common-Lisp/99-bottles-of-beer-1.lisp b/Task/99-Bottles-of-Beer/Common-Lisp/99-bottles-of-beer-1.lisp new file mode 100644 index 0000000000..eaed32bce3 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Common-Lisp/99-bottles-of-beer-1.lisp @@ -0,0 +1,6 @@ +(defun bottles (x) + (loop for bottles from x downto 1 + do (format t "~a bottle~:p of beer on the wall +~:*~a bottle~:p of beer +Take one down, pass it around +~a bottle~:p of beer on the wall~2%" bottles (1- bottles)))) diff --git a/Task/99-Bottles-of-Beer/Common-Lisp/99-bottles-of-beer-2.lisp b/Task/99-Bottles-of-Beer/Common-Lisp/99-bottles-of-beer-2.lisp new file mode 100644 index 0000000000..f70ed72c5d --- /dev/null +++ b/Task/99-Bottles-of-Beer/Common-Lisp/99-bottles-of-beer-2.lisp @@ -0,0 +1 @@ +(bottles 99) diff --git a/Task/99-Bottles-of-Beer/D/99-bottles-of-beer.d b/Task/99-Bottles-of-Beer/D/99-bottles-of-beer.d new file mode 100644 index 0000000000..c2de71f714 --- /dev/null +++ b/Task/99-Bottles-of-Beer/D/99-bottles-of-beer.d @@ -0,0 +1,20 @@ +import std.stdio; + +void main() { + int bottles = 99; + + while (bottles > 1) { + writeln(bottles, " bottles of beer on the wall,"); + writeln(bottles, " bottles of beer."); + writeln("Take one down, pass it around,"); + if (--bottles > 1) { + writeln(bottles, " bottles of beer on the wall.\n"); + } + } + writeln("1 bottle of beer on the wall.\n"); + + writeln("No more bottles of beer on the wall,"); + writeln("no more bottles of beer."); + writeln("Go to the store and buy some more,"); + writeln("99 bottles of beer on the wall."); +} diff --git a/Task/99-Bottles-of-Beer/Dart/99-bottles-of-beer.dart b/Task/99-Bottles-of-Beer/Dart/99-bottles-of-beer.dart new file mode 100644 index 0000000000..94684cc270 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Dart/99-bottles-of-beer.dart @@ -0,0 +1,9 @@ +main() { + for(int x=99;x>0;x--) { + print("$x bottles of beer on the wall"); + print("$x bottles of beer"); + print("Take one down, pass it around"); + print("${x-1} bottles of beer on the wall"); + print(""); + } +} diff --git a/Task/99-Bottles-of-Beer/Delphi/99-bottles-of-beer.delphi b/Task/99-Bottles-of-Beer/Delphi/99-bottles-of-beer.delphi new file mode 100644 index 0000000000..011054cf5e --- /dev/null +++ b/Task/99-Bottles-of-Beer/Delphi/99-bottles-of-beer.delphi @@ -0,0 +1,27 @@ +program Hundred_Bottles; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +const C_1_Down = 'Take one down, pass it around' ; + +Var i : Integer ; + +// As requested, some fun : examples of Delphi basic techniques. Just to make it a bit complex + +procedure WriteABottle( BottleNr : Integer ) ; +begin + Writeln(BottleNr, ' bottles of beer on the wall' ) ; +end ; + +begin + for i := 99 Downto 1 do begin + WriteABottle(i); + Writeln( Format('%d bottles of beer' , [i] ) ) ; + Writeln( C_1_Down ) ; + WriteABottle(i-1); + Writeln ; +End ; + +end. diff --git a/Task/99-Bottles-of-Beer/E/99-bottles-of-beer.e b/Task/99-Bottles-of-Beer/E/99-bottles-of-beer.e new file mode 100644 index 0000000000..4d19b0fdc6 --- /dev/null +++ b/Task/99-Bottles-of-Beer/E/99-bottles-of-beer.e @@ -0,0 +1,14 @@ +def bottles(n) { + return switch (n) { + match ==0 { "No bottles" } + match ==1 { "1 bottle" } + match _ { `$n bottles` } + } +} +for n in (1..99).descending() { + println(`${bottles(n)} of beer on the wall, +${bottles(n)} of beer. +Take one down, pass it around, +${bottles(n.previous())} of beer on the wall. +`) +} diff --git a/Task/99-Bottles-of-Beer/EGL/99-bottles-of-beer.egl b/Task/99-Bottles-of-Beer/EGL/99-bottles-of-beer.egl new file mode 100644 index 0000000000..2e246ca3f9 --- /dev/null +++ b/Task/99-Bottles-of-Beer/EGL/99-bottles-of-beer.egl @@ -0,0 +1,22 @@ +program TestProgram type BasicProgram {} + + function main() + for (count int from 99 to 1 decrement by 1) + SysLib.writeStdout( bottleStr( count ) :: " of beer on the wall." ); + SysLib.writeStdout( bottleStr( count ) :: " of beer." ); + SysLib.writeStdout( "Take one down, pass it around." ); + SysLib.writeStdout( bottleStr( count - 1) :: " of beer on the wall.\n"); + end + end + + private function bottleStr( count int in) returns( string ) + case ( count ) + when ( 1 ) + return( "1 bottle" ); + when ( 0 ) + return( "No more bottles" ); + otherwise + return( count :: " bottles" ); + end + end +end diff --git a/Task/99-Bottles-of-Beer/Ela/99-bottles-of-beer.ela b/Task/99-Bottles-of-Beer/Ela/99-bottles-of-beer.ela new file mode 100644 index 0000000000..e3c8d06014 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Ela/99-bottles-of-beer.ela @@ -0,0 +1,9 @@ +open list + +beer 1 = "1 bottle of beer on the wall\n1 bottle of beer\nTake one down, pass it around" +beer 0 = "better go to the store and buy some more." +beer v = show v ++ " bottles of beer on the wall\n" + ++ show v + ++" bottles of beer\nTake one down, pass it around\n" + +map beer [99,98..0] diff --git a/Task/99-Bottles-of-Beer/Euphoria/99-bottles-of-beer.euphoria b/Task/99-Bottles-of-Beer/Euphoria/99-bottles-of-beer.euphoria new file mode 100644 index 0000000000..2d227e0434 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Euphoria/99-bottles-of-beer.euphoria @@ -0,0 +1,50 @@ +include std/console.e +include std/search.e + +function one_or_it( atom n ) + if n = 1 then + return "it" + else + return "one" + end if +end function + +function numberable( atom n ) + if n = 0 then + return "no" + else + return sprintf( "%d", n ) + end if +end function + +function plural( atom n ) + if n != 1 then + return "s" + else + return "" + end if +end function + +atom stillDrinking = 1 + +sequence yn +sequence plurality +sequence numerality + +while stillDrinking do + for bottle = 99 to 1 by -1 do + plurality = plural( bottle ) + numerality = numberable( bottle ) + printf( 1, "%s bottle%s of beer on the wall\n%s bottle%s of beer\n", + { numerality, plurality, numerality, plurality } ) + printf( 1, "Take %s down and pass it round\n", { one_or_it( bottle ) } ) + printf( 1, "%s bottle%s of beer on the wall\n\n", + { numberable( bottle - 1 ), plural( bottle - 1 ) } ) + end for + puts( 1, "No more bottles of beer on the wall\nNo more bottles of beer\n" ) + puts( 1, "Go to the store and buy some more\n99 bottles of beer on the wall\n" ) + puts( 1, "\nKeep drinking? " ) + yn = gets(0) + stillDrinking = find_any( "yY", yn ) + puts( 1, "\n" ) +end while diff --git a/Task/A+B/C++/a+b-1.cpp b/Task/A+B/C++/a+b-1.cpp new file mode 100644 index 0000000000..119b27f180 --- /dev/null +++ b/Task/A+B/C++/a+b-1.cpp @@ -0,0 +1,9 @@ +// Standard input-output streams +#include +using namespace std; +void main() +{ + int a, b; + cin >> a >> b; + cout << a + b << endl; +} diff --git a/Task/A+B/C++/a+b-2.cpp b/Task/A+B/C++/a+b-2.cpp new file mode 100644 index 0000000000..868b745d8c --- /dev/null +++ b/Task/A+B/C++/a+b-2.cpp @@ -0,0 +1,13 @@ +// Input file: input.txt +// Output file: output.txt +#include +using namespace std; +int main() +{ + ifstream in("input.txt"); + ofstream out("output.txt"); + int a, b; + in >> a >> b; + out << a + b << endl; + return 0; +} diff --git a/Task/A+B/Common-Lisp/a+b.lisp b/Task/A+B/Common-Lisp/a+b.lisp new file mode 100644 index 0000000000..df01c222c8 --- /dev/null +++ b/Task/A+B/Common-Lisp/a+b.lisp @@ -0,0 +1 @@ +(write (+ (read) (read))) diff --git a/Task/A+B/D/a+b-1.d b/Task/A+B/D/a+b-1.d new file mode 100644 index 0000000000..5f33c94449 --- /dev/null +++ b/Task/A+B/D/a+b-1.d @@ -0,0 +1,11 @@ +import std.stdio, std.conv, std.string; + +void main() { + string[] r; + try + r = readln().split(); + catch (StdioException e) + r = ["10", "20"]; + + writeln(to!int(r[0]) + to!int(r[1])); +} diff --git a/Task/A+B/D/a+b-2.d b/Task/A+B/D/a+b-2.d new file mode 100644 index 0000000000..734612489f --- /dev/null +++ b/Task/A+B/D/a+b-2.d @@ -0,0 +1,8 @@ +import std.stdio, std.conv, std.string; + +void main() { + auto fin = File("sum_input.txt", "r"); + auto r = fin.readln().split(); + auto fout = File("sum_output.txt", "w"); + fout.writeln(to!int(r[0]) + to!int(r[1])); +} diff --git a/Task/A+B/DMS/a+b.dms b/Task/A+B/DMS/a+b.dms new file mode 100644 index 0000000000..b9f6516e22 --- /dev/null +++ b/Task/A+B/DMS/a+b.dms @@ -0,0 +1,3 @@ +number a = GetNumber( "Please input 'a'", a, a ) // prompts for 'a' +number b = GetNumber( "Please input 'b'", b, b ) // prompts for 'b' +Result( a + b + "\n" ) diff --git a/Task/A+B/DWScript/a+b.dwscript b/Task/A+B/DWScript/a+b.dwscript new file mode 100644 index 0000000000..c023d07eef --- /dev/null +++ b/Task/A+B/DWScript/a+b.dwscript @@ -0,0 +1,3 @@ +var a := StrToInt(InputBox('A+B', 'Enter 1st number', '0')); +var b := StrToInt(InputBox('A+B', 'Enter 2nd number', '0')); +ShowMessage('Sum is '+IntToStr(a+b)); diff --git a/Task/A+B/Deja-Vu/a+b.djv b/Task/A+B/Deja-Vu/a+b.djv new file mode 100644 index 0000000000..4540b1d13b --- /dev/null +++ b/Task/A+B/Deja-Vu/a+b.djv @@ -0,0 +1,4 @@ +0 +for k in split " " input: + + to-num k +print diff --git a/Task/A+B/Delphi/a+b.delphi b/Task/A+B/Delphi/a+b.delphi new file mode 100644 index 0000000000..1686668b29 --- /dev/null +++ b/Task/A+B/Delphi/a+b.delphi @@ -0,0 +1,14 @@ +program SUM; + +{$APPTYPE CONSOLE} + +uses + SysUtils; + +var + s1, s2:string; +begin + ReadLn(s1); + Readln(s2); + Writeln(StrToIntDef(s1, 0) + StrToIntDef(s2,0)); +end. diff --git a/Task/A+B/EGL/a+b.egl b/Task/A+B/EGL/a+b.egl new file mode 100644 index 0000000000..f8b42c0b49 --- /dev/null +++ b/Task/A+B/EGL/a+b.egl @@ -0,0 +1,18 @@ +package programs; + +// basic program +// +program AplusB type BasicProgram {} + function main() + try + arg1 string = SysLib.getCmdLineArg(1); + arg2 string = SysLib.getCmdLineArg(2); + int1 int = arg1; + int2 int = arg2; + sum int = int1 + int2; + SysLib.writeStdout("sum1: " + sum); + onException(exception AnyException) + SysLib.writeStdout("No valid input. Provide 2 integer numbers as arguments to the program."); + end + end +end diff --git a/Task/A+B/Ela/a+b.ela b/Task/A+B/Ela/a+b.ela new file mode 100644 index 0000000000..541697631e --- /dev/null +++ b/Task/A+B/Ela/a+b.ela @@ -0,0 +1,3 @@ +open console list string read + +readn() |> string.split " " |> map readStr |> sum diff --git a/Task/A+B/Elena/a+b.elena b/Task/A+B/Elena/a+b.elena new file mode 100644 index 0000000000..ee8fac7a79 --- /dev/null +++ b/Task/A+B/Elena/a+b.elena @@ -0,0 +1,11 @@ +#define std'basic'*. +#define ext'io'*. + +#symbol Console => +[ + #var anOutput := __wrap(ELineInput, 'program'input). + #var A := anOutput >> Integer. + #var B := anOutput >> Integer. + + 'program'output << A + B. +]. diff --git a/Task/A+B/Euler-Math-Toolbox/a+b.euler b/Task/A+B/Euler-Math-Toolbox/a+b.euler new file mode 100644 index 0000000000..27c7508294 --- /dev/null +++ b/Task/A+B/Euler-Math-Toolbox/a+b.euler @@ -0,0 +1,7 @@ +>s=lineinput("Two numbers seperated by a blank"); + Two numbers seperated by a blank? >4 5 +>vs=strtokens(s) + 4 + 5 +>vs[1]()+vs[2]() + 9 diff --git a/Task/A+B/Euphoria/a+b.euphoria b/Task/A+B/Euphoria/a+b.euphoria new file mode 100644 index 0000000000..d757131d03 --- /dev/null +++ b/Task/A+B/Euphoria/a+b.euphoria @@ -0,0 +1,12 @@ +include get.e + +function snd(sequence s) + return s[2] +end function + +integer a,b + +a = snd(get(0)) +b = snd(get(0)) + +printf(1," %d\n",a+b) diff --git a/Task/Abstract-type/C++/abstract-type.cpp b/Task/Abstract-type/C++/abstract-type.cpp new file mode 100644 index 0000000000..30a59e0749 --- /dev/null +++ b/Task/Abstract-type/C++/abstract-type.cpp @@ -0,0 +1,7 @@ +class Abs { +public: + virtual int method1(double value) = 0; + virtual int add(int a, int b){ + return a+b; + } +}; diff --git a/Task/Abstract-type/C-sharp/abstract-type.cs b/Task/Abstract-type/C-sharp/abstract-type.cs new file mode 100644 index 0000000000..6cfe5d83d3 --- /dev/null +++ b/Task/Abstract-type/C-sharp/abstract-type.cs @@ -0,0 +1,9 @@ +abstract class Class1 +{ + public abstract void method1(); + + public int method2() + { + return 0; + } +} diff --git a/Task/Abstract-type/Common-Lisp/abstract-type-1.lisp b/Task/Abstract-type/Common-Lisp/abstract-type-1.lisp new file mode 100644 index 0000000000..c9058e63ef --- /dev/null +++ b/Task/Abstract-type/Common-Lisp/abstract-type-1.lisp @@ -0,0 +1,13 @@ +(defgeneric kar (kons) + (:documentation "Return the kar of a kons.")) + +(defgeneric kdr (kons) + (:documentation "Return the kdr of a kons.")) + +(defun konsp (object &aux (args (list object))) + "True if there are applicable methods for kar and kdr on object." + (not (or (endp (compute-applicable-methods #'kar args)) + (endp (compute-applicable-methods #'kdr args))))) + +(deftype kons () + '(satisfies konsp)) diff --git a/Task/Abstract-type/Common-Lisp/abstract-type-2.lisp b/Task/Abstract-type/Common-Lisp/abstract-type-2.lisp new file mode 100644 index 0000000000..e5f2be2058 --- /dev/null +++ b/Task/Abstract-type/Common-Lisp/abstract-type-2.lisp @@ -0,0 +1,10 @@ +(defmethod kar ((cons cons)) + (car cons)) + +(defmethod kdr ((cons cons)) + (cdr cons)) + +(konsp (cons 1 2)) ; => t +(typep (cons 1 2) 'kons) ; => t +(kar (cons 1 2)) ; => 1 +(kdr (cons 1 2)) ; => 2 diff --git a/Task/Abstract-type/Common-Lisp/abstract-type-3.lisp b/Task/Abstract-type/Common-Lisp/abstract-type-3.lisp new file mode 100644 index 0000000000..def1178366 --- /dev/null +++ b/Task/Abstract-type/Common-Lisp/abstract-type-3.lisp @@ -0,0 +1,11 @@ +(defmethod kar ((n integer)) + 1) + +(defmethod kdr ((n integer)) + (if (zerop n) nil + (1- n))) + +(konsp 45) ; => t +(typep 45 'kons) ; => t +(kar 45) ; => 1 +(kdr 45) ; => 44 diff --git a/Task/Abstract-type/D/abstract-type.d b/Task/Abstract-type/D/abstract-type.d new file mode 100644 index 0000000000..6bf0f5ccea --- /dev/null +++ b/Task/Abstract-type/D/abstract-type.d @@ -0,0 +1,27 @@ +import std.stdio; + +class Foo { + // abstract methods can have an implementation for + // use in super calls. + abstract void foo() { + writeln("Test"); + } +} + +interface Bar { + void bar(); + + // Final interface methods are allowed. + final int spam() { return 1; } +} + +class Baz : Foo, Bar { // Super class must come first. + override void foo() { + writefln("Meep"); + super.foo(); + } + + void bar() {} +} + +void main() {} diff --git a/Task/Abstract-type/Delphi/abstract-type-1.delphi b/Task/Abstract-type/Delphi/abstract-type-1.delphi new file mode 100644 index 0000000000..bb1e1ee933 --- /dev/null +++ b/Task/Abstract-type/Delphi/abstract-type-1.delphi @@ -0,0 +1,3 @@ +TSomeClass = class abstract (TObject) + ... +end; diff --git a/Task/Abstract-type/Delphi/abstract-type-2.delphi b/Task/Abstract-type/Delphi/abstract-type-2.delphi new file mode 100644 index 0000000000..fbe8266c3c --- /dev/null +++ b/Task/Abstract-type/Delphi/abstract-type-2.delphi @@ -0,0 +1,13 @@ +type + TMyObject = class(TObject) + public + procedure AbstractFunction; virtual; abstract; // Your virtual abstract function to overwrite in descendant + procedure ConcreteFunction; virtual; // Concrete function calling the abstract function + end; + +implementation + +procedure TMyObject.ConcreteFunction; +begin + AbstractFunction; // Calling the abstract function +end; diff --git a/Task/Abstract-type/E/abstract-type-1.e b/Task/Abstract-type/E/abstract-type-1.e new file mode 100644 index 0000000000..70d077e4cd --- /dev/null +++ b/Task/Abstract-type/E/abstract-type-1.e @@ -0,0 +1,3 @@ +interface Foo { + to bar(a :int, b :int) +} diff --git a/Task/Abstract-type/E/abstract-type-2.e b/Task/Abstract-type/E/abstract-type-2.e new file mode 100644 index 0000000000..413b7cf8a3 --- /dev/null +++ b/Task/Abstract-type/E/abstract-type-2.e @@ -0,0 +1,9 @@ +interface Foo guards FooStamp { + to bar(a :int, b :int) +} + +def x implements FooStamp { + to bar(a :int, b :int) { + return a - b + } +} diff --git a/Task/Accumulator-factory/C++/accumulator-factory-1.cpp b/Task/Accumulator-factory/C++/accumulator-factory-1.cpp new file mode 100644 index 0000000000..9fe33e063a --- /dev/null +++ b/Task/Accumulator-factory/C++/accumulator-factory-1.cpp @@ -0,0 +1,57 @@ +#include + +class Acc +{ +public: + Acc(int init) + : _type(intType) + , _intVal(init) + {} + + Acc(float init) + : _type(floatType) + , _floatVal(init) + {} + + int operator()(int x) + { + if( _type == intType ) + { + _intVal += x; + return _intVal; + } + else + { + _floatVal += x; + return static_cast(_floatVal); + } + } + + float operator()(float x) + { + if( _type == intType ) + { + _floatVal = _intVal + x; + _type = floatType; + return _floatVal; + } + else + { + _floatVal += x; + return _floatVal; + } + } +private: + enum {floatType, intType} _type; + float _floatVal; + int _intVal; +}; + +int main() +{ + Acc a(1); + a(5); + Acc(3); + std::cout << a(2.3f); + return 0; +} diff --git a/Task/Accumulator-factory/C++/accumulator-factory-2.cpp b/Task/Accumulator-factory/C++/accumulator-factory-2.cpp new file mode 100644 index 0000000000..0e930cd38a --- /dev/null +++ b/Task/Accumulator-factory/C++/accumulator-factory-2.cpp @@ -0,0 +1,17 @@ +#include +#include + +template +std::function makeAccumulator(T sum) { + return [=](T increment) mutable { + return sum += increment; + }; +} + +int main() { + auto acc = makeAccumulator(1); + acc(5); + makeAccumulator(3); + std::cout << acc(2.3) << std::endl; + return 0; +} diff --git a/Task/Accumulator-factory/Clay/accumulator-factory-1.clay b/Task/Accumulator-factory/Clay/accumulator-factory-1.clay new file mode 100644 index 0000000000..ace691ff36 --- /dev/null +++ b/Task/Accumulator-factory/Clay/accumulator-factory-1.clay @@ -0,0 +1,13 @@ +acc(n) { + return (m) => { + n = n + m; + return n; + }; +} + +main() { + var x = acc(1.0); + x(5); + acc(3); + println(x(2.3)); // Prints “8.300000000000001”. +} diff --git a/Task/Accumulator-factory/Clay/accumulator-factory-2.clay b/Task/Accumulator-factory/Clay/accumulator-factory-2.clay new file mode 100644 index 0000000000..4707ae6092 --- /dev/null +++ b/Task/Accumulator-factory/Clay/accumulator-factory-2.clay @@ -0,0 +1,2 @@ + var y = acc(Vector[Char]("Hello")); + println(y(" World!")); // Prints "Hello World!”. diff --git a/Task/Accumulator-factory/Clay/accumulator-factory-3.clay b/Task/Accumulator-factory/Clay/accumulator-factory-3.clay new file mode 100644 index 0000000000..13fbb39a6a --- /dev/null +++ b/Task/Accumulator-factory/Clay/accumulator-factory-3.clay @@ -0,0 +1,6 @@ +[N | Numeric?(N)] acc(n: N) { + return (m) => { + n = n + m; + return n; + }; +} diff --git a/Task/Accumulator-factory/Common-Lisp/accumulator-factory-1.lisp b/Task/Accumulator-factory/Common-Lisp/accumulator-factory-1.lisp new file mode 100644 index 0000000000..a3762e8073 --- /dev/null +++ b/Task/Accumulator-factory/Common-Lisp/accumulator-factory-1.lisp @@ -0,0 +1,3 @@ +(defun accumulator (sum) + (lambda (n) + (setf sum (+ sum n)))) diff --git a/Task/Accumulator-factory/Common-Lisp/accumulator-factory-2.lisp b/Task/Accumulator-factory/Common-Lisp/accumulator-factory-2.lisp new file mode 100644 index 0000000000..29114fc66e --- /dev/null +++ b/Task/Accumulator-factory/Common-Lisp/accumulator-factory-2.lisp @@ -0,0 +1,4 @@ +(defvar x (accumulator 1)) +(funcall x 5) +(accumulator 3) +(funcall x 2.3) diff --git a/Task/Accumulator-factory/D/accumulator-factory.d b/Task/Accumulator-factory/D/accumulator-factory.d new file mode 100644 index 0000000000..19678ea3b3 --- /dev/null +++ b/Task/Accumulator-factory/D/accumulator-factory.d @@ -0,0 +1,11 @@ +void main() { + auto x = acc(1); + x(5); + acc(3); + writeln(x(2.3)); +} + +auto acc(U = real, T)(T initvalue) { // U is type of the accumulator + auto accum = cast(U)initvalue ; + return (U n) { return accum += n ; } ; +} diff --git a/Task/Accumulator-factory/E/accumulator-factory.e b/Task/Accumulator-factory/E/accumulator-factory.e new file mode 100644 index 0000000000..49d7f07f16 --- /dev/null +++ b/Task/Accumulator-factory/E/accumulator-factory.e @@ -0,0 +1,3 @@ +def foo(var x) { + return fn y { x += y } +} diff --git a/Task/Accumulator-factory/Elena/accumulator-factory.elena b/Task/Accumulator-factory/Elena/accumulator-factory.elena new file mode 100644 index 0000000000..926d7ad59d --- /dev/null +++ b/Task/Accumulator-factory/Elena/accumulator-factory.elena @@ -0,0 +1,17 @@ +#define std'dictionary'*. +#define std'basic'*. +#define sys'dynamics'*. + +#symbol NewAccumulator : aValue = + #join (Variable::aValue) { eval : aValue [ $self content'set:($self + aValue). ] }. + +#symbol Program = +[ + #var x := NewAccumulator::1. + + x::5. + + NewAccumulator::3. + + 'program'Output << x::2.3r. +]. diff --git a/Task/Ackermann-function/C++/ackermann-function.cpp b/Task/Ackermann-function/C++/ackermann-function.cpp new file mode 100644 index 0000000000..297e06dcd2 --- /dev/null +++ b/Task/Ackermann-function/C++/ackermann-function.cpp @@ -0,0 +1,18 @@ +#include +using namespace std; +long ackermann(long x, long y) +{ + if (x == 0) return y+1; + else if (y == 0) return ackermann(x-1, 1); + else return ackermann(x-1, ackermann(x, y-1)); +} + +int main() +{ + long x,y; + cout << "x ve y..:"; + cin>>x; + cin>>y; + cout< 0) + { + if (n > 0) + return Ackermann(m - 1, Ackermann(m, n - 1)); + else if (n == 0) + return Ackermann(m - 1, 1); + } + else if(m == 0) + { + if(n >= 0) + return n + 1; + } + + throw new System.ArgumentOutOfRangeException(); + } + + static void Main() + { + for (long m = 0; m <= 3; ++m) + { + for (long n = 0; n <= 4; ++n) + { + Console.WriteLine("Ackermann({0}, {1}) = {2}", m, n, Ackermann(m, n)); + } + } + } +} diff --git a/Task/Ackermann-function/CLIPS/ackermann-function-1.clips b/Task/Ackermann-function/CLIPS/ackermann-function-1.clips new file mode 100644 index 0000000000..12a3383937 --- /dev/null +++ b/Task/Ackermann-function/CLIPS/ackermann-function-1.clips @@ -0,0 +1,10 @@ +(deffunction ackerman + (?m ?n) + (if (= 0 ?m) + then (+ ?n 1) + else (if (= 0 ?n) + then (ackerman (- ?m 1) 1) + else (ackerman (- ?m 1) (ackerman ?m (- ?n 1))) + ) + ) +) diff --git a/Task/Ackermann-function/CLIPS/ackermann-function-2.clips b/Task/Ackermann-function/CLIPS/ackermann-function-2.clips new file mode 100644 index 0000000000..b8b6c1567a --- /dev/null +++ b/Task/Ackermann-function/CLIPS/ackermann-function-2.clips @@ -0,0 +1,68 @@ +(deffacts solve-items + (solve 0 4) + (solve 1 4) + (solve 2 4) + (solve 3 4) +) + +(defrule acker-m-0 + ?compute <- (compute 0 ?n) + => + (retract ?compute) + (assert (ackerman 0 ?n (+ ?n 1))) +) + +(defrule acker-n-0-pre + (compute ?m&:(> ?m 0) 0) + (not (ackerman =(- ?m 1) 1 ?)) + => + (assert (compute (- ?m 1) 1)) +) + +(defrule acker-n-0 + ?compute <- (compute ?m&:(> ?m 0) 0) + (ackerman =(- ?m 1) 1 ?val) + => + (retract ?compute) + (assert (ackerman ?m 0 ?val)) +) + +(defrule acker-m-n-pre-1 + (compute ?m&:(> ?m 0) ?n&:(> ?n 0)) + (not (ackerman ?m =(- ?n 1) ?)) + => + (assert (compute ?m (- ?n 1))) +) + +(defrule acker-m-n-pre-2 + (compute ?m&:(> ?m 0) ?n&:(> ?n 0)) + (ackerman ?m =(- ?n 1) ?newn) + (not (ackerman =(- ?m 1) ?newn ?)) + => + (assert (compute (- ?m 1) ?newn)) +) + +(defrule acker-m-n + ?compute <- (compute ?m&:(> ?m 0) ?n&:(> ?n 0)) + (ackerman ?m =(- ?n 1) ?newn) + (ackerman =(- ?m 1) ?newn ?val) + => + (retract ?compute) + (assert (ackerman ?m ?n ?val)) +) + +(defrule acker-solve + (solve ?m ?n) + (not (compute ?m ?n)) + (not (ackerman ?m ?n ?)) + => + (assert (compute ?m ?n)) +) + +(defrule acker-solved + ?solve <- (solve ?m ?n) + (ackerman ?m ?n ?result) + => + (retract ?solve) + (printout t "A(" ?m "," ?n ") = " ?result crlf) +) diff --git a/Task/Ackermann-function/Clay/ackermann-function.clay b/Task/Ackermann-function/Clay/ackermann-function.clay new file mode 100644 index 0000000000..6bddfd2238 --- /dev/null +++ b/Task/Ackermann-function/Clay/ackermann-function.clay @@ -0,0 +1,8 @@ +ackermann(m, n) { + if(m == 0) + return n + 1; + if(n == 0) + return ackermann(m - 1, 1); + + return ackermann(m - 1, ackermann(m, n - 1)); +} diff --git a/Task/Ackermann-function/Common-Lisp/ackermann-function-1.lisp b/Task/Ackermann-function/Common-Lisp/ackermann-function-1.lisp new file mode 100644 index 0000000000..9f93394b6f --- /dev/null +++ b/Task/Ackermann-function/Common-Lisp/ackermann-function-1.lisp @@ -0,0 +1,4 @@ +(defun ackermann (m n) + (cond ((zerop m) (1+ n)) + ((zerop n) (ackermann (1- m) 1)) + (t (ackermann (1- m) (ackermann m (1- n)))))) diff --git a/Task/Ackermann-function/Common-Lisp/ackermann-function-2.lisp b/Task/Ackermann-function/Common-Lisp/ackermann-function-2.lisp new file mode 100644 index 0000000000..1f639441cb --- /dev/null +++ b/Task/Ackermann-function/Common-Lisp/ackermann-function-2.lisp @@ -0,0 +1,10 @@ +(defun ackermann (m n) + (case m ((0) (1+ n)) + ((1) (+ 2 n)) + ((2) (+ n n 3)) + ((3) (- (expt 2 (+ 3 n)) 3)) + (otherwise (ackermann (1- m) (if (zerop n) 1 (ackermann m (1- n))))))) + +(loop for m from 0 to 4 do + (loop for n from (- 5 m) to (- 6 m) do + (format t "A(~d, ~d) = ~d~%" m n (ackermann m n)))) diff --git a/Task/Ackermann-function/Coq/ackermann-function.coq b/Task/Ackermann-function/Coq/ackermann-function.coq new file mode 100644 index 0000000000..b96929e305 --- /dev/null +++ b/Task/Ackermann-function/Coq/ackermann-function.coq @@ -0,0 +1,10 @@ +Require Import Arith. +Fixpoint A m := fix A_m n := + match m with + | 0 => n + 1 + | S pm => + match n with + | 0 => A pm 1 + | S pn => A pm (A_m pn) + end + end. diff --git a/Task/Ackermann-function/D/ackermann-function-1.d b/Task/Ackermann-function/D/ackermann-function-1.d new file mode 100644 index 0000000000..d4171ac513 --- /dev/null +++ b/Task/Ackermann-function/D/ackermann-function-1.d @@ -0,0 +1,11 @@ +ulong ackermann(in ulong m, in ulong n) pure nothrow { + if (m == 0) + return n + 1; + if (n == 0) + return ackermann(m - 1, 1); + return ackermann(m - 1, ackermann(m, n - 1)); +} + +void main() { + assert(ackermann(2, 4) == 11); +} diff --git a/Task/Ackermann-function/D/ackermann-function-2.d b/Task/Ackermann-function/D/ackermann-function-2.d new file mode 100644 index 0000000000..533dbf8a70 --- /dev/null +++ b/Task/Ackermann-function/D/ackermann-function-2.d @@ -0,0 +1,50 @@ +import std.stdio, std.bigint, std.conv; + +/*pure nothrow*/ BigInt ipow(/*in*/ BigInt base, /*in*/ BigInt exp){ + auto result = BigInt(1); + //while (exp) { + while (exp != 0) { + //if (exp & 1) + if (exp % 2) + result *= base; + exp >>= 1; + base *= base; + } + + return result; +} + +/*pure nothrow*/ BigInt ackermann(in int m, in int n) +in { + assert(m >= 0 && n >= 0); +} out(result) { + //assert(result >= 0); + assert(cast()result >= 0); +} body { + /*pure nothrow*/ static BigInt ack(in int m, /*in*/ BigInt n) { + switch (m) { + case 0: return n + 1; + case 1: return n + 2; + case 2: return 3 + 2 * n; + //case 3: return 5 + 8 * (2 ^^ n - 1); + case 3: return 5 + 8 * (ipow(BigInt(2), n) - 1); + default: if (n == 0) + return ack(m - 1, BigInt(1)); + else + return ack(m - 1, ack(m, n - 1)); + } + } + + return ack(m, BigInt(n)); +} + +void main() { + foreach (m; 1 .. 4) + foreach (n; 1 .. 9) + writefln("ackermann(%d, %d): %s", m, n, ackermann(m, n)); + writefln("ackermann(4, 1): %s", ackermann(4, 1)); + + auto a = text(ackermann(4, 2)); + writefln("ackermann(4, 2)) (%d digits):\n%s...\n%s", + a.length, a[0 .. 94], a[$-96 .. $]); +} diff --git a/Task/Ackermann-function/DWScript/ackermann-function.dwscript b/Task/Ackermann-function/DWScript/ackermann-function.dwscript new file mode 100644 index 0000000000..d31252a171 --- /dev/null +++ b/Task/Ackermann-function/DWScript/ackermann-function.dwscript @@ -0,0 +1,8 @@ +function Ackermann(m, n : Integer) : Integer; +begin + if m = 0 then + Result := n+1 + else if n = 0 then + Result := Ackermann(m-1, 1) + else Result := Ackermann(m-1, Ackermann(m, n-1)); +end; diff --git a/Task/Ackermann-function/Dart/ackermann-function.dart b/Task/Ackermann-function/Dart/ackermann-function.dart new file mode 100644 index 0000000000..926bcc23a2 --- /dev/null +++ b/Task/Ackermann-function/Dart/ackermann-function.dart @@ -0,0 +1,13 @@ +int A(int m, int n) => m==0 ? n+1 : n==0 ? A(m-1,1) : A(m-1,A(m,n-1)); + +main() { + print(A(0,0)); + print(A(1,0)); + print(A(0,1)); + print(A(2,2)); + print(A(2,3)); + print(A(3,3)); + print(A(3,4)); + print(A(3,5)); + print(A(4,0)); +} diff --git a/Task/Ackermann-function/Delphi/ackermann-function.delphi b/Task/Ackermann-function/Delphi/ackermann-function.delphi new file mode 100644 index 0000000000..93564de56a --- /dev/null +++ b/Task/Ackermann-function/Delphi/ackermann-function.delphi @@ -0,0 +1,9 @@ +function Ackermann(m,n:Int64):Int64; +begin + if m = 0 then + Result := n + 1 + else if n = 0 then + Result := Ackermann(m-1, 1) + else + Result := Ackermann(m-1, Ackermann(m, n - 1)); +end; diff --git a/Task/Ackermann-function/E/ackermann-function.e b/Task/Ackermann-function/E/ackermann-function.e new file mode 100644 index 0000000000..ad957460fb --- /dev/null +++ b/Task/Ackermann-function/E/ackermann-function.e @@ -0,0 +1,5 @@ +def A(m, n) { + return if (m <=> 0) { n+1 } \ + else if (m > 0 && n <=> 0) { A(m-1, 1) } \ + else { A(m-1, A(m,n-1)) } +} diff --git a/Task/Ackermann-function/Ela/ackermann-function.ela b/Task/Ackermann-function/Ela/ackermann-function.ela new file mode 100644 index 0000000000..bc227267b2 --- /dev/null +++ b/Task/Ackermann-function/Ela/ackermann-function.ela @@ -0,0 +1,3 @@ +ack 0 n = n+1 +ack m 0 = ack (m - 1) 1 +ack m n = ack (m - 1) <| ack m <| n - 1 diff --git a/Task/Ackermann-function/Elena/ackermann-function.elena b/Task/Ackermann-function/Elena/ackermann-function.elena new file mode 100644 index 0000000000..58f6528cbb --- /dev/null +++ b/Task/Ackermann-function/Elena/ackermann-function.elena @@ -0,0 +1,33 @@ +#define std'dictionary'*. +#define std'patterns'*. + +#subject m, n. + +// --- Ackermann function --- + +#symbol Ackermann &m:anM &n:anN = +[ + #if anM + ifequal:0 [ ^ anN + 1. ] + | greater:0 ? + [ + #if anN + ifequal:0 [ ^ Ackermann &&m:(anM - 1) &n:1. ] + | greater:0 ? [ ^ Ackermann &&m:(anM - 1) &n:(Ackermann &&m:anM &n:(anN - 1)). ]. + ]. + + control fail. +]. + +#symbol Program = +[ + loop &&from:0 &to:3 run: anM = + [ + loop &&from:0 &to:5 run: anN = + [ + 'program'output << "A(" << anM << "," << anN << ")=" << (Ackermann &&m:anM &n:anN) << "%n". + ]. + ]. + + 'program'Input get. +]. diff --git a/Task/Ackermann-function/Euler-Math-Toolbox/ackermann-function.euler b/Task/Ackermann-function/Euler-Math-Toolbox/ackermann-function.euler new file mode 100644 index 0000000000..685208b77d --- /dev/null +++ b/Task/Ackermann-function/Euler-Math-Toolbox/ackermann-function.euler @@ -0,0 +1,16 @@ +>M=zeros(1000,1000); +>function map A(m,n) ... +$ global M; +$ if m==0 then return n+1; endif; +$ if n==0 then return A(m-1,1); endif; +$ if m<=cols(M) and n<=cols(M) then +$ M[m,n]=A(m-1,A(m,n-1)); +$ return M[m,n]; +$ else return A(m-1,A(m,n-1)); +$ endif; +$endfunction +>shortestformat; A((0:3)',0:5) + 1 2 3 4 5 6 + 2 3 4 5 6 7 + 3 5 7 9 11 13 + 5 13 29 61 125 253 diff --git a/Task/Ackermann-function/Euphoria/ackermann-function.euphoria b/Task/Ackermann-function/Euphoria/ackermann-function.euphoria new file mode 100644 index 0000000000..cd4d6a4745 --- /dev/null +++ b/Task/Ackermann-function/Euphoria/ackermann-function.euphoria @@ -0,0 +1,16 @@ +function ack(atom m, atom n) + if m = 0 then + return n + 1 + elsif m > 0 and n = 0 then + return ack(m - 1, 1) + else + return ack(m - 1, ack(m, n - 1)) + end if +end function + +for i = 0 to 3 do + for j = 0 to 6 do + printf( 1, "%5d", ack( i, j ) ) + end for + puts( 1, "\n" ) +end for diff --git a/Task/Active-object/E/active-object.e b/Task/Active-object/E/active-object.e new file mode 100644 index 0000000000..7fad3cf284 --- /dev/null +++ b/Task/Active-object/E/active-object.e @@ -0,0 +1,51 @@ +def makeIntegrator() { + var value := 0.0 + var input := fn { 0.0 } + + var input1 := input() + var t1 := timer.now() + + def update() { + def t2 := timer.now() + def input2 :float64 := input() + def dt := (t2 - t1) / 1000 + + value += (input1 + input2) * dt / 2 + + t1 := t2 + input1 := input2 + } + + var task() { + update <- () + task <- () + } + task() + + def integrator { + to input(new) :void { input := new } + to output() :float64 { return value } + to shutdown() { task := fn {} } + } + return integrator +} + +def test() { + def result + + def pi := (-1.0).acos() + def freq := pi / 1000 + + def base := timer.now() + def i := makeIntegrator() + + i.input(fn { (freq * timer.now()).sin() }) + timer.whenPast(base + 2000, fn { + i.input(fn {0}) + }) + timer.whenPast(base + 2500, fn { + bind result := i.output() + i.shutdown() + }) + return result +} diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Common-Lisp/add-a-variable-to-a-class-instance-at-runtime-1.lisp b/Task/Add-a-variable-to-a-class-instance-at-runtime/Common-Lisp/add-a-variable-to-a-class-instance-at-runtime-1.lisp new file mode 100644 index 0000000000..a5d1c74608 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Common-Lisp/add-a-variable-to-a-class-instance-at-runtime-1.lisp @@ -0,0 +1,5 @@ +(defun augment-instance-with-slots (instance slots) + (change-class instance + (make-instance 'standard-class + :direct-superclasses (list (class-of instance)) + :direct-slots slots))) diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Common-Lisp/add-a-variable-to-a-class-instance-at-runtime-2.lisp b/Task/Add-a-variable-to-a-class-instance-at-runtime/Common-Lisp/add-a-variable-to-a-class-instance-at-runtime-2.lisp new file mode 100644 index 0000000000..0f54bac71c --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Common-Lisp/add-a-variable-to-a-class-instance-at-runtime-2.lisp @@ -0,0 +1,12 @@ +CL-USER> (let* ((instance (make-instance 'foo :bar 42 :baz 69)) + (new-slots '((:name xenu :initargs (:xenu))))) + (augment-instance-with-slots instance new-slots) + (reinitialize-instance instance :xenu 666) + (describe instance)) +#<# {1003AEE271}> + [standard-object] + +Slots with :INSTANCE allocation: + BAR = 42 + BAZ = 69 + XENU = 666 diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/D/add-a-variable-to-a-class-instance-at-runtime-1.d b/Task/Add-a-variable-to-a-class-instance-at-runtime/D/add-a-variable-to-a-class-instance-at-runtime-1.d new file mode 100644 index 0000000000..da09b56074 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/D/add-a-variable-to-a-class-instance-at-runtime-1.d @@ -0,0 +1,31 @@ +struct Dynamic(T) { + private T[string] vars; + + @property T opDispatch(string key)() pure nothrow { + return vars[key]; + } + + @property void opDispatch(string key, U)(U value)/*pure*/ nothrow { + vars[key] = value; + } +} + +void main() { + import std.variant, std.stdio; + + // If the type of the attributes is known at compile-time: + auto d1 = Dynamic!double(); + d1.first = 10.5; + d1.second = 20.2; + writeln(d1.first, " ", d1.second); + + + // If the type of the attributes is mixed: + auto d2 = Dynamic!Variant(); + d2.a = "Hello"; + d2.b = 11; + d2.c = ['x':2, 'y':4]; + d2.d = (int x) => x ^^ 3; + writeln(d2.a, " ", d2.b, " ", d2.c); + immutable int x = d2.b.get!int; +} diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/D/add-a-variable-to-a-class-instance-at-runtime-2.d b/Task/Add-a-variable-to-a-class-instance-at-runtime/D/add-a-variable-to-a-class-instance-at-runtime-2.d new file mode 100644 index 0000000000..033f40d1cb --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/D/add-a-variable-to-a-class-instance-at-runtime-2.d @@ -0,0 +1,13 @@ +import std.stdio, std.variant, std.conv; + +struct Dyn { + Variant[string] data; + alias data this; +} + +void main(string[] args) { + Dyn d; + const attribute_name = text("attribute_", args.length); + d[attribute_name] = "something"; + writeln(d[attribute_name]); +} diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Elena/add-a-variable-to-a-class-instance-at-runtime.elena b/Task/Add-a-variable-to-a-class-instance-at-runtime/Elena/add-a-variable-to-a-class-instance-at-runtime.elena new file mode 100644 index 0000000000..d1d5e0369b --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Elena/add-a-variable-to-a-class-instance-at-runtime.elena @@ -0,0 +1,27 @@ +#subject foo. + +#class FieldContainer +{ + #field theValue. + + #method foo'set : anObject + [ + theValue := anObject. + ] + + #method foo'get = theValue. +} + +#symbol Program = +[ + #var anObject := 234. + + // adding a field + anObject := anObject &= FieldContainer. + + anObject foo'set:"bar". + + 'program'Output << anObject << ".foo=" << anObject foo. + + 'program'input get. +]. diff --git a/Task/Address-of-a-variable/C-sharp/address-of-a-variable.cs b/Task/Address-of-a-variable/C-sharp/address-of-a-variable.cs new file mode 100644 index 0000000000..f54c793679 --- /dev/null +++ b/Task/Address-of-a-variable/C-sharp/address-of-a-variable.cs @@ -0,0 +1,5 @@ +unsafe +{ + int i = 5; + void* address_of_i = &i; +} diff --git a/Task/Address-of-a-variable/COBOL/address-of-a-variable-1.cobol b/Task/Address-of-a-variable/COBOL/address-of-a-variable-1.cobol new file mode 100644 index 0000000000..b4657bd3ec --- /dev/null +++ b/Task/Address-of-a-variable/COBOL/address-of-a-variable-1.cobol @@ -0,0 +1,7 @@ +data division. +working-storage section. +01 ptr usage pointer. +01 var pic x(64). + +procedure division. +set ptr to address of var. diff --git a/Task/Address-of-a-variable/COBOL/address-of-a-variable-2.cobol b/Task/Address-of-a-variable/COBOL/address-of-a-variable-2.cobol new file mode 100644 index 0000000000..932d23a87e --- /dev/null +++ b/Task/Address-of-a-variable/COBOL/address-of-a-variable-2.cobol @@ -0,0 +1,12 @@ +OCOBOL*> Rosetta Code set address example + *> tectonics: cobc -x setaddr.cob && ./setaddr + program-id. setaddr. + data division. + working-storage section. + 01 prealloc pic x(8) value 'somedata'. + 01 var pic x(8) based. + procedure division. + set address of var to address of prealloc + display var end-display + goback. + end program setaddr. diff --git a/Task/Address-of-a-variable/Common-Lisp/address-of-a-variable-1.lisp b/Task/Address-of-a-variable/Common-Lisp/address-of-a-variable-1.lisp new file mode 100644 index 0000000000..3b27d9997e --- /dev/null +++ b/Task/Address-of-a-variable/Common-Lisp/address-of-a-variable-1.lisp @@ -0,0 +1,16 @@ +;;; Demonstration of references by swapping two variables using a function rather than a macro +;;; Needs http://paste.lisp.org/display/71952 +(defun swap (ref-left ref-right) + ;; without with-refs we would have to write this: + ;; (psetf (deref ref-left) (deref ref-right) + ;; (deref ref-right) (deref ref-left)) + (with-refs ((l ref-left) (r ref-right)) + (psetf l r r l))) + +(defvar *x* 42) +(defvar *y* 0) + +(swap (ref *x*) (ref *y*)) + +;; *y* -> 42 +;; *x* -> 0 diff --git a/Task/Address-of-a-variable/Common-Lisp/address-of-a-variable-2.lisp b/Task/Address-of-a-variable/Common-Lisp/address-of-a-variable-2.lisp new file mode 100644 index 0000000000..0fb72fcbc8 --- /dev/null +++ b/Task/Address-of-a-variable/Common-Lisp/address-of-a-variable-2.lisp @@ -0,0 +1,27 @@ +(use-package :ffi) + +(defmacro def-libc-call-out (name &rest args) + `(def-call-out ,name + (:language :stdc) + #-cygwin(:library "libc.so.6") + #+cygwin (:library "cygwin1.dll") + ,@args)) + +(progn + (def-libc-call-out errno-location + #-cygwin (:name "__errno_location") + #+cygwin (:name "__errno") + (:arguments) + (:return-type (c-pointer int))) + + (defun get-errno () + (let ((loc (errno-location))) + (foreign-value loc))) + + (defun set-errno (value) + (let ((loc (errno-location))) + (setf (foreign-value loc) value))) + + (defsetf get-errno set-errno) + + (define-symbol-macro errno (get-errno))) diff --git a/Task/Address-of-a-variable/D/address-of-a-variable-1.d b/Task/Address-of-a-variable/D/address-of-a-variable-1.d new file mode 100644 index 0000000000..61e45a7e79 --- /dev/null +++ b/Task/Address-of-a-variable/D/address-of-a-variable-1.d @@ -0,0 +1,2 @@ +int i; +int* ip = &i; diff --git a/Task/Address-of-a-variable/D/address-of-a-variable-2.d b/Task/Address-of-a-variable/D/address-of-a-variable-2.d new file mode 100644 index 0000000000..daa520b344 --- /dev/null +++ b/Task/Address-of-a-variable/D/address-of-a-variable-2.d @@ -0,0 +1 @@ +int* ip = cast(int*)0xdeadf00d; diff --git a/Task/Address-of-a-variable/D/address-of-a-variable-3.d b/Task/Address-of-a-variable/D/address-of-a-variable-3.d new file mode 100644 index 0000000000..65c2a04524 --- /dev/null +++ b/Task/Address-of-a-variable/D/address-of-a-variable-3.d @@ -0,0 +1,7 @@ +void test(ref int i) { + writefln(&i); +} + +void main() { + test(* (cast(int*)0xdeadf00d) ); +} diff --git a/Task/Align-columns/C-sharp/align-columns.cs b/Task/Align-columns/C-sharp/align-columns.cs new file mode 100644 index 0000000000..0a5f4dd4bd --- /dev/null +++ b/Task/Align-columns/C-sharp/align-columns.cs @@ -0,0 +1,74 @@ +using System; +class ColumnAlignerProgram +{ + delegate string Justification(string s, int width); + + static string[] AlignColumns(string[] lines, Justification justification) + { + const char Separator = '$'; + // build input table and calculate columns count + string[][] table = new string[lines.Length][]; + int columns = 0; + for (int i = 0; i < lines.Length; i++) + { + string[] row = lines[i].TrimEnd(Separator).Split(Separator); + if (columns < row.Length) columns = row.Length; + table[i] = row; + } + // create formatted table + string[][] formattedTable = new string[table.Length][]; + for (int i = 0; i < formattedTable.Length; i++) + { + formattedTable[i] = new string[columns]; + } + for (int j = 0; j < columns; j++) + { + // get max column width + int columnWidth = 0; + for (int i = 0; i < table.Length; i++) + { + if (j < table[i].Length && columnWidth < table[i][j].Length) + columnWidth = table[i][j].Length; + } + // justify column cells + for (int i = 0; i < formattedTable.Length; i++) + { + if (j < table[i].Length) + formattedTable[i][j] = justification(table[i][j], columnWidth); + else + formattedTable[i][j] = new String(' ', columnWidth); + } + } + // create result + string[] result = new string[formattedTable.Length]; + for (int i = 0; i < result.Length; i++) + { + result[i] = String.Join(" ", formattedTable[i]); + } + return result; + } + + static string JustifyLeft(string s, int width) { return s.PadRight(width); } + static string JustifyRight(string s, int width) { return s.PadLeft(width); } + static string JustifyCenter(string s, int width) + { + return s.PadLeft((width + s.Length) / 2).PadRight(width); + } + + static void Main() + { + string[] 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.", + }; + + foreach (string line in AlignColumns(input, JustifyCenter)) + { + Console.WriteLine(line); + } + } +} diff --git a/Task/Align-columns/Common-Lisp/align-columns.lisp b/Task/Align-columns/Common-Lisp/align-columns.lisp new file mode 100644 index 0000000000..2659e5b57f --- /dev/null +++ b/Task/Align-columns/Common-Lisp/align-columns.lisp @@ -0,0 +1,48 @@ +(defun nonempty (seq) + (position-if (lambda (x) (declare (ignore x)) t) seq)) + +(defun split (delim seq) + "Splits seq on delim into a list of subsequences. Trailing empty +subsequences are removed." + (labels + ((f (seq &aux (pos (position delim seq))) + (if pos + (cons + (subseq seq 0 pos) + (f (subseq seq (1+ pos)))) + (list seq)))) + (let* ((list (f seq)) + (end (position-if #'nonempty list :from-end t))) + (subseq list 0 (1+ end))))) + +(defun lengthen (list minlen filler-elem &aux (len (length list))) + "Destructively pads list with filler-elem up to minlen." + (if (< len minlen) + (nconc list (make-list (- minlen len) :initial-element filler-elem)) + list)) + +(defun align-columns (text + &key (align :left) + &aux + (fmtmod (case align + (:left "@") + (:right ":") + (:center "@:") + (t (error "Invalid alignment.")))) + (fields (mapcar (lambda (line) (split #\$ line)) + (split #\Newline text))) + (mostcols (loop for l in fields + maximize (length l))) + widest) + (setf fields (mapcar (lambda (l) (lengthen l mostcols "")) + fields)) + (setf widest (loop for col below (length (first fields)) + collect (loop for row in fields + maximize (length (elt row col))))) + (format nil + (with-output-to-string (s) + (princ "~{~{" s) + (dolist (w widest) + (format s "~~~d~a<~~a~~>" (1+ w) fmtmod)) + (princ "~}~%~}" s)) + fields)) diff --git a/Task/Align-columns/D/align-columns.d b/Task/Align-columns/D/align-columns.d new file mode 100644 index 0000000000..51f6103d21 --- /dev/null +++ b/Task/Align-columns/D/align-columns.d @@ -0,0 +1,23 @@ +import std.stdio, std.string, std.algorithm, std.range; + +void main() { + auto data = +"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." + .splitLines.map!q{ a.chomp("$").split("$") }; + + int[int] maxWidths; + foreach (line; data) + foreach (i, word; line) + maxWidths[i] = max(maxWidths.get(i, 0), word.length); + + foreach (just; [&leftJustify!string, ¢er!string, + &rightJustify!string]) + foreach (line; data) + writefln("%-(%s %)", iota(line.length) + .map!(i => just(line[i], maxWidths[i], ' '))); +} diff --git a/Task/Align-columns/Delphi/align-columns.delphi b/Task/Align-columns/Delphi/align-columns.delphi new file mode 100644 index 0000000000..ce8bedf869 --- /dev/null +++ b/Task/Align-columns/Delphi/align-columns.delphi @@ -0,0 +1,56 @@ +USES + StdCtrls, Classes, SysUtils, StrUtils, Contnrs; + +procedure AlignByColumn(Output: TMemo; Align: TAlignment); +const + TextToAlign = + 'Given$a$text$file$of$many$lines,$where$fields$within$a$line$'#$D#$A + + 'are$delineated$by$a$single$''dollar''$character,$write$a$program'#$D#$A + + 'that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$'#$D#$A + + 'column$are$separated$by$at$least$one$space.'#$D#$A + + 'Further,$allow$for$each$word$in$a$column$to$be$either$left$'#$D#$A + + 'justified,$right$justified,$or$center$justified$within$its$column.'; +var + TextLine, TempTString: TStringlist; + TextLines: TObjectList; + MaxLength, i, j: Byte; + OutPutString, EmptyString, Item: String; +begin + TRY + MaxLength := 0; + TextLines := TObjectList.Create(True); + TextLine := TStringList.Create; + TextLine.text := TextToAlign; + for i:= 0 to TextLine.Count - 1 do + begin + TempTString := TStringlist.create; + TempTString.text :=AnsiReplaceStr(TextLine[i], '$', #$D#$A); + TextLines.Add(TempTString); + end; + for i := 0 to TextLines.Count - 1 do + for j := 0 to TStringList(TextLines.Items[i]).Count - 1 do + If Length(TStringList(TextLines.Items[i])[j]) > MaxLength then + MaxLength := Length(TStringList(TextLines.Items[i])[j]); + If MaxLength > 0 then + MaxLength := MaxLength + 2; // Add to empty spaces to it + for i := 0 to TextLines.Count - 1 do + begin + OutPutString := ''; + for j := 0 to TStringList(TextLines.Items[i]).Count - 1 do + begin + EmptyString := StringOfChar(' ', MaxLength); + Item := TStringList(TextLines.Items[i])[j]; + case Align of + taLeftJustify: Move(Item[1], EmptyString[2], Length(Item)); + taRightJustify: Move(Item[1], EmptyString[MaxLength - Length(Item) + 1], Length(Item)); + taCenter: Move(Item[1], EmptyString[(MaxLength - Length(Item) + 1) div 2 + 1], Length(Item)); + end; + OutPutString := OutPutString + EmptyString; + end; + Output.Lines.Add(OutPutString); + end; + FINALLY + FreeAndNil(TextLine); + FreeAndNil(TextLines); + END; +end; diff --git a/Task/Align-columns/E/align-columns-1.e b/Task/Align-columns/E/align-columns-1.e new file mode 100644 index 0000000000..2f83961d82 --- /dev/null +++ b/Task/Align-columns/E/align-columns-1.e @@ -0,0 +1,29 @@ +pragma.enable("accumulator") + +def left(width, word) { + return word + " " * (width - word.size()) +} + +def center(width, word) { + def leftCount := (width - word.size()) // 2 + return " " * leftCount + word + " " * (width - word.size() - leftCount) +} + +def right(width, word) { + return " " * (width - word.size()) + word +} + +def alignColumns(align, text) { + def split := accum [] for line in text.split("\n") { _.with(line.split("$")) } + var widths := [] + for line in split { + for i => word in line { + widths with= (i, widths.fetch(i, fn{0}).max(word.size())) + } + } + return accum "" for line in split { + _ + accum "" for i => word in line { + _ + align(widths[i] + 1, word) + } + "\n" + } +} diff --git a/Task/Align-columns/E/align-columns-2.e b/Task/Align-columns/E/align-columns-2.e new file mode 100644 index 0000000000..4aa82760aa --- /dev/null +++ b/Task/Align-columns/E/align-columns-2.e @@ -0,0 +1,30 @@ +? def 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."; null + +? println(alignColumns(left, 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. + +? println(alignColumns(center, 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. + +? println(alignColumns(right, 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. diff --git a/Task/Align-columns/Euphoria/align-columns.euphoria b/Task/Align-columns/Euphoria/align-columns.euphoria new file mode 100644 index 0000000000..6e031deaf3 --- /dev/null +++ b/Task/Align-columns/Euphoria/align-columns.euphoria @@ -0,0 +1,61 @@ +constant 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." +} + +function split(sequence s, integer c) + sequence out + integer first, delim + out = {} + first = 1 + while first<=length(s) do + delim = find_from(c,s,first) + if delim = 0 then + delim = length(s)+1 + end if + out = append(out,s[first..delim-1]) + first = delim + 1 + end while + return out +end function + +function align(sequence s, integer width, integer alignment) + integer n + n = width - length(s) + if n <= 0 then + return s + elsif alignment < 0 then + return s & repeat(' ', n) + elsif alignment > 0 then + return repeat(' ', n) & s + else + return repeat(' ', floor(n/2)) & s & repeat(' ', floor(n/2+0.5)) + end if +end function + +integer maxlen +sequence lines +maxlen = 0 +lines = repeat(0,length(data)) +for i = 1 to length(data) do + lines[i] = split(data[i],'$') + for j = 1 to length(lines[i]) do + if length(lines[i][j]) > maxlen then + maxlen = length(lines[i][j]) + end if + end for +end for + +for a = -1 to 1 do + for i = 1 to length(lines) do + for j = 1 to length(lines[i]) do + puts(1, align(lines[i][j],maxlen,a) & ' ') + end for + puts(1,'\n') + end for + puts(1,'\n') +end for diff --git a/Task/Anagrams-Deranged-anagrams/Common-Lisp/anagrams-deranged-anagrams.lisp b/Task/Anagrams-Deranged-anagrams/Common-Lisp/anagrams-deranged-anagrams.lisp new file mode 100644 index 0000000000..b139bf3c03 --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/Common-Lisp/anagrams-deranged-anagrams.lisp @@ -0,0 +1,20 @@ +(defun read-words (file) + (with-open-file (stream file) + (loop with w = "" while w collect (setf w (read-line stream nil))))) + +(defun deranged (a b) + (loop for ac across a for bc across b always (char/= ac bc))) + +(defun longest-deranged (file) + (let ((h (make-hash-table :test #'equal)) + (wordlist (sort (read-words file) + #'(lambda (x y) (> (length x) (length y)))))) + (loop for w in wordlist do + (let* ((ws (sort (copy-seq w) #'char<)) + (l (gethash ws h))) + (loop for w1 in l do + (if (deranged w w1) + (return-from longest-deranged (list w w1)))) + (setf (gethash ws h) (cons w l)))))) + +(format t "~{~A~%~^~}" (longest-deranged "unixdict.txt")) diff --git a/Task/Anagrams-Deranged-anagrams/D/anagrams-deranged-anagrams.d b/Task/Anagrams-Deranged-anagrams/D/anagrams-deranged-anagrams.d new file mode 100644 index 0000000000..778ab9f358 --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/D/anagrams-deranged-anagrams.d @@ -0,0 +1,28 @@ +import std.stdio, std.file, std.string, std.algorithm, + std.typecons, std.range; + +auto findDeranged(in string[] words) /*pure nothrow*/ { + Tuple!(string, string)[] result; + foreach (immutable i, const w1; words) + foreach (const w2; words[i + 1 .. $]) + if (zip(w1, w2).all!q{ a[0] != a[1] }()) + result ~= tuple(w1, w2); + return result; +} + +void main() { + Appender!(string[])[30] wClasses; + foreach (word; std.algorithm.splitter(readText("unixdict.txt"))) + wClasses[$ - word.length] ~= word; + auto r = wClasses[].map!q{ a.data }().filter!q{ a.length }(); + writeln("Longest deranged anagrams:"); + foreach (words; r) { + string[][const ubyte[]] anags; // Assume input is ASCII. + foreach (w; words) + anags[(cast(ubyte[])w).sort().release().idup] ~= w.idup; + auto pairs = anags.byValue.filter!q{ a.length > 1 }() + .map!findDeranged().filter!q{ a.length }(); + if (!pairs.empty) + return writefln(" %s, %s", pairs.front[0].tupleof); + } +} diff --git a/Task/Anagrams/C++/anagrams.cpp b/Task/Anagrams/C++/anagrams.cpp new file mode 100644 index 0000000000..cd561c54da --- /dev/null +++ b/Task/Anagrams/C++/anagrams.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include +#include +#include + +int main() { + std::ifstream in("unixdict.txt"); + typedef std::map > AnagramMap; + AnagramMap anagrams; + + std::string word; + size_t count = 0; + while (std::getline(in, word)) { + std::string key = word; + std::sort(key.begin(), key.end()); + // note: the [] op. automatically inserts a new value if key does not exist + AnagramMap::mapped_type & v = anagrams[key]; + v.push_back(word); + count = std::max(count, v.size()); + } + + in.close(); + + for (AnagramMap::const_iterator it = anagrams.begin(), e = anagrams.end(); + it != e; it++) + if (it->second.size() >= count) { + std::copy(it->second.begin(), it->second.end(), + std::ostream_iterator(std::cout, ", ")); + std::cout << std::endl; + } + return 0; +} diff --git a/Task/Anagrams/Common-Lisp/anagrams-1.lisp b/Task/Anagrams/Common-Lisp/anagrams-1.lisp new file mode 100644 index 0000000000..7ed43ea4d5 --- /dev/null +++ b/Task/Anagrams/Common-Lisp/anagrams-1.lisp @@ -0,0 +1,23 @@ +(defun anagrams (&optional (url "http://www.puzzlers.org/pub/wordlists/unixdict.txt")) + (let ((words (drakma:http-request url :want-stream t)) + (wordsets (make-hash-table :test 'equalp))) + ;; populate the wordsets and close stream + (do ((word (read-line words nil nil) (read-line words nil nil))) + ((null word) (close words)) + (let ((letters (sort (copy-seq word) 'char<))) + (multiple-value-bind (pair presentp) + (gethash letters wordsets) + (if presentp + (setf (car pair) (1+ (car pair)) + (cdr pair) (cons word (cdr pair))) + (setf (gethash letters wordsets) + (cons 1 (list word))))))) + ;; find and return the biggest wordsets + (loop with maxcount = 0 with maxwordsets = '() + for pair being each hash-value of wordsets + if (> (car pair) maxcount) + do (setf maxcount (car pair) + maxwordsets (list (cdr pair))) + else if (eql (car pair) maxcount) + do (push (cdr pair) maxwordsets) + finally (return (values maxwordsets maxcount))))) diff --git a/Task/Anagrams/Common-Lisp/anagrams-2.lisp b/Task/Anagrams/Common-Lisp/anagrams-2.lisp new file mode 100644 index 0000000000..9520e68c0a --- /dev/null +++ b/Task/Anagrams/Common-Lisp/anagrams-2.lisp @@ -0,0 +1,3 @@ +(multiple-value-bind (wordsets count) (anagrams) + (pprint wordsets) + (print count)) diff --git a/Task/Anagrams/Common-Lisp/anagrams-3.lisp b/Task/Anagrams/Common-Lisp/anagrams-3.lisp new file mode 100644 index 0000000000..539de17ce2 --- /dev/null +++ b/Task/Anagrams/Common-Lisp/anagrams-3.lisp @@ -0,0 +1,19 @@ +(defun read-words (file) + (with-open-file (stream file) + (loop with w = "" while w collect (setf w (read-line stream nil))))) + +(defun anagram (file) + (let ((wordlist (read-words file)) + (h (make-hash-table :test #'equal)) + longest) + (loop for w in wordlist with ws do + (setf ws (sort (copy-seq w) #'char<)) + (setf (gethash ws h) (cons w (gethash ws h)))) + (loop for w being the hash-keys in h using (hash-value wl) + with max-len = 0 do + (let ((l (length wl))) + (if (> l max-len) (setf longest nil max-len l)) + (if (= l max-len) (push wl longest)))) + longest)) + +(format t "~{~{~a ~}~^~%~}" (anagram "unixdict.txt")) diff --git a/Task/Anagrams/Common-Lisp/anagrams-4.lisp b/Task/Anagrams/Common-Lisp/anagrams-4.lisp new file mode 100644 index 0000000000..7a2eb4555c --- /dev/null +++ b/Task/Anagrams/Common-Lisp/anagrams-4.lisp @@ -0,0 +1,9 @@ +import std.stdio, std.algorithm, std.range, std.string; + +void main() { + dstring[][dstring] anags; + foreach (dchar[] w; File("unixdict.txt").lines()) + anags[w.chomp().sort().release().idup] ~= w.chomp().idup; + immutable m = anags.byValue.map!(ws => ws.length)().reduce!max(); + writefln("%(%s\n%)", anags.byValue.filter!(ws => ws.length == m)()); +} diff --git a/Task/Anagrams/Common-Lisp/anagrams-5.lisp b/Task/Anagrams/Common-Lisp/anagrams-5.lisp new file mode 100644 index 0000000000..5ce22043d5 --- /dev/null +++ b/Task/Anagrams/Common-Lisp/anagrams-5.lisp @@ -0,0 +1,13 @@ +import std.stdio, std.algorithm, std.file; + +void main() { + char[] keys = cast(char[])read("unixdict.txt"); + string vals = keys.idup; + string[][string] anags; + foreach (w; std.array.splitter(keys)) { + const k = cast(string)sort(cast(ubyte[])w).release(); + anags[k] ~= vals[k.ptr-keys.ptr .. k.ptr-keys.ptr + k.length]; + } + immutable m = anags.byValue.map!(ws => ws.length)().reduce!max(); + writefln("%(%s\n%)", filter!(ws => ws.length == m)(anags.byValue)); +} diff --git a/Task/Anagrams/Common-Lisp/anagrams-6.lisp b/Task/Anagrams/Common-Lisp/anagrams-6.lisp new file mode 100644 index 0000000000..a653db655f --- /dev/null +++ b/Task/Anagrams/Common-Lisp/anagrams-6.lisp @@ -0,0 +1,10 @@ +import std.stdio, std.stream, tools.functional, tools.base; + +void main() { + ( (new BufferedFile("/usr/share/dict/cracklib-small")) + /map/ ex!("s -> s.dup") + /groupby/ ex!("s -> s.dup.sort") + /map/ (string key, string[] value) { return value; } + /qsort/ ex!("a, b -> a.length < b.length") + )[$-1].writefln(); +} diff --git a/Task/Anagrams/E/anagrams.e b/Task/Anagrams/E/anagrams.e new file mode 100644 index 0000000000..f041514dae --- /dev/null +++ b/Task/Anagrams/E/anagrams.e @@ -0,0 +1,22 @@ +println("Downloading...") +when (def wordText := <- getText()) -> { + def words := wordText.split("\n") + + def storage := [].asMap().diverge() + def anagramTable extends storage { + to get(key) { return storage.fetch(key, fn { storage[key] := [].diverge() }) } + } + + println("Grouping...") + var largestGroupSeen := 0 + for word in words { + def anagramGroup := anagramTable[word.sort()] + anagramGroup.push(word) + largestGroupSeen max= anagramGroup.size() + } + + println("Selecting...") + for _ => anagramGroup ? (anagramGroup.size() == mostSeen) in anagramTable { + println(anagramGroup.snapshot()) + } +} diff --git a/Task/Anagrams/Elena/anagrams.elena b/Task/Anagrams/Elena/anagrams.elena new file mode 100644 index 0000000000..8424282c57 --- /dev/null +++ b/Task/Anagrams/Elena/anagrams.elena @@ -0,0 +1,47 @@ +#define std'dictionary'*. +#define std'basic'*. +#define std'patterns'*. +#define std'routines'*. +#define std'collections'*. +#define ext'patterns'*. +#define sys'dates'*. +#define io'* = sys'io'*. + +#symbol Str2CharList : aLiteral + = Summing &&var:List &prop:ecloneprop start:Scan::aLiteral. + +#symbol Normalized : aLiteral + = WideStrValue::(Summing::String start: + Scan::(Str2CharList::aLiteral~esort run: aPair = (aPair former < aPair later))). + +#symbol Program = +[ + #var aStart := Now. + + #var aDictionary := Dictionary. + + ReaderScan &&io'path:"unixdict.txt" &:io'AReadOnlyTextFile run: aWord = + [ + #var aKey := Normalized::aWord. + #var anItem := nil. + #if anItem := aDictionary @ aKey + | [ + anItem := List. + aDictionary append &dictionary_key:aKey &content:anItem. + ]. + + anItem += WideStrValue::aWord. + ]. + + aDictionary~esort run: aPair = (aPair former count > aPair later count). + + Scan &&enumerable:aDictionary &length:20 &:EListSubRange run: aList = + [ + 'program'output << aList << "%n". + ]. + + #var anEnd := Now. + + #var aDiff := anEnd - aStart. + 'program'output << "%nTime elapsed in msec:" << aDiff milliseconds. +]. diff --git a/Task/Anagrams/Euphoria/anagrams.euphoria b/Task/Anagrams/Euphoria/anagrams.euphoria new file mode 100644 index 0000000000..ea9a19e74e --- /dev/null +++ b/Task/Anagrams/Euphoria/anagrams.euphoria @@ -0,0 +1,49 @@ +include sort.e + +function compare_keys(sequence a, sequence b) + return compare(a[1],b[1]) +end function + +constant fn = open("unixdict.txt","r") +sequence words, anagrams +object word +words = {} +while 1 do + word = gets(fn) + if atom(word) then + exit + end if + word = word[1..$-1] -- truncate new-line character + words = append(words, {sort(word), word}) +end while +close(fn) + +integer maxlen +maxlen = 0 +words = custom_sort(routine_id("compare_keys"), words) +anagrams = {words[1]} +for i = 2 to length(words) do + if equal(anagrams[$][1],words[i][1]) then + anagrams[$] = append(anagrams[$], words[i][2]) + elsif length(anagrams[$]) = 2 then + anagrams[$] = words[i] + else + if length(anagrams[$]) > maxlen then + maxlen = length(anagrams[$]) + end if + anagrams = append(anagrams, words[i]) + end if +end for +if length(anagrams[$]) = 2 then + anagrams = anagrams[1..$-1] +end if + +for i = 1 to length(anagrams) do + if length(anagrams[i]) = maxlen then + for j = 2 to length(anagrams[i]) do + puts(1,anagrams[i][j]) + puts(1,' ') + end for + puts(1,"\n") + end if +end for diff --git a/Task/Animate-a-pendulum/C++/animate-a-pendulum-1.cpp b/Task/Animate-a-pendulum/C++/animate-a-pendulum-1.cpp new file mode 100644 index 0000000000..1da20a6dd1 --- /dev/null +++ b/Task/Animate-a-pendulum/C++/animate-a-pendulum-1.cpp @@ -0,0 +1,66 @@ +#ifndef __wxPendulumDlg_h__ +#define __wxPendulumDlg_h__ + +// --------------------- +/// @author Martin Ettl +/// @date 2013-02-03 +// --------------------- + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include +#include +#else +#include +#endif +#include +#include +#include + +class wxPendulumDlgApp : public wxApp +{ + public: + bool OnInit(); + int OnExit(); +}; + +class wxPendulumDlg : public wxDialog +{ + public: + + wxPendulumDlg(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("wxPendulum"), + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = wxSUNKEN_BORDER | wxCAPTION | wxRESIZE_BORDER | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxCLOSE_BOX); + + virtual ~wxPendulumDlg(); + + // Event handler + void wxPendulumDlgPaint(wxPaintEvent& event); + void wxPendulumDlgSize(wxSizeEvent& event); + void OnTimer(wxTimerEvent& event); + + private: + + // a pointer to a timer object + wxTimer *m_timer; + + unsigned int m_uiLength; + double m_Angle; + double m_AngleVelocity; + + enum wxIDs + { + ID_WXTIMER1 = 1001, + ID_DUMMY_VALUE_ + }; + + void OnClose(wxCloseEvent& event); + void CreateGUIControls(); + + DECLARE_EVENT_TABLE() +}; + +#endif // __wxPendulumDlg_h__ diff --git a/Task/Animate-a-pendulum/C++/animate-a-pendulum-2.cpp b/Task/Animate-a-pendulum/C++/animate-a-pendulum-2.cpp new file mode 100644 index 0000000000..47e29d6289 --- /dev/null +++ b/Task/Animate-a-pendulum/C++/animate-a-pendulum-2.cpp @@ -0,0 +1,112 @@ +// --------------------- +/// @author Martin Ettl +/// @date 2013-02-03 +// --------------------- + +#include "wxPendulumDlg.hpp" +#include + +IMPLEMENT_APP(wxPendulumDlgApp) + +bool wxPendulumDlgApp::OnInit() +{ + wxPendulumDlg* dialog = new wxPendulumDlg(NULL); + SetTopWindow(dialog); + dialog->Show(true); + return true; +} + +int wxPendulumDlgApp::OnExit() +{ + return 0; +} + +BEGIN_EVENT_TABLE(wxPendulumDlg, wxDialog) + EVT_CLOSE(wxPendulumDlg::OnClose) + EVT_SIZE(wxPendulumDlg::wxPendulumDlgSize) + EVT_PAINT(wxPendulumDlg::wxPendulumDlgPaint) + EVT_TIMER(ID_WXTIMER1, wxPendulumDlg::OnTimer) +END_EVENT_TABLE() + +wxPendulumDlg::wxPendulumDlg(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style) + : wxDialog(parent, id, title, position, size, style) +{ + CreateGUIControls(); +} + +wxPendulumDlg::~wxPendulumDlg() +{ +} + +void wxPendulumDlg::CreateGUIControls() +{ + SetIcon(wxNullIcon); + SetSize(8, 8, 509, 412); + Center(); + + m_uiLength = 200; + m_Angle = M_PI/2.; + m_AngleVelocity = 0; + + m_timer = new wxTimer(); + m_timer->SetOwner(this, ID_WXTIMER1); + m_timer->Start(20); +} + +void wxPendulumDlg::OnClose(wxCloseEvent& WXUNUSED(event)) +{ + Destroy(); +} + +void wxPendulumDlg::wxPendulumDlgPaint(wxPaintEvent& WXUNUSED(event)) +{ + SetBackgroundStyle(wxBG_STYLE_CUSTOM); + wxBufferedPaintDC dc(this); + + // Get window dimensions + wxSize sz = GetClientSize(); + // determine the center of the canvas + const wxPoint center(wxPoint(sz.x / 2, sz.y / 2)); + + // create background color + wxColour powderblue = wxColour(176,224,230); + + // draw powderblue background + dc.SetPen(powderblue); + dc.SetBrush(powderblue); + dc.DrawRectangle(0, 0, sz.x, sz.y); + + // draw lines + wxPen Pen(*wxBLACK_PEN); + Pen.SetWidth(1); + dc.SetPen(Pen); + dc.SetBrush(*wxBLACK_BRUSH); + + double angleAccel, dt = 0.15; + + angleAccel = (-9.81 / m_uiLength) * sin(m_Angle); + m_AngleVelocity += angleAccel * dt; + m_Angle += m_AngleVelocity * dt; + + int anchorX = sz.x / 2, anchorY = sz.y / 4; + int ballX = anchorX + (int)(sin(m_Angle) * m_uiLength); + int ballY = anchorY + (int)(cos(m_Angle) * m_uiLength); + dc.DrawLine(anchorX, anchorY, ballX, ballY); + + dc.SetBrush(*wxGREY_BRUSH); + dc.DrawEllipse(anchorX - 3, anchorY - 4, 7, 7); + + dc.SetBrush(wxColour(255,255,0)); // yellow + dc.DrawEllipse(ballX - 7, ballY - 7, 20, 20); +} + +void wxPendulumDlg::wxPendulumDlgSize(wxSizeEvent& WXUNUSED(event)) +{ + Refresh(); +} + +void wxPendulumDlg::OnTimer(wxTimerEvent& WXUNUSED(event)) +{ + // force refresh + Refresh(); +} diff --git a/Task/Animate-a-pendulum/C-sharp/animate-a-pendulum.cs b/Task/Animate-a-pendulum/C-sharp/animate-a-pendulum.cs new file mode 100644 index 0000000000..45e37c665e --- /dev/null +++ b/Task/Animate-a-pendulum/C-sharp/animate-a-pendulum.cs @@ -0,0 +1,54 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +class CSharpPendulum +{ + Form _form; + Timer _timer; + + double _angle = Math.PI / 2, + _angleAccel, + _angleVelocity = 0, + _dt = 0.1; + + int _length = 50; + + [STAThread] + static void Main() + { + var p = new CSharpPendulum(); + } + + public CSharpPendulum() + { + _form = new Form() { Text = "Pendulum", Width = 200, Height = 200 }; + _timer = new Timer() { Interval = 30 }; + + _timer.Tick += delegate(object sender, EventArgs e) + { + int anchorX = (_form.Width / 2) - 12, + anchorY = _form.Height / 4, + ballX = anchorX + (int)(Math.Sin(_angle) * _length), + ballY = anchorY + (int)(Math.Cos(_angle) * _length); + + _angleAccel = -9.81 / _length * Math.Sin(_angle); + _angleVelocity += _angleAccel * _dt; + _angle += _angleVelocity * _dt; + + Bitmap dblBuffer = new Bitmap(_form.Width, _form.Height); + Graphics g = Graphics.FromImage(dblBuffer); + Graphics f = Graphics.FromHwnd(_form.Handle); + + g.DrawLine(Pens.Black, new Point(anchorX, anchorY), new Point(ballX, ballY)); + g.FillEllipse(Brushes.Black, anchorX - 3, anchorY - 4, 7, 7); + g.FillEllipse(Brushes.DarkGoldenrod, ballX - 7, ballY - 7, 14, 14); + + f.Clear(Color.White); + f.DrawImage(dblBuffer, new Point(0, 0)); + }; + + _timer.Start(); + Application.Run(_form); + } +} diff --git a/Task/Animate-a-pendulum/E/animate-a-pendulum.e b/Task/Animate-a-pendulum/E/animate-a-pendulum.e new file mode 100644 index 0000000000..e3cc31f9dc --- /dev/null +++ b/Task/Animate-a-pendulum/E/animate-a-pendulum.e @@ -0,0 +1,88 @@ +#!/usr/bin/env rune +pragma.syntax("0.9") + +def pi := (-1.0).acos() +def makeEPainter := +def makeLamportSlot := +def whenever := +def colors := + +# -------------------------------------------------------------- +# --- Definitions + +def makePendulumSim(length_m :float64, + gravity_mps2 :float64, + initialAngle_rad :float64, + timestep_ms :int) { + var velocity := 0 + def &angle := makeLamportSlot(initialAngle_rad) + def k := -gravity_mps2/length_m + def timestep_s := timestep_ms / 1000 + def clock := timer.every(timestep_ms, fn _ { + def acceleration := k * angle.sin() + velocity += acceleration * timestep_s + angle += velocity * timestep_s + }) + return [clock, &angle] +} + +def makeDisplayComponent(&angle) { + def c + def updater := whenever([&angle], fn { c.repaint() }) + + bind c := makeEPainter(def paintCallback { + to paintComponent(g) { + try { + def originX := c.getWidth() // 2 + def originY := c.getHeight() // 2 + def pendRadius := (originX.min(originY) * 0.95).round() + def ballRadius := (originX.min(originY) * 0.04).round() + def ballX := (originX + angle.sin() * pendRadius).round() + def ballY := (originY + angle.cos() * pendRadius).round() + + g.setColor(colors.getWhite()) + g.fillRect(0, 0, c.getWidth(), c.getHeight()) + g.setColor(colors.getBlack()) + + g.fillOval(originX - 2, originY - 2, 4, 4) + g.drawLine(originX, originY, ballX, ballY) + g.fillOval(ballX - ballRadius, ballY - ballRadius, ballRadius * 2, ballRadius * 2) + + updater[] # provoke interest provided that we did get drawn (window not closed) + } catch p { + stderr.println(`In paint callback: $p${p.eStack()}`) + } + } + }) + + c.setPreferredSize((300, 300)) + return c +} + +# -------------------------------------------------------------- +# --- Application setup + +def [clock, &angle] := makePendulumSim(1, 9.80665, pi*99/100, 10) + +# Initialize AWT, move to AWT event thread +when (currentVat.morphInto("awt")) -> { + + # Create the window + def frame := ("Pendulum") + frame.setContentPane(def display := makeDisplayComponent(&angle)) + frame.addWindowListener(def mainWindowListener { + to windowClosing(_) { + clock.stop() + interp.continueAtTop() + } + match _ {} + }) + frame.setLocation(50, 50) + frame.pack() + + # Start and become visible + frame.show() + clock.start() +} + +interp.blockAtTop() diff --git a/Task/Animate-a-pendulum/Euphoria/animate-a-pendulum.euphoria b/Task/Animate-a-pendulum/Euphoria/animate-a-pendulum.euphoria new file mode 100644 index 0000000000..59e2c6d1ff --- /dev/null +++ b/Task/Animate-a-pendulum/Euphoria/animate-a-pendulum.euphoria @@ -0,0 +1,57 @@ +include graphics.e +include misc.e + +constant dt = 1E-3 +constant g = 50 + +sequence vc +sequence suspension +atom len + +procedure draw_pendulum(atom color, atom len, atom alfa) + sequence point + point = (len*{sin(alfa),cos(alfa)} + suspension) + draw_line(color, {suspension, point}) + ellipse(color,0,point-{10,10},point+{10,10}) +end procedure + +function wait() + atom t0 + t0 = time() + while time() = t0 do + if get_key() != -1 then + return 1 + end if + end while + return 0 +end function + +procedure animation() + atom alfa, omega, epsilon + + if graphics_mode(18) then + end if + + vc = video_config() + suspension = {vc[VC_XPIXELS]/2,vc[VC_YPIXELS]/2} + len = vc[VC_YPIXELS]/2-20 + + alfa = PI/2 + omega = 0 + + while 1 do + draw_pendulum(BRIGHT_WHITE,len,alfa) + if wait() then + exit + end if + draw_pendulum(BLACK,len,alfa) + epsilon = -len*sin(alfa)*g + omega += dt*epsilon + alfa += dt*omega + end while + + if graphics_mode(-1) then + end if +end procedure + +animation() diff --git a/Task/Animation/C-sharp/animation.cs b/Task/Animation/C-sharp/animation.cs new file mode 100644 index 0000000000..416342c0a1 --- /dev/null +++ b/Task/Animation/C-sharp/animation.cs @@ -0,0 +1,56 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace BasicAnimation +{ + class BasicAnimationForm : Form + { + bool isReverseDirection; + Label textLabel; + Timer timer; + + internal BasicAnimationForm() + { + this.Size = new Size(150, 75); + this.Text = "Basic Animation"; + + textLabel = new Label(); + textLabel.Text = "Hello World! "; + textLabel.Location = new Point(3,3); + textLabel.AutoSize = true; + textLabel.Click += new EventHandler(textLabel_OnClick); + this.Controls.Add(textLabel); + + timer = new Timer(); + timer.Interval = 500; + timer.Tick += new EventHandler(timer_OnTick); + timer.Enabled = true; + + isReverseDirection = false; + } + + private void timer_OnTick(object sender, EventArgs e) + { + string oldText = textLabel.Text, newText; + if(isReverseDirection) + newText = oldText.Substring(1, oldText.Length - 1) + oldText.Substring(0, 1); + else + newText = oldText.Substring(oldText.Length - 1, 1) + oldText.Substring(0, oldText.Length - 1); + textLabel.Text = newText; + } + + private void textLabel_OnClick(object sender, EventArgs e) + { + isReverseDirection = !isReverseDirection; + } + } + + class Program + { + static void Main() + { + Application.Run(new BasicAnimationForm()); + } + } +} diff --git a/Task/Animation/Common-Lisp/animation.lisp b/Task/Animation/Common-Lisp/animation.lisp new file mode 100644 index 0000000000..08b1f013c4 --- /dev/null +++ b/Task/Animation/Common-Lisp/animation.lisp @@ -0,0 +1,33 @@ +(use-package :ltk) + +(defparameter *message* "Hello World! ") +(defparameter *direction* :left) +(defun animate (label) + (let* ((n (length *message*)) + (i (if (eq *direction* :left) 0 (1- n))) + (c (char *message* i))) + (if (eq *direction* :left) + (setq *message* (concatenate 'string + (subseq *message* 1 n) + (list c))) + (setq *message* (concatenate 'string (list c) + (subseq *message* 0 (1- n))))) + (setf (ltk:text label) *message*) + (ltk:after 125 (lambda () (animate label))))) + +(defun basic-animation () + (ltk:with-ltk () + (let* ((label (make-instance 'label + :font "Courier 14"))) + (setf (text label) *message*) + (ltk:bind label "" + (lambda (event) + (declare (ignore event)) + (cond + ((eq *direction* :left) (setq *direction* :right)) + ((eq *direction* :right) (setq *direction* :left))))) + (ltk:pack label) + (animate label) + (ltk:mainloop)))) + +(basic-animation) diff --git a/Task/Animation/D/animation.d b/Task/Animation/D/animation.d new file mode 100644 index 0000000000..680706a681 --- /dev/null +++ b/Task/Animation/D/animation.d @@ -0,0 +1,24 @@ +module test26; + +import qd, SDL_ttf, tools.time; + +void main() { + screen(320, 200); + auto last = sec(); + string text = "Hello World! "; + auto speed = 0.2; + int dir = true; + while (true) { + cls; + print(10, 10, Bottom|Right, text); + if (sec() - last > speed) { + last = sec(); + if (dir == 0) text = text[$-1] ~ text[0 .. $-1]; + else text = text[1 .. $] ~ text[0]; + } + flip; events; + if (mouse.clicked + && mouse.pos in display.select(10, 10, 100, 20) + ) dir = !dir; + } +} diff --git a/Task/Animation/E/animation-1.e b/Task/Animation/E/animation-1.e new file mode 100644 index 0000000000..886fe0c3e3 --- /dev/null +++ b/Task/Animation/E/animation-1.e @@ -0,0 +1,38 @@ +# State +var text := "Hello World! " +var leftward := false + +# Window +def w := ("RC: Basic Animation") + +# Text in window +w.setContentPane(def l := (text)) +l.setOpaque(true) # repaints badly if not set! +l.addMouseListener(def mouseListener { + to mouseClicked(_) { + leftward := !leftward + } + match _ {} +}) + +# Animation +def anim := timer.every(100, fn _ { # milliseconds + def s := text.size() + l.setText(text := if (leftward) { + text(1, s) + text(0, 1) + } else { + text(s - 1, s) + text(0, s - 1) + }) +}) + +# Set up window shape and close behavior +w.pack() +w.setLocationRelativeTo(null) +w.addWindowListener(def windowListener { + to windowClosing(_) { anim.stop() } + match _ {} +}) + +# Start everything +w.show() +anim.start() diff --git a/Task/Animation/E/animation-2.e b/Task/Animation/E/animation-2.e new file mode 100644 index 0000000000..cf026fb618 --- /dev/null +++ b/Task/Animation/E/animation-2.e @@ -0,0 +1,17 @@ +def [reverse, stop] := { + var text := "Hello World! " + var leftward := false + + def anim := timer.every(100, fn _ { # milliseconds + def s := text.size() + text := if (leftward) { + text(1, s) + text(0, 1) + } else { + text(s - 1, s) + text(0, s - 1) + } + print("\b" * s, text) + }) + print("\n", text) + anim.start() + [def _() { leftward := !leftward; null }, anim.stop] +} diff --git a/Task/Anonymous-recursion/C++/anonymous-recursion-1.cpp b/Task/Anonymous-recursion/C++/anonymous-recursion-1.cpp new file mode 100644 index 0000000000..c04d0fc664 --- /dev/null +++ b/Task/Anonymous-recursion/C++/anonymous-recursion-1.cpp @@ -0,0 +1,27 @@ +double fib(const double n) +{ + if(n < 0) + { + throw "Invalid argument passed to fib"; + } + else + { + class actual_fib + { + public: + static double calc(const double n) + { + if(n < 2) + { + return n; + } + else + { + return calc(n-1) + calc(n-2); + } + } + }; + + return actual_fib::calc(n); + } +} diff --git a/Task/Anonymous-recursion/C++/anonymous-recursion-2.cpp b/Task/Anonymous-recursion/C++/anonymous-recursion-2.cpp new file mode 100644 index 0000000000..77b2b591c2 --- /dev/null +++ b/Task/Anonymous-recursion/C++/anonymous-recursion-2.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; + +double fib(double n) +{ + if(n < 0) + throw "Invalid argument"; + + function actual_fib = [&](double n) + { + if(n < 2) return n; + return actual_fib(n-1) + actual_fib(n-2); + }; + + return actual_fib(n); +} diff --git a/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-1.lisp b/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-1.lisp new file mode 100644 index 0000000000..390f5351d1 --- /dev/null +++ b/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-1.lisp @@ -0,0 +1,9 @@ +(defun fib (number) + "Fibonacci sequence function." + (if (< number 0) + (error "Error. The number entered: ~A is negative" number) + (labels ((fib1 (n a b) + (if (= n 0) + a + (fib1 (- n 1) b (+ a b))))) + (fib1 number 0 1)))) diff --git a/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-2.lisp b/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-2.lisp new file mode 100644 index 0000000000..dc9837e6d4 --- /dev/null +++ b/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-2.lisp @@ -0,0 +1,8 @@ +(defun fib (number) + "Fibonacci sequence function." + (if (< number 0) + (error "Error. The number entered: ~A is negative" number) + (recursive ((n number) (a 0) (b 1)) + (if (= n 0) + a + (recurse (- n 1) b (+ a b)))))) diff --git a/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-3.lisp b/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-3.lisp new file mode 100644 index 0000000000..6e3ec84378 --- /dev/null +++ b/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-3.lisp @@ -0,0 +1,5 @@ +(defmacro recursive ((&rest parm-init-pairs) &body body) + (let ((hidden-name (gensym "RECURSIVE-"))) + `(macrolet ((recurse (&rest args) `(,',hidden-name ,@args))) + (labels ((,hidden-name (,@(mapcar #'first parm-init-pairs)) ,@body)) + (,hidden-name ,@(mapcar #'second parm-init-pairs)))))) diff --git a/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-4.lisp b/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-4.lisp new file mode 100644 index 0000000000..7be6813054 --- /dev/null +++ b/Task/Anonymous-recursion/Common-Lisp/anonymous-recursion-4.lisp @@ -0,0 +1,64 @@ +(setf (symbol-function '!) (symbol-function 'funcall) + (symbol-function '!!) (symbol-function 'apply)) + +(defmacro ? (args &body body) + `(lambda ,args ,@body)) + +(defstruct combinator + (name nil :type symbol) + (function nil :type function)) + +(defmethod print-object ((combinator combinator) stream) + (print-unreadable-object (combinator stream :type t) + (format stream "~A" (combinator-name combinator)))) + +(defconstant +y-combinator+ + (make-combinator + :name 'y-combinator + :function (? (f) (! (? (g) (! g g)) + (? (g) (! f (? (&rest a) + (!! (! g g) a)))))))) + +(defconstant +z-combinator+ + (make-combinator + :name 'z-combinator + :function (? (f) (! (? (g) (! f (? (x) (! (! g g) x)))) + (? (g) (! f (? (x) (! (! g g) x)))))))) + +(defparameter *default-combinator* +y-combinator+) + +(defmacro with-y-combinator (&body body) + `(let ((*default-combinator* +y-combinator+)) + ,@body)) + +(defmacro with-z-combinator (&body body) + `(let ((*default-combinator* +z-combinator+)) + ,@body)) + +(defun x-call (x-function &rest args) + (apply (funcall (combinator-function *default-combinator*) x-function) args)) + +(defmacro x-function ((name &rest args) &body body) + `(lambda (,name) + (lambda ,args + (macrolet ((,name (&rest args) + `(funcall ,',name ,@args))) + ,@body)))) + +(defmacro x-defun (name args &body body) + `(defun ,name ,args + (x-call (x-function (,name ,@args) ,@body) ,@args))) + +;;;; examples + +(x-defun factorial (n) + (if (zerop n) + 1 + (* n (factorial (1- n))))) + +(x-defun fib (n) + (case n + (0 0) + (1 1) + (otherwise (+ (fib (- n 1)) + (fib (- n 2)))))) diff --git a/Task/Anonymous-recursion/D/anonymous-recursion-1.d b/Task/Anonymous-recursion/D/anonymous-recursion-1.d new file mode 100644 index 0000000000..b8132604db --- /dev/null +++ b/Task/Anonymous-recursion/D/anonymous-recursion-1.d @@ -0,0 +1,9 @@ +uint fib(in uint n) pure nothrow { + immutable self = &__traits(parent, {}); + return (n < 2) ? n : self(n - 1) + self(n - 2); +} + +void main() { + import std.stdio; + writeln(fib(39)); +} diff --git a/Task/Anonymous-recursion/D/anonymous-recursion-2.d b/Task/Anonymous-recursion/D/anonymous-recursion-2.d new file mode 100644 index 0000000000..5340199d57 --- /dev/null +++ b/Task/Anonymous-recursion/D/anonymous-recursion-2.d @@ -0,0 +1,18 @@ +import std.stdio; + +int fib(in int n) pure nothrow { + assert(n >= 0); + + return (new class { + static int opCall(in int m) pure nothrow { + if (m < 2) + return m; + else + return opCall(m - 1) + opCall(m - 2); + } + })(n); +} + +void main() { + writeln(fib(39)); +} diff --git a/Task/Anonymous-recursion/Deja-Vu/anonymous-recursion-1.djv b/Task/Anonymous-recursion/Deja-Vu/anonymous-recursion-1.djv new file mode 100644 index 0000000000..e12c0c2c3f --- /dev/null +++ b/Task/Anonymous-recursion/Deja-Vu/anonymous-recursion-1.djv @@ -0,0 +1,18 @@ +Y f: + labda y: + labda: + f y @y + call dup + +labda fib n: + if <= n 1: + 1 + else: + fib - n 1 + fib - n 2 + + +Y +set :fibo + +for j range 0 10: + print fibo j diff --git a/Task/Anonymous-recursion/Deja-Vu/anonymous-recursion-2.djv b/Task/Anonymous-recursion/Deja-Vu/anonymous-recursion-2.djv new file mode 100644 index 0000000000..c6080a0d40 --- /dev/null +++ b/Task/Anonymous-recursion/Deja-Vu/anonymous-recursion-2.djv @@ -0,0 +1,15 @@ +fibo-2 n: + n 0 1 + labda times back-2 back-1: + if = times 0: + back-2 + elseif = times 1: + back-1 + elseif = times 2: + + back-1 back-2 + else: + recurse -- times back-1 + back-1 back-2 + call + +for j range 0 10: + print fibo-2 j diff --git a/Task/Anonymous-recursion/Ela/anonymous-recursion-1.ela b/Task/Anonymous-recursion/Ela/anonymous-recursion-1.ela new file mode 100644 index 0000000000..dce4e280f4 --- /dev/null +++ b/Task/Anonymous-recursion/Ela/anonymous-recursion-1.ela @@ -0,0 +1,2 @@ +fib n | n < 0 = fail "Negative n" + | else = fix (\f n -> if n < 2 then n else f (n - 1) + f (n - 2)) n diff --git a/Task/Anonymous-recursion/Ela/anonymous-recursion-2.ela b/Task/Anonymous-recursion/Ela/anonymous-recursion-2.ela new file mode 100644 index 0000000000..1c93af6c57 --- /dev/null +++ b/Task/Anonymous-recursion/Ela/anonymous-recursion-2.ela @@ -0,0 +1 @@ +fix f = f (& fix f) diff --git a/Task/Anonymous-recursion/Elena/anonymous-recursion.elena b/Task/Anonymous-recursion/Elena/anonymous-recursion.elena new file mode 100644 index 0000000000..c5fdee5b6d --- /dev/null +++ b/Task/Anonymous-recursion/Elena/anonymous-recursion.elena @@ -0,0 +1,21 @@ +#define std'dictionary'*. +#define std'patterns'*. + +#symbol fibo : i = +[ + Control ifNot:(i < 0). + + #if (i < 2) + ? [ ^ i. ] + | [ ^ fibo::(i - 2) + fibo::(i - 1). ]. +]. + +#symbol Program = +[ + loop &&from:-1 &to:10 run: i = + [ + 'program'output << "%nfib(" << i << ")=". + + 'program'output << fibo::i | << "failed". + ]. +]. diff --git a/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-1.cpp b/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-1.cpp new file mode 100644 index 0000000000..b5b7ab1d68 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-1.cpp @@ -0,0 +1,16 @@ +#include //cout for printing +#include //for_each defined here + +//create the function (print the square) +void print_square(int i) { + std::cout << i*i << " "; +} + +int main() { + //create the array + int ary[]={1,2,3,4,5}; + //stl for_each + std::for_each(ary,ary+5,print_square); + return 0; +} +//prints 1 4 9 16 25 diff --git a/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-2.cpp b/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-2.cpp new file mode 100644 index 0000000000..8bc4dc2d13 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-2.cpp @@ -0,0 +1,22 @@ +#include // cout for printing +#include // for_each defined here +#include // stl vector class + +// create the function (print the square) +void print_square(int i) { + std::cout << i*i << " "; +} + +int main() { + // create the array + std::vector ary; + ary.push_back(1); + ary.push_back(2); + ary.push_back(3); + ary.push_back(4); + ary.push_back(5); + // stl for_each + std::for_each(ary.begin(),ary.end(),print_square); + return 0; +} +//prints 1 4 9 16 25 diff --git a/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-3.cpp b/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-3.cpp new file mode 100644 index 0000000000..b7cea1cbce --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-3.cpp @@ -0,0 +1,24 @@ +#include // cout for printing +#include // for_each defined here +#include // stl vector class +#include // bind and ptr_fun + +// create a binary function (print any two arguments together) +template +void print_juxtaposed(type1 x, type2 y) { + std::cout << x << y; +} + +int main() { + // create the array + std::vector ary; + ary.push_back(1); + ary.push_back(2); + ary.push_back(3); + ary.push_back(4); + ary.push_back(5); + // stl for_each, using binder and adaptable unary function + std::for_each(ary.begin(),ary.end(),std::bind2nd(std::ptr_fun(print_juxtaposed),"x ")); + return 0; +} +//prints 1x 2x 3x 4x 5x diff --git a/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-4.cpp b/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-4.cpp new file mode 100644 index 0000000000..b6e64869ac --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-4.cpp @@ -0,0 +1,6 @@ +using namespace std; +using namespace boost::lambda; +vector ary(10); +int i = 0; +for_each(ary.begin(), ary.end(), _1 = ++var(i)); // init array +transform(ary.begin(), ary.end(), ostream_iterator(cout, " "), _1 * _1); // square and output diff --git a/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-5.cpp b/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-5.cpp new file mode 100644 index 0000000000..dc4b996099 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/C++/apply-a-callback-to-an-array-5.cpp @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +int main( ) { + std::vector< int > intVec( 10 ) ; + std::iota( intVec.begin( ) , intVec.end( ) , 1 ) ;//fill the vector + std::transform( intVec.begin( ) , intVec.end( ) , intVec.begin( ) , + [ ] ( int i ) { return i * i ; } ) ; //transform it with closures + std::copy( intVec.begin( ) , intVec.end( ) , + std::ostream_iterator ( std::cout , " " ) ) ; + std::cout << std::endl ; + return 0 ; +} diff --git a/Task/Apply-a-callback-to-an-array/C-sharp/apply-a-callback-to-an-array-1.cs b/Task/Apply-a-callback-to-an-array/C-sharp/apply-a-callback-to-an-array-1.cs new file mode 100644 index 0000000000..5732b940db --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/C-sharp/apply-a-callback-to-an-array-1.cs @@ -0,0 +1,34 @@ +using System; + +static class Program +{ + // Purpose: Apply a callback (or anonymous method) to an Array + // Output: Prints the squares of an int array to the console. + // Compiler: Visual Studio 2005 + // Framework: .net 2 + + [STAThread] + public static void Main() + { + int[] intArray = { 1, 2, 3, 4, 5 }; + + // Using a callback, + Console.WriteLine("Printing squares using a callback:"); + Array.ForEach(intArray, PrintSquare); + + // or using an anonymous method: + Console.WriteLine("Printing squares using an anonymous method:"); + Array.ForEach + ( + intArray, + delegate(int value) + { + Console.WriteLine(value * value); + }); + } + + public static void PrintSquare(int value) + { + Console.WriteLine(value * value); + } +} diff --git a/Task/Apply-a-callback-to-an-array/C-sharp/apply-a-callback-to-an-array-2.cs b/Task/Apply-a-callback-to-an-array/C-sharp/apply-a-callback-to-an-array-2.cs new file mode 100644 index 0000000000..e5bc00017c --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/C-sharp/apply-a-callback-to-an-array-2.cs @@ -0,0 +1,2 @@ +int[] intArray = { 1, 2, 3, 4, 5 }; +Array.ForEach(intArray, i => Console.WriteLine(i * i)); diff --git a/Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-1.clean b/Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-1.clean new file mode 100644 index 0000000000..10dd299736 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-1.clean @@ -0,0 +1,4 @@ +square x = x * x + +values :: {#Int} +values = {x \\ x <- [1 .. 10]} diff --git a/Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-2.clean b/Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-2.clean new file mode 100644 index 0000000000..ec248cb33b --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-2.clean @@ -0,0 +1 @@ +mapArray f array = {f x \\ x <-: array} diff --git a/Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-3.clean b/Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-3.clean new file mode 100644 index 0000000000..3c5046d3a1 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Clean/apply-a-callback-to-an-array-3.clean @@ -0,0 +1,2 @@ +Start :: {#Int} +Start = mapArray square values diff --git a/Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-1.lisp b/Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-1.lisp new file mode 100644 index 0000000000..180dffef37 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-1.lisp @@ -0,0 +1 @@ +(map nil #'print #(1 2 3 4 5)) diff --git a/Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-2.lisp b/Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-2.lisp new file mode 100644 index 0000000000..527fe73b11 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-2.lisp @@ -0,0 +1,2 @@ +(defun square (x) (* x x)) +(map 'vector #'square #(1 2 3 4 5)) diff --git a/Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-3.lisp b/Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-3.lisp new file mode 100644 index 0000000000..d4ca72ce73 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Common-Lisp/apply-a-callback-to-an-array-3.lisp @@ -0,0 +1,2 @@ +(defvar *a* (vector 1 2 3)) +(map-into *a* #'1+ *a*) diff --git a/Task/Apply-a-callback-to-an-array/D/apply-a-callback-to-an-array.d b/Task/Apply-a-callback-to-an-array/D/apply-a-callback-to-an-array.d new file mode 100644 index 0000000000..81217d6492 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/D/apply-a-callback-to-an-array.d @@ -0,0 +1,7 @@ +import std.stdio, std.algorithm; + +void main() { + auto items = [1, 2, 3, 4, 5]; + auto m = items.map!(x => x + 5)(); + writeln(m); +} diff --git a/Task/Apply-a-callback-to-an-array/Delphi/apply-a-callback-to-an-array.delphi b/Task/Apply-a-callback-to-an-array/Delphi/apply-a-callback-to-an-array.delphi new file mode 100644 index 0000000000..201241fcf7 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Delphi/apply-a-callback-to-an-array.delphi @@ -0,0 +1,17 @@ +// Declare the callback function +procedure callback(const AInt:Integer); +begin + WriteLn(AInt); +end; + +const + // Declare a static array + myArray:Array[0..4] of Integer=(1,4,6,8,7); +var + // Declare interator variable + i:Integer; +begin + // Iterate the array and apply callback + for i:=0 to length(myArray)-1 do + callback(myArray[i]); +end. diff --git a/Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-1.e b/Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-1.e new file mode 100644 index 0000000000..82a0493657 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-1.e @@ -0,0 +1,4 @@ +def array := [1,2,3,4,5] +def square(value) { + return value * value +} diff --git a/Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-2.e b/Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-2.e new file mode 100644 index 0000000000..dbbec770ef --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-2.e @@ -0,0 +1,4 @@ +def callback(index, value) { + println(`Item $index is $value.`) +} +array.iterate(callback) diff --git a/Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-3.e b/Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-3.e new file mode 100644 index 0000000000..ce9cad9cbe --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/E/apply-a-callback-to-an-array-3.e @@ -0,0 +1,8 @@ +def map(func, collection) { + def output := [].diverge() + for item in collection { + output.push(func(item)) + } + return output.snapshot() +} +println(map(square, array)) diff --git a/Task/Apply-a-callback-to-an-array/EGL/apply-a-callback-to-an-array.egl b/Task/Apply-a-callback-to-an-array/EGL/apply-a-callback-to-an-array.egl new file mode 100644 index 0000000000..1251fa28ac --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/EGL/apply-a-callback-to-an-array.egl @@ -0,0 +1,20 @@ +delegate callback( i int ) returns( int ) end + +program ApplyCallbackToArray + function main() + values int[] = [ 1, 2, 3, 4, 5 ]; + + func callback = square; + for ( i int to values.getSize() ) + values[ i ] = func( values[ i ] ); + end + + for ( i int to values.getSize() ) + SysLib.writeStdout( values[ i ] ); + end + end + + function square( i int ) returns( int ) + return( i * i ); + end +end diff --git a/Task/Apply-a-callback-to-an-array/Efene/apply-a-callback-to-an-array.efene b/Task/Apply-a-callback-to-an-array/Efene/apply-a-callback-to-an-array.efene new file mode 100644 index 0000000000..58d1917266 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Efene/apply-a-callback-to-an-array.efene @@ -0,0 +1,32 @@ +square = fn (N) { + N * N +} + +# list comprehension +squares1 = fn (Numbers) { + [square(N) for N in Numbers] +} + +# functional form +squares2a = fn (Numbers) { + lists.map(fn square:1, Numbers) +} + +# functional form with lambda +squares2b = fn (Numbers) { + lists.map(fn (N) { N * N }, Numbers) +} + +# no need for a function +squares3 = fn (Numbers) { + [N * N for N in Numbers] +} + +@public +run = fn () { + Numbers = [1, 3, 5, 7] + io.format("squares1 : ~p~n", [squares1(Numbers)]) + io.format("squares2a: ~p~n", [squares2a(Numbers)]) + io.format("squares2b: ~p~n", [squares2b(Numbers)]) + io.format("squares3 : ~p~n", [squares3(Numbers)]) +} diff --git a/Task/Apply-a-callback-to-an-array/Elena/apply-a-callback-to-an-array.elena b/Task/Apply-a-callback-to-an-array/Elena/apply-a-callback-to-an-array.elena new file mode 100644 index 0000000000..f715ecd28a --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Elena/apply-a-callback-to-an-array.elena @@ -0,0 +1,11 @@ +#define std'patterns'*. +#define std'routines'*. +#define std'dictionary'*. + +#symbol PrintSquarePower: aNumber + = 'program'output << aNumber * aNumber << "%n". + +#symbol Program = +[ + Scan::(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) run:(#symbol PrintSquarePower). +]. diff --git a/Task/Apply-a-callback-to-an-array/Euphoria/apply-a-callback-to-an-array.euphoria b/Task/Apply-a-callback-to-an-array/Euphoria/apply-a-callback-to-an-array.euphoria new file mode 100644 index 0000000000..c8c703c9a6 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Euphoria/apply-a-callback-to-an-array.euphoria @@ -0,0 +1,18 @@ +function apply_to_all(sequence s, integer f) + -- apply a function to all elements of a sequence + sequence result + result = {} + for i = 1 to length(s) do + -- we can call add1() here although it comes later in the program + result = append(result, call_func(f, {s[i]})) + end for + return result +end function + +function add1(atom x) + return x + 1 +end function + +-- add1() is visible here, so we can ask for its routine id +? apply_to_all({1, 2, 3}, routine_id("add1")) +-- displays {2,3,4} diff --git a/Task/Arbitrary-precision-integers-(included)/C-sharp/arbitrary-precision-integers-(included).cs b/Task/Arbitrary-precision-integers-(included)/C-sharp/arbitrary-precision-integers-(included).cs new file mode 100644 index 0000000000..a16bcb2aed --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/C-sharp/arbitrary-precision-integers-(included).cs @@ -0,0 +1,23 @@ +using System; +using System.Diagnostics; +using System.Linq; +using System.Numerics; + +static class Program { + static void Main() { + BigInteger n = BigInteger.Pow(5, (int)BigInteger.Pow(4, (int)BigInteger.Pow(3, 2))); + string result = n.ToString(); + + Debug.Assert(result.Length == 183231); + Debug.Assert(result.StartsWith("62060698786608744707")); + Debug.Assert(result.EndsWith("92256259918212890625")); + + Console.WriteLine("n = 5^4^3^2"); + Console.WriteLine("n = {0}...{1}", + result.Substring(0, 20), + result.Substring(result.Length - 20, 20) + ); + + Console.WriteLine("n digits = {0}", result.Length); + } +} diff --git a/Task/Arbitrary-precision-integers-(included)/Common-Lisp/arbitrary-precision-integers-(included).lisp b/Task/Arbitrary-precision-integers-(included)/Common-Lisp/arbitrary-precision-integers-(included).lisp new file mode 100644 index 0000000000..9d75c9feba --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Common-Lisp/arbitrary-precision-integers-(included).lisp @@ -0,0 +1,3 @@ +(let ((s (format () "~s" (expt 5 (expt 4 (expt 3 2)))))) + (format t "~a...~a, length ~a" (subseq s 0 20) + (subseq s (- (length s) 20)) (length s))) diff --git a/Task/Arbitrary-precision-integers-(included)/D/arbitrary-precision-integers-(included).d b/Task/Arbitrary-precision-integers-(included)/D/arbitrary-precision-integers-(included).d new file mode 100644 index 0000000000..3206a0fc59 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/D/arbitrary-precision-integers-(included).d @@ -0,0 +1,6 @@ +import std.stdio, std.bigint, std.conv; + +void main() { + auto s = text(BigInt(5) ^^ 4 ^^ 3 ^^ 2); + writefln("5^4^3^2 = %s..%s (%d digits)", s[0..20], s[$-20..$], s.length); +} diff --git a/Task/Arbitrary-precision-integers-(included)/E/arbitrary-precision-integers-(included).e b/Task/Arbitrary-precision-integers-(included)/E/arbitrary-precision-integers-(included).e new file mode 100644 index 0000000000..45384c7657 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/E/arbitrary-precision-integers-(included).e @@ -0,0 +1,10 @@ +? def value := 5**(4**(3**2)); null +? def decimal := value.toString(10); null +? decimal(0, 20) +# value: "62060698786608744707" + +? decimal(decimal.size() - 20) +# value: "92256259918212890625" + +? decimal.size() +# value: 183231 diff --git a/Task/Arbitrary-precision-integers-(included)/Emacs-Lisp/arbitrary-precision-integers-(included).l b/Task/Arbitrary-precision-integers-(included)/Emacs-Lisp/arbitrary-precision-integers-(included).l new file mode 100644 index 0000000000..1d6a049d06 --- /dev/null +++ b/Task/Arbitrary-precision-integers-(included)/Emacs-Lisp/arbitrary-precision-integers-(included).l @@ -0,0 +1,9 @@ +(let* ((answer (calc-eval "5**4**3**2")) + (length (length answer))) + (message "%s has %d digits" + (if (> length 40) + (format "%s...%s" + (substring answer 0 20) + (substring answer (- length 20) length)) + answer) + length)) diff --git a/Task/Arena-storage-pool/C++/arena-storage-pool-1.cpp b/Task/Arena-storage-pool/C++/arena-storage-pool-1.cpp new file mode 100644 index 0000000000..e5e3a4f613 --- /dev/null +++ b/Task/Arena-storage-pool/C++/arena-storage-pool-1.cpp @@ -0,0 +1 @@ +T* foo = new(arena) T; diff --git a/Task/Arena-storage-pool/C++/arena-storage-pool-2.cpp b/Task/Arena-storage-pool/C++/arena-storage-pool-2.cpp new file mode 100644 index 0000000000..078d16ab78 --- /dev/null +++ b/Task/Arena-storage-pool/C++/arena-storage-pool-2.cpp @@ -0,0 +1,104 @@ +#include +#include +#include + +// This class basically provides a global stack of pools; it is not thread-safe, and pools must be destructed in reverse order of construction +// (you definitely want something better in production use :-)) +class Pool +{ +public: + Pool(std::size_type sz); + ~Pool(); + static Pool& current() { return *cur; } + void* allocate(std::size_type sz, std::size_t alignment); +private: + char* memory; // char* instead of void* enables pointer arithmetic + char* free; + char* end; + Pool* prev; + static Pool* cur; + + // prohibit copying + Pool(Pool const&); // not implemented + Pool& operator=(Pool const&); // not implemented +}; + +Pool* pool::cur = 0; + +Pool::Pool(std::size_type size): + memory(static_cast(::operator new(size))), + free(memory), + end(memory)) +{ + prev = cur; + cur = this; +} + +Pool::~Pool() +{ + ::operator delete(memory); + cur = prev; +} + +void* Pool::allocate(std::size_t size, std::size_t alignment) +{ + char* start = free; + + // align the pointer + std::size_t extra = (start - memory) % aligment; + if (extra != 0) + { + extra = alignment - extra; + } + + // test if we can still allocate that much memory + if (end - free < size + extra) + throw std::bad_alloc(); + + // the free memory now starts after the newly allocated object + free = start + size + extra; + return start; +} + +// this is just a simple C-like struct, except that it uses a specific allocation/deallocation function. +struct X +{ + int member; + void* operator new(std::size_t); + void operator delete(void*) {} // don't deallocate memory for single objects +}; + +void* X::operator new(std::size_t size) +{ + // unfortunately C++ doesn't offer a portable way to find out alignment + // however, using the size as alignment is always safe (although usually wasteful) + return Pool::current().allocate(size, size); +} + +// Example program +int main() +{ + Pool my_pool(3*sizeof(X)); + X* p1 = new X; // uses the allocator function defined above + X* p2 = new X; + X* p3 = new X; + delete p3; // doesn't really deallocate the memory because operator delete has an empty body + + try + { + X* p4 = new X; // should fail + assert(false); + } + catch(...) + { + } + + X* p5 = new X[10]; // uses global array allocation routine because we didn't provide operator new[] and operator delete[] + delete[] p5; // global array deallocation + + Pool* my_second_pool(1000); // a large pool + X* p6 = new X; // allocate a new object from that pool + X* p7 = new X; + delete my_second_pool // also deallocates the memory for p6 and p7 + +} // Here my_pool goes out of scope, deallocating the memory for p1, p2 and p3 diff --git a/Task/Arithmetic-Complex/C++/arithmetic-complex.cpp b/Task/Arithmetic-Complex/C++/arithmetic-complex.cpp new file mode 100644 index 0000000000..6d37a1e68f --- /dev/null +++ b/Task/Arithmetic-Complex/C++/arithmetic-complex.cpp @@ -0,0 +1,19 @@ +#include +#include +using std::complex; + +void complex_operations() { + complex a(1.0, 1.0); + complex b(3.14159, 1.25); + + // addition + std::cout << a + b << std::endl; + // multiplication + std::cout << a * b << std::endl; + // inversion + std::cout << 1.0 / a << std::endl; + // negation + std::cout << -a << std::endl; + // conjugate + std::cout << std::conj(a) << std::endl; +} diff --git a/Task/Arithmetic-Complex/C-sharp/arithmetic-complex-1.cs b/Task/Arithmetic-Complex/C-sharp/arithmetic-complex-1.cs new file mode 100644 index 0000000000..97147b6c4c --- /dev/null +++ b/Task/Arithmetic-Complex/C-sharp/arithmetic-complex-1.cs @@ -0,0 +1,17 @@ +namespace RosettaCode.Arithmetic.Complex +{ + using System; + using System.Numerics; + + internal static class Program + { + private static void Main() + { + var number = Complex.ImaginaryOne; + foreach (var result in new[] { number + number, number * number, -number, 1 / number, Complex.Conjugate(number) }) + { + Console.WriteLine(result); + } + } + } +} diff --git a/Task/Arithmetic-Complex/C-sharp/arithmetic-complex-2.cs b/Task/Arithmetic-Complex/C-sharp/arithmetic-complex-2.cs new file mode 100644 index 0000000000..487a6f93ec --- /dev/null +++ b/Task/Arithmetic-Complex/C-sharp/arithmetic-complex-2.cs @@ -0,0 +1,205 @@ +using System; + +public struct ComplexNumber +{ + public static readonly ComplexNumber i = new ComplexNumber(0.0, 1.0); + public static readonly ComplexNumber Zero = new ComplexNumber(0.0, 0.0); + + public double Re; + public double Im; + + public ComplexNumber(double re) + { + this.Re = re; + this.Im = 0; + } + + public ComplexNumber(double re, double im) + { + this.Re = re; + this.Im = im; + } + + public static ComplexNumber operator *(ComplexNumber n1, ComplexNumber n2) + { + return new ComplexNumber(n1.Re * n2.Re - n1.Im * n2.Im, + n1.Im * n2.Re + n1.Re * n2.Im); + } + + public static ComplexNumber operator *(double n1, ComplexNumber n2) + { + return new ComplexNumber(n1 * n2.Re, n1 * n2.Im); + } + + public static ComplexNumber operator /(ComplexNumber n1, ComplexNumber n2) + { + double n2Norm = n2.Re * n2.Re + n2.Im * n2.Im; + return new ComplexNumber((n1.Re * n2.Re + n1.Im * n2.Im) / n2Norm, + (n1.Im * n2.Re - n1.Re * n2.Im) / n2Norm); + } + + public static ComplexNumber operator /(ComplexNumber n1, double n2) + { + return new ComplexNumber(n1.Re / n2, n1.Im / n2); + } + + public static ComplexNumber operator +(ComplexNumber n1, ComplexNumber n2) + { + return new ComplexNumber(n1.Re + n2.Re, n1.Im + n2.Im); + } + + public static ComplexNumber operator -(ComplexNumber n1, ComplexNumber n2) + { + return new ComplexNumber(n1.Re - n2.Re, n1.Im - n2.Im); + } + + public static ComplexNumber operator -(ComplexNumber n) + { + return new ComplexNumber(-n.Re, -n.Im); + } + + public static implicit operator ComplexNumber(double n) + { + return new ComplexNumber(n, 0.0); + } + + public static explicit operator double(ComplexNumber n) + { + return n.Re; + } + + public static bool operator ==(ComplexNumber n1, ComplexNumber n2) + { + return n1.Re == n2.Re && n1.Im == n2.Im; + } + + public static bool operator !=(ComplexNumber n1, ComplexNumber n2) + { + return n1.Re != n2.Re || n1.Im != n2.Im; + } + + public override bool Equals(object obj) + { + return this == (ComplexNumber)obj; + } + + public override int GetHashCode() + { + return Re.GetHashCode() ^ Im.GetHashCode(); + } + + public override string ToString() + { + return String.Format("{0}+{1}*i", Re, Im); + } +} + +public static class ComplexMath +{ + public static double Abs(ComplexNumber a) + { + return Math.Sqrt(Norm(a)); + } + + public static double Norm(ComplexNumber a) + { + return a.Re * a.Re + a.Im * a.Im; + } + + public static double Arg(ComplexNumber a) + { + return Math.Atan2(a.Im, a.Re); + } + + public static ComplexNumber Inverse(ComplexNumber a) + { + double norm = Norm(a); + return new ComplexNumber(a.Re / norm, -a.Im / norm); + } + + public static ComplexNumber Conjugate(ComplexNumber a) + { + return new ComplexNumber(a.Re, -a.Im); + + } + + public static ComplexNumber Exp(ComplexNumber a) + { + double e = Math.Exp(a.Re); + return new ComplexNumber(e * Math.Cos(a.Im), e * Math.Sin(a.Im)); + } + + public static ComplexNumber Log(ComplexNumber a) + { + + return new ComplexNumber(0.5 * Math.Log(Norm(a)), Arg(a)); + } + + public static ComplexNumber Power(ComplexNumber a, ComplexNumber power) + { + return Exp(power * Log(a)); + } + + public static ComplexNumber Power(ComplexNumber a, int power) + { + bool inverse = false; + if (power < 0) + { + inverse = true; power = -power; + } + + ComplexNumber result = 1.0; + ComplexNumber multiplier = a; + while (power > 0) + { + if ((power & 1) != 0) result *= multiplier; + multiplier *= multiplier; + power >>= 1; + } + + if (inverse) + return Inverse(result); + else + return result; + } + + public static ComplexNumber Sqrt(ComplexNumber a) + { + return Exp(0.5 * Log(a)); + } + + public static ComplexNumber Sin(ComplexNumber a) + { + return Sinh(ComplexNumber.i * a) / ComplexNumber.i; + } + + public static ComplexNumber Cos(ComplexNumber a) + { + return Cosh(ComplexNumber.i * a); + } + + public static ComplexNumber Sinh(ComplexNumber a) + { + return 0.5 * (Exp(a) - Exp(-a)); + } + + public static ComplexNumber Cosh(ComplexNumber a) + { + return 0.5 * (Exp(a) + Exp(-a)); + } + +} + +class Program +{ + static void Main(string[] args) + { + // usage + ComplexNumber i = 2; + ComplexNumber j = new ComplexNumber(1, -2); + Console.WriteLine(i * j); + Console.WriteLine(ComplexMath.Power(j, 2)); + Console.WriteLine((double)ComplexMath.Sin(i) + " vs " + Math.Sin(2)); + Console.WriteLine(ComplexMath.Power(j, 0) == 1.0); + } +} diff --git a/Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-1.lisp b/Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-1.lisp new file mode 100644 index 0000000000..e6aa8cb1c6 --- /dev/null +++ b/Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-1.lisp @@ -0,0 +1,5 @@ +> (sqrt -1) +#C(0.0 1.0) + +> (expt #c(0 1) 2) +-1 diff --git a/Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-2.lisp b/Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-2.lisp new file mode 100644 index 0000000000..6e82b7a220 --- /dev/null +++ b/Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-2.lisp @@ -0,0 +1,17 @@ +> (+ #c(0 1) #c(1 0)) +#C(1 1) + +> (* #c(1 1) 2) +#C(2 2) + +> (* #c(1 1) #c(0 2)) +#C(-2 2) + +> (- #c(1 1)) +#C(-1 -1) + +> (/ #c(0 2)) +#C(0 -1/2) + +> (conjugate #c(1 1)) +#C(1 -1) diff --git a/Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-3.lisp b/Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-3.lisp new file mode 100644 index 0000000000..19f24fef1f --- /dev/null +++ b/Task/Arithmetic-Complex/Common-Lisp/arithmetic-complex-3.lisp @@ -0,0 +1,8 @@ +> (complex 64 (/ 3 4)) +#C(64 3/4) + +> (realpart #c(5 5)) +5 + +> (imagpart (complex 0 pi)) +3.141592653589793d0 diff --git a/Task/Arithmetic-Complex/D/arithmetic-complex.d b/Task/Arithmetic-Complex/D/arithmetic-complex.d new file mode 100644 index 0000000000..1dc6c09501 --- /dev/null +++ b/Task/Arithmetic-Complex/D/arithmetic-complex.d @@ -0,0 +1,11 @@ +import std.stdio, std.complex; + +void main() { + auto x = complex(1, 1); // complex of doubles on default + auto y = complex(3.14159, 1.2); + + writeln(x + y); // addition + writeln(x * y); // multiplication + writeln(1.0 / x); // inversion + writeln(-x); // negation +} diff --git a/Task/Arithmetic-Complex/Euler-Math-Toolbox/arithmetic-complex.euler b/Task/Arithmetic-Complex/Euler-Math-Toolbox/arithmetic-complex.euler new file mode 100644 index 0000000000..6cabdf4e7b --- /dev/null +++ b/Task/Arithmetic-Complex/Euler-Math-Toolbox/arithmetic-complex.euler @@ -0,0 +1,13 @@ +>a=1+4i; b=5-3i; +>a+b + 6+1i +>a-b + -4+7i +>a*b + 17+17i +>a/b + -0.205882352941+0.676470588235i +>fraction a/b + -7/34+23/34i +>conj(a) + 1-4i diff --git a/Task/Arithmetic-Complex/Euphoria/arithmetic-complex.euphoria b/Task/Arithmetic-Complex/Euphoria/arithmetic-complex.euphoria new file mode 100644 index 0000000000..882f7dc34d --- /dev/null +++ b/Task/Arithmetic-Complex/Euphoria/arithmetic-complex.euphoria @@ -0,0 +1,58 @@ +constant REAL = 1, IMAG = 2 +type complex(sequence s) + return length(s) = 2 and atom(s[REAL]) and atom(s[IMAG]) +end type + +function add(complex a, complex b) + return a + b +end function + +function mult(complex a, complex b) + return {a[REAL] * b[REAL] - a[IMAG] * b[IMAG], + a[REAL] * b[IMAG] + a[IMAG] * b[REAL]} +end function + +function inv(complex a) + atom denom + denom = a[REAL] * a[REAL] + a[IMAG] * a[IMAG] + return {a[REAL] / denom, -a[IMAG] / denom} +end function + +function neg(complex a) + return -a +end function + +function scomplex(complex a) + sequence s + if a[REAL] != 0 then + s = sprintf("%g",a) + else + s = {} + end if + + if a[IMAG] != 0 then + if a[IMAG] = 1 then + s &= "+i" + elsif a[IMAG] = -1 then + s &= "-i" + else + s &= sprintf("%+gi",a[IMAG]) + end if + end if + + if length(s) = 0 then + return "0" + else + return s + end if +end function + +complex a, b +a = { 1.0, 1.0 } +b = { 3.14159, 1.2 } +printf(1,"a = %s\n",{scomplex(a)}) +printf(1,"b = %s\n",{scomplex(b)}) +printf(1,"a+b = %s\n",{scomplex(add(a,b))}) +printf(1,"a*b = %s\n",{scomplex(mult(a,b))}) +printf(1,"1/a = %s\n",{scomplex(inv(a))}) +printf(1,"-a = %s\n",{scomplex(neg(a))}) diff --git a/Task/Arithmetic-Integer/C++/arithmetic-integer.cpp b/Task/Arithmetic-Integer/C++/arithmetic-integer.cpp new file mode 100644 index 0000000000..3a3f49668a --- /dev/null +++ b/Task/Arithmetic-Integer/C++/arithmetic-integer.cpp @@ -0,0 +1,12 @@ +#include + +int main() +{ + int a, b; + std::cin >> a >> b; + std::cout << "a+b = " << a+b << "\n"; + std::cout << "a-b = " << a-b << "\n"; + std::cout << "a*b = " << a*b << "\n"; + std::cout << "a/b = " << a/b << ", remainder " << a%b << "\n"; + return 0; +} diff --git a/Task/Arithmetic-Integer/Chef/arithmetic-integer.chef b/Task/Arithmetic-Integer/Chef/arithmetic-integer.chef new file mode 100644 index 0000000000..de1acdec64 --- /dev/null +++ b/Task/Arithmetic-Integer/Chef/arithmetic-integer.chef @@ -0,0 +1,36 @@ +Number Soup. + +Only reads single values. + +Ingredients. +1 g Numbers +3 g Water +5 g Soup + +Method. +Take Numbers from refrigerator. +Take Soup from refrigerator. +Put Numbers into 1st mixing bowl. +Add Soup into the 1st mixing bowl. +Pour contents of the 1st mixing bowl into 1st baking dish. +Clean 1st mixing bowl. +Put Numbers into 1st mixing bowl. +Remove Soup from 1st mixing bowl. +Pour contents of the 1st mixing bowl into 2nd baking dish. +Clean 1st mixing bowl. +Put Numbers into 1st mixing bowl. +Combine Soup into 1st mixing bowl. +Pour contents of the 1st mixing bowl into 3rd baking dish. +Clean 1st mixing bowl. +Put Numbers into 1st mixing bowl. +Divide Soup into 1st mixing bowl. +Pour contents of the 1st mixing bowl into 4th baking dish. +Clean 1st mixing bowl. +Put Water into 1st mixing bowl. +Verb the Soup. +Combine Numbers into 1st mixing bowl. +Verb the Soup until verbed. +Pour contents of the 1st mixing bowl into 5th baking dish. +Clean 1st mixing bowl. + +Serves 5. diff --git a/Task/Arithmetic-Integer/Common-Lisp/arithmetic-integer.lisp b/Task/Arithmetic-Integer/Common-Lisp/arithmetic-integer.lisp new file mode 100644 index 0000000000..453bdcad75 --- /dev/null +++ b/Task/Arithmetic-Integer/Common-Lisp/arithmetic-integer.lisp @@ -0,0 +1,6 @@ +(defun arithmetic (&optional (a (read *query-io*)) (b (read *query-io*))) + (mapc + (lambda (op) + (format t "~a => ~a~%" (list op a b) (funcall (symbol-function op) a b))) + '(+ - * mod rem floor ceiling truncate round expt)) + (values)) diff --git a/Task/Arithmetic-Integer/D/arithmetic-integer-1.d b/Task/Arithmetic-Integer/D/arithmetic-integer-1.d new file mode 100644 index 0000000000..9a6af238ba --- /dev/null +++ b/Task/Arithmetic-Integer/D/arithmetic-integer-1.d @@ -0,0 +1,17 @@ +import std.stdio, std.string, std.conv; + +void main() { + int a = 10, b = 20; + try { + a = readln().strip().to!int(); + b = readln().strip().to!int(); + } catch (StdioException e) {} + writeln("a = ", a, ", b = ", b); + + writeln("a + b = ", a + b); + writeln("a - b = ", a - b); + writeln("a * b = ", a * b); + writeln("a / b = ", a / b); + writeln("a % b = ", a % b); + writeln("a ^^ b = ", a ^^ b); +} diff --git a/Task/Arithmetic-Integer/D/arithmetic-integer-2.d b/Task/Arithmetic-Integer/D/arithmetic-integer-2.d new file mode 100644 index 0000000000..a2615445c4 --- /dev/null +++ b/Task/Arithmetic-Integer/D/arithmetic-integer-2.d @@ -0,0 +1,13 @@ +import std.stdio, std.string, std.conv, std.typetuple; + +void main() { + int a = -16, b = 5; + try { + a = readln().strip().to!int(); + b = readln().strip().to!int(); + } catch (StdioException e) {} + writeln("a = ", a, ", b = ", b); + + foreach (op; TypeTuple!("+", "-", "*", "/", "%", "^^")) + mixin(`writeln("a ` ~ op ~ ` b = ", a` ~ op ~ `b);`); +} diff --git a/Task/Arithmetic-Integer/DWScript/arithmetic-integer.dwscript b/Task/Arithmetic-Integer/DWScript/arithmetic-integer.dwscript new file mode 100644 index 0000000000..1bc4a99751 --- /dev/null +++ b/Task/Arithmetic-Integer/DWScript/arithmetic-integer.dwscript @@ -0,0 +1,9 @@ +var a := StrToInt(ParamStr(0)); +var b := StrToInt(ParamStr(1)); + +PrintLn(Format('%d + %d = %d', [a, b, a + b])); +PrintLn(Format('%d - %d = %d', [a, b, a - b])); +PrintLn(Format('%d * %d = %d', [a, b, a * b])); +PrintLn(Format('%d / %d = %d', [a, b, a div b])); +PrintLn(Format('%d mod %d = %d', [a, b, a mod b])); +PrintLn(Format('%d ^ %d = %d', [a, b, Trunc(Power(a, b))])); diff --git a/Task/Arithmetic-Integer/Delphi/arithmetic-integer.delphi b/Task/Arithmetic-Integer/Delphi/arithmetic-integer.delphi new file mode 100644 index 0000000000..fb49e23bb0 --- /dev/null +++ b/Task/Arithmetic-Integer/Delphi/arithmetic-integer.delphi @@ -0,0 +1,19 @@ +program IntegerArithmetic; + +{$APPTYPE CONSOLE} + +uses SysUtils, Math; + +var + a, b: Integer; +begin + a := StrToInt(ParamStr(1)); + b := StrToInt(ParamStr(2)); + + WriteLn(Format('%d + %d = %d', [a, b, a + b])); + WriteLn(Format('%d - %d = %d', [a, b, a - b])); + WriteLn(Format('%d * %d = %d', [a, b, a * b])); + WriteLn(Format('%d / %d = %d', [a, b, a div b])); // rounds towards 0 + WriteLn(Format('%d %% %d = %d', [a, b, a mod b])); // matches sign of the first operand + WriteLn(Format('%d ^ %d = %d', [a, b, Trunc(Power(a, b))])); +end. diff --git a/Task/Arithmetic-Integer/E/arithmetic-integer.e b/Task/Arithmetic-Integer/E/arithmetic-integer.e new file mode 100644 index 0000000000..d33ab07fe7 --- /dev/null +++ b/Task/Arithmetic-Integer/E/arithmetic-integer.e @@ -0,0 +1,8 @@ +def arithmetic(a :int, b :int) { + return `$\ + Sum: ${a + b} + Difference: ${a - b} + Product: ${a * b} + Quotient: ${a // b} + Remainder: ${a % b}$\n` +} diff --git a/Task/Arithmetic-Integer/Efene/arithmetic-integer.efene b/Task/Arithmetic-Integer/Efene/arithmetic-integer.efene new file mode 100644 index 0000000000..039e8a652e --- /dev/null +++ b/Task/Arithmetic-Integer/Efene/arithmetic-integer.efene @@ -0,0 +1,15 @@ +@public +run = fn () { + + First = io.get_line("First number: ") + Second = io.get_line("Second number: ") + + A = list_to_integer(lists.delete($\n, First)) + B = list_to_integer(lists.delete($\n, Second)) + + io.format("Sum: ~p~n", [A + B]) + io.format("Difference: ~p~n", [A - B]) + io.format("Product: ~p~n", [A * B]) + io.format("Quotient: ~p~n", [A / B]) + io.format("Remainder: ~p~n", [A % B]) +} diff --git a/Task/Arithmetic-Integer/Elena/arithmetic-integer.elena b/Task/Arithmetic-Integer/Elena/arithmetic-integer.elena new file mode 100644 index 0000000000..78c9fbf12f --- /dev/null +++ b/Task/Arithmetic-Integer/Elena/arithmetic-integer.elena @@ -0,0 +1,14 @@ +#define std'basic'*. +#define math'* = std'math'*. + +#symbol Program = +[ + #var a := 'program'input >> Integer. + #var b := 'program'input >> Integer. + + 'program'output << a << " + " << b << " = " << a + b << "%n". + 'program'output << a << " - " << b << " = " << a - b << "%n". + 'program'output << a << " * " << b << " = " << a * b << "%n". + 'program'output << a << " / " << b << " = " << a / b << "%n". // truncates towards 0 + 'program'output << a << " %% " << b << " = " << a~math'eops math'modulus:b << "%n". // matches sign of first operand +]. diff --git a/Task/Arithmetic-Integer/Euphoria/arithmetic-integer.euphoria b/Task/Arithmetic-Integer/Euphoria/arithmetic-integer.euphoria new file mode 100644 index 0000000000..7c21af953a --- /dev/null +++ b/Task/Arithmetic-Integer/Euphoria/arithmetic-integer.euphoria @@ -0,0 +1,13 @@ +include get.e + +integer a,b + +a = floor(prompt_number("a = ",{})) +b = floor(prompt_number("b = ",{})) + +printf(1,"a + b = %d\n", a+b) +printf(1,"a - b = %d\n", a-b) +printf(1,"a * b = %d\n", a*b) +printf(1,"a / b = %g\n", a/b) -- does not truncate +printf(1,"remainder(a,b) = %d\n", remainder(a,b)) -- same sign as first operand +printf(1,"power(a,b) = %g\n", power(a,b)) diff --git a/Task/Arithmetic-Rational/C++/arithmetic-rational.cpp b/Task/Arithmetic-Rational/C++/arithmetic-rational.cpp new file mode 100644 index 0000000000..c775071579 --- /dev/null +++ b/Task/Arithmetic-Rational/C++/arithmetic-rational.cpp @@ -0,0 +1,27 @@ +#include +#include "math.h" +#include "boost/rational.hpp" + +typedef boost::rational frac; + +bool is_perfect(int c) +{ + frac sum(1, c); + for (int f = 2;f < sqrt(static_cast(c)); ++f){ + + if (c % f == 0) sum += frac(1,f) + frac(1, c/f); + } + if (sum.denominator() == 1){ + return (sum == 1); + } + return false; +} + +int main() +{ + for (int candidate = 2; candidate < 0x80000; ++candidate){ + if (is_perfect(candidate)) + std::cout << candidate << " is perfect" << std::endl; + } + return 0; +} diff --git a/Task/Arithmetic-Rational/Common-Lisp/arithmetic-rational.lisp b/Task/Arithmetic-Rational/Common-Lisp/arithmetic-rational.lisp new file mode 100644 index 0000000000..e91f01dc5d --- /dev/null +++ b/Task/Arithmetic-Rational/Common-Lisp/arithmetic-rational.lisp @@ -0,0 +1,7 @@ +(loop for candidate from 2 below (expt 2 19) + for sum = (+ (/ candidate) + (loop for factor from 2 to (isqrt candidate) + when (zerop (mod candidate factor)) + sum (+ (/ factor) (/ (floor candidate factor))))) + when (= sum 1) + collect candidate) diff --git a/Task/Arithmetic-Rational/D/arithmetic-rational.d b/Task/Arithmetic-Rational/D/arithmetic-rational.d new file mode 100644 index 0000000000..c30a800580 --- /dev/null +++ b/Task/Arithmetic-Rational/D/arithmetic-rational.d @@ -0,0 +1,170 @@ +import std.bigint, std.traits, std.conv; + +T gcd(T)(/*in*/ T a, /*in*/ T b) /*pure nothrow*/ { + // std.numeric.gcd doesn't work with BigInt. + return (b != 0) ? gcd(b, a % b) : (a < 0) ? -a : a; +} + +T lcm(T)(/*in*/ T a, /*in*/ T b) { + return a / gcd(a, b) * b; +} + +struct RationalT(T) { + /*const*/ private T num, den; // Numerator & denominator. + + private enum Type { NegINF = -2, + NegDEN = -1, + NaRAT = 0, + NORMAL = 1, + PosINF = 2 }; + + this(U : RationalT)(U n) pure nothrow { + num = n.num; + den = n.den; + } + + this(U)(in U n) pure nothrow if (isIntegral!U) { + num = toT(n); + den = 1UL; + } + + this(U, V)(/*in*/ U n, /*in*/ V d) /*pure nothrow*/ { + num = toT(n); + den = toT(d); + /*const*/ T common = gcd(num, den); + if (common != 0) { + num /= common; + den /= common; + } else { // infinite or NOT a Number + num = (num == 0) ? 0 : (num < 0) ? -1 : 1; + den = 0; + } + if (den < 0) { // Assure den is non-negative. + num = -num; + den = -den; + } + } + + static T toT(U)(/*in*/ ref U n) pure nothrow if (is(U == T)) { + return n; + } + + static T toT(U)(in ref U n) pure nothrow if (!is(U == T)) { + T result = n; + return result; + } + + T nomerator() /*const*/ pure nothrow @property { + return num; + } + + T denominator() /*const*/ pure nothrow @property { + return den; + } + + string toString() /*const*/ { + if (den == 0) { + if (num == 0) + return "NaRat"; + else + return ((num < 0) ? "-" : "+") ~ "infRat"; + } + return text(num) ~ (den == 1 ? "" : ("/" ~ text(den))); + } + + RationalT opBinary(string op)(/*in*/ RationalT r) + /*const pure nothrow*/ if (op == "+" || op == "-") { + T common = lcm(den, r.den); + T n = mixin("common / den * num" ~ op ~ + "common / r.den * r.num" ); + return RationalT(n, common); + } + + RationalT opBinary(string op)(/*in*/ RationalT r) + /*const pure nothrow*/ if (op == "*") { + return RationalT(num * r.num, den * r.den); + } + + RationalT opBinary(string op)(/*in*/ RationalT r) + /*const pure nothrow*/ if (op == "/") { + return RationalT(num * r.den, den * r.num); + } + + RationalT opBinary(string op, U)(in U r) + /*const pure nothrow*/ if (isIntegral!U && (op == "+" || + op == "-" || op == "*" || op == "/")) { + return opBinary!op(RationalT(r)); + } + + RationalT opBinary(string op)(in size_t p) + /*const pure nothrow*/ if (op == "^^") { + return RationalT(num ^^ p, den ^^ p); + } + + RationalT opBinaryRight(string op, U)(in U l) + /*const pure nothrow*/ if (isIntegral!U) { + return RationalT(l).opBinary!op(RationalT(num, den)); + } + + RationalT opOpAssign(string op, U)(in U l) + /*const pure nothrow*/ { + mixin("this = this " ~ op ~ "l;"); + return this; + } + + RationalT opUnary(string op)() + /*const pure nothrow*/ if (op == "+" || op == "-") { + return RationalT(mixin(op ~ "num"), den); + } + + bool opCast(U)() const if (is(U == bool)) { + return num != 0; + } + + int opEquals(U)(/*in*/ U r) /*const pure nothrow*/ { + RationalT rhs = RationalT(r); + if (type() == Type.NaRAT || rhs.type() == Type.NaRAT) + return false; + return num == rhs.num && den == rhs.den; + } + + int opCmp(U)(/*in*/ U r) /*const pure nothrow*/ { + auto rhs = RationalT(r); + if (type() == Type.NaRAT || rhs.type() == Type.NaRAT) + throw new Exception("Compare involve a NaRAT."); + if (type() != Type.NORMAL || + rhs.type() != Type.NORMAL) // for infinite + return (type() == rhs.type()) ? 0 : + ((type() < rhs.type()) ? -1 : 1); + auto diff = num * rhs.den - den * rhs.num; + return (diff == 0) ? 0 : ((diff < 0) ? -1 : 1); + } + + Type type() /*const pure nothrow*/ { + if (den > 0) return Type.NORMAL; + if (den < 0) return Type.NegDEN; + if (num > 0) return Type.PosINF; + if (num < 0) return Type.NegINF; + return Type.NaRAT; + } +} + +alias Rational = RationalT!BigInt; + +version (arithmetic_rational_main) { // Test. + void main() { + import std.stdio, std.math; + alias RatL = RationalT!long; + + foreach (immutable p; 2 .. 2 ^^ 19) { + auto sum = RatL(1, p); + immutable limit = 1 + cast(uint)sqrt(cast(real)p); + foreach (immutable factor; 2 .. limit) + if (p % factor == 0) + sum += RatL(1, factor) + RatL(factor, p); + if (sum.denominator == 1) + writefln("Sum of recipr. factors of %6s = %s exactly%s", + p, sum, (sum == 1) ? ", perfect." : "."); + } + } +} diff --git a/Task/Arithmetic-Rational/Elisa/arithmetic-rational-1.elisa b/Task/Arithmetic-Rational/Elisa/arithmetic-rational-1.elisa new file mode 100644 index 0000000000..9a15a5201a --- /dev/null +++ b/Task/Arithmetic-Rational/Elisa/arithmetic-rational-1.elisa @@ -0,0 +1,61 @@ +component RationalNumbers; + type Rational; + Rational(Numerator = integer, Denominater = integer) -> Rational; + + Rational + Rational -> Rational; + Rational - Rational -> Rational; + Rational * Rational -> Rational; + Rational / Rational -> Rational; + + Rational == Rational -> boolean; + Rational <> Rational -> boolean; + Rational >= Rational -> boolean; + Rational <= Rational -> boolean; + Rational > Rational -> boolean; + Rational < Rational -> boolean; + + + Rational -> Rational; + - Rational -> Rational; + abs(Rational) -> Rational; + + Rational(integer) -> Rational; + Numerator(Rational) -> integer; + Denominator(Rational) -> integer; + begin + Rational(A,B) = Rational:[A;B]; + + R1 + R2 = Normalize( R1.A * R2.B + R1.B * R2.A, R1.B * R2.B); + R1 - R2 = Normalize( R1.A * R2.B - R1.B * R2.A, R1.B * R2.B); + R1 * R2 = Normalize( R1.A * R2.A, R1.B * R2.B); + R1 / R2 = Normalize( R1.A * R2.B, R1.B * R2.A); + + R1 == R2 = [ R = (R1 - R2); R.A == 0]; + R1 <> R2 = [ R = (R1 - R2); R.A <> 0]; + R1 >= R2 = [ R = (R1 - R2); R.A >= 0]; + R1 <= R2 = [ R = (R1 - R2); R.A <= 0]; + R1 > R2 = [ R = (R1 - R2); R.A > 0]; + R1 < R2 = [ R = (R1 - R2); R.A < 0]; + + + R = R; + - R = Rational(-R.A, R.B); + + abs(R) = Rational(abs(R.A), abs(R.B)); + Rational(I) = Rational (I, 1); + Numerator(R) = R.A; + Denominator(R) = R.B; + + << internal definitions >> + + Normalize (A = integer, B = integer) -> Rational; + Normalize (A, B) = [ exception( B == 0, "Illegal Rational Number"); + Common = GCD(abs(A), abs(B)); + if B < 0 then Rational(-A / Common, -B / Common) + else Rational( A / Common, B / Common) ]; + + GCD (A = integer, B = integer) -> integer; + GCD (A, B) = [ if A == 0 then return(B); + if B == 0 then return(A); + if A > B then GCD (B, mod(A,B)) + else GCD (A, mod(B,A)) ]; + +end component RationalNumbers; diff --git a/Task/Arithmetic-Rational/Elisa/arithmetic-rational-2.elisa b/Task/Arithmetic-Rational/Elisa/arithmetic-rational-2.elisa new file mode 100644 index 0000000000..9ea4ebbb56 --- /dev/null +++ b/Task/Arithmetic-Rational/Elisa/arithmetic-rational-2.elisa @@ -0,0 +1,14 @@ +use RationalNumbers; + +PerfectNumbers( Limit = integer) -> multi(integer); +PerfectNumbers( Limit) = + [ Candidate = 2 .. Limit; + Sum:= Rational(1,Candidate); + [ Divisor = 2 .. integer(sqrt(real(Candidate))); + if mod(Candidate, Divisor) == 0 then + Sum := Sum + Rational(1, Divisor) + Rational(Divisor, Candidate); + ]; + if Sum == Rational(1,1) then Candidate + ]; + +PerfectNumbers(10000)? diff --git a/Task/Arithmetic-evaluation/C++/arithmetic-evaluation.cpp b/Task/Arithmetic-evaluation/C++/arithmetic-evaluation.cpp new file mode 100644 index 0000000000..6293355eda --- /dev/null +++ b/Task/Arithmetic-evaluation/C++/arithmetic-evaluation.cpp @@ -0,0 +1,116 @@ + #include + #include + #include + #include + #include + #include + #include + + using boost::spirit::rule; + using boost::spirit::parser_tag; + using boost::spirit::ch_p; + using boost::spirit::real_p; + + using boost::spirit::tree_node; + using boost::spirit::node_val_data; + + // The grammar + struct parser: public boost::spirit::grammar + { + enum rule_ids { addsub_id, multdiv_id, value_id, real_id }; + + struct set_value + { + set_value(parser const& p): self(p) {} + void operator()(tree_node >& node, + std::string::iterator begin, + std::string::iterator end) const + { + node.value.value(self.tmp); + } + parser const& self; + }; + + mutable double tmp; + + template struct definition + { + rule > addsub; + rule > multdiv; + rule > value; + rule > real; + + definition(parser const& self) + { + using namespace boost::spirit; + addsub = multdiv + >> *((root_node_d[ch_p('+')] | root_node_d[ch_p('-')]) >> multdiv); + multdiv = value + >> *((root_node_d[ch_p('*')] | root_node_d[ch_p('/')]) >> value); + value = real | inner_node_d[('(' >> addsub >> ')')]; + real = leaf_node_d[access_node_d[real_p[assign_a(self.tmp)]][set_value(self)]]; + } + + rule > const& start() const + { + return addsub; + } + }; + }; + + template + double evaluate(TreeIter const& i) + { + double op1, op2; + switch (i->value.id().to_long()) + { + case parser::real_id: + return i->value.value(); + case parser::value_id: + case parser::addsub_id: + case parser::multdiv_id: + op1 = evaluate(i->children.begin()); + op2 = evaluate(i->children.begin()+1); + switch(*i->value.begin()) + { + case '+': + return op1 + op2; + case '-': + return op1 - op2; + case '*': + return op1 * op2; + case '/': + return op1 / op2; + default: + assert(!"Should not happen"); + } + default: + assert(!"Should not happen"); + } + return 0; + } + + // the read/eval/write loop + int main() + { + parser eval; + std::string line; + while (std::cout << "Expression: " + && std::getline(std::cin, line) + && !line.empty()) + { + typedef boost::spirit::node_val_data_factory factory_t; + boost::spirit::tree_parse_info info = + boost::spirit::ast_parse(line.begin(), line.end(), + eval, boost::spirit::space_p); + if (info.full) + { + std::cout << "Result: " << evaluate(info.trees.begin()) << std::endl; + } + else + { + std::cout << "Error in expression." << std::endl; + } + } + }; diff --git a/Task/Arithmetic-evaluation/Common-Lisp/arithmetic-evaluation.lisp b/Task/Arithmetic-evaluation/Common-Lisp/arithmetic-evaluation.lisp new file mode 100644 index 0000000000..a93c80a5fd --- /dev/null +++ b/Task/Arithmetic-evaluation/Common-Lisp/arithmetic-evaluation.lisp @@ -0,0 +1,86 @@ +(defun tokenize-stream (stream) + (labels ((whitespace-p (char) + (find char #(#\space #\newline #\return #\tab))) + (consume-whitespace () + (loop while (whitespace-p (peek-char nil stream nil #\a)) + do (read-char stream))) + (read-integer () + (loop while (digit-char-p (peek-char nil stream nil #\space)) + collect (read-char stream) into digits + finally (return (parse-integer (coerce digits 'string)))))) + (consume-whitespace) + (let ((c (peek-char nil stream nil nil))) + (let ((token (case c + ((nil) nil) + ((#\() :lparen) + ((#\)) :rparen) + ((#\*) '*) + ((#\/) '/) + ((#\+) '+) + ((#\-) '-) + (otherwise + (unless (digit-char-p c) + (cerror "Skip it." "Unexpected character ~w." c) + (read-char stream) + (return-from tokenize-stream + (tokenize-stream stream))) + (read-integer))))) + (unless (or (null token) (integerp token)) + (read-char stream)) + token)))) + +(defun group-parentheses (tokens &optional (delimited nil)) + (do ((new-tokens '())) + ((endp tokens) + (when delimited + (cerror "Insert it." "Expected right parenthesis.")) + (values (nreverse new-tokens) '())) + (let ((token (pop tokens))) + (case token + ((:lparen) + (multiple-value-bind (group remaining-tokens) + (group-parentheses tokens t) + (setf new-tokens (cons group new-tokens) + tokens remaining-tokens))) + ((:rparen) + (if (not delimited) + (cerror "Ignore it." "Unexpected right parenthesis.") + (return (values (nreverse new-tokens) tokens)))) + (otherwise + (push token new-tokens)))))) + +(defun group-operations (expression) + (flet ((gop (exp) (group-operations exp))) + (if (integerp expression) + expression + (destructuring-bind (a &optional op1 b op2 c &rest others) + expression + (unless (member op1 '(+ - * / nil)) + (error "syntax error: in expr ~a expecting operator, not ~a" + expression op1)) + (unless (member op2 '(+ - * / nil)) + (error "syntax error: in expr ~a expecting operator, not ~a" + expression op2)) + (cond + ((not op1) (gop a)) + ((not op2) `(,(gop a) ,op1 ,(gop b))) + (t (let ((a (gop a)) (b (gop b)) (c (gop c))) + (if (and (member op1 '(+ -)) (member op2 '(* /))) + (gop `(,a ,op1 (,b ,op2 ,c) ,@others)) + (gop `((,a ,op1 ,b) ,op2 ,c ,@others)))))))))) + +(defun infix-to-prefix (expression) + (if (integerp expression) + expression + (destructuring-bind (a op b) expression + `(,op ,(infix-to-prefix a) ,(infix-to-prefix b))))) + +(defun evaluate (string) + (with-input-from-string (in string) + (eval + (infix-to-prefix + (group-operations + (group-parentheses + (loop for token = (tokenize-stream in) + until (null token) + collect token))))))) diff --git a/Task/Arithmetic-evaluation/D/arithmetic-evaluation.d b/Task/Arithmetic-evaluation/D/arithmetic-evaluation.d new file mode 100644 index 0000000000..a25df41e50 --- /dev/null +++ b/Task/Arithmetic-evaluation/D/arithmetic-evaluation.d @@ -0,0 +1,219 @@ +import std.stdio, std.string, std.ascii, std.conv, std.array, + std.exception, std.traits; + +struct Stack(T) { + T[] data; + alias data this; + void push(T top) pure nothrow { data ~= top; } + + T pop(bool discard = true)() pure { + if (data.empty) + throw new Exception("Stack Empty"); + auto top = data.back; + static if (discard) + data.popBack(); + return top; + } +} + +enum Type { Num, OBkt, CBkt, Add, Sub, Mul, Div } +immutable opChar = ["#", "(", ")", "+", "-", "*", "/"]; +immutable opPrec = [ 0, -9, -9, 1, 1, 2, 2]; + +abstract class Visitor { void visit(XP e); } + +final class XP { + immutable Type type; + immutable string str; + immutable int pos; // Optional, to dispaly AST struct. + XP LHS, RHS; + + this(string s=")", int p = -1) nothrow { + str = s; + pos = p; + type = Type.Num; + foreach_reverse (immutable t; [EnumMembers!Type[1 .. $]]) + if (opChar[t] == s) + type = t; + } + + override int opCmp(Object other) pure { + auto rhs = cast(XP)other; + enforce(rhs !is null); + return opPrec[type] - opPrec[rhs.type]; + } + + void accept(Visitor v) { v.visit(this); } +} + +final class AST { + XP root; + Stack!XP opr, num; + string xpr, token; + int xpHead, xpTail; + + void joinXP(XP x) pure { + x.RHS = num.pop(); + x.LHS = num.pop(); + num.push(x); + } + + string nextToken() pure { + while (xpHead < xpr.length && xpr[xpHead] == ' ') + xpHead++; // Skip spc. + xpTail = xpHead; + if (xpHead < xpr.length) { + token = xpr[xpTail .. xpTail + 1]; + switch (token) { + case "(", ")", "+", "-", "*", "/": // Valid non-number. + xpTail++; + return token; + default: // Should be number. + if (token[0].isDigit()) { + while (xpTail < xpr.length && xpr[xpTail].isDigit()) + xpTail++; + return xpr[xpHead .. xpTail]; + } // Else may be error. + } // End switch. + } + if (xpTail < xpr.length) + throw new Exception("Invalid Char <" ~ xpr[xpTail] ~ ">"); + return null; + } // End nextToken. + + AST parse(in string s) { + bool expectingOP; + xpr = s; + try { + xpHead = xpTail = 0; + num = opr = null; + root = null; + opr.push(new XP); // CBkt, prevent evaluate null OP precedence. + while ((token = nextToken()) !is null) { + XP tokenXP = new XP(token, xpHead); + if (expectingOP) { // Process OP-alike XP. + switch (token) { + case ")": + while (opr.pop!false().type != Type.OBkt) + joinXP(opr.pop()); + opr.pop(); + expectingOP = true; + break; + case "+", "-", "*", "/": + while (tokenXP <= opr.pop!false()) + joinXP(opr.pop()); + opr.push(tokenXP); + expectingOP = false; + break; + default: + throw new Exception("Expecting Operator or ), not <" + ~ token ~ ">"); + } + } else { // Process Num-alike XP. + switch (token) { + case "+", "-", "*", "/", ")": + throw new Exception("Expecting Number or (, not <" + ~ token ~ ">"); + case "(": + opr.push(tokenXP); + expectingOP = false; + break; + default: // Number. + num.push(tokenXP); + expectingOP = true; + } + } + xpHead = xpTail; + } // End while. + + while (opr.length > 1) // Join pending Op. + joinXP(opr.pop()); + } catch(Exception e) { + writefln("%s\n%s\n%s^", e.msg, xpr, " ".replicate(xpHead)); + root = null; + return this; + } + + if (num.length != 1) { // Should be one XP left. + writefln("Parse Error..."); + root = null; + } else { + root = num.pop(); + } + return this; + } // End Parse. +} // End class AST. + +// To display AST fancy struct. +void ins(ref char[][] s, in string v, in int p, in int l) +pure nothrow { + if (l + 1 > s.length) + s.length++; + while (s[l].length < p + v.length + 1) + s[l] ~= " "; + s[l][p .. p + v.length] = v; +} + +final class CalcVis : Visitor { + int result, level; + string resultStr; + char[][] Tree; + + static void opCall(AST a) { + if (a && a.root) { + auto c = new CalcVis; + a.root.accept(c); + foreach (immutable i; 1 .. c.Tree.length) { // More fancy. + bool flipflop = false; + enum char mk = '.'; + foreach (immutable j; 0 .. c.Tree[i].length) { + while (j >= c.Tree[i - 1].length) + c.Tree[i - 1] ~= " "; + immutable c1 = c.Tree[i][j]; + immutable c2 = c.Tree[i - 1][j]; + if (flipflop && (c1 == ' ') && c2 == ' ') + c.Tree[i - 1][j] = mk; + if (c1 != mk && c1 != ' ' && + (j == 0 || !isDigit(c.Tree[i][j - 1]))) + flipflop = !flipflop; + } + } + foreach (const t; c.Tree) + writefln(t); + writefln("\n%s ==>\n%s = %s", a.xpr, c.resultStr, c.result); + } else + writefln("Evalute invalid or null Expression."); + } + + // Calc. the value, display AST struct and eval order. + override void visit(XP xp) { + ins(Tree, xp.str, xp.pos, level); + level++; + if (xp.type == Type.Num) { + resultStr ~= xp.str; + result = to!int(xp.str); + } else { + resultStr ~= "("; + xp.LHS.accept(this); + immutable int lhs = result; + resultStr ~= opChar[xp.type]; + xp.RHS.accept(this); + resultStr ~= ")"; + switch (xp.type) { + case Type.Add: result = lhs + result; break; + case Type.Sub: result = lhs - result; break; + case Type.Mul: result = lhs * result; break; + case Type.Div: result = lhs / result; break; + default: throw new Exception("Invalid type"); + } + } + level--; + } +} + +void main(string[] args) { + immutable exp0 = "1 + 2*(3 - 2*(3 - 2)*((2 - 4)*5" ~ + " - 22/(7 + 2*(3 - 1)) - 1)) + 1"; + immutable exp = args.length > 1 ? args[1 .. $].join(" ") : exp0; + (new AST).parse(exp).CalcVis(); // Should be 60. +} diff --git a/Task/Arithmetic-evaluation/E/arithmetic-evaluation-1.e b/Task/Arithmetic-evaluation/E/arithmetic-evaluation-1.e new file mode 100644 index 0000000000..7ac8889e94 --- /dev/null +++ b/Task/Arithmetic-evaluation/E/arithmetic-evaluation-1.e @@ -0,0 +1,18 @@ +def eParser := +def LiteralExpr := .asType() +def arithEvaluate(expr :String) { + def ast := eParser(expr) + + def evalAST(ast) { + return switch (ast) { + match e`@a + @b` { evalAST(a) + evalAST(b) } + match e`@a - @b` { evalAST(a) - evalAST(b) } + match e`@a * @b` { evalAST(a) * evalAST(b) } + match e`@a / @b` { evalAST(a) / evalAST(b) } + match e`-@a` { -(evalAST(a)) } + match l :LiteralExpr { l.getValue() } + } + } + + return evalAST(ast) +} diff --git a/Task/Arithmetic-evaluation/E/arithmetic-evaluation-2.e b/Task/Arithmetic-evaluation/E/arithmetic-evaluation-2.e new file mode 100644 index 0000000000..759c022e0d --- /dev/null +++ b/Task/Arithmetic-evaluation/E/arithmetic-evaluation-2.e @@ -0,0 +1,8 @@ +? arithEvaluate("1 + 2") +# value: 3 + +? arithEvaluate("(1 + 2) * 10 / 100") +# value: 0.3 + +? arithEvaluate("(1 + 2 / 2) * (5 + 5)") +# value: 20.0 diff --git a/Task/Arithmetic-evaluation/Elena/arithmetic-evaluation-1.elena b/Task/Arithmetic-evaluation/Elena/arithmetic-evaluation-1.elena new file mode 100644 index 0000000000..477ce675b5 --- /dev/null +++ b/Task/Arithmetic-evaluation/Elena/arithmetic-evaluation-1.elena @@ -0,0 +1,285 @@ +#define std'dictionary'*. +#define std'basic'*. +#define std'patterns'*. +#define ext'io'*. +#define ext'convertors'*. + +#subject parse_order. + +#class Token +{ + #field theValue. + + #initializer + [ + theValue := String. + ] + + #method parse_order'get = 0. + + #method += aChar + [ + theValue += aChar. + ] + + #method + aNode + [ + ^ aNode += self. + ] + + #method numeric = Real64Value &&literal:theValue &:erealformatter. +} + + +#class Node +{ + #field theLeft. + #field theRight. + + #role LeftAssigned + { + #method += aNode + [ + theRight := aNode. + + #shift. + ] + } + #role Empty + { + #method += aNode + [ + theLeft := aNode. + + #shift LeftAssigned. + ] + } + #initializer + [ + #shift Empty. + ] + + #method + aNode + [ + #if (self parse_order > aNode parse_order)? + [ + self += aNode. + ] + | [ + aNode += self. + + ^ aNode. + ]. + ] + + #method += aNode + [ + #if (theRight parse_order > aNode parse_order)? + [ + theRight += aNode. + ] + | [ + theRight := aNode += theRight. + ]. + ] +} + +#class SummaryNode (Node) +{ + #method parse_order'get = 2. + + #method numeric = theLeft numeric + theRight numeric. +} +#class DifferenceNode (Node) +{ + #method parse_order'get = 2. + + #method numeric = theLeft numeric - theRight numeric. +} +#class ProductNode (Node) +{ + #method parse_order'get = 1. + + #method numeric = theLeft numeric * theRight numeric. +} +#class FractionNode (Node) +{ + #method parse_order'get = 1. + + #method numeric = theLeft numeric / theRight numeric. +} +#class SubExpression +{ + #field theParser. + #field theCounter. + + #role EOF + { + #method available'is [ control fail. ] + + #method += aChar [ $self fail. ] + } + + #initializer + [ + theParser := arithmeval'Parser. + theCounter := Integer << 1. + ] + + #method available'is [] + + #method parse_order'get = 0. + + #method + aNode + [ + ^ aNode += self. + ] + + #method append : aChar + [ + #if control if:(aChar == 41) + [ + theCounter -= 1. + ] + | if:(aChar == 40) + [ + theCounter += 1. + ]. + + #if (theCounter == 0)? + [ #shift EOF. ^ $self. ]. + + theParser evaluate:aChar. + ] + + #method numeric = theParser numeric. +} +#class Parser +{ + #field theToken. + #field theTopNode. + + #role Brackets + { + #method evaluate : aChar + [ + theToken += aChar. + + #if theToken available'is + | [ + #shift. + ]. + ] + } + #role Start + { + #method evaluate : aChar + [ + #if (40 == aChar)? + [ + theToken := SubExpression. + theTopNode := theToken. + + #shift Brackets. + ] + | [ + theToken := Token. + theTopNode := theToken. + + theToken += aChar. + + #shift. + ]. + ] + } + #role Operator + { + #method evaluate : aChar + [ + #if Control if:(48 < aChar) if:(58 > aChar) + [ + theToken := (Token += aChar). + + theTopNode += theToken. + + #shift. + ] + | if:(40 == aChar) + [ + theToken := SubExpression. + theTopNode += theToken. + + #shift Brackets. + ] + | [ $self fail. ]. + ] + } + + #initializer + [ + #shift Start. + ] + + #method numeric = theTopNode numeric. + + #method evaluate : aChar + [ + #if Control if:(48 < aChar) if:(58 > aChar) + [ + theToken += aChar. + ] + | if:(42 == aChar) // * + [ + theTopNode := theTopNode + ProductNode. + + #shift Operator. + ] + | if:(47 == aChar) // / + [ + theTopNode := theTopNode + FractionNode. + + #shift Operator. + ] + | if:(43 == aChar) // + + [ + theTopNode := theTopNode + SummaryNode. + + #shift Operator. + ] + | if:(45 == aChar) // - + [ + theTopNode := theTopNode + DifferenceNode. + + #shift Operator. + ] + | if:(40 == aChar) + [ + theToken := SubExpression. + theTopNode := theToken. + + #shift Brackets. + ] + | [ $self fail. ]. + ] + + #method start : aProcess + [ + aProcess run:self. + + ^ self numeric. + ] +} + +#symbol Program = +[ + #var aText := String. + + #while ((Console >> aText) length > 0)? + [ + #var aParser := Parser. + + Console << "=" << aParser start:Scan::aText | ^^"Invalid Expression". + + Console << "%n". + ]. +]. diff --git a/Task/Arithmetic-evaluation/Elena/arithmetic-evaluation-2.elena b/Task/Arithmetic-evaluation/Elena/arithmetic-evaluation-2.elena new file mode 100644 index 0000000000..7302c4fe7b --- /dev/null +++ b/Task/Arithmetic-evaluation/Elena/arithmetic-evaluation-2.elena @@ -0,0 +1,30 @@ +number ::= $numeric; +numeric ::= "(" sub_expr; +numeric ::= number; +factor ::= number factor_r; +factor ::= "(" sub_expr; +sum ::= "+" factor ; +difference ::= "-" factor ; +multiply ::= "*" numeric; +divide ::= "/" numeric; +factor_r ::= multiply factor_r; +factor_r ::= divide factor_r; +factor_r ::= $eps; +expr_r ::= sum expr_r; +expr_r ::= difference expr_r; +expr_r ::= $eps; +neg_r ::= factor_r expr_r; +sub_expr ::= expression sub_expr_r; +sub_expr_r ::= ")" factor_r; +neg_expression ::= $numeric neg_r; +expression ::= factor expr_r; +expression ::= "-" neg_expression; +print ::= "?" expression; +start ::= print; +print => &nil 'program'output $body ^write; +multiply => $body ^multiply; +divide => $body ^divide; +sum => $body ^add; +difference => $body ^subtract; +neg_expression => 0 $terminal ^subtract $body; +number => $terminal $body; diff --git a/Task/Arithmetic-geometric-mean/C++/arithmetic-geometric-mean.cpp b/Task/Arithmetic-geometric-mean/C++/arithmetic-geometric-mean.cpp new file mode 100644 index 0000000000..6daecaa99e --- /dev/null +++ b/Task/Arithmetic-geometric-mean/C++/arithmetic-geometric-mean.cpp @@ -0,0 +1,34 @@ +/*Arithmetic Geometric Mean of 1 and 1/sqrt(2) + + Nigel_Galloway + February 7th., 2012. +*/ + +#include "gmp.h" + +void agm (const mpf_t in1, const mpf_t in2, mpf_t out1, mpf_t out2) { + mpf_add (out1, in1, in2); + mpf_div_ui (out1, out1, 2); + mpf_mul (out2, in1, in2); + mpf_sqrt (out2, out2); +} + +int main (void) { + mpf_set_default_prec (65568); + mpf_t x0, y0, resA, resB; + + mpf_init_set_ui (y0, 1); + mpf_init_set_d (x0, 0.5); + mpf_sqrt (x0, x0); + mpf_init (resA); + mpf_init (resB); + + for(int i=0; i<7; i++){ + agm(x0, y0, resA, resB); + agm(resA, resB, x0, y0); + } + gmp_printf ("%.20000Ff\n", x0); + gmp_printf ("%.20000Ff\n\n", y0); + + return 0; +} diff --git a/Task/Arithmetic-geometric-mean/C-sharp/arithmetic-geometric-mean.cs b/Task/Arithmetic-geometric-mean/C-sharp/arithmetic-geometric-mean.cs new file mode 100644 index 0000000000..30a524f013 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/C-sharp/arithmetic-geometric-mean.cs @@ -0,0 +1,78 @@ +namespace RosettaCode.ArithmeticGeometricMean +{ + using System; + using System.Collections.Generic; + using System.Globalization; + + internal static class Program + { + private static double ArithmeticGeometricMean(double number, + double otherNumber, + IEqualityComparer + comparer) + { + return comparer.Equals(number, otherNumber) + ? number + : ArithmeticGeometricMean( + ArithmeticMean(number, otherNumber), + GeometricMean(number, otherNumber), comparer); + } + + private static double ArithmeticMean(double number, double otherNumber) + { + return 0.5 * (number + otherNumber); + } + + private static double GeometricMean(double number, double otherNumber) + { + return Math.Sqrt(number * otherNumber); + } + + private static void Main() + { + Console.WriteLine( + ArithmeticGeometricMean(1, 0.5 * Math.Sqrt(2), + new RelativeDifferenceComparer(1e-5)). + ToString(CultureInfo.InvariantCulture)); + } + + private class RelativeDifferenceComparer : IEqualityComparer + { + private readonly double _maximumRelativeDifference; + + internal RelativeDifferenceComparer(double maximumRelativeDifference) + { + _maximumRelativeDifference = maximumRelativeDifference; + } + + public bool Equals(double number, double otherNumber) + { + return RelativeDifference(number, otherNumber) <= + _maximumRelativeDifference; + } + + public int GetHashCode(double number) + { + return number.GetHashCode(); + } + + private static double RelativeDifference(double number, + double otherNumber) + { + return AbsoluteDifference(number, otherNumber) / + Norm(number, otherNumber); + } + + private static double AbsoluteDifference(double number, + double otherNumber) + { + return Math.Abs(number - otherNumber); + } + + private static double Norm(double number, double otherNumber) + { + return 0.5 * (Math.Abs(number) + Math.Abs(otherNumber)); + } + } + } +} diff --git a/Task/Arithmetic-geometric-mean/Common-Lisp/arithmetic-geometric-mean.lisp b/Task/Arithmetic-geometric-mean/Common-Lisp/arithmetic-geometric-mean.lisp new file mode 100644 index 0000000000..20df61a9ac --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Common-Lisp/arithmetic-geometric-mean.lisp @@ -0,0 +1,5 @@ +(defun agm (a0 g0 &optional (tolerance 1d-8)) + (loop for a = a0 then (* (+ a g) 5d-1) + and g = g0 then (sqrt (* a g)) + until (< (abs (- a g)) tolerance) + finally (return a))) diff --git a/Task/Arithmetic-geometric-mean/D/arithmetic-geometric-mean.d b/Task/Arithmetic-geometric-mean/D/arithmetic-geometric-mean.d new file mode 100644 index 0000000000..9022377511 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/D/arithmetic-geometric-mean.d @@ -0,0 +1,15 @@ +import std.stdio, std.math, std.typecons; + +real agm(real a, real g, in int bitPrecision=60) pure nothrow { + do { + //(a, g) = tuple((a + g) / 2.0, sqrt(a * g)); + immutable ag = tuple((a + g) / 2.0, sqrt(a * g)); + a = ag[0]; + g = ag[1]; + } while (feqrel(a, g) < bitPrecision); + return a; +} + +void main() { + writefln("%0.19f", agm(1, 1 / sqrt(2.0))); +} diff --git a/Task/Array-concatenation/C++/array-concatenation.cpp b/Task/Array-concatenation/C++/array-concatenation.cpp new file mode 100644 index 0000000000..1dea6457b5 --- /dev/null +++ b/Task/Array-concatenation/C++/array-concatenation.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main() +{ + std::vector a(3), b(4); + a[0] = 11; a[1] = 12; a[2] = 13; + b[0] = 21; b[1] = 22; b[2] = 23; b[3] = 24; + + a.insert(a.end(), b.begin(), b.end()); + + for (int i = 0; i < a.size(); ++i) + std::cout << "a[" << i << "] = " << a[i] << "\n"; +} diff --git a/Task/Array-concatenation/C-sharp/array-concatenation-1.cs b/Task/Array-concatenation/C-sharp/array-concatenation-1.cs new file mode 100644 index 0000000000..b47ccd222b --- /dev/null +++ b/Task/Array-concatenation/C-sharp/array-concatenation-1.cs @@ -0,0 +1,22 @@ +using System; + +namespace RosettaCode +{ + class Program + { + static void Main(string[] args) + { + int[] a = { 1, 2, 3 }; + int[] b = { 4, 5, 6 }; + + int[] c = new int[a.Length + b.Length]; + a.CopyTo(c, 0); + b.CopyTo(c, a.Length); + + foreach(int n in c) + { + Console.WriteLine(n.ToString()); + } + } + } +} diff --git a/Task/Array-concatenation/C-sharp/array-concatenation-2.cs b/Task/Array-concatenation/C-sharp/array-concatenation-2.cs new file mode 100644 index 0000000000..f6770d9439 --- /dev/null +++ b/Task/Array-concatenation/C-sharp/array-concatenation-2.cs @@ -0,0 +1,12 @@ +using System.Linq; + +class Program +{ + static void Main(string[] args) + { + int[] a = { 1, 2, 3 }; + int[] b = { 4, 5, 6 }; + + int[] c = a.Concat(b).ToArray(); + } +} diff --git a/Task/Array-concatenation/Common-Lisp/array-concatenation.lisp b/Task/Array-concatenation/Common-Lisp/array-concatenation.lisp new file mode 100644 index 0000000000..74defb497a --- /dev/null +++ b/Task/Array-concatenation/Common-Lisp/array-concatenation.lisp @@ -0,0 +1,2 @@ +(concatenate 'vector #(0 1 2 3) #(4 5 6 7)) + => #(0 1 2 3 4 5 6 7) diff --git a/Task/Array-concatenation/D/array-concatenation.d b/Task/Array-concatenation/D/array-concatenation.d new file mode 100644 index 0000000000..c4382773be --- /dev/null +++ b/Task/Array-concatenation/D/array-concatenation.d @@ -0,0 +1,8 @@ +import std.stdio: writeln; + +void main() { + int[] a = [1, 2]; + int[] b = [4, 5, 6]; + + writeln(a, " ~ ", b, " = ", a ~ b); +} diff --git a/Task/Array-concatenation/Delphi/array-concatenation.delphi b/Task/Array-concatenation/Delphi/array-concatenation.delphi new file mode 100644 index 0000000000..60d5379497 --- /dev/null +++ b/Task/Array-concatenation/Delphi/array-concatenation.delphi @@ -0,0 +1,38 @@ +type + TReturnArray = array of integer; //you need to define a type to be able to return it + +function ConcatArray(a1,a2:array of integer):TReturnArray; +var + i,r:integer; +begin + { Low(array) is not necessarily 0 } + SetLength(result,High(a1)-Low(a1)+High(a2)-Low(a2)+2); //BAD idea to set a length you won't release, just to show the idea! + r:=0; //index on the result may be different to indexes on the sources + for i := Low(a1) to High(a1) do begin + result[r] := a1[i]; + Inc(r); + end; + for i := Low(a2) to High(a2) do begin + result[r] := a2[i]; + Inc(r); + end; +end; + +procedure TForm1.Button1Click(Sender: TObject); +var + a1,a2:array of integer; + r1:array of integer; + i:integer; +begin + SetLength(a1,4); + SetLength(a2,3); + for i := Low(a1) to High(a1) do + a1[i] := i; + for i := Low(a2) to High(a2) do + a2[i] := i; + TReturnArray(r1) := ConcatArray(a1,a2); + for i := Low(r1) to High(r1) do + showMessage(IntToStr(r1[i])); + Finalize(r1); //IMPORTANT! + ShowMessage(IntToStr(High(r1))); +end; diff --git a/Task/Array-concatenation/E/array-concatenation.e b/Task/Array-concatenation/E/array-concatenation.e new file mode 100644 index 0000000000..51ebdbe787 --- /dev/null +++ b/Task/Array-concatenation/E/array-concatenation.e @@ -0,0 +1,2 @@ +? [1,2] + [3,4] +# value: [1, 2, 3, 4] diff --git a/Task/Array-concatenation/EGL/array-concatenation.egl b/Task/Array-concatenation/EGL/array-concatenation.egl new file mode 100644 index 0000000000..6bad88b734 --- /dev/null +++ b/Task/Array-concatenation/EGL/array-concatenation.egl @@ -0,0 +1,13 @@ +program ArrayConcatenation + function main() + a int[] = [ 1, 2, 3 ]; + b int[] = [ 4, 5, 6 ]; + c int[]; + c.appendAll(a); + c.appendAll(b); + + for (i int from 1 to c.getSize()) + SysLib.writeStdout("Element " :: i :: " = " :: c[i]); + end + end +end diff --git a/Task/Array-concatenation/Efene/array-concatenation.efene b/Task/Array-concatenation/Efene/array-concatenation.efene new file mode 100644 index 0000000000..4e0753aa01 --- /dev/null +++ b/Task/Array-concatenation/Efene/array-concatenation.efene @@ -0,0 +1,11 @@ +@public +run = fn () { + A = [1, 2, 3, 4] + B = [5, 6, 7, 8] + + C = A ++ B + D = lists.append([A, B]) + + io.format("~p~n", [C]) + io.format("~p~n", [D]) +} diff --git a/Task/Array-concatenation/Elena/array-concatenation.elena b/Task/Array-concatenation/Elena/array-concatenation.elena new file mode 100644 index 0000000000..1f4023dfdf --- /dev/null +++ b/Task/Array-concatenation/Elena/array-concatenation.elena @@ -0,0 +1,11 @@ +#define std'routines'arrays'*. + +#symbol Program = +[ + #var a := (1,2,3). + #var b := (4,5). + + #var c := a~earrayop add:b. + + 'program'output << "(" << a << ") + (" << b << ") = (" << c <<")%n". +]. diff --git a/Task/Array-concatenation/Euphoria/array-concatenation.euphoria b/Task/Array-concatenation/Euphoria/array-concatenation.euphoria new file mode 100644 index 0000000000..ebf38133ed --- /dev/null +++ b/Task/Array-concatenation/Euphoria/array-concatenation.euphoria @@ -0,0 +1,5 @@ +sequence s1,s2,s3 +s1 = {1,2,3} +s2 = {4,5,6} +s3 = s1 & s2 +? s3 diff --git a/Task/Arrays/C++/arrays-1.cpp b/Task/Arrays/C++/arrays-1.cpp new file mode 100644 index 0000000000..daf8076357 --- /dev/null +++ b/Task/Arrays/C++/arrays-1.cpp @@ -0,0 +1,4 @@ + // Qt + QVector myArray4(10); + myArray4.push_back(1); + myArray4.push_back(2); diff --git a/Task/Arrays/C++/arrays-2.cpp b/Task/Arrays/C++/arrays-2.cpp new file mode 100644 index 0000000000..27f88be34e --- /dev/null +++ b/Task/Arrays/C++/arrays-2.cpp @@ -0,0 +1,4 @@ + // MFC + CArray myArray5(10); + myArray5.Add(1); + myArray5.Add(2); diff --git a/Task/Arrays/C++/arrays-3.cpp b/Task/Arrays/C++/arrays-3.cpp new file mode 100644 index 0000000000..6c52abd0c0 --- /dev/null +++ b/Task/Arrays/C++/arrays-3.cpp @@ -0,0 +1,6 @@ +int myArray[2]; + +myArray[0] = 1; +myArray[1] = 3; + +cout << myArray[1] << endl; diff --git a/Task/Arrays/C++/arrays-4.cpp b/Task/Arrays/C++/arrays-4.cpp new file mode 100644 index 0000000000..41d3fd046a --- /dev/null +++ b/Task/Arrays/C++/arrays-4.cpp @@ -0,0 +1,7 @@ +int* myArray = new int[10]; + +myArray[0] = 1; +myArray[1] = 3; + +cout << myArray[1] << endl; +delete [] myArray; diff --git a/Task/Arrays/C++/arrays-5.cpp b/Task/Arrays/C++/arrays-5.cpp new file mode 100644 index 0000000000..b5119b9644 --- /dev/null +++ b/Task/Arrays/C++/arrays-5.cpp @@ -0,0 +1,8 @@ +vector myArray2; + +myArray2.push_back(1); +myArray2.push_back(3); + +myArray2[0] = 2; + +cout << myArray2[0] << endl; diff --git a/Task/Arrays/C++/arrays-6.cpp b/Task/Arrays/C++/arrays-6.cpp new file mode 100644 index 0000000000..f753436759 --- /dev/null +++ b/Task/Arrays/C++/arrays-6.cpp @@ -0,0 +1,25 @@ +#include +using std::cout; +using std::endl; + +#include +#include +#include + +int main() +{ + boost::array A; + A[0] = 5; // not bounds checked + A[1] = 2; + A.at(2) = 3; // this is bounds checked. + + cout << A[0] << endl; // not bounds checked + + for (int i =0; i < 3; ++i) { + cout << A.at(i) << endl; // this is bounds checked + } + + // use it as you would any STL ordered container. + std::reverse(A.begin(),A.end()); + BOOST_FOREACH(int i, A){cout << i << endl;} +} diff --git a/Task/Arrays/C-sharp/arrays-1.cs b/Task/Arrays/C-sharp/arrays-1.cs new file mode 100644 index 0000000000..3f7d9ef8aa --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-1.cs @@ -0,0 +1 @@ + int[] numbers = new int[10]; diff --git a/Task/Arrays/C-sharp/arrays-10.cs b/Task/Arrays/C-sharp/arrays-10.cs new file mode 100644 index 0000000000..ca083e8e46 --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-10.cs @@ -0,0 +1,2 @@ +array :: {Real} +array = createArray 10 3.1415 diff --git a/Task/Arrays/C-sharp/arrays-11.cs b/Task/Arrays/C-sharp/arrays-11.cs new file mode 100644 index 0000000000..9795c01b26 --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-11.cs @@ -0,0 +1,2 @@ +array :: {Int} +array = {x \\ x <- [1 .. 10]} diff --git a/Task/Arrays/C-sharp/arrays-12.cs b/Task/Arrays/C-sharp/arrays-12.cs new file mode 100644 index 0000000000..85a7bd4f92 --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-12.cs @@ -0,0 +1,2 @@ +array :: {!Int} +array = {x \\ x <- [1 .. 10]} diff --git a/Task/Arrays/C-sharp/arrays-13.cs b/Task/Arrays/C-sharp/arrays-13.cs new file mode 100644 index 0000000000..d4967f4131 --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-13.cs @@ -0,0 +1,2 @@ +array :: {#Char} +array = {x \\ x <- ['a' .. 'z']} diff --git a/Task/Arrays/C-sharp/arrays-2.cs b/Task/Arrays/C-sharp/arrays-2.cs new file mode 100644 index 0000000000..d47fa52cf3 --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-2.cs @@ -0,0 +1 @@ + string[] words = { "these", "are", "arrays" }; diff --git a/Task/Arrays/C-sharp/arrays-3.cs b/Task/Arrays/C-sharp/arrays-3.cs new file mode 100644 index 0000000000..f8bd42d7f2 --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-3.cs @@ -0,0 +1 @@ + int[] more_numbers = new int[3]{ 21, 14 ,63 }; diff --git a/Task/Arrays/C-sharp/arrays-4.cs b/Task/Arrays/C-sharp/arrays-4.cs new file mode 100644 index 0000000000..86ef97e4e5 --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-4.cs @@ -0,0 +1 @@ + int[,] number_matrix = new int[3,2]; diff --git a/Task/Arrays/C-sharp/arrays-5.cs b/Task/Arrays/C-sharp/arrays-5.cs new file mode 100644 index 0000000000..3cc785168d --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-5.cs @@ -0,0 +1 @@ + string[,] string_matrix = { {"I","swam"}, {"in","the"}, {"freezing","water"} }; diff --git a/Task/Arrays/C-sharp/arrays-6.cs b/Task/Arrays/C-sharp/arrays-6.cs new file mode 100644 index 0000000000..2ea9dc5444 --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-6.cs @@ -0,0 +1 @@ + string[,] funny_matrix = new string[2,2]{ {"clowns", "are"} , {"not", "funny"} }; diff --git a/Task/Arrays/C-sharp/arrays-7.cs b/Task/Arrays/C-sharp/arrays-7.cs new file mode 100644 index 0000000000..b0e59984c9 --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-7.cs @@ -0,0 +1,6 @@ +int[] array = new int[10]; + +array[0] = 1; +array[1] = 3; + +Console.WriteLine(array[0]); diff --git a/Task/Arrays/C-sharp/arrays-8.cs b/Task/Arrays/C-sharp/arrays-8.cs new file mode 100644 index 0000000000..aea630593c --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-8.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +List list = new List(); + +list.Add(1); +list.Add(3); + +list[0] = 2; + +Console.WriteLine(list[0]); diff --git a/Task/Arrays/C-sharp/arrays-9.cs b/Task/Arrays/C-sharp/arrays-9.cs new file mode 100644 index 0000000000..fac6242999 --- /dev/null +++ b/Task/Arrays/C-sharp/arrays-9.cs @@ -0,0 +1,2 @@ +array :: {String} +array = {"Hello", "World"} diff --git a/Task/Arrays/Common-Lisp/arrays-1.lisp b/Task/Arrays/Common-Lisp/arrays-1.lisp new file mode 100644 index 0000000000..c3ddc4bfcd --- /dev/null +++ b/Task/Arrays/Common-Lisp/arrays-1.lisp @@ -0,0 +1,4 @@ +(let ((array (make-array 10))) + (setf (aref array 0) 1 + (aref array 1) 3) + (print array)) diff --git a/Task/Arrays/Common-Lisp/arrays-2.lisp b/Task/Arrays/Common-Lisp/arrays-2.lisp new file mode 100644 index 0000000000..9f631c562d --- /dev/null +++ b/Task/Arrays/Common-Lisp/arrays-2.lisp @@ -0,0 +1,5 @@ +(let ((array (make-array 0 :adjustable t :fill-pointer 0))) + (vector-push-extend 1 array) + (vector-push-extend 3 array) + (setf (aref array 0) 2) + (print array)) diff --git a/Task/Arrays/Common-Lisp/arrays-3.lisp b/Task/Arrays/Common-Lisp/arrays-3.lisp new file mode 100644 index 0000000000..5f24f28438 --- /dev/null +++ b/Task/Arrays/Common-Lisp/arrays-3.lisp @@ -0,0 +1 @@ +(make-array 10) diff --git a/Task/Arrays/Common-Lisp/arrays-4.lisp b/Task/Arrays/Common-Lisp/arrays-4.lisp new file mode 100644 index 0000000000..41846687c6 --- /dev/null +++ b/Task/Arrays/Common-Lisp/arrays-4.lisp @@ -0,0 +1 @@ +(make-array '(10 20)) diff --git a/Task/Arrays/Common-Lisp/arrays-5.lisp b/Task/Arrays/Common-Lisp/arrays-5.lisp new file mode 100644 index 0000000000..b5fed9a5fe --- /dev/null +++ b/Task/Arrays/Common-Lisp/arrays-5.lisp @@ -0,0 +1,4 @@ +; Makes an array of 20 objects initialized to nil +(make-array 20 :initial-element nil) +; Makes an integer array of 4 elements containing 1 2 3 and 4 initially which can be resized +(make-array 4 :element-type 'integer :initial-contents '(1 2 3 4) :adjustable t) diff --git a/Task/Arrays/Component-Pascal/arrays.pascal b/Task/Arrays/Component-Pascal/arrays.pascal new file mode 100644 index 0000000000..5f61ded698 --- /dev/null +++ b/Task/Arrays/Component-Pascal/arrays.pascal @@ -0,0 +1,27 @@ +MODULE TestArray; +(* Implemented in BlackBox Component Builder *) + + IMPORT Out; + + (* Static array *) + + PROCEDURE DoOneDim*; + CONST M = 5; + VAR a: ARRAY M OF INTEGER; + BEGIN + a[0] := 100; (* set first element's value of array a to 100 *) + a[M-1] := -100; (* set M-th element's value of array a to -100 *) + Out.Int(a[0], 0); Out.Ln; + Out.Int(a[M-1], 0); Out.Ln; + END DoOneDim; + + PROCEDURE DoTwoDim*; + VAR b: ARRAY 5, 4 OF INTEGER; + BEGIN + b[1, 2] := 100; (* second row, third column element *) + b[4, 3] := -100; (* fifth row, fourth column element *) + Out.Int(b[1, 2], 0); Out.Ln; + Out.Int(b[4, 3], 0); Out.Ln; + END DoTwoDim; + +END TestArray. diff --git a/Task/Arrays/D/arrays.d b/Task/Arrays/D/arrays.d new file mode 100644 index 0000000000..60d4d9eebf --- /dev/null +++ b/Task/Arrays/D/arrays.d @@ -0,0 +1,41 @@ +// All D arrays are capable of bounds checks. + +import std.stdio, core.stdc.stdlib; +import std.container: Array; + +void main() { + // GC-managed heap allocated dynamic array: + auto array1 = new int[1]; + array1[0] = 1; + array1 ~= 3; // append a second item + // array1[10] = 4; // run-time error + writeln("A) Element 0: ", array1[0]); + writeln("A) Element 1: ", array1[1]); + + // Stack-allocated fixed-size array: + int[5] array2; + array2[0] = 1; + array2[1] = 3; + // array2[2] = 4; // compile-time error + writeln("B) Element 0: ", array2[0]); + writeln("B) Element 1: ", array2[1]); + + // Stack-allocated dynamic fixed-sized array, + // length known only at run-time: + int n = 2; + int[] array3 = (cast(int*)alloca(n * int.sizeof))[0 .. n]; + array3[0] = 1; + array3[1] = 3; + // array3[10] = 4; // run-time error + writeln("C) Element 0: ", array3[0]); + writeln("C) Element 1: ", array3[1]); + + // Phobos-defined heap allocated not GC-managed array: + Array!int array4; + array4.length = 2; + array4[0] = 1; + array4[1] = 3; + // array4[10] = 4; // run-time exception + writeln("D) Element 0: ", array4[0]); + writeln("D) Element 1: ", array4[1]); +} diff --git a/Task/Arrays/DWScript/arrays.dwscript b/Task/Arrays/DWScript/arrays.dwscript new file mode 100644 index 0000000000..1cc4e62283 --- /dev/null +++ b/Task/Arrays/DWScript/arrays.dwscript @@ -0,0 +1,14 @@ +// dynamic array, extensible, this a reference type +var d : array of Integer; +d.Add(1); // has various methods to add, delete, etc. +d.Add(2, 3); + +// read and write elements by index +item := d[5]; +d[6] := item+1; + +// static, fixed-size array, arbitrary lower-bound, this is a value type +var s : array [2..4] of Integer; + +// inline array constructor, works for both static and dynamic arrays +s := [1, 2, 3]; diff --git a/Task/Arrays/Dao/arrays.dao b/Task/Arrays/Dao/arrays.dao new file mode 100644 index 0000000000..75cd07865c --- /dev/null +++ b/Task/Arrays/Dao/arrays.dao @@ -0,0 +1,10 @@ +# use [] to create numeric arrays of int, float, double or complex types: +a = [ 1, 2, 3 ] # a vector +b = [ 1, 2; 3, 4 ] # a 2X2 matrix + +# use {} to create normal arrays of any types: +c = { 1, 2, 'abc' } + +d = a[1] +e = b[0,1] # first row, second column +f = c[1] diff --git a/Task/Arrays/Delphi/arrays.delphi b/Task/Arrays/Delphi/arrays.delphi new file mode 100644 index 0000000000..a9ebb3d530 --- /dev/null +++ b/Task/Arrays/Delphi/arrays.delphi @@ -0,0 +1,30 @@ +procedure TForm1.Button1Click(Sender: TObject); +var + StaticArray: array[0..9] of Integer; + DynamicArray: array of Integer; + StaticArrayText, + DynamicArrayText: string; + lcv: Integer; +begin + // Setting the length of the dynamic array the same as the static one + SetLength(DynamicArray, Length(StaticArray)); + // Asking random numbers storing into the static array + for lcv := 0 to Pred(Length(StaticArray)) do + begin + StaticArray[lcv] := StrToInt( + InputBox('Random number', + 'Enter a random number for position', + IntToStr(Succ(lcv)))); + end; + // Storing entered numbers of the static array in reverse order into the dynamic + for lcv := 0 to Pred(Length(StaticArray)) do + DynamicArray[Pred(Length(DynamicArray)) - lcv] := StaticArray[lcv]; + // Concatenating the static and dynamic array into a single string variable + for lcv := 0 to Pred(Length(StaticArray)) do + begin + StaticArrayText := StaticArrayText + IntToStr(StaticArray[lcv]); + DynamicArrayText := DynamicArrayText + IntToStr(DynamicArray[lcv]); + end; + // Displaying both arrays (#13#10 = Carriage Return/Line Feed) + ShowMessage(StaticArrayText + #13#10 + DynamicArrayText); +end; diff --git a/Task/Arrays/E/arrays-1.e b/Task/Arrays/E/arrays-1.e new file mode 100644 index 0000000000..7f97a2c081 --- /dev/null +++ b/Task/Arrays/E/arrays-1.e @@ -0,0 +1,11 @@ +? def empty := [] +# value: [] + +? def numbers := [1,2,3,4,5] +# value: [1, 2, 3, 4, 5] + +? numbers.with(6) +# value: [1, 2, 3, 4, 5, 6] + +? numbers + [4,3,2,1] +# value: [1, 2, 3, 4, 5, 4, 3, 2, 1] diff --git a/Task/Arrays/E/arrays-2.e b/Task/Arrays/E/arrays-2.e new file mode 100644 index 0000000000..510c2a8549 --- /dev/null +++ b/Task/Arrays/E/arrays-2.e @@ -0,0 +1,8 @@ +? var numbers := [] +# value: [] + +? numbers := numbers.with(1) +# value: [1] + +? numbers with= 2 # shorthand for same +# value: [1, 2] diff --git a/Task/Arrays/E/arrays-3.e b/Task/Arrays/E/arrays-3.e new file mode 100644 index 0000000000..28a561d5a2 --- /dev/null +++ b/Task/Arrays/E/arrays-3.e @@ -0,0 +1,12 @@ +? def flex := numbers.diverge() +# value: [1, 2].diverge() + +? flex.push(-3) +? flex +# value: [1, 2, -3].diverge() + +? numbers +# value: [1, 2] + +? flex.snapshot() +# value: [1, 2, -3] diff --git a/Task/Arrays/E/arrays-4.e b/Task/Arrays/E/arrays-4.e new file mode 100644 index 0000000000..5242055073 --- /dev/null +++ b/Task/Arrays/E/arrays-4.e @@ -0,0 +1 @@ +([0] * 100).diverge(int) # contains 100 zeroes, can only contain integers diff --git a/Task/Arrays/EGL/arrays.egl b/Task/Arrays/EGL/arrays.egl new file mode 100644 index 0000000000..184c1647b3 --- /dev/null +++ b/Task/Arrays/EGL/arrays.egl @@ -0,0 +1,3 @@ +array int[10]; //optionally, add a braced list of values. E.g. array int[10]{1, 2, 3}; +array[1] = 42; +SysLib.writeStdout(array[1]); diff --git a/Task/Arrays/Elena/arrays-1.elena b/Task/Arrays/Elena/arrays-1.elena new file mode 100644 index 0000000000..9e19321538 --- /dev/null +++ b/Task/Arrays/Elena/arrays-1.elena @@ -0,0 +1,3 @@ + #var anArray := (1, 2, 3). + + 'program'Output << anArray@1. diff --git a/Task/Arrays/Elena/arrays-2.elena b/Task/Arrays/Elena/arrays-2.elena new file mode 100644 index 0000000000..13a780b91d --- /dev/null +++ b/Task/Arrays/Elena/arrays-2.elena @@ -0,0 +1,4 @@ + #var anArray := basic'NewArray::3. + anArray@0 content'set:2. + + 'program'Output << anArray@0. diff --git a/Task/Arrays/Euphoria/arrays.euphoria b/Task/Arrays/Euphoria/arrays.euphoria new file mode 100644 index 0000000000..ce69d2c7dd --- /dev/null +++ b/Task/Arrays/Euphoria/arrays.euphoria @@ -0,0 +1,29 @@ +--Arrays task for Rosetta Code wiki +--User:Lnettnay + +atom dummy +--Arrays are sequences +-- single dimensioned array of 10 elements +sequence xarray = repeat(0,10) +xarray[5] = 5 +dummy = xarray[5] +? dummy + +--2 dimensional array +--5 sequences of 10 elements each +sequence xyarray = repeat(repeat(0,10),5) +xyarray[3][6] = 12 +dummy = xyarray[3][6] +? dummy + +--dynamic array use (all sequences can be modified at any time) +sequence dynarray = {} +for x = 1 to 10 do + dynarray = append(dynarray, x * x) +end for +? dynarray + +for x = 1 to 10 do + dynarray = prepend(dynarray, x) +end for +? dynarray diff --git a/Task/Assertions/C++/assertions.cpp b/Task/Assertions/C++/assertions.cpp new file mode 100644 index 0000000000..dc4d7c09c3 --- /dev/null +++ b/Task/Assertions/C++/assertions.cpp @@ -0,0 +1,10 @@ +#include // assert.h also works + +int main() +{ + int a; + // ... input or change a here + + assert(a == 42); // Aborts program if a is not 42, unless the NDEBUG macro was defined + // when including , in which case it has no effect +} diff --git a/Task/Assertions/C-sharp/assertions.cs b/Task/Assertions/C-sharp/assertions.cs new file mode 100644 index 0000000000..a53252ab84 --- /dev/null +++ b/Task/Assertions/C-sharp/assertions.cs @@ -0,0 +1,3 @@ +using System.Diagnostics; + +Debug.Assert(a == 42); diff --git a/Task/Assertions/Common-Lisp/assertions.lisp b/Task/Assertions/Common-Lisp/assertions.lisp new file mode 100644 index 0000000000..b673025183 --- /dev/null +++ b/Task/Assertions/Common-Lisp/assertions.lisp @@ -0,0 +1,2 @@ +(let ((x 42)) + (assert (and (integerp x) (= 42 x)) (x))) diff --git a/Task/Assertions/Component-Pascal/assertions.pascal b/Task/Assertions/Component-Pascal/assertions.pascal new file mode 100644 index 0000000000..7657d05748 --- /dev/null +++ b/Task/Assertions/Component-Pascal/assertions.pascal @@ -0,0 +1,11 @@ +MODULE Assertions; +VAR + x: INTEGER; +PROCEDURE DoIt*; +BEGIN + x := 41; + ASSERT(x = 42); +END DoIt; +END Assertions. + +Assertions.DoIt diff --git a/Task/Assertions/D/assertions.d b/Task/Assertions/D/assertions.d new file mode 100644 index 0000000000..9391d49ae1 --- /dev/null +++ b/Task/Assertions/D/assertions.d @@ -0,0 +1,5 @@ +import std.string; +void main() { + int a = readln().chomp().atoi(); + assert(a == 42, "You did not input 42!"); +} diff --git a/Task/Assertions/DWScript/assertions-1.dwscript b/Task/Assertions/DWScript/assertions-1.dwscript new file mode 100644 index 0000000000..09b0c9204a --- /dev/null +++ b/Task/Assertions/DWScript/assertions-1.dwscript @@ -0,0 +1 @@ +Assert(a = 42, 'Not 42!'); diff --git a/Task/Assertions/DWScript/assertions-2.dwscript b/Task/Assertions/DWScript/assertions-2.dwscript new file mode 100644 index 0000000000..5c1c8fa6a3 --- /dev/null +++ b/Task/Assertions/DWScript/assertions-2.dwscript @@ -0,0 +1,8 @@ +procedure UniversalAnswer(var a : Integer); +require + a = 42; +begin + // code here +ensure + a = 42; +end; diff --git a/Task/Assertions/Dart/assertions.dart b/Task/Assertions/Dart/assertions.dart new file mode 100644 index 0000000000..54d6e43b9b --- /dev/null +++ b/Task/Assertions/Dart/assertions.dart @@ -0,0 +1,7 @@ +main() { + int i=42; + int j=41; + + Expect.equals(42,i); + Expect.equals(42,j); +} diff --git a/Task/Assertions/Delphi/assertions-1.delphi b/Task/Assertions/Delphi/assertions-1.delphi new file mode 100644 index 0000000000..fc4c3d8df8 --- /dev/null +++ b/Task/Assertions/Delphi/assertions-1.delphi @@ -0,0 +1 @@ +Assert(a = 42); diff --git a/Task/Assertions/Delphi/assertions-2.delphi b/Task/Assertions/Delphi/assertions-2.delphi new file mode 100644 index 0000000000..a4ec68f186 --- /dev/null +++ b/Task/Assertions/Delphi/assertions-2.delphi @@ -0,0 +1 @@ +{$ASSERTIONS OFF} diff --git a/Task/Assertions/Delphi/assertions-3.delphi b/Task/Assertions/Delphi/assertions-3.delphi new file mode 100644 index 0000000000..31d178c25c --- /dev/null +++ b/Task/Assertions/Delphi/assertions-3.delphi @@ -0,0 +1,21 @@ +program TestAssert; + +{$APPTYPE CONSOLE} + +{.$ASSERTIONS OFF} // remove '.' to disable assertions + +uses + SysUtils; + +var + a: Integer; + +begin + try + Assert(a = 42); + except + on E:Exception do + Writeln(E.Classname, ': ', E.Message); + end; + Readln; +end. diff --git a/Task/Assertions/E/assertions.e b/Task/Assertions/E/assertions.e new file mode 100644 index 0000000000..42fd1edd60 --- /dev/null +++ b/Task/Assertions/E/assertions.e @@ -0,0 +1,5 @@ +require(a == 42) # default message, "Required condition failed" + +require(a == 42, "The Answer is Wrong.") # supplied message + +require(a == 42, fn { `Off by ${a - 42}.` }) # computed only on failure diff --git a/Task/Assertions/Emacs-Lisp/assertions.l b/Task/Assertions/Emacs-Lisp/assertions.l new file mode 100644 index 0000000000..63cc9be839 --- /dev/null +++ b/Task/Assertions/Emacs-Lisp/assertions.l @@ -0,0 +1,3 @@ +(require 'cl) +(let ((x 41)) + (assert (= x 42) t "the answer is not right")) diff --git a/Task/Assertions/Euphoria/assertions.euphoria b/Task/Assertions/Euphoria/assertions.euphoria new file mode 100644 index 0000000000..440615c729 --- /dev/null +++ b/Task/Assertions/Euphoria/assertions.euphoria @@ -0,0 +1,7 @@ +type fourty_two(integer i) + return i = 42 +end type + +fourty_two i + +i = 41 -- type-check failure diff --git a/Task/Associative-array-Creation/C++/associative-array-creation-1.cpp b/Task/Associative-array-Creation/C++/associative-array-creation-1.cpp new file mode 100644 index 0000000000..6d458a8d98 --- /dev/null +++ b/Task/Associative-array-Creation/C++/associative-array-creation-1.cpp @@ -0,0 +1 @@ +#include diff --git a/Task/Associative-array-Creation/C++/associative-array-creation-10.cpp b/Task/Associative-array-Creation/C++/associative-array-creation-10.cpp new file mode 100644 index 0000000000..606960135b --- /dev/null +++ b/Task/Associative-array-Creation/C++/associative-array-creation-10.cpp @@ -0,0 +1,26 @@ +#include +#include + +int main() +{ + // Create the map. + std::map exampleMap; + + // Choose our key + int myKey = 7; + + // Choose our value + double myValue = 3.14; + + // Assign a value to the map with the specified key. + exampleMap[myKey] = myValue; + + // Retrieve the value + double myRetrievedValue = exampleMap[myKey]; + + // Display our retrieved value. + std::cout << myRetrievedValue << std::endl; + + // main() must return 0 on success. + return 0; +} diff --git a/Task/Associative-array-Creation/C++/associative-array-creation-2.cpp b/Task/Associative-array-Creation/C++/associative-array-creation-2.cpp new file mode 100644 index 0000000000..3a72b7879e --- /dev/null +++ b/Task/Associative-array-Creation/C++/associative-array-creation-2.cpp @@ -0,0 +1 @@ +std::map exampleMap diff --git a/Task/Associative-array-Creation/C++/associative-array-creation-3.cpp b/Task/Associative-array-Creation/C++/associative-array-creation-3.cpp new file mode 100644 index 0000000000..1bd40c2549 --- /dev/null +++ b/Task/Associative-array-Creation/C++/associative-array-creation-3.cpp @@ -0,0 +1 @@ +std::map exampleMap diff --git a/Task/Associative-array-Creation/C++/associative-array-creation-4.cpp b/Task/Associative-array-Creation/C++/associative-array-creation-4.cpp new file mode 100644 index 0000000000..9863216d71 --- /dev/null +++ b/Task/Associative-array-Creation/C++/associative-array-creation-4.cpp @@ -0,0 +1 @@ +exampleMap[7] = 3.14 diff --git a/Task/Associative-array-Creation/C++/associative-array-creation-5.cpp b/Task/Associative-array-Creation/C++/associative-array-creation-5.cpp new file mode 100644 index 0000000000..22d67150d1 --- /dev/null +++ b/Task/Associative-array-Creation/C++/associative-array-creation-5.cpp @@ -0,0 +1,3 @@ +int myKey = 7; +double myValue = 3.14; +exampleMap[myKey] = myValue; diff --git a/Task/Associative-array-Creation/C++/associative-array-creation-6.cpp b/Task/Associative-array-Creation/C++/associative-array-creation-6.cpp new file mode 100644 index 0000000000..31d2168f81 --- /dev/null +++ b/Task/Associative-array-Creation/C++/associative-array-creation-6.cpp @@ -0,0 +1 @@ +exampleMap.insert(std::pair(7,3.14)); diff --git a/Task/Associative-array-Creation/C++/associative-array-creation-7.cpp b/Task/Associative-array-Creation/C++/associative-array-creation-7.cpp new file mode 100644 index 0000000000..a0beca349b --- /dev/null +++ b/Task/Associative-array-Creation/C++/associative-array-creation-7.cpp @@ -0,0 +1 @@ +exampleMap.insert(std::make_pair(7,3.14)); diff --git a/Task/Associative-array-Creation/C++/associative-array-creation-8.cpp b/Task/Associative-array-Creation/C++/associative-array-creation-8.cpp new file mode 100644 index 0000000000..72bc956252 --- /dev/null +++ b/Task/Associative-array-Creation/C++/associative-array-creation-8.cpp @@ -0,0 +1 @@ +myValue = exampleMap[myKey] diff --git a/Task/Associative-array-Creation/C++/associative-array-creation-9.cpp b/Task/Associative-array-Creation/C++/associative-array-creation-9.cpp new file mode 100644 index 0000000000..9a37781d0e --- /dev/null +++ b/Task/Associative-array-Creation/C++/associative-array-creation-9.cpp @@ -0,0 +1,7 @@ +double myValue = 0.0; +std::map::iterator myIterator = exampleMap.find(myKey); +if(exampleMap.end() != myIterator) +{ + // Return the value for that key. + myValue = myIterator->second; +} diff --git a/Task/Associative-array-Creation/C-sharp/associative-array-creation-1.cs b/Task/Associative-array-Creation/C-sharp/associative-array-creation-1.cs new file mode 100644 index 0000000000..094a32cf9e --- /dev/null +++ b/Task/Associative-array-Creation/C-sharp/associative-array-creation-1.cs @@ -0,0 +1,2 @@ +System.Collections.HashTable map = new System.Collections.HashTable(); +map["key1"] = "foo"; diff --git a/Task/Associative-array-Creation/C-sharp/associative-array-creation-2.cs b/Task/Associative-array-Creation/C-sharp/associative-array-creation-2.cs new file mode 100644 index 0000000000..1d69d46f45 --- /dev/null +++ b/Task/Associative-array-Creation/C-sharp/associative-array-creation-2.cs @@ -0,0 +1,2 @@ +Dictionary map = new Dictionary(); +map[ "key1" ] = "foo"; diff --git a/Task/Associative-array-Creation/C-sharp/associative-array-creation-3.cs b/Task/Associative-array-Creation/C-sharp/associative-array-creation-3.cs new file mode 100644 index 0000000000..eedae21036 --- /dev/null +++ b/Task/Associative-array-Creation/C-sharp/associative-array-creation-3.cs @@ -0,0 +1 @@ +var map = new Dictionary {{"key1", "foo"}}; diff --git a/Task/Associative-array-Creation/ColdFusion/associative-array-creation.cfm b/Task/Associative-array-Creation/ColdFusion/associative-array-creation.cfm new file mode 100644 index 0000000000..e490392f36 --- /dev/null +++ b/Task/Associative-array-Creation/ColdFusion/associative-array-creation.cfm @@ -0,0 +1,4 @@ + + + + diff --git a/Task/Associative-array-Creation/Common-Lisp/associative-array-creation.lisp b/Task/Associative-array-Creation/Common-Lisp/associative-array-creation.lisp new file mode 100644 index 0000000000..1ecfe47aca --- /dev/null +++ b/Task/Associative-array-Creation/Common-Lisp/associative-array-creation.lisp @@ -0,0 +1,13 @@ +;; default :test is #'eql, which is suitable for numbers only, +;; or for implementation identity for other types! +;; Use #'equalp if you want case-insensitive keying on strings. + +(setf my-hash (make-hash-table :test #'equal)) +(setf (gethash "H2O" my-hash) "Water") +(setf (gethash "HCl" my-hash) "Hydrochloric Acid") +(setf (gethash "CO" my-hash) "Carbon Monoxide") + +;; That was actually a hash table, an associative array or +;; alist is written like this: +(defparameter *legs* '((cow . 4) (flamingo . 2) (centipede . 100))) +;; you can use assoc to do lookups and cons new elements onto it to make it longer. diff --git a/Task/Associative-array-Creation/D/associative-array-creation.d b/Task/Associative-array-Creation/D/associative-array-creation.d new file mode 100644 index 0000000000..35212b2b1e --- /dev/null +++ b/Task/Associative-array-Creation/D/associative-array-creation.d @@ -0,0 +1,4 @@ +void main() { + auto hash = ["foo":42, "bar":100]; + assert("foo" in hash); +} diff --git a/Task/Associative-array-Creation/Dao/associative-array-creation.dao b/Task/Associative-array-Creation/Dao/associative-array-creation.dao new file mode 100644 index 0000000000..0ac21b343b --- /dev/null +++ b/Task/Associative-array-Creation/Dao/associative-array-creation.dao @@ -0,0 +1,5 @@ +m = { => } # empty, future inserted keys will be ordered +h = { : } # empty, future inserted keys will not be ordered + +m = { 'foo' => 42, 'bar' => 100 } # with ordered keys +h = { 'foo' : 42, 'bar' : 100 } # with unordered keys diff --git a/Task/Associative-array-Creation/Delphi/associative-array-creation.delphi b/Task/Associative-array-Creation/Delphi/associative-array-creation.delphi new file mode 100644 index 0000000000..e583e1bf24 --- /dev/null +++ b/Task/Associative-array-Creation/Delphi/associative-array-creation.delphi @@ -0,0 +1,19 @@ +program AssociativeArrayCreation; + +{$APPTYPE CONSOLE} + +uses Generics.Collections; + +var + lDictionary: TDictionary; +begin + lDictionary := TDictionary.Create; + try + lDictionary.Add('foo', 5); + lDictionary.Add('bar', 10); + lDictionary.Add('baz', 15); + lDictionary.AddOrSetValue('foo', 6); // replaces value if it exists + finally + lDictionary.Free; + end; +end. diff --git a/Task/Associative-array-Creation/E/associative-array-creation.e b/Task/Associative-array-Creation/E/associative-array-creation.e new file mode 100644 index 0000000000..3c5e5d2ac0 --- /dev/null +++ b/Task/Associative-array-Creation/E/associative-array-creation.e @@ -0,0 +1,5 @@ +[].asMap() # immutable, empty +["one" => 1, "two" => 2] # immutable, 2 mappings +[].asMap().diverge() # mutable, empty +["one" => 2].diverge(String, float64) # mutable, initial contents, + # typed (coerces to float) diff --git a/Task/Associative-array-Creation/Elena/associative-array-creation.elena b/Task/Associative-array-Creation/Elena/associative-array-creation.elena new file mode 100644 index 0000000000..be7ca475c6 --- /dev/null +++ b/Task/Associative-array-Creation/Elena/associative-array-creation.elena @@ -0,0 +1,8 @@ +#define std'dictionary'*. +#define std'collections'*. + +#symbol Program = +[ + #var map := Dictionary. + map append &dictionary_key:"foo" &content:"bar". +]. diff --git a/Task/Associative-array-Iteration/C++/associative-array-iteration-1.cpp b/Task/Associative-array-Iteration/C++/associative-array-iteration-1.cpp new file mode 100644 index 0000000000..b36f44ece5 --- /dev/null +++ b/Task/Associative-array-Iteration/C++/associative-array-iteration-1.cpp @@ -0,0 +1,12 @@ +std::map myDict; +myDict["hello"] = 1; +myDict["world"] = 2; +myDict["!"] = 3; + +// iterating over key-value pairs: +for (std::map::iterator it = myDict.begin(); it != myDict.end(); it++) { + // the thing pointed to by the iterator is a pair + std::string key = it->first; + int value = it->second; + std::cout << "key = " << key << ", value = " << value << std::endl; +} diff --git a/Task/Associative-array-Iteration/C++/associative-array-iteration-2.cpp b/Task/Associative-array-Iteration/C++/associative-array-iteration-2.cpp new file mode 100644 index 0000000000..c4fd35b812 --- /dev/null +++ b/Task/Associative-array-Iteration/C++/associative-array-iteration-2.cpp @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +using namespace std; + +int main() +{ + map myDict; + myDict["hello"] = 1; + myDict["world"] = 2; + myDict["!"] = 3; + + for_each(myDict.begin(), myDict.end(), + [](const pair& p) + { + cout << "key = " << p.first << ", value = " << p.second << endl; + }); + return 0; +} diff --git a/Task/Associative-array-Iteration/C-sharp/associative-array-iteration.cs b/Task/Associative-array-Iteration/C-sharp/associative-array-iteration.cs new file mode 100644 index 0000000000..1f5294daaa --- /dev/null +++ b/Task/Associative-array-Iteration/C-sharp/associative-array-iteration.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +namespace AssocArrays +{ + class Program + { + static void Main(string[] args) + { + + Dictionary assocArray = new Dictionary(); + + assocArray["Hello"] = 1; + assocArray.Add("World", 2); + assocArray["!"] = 3; + + foreach (KeyValuePair kvp in assocArray) + { + Console.WriteLine(kvp.Key + " : " + kvp.Value); + } + + foreach (string key in assocArray.Keys) + { + Console.WriteLine(key); + } + + foreach (int val in assocArray.Values) + { + Console.WriteLine(val.ToString()); + } + } + } +} diff --git a/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-1.lisp b/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-1.lisp new file mode 100644 index 0000000000..8a6304ed0e --- /dev/null +++ b/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-1.lisp @@ -0,0 +1,8 @@ +;; iterate using dolist, destructure manually +(dolist (pair alist) + (destructuring-bind (key . value) pair + (format t "~&Key: ~a, Value: ~a." key value))) + +;; iterate and destructure with loop +(loop for (key . value) in alist + do (format t "~&Key: ~a, Value: ~a." key value)) diff --git a/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-2.lisp b/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-2.lisp new file mode 100644 index 0000000000..bb62e0b8af --- /dev/null +++ b/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-2.lisp @@ -0,0 +1,2 @@ +(loop for (key value) on plist :by 'cddr + do (format t "~&Key: ~a, Value: ~a." key value)) diff --git a/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-3.lisp b/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-3.lisp new file mode 100644 index 0000000000..ac7ec959ec --- /dev/null +++ b/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-3.lisp @@ -0,0 +1,3 @@ +(maphash (lambda (key value) + (format t "~&Key: ~a, Value: ~a." key value)) + hash-table) diff --git a/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-4.lisp b/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-4.lisp new file mode 100644 index 0000000000..3786d80b5a --- /dev/null +++ b/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-4.lisp @@ -0,0 +1,2 @@ +(loop for key being each hash-key of hash-table using (hash-value value) + do (format t "~&Key: ~a, Value: ~a." key value)) diff --git a/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-5.lisp b/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-5.lisp new file mode 100644 index 0000000000..b43071bcac --- /dev/null +++ b/Task/Associative-array-Iteration/Common-Lisp/associative-array-iteration-5.lisp @@ -0,0 +1,6 @@ +(with-hash-table-iterator (next-entry hash-table) + (loop + (multiple-value-bind (nextp key value) (next-entry) + (if (not nextp) + (return) + (format t "~&Key: ~a, Value: ~a." key value))))) diff --git a/Task/Associative-array-Iteration/D/associative-array-iteration.d b/Task/Associative-array-Iteration/D/associative-array-iteration.d new file mode 100644 index 0000000000..702e860427 --- /dev/null +++ b/Task/Associative-array-Iteration/D/associative-array-iteration.d @@ -0,0 +1,40 @@ +import std.stdio: writeln; + +void main() { + // the associative array + auto aa = ["alice":2, "bob":97, "charlie":45]; + + // how to iterate key/value pairs: + foreach (key, value; aa) + writeln("1) Got key ", key, " with value ", value); + writeln(); + + // how to iterate the keys: + foreach (key, _; aa) + writeln("2) Got key ", key); + writeln(); + + // how to iterate the values: + foreach (value; aa) + writeln("3) Got value ", value); + writeln(); + + // how to extract the values, lazy: + foreach (value; aa.byValue()) + writeln("4) Got value ", value); + writeln(); + + // how to extract the keys, lazy: + foreach (key; aa.byKey()) + writeln("5) Got key ", key); + writeln(); + + // how to extract all the keys: + foreach (key; aa.keys) + writeln("6) Got key ", key); + writeln(); + + // how to extract all the values: + foreach (value; aa.values) + writeln("7) Got value ", value); +} diff --git a/Task/Associative-array-Iteration/Dao/associative-array-iteration.dao b/Task/Associative-array-Iteration/Dao/associative-array-iteration.dao new file mode 100644 index 0000000000..fd1353d431 --- /dev/null +++ b/Task/Associative-array-Iteration/Dao/associative-array-iteration.dao @@ -0,0 +1,3 @@ +m = { 'def' => 1, 'abc' => 2 } +for( kv in m ) io.writeln( kv ); +for( k in m.keys(); v in m.values() ) io.writeln( k, v ) diff --git a/Task/Associative-array-Iteration/Delphi/associative-array-iteration.delphi b/Task/Associative-array-Iteration/Delphi/associative-array-iteration.delphi new file mode 100644 index 0000000000..c69be1ce7e --- /dev/null +++ b/Task/Associative-array-Iteration/Delphi/associative-array-iteration.delphi @@ -0,0 +1,29 @@ +program AssociativeArrayIteration; + +{$APPTYPE CONSOLE} + +uses SysUtils, Generics.Collections; + +var + i: Integer; + s: string; + lDictionary: TDictionary; + lPair: TPair; +begin + lDictionary := TDictionary.Create; + try + lDictionary.Add('foo', 5); + lDictionary.Add('bar', 10); + lDictionary.Add('baz', 15); + lDictionary.AddOrSetValue('foo', 6); + + for lPair in lDictionary do + Writeln(Format('Pair: %s = %d', [lPair.Key, lPair.Value])); + for s in lDictionary.Keys do + Writeln('Key: ' + s); + for i in lDictionary.Values do + Writeln('Value: ', i); + finally + lDictionary.Free; + end; +end. diff --git a/Task/Associative-array-Iteration/E/associative-array-iteration.e b/Task/Associative-array-Iteration/E/associative-array-iteration.e new file mode 100644 index 0000000000..a7e8c2cca7 --- /dev/null +++ b/Task/Associative-array-Iteration/E/associative-array-iteration.e @@ -0,0 +1,21 @@ +def map := [ + "a" => 1, + "b" => 2, + "c" => 3, +] + +for key => value in map { + println(`$key $value`) +} + +for value in map { # ignore keys + println(`. $value`) +} + +for key => _ in map { # ignore values + println(`$key .`) +} + +for key in map.domain() { # iterate over the set whose values are the keys + println(`$key .`) +} diff --git a/Task/Associative-array-Iteration/Elena/associative-array-iteration.elena b/Task/Associative-array-Iteration/Elena/associative-array-iteration.elena new file mode 100644 index 0000000000..eeddf766ee --- /dev/null +++ b/Task/Associative-array-Iteration/Elena/associative-array-iteration.elena @@ -0,0 +1,26 @@ +#define std'dictionary'*. +#define std'routines'*. +#define std'collections'*. +#define std'patterns'*. + +// --- Program --- + +#symbol Program = +[ + // 1. Create + #var aMap := Dictionary. + aMap + append &dictionary_key:"key" &content:"foox" + append &dictionary_key:"key" &content:"foo" + append &dictionary_key:"key2" &content:"foo2" + append &dictionary_key:"key3" &content:"foo3" + append &dictionary_key:"key4" &content:"foo4". + + (aMap enumerator)~foreach run: anItem = + [ + 'program'Output << anItem dictionary_key << " : " << anItem content << "%n". + ]. + + // only values + Scan::aMap run: aValue = ('program'Output << avalue << "%n"). +]. diff --git a/Task/Atomic-updates/C-sharp/atomic-updates.cs b/Task/Atomic-updates/C-sharp/atomic-updates.cs new file mode 100644 index 0000000000..2de38b2ba2 --- /dev/null +++ b/Task/Atomic-updates/C-sharp/atomic-updates.cs @@ -0,0 +1,125 @@ +using System; //Rand class +using System.Threading; //Thread, Mutex classes +public class ThreadSafeBuckets +{ + //This class is thread safe, and ensures that all operations on it are atomic. + //Calling threads do not need to ensure safety. + Random rand = new Random(); + int[] Buckets; + object[] locks; //Mutexes for each bucket so they can lock individually + public int BucketCount { get; private set; } + public ThreadSafeBuckets(int bucketcount) + { + //Create buckets+mutexes and fill them with a random amount + BucketCount = bucketcount; + Buckets = new int[bucketcount]; + locks = new object[bucketcount]; + int startingtotal = 0; + for (int i = 0; i < BucketCount; i++) + { + locks[i] = new object(); + Buckets[i] = rand.Next(30); + startingtotal += Buckets[i]; + } + //Print the starting total + Console.WriteLine("Starting total: " + startingtotal); + } + public int GetBucketValue(int i) + { + return Buckets[i]; + } + public void Transfer(int i, int j, int amount) + { + //Transfer amount from bucket i to bucket j + if (i > BucketCount || j > BucketCount || i < 0 || j < 0 || + i == j || amount < 0) + return; + + //To prevent deadlock, always lock the lower bucket first + lock (locks[Math.Min(i, j)]) + lock (locks[Math.Max(i, j)]) + { + //Make sure don't transfer out more than is in the bucket + amount = Math.Min(amount, Buckets[i]); + + //Do the transfer + Buckets[i] -= amount; + Buckets[j] += amount; + } + } + + public void PrintBuckets() + { + int counter = 0; + //Lock all the buckets in sequential order and print their contents + for (int i = 0; i < BucketCount; i++) + { + Monitor.Enter(locks[i]); + Console.Write(Buckets[i] + " "); + counter += Buckets[i]; + } + //Print the bucket total, then unlock all the mutexes + Console.Write("= " + counter); + Console.WriteLine(); + + foreach (var l in locks) + Monitor.Exit(l); + } +} + +class Program +{ + static ThreadSafeBuckets TSBs; + + public static void Main(){ + //Create the thread-safe bucket list + TSBs = new ThreadSafeBuckets(10); + TSBs.PrintBuckets(); + //Create and start the Equalizing Thread + new Thread(new ThreadStart(EqualizerThread)).Start(); + Thread.Sleep(1); + //Create and start the Randamizing Thread + new Thread(new ThreadStart(RandomizerThread)).Start(); + //Use this thread to do the printing + PrinterThread(); + } + //EqualizerThread runs on it's own thread and randomly averages two buckets + static void EqualizerThread() + { + Random rand = new Random(); + while (true) + { + //Pick two buckets + int b1 = rand.Next(TSBs.BucketCount); + int b2 = rand.Next(TSBs.BucketCount); + //Get the difference + int diff = TSBs.GetBucketValue(b1) - TSBs.GetBucketValue(b2); + //Transfer to equalize + if (diff < 0) + TSBs.Transfer(b2, b1, -diff / 2); + else + TSBs.Transfer(b1, b2, diff/2); + } + } + //RandomizerThread redistributes the values between two buckets + static void RandomizerThread() + { + Random rand = new Random(); + while (true) + { + int b1 = rand.Next(TSBs.BucketCount); + int b2 = rand.Next(TSBs.BucketCount); + int diff = rand.Next(TSBs.GetBucketValue(b1)); + TSBs.Transfer(b1, b2, diff); + } + } + //PrinterThread prints the current bucket contents + static void PrinterThread() + { + while (true) + { + Thread.Sleep(50); //Only print every few milliseconds to let the other threads work + TSBs.PrintBuckets(); + } + } +} diff --git a/Task/Atomic-updates/D/atomic-updates.d b/Task/Atomic-updates/D/atomic-updates.d new file mode 100644 index 0000000000..98b8b3faaf --- /dev/null +++ b/Task/Atomic-updates/D/atomic-updates.d @@ -0,0 +1,118 @@ +import std.stdio: writeln; +import std.conv: text; +import std.random: uniform, Xorshift; +import std.algorithm: min, max; +import std.parallelism: task; +import core.thread: Thread; +import core.sync.mutex: Mutex; +import core.time: dur; + +__gshared uint transfersCount; + +final class Buckets(size_t nBuckets) if (nBuckets > 0) { + alias TBucketValue = uint; + + // The trailing padding avoids cache line contention + // when run with two or more cores. + align(128) private static struct Bucket { + TBucketValue value; + Mutex mtx; + alias value this; + } + + private Bucket[nBuckets] buckets; + private bool running; + + public this() { + this.running = true; + foreach (ref b; buckets) + b = Bucket(uniform(0, 100), new Mutex); + } + + public TBucketValue opIndex(in size_t index) const pure nothrow { + return buckets[index]; + } + + public void transfer(in size_t from, in size_t to, + in TBucketValue amount) { + immutable low = min(from, to); + immutable high = max(from, to); + buckets[low].mtx.lock(); + buckets[high].mtx.lock(); + + scope(exit) { + buckets[low].mtx.unlock(); + buckets[high].mtx.unlock(); + } + + immutable realAmount = min(buckets[from].value, amount); + buckets[from] -= realAmount; + buckets[to ] += realAmount; + transfersCount++; + } + + @property size_t length() const pure nothrow { + return this.buckets.length; + } + + void toString(in void delegate(const(char)[]) sink) { + TBucketValue total = 0; + foreach (ref b; buckets) { + b.mtx.lock(); + total += b; + } + + scope(exit) + foreach (ref b; buckets) + b.mtx.unlock(); + + sink(text(buckets)); + sink(" "); + sink(text(total)); + } +} + +void randomize(size_t N)(Buckets!N data) { + immutable maxi = data.length - 1; + auto rng = Xorshift(1); + + while (data.running) { + immutable i = uniform(0, maxi, rng); + immutable j = uniform(0, maxi, rng); + immutable amount = uniform(0, 20, rng); + data.transfer(i, j, amount); + } +} + +void equalize(size_t N)(Buckets!N data) { + immutable maxi = data.length - 1; + auto rng = Xorshift(1); + + while (data.running) { + immutable i = uniform(0, maxi, rng); + immutable j = uniform(0, maxi, rng); + immutable a = data[i]; + immutable b = data[j]; + if (a > b) + data.transfer(i, j, (a - b) / 2); + else + data.transfer(j, i, (b - a) / 2); + } +} + +void display(size_t N)(Buckets!N data) { + foreach (immutable _; 0 .. 10) { + writeln(transfersCount, " ", data); + transfersCount = 0; + Thread.sleep(dur!"msecs"(1000)); + } + data.running = false; +} + +void main() { + writeln("N. transfers, buckets, buckets sum:"); + auto data = new Buckets!20(); + task!randomize(data).executeInNewThread(); + task!equalize(data).executeInNewThread(); + task!display(data).executeInNewThread(); +} diff --git a/Task/Atomic-updates/E/atomic-updates.e b/Task/Atomic-updates/E/atomic-updates.e new file mode 100644 index 0000000000..39e95f661c --- /dev/null +++ b/Task/Atomic-updates/E/atomic-updates.e @@ -0,0 +1,123 @@ +#!/usr/bin/env rune +pragma.syntax("0.9") + +def pi := (-1.0).acos() +def makeEPainter := +def colors := + +# -------------------------------------------------------------- +# --- Definitions + +/** Execute 'task' repeatedly as long 'indicator' is unresolved. */ +def doWhileUnresolved(indicator, task) { + def loop() { + if (!Ref.isResolved(indicator)) { + task() + loop <- () + } + } + loop <- () +} + +/** The data structure specified for the task. */ +def makeBuckets(size) { + def values := ([100] * size).diverge() # storage + def buckets { + to size() :int { return size } + /** get current quantity in bucket 'i' */ + to get(i :int) { return values[i] } + /** transfer 'amount' units, as much as possible, from bucket 'i' to bucket 'j' + or vice versa if 'amount' is negative */ + to transfer(i :int, j :int, amount :int) { + def amountLim := amount.min(values[i]).max(-(values[j])) + values[i] -= amountLim + values[j] += amountLim + } + } + return buckets +} + +/** A view of the current state of the buckets. */ +def makeDisplayComponent(buckets) { + def c := makeEPainter(def paintCallback { + to paintComponent(g) { + def pixelsW := c.getWidth() + def pixelsH := c.getHeight() + def bucketsW := buckets.size() + + g.setColor(colors.getWhite()) + g.fillRect(0, 0, pixelsW, pixelsH) + + g.setColor(colors.getDarkGray()) + var sum := 0 + for i in 0..!bucketsW { + sum += def value := buckets[i] + def x0 := (i * pixelsW / bucketsW).floor() + def x1 := ((i + 1) * pixelsW / bucketsW).floor() + g.fillRect(x0 + 1, pixelsH - value, + x1 - x0 - 1, value) + } + + g.setColor(colors.getBlack()) + g."drawString(String, int, int)"(`Total: $sum`, 2, 20) + } + }) + c.setPreferredSize((500, 300)) + return c +} + +# -------------------------------------------------------------- +# --- Application setup + +def buckets := makeBuckets(100) +def done # Promise indicating when the window is closed + +# Create the window +def frame := ("Atomic transfers") +frame.setContentPane(def display := makeDisplayComponent(buckets)) +frame.addWindowListener(def mainWindowListener { + to windowClosing(event) :void { + bind done := null + } + match _ {} +}) +frame.setLocation(50, 50) +frame.pack() + +# -------------------------------------------------------------- +# --- Tasks + +# Neatens up buckets +var ni := 0 +doWhileUnresolved(done, fn { + def i := ni + def j := (ni + 1) %% buckets.size() + buckets.transfer(i, j, (buckets[i] - buckets[j]) // 4) + ni := j +}) + +# Messes up buckets +var mi := 0 +doWhileUnresolved(done, fn { + def i := (mi + entropy.nextInt(3)) %% buckets.size() + def j := (i + entropy.nextInt(3)) %% buckets.size() #entropy.nextInt(buckets.size()) + buckets.transfer(i, j, (buckets[i] / pi).floor()) + mi := j +}) + +# Updates display at fixed 10 Hz +# (Note: tries to catch up; on slow systems slow this down or it will starve the other tasks) +def clock := timer.every(100, def _(_) { + if (Ref.isResolved(done)) { + clock.stop() + } else { + display.repaint() + } +}) +clock.start() + +# -------------------------------------------------------------- +# --- All ready, go visible and wait + +frame.show() +interp.waitAtTop(done) diff --git a/Task/Atomic-updates/Euphoria/atomic-updates.euphoria b/Task/Atomic-updates/Euphoria/atomic-updates.euphoria new file mode 100644 index 0000000000..8d460664d4 --- /dev/null +++ b/Task/Atomic-updates/Euphoria/atomic-updates.euphoria @@ -0,0 +1,69 @@ +function move(sequence s, integer amount, integer src, integer dest) + if src < 1 or src > length(s) or dest < 1 or dest > length(s) or amount < 0 then + return -1 + else + if src != dest and amount then + if amount > s[src] then + amount = s[src] + end if + s[src] -= amount + s[dest] += amount + end if + return s + end if +end function + +sequence buckets +buckets = repeat(100,10) + +procedure equalize() + integer i, j, diff + while 1 do + i = rand(length(buckets)) + j = rand(length(buckets)) + diff = buckets[i] - buckets[j] + if diff >= 2 then + buckets = move(buckets, floor(diff / 2), i, j) + elsif diff <= -2 then + buckets = move(buckets, -floor(diff / 2), j, i) + end if + task_yield() + end while +end procedure + +procedure redistribute() + integer i, j + while 1 do + i = rand(length(buckets)) + j = rand(length(buckets)) + if buckets[i] then + buckets = move(buckets, rand(buckets[i]), i, j) + end if + task_yield() + end while +end procedure + +function sum(sequence s) + integer sum + sum = 0 + for i = 1 to length(s) do + sum += s[i] + end for + return sum +end function + +atom task + +task = task_create(routine_id("equalize"), {}) +task_schedule(task, 1) + +task = task_create(routine_id("redistribute"), {}) +task_schedule(task, 1) + +task_schedule(0, {0.5, 0.5}) + +for i = 1 to 24 do + print(1,buckets) + printf(1," sum: %d\n", {sum(buckets)}) + task_yield() +end for diff --git a/Task/Average-loop-length/D/average-loop-length.d b/Task/Average-loop-length/D/average-loop-length.d new file mode 100644 index 0000000000..79d608cf6b --- /dev/null +++ b/Task/Average-loop-length/D/average-loop-length.d @@ -0,0 +1,44 @@ +import std.stdio, std.random, std.math, std.algorithm, std.range; + +real analytical(in int n) /*pure nothrow*/ { + real total = 0.0; + foreach (immutable k; 1 .. n + 1) { + immutable x = reduce!q{a * b}(1.0L, iota(n - k + 1, n + 1)) + * k ^^ 2; + total += x / ((cast(real)n) ^^ (k + 1)); + } + return total; +} + +size_t loopLength(size_t maxN)(in int size, ref Xorshift rng) { + __gshared bool[maxN + 1] seen; + seen[0 .. size + 1] = false; + int current = 1; + size_t steps = 0; + while (!seen[current]) { + seen[current] = true; + current = uniform(1, size + 1, rng); + steps++; + } + return steps; +} + +void main() { + enum maxN = 40; + enum nTrials = 300_000; + auto rng = Xorshift(unpredictableSeed); + writeln(" n average analytical (error)"); + writeln("=== ========= ============ =========="); + + foreach (immutable n; 1 .. maxN + 1) { + long total = 0; + foreach (immutable _; 0 .. nTrials) + total += loopLength!maxN(n, rng); + immutable average = total / cast(real)nTrials; + immutable an = analytical(n); + immutable percentError = abs(an - average) / an * 100; + immutable errorS = format("%2.4f", percentError); + writefln("%3d %9.5f %12.5f (%7s%%)", + n, average, an, errorS); + } +} diff --git a/Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-1.cpp b/Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-1.cpp new file mode 100644 index 0000000000..a01bbc264a --- /dev/null +++ b/Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-1.cpp @@ -0,0 +1,12 @@ +#include + +double mean(const std::vector& numbers) +{ + if (numbers.size() == 0) + return 0; + + double sum = 0; + for (std::vector::iterator i = numbers.begin(); i != numbers.end(); i++) + sum += *i; + return sum / numbers.size(); +} diff --git a/Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-2.cpp b/Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-2.cpp new file mode 100644 index 0000000000..9261987c15 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-2.cpp @@ -0,0 +1,9 @@ +#include +#include + +double mean(const std::vector& numbers) +{ + if (numbers.empty()) + return 0; + return std::accumulate(numbers.begin(), numbers.end(), 0.0) / numbers.size(); +} diff --git a/Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-3.cpp b/Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-3.cpp new file mode 100644 index 0000000000..4a038e9aad --- /dev/null +++ b/Task/Averages-Arithmetic-mean/C++/averages-arithmetic-mean-3.cpp @@ -0,0 +1,10 @@ +#include +#include + +template +double mean(Iterator begin, Iterator end) +{ + if (begin == end) + return 0; + return std::accumulate(begin, end, 0.0) / std::distance(begin, end); +} diff --git a/Task/Averages-Arithmetic-mean/C-sharp/averages-arithmetic-mean-1.cs b/Task/Averages-Arithmetic-mean/C-sharp/averages-arithmetic-mean-1.cs new file mode 100644 index 0000000000..a2617abdbc --- /dev/null +++ b/Task/Averages-Arithmetic-mean/C-sharp/averages-arithmetic-mean-1.cs @@ -0,0 +1,10 @@ +using System; +using System.Linq; + +class Program +{ + static void Main() + { + Console.WriteLine(new[] { 1, 2, 3 }.Average()); + } +} diff --git a/Task/Averages-Arithmetic-mean/C-sharp/averages-arithmetic-mean-2.cs b/Task/Averages-Arithmetic-mean/C-sharp/averages-arithmetic-mean-2.cs new file mode 100644 index 0000000000..98607c7f2c --- /dev/null +++ b/Task/Averages-Arithmetic-mean/C-sharp/averages-arithmetic-mean-2.cs @@ -0,0 +1,29 @@ +using System; + +class Program +{ + static void Main(string[] args) + { + double average = 0; + + double[] numArray = { 1, 2, 3, 4, 5 }; + average = Average(numArray); + + Console.WriteLine(average); // Output is 3 + + // Alternative use + average = Average(1, 2, 3, 4, 5); + + Console.WriteLine(average); // Output is still 3 + Console.ReadLine(); + } + + static double Average(params double[] nums) + { + double d = 0; + + foreach (double num in nums) + d += num; + return d / nums.Length; + } +} diff --git a/Task/Averages-Arithmetic-mean/Chef/averages-arithmetic-mean.chef b/Task/Averages-Arithmetic-mean/Chef/averages-arithmetic-mean.chef new file mode 100644 index 0000000000..44d849d157 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Chef/averages-arithmetic-mean.chef @@ -0,0 +1,31 @@ +Mean. + +Chef has no way to detect EOF, so rather than interpreting +some arbitrary number as meaning "end of input", this program +expects the first input to be the sample size. Pass in the samples +themselves as the other inputs. For example, if you wanted to +compute the mean of 10, 100, 47, you could pass in 3, 10, 100, and +47. To test the "zero-length vector" case, you need to pass in 0. + +Ingredients. +0 g Sample Size +0 g Counter +0 g Current Sample + +Method. +Take Sample Size from refrigerator. +Put Sample Size into mixing bowl. +Fold Counter into mixing bowl. +Put Current Sample into mixing bowl. +Loop Counter. +Take Current Sample from refrigerator. +Add Current Sample into mixing bowl. +Endloop Counter until looped. +If Sample Size. +Divide Sample Size into mixing bowl. +Put Counter into 2nd mixing bowl. +Fold Sample Size into 2nd mixing bowl. +Endif until ifed. +Pour contents of mixing bowl into baking dish. + +Serves 1. diff --git a/Task/Averages-Arithmetic-mean/Cobra/averages-arithmetic-mean.cobra b/Task/Averages-Arithmetic-mean/Cobra/averages-arithmetic-mean.cobra new file mode 100644 index 0000000000..8a9f4c9783 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Cobra/averages-arithmetic-mean.cobra @@ -0,0 +1,13 @@ +class Rosetta + def mean(ns as List) as number + if ns.count == 0 + return 0 + else + sum = 0.0 + for n in ns + sum += n + return sum / ns.count + + def main + print "mean of [[]] is [.mean(List())]" + print "mean of [[1,2,3,4]] is [.mean([1.0,2.0,3.0,4.0])]" diff --git a/Task/Averages-Arithmetic-mean/Common-Lisp/averages-arithmetic-mean-1.lisp b/Task/Averages-Arithmetic-mean/Common-Lisp/averages-arithmetic-mean-1.lisp new file mode 100644 index 0000000000..17116de0a0 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Common-Lisp/averages-arithmetic-mean-1.lisp @@ -0,0 +1,4 @@ +(defun mean (&rest sequence) + (if (null sequence) + nil + (/ (reduce #'+ sequence) (length sequence)))) diff --git a/Task/Averages-Arithmetic-mean/Common-Lisp/averages-arithmetic-mean-2.lisp b/Task/Averages-Arithmetic-mean/Common-Lisp/averages-arithmetic-mean-2.lisp new file mode 100644 index 0000000000..5d01ebabec --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Common-Lisp/averages-arithmetic-mean-2.lisp @@ -0,0 +1,4 @@ +(defun mean (list) + (unless (null list) + (/ (loop for i in list sum i) + (length list)))) diff --git a/Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-1.d b/Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-1.d new file mode 100644 index 0000000000..ebeaf8b920 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-1.d @@ -0,0 +1,23 @@ +import std.stdio; + +real mean(Range)(Range r) { + real sum = 0.0; + int count; + + foreach (item; r) { + sum += item; + count++; + } + + if (count == 0) + return 0.0; + else + return sum / count; +} + +void main() { + int[] data; + writeln("mean: ", data.mean()); + data = [3, 1, 4, 1, 5, 9]; + writeln("mean: ", data.mean()); +} diff --git a/Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-2.d b/Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-2.d new file mode 100644 index 0000000000..1fd514aa78 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-2.d @@ -0,0 +1,13 @@ +import std.stdio, std.algorithm, std.range; + +auto mean(Range)(Range r) { + auto len = r.walkLength(); + return len == 0 ? 0.0 : reduce!q{a + b}(0.0L, r) / len; +} + +void main() { + int[] data; + writeln("mean: ", data.mean()); + data = [3, 1, 4, 1, 5, 9]; + writeln("mean: ", data.mean()); +} diff --git a/Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-3.d b/Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-3.d new file mode 100644 index 0000000000..6d2aed0863 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/D/averages-arithmetic-mean-3.d @@ -0,0 +1,14 @@ +import std.stdio, std.conv, std.algorithm, std.math, std.traits; + +CommonType!(T, real) mean(T)(T[] n ...) if (isNumeric!(T)) { + alias CommonType!(T, real) E; + auto num = n.dup; + schwartzSort!(abs, "a > b")(num); + return reduce!q{a+b}(0.0L, map!(to!E)(num)) / max(1, num.length); +} + +void main() { + writefln("%8.5f", mean((int[]).init)); + writefln("%8.5f", mean( 0, 3, 1, 4, 1, 5, 9, 0)); + writefln("%8.5f", mean([-1e20, 3, 1, 4, 1, 5, 9, 1e20])); +} diff --git a/Task/Averages-Arithmetic-mean/Delphi/averages-arithmetic-mean.delphi b/Task/Averages-Arithmetic-mean/Delphi/averages-arithmetic-mean.delphi new file mode 100644 index 0000000000..bf6e34ccae --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Delphi/averages-arithmetic-mean.delphi @@ -0,0 +1,22 @@ +program AveragesArithmeticMean; + +{$APPTYPE CONSOLE} + +uses Types; + +function ArithmeticMean(aArray: TDoubleDynArray): Double; +var + lValue: Double; +begin + Result := 0; + + for lValue in aArray do + Result := Result + lValue; + if Result > 0 then + Result := Result / Length(aArray); +end; + +begin + Writeln(Mean(TDoubleDynArray.Create())); + Writeln(Mean(TDoubleDynArray.Create(1,2,3,4,5))); +end. diff --git a/Task/Averages-Arithmetic-mean/E/averages-arithmetic-mean.e b/Task/Averages-Arithmetic-mean/E/averages-arithmetic-mean.e new file mode 100644 index 0000000000..dc2da8d989 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/E/averages-arithmetic-mean.e @@ -0,0 +1,9 @@ +def meanOrZero(numbers) { + var count := 0 + var sum := 0 + for x in numbers { + sum += x + count += 1 + } + return sum / 1.max(count) +} diff --git a/Task/Averages-Arithmetic-mean/Elena/averages-arithmetic-mean.elena b/Task/Averages-Arithmetic-mean/Elena/averages-arithmetic-mean.elena new file mode 100644 index 0000000000..9eaa3d8ee3 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Elena/averages-arithmetic-mean.elena @@ -0,0 +1,50 @@ +#define std'basic'*. +#define std'patterns'*. +#define std'dictionary'*. + +#class MeanAction +{ + #field theValue. + #field theCount. + + #role Empty + { + #method save : aWriter = 0 save:aWriter. + + #method evaluate : aValue + [ + theValue := Real::0. + theCount := Integer::0. + + #shift. + + self evaluate:aValue. + ] + } + + #initializer + [ + #shift Empty. + ] + + #method save : aWriter = (theValue / theCount) save:aWriter. + + #method evaluate : aValue + [ + theCount += 1. + + theValue += aValue. + ] + + #method start : aPattern + [ + aPattern run:self. + + ^ Real64Value::self. + ] +} + +#symbol Program = +[ + 'program'Output << MeanAction start:Scan::(1, 2, 3, 4, 5, 6, 7, 8). +]. diff --git a/Task/Averages-Arithmetic-mean/Emacs-Lisp/averages-arithmetic-mean.l b/Task/Averages-Arithmetic-mean/Emacs-Lisp/averages-arithmetic-mean.l new file mode 100644 index 0000000000..a2c13c6f5e --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Emacs-Lisp/averages-arithmetic-mean.l @@ -0,0 +1,3 @@ + (defun mean (lst) + (/ (float (apply '+ lst)) (length lst))) + (mean '(1 2 3 4)) diff --git a/Task/Averages-Arithmetic-mean/Euphoria/averages-arithmetic-mean.euphoria b/Task/Averages-Arithmetic-mean/Euphoria/averages-arithmetic-mean.euphoria new file mode 100644 index 0000000000..80058ad511 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Euphoria/averages-arithmetic-mean.euphoria @@ -0,0 +1,16 @@ +function mean(sequence s) + atom sum + if length(s) = 0 then + return 0 + else + sum = 0 + for i = 1 to length(s) do + sum += s[i] + end for + return sum/length(s) + end if +end function + +sequence test +test = {1.0, 2.0, 5.0, -5.0, 9.5, 3.14159} +? mean(test) diff --git a/Task/Averages-Mean-angle/Common-Lisp/averages-mean-angle.lisp b/Task/Averages-Mean-angle/Common-Lisp/averages-mean-angle.lisp new file mode 100644 index 0000000000..2ca36ecd28 --- /dev/null +++ b/Task/Averages-Mean-angle/Common-Lisp/averages-mean-angle.lisp @@ -0,0 +1,17 @@ +(defun average (list) + (/ (reduce #'+ list) (length list))) + +(defun radians (angle) + (* pi 1/180 angle)) + +(defun degrees (angle) + (* 180 (/ 1 pi) angle)) + +(defun mean-angle (angles) + (let* ((angles (map 'list #'radians angles)) + (cosines (map 'list #'cos angles)) + (sines (map 'list #'sin angles))) + (degrees (atan (average sines) (average cosines))))) + +(loop for angles in '((350 10) (90 180 270 360) (10 20 30)) + do (format t "~&The mean angle of ~a is ~$°." angles (mean-angle angles))) diff --git a/Task/Averages-Mean-angle/D/averages-mean-angle.d b/Task/Averages-Mean-angle/D/averages-mean-angle.d new file mode 100644 index 0000000000..d635855a51 --- /dev/null +++ b/Task/Averages-Mean-angle/D/averages-mean-angle.d @@ -0,0 +1,16 @@ +import std.stdio, std.algorithm, std.complex; +import std.math: PI; + +auto radians(T)(in T d) pure nothrow { return d * PI / 180; } +auto degrees(T)(in T r) pure nothrow { return r * 180 / PI; } + +real meanAngle(T)(in T[] D) /*pure nothrow*/ { + immutable t = reduce!((a,d) => a + expi(radians(d)))(complex(0),D); + return (t / D.length).arg().degrees(); +} + +void main() { + foreach (angles; [[350, 10], [90, 180, 270, 360], [10, 20, 30]]) + writefln("The mean angle of %s is: %.2f degrees", + angles, meanAngle(angles)); +} diff --git a/Task/Averages-Mean-angle/Euler-Math-Toolbox/averages-mean-angle.euler b/Task/Averages-Mean-angle/Euler-Math-Toolbox/averages-mean-angle.euler new file mode 100644 index 0000000000..293e6eb62d --- /dev/null +++ b/Task/Averages-Mean-angle/Euler-Math-Toolbox/averages-mean-angle.euler @@ -0,0 +1,16 @@ +>function meanangle (a) ... +$ z=sum(exp(rad(a)*I)); +$ if z~=0 then error("Not meaningful"); +$ else return deg(arg(z)) +$ endfunction +>meanangle([350,10]) + 0 +>meanangle([90,180,270,360]) + Error : Not meaningful + + Error generated by error() command + + Error in function meanangle in line + if z~=0 then error("Not meaningful"); +>meanangle([10,20,30]) + 20 diff --git a/Task/Averages-Median/C++/averages-median.cpp b/Task/Averages-Median/C++/averages-median.cpp new file mode 100644 index 0000000000..5ca5dcd062 --- /dev/null +++ b/Task/Averages-Median/C++/averages-median.cpp @@ -0,0 +1,32 @@ +#include + +// inputs must be random-access iterators of doubles +// Note: this function modifies the input range +template +double median(Iterator begin, Iterator end) { + // this is middle for odd-length, and "upper-middle" for even length + Iterator middle = begin + (end - begin) / 2; + + // This function runs in O(n) on average, according to the standard + std::nth_element(begin, middle, end); + + if ((end - begin) % 2 != 0) { // odd length + return *middle; + } else { // even length + // the "lower middle" is the max of the lower half + Iterator lower_middle = std::max_element(begin, middle); + return (*middle + *lower_middle) / 2.0; + } +} + +#include + +int main() { + double a[] = {4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2}; + double b[] = {4.1, 7.2, 1.7, 9.3, 4.4, 3.2}; + + std::cout << median(a+0, a + sizeof(a)/sizeof(a[0])) << std::endl; // 4.4 + std::cout << median(b+0, b + sizeof(b)/sizeof(b[0])) << std::endl; // 4.25 + + return 0; +} diff --git a/Task/Averages-Median/Common-Lisp/averages-median.lisp b/Task/Averages-Median/Common-Lisp/averages-median.lisp new file mode 100644 index 0000000000..5ca82d5c47 --- /dev/null +++ b/Task/Averages-Median/Common-Lisp/averages-median.lisp @@ -0,0 +1,23 @@ +((defun select-nth (n list predicate) + "Select nth element in list, ordered by predicate, modifying list." + (do ((pivot (pop list)) + (ln 0) (left '()) + (rn 0) (right '())) + ((endp list) + (cond + ((< n ln) (select-nth n left predicate)) + ((eql n ln) pivot) + ((< n (+ ln rn 1)) (select-nth (- n ln 1) right predicate)) + (t (error "n out of range.")))) + (if (funcall predicate (first list) pivot) + (psetf list (cdr list) + (cdr list) left + left list + ln (1+ ln)) + (psetf list (cdr list) + (cdr list) right + right list + rn (1+ rn))))) + +(defun median (list predicate) + (select-nth (floor (length list) 2) list predicate)) diff --git a/Task/Averages-Median/D/averages-median.d b/Task/Averages-Median/D/averages-median.d new file mode 100644 index 0000000000..7cba44a690 --- /dev/null +++ b/Task/Averages-Median/D/averages-median.d @@ -0,0 +1,17 @@ +import std.stdio, std.algorithm; + +T median(T)(T[] nums) /*pure nothrow*/ { + nums.sort(); + if (nums.length & 1) + return nums[$ / 2]; + else + return (nums[$ / 2 - 1] + nums[$ / 2]) / 2.0; +} + +void main() { + auto a1 = [5.1, 2.6, 6.2, 8.8, 4.6, 4.1]; + writeln("Even median: ", median(a1)); + + auto a2 = [5.1, 2.6, 8.8, 4.6, 4.1]; + writeln("Odd median: ", median(a2)); +} diff --git a/Task/Averages-Median/Delphi/averages-median.delphi b/Task/Averages-Median/Delphi/averages-median.delphi new file mode 100644 index 0000000000..f48d1907e0 --- /dev/null +++ b/Task/Averages-Median/Delphi/averages-median.delphi @@ -0,0 +1,23 @@ +program AveragesMedian; + +{$APPTYPE CONSOLE} + +uses Generics.Collections, Types; + +function Median(aArray: TDoubleDynArray): Double; +var + lMiddleIndex: Integer; +begin + TArray.Sort(aArray); + + lMiddleIndex := Length(aArray) div 2; + if Odd(Length(aArray)) then + Result := aArray[lMiddleIndex] + else + Result := (aArray[lMiddleIndex - 1] + aArray[lMiddleIndex]) / 2; +end; + +begin + Writeln(Median(TDoubleDynArray.Create(4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2))); + Writeln(Median(TDoubleDynArray.Create(4.1, 7.2, 1.7, 9.3, 4.4, 3.2))); +end. diff --git a/Task/Averages-Median/E/averages-median-1.e b/Task/Averages-Median/E/averages-median-1.e new file mode 100644 index 0000000000..cebcb97e9b --- /dev/null +++ b/Task/Averages-Median/E/averages-median-1.e @@ -0,0 +1,11 @@ +def median(list) { + def sorted := list.sort() + def count := sorted.size() + def mid1 := count // 2 + def mid2 := (count - 1) // 2 + if (mid1 == mid2) { # avoid inexact division + return sorted[mid1] + } else { + return (sorted[mid1] + sorted[mid2]) / 2 + } +} diff --git a/Task/Averages-Median/E/averages-median-2.e b/Task/Averages-Median/E/averages-median-2.e new file mode 100644 index 0000000000..8c6b1f8c05 --- /dev/null +++ b/Task/Averages-Median/E/averages-median-2.e @@ -0,0 +1,5 @@ +? median([1,9,2]) +# value: 2 + +? median([1,9,2,4]) +# value: 3.0 diff --git a/Task/Averages-Median/Elena/averages-median.elena b/Task/Averages-Median/Elena/averages-median.elena new file mode 100644 index 0000000000..bd4c4ed0da --- /dev/null +++ b/Task/Averages-Median/Elena/averages-median.elena @@ -0,0 +1,27 @@ +#define std'dictionary'*. +#define std'math'*. +#define std'routines'*. + +#symbol Sorted : anArray + = anArray clone ~esort run: aPair = (aPair former < aPair later). + +#symbol Median : anArray = +[ + #var aSorted := Sorted::anArray. + + #var aLen := aSorted count. + #if aLen + == 0 ? [ ^ nil. ] + | [ + #var aMiddleIndex := aLen / 2. + #if aLen~eops modulus:2 + == 0 ? [ ^ aSorted@aMiddleIndex. ] + | [ ^ (aSorted@(aMiddleIndex - 1) + aSorted@aMiddleIndex) / 2. ]. + ]. +]. + +#symbol Program = +[ + 'program'output << Median::(4.1r, 5.6r, 7.2r, 1.7r, 9.3r, 4.4r, 3.2r) << "%n". + 'program'output << Median::(4.1r, 7.2r, 1.7r, 9.3r, 4.4r, 3.2r) << "%n". +]. diff --git a/Task/Averages-Median/Euler-Math-Toolbox/averages-median.euler b/Task/Averages-Median/Euler-Math-Toolbox/averages-median.euler new file mode 100644 index 0000000000..d675ade809 --- /dev/null +++ b/Task/Averages-Median/Euler-Math-Toolbox/averages-median.euler @@ -0,0 +1,50 @@ +>type median + function median (x, v: none, p) + + ## Default for v : none + ## Default for p : 0.5 + + m=rows(x); + if m>1 then + y=zeros(m,1); + loop 1 to m; + y[#]=median(x[#],v,p); + end; + return y; + else + if v<>none then + {xs,i}=sort(x); vsh=v[i]; + n=cols(xs); + ns=sum(vsh); + i=1+p*(ns-1); i0=floor(i); + vs=cumsum(vsh); + loop 1 to n + if vs[#]>i0 then + return xs[#]; + elseif vs[#]+1>i0 then + k=#+1; + repeat; + if vsh[k]>0 or k>n then break; endif; + k=k+1; + end; + return (1-(i-i0))*xs[#]+(i-i0)*xs[k]+0; + endif; + end; + return xs[n]; + else + xs=sort(x); + n=cols(x); + i=1+p*(n-1); i0=floor(i); + if i0==n then return xs[n]; endif; + return (i-i0)*xs[i+1]+(1-(i-i0))*xs[i]; + endif; + endif; + endfunction +>median(1:10) + 5.5 +>median(1:9) + 5 +>median(1:10,p=0.2) + 2.8 +>0.2*10+0.8*1 + 2.8 diff --git a/Task/Averages-Median/Euphoria/averages-median.euphoria b/Task/Averages-Median/Euphoria/averages-median.euphoria new file mode 100644 index 0000000000..79839c9c20 --- /dev/null +++ b/Task/Averages-Median/Euphoria/averages-median.euphoria @@ -0,0 +1,25 @@ +function median(sequence s) + atom min,k + -- Selection sort of half+1 + for i = 1 to length(s)/2+1 do + min = s[i] + k = 0 + for j = i+1 to length(s) do + if s[j] < min then + min = s[j] + k = j + end if + end for + if k then + s[k] = s[i] + s[i] = min + end if + end for + if remainder(length(s),2) = 0 then + return (s[$/2]+s[$/2+1])/2 + else + return s[$/2+1] + end if +end function + +? median({ 4.4, 2.3, -1.7, 7.5, 6.6, 0.0, 1.9, 8.2, 9.3, 4.5 }) diff --git a/Task/Averages-Mode/C++/averages-mode.cpp b/Task/Averages-Mode/C++/averages-mode.cpp new file mode 100644 index 0000000000..93eba2da86 --- /dev/null +++ b/Task/Averages-Mode/C++/averages-mode.cpp @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include + +// helper struct +template struct referring +{ + referring(T const& t): value(t) {} + template + bool operator()(std::pair const& p) const + { + return *p.first == value; + } + T const& value; +}; + +// requires: +// FwdIterator is a ForwardIterator +// The value_type of FwdIterator is EqualityComparable +// OutIterator is an output iterator +// the value_type of FwdIterator is convertible to the value_type of OutIterator +// [first, last) is a valid range +// provides: +// the mode is written to result +template + void mode(FwdIterator first, FwdIterator last, OutIterator result) +{ + typedef typename std::iterator_traits::value_type value_type; + typedef std::list > count_type; + typedef typename count_type::iterator count_iterator; + + // count elements + count_type counts; + + while (first != last) + { + count_iterator element = std::find_if(counts.begin(), counts.end(), + referring(*first)); + if (element == counts.end()) + counts.push_back(std::make_pair(first, 1)); + else + ++element->second; + ++first; + } + + // find maximum + int max = 0; + for (count_iterator i = counts.begin(); i != counts.end(); ++i) + if (i->second > max) + max = i->second; + + // copy corresponding elements to output sequence + for (count_iterator i = counts.begin(); i != counts.end(); ++i) + if (i->second == max) + *result++ = *i->first; +} + +// example usage +int main() +{ + int values[] = { 1, 2, 3, 1, 2, 4, 2, 5, 2, 3, 3, 1, 3, 6 }; + median(values, values + sizeof(values)/sizeof(int), + std::ostream_iterator(std::cout, " ")); + std::cout << std::endl; + return 0; +} diff --git a/Task/Averages-Mode/D/averages-mode.d b/Task/Averages-Mode/D/averages-mode.d new file mode 100644 index 0000000000..e20dd5ad3c --- /dev/null +++ b/Task/Averages-Mode/D/averages-mode.d @@ -0,0 +1,17 @@ +import std.stdio, std.algorithm, std.array; + +T[] mode(T)(T[] items) /*pure nothrow*/ { + int[T] aa; + foreach (item; items) + aa[item]++; + int m = aa.byValue.reduce!max(); + return aa.byKey.filter!(k => aa[k] == m)().array(); +} + +void main() { + auto data = [1, 2, 3, 1, 2, 4, 2, 5, 3, 3, 1, 3, 6]; + writeln("Mode: ", data.mode()); + + data ~= 2; + writeln("Mode: ", data.mode()); +} diff --git a/Task/Averages-Mode/E/averages-mode-1.e b/Task/Averages-Mode/E/averages-mode-1.e new file mode 100644 index 0000000000..1d258d304c --- /dev/null +++ b/Task/Averages-Mode/E/averages-mode-1.e @@ -0,0 +1,9 @@ +pragma.enable("accumulator") +def mode(values) { + def counts := [].asMap().diverge() + var maxCount := 0 + for v in values { + maxCount max= (counts[v] := counts.fetch(v, fn{0}) + 1) + } + return accum [].asSet() for v => ==maxCount in counts { _.with(v) } +} diff --git a/Task/Averages-Mode/E/averages-mode-2.e b/Task/Averages-Mode/E/averages-mode-2.e new file mode 100644 index 0000000000..2d6d12195d --- /dev/null +++ b/Task/Averages-Mode/E/averages-mode-2.e @@ -0,0 +1,2 @@ +? mode([1,1,2,2,3,3,4,4,4,5,5,6,6,7,8,8,9,9,0,0,0]) +# value: [4, 0].asSet() diff --git a/Task/Averages-Mode/E/averages-mode-3.e b/Task/Averages-Mode/E/averages-mode-3.e new file mode 100644 index 0000000000..5ba126f485 --- /dev/null +++ b/Task/Averages-Mode/E/averages-mode-3.e @@ -0,0 +1,3 @@ + def newCount := counts.fetch(v, fn { 0 }) + 1 + counts[v] := newCount + maxCount := maxCount.max(newCount) diff --git a/Task/Averages-Mode/Elena/averages-mode.elena b/Task/Averages-Mode/Elena/averages-mode.elena new file mode 100644 index 0000000000..dd9e1d2626 --- /dev/null +++ b/Task/Averages-Mode/Elena/averages-mode.elena @@ -0,0 +1,44 @@ +#define std'dictionary'*. +#define std'basic'*. +#define std'patterns'*. +#define std'routines'*. +#define std'collections'*. + +#subject mode. + +#symbol ModeValue : anArray = +[ + #var aCountMap := Dictionary. + Scan::anArray run: anItem = + [ + #if aCountMap@anItem += 1 + | [ + aCountMap append &dictionary_key:anItem &content:Integer::1. + ]. + ]. + + aCountMap~esort run: aPair = (aPair former > aPair later). + + #var aResult := List. + + #var aMax := aCountMap first_item content. + Scan::aCountMap run: anItem = + [ + #if (aMax == anItem)? + [ aResult += anItem dictionary_key. ]. + ]. + + ^ aResult. +]. + +#symbol Program = +[ + #var anArray1 := (1, 1, 2, 4, 4). + #var anArray2 := (1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17). + + #var aMode1 := ModeValue::anArray1. + #var aMode2 := ModeValue::anArray2. + + 'program'output << "mode of (" << anArray1 << ") is (" << aMode1 << ")%n". + 'program'output << "mode of (" << anArray2 << ") is (" << aMode2 << ")%n". +]. diff --git a/Task/Averages-Mode/Euphoria/averages-mode.euphoria b/Task/Averages-Mode/Euphoria/averages-mode.euphoria new file mode 100644 index 0000000000..7b4cfce394 --- /dev/null +++ b/Task/Averages-Mode/Euphoria/averages-mode.euphoria @@ -0,0 +1,39 @@ +include misc.e + +function mode(sequence s) + sequence uniques, counts, modes + integer j,max + uniques = {} + counts = {} + for i = 1 to length(s) do + j = find(s[i], uniques) + if j then + counts[j] += 1 + else + uniques = append(uniques, s[i]) + counts = append(counts, 1) + end if + end for + + max = counts[1] + for i = 2 to length(counts) do + if counts[i] > max then + max = counts[i] + end if + end for + + j = 1 + modes = {} + while j <= length(s) do + j = find_from(max, counts, j) + if j = 0 then + exit + end if + modes = append(modes, uniques[j]) + j += 1 + end while + return modes +end function + +constant s = { 1, "blue", 2, 7.5, 5, "green", "red", 5, 2, "blue", "white" } +pretty_print(1,mode(s),{3}) diff --git a/Task/Averages-Pythagorean-means/C++/averages-pythagorean-means.cpp b/Task/Averages-Pythagorean-means/C++/averages-pythagorean-means.cpp new file mode 100644 index 0000000000..83187ef29e --- /dev/null +++ b/Task/Averages-Pythagorean-means/C++/averages-pythagorean-means.cpp @@ -0,0 +1,25 @@ +#include +#include +#include +#include +#include + +double toInverse ( int i ) { + return 1.0 / i ; +} + +int main( ) { + std::vector numbers ; + for ( int i = 1 ; i < 11 ; i++ ) + numbers.push_back( i ) ; + double arithmetic_mean = std::accumulate( numbers.begin( ) , numbers.end( ) , 0 ) / 10.0 ; + double geometric_mean = + pow( std::accumulate( numbers.begin( ) , numbers.end( ) , 1 , std::multiplies( ) ), 0.1 ) ; + std::vector inverses ; + inverses.resize( numbers.size( ) ) ; + std::transform( numbers.begin( ) , numbers.end( ) , inverses.begin( ) , toInverse ) ; + double harmonic_mean = 10 / std::accumulate( inverses.begin( ) , inverses.end( ) , 0.0 ); //initial value of accumulate must be a double! + std::cout << "The arithmetic mean is " << arithmetic_mean << " , the geometric mean " + << geometric_mean << " and the harmonic mean " << harmonic_mean << " !\n" ; + return 0 ; +} diff --git a/Task/Averages-Pythagorean-means/Common-Lisp/averages-pythagorean-means.lisp b/Task/Averages-Pythagorean-means/Common-Lisp/averages-pythagorean-means.lisp new file mode 100644 index 0000000000..5c68e27e4e --- /dev/null +++ b/Task/Averages-Pythagorean-means/Common-Lisp/averages-pythagorean-means.lisp @@ -0,0 +1,23 @@ +(defun generic-mean (nums reduce-op final-op) + (funcall final-op (reduce reduce-op nums))) + +(defun a-mean (nums) + (generic-mean nums #'+ (lambda (x) (/ x (length nums))))) + +(defun g-mean (nums) + (generic-mean nums #'* (lambda (x) (expt x (/ 1 (length nums)))))) + +(defun h-mean (nums) + (generic-mean nums + (lambda (x y) (+ x + (/ 1 y))) + (lambda (x) (/ (length nums) x)))) + +(let ((numbers (loop for i from 1 to 10 collect i))) + (let ((a-mean (a-mean numbers)) + (g-mean (g-mean numbers)) + (h-mean (h-mean numbers))) + (assert (> a-mean g-mean h-mean)) + (format t "a-mean ~a~%" a-mean) + (format t "g-mean ~a~%" g-mean) + (format t "h-mean ~a~%" h-mean))) diff --git a/Task/Averages-Pythagorean-means/D/averages-pythagorean-means.d b/Task/Averages-Pythagorean-means/D/averages-pythagorean-means.d new file mode 100644 index 0000000000..9a7d0c3632 --- /dev/null +++ b/Task/Averages-Pythagorean-means/D/averages-pythagorean-means.d @@ -0,0 +1,19 @@ +import std.stdio, std.algorithm, std.range, std.functional; + +auto amean(T)(T data) { + return data.reduce!q{a + b}() / data.length; +} + +auto gmean(T)(T data) { + return data.reduce!q{a * b}() ^^ (1.0 / data.length); +} + +auto hmean(T)(T data) { + return data.length / data.reduce!q{1.0/a + b}(); +} + +void main() { + auto m = adjoin!(hmean, gmean, amean)(iota(1.0L, 11.0L)); + writefln("%.19f %.19f %.19f", m.tupleof); + assert([m.tupleof].isSorted()); +} diff --git a/Task/Averages-Pythagorean-means/Delphi/averages-pythagorean-means.delphi b/Task/Averages-Pythagorean-means/Delphi/averages-pythagorean-means.delphi new file mode 100644 index 0000000000..af74738dc6 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Delphi/averages-pythagorean-means.delphi @@ -0,0 +1,50 @@ +program AveragesPythagoreanMeans; + +{$APPTYPE CONSOLE} + +uses Types, Math; + +function ArithmeticMean(aArray: TDoubleDynArray): Double; +var + lValue: Double; +begin + Result := 0; + for lValue in aArray do + Result := Result + lValue; + if Result > 0 then + Result := Result / Length(aArray); +end; + +function GeometricMean(aArray: TDoubleDynArray): Double; +var + lValue: Double; +begin + Result := 1; + for lValue in aArray do + Result := Result * lValue; + Result := Power(Result, 1 / Length(aArray)); +end; + +function HarmonicMean(aArray: TDoubleDynArray): Double; +var + lValue: Double; +begin + Result := 0; + for lValue in aArray do + Result := Result + 1 / lValue; + Result := Length(aArray) / Result; +end; + +var + lSourceArray: TDoubleDynArray; + AMean, GMean, HMean: Double; +begin + lSourceArray := TDoubleDynArray.Create(1,2,3,4,5,6,7,8,9,10); + AMean := ArithmeticMean(lSourceArray)); + GMean := GeometricMean(lSourceArray)); + HMean := HarmonicMean(lSourceArray)); + if (AMean >= GMean) and (GMean >= HMean) then + Writeln(AMean, " ≥ ", GMean, " ≥ ", HMean) + else + writeln("Error!"); +end. diff --git a/Task/Averages-Pythagorean-means/E/averages-pythagorean-means-1.e b/Task/Averages-Pythagorean-means/E/averages-pythagorean-means-1.e new file mode 100644 index 0000000000..48fab9b2ec --- /dev/null +++ b/Task/Averages-Pythagorean-means/E/averages-pythagorean-means-1.e @@ -0,0 +1,15 @@ +def makeMean(base, include, finish) { + return def mean(numbers) { + var count := 0 + var acc := base + for x in numbers { + acc := include(acc, x) + count += 1 + } + return finish(acc, count) + } +} + +def A := makeMean(0, fn b,x { b+x }, fn acc,n { acc / n }) +def G := makeMean(1, fn b,x { b*x }, fn acc,n { acc ** (1/n) }) +def H := makeMean(0, fn b,x { b+1/x }, fn acc,n { n / acc }) diff --git a/Task/Averages-Pythagorean-means/E/averages-pythagorean-means-2.e b/Task/Averages-Pythagorean-means/E/averages-pythagorean-means-2.e new file mode 100644 index 0000000000..35d050eeba --- /dev/null +++ b/Task/Averages-Pythagorean-means/E/averages-pythagorean-means-2.e @@ -0,0 +1,8 @@ +? A(1..10) +# value: 5.5 + +? G(1..10) +# value: 4.528728688116765 + +? H(1..10) +# value: 3.414171521474055 diff --git a/Task/Averages-Pythagorean-means/Euler-Math-Toolbox/averages-pythagorean-means-1.euler b/Task/Averages-Pythagorean-means/Euler-Math-Toolbox/averages-pythagorean-means-1.euler new file mode 100644 index 0000000000..f3bf0365c6 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Euler-Math-Toolbox/averages-pythagorean-means-1.euler @@ -0,0 +1,7 @@ +>function A(x) := mean(x) +>function G(x) := exp(mean(log(x))) +>function H(x) := 1/mean(1/x) +>x=1:10; A(x), G(x), H(x) + 5.5 + 4.52872868812 + 3.41417152147 diff --git a/Task/Averages-Pythagorean-means/Euler-Math-Toolbox/averages-pythagorean-means-2.euler b/Task/Averages-Pythagorean-means/Euler-Math-Toolbox/averages-pythagorean-means-2.euler new file mode 100644 index 0000000000..29b119c763 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Euler-Math-Toolbox/averages-pythagorean-means-2.euler @@ -0,0 +1 @@ +>function G(x) := prod(x)^(1/length(x)) diff --git a/Task/Averages-Pythagorean-means/Euphoria/averages-pythagorean-means.euphoria b/Task/Averages-Pythagorean-means/Euphoria/averages-pythagorean-means.euphoria new file mode 100644 index 0000000000..f4d6e0d812 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Euphoria/averages-pythagorean-means.euphoria @@ -0,0 +1,52 @@ +function arithmetic_mean(sequence s) + atom sum + if length(s) = 0 then + return 0 + else + sum = 0 + for i = 1 to length(s) do + sum += s[i] + end for + return sum/length(s) + end if +end function + +function geometric_mean(sequence s) + atom p + p = 1 + for i = 1 to length(s) do + p *= s[i] + end for + return power(p,1/length(s)) +end function + +function harmonic_mean(sequence s) + atom sum + if length(s) = 0 then + return 0 + else + sum = 0 + for i = 1 to length(s) do + sum += 1/s[i] + end for + return length(s) / sum + end if +end function + +function true_or_false(atom x) + if x then + return "true" + else + return "false" + end if +end function + +constant s = {1,2,3,4,5,6,7,8,9,10} +constant arithmetic = arithmetic_mean(s), + geometric = geometric_mean(s), + harmonic = harmonic_mean(s) +printf(1,"Arithmetic: %g\n", arithmetic) +printf(1,"Geometric: %g\n", geometric) +printf(1,"Harmonic: %g\n", harmonic) +printf(1,"Arithmetic>=Geometric>=Harmonic: %s\n", + {true_or_false(arithmetic>=geometric and geometric>=harmonic)}) diff --git a/Task/Averages-Root-mean-square/C++/averages-root-mean-square.cpp b/Task/Averages-Root-mean-square/C++/averages-root-mean-square.cpp new file mode 100644 index 0000000000..7a9059968a --- /dev/null +++ b/Task/Averages-Root-mean-square/C++/averages-root-mean-square.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +int main( ) { + std::vector numbers ; + for ( int i = 1 ; i < 11 ; i++ ) + numbers.push_back( i ) ; + double meansquare = sqrt ( ( std::inner_product( numbers.begin(), numbers.end(), numbers.begin(), 0 ))/10.0 ); + std::cout << "The quadratic mean of the numbers 1 .. 10 is " << meansquare << " !\n" ; + return 0 ; +} diff --git a/Task/Averages-Root-mean-square/Common-Lisp/averages-root-mean-square.lisp b/Task/Averages-Root-mean-square/Common-Lisp/averages-root-mean-square.lisp new file mode 100644 index 0000000000..dd91324d1e --- /dev/null +++ b/Task/Averages-Root-mean-square/Common-Lisp/averages-root-mean-square.lisp @@ -0,0 +1,5 @@ +(loop for x from 1 to 10 + for xx = (* x x) + for n from 1 + summing xx into xx-sum + finally (return (sqrt (/ xx-sum n))))) diff --git a/Task/Averages-Root-mean-square/D/averages-root-mean-square.d b/Task/Averages-Root-mean-square/D/averages-root-mean-square.d new file mode 100644 index 0000000000..c3381d5279 --- /dev/null +++ b/Task/Averages-Root-mean-square/D/averages-root-mean-square.d @@ -0,0 +1,9 @@ +import std.stdio, std.math, std.algorithm, std.range; + +real rms(R)(R d) { + return sqrt(reduce!((a, b) => a + b * b)(d) / cast(real)d.length); +} + +void main() { + writefln("%.19f", rms(iota(1, 11))); +} diff --git a/Task/Averages-Root-mean-square/Delphi/averages-root-mean-square.delphi b/Task/Averages-Root-mean-square/Delphi/averages-root-mean-square.delphi new file mode 100644 index 0000000000..dd02c72751 --- /dev/null +++ b/Task/Averages-Root-mean-square/Delphi/averages-root-mean-square.delphi @@ -0,0 +1,22 @@ +program AveragesMeanSquare; + +{$APPTYPE CONSOLE} + +uses Types; + +function MeanSquare(aArray: TDoubleDynArray): Double; +var + lValue: Double; +begin + Result := 0; + + for lValue in aArray do + Result := Result + (lValue * lValue); + if Result > 0 then + Result := Sqrt(Result / Length(aArray)); +end; + +begin + Writeln(MeanSquare(TDoubleDynArray.Create())); + Writeln(MeanSquare(TDoubleDynArray.Create(1,2,3,4,5,6,7,8,9,10))); +end. diff --git a/Task/Averages-Root-mean-square/E/averages-root-mean-square-1.e b/Task/Averages-Root-mean-square/E/averages-root-mean-square-1.e new file mode 100644 index 0000000000..ae3ada1043 --- /dev/null +++ b/Task/Averages-Root-mean-square/E/averages-root-mean-square-1.e @@ -0,0 +1,13 @@ +def makeMean(base, include, finish) { + return def mean(numbers) { + var count := 0 + var acc := base + for x in numbers { + acc := include(acc, x) + count += 1 + } + return finish(acc, count) + } +} + +def RMS := makeMean(0, fn b,x { b+x**2 }, fn acc,n { (acc/n).sqrt() }) diff --git a/Task/Averages-Root-mean-square/E/averages-root-mean-square-2.e b/Task/Averages-Root-mean-square/E/averages-root-mean-square-2.e new file mode 100644 index 0000000000..e9c1aaf8b8 --- /dev/null +++ b/Task/Averages-Root-mean-square/E/averages-root-mean-square-2.e @@ -0,0 +1,2 @@ +? RMS(1..10) +# value: 6.2048368229954285 diff --git a/Task/Averages-Root-mean-square/Euphoria/averages-root-mean-square.euphoria b/Task/Averages-Root-mean-square/Euphoria/averages-root-mean-square.euphoria new file mode 100644 index 0000000000..7ad2ff66b8 --- /dev/null +++ b/Task/Averages-Root-mean-square/Euphoria/averages-root-mean-square.euphoria @@ -0,0 +1,14 @@ +function rms(sequence s) + atom sum + if length(s) = 0 then + return 0 + end if + sum = 0 + for i = 1 to length(s) do + sum += power(s[i],2) + end for + return sqrt(sum/length(s)) +end function + +constant s = {1,2,3,4,5,6,7,8,9,10} +? rms(s) diff --git a/Task/Averages-Simple-moving-average/C++/averages-simple-moving-average.cpp b/Task/Averages-Simple-moving-average/C++/averages-simple-moving-average.cpp new file mode 100644 index 0000000000..e1b1e97c82 --- /dev/null +++ b/Task/Averages-Simple-moving-average/C++/averages-simple-moving-average.cpp @@ -0,0 +1,101 @@ +#include +#include +#include + +using std::cout; +using std::endl; + +class SMA { +public: + SMA(unsigned int period) : + period(period), window(new double[period]), head(NULL), tail(NULL), + total(0) { + assert(period >= 1); + } + ~SMA() { + delete[] window; + } + + // Adds a value to the average, pushing one out if nescessary + void add(double val) { + // Special case: Initialization + if (head == NULL) { + head = window; + *head = val; + tail = head; + inc(tail); + total = val; + return; + } + + // Were we already full? + if (head == tail) { + // Fix total-cache + total -= *head; + // Make room + inc(head); + } + + // Write the value in the next spot. + *tail = val; + inc(tail); + + // Update our total-cache + total += val; + } + + // Returns the average of the last P elements added to this SMA. + // If no elements have been added yet, returns 0.0 + double avg() const { + ptrdiff_t size = this->size(); + if (size == 0) { + return 0; // No entries => 0 average + } + return total / (double) size; // Cast to double for floating point arithmetic + } + +private: + unsigned int period; + double * window; // Holds the values to calculate the average of. + + // Logically, head is before tail + double * head; // Points at the oldest element we've stored. + double * tail; // Points at the newest element we've stored. + + double total; // Cache the total so we don't sum everything each time. + + // Bumps the given pointer up by one. + // Wraps to the start of the array if needed. + void inc(double * & p) { + if (++p >= window + period) { + p = window; + } + } + + // Returns how many numbers we have stored. + ptrdiff_t size() const { + if (head == NULL) + return 0; + if (head == tail) + return period; + return (period + tail - head) % period; + } +}; + +int main(int argc, char * * argv) { + SMA foo(3); + SMA bar(5); + + int data[] = { 1, 2, 3, 4, 5, 5, 4, 3, 2, 1 }; + for (int * itr = data; itr < data + 10; itr++) { + foo.add(*itr); + cout << "Added " << *itr << " avg: " << foo.avg() << endl; + } + cout << endl; + for (int * itr = data; itr < data + 10; itr++) { + bar.add(*itr); + cout << "Added " << *itr << " avg: " << bar.avg() << endl; + } + + return 0; +} diff --git a/Task/Averages-Simple-moving-average/Common-Lisp/averages-simple-moving-average.lisp b/Task/Averages-Simple-moving-average/Common-Lisp/averages-simple-moving-average.lisp new file mode 100644 index 0000000000..214b4225cd --- /dev/null +++ b/Task/Averages-Simple-moving-average/Common-Lisp/averages-simple-moving-average.lisp @@ -0,0 +1,11 @@ +(defun simple-moving-average (period &aux + (sum 0) (count 0) (values (make-list period)) (pointer values)) + (setf (rest (last values)) values) ; construct circularity + (lambda (n) + (when (first pointer) + (decf sum (first pointer))) ; subtract old value + (incf sum n) ; add new value + (incf count) + (setf (first pointer) n) + (setf pointer (rest pointer)) ; advance pointer + (/ sum (min count period)))) diff --git a/Task/Averages-Simple-moving-average/D/averages-simple-moving-average-1.d b/Task/Averages-Simple-moving-average/D/averages-simple-moving-average-1.d new file mode 100644 index 0000000000..5b2f4e374b --- /dev/null +++ b/Task/Averages-Simple-moving-average/D/averages-simple-moving-average-1.d @@ -0,0 +1,25 @@ +import std.stdio, std.traits, std.algorithm; + +auto sma(T, int period)() { + T[period] data = 0; // D FP are default-initialized to NaN + T sum = 0; + int index, nfilled; + + // return (in T v) nothrow { + return delegate (in T v) nothrow { + sum += -data[index] + v; + data[index] = v; + index = (index + 1) % period; + nfilled = min(period, nfilled + 1); + return cast(CommonType!(T, float))sum / nfilled; + }; +} + +void main() { + auto s3 = sma!(int, 3)(); + auto s5 = sma!(double, 5)(); + + foreach (e; [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) + writefln("Added %d, sma(3) = %f, sma(5) = %f", + e, s3(e), s5(e)); +} diff --git a/Task/Averages-Simple-moving-average/D/averages-simple-moving-average-2.d b/Task/Averages-Simple-moving-average/D/averages-simple-moving-average-2.d new file mode 100644 index 0000000000..0464bcd31b --- /dev/null +++ b/Task/Averages-Simple-moving-average/D/averages-simple-moving-average-2.d @@ -0,0 +1,24 @@ +import std.stdio, std.traits, std.algorithm; + +struct SMA(T, int period) { + T[period] data = 0; + T sum = 0; + int index, nfilled; + + auto opCall(in T v) pure nothrow { + sum += -data[index] + v; + data[index] = v; + index = (index + 1) % period; + nfilled = min(period, nfilled + 1); + return cast(CommonType!(T, float))sum / nfilled; + } +} + +void main() { + SMA!(int, 3) s3; + SMA!(double, 5) s5; + + foreach (e; [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) + writefln("Added %d, sma(3) = %f, sma(5) = %f", + e, s3(e), s5(e)); +} diff --git a/Task/Averages-Simple-moving-average/E/averages-simple-moving-average-1.e b/Task/Averages-Simple-moving-average/E/averages-simple-moving-average-1.e new file mode 100644 index 0000000000..93f859c12d --- /dev/null +++ b/Task/Averages-Simple-moving-average/E/averages-simple-moving-average-1.e @@ -0,0 +1,22 @@ +pragma.enable("accumulator") +def makeMovingAverage(period) { + def values := ([null] * period).diverge() + var index := 0 + var count := 0 + + def insert(v) { + values[index] := v + index := (index + 1) %% period + count += 1 + } + + /** Returns the simple moving average of the inputs so far, or null if there + have been no inputs. */ + def average() { + if (count > 0) { + return accum 0 for x :notNull in values { _ + x } / count.min(period) + } + } + + return [insert, average] +} diff --git a/Task/Averages-Simple-moving-average/E/averages-simple-moving-average-2.e b/Task/Averages-Simple-moving-average/E/averages-simple-moving-average-2.e new file mode 100644 index 0000000000..a9d37dc50c --- /dev/null +++ b/Task/Averages-Simple-moving-average/E/averages-simple-moving-average-2.e @@ -0,0 +1,33 @@ +? for period in [3, 5] { +> def [insert, average] := makeMovingAverage(period) +> println(`Period $period:`) +> for value in [1,2,3,4,5,5,4,3,2,1] { +> insert(value) +> println(value, "\t", average()) +> } +> println() +> } + +Period 3: +1 1.0 +2 1.5 +3 2.0 +4 3.0 +5 4.0 +5 4.666666666666667 +4 4.666666666666667 +3 4.0 +2 3.0 +1 2.0 + +Period 5: +1 1.0 +2 1.5 +3 2.0 +4 2.5 +5 3.0 +5 3.8 +4 4.2 +3 4.2 +2 3.8 +1 3.0 diff --git a/Task/Averages-Simple-moving-average/Elena/averages-simple-moving-average.elena b/Task/Averages-Simple-moving-average/Elena/averages-simple-moving-average.elena new file mode 100644 index 0000000000..f377becd21 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Elena/averages-simple-moving-average.elena @@ -0,0 +1,54 @@ +#define std'dictionary'*. +#define std'basic'*. +#define std'collections'*. +#define std'patterns'*. + +#class ESMARole +{ + #field thePeriod. + + #initializer : aPeriod + [ + thePeriod := aPeriod. + ] + + #method + aNumber + [ + self += NewInt32Value::aNumber. + + #if (self count > thePeriod)? + [ + self first_item'reduce. + ]. + + #var aCount := self count. + #if (aCount == 0)? + [ ^ 0. ]. + + #var aSum := Summing::Real::0 start:Scan::self. + + ^ aSum / aCount. + ] +} + +#symbol SMA : aPeriod = __wrap(ESMARole::aPeriod, List). + +// --- Program --- + +#symbol Program = +[ + #var SMA3 := SMA::3. + #var SMA5 := SMA::5. + + loop &&from:1 &to:5 run: i = + [ + 'program'output << "sma3 + " << i << " = " << SMA3 + i. + 'program'output << ",sma5 + " << i << " = " << SMA5 + i << "%n". + ]. + + loop &&from:5 &to:1 &step:-1 run: i = + [ + 'program'output << "sma3 + " << i << " = " << SMA3 + i. + 'program'output << ",sma5 + " << i << " = " << SMA5 + i << "%n". + ]. +]. diff --git a/Task/Averages-Simple-moving-average/Euler-Math-Toolbox/averages-simple-moving-average-1.euler b/Task/Averages-Simple-moving-average/Euler-Math-Toolbox/averages-simple-moving-average-1.euler new file mode 100644 index 0000000000..be5d1c7a9a --- /dev/null +++ b/Task/Averages-Simple-moving-average/Euler-Math-Toolbox/averages-simple-moving-average-1.euler @@ -0,0 +1,3 @@ +>n=1000; m=100; x=random(1,n); +>x10=fold(x,ones(1,m)/m); +>x10=fftfold(x,ones(1,m)/m)[m:n]; // more efficient diff --git a/Task/Averages-Simple-moving-average/Euler-Math-Toolbox/averages-simple-moving-average-2.euler b/Task/Averages-Simple-moving-average/Euler-Math-Toolbox/averages-simple-moving-average-2.euler new file mode 100644 index 0000000000..4457109244 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Euler-Math-Toolbox/averages-simple-moving-average-2.euler @@ -0,0 +1,30 @@ +>function store (x:number, v:vector, n:index) ... +$if cols(v)v=zeros(1,0); for k=1:20; v=store(k,v,10); mean(v), end; + 1 + 1.5 + 2 + 2.5 + 3 + 3.5 + 4 + 4.5 + 5 + 5.5 + 6.5 + 7.5 + 8.5 + 9.5 + 10.5 + 11.5 + 12.5 + 13.5 + 14.5 + 15.5 +>v + [ 11 12 13 14 15 16 17 18 19 20 ] diff --git a/Task/Balanced-brackets/C++/balanced-brackets.cpp b/Task/Balanced-brackets/C++/balanced-brackets.cpp new file mode 100644 index 0000000000..290b8d4ace --- /dev/null +++ b/Task/Balanced-brackets/C++/balanced-brackets.cpp @@ -0,0 +1,33 @@ +#include +#include +#include + +std::string generate(int n, char left = '[', char right = ']') +{ + std::string str(std::string(n, left) + std::string(n, right)); + std::random_shuffle(str.begin(), str.end()); + return str; +} + +bool balanced(const std::string &str, char left = '[', char right = ']') +{ + int count = 0; + for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) + { + if (*it == left) + count++; + else if (*it == right) + if (--count < 0) return false; + } + return count == 0; +} + +int main() +{ + srand(time(NULL)); // seed rng + for (int i = 0; i < 9; ++i) + { + std::string s(generate(i)); + std::cout << (balanced(s) ? " ok: " : "bad: ") << s << "\n"; + } +} diff --git a/Task/Balanced-brackets/Common-Lisp/balanced-brackets.lisp b/Task/Balanced-brackets/Common-Lisp/balanced-brackets.lisp new file mode 100644 index 0000000000..3f4607bad9 --- /dev/null +++ b/Task/Balanced-brackets/Common-Lisp/balanced-brackets.lisp @@ -0,0 +1,27 @@ +(defun string-of-brackets (n) + (let ((result (make-string (* 2 n))) + (opening n) + (closing n)) + (dotimes (i (* 2 n) result) + (setf (aref result i) + (cond + ((zerop opening) #\]) + ((zerop closing) #\[) + (t (if (= (random 2) 0) + (progn (decf opening) #\[) + (progn (decf closing) #\])))))))) + +(defun balancedp (string) + (zerop (reduce (lambda (nesting bracket) + (ecase bracket + (#\] (if (= nesting 0) + (return-from balancedp nil) + (1- nesting))) + (#\[ (1+ nesting)))) + string + :initial-value 0))) + +(defun show-balanced-brackets () + (dotimes (i 10) + (let ((s (string-of-brackets i))) + (format t "~3A: ~A~%" (balancedp s) s)))) diff --git a/Task/Balanced-brackets/D/balanced-brackets-1.d b/Task/Balanced-brackets/D/balanced-brackets-1.d new file mode 100644 index 0000000000..ffde7bf9d0 --- /dev/null +++ b/Task/Balanced-brackets/D/balanced-brackets-1.d @@ -0,0 +1,10 @@ +import std.stdio, std.algorithm, std.random; + +void main() { + foreach (i; 1 .. 9) { + string s; + foreach (_; 0 .. i * 2) + s ~= "[]"[uniform(0, 2)]; + writeln(s.balancedParens('[', ']') ? " OK: " : "bad: ", s); + } +} diff --git a/Task/Balanced-brackets/D/balanced-brackets-2.d b/Task/Balanced-brackets/D/balanced-brackets-2.d new file mode 100644 index 0000000000..f0c6aafc6c --- /dev/null +++ b/Task/Balanced-brackets/D/balanced-brackets-2.d @@ -0,0 +1,20 @@ +import std.stdio, std.random; + +void main() { +NEXT_STR: + foreach (j; 1 .. 9) { + string s; + foreach (_; 0 .. j * 2) + s ~= "[]"[uniform(0, 2)]; + + int balance; + foreach (i, c; s) { + balance += (c == '[') ? 1 : ((c == ']') ? -1 : 0); + if (balance < 0 || balance >= s.length - i) { + writefln("BAD: %s (%s)", s, balance < 0 ? "-" : "+"); + continue NEXT_STR; + } + } + writefln(" OK: %s (=)", s); + } +} diff --git a/Task/Balanced-brackets/D/balanced-brackets-3.d b/Task/Balanced-brackets/D/balanced-brackets-3.d new file mode 100644 index 0000000000..d586906668 --- /dev/null +++ b/Task/Balanced-brackets/D/balanced-brackets-3.d @@ -0,0 +1,20 @@ +import std.stdio, std.random, std.conv, std.range, std.algorithm; + +bool isBalanced(in char[] s) pure nothrow { + static bool bal(in char[] s, in int nb=0) pure nothrow { + if (nb == 0 && s.empty) return true; + if (s.empty || nb < 0) return false; + if (s[0] == '[') return bal(s[1 .. $], nb + 1); + if (s[0] == ']') return bal(s[1 .. $], nb - 1); + return bal(s[1 .. $], nb); // ignore char + } + return bal(s); +} + +void main() { + foreach (i; 1 .. 9) { + auto sr = iota(i * 2).map!(_ => ['[',']'][uniform(0, 2)])(); + auto s = sr.array(); + writefln("%5s: %s", s.isBalanced().text(), s); + } +} diff --git a/Task/Balanced-brackets/Delphi/balanced-brackets.delphi b/Task/Balanced-brackets/Delphi/balanced-brackets.delphi new file mode 100644 index 0000000000..323451beb0 --- /dev/null +++ b/Task/Balanced-brackets/Delphi/balanced-brackets.delphi @@ -0,0 +1,31 @@ +procedure Balanced_Brackets; + +var BracketsStr : string; + TmpStr : string; + I,J : integer; + +begin + Randomize; + for I := 1 to 9 do + begin + { Create a random string of 2*N chars with N*"[" and N*"]" } + TmpStr := ''; + for J := 1 to I do + TmpStr := '['+TmpStr+']'; + BracketsStr := ''; + while TmpStr > '' do + begin + J := Random(Length(TmpStr))+1; + BracketsStr := BracketsStr+TmpStr[J]; + Delete(TmpStr,J,1); + end; + TmpStr := BracketsStr; + { Test for balanced brackets } + while Pos('[]',TmpStr) > 0 do + Delete(TmpStr,Pos('[]',TmpStr),2); + if TmpStr = '' then + writeln(BracketsStr+': OK') + else + writeln(BracketsStr+': not OK'); + end; +end; diff --git a/Task/Balanced-brackets/Elena/balanced-brackets.elena b/Task/Balanced-brackets/Elena/balanced-brackets.elena new file mode 100644 index 0000000000..6768a04f12 --- /dev/null +++ b/Task/Balanced-brackets/Elena/balanced-brackets.elena @@ -0,0 +1,32 @@ +#define std'dictionary'*. +#define std'basic'*. +#define std'patterns'*. +#define ext'utils'*. +#define ext'routines'*. + +#symbol RandomBrackets : aLength = + Randomized + &&count:(aLength * 2) + &base:(FilledWideLiteral &&pattern:"[" &count:aLength + (FilledWideLiteral &&pattern:"]" &count:aLength)). + +#symbol IsBalanced : aLiteral = +[ + #var aCounter := Integer::0. + + #if Scan::aLiteral seek: aChar = (aCounter append:(aChar ifequal:"[" ^^1 | ^^-1) < 0). + + ^ (0 == aCounter). +]. + +#symbol Program = +[ + loop &&from:0 &till:10 run: aLength = + [ + #var anStr := RandomBrackets::aLength. + #var balanced := IsBalanced::anStr. + + 'program'output << """" << anStr << (balanced is ^^""" is balanced%n" | ^^""" is not balanced%n"). + ]. + + 'program'input get. +]. diff --git a/Task/Balanced-brackets/Euphoria/balanced-brackets.euphoria b/Task/Balanced-brackets/Euphoria/balanced-brackets.euphoria new file mode 100644 index 0000000000..186ecbdb66 --- /dev/null +++ b/Task/Balanced-brackets/Euphoria/balanced-brackets.euphoria @@ -0,0 +1,45 @@ +function check_brackets(sequence s) + integer level + level = 0 + for i = 1 to length(s) do + if s[i] = '[' then + level += 1 + elsif s[i] = ']' then + level -= 1 + if level < 0 then + return 0 + end if + end if + end for + return level = 0 +end function + +function generate_brackets(integer n) + integer opened,closed,r + sequence s + opened = n + closed = n + s = "" + for i = 1 to n*2 do + r = rand(opened+closed) + if r<=opened then + s &= '[' + opened -= 1 + else + s &= ']' + closed -= 1 + end if + end for + return s +end function + +sequence s +for i = 1 to 10 do + s = generate_brackets(3) + puts(1,s) + if check_brackets(s) then + puts(1," OK\n") + else + puts(1," NOT OK\n") + end if +end for diff --git a/Task/Balanced-ternary/Common-Lisp/balanced-ternary-1.lisp b/Task/Balanced-ternary/Common-Lisp/balanced-ternary-1.lisp new file mode 100644 index 0000000000..3d265403a5 --- /dev/null +++ b/Task/Balanced-ternary/Common-Lisp/balanced-ternary-1.lisp @@ -0,0 +1,93 @@ +;;; balanced ternary +;;; represented as a list of 0, 1 or -1s, with least significant digit first + +;;; convert ternary to integer +(defun bt-integer (b) + (reduce (lambda (x y) (+ x (* 3 y))) b :from-end t :initial-value 0)) + +;;; convert integer to ternary +(defun integer-bt (n) + (if (zerop n) nil + (case (mod n 3) + (0 (cons 0 (integer-bt (/ n 3)))) + (1 (cons 1 (integer-bt (floor n 3)))) + (2 (cons -1 (integer-bt (floor (1+ n) 3))))))) + +;;; convert string to ternary +(defun string-bt (s) + (loop with o = nil for c across s do + (setf o (cons (case c (#\+ 1) (#\- -1) (#\0 0)) o)) + finally (return o))) + +;;; convert ternary to string +(defun bt-string (bt) + (if (not bt) "0" + (let* ((l (length bt)) + (s (make-array l :element-type 'character))) + (mapc (lambda (b) + (setf (aref s (decf l)) + (case b (-1 #\-) (0 #\0) (1 #\+)))) + bt) + s))) + +;;; arithmetics +(defun bt-neg (a) (map 'list #'- a)) +(defun bt-sub (a b) (bt-add a (bt-neg b))) + +(let ((tbl #((0 -1) (1 -1) (-1 0) (0 0) (1 0) (-1 1) (0 1)))) + (defun bt-add-digits (a b c) + (values-list (aref tbl (+ 3 a b c))))) + +(defun bt-add (a b &optional (c 0)) + (if (not (and a b)) + (if (zerop c) (or a b) + (bt-add (list c) (or a b))) + (multiple-value-bind (d c) + (bt-add-digits (if a (car a) 0) (if b (car b) 0) c) + (let ((res (bt-add (cdr a) (cdr b) c))) + ;; trim leading zeros + (if (or res (not (zerop d))) + (cons d res)))))) + +(defun bt-mul (a b) + (if (not (and a b)) + nil + (bt-add (case (car a) + (-1 (bt-neg b)) + ( 0 nil) + ( 1 b)) + (cons 0 (bt-mul (cdr a) b))))) + +;;; division with quotient/remainder, for completeness +(defun bt-truncate (a b) + (let ((n (- (length a) (length b))) + (d (car (last b)))) + (if (minusp n) + (values nil a) + (labels ((recur (a b x) + (multiple-value-bind (quo rem) + (if (plusp x) (recur a (cons 0 b) (1- x)) + (values nil a)) + + (loop with g = (car (last rem)) + with quo = (cons 0 quo) + while (= (length rem) (length b)) do + (cond ((= g d) (setf rem (bt-sub rem b) + quo (bt-add '(1) quo))) + ((= g (- d)) (setf rem (bt-add rem b) + quo (bt-add '(-1) quo)))) + (setf x (car (last rem))) + finally (return (values quo rem)))))) + + (recur a b n))))) + +;;; test case +(let* ((a (string-bt "+-0++0+")) + (b (integer-bt -436)) + (c (string-bt "+-++-")) + (d (bt-mul a (bt-sub b c)))) + (format t "a~5d~8t~a~%b~5d~8t~a~%c~5d~8t~a~%a × (b − c) = ~d ~a~%" + (bt-integer a) (bt-string a) + (bt-integer b) (bt-string b) + (bt-integer c) (bt-string c) + (bt-integer d) (bt-string d))) diff --git a/Task/Balanced-ternary/Common-Lisp/balanced-ternary-2.lisp b/Task/Balanced-ternary/Common-Lisp/balanced-ternary-2.lisp new file mode 100644 index 0000000000..6a07058bb6 --- /dev/null +++ b/Task/Balanced-ternary/Common-Lisp/balanced-ternary-2.lisp @@ -0,0 +1,4 @@ +a 523 +-0++0+ +b -436 -++-0-- +c 65 +-++- +a × (b − c) = -262023 ----0+--0++0 diff --git a/Task/Balanced-ternary/D/balanced-ternary.d b/Task/Balanced-ternary/D/balanced-ternary.d new file mode 100644 index 0000000000..8ddc97e1d9 --- /dev/null +++ b/Task/Balanced-ternary/D/balanced-ternary.d @@ -0,0 +1,142 @@ +import std.stdio, std.bigint, std.range, std.algorithm, std.array, + std.conv, std.exception; + +struct BalancedTernary { + enum Dig : byte { N=-1, Z=0, P=+1 } // digits + Dig[] digits; + // Represented as a list of 0, 1 or -1s, + // with least significant digit first. + + static string dig2str = "-0+"; + + const static Dig[dchar] str2dig; // = ['+': Dig.P, ...]; + static this() { + str2dig = ['+': Dig.P, '-': Dig.N, '0': Dig.Z]; + } + + immutable static Dig[2][] table = + [[Dig.Z, Dig.N], [Dig.P, Dig.N], [Dig.N, Dig.Z], + [Dig.Z, Dig.Z], [Dig.P, Dig.Z], [Dig.N, Dig.P], + [Dig.Z, Dig.P]]; + + this(string inp) { + this.digits = map!(c => cast()str2dig[c])(retro(inp)).array(); + } + + this(long inp) { + this.digits = _bint2ternary(BigInt(inp)); + } + + this(BigInt inp) { + this.digits = _bint2ternary(inp); + } + + this(BalancedTernary inp) { + // no need to dup, they are virtually immutable + this.digits = inp.digits; + } + + private this(Dig[] inp) { + this.digits = inp; + } + + static Dig[] _bint2ternary(/*in*/ BigInt n) { + static py_div(T1, T2)(T1 a, T2 b) { + if (a < 0) + if (b < 0) + return -a / -b; + else + return -(-a / b) - (-a % b != 0 ? 1 : 0); + else if (b < 0) + return -(a / -b) - (a % -b != 0 ? 1 : 0); + else + return a / b; + } + + if (n == 0) return []; + switch (((n % 3) + 3) % 3) { // (n % 3) is the remainder + case 0: return Dig.Z ~ _bint2ternary(py_div(n, 3)); + case 1: return Dig.P ~ _bint2ternary(py_div(n, 3)); + case 2: return Dig.N ~ _bint2ternary(py_div(n + 1, 3)); + default: assert(0, "Can't happen"); + } + } + + @property BigInt toBint() const { + return reduce!((y,x) => x + 3 * y)(BigInt(0), retro(digits)); + } + + string toString() const { + if (digits.empty) return "0"; + //return map!(d => dig2str[d + 1])(retro(digits)).array(); + auto r = map!(d => cast()dig2str[d+1])(retro(digits)).array(); + return assumeUnique(r); /// + } + + static Dig[] neg_(Dig[] digs) { + return map!(d => -d)(digs).array(); + } + + BalancedTernary opUnary(string op:"-")() { + return BalancedTernary(neg_(this.digits)); + } + + static Dig[] add_(Dig[] a, Dig[] b, Dig c=Dig.Z) { + auto a_or_b = a.length ? a : b; + if (a.empty || b.empty) { + if (c == Dig.Z) + return a_or_b; + else + return BalancedTernary.add_([c], a_or_b); + } else { + // (const d, c) = table[...]; + const dc = table[3 + (a.length ? a[0] : 0) + + (b.length ? b[0] : 0) + c]; + auto res = add_(a[1 .. $], b[1 .. $], dc[1]); + // trim leading zeros + if (res.length || dc[0] != Dig.Z) + return [dc[0]] ~ res; + else + return res; + } + } + + BalancedTernary opBinary(string op:"+")(BalancedTernary b) { + return BalancedTernary(add_(this.digits, b.digits)); + } + + BalancedTernary opBinary(string op:"-")(BalancedTernary b) { + return this + (-b); + } + + static Dig[] mul_(in Dig[] a, /*in*/ Dig[] b) { + if (a.empty || b.empty) { + return []; + } else { + Dig[] y = Dig.Z ~ mul_(a[1 .. $], b); + final switch (a[0]) { + case Dig.N: return add_(neg_(b), y); + case Dig.Z: return add_([], y); + case Dig.P: return add_(b, y); + } + } + } + + BalancedTernary opBinary(string op:"*")(BalancedTernary b) { + return BalancedTernary(mul_(this.digits, b.digits)); + } +} + +void main() { + auto a = BalancedTernary("+-0++0+"); + writeln("a: ", a.toBint, " ", a); + + auto b = BalancedTernary(-436); + writeln("b: ", b.toBint, " ", b); + + auto c = BalancedTernary("+-++-"); + writeln("c: ", c.toBint, " ", c); + + auto r = a * (b - c); + writeln("a * (b - c): ", r.toBint, " ", r); +} diff --git a/Task/Best-shuffle/Common-Lisp/best-shuffle-1.lisp b/Task/Best-shuffle/Common-Lisp/best-shuffle-1.lisp new file mode 100644 index 0000000000..bf81f4784d --- /dev/null +++ b/Task/Best-shuffle/Common-Lisp/best-shuffle-1.lisp @@ -0,0 +1,23 @@ +(defun count-equal-chars (string1 string2) + (loop for c1 across string1 and c2 across string2 + count (char= c1 c2))) + +(defun shuffle (string) + (let ((length (length string)) + (result (copy-seq string))) + (dotimes (i length result) + (dotimes (j length) + (when (and (/= i j) + (char/= (aref string i) (aref result j)) + (char/= (aref string j) (aref result i))) + (rotatef (aref result i) (aref result j))))))) + +(defun best-shuffle (list) + (dolist (string list) + (let ((shuffled (shuffle string))) + (format t "~%~a ~a (~a)" + string + shuffled + (count-equal-chars string shuffled))))) + +(best-shuffle '("abracadabra" "seesaw" "elk" "grrrrrr" "up" "a")) diff --git a/Task/Best-shuffle/Common-Lisp/best-shuffle-2.lisp b/Task/Best-shuffle/Common-Lisp/best-shuffle-2.lisp new file mode 100644 index 0000000000..836d307235 --- /dev/null +++ b/Task/Best-shuffle/Common-Lisp/best-shuffle-2.lisp @@ -0,0 +1,46 @@ +(defun all-best-shuffles (str) + (let (tbl out (shortest (length str)) (s str)) + + (labels ((perm (ar l tmpl res overlap) + (when (> overlap shortest) + (return-from perm)) + (when (zerop l) ; max depth of perm + (when (< overlap shortest) + (setf shortest overlap out '())) + (when (= overlap shortest) + (setf res (reverse (format nil "~{~c~^~}" res))) + (push (list res overlap) out) + (return-from perm))) + (decf l) + (dolist (x ar) + (when (plusp (cdr x)) + (when (char= (car x) (char tmpl l)) + (incf overlap)) + (decf (cdr x)) + (push (car x) res) + (perm ar l tmpl res overlap) + (pop res) + (incf (cdr x)) + (when (char= (car x) (char tmpl l)) + (decf overlap)))))) + + (loop while (plusp (length s)) do + (let* ((c (char s 0)) + (l (count c s))) + (push (cons c l) tbl) + (setf s (remove c s)))) + + (perm tbl (length str) (reverse str) '() 0)) + out)) + +(defun best-shuffle (str) + "Algorithm: list all best shuffles, then pick one" + (let ((c (all-best-shuffles str))) + (elt c (random (length c))))) + +(format t "All best shuffles:") +(print (all-best-shuffles "seesaw")) + +(format t "~%~%Random best shuffles:~%") +(dolist (s (list "abracadabra" "seesaw" "elk" "grrrrrr" "up" "a")) + (format t "~A: ~A~%" s (best-shuffle s))) diff --git a/Task/Best-shuffle/D/best-shuffle-1.d b/Task/Best-shuffle/D/best-shuffle-1.d new file mode 100644 index 0000000000..4df5a7338b --- /dev/null +++ b/Task/Best-shuffle/D/best-shuffle-1.d @@ -0,0 +1,40 @@ +import std.stdio, std.random, std.algorithm, std.conv, std.range, +std.traits, std.typecons; + +auto bestShuffle(S)(in S orig) if (isSomeString!S) { + static if (isNarrowString!S) + auto o = to!dstring(orig); + else alias orig o; + + auto s = o.dup; + randomShuffle(s); + foreach (i, ref ci; s) { + if (ci != o[i]) + continue; + foreach (j, ref cj; s) + if (ci != cj && ci != o[j] && cj != o[i]) { + swap(ci, cj); + break; + } + } + return tuple(s, count!"a[0] == a[1]"(zip(s, o))); +} + +unittest { + assert(bestShuffle("abracadabra"d)[1] == 0); + assert(bestShuffle("immediately"d)[1] == 0); + assert(bestShuffle("grrrrrr"d)[1] == 5); + assert(bestShuffle("seesaw"d)[1] == 0); + assert(bestShuffle("pop"d)[1] == 1); + assert(bestShuffle("up"d)[1] == 0); + assert(bestShuffle("a"d)[1] == 1); + assert(bestShuffle(""d)[1] == 0); +} + +void main(string[] args) { + if (args.length > 1) { + string entry = join(args[1 .. $], " "); + auto res = bestShuffle(entry); + writefln("%s : %s (%s)", entry, res[0], res[1]); + } +} diff --git a/Task/Best-shuffle/D/best-shuffle-2.d b/Task/Best-shuffle/D/best-shuffle-2.d new file mode 100644 index 0000000000..bf7f514b31 --- /dev/null +++ b/Task/Best-shuffle/D/best-shuffle-2.d @@ -0,0 +1,103 @@ +import std.stdio, std.algorithm, std.range; + +extern(C) pure nothrow void* alloca(in size_t size); + +void bestShuffle(in char[] txt, ref char[] result) pure nothrow { + // Assume alloca to be pure. + //extern(C) pure nothrow void* alloca(in size_t size); + enum size_t NCHAR = cast(size_t)char.max + 1; + enum size_t MAX_VLA_SIZE = 1024; + immutable size_t len = txt.length; + if (len == 0) + return; + + // txt and result must have the same length + // allocate only when necessary + if (result.length != len) + result.length = len; + + // how many of each character? + size_t[NCHAR] counts; + size_t fmax = 0; + foreach (char c; txt) { + counts[c]++; + if (fmax < counts[c]) + fmax = counts[c]; + } + assert(fmax > 0 && fmax <= len); + + // all character positions, grouped by character + size_t[] ndx1; + { + size_t* ptr1; + if ((len * size_t.sizeof) < MAX_VLA_SIZE) + ptr1 = cast(size_t*)alloca(len * size_t.sizeof); + // If alloca() has failed, or the memory needed is too much + // large, then allocate from the heap. + ndx1 = (ptr1 == null) ? new size_t[len] : ptr1[0 .. len]; + } + { + int pos = 0; + foreach (size_t ch; 0 .. NCHAR) + if (counts[ch]) + foreach (j, char c; txt) + if (c == ch) { + ndx1[pos] = j; + pos++; + } + } + + // regroup them for cycles + size_t[] ndx2; + { + size_t* ptr2; + if ((len * size_t.sizeof) < MAX_VLA_SIZE) + ptr2 = cast(size_t*)alloca(len * size_t.sizeof); + ndx2 = (ptr2 == null) ? new size_t[len] : ptr2[0 .. len]; + } + { + size_t n, m; + foreach (size_t i; 0 .. len) { + ndx2[i] = ndx1[n]; + n += fmax; + if (n >= len) { + m++; + n = m; + } + } + } + + // how long can our cyclic groups be? + immutable size_t grp = 1 + (len - 1) / fmax; + + // how many of them are full length? + immutable size_t lng = 1 + (len - 1) % fmax; + + // rotate each group + { + size_t j; + foreach (size_t i; 0 .. fmax) { + immutable size_t first = ndx2[j]; + immutable size_t glen = grp - (i < lng ? 0 : 1); + foreach (size_t k; 1 .. glen) + ndx1[j + k - 1] = ndx2[j + k]; + ndx1[j + glen - 1] = first; + j += glen; + } + } + + // result is original permuted according to our cyclic groups + foreach (size_t i; 0 .. len) + result[ndx2[i]] = txt[ndx1[i]]; +} + +void main() { + auto data = ["abracadabra", "seesaw", "elk", "grrrrrr", + "up", "a", "aabbbbaa", "", "xxxxx"]; + foreach (txt; data) { + auto result = txt.dup; + bestShuffle(txt, result); + immutable nEqual = zip(txt, result).count!q{a[0] == a[1]}(); + writefln("%s, %s, (%d)", txt, result, nEqual); + } +} diff --git a/Task/Binary-search/C++/binary-search-1.cpp b/Task/Binary-search/C++/binary-search-1.cpp new file mode 100644 index 0000000000..15eeca49e9 --- /dev/null +++ b/Task/Binary-search/C++/binary-search-1.cpp @@ -0,0 +1,28 @@ +template +int binsearch(const T array[], int len, T what) +{ + if (len == 0) return -1; + int mid = len / 2; + if (array[mid] == what) return mid; + if (array[mid] < what) { + int result = binsearch(array+mid+1, len-(mid+1), what); + if (result == -1) return -1; + else return result + mid+1; + } + if (array[mid] > what) + return binsearch(array, mid, what); +} + +#include +int main() +{ + int array[] = {2, 3, 5, 6, 8}; + int result1 = binsearch(array, sizeof(array)/sizeof(int), 4), + result2 = binsearch(array, sizeof(array)/sizeof(int), 8); + if (result1 == -1) std::cout << "4 not found!" << std::endl; + else std::cout << "4 found at " << result1 << std::endl; + if (result2 == -1) std::cout << "8 not found!" << std::endl; + else std::cout << "8 found at " << result2 << std::endl; + + return 0; +} diff --git a/Task/Binary-search/C++/binary-search-2.cpp b/Task/Binary-search/C++/binary-search-2.cpp new file mode 100644 index 0000000000..4d74c20e7f --- /dev/null +++ b/Task/Binary-search/C++/binary-search-2.cpp @@ -0,0 +1,15 @@ +template +int binSearch(const T arr[], int len, T what) { + int low = 0; + int high = len - 1; + while (low <= high) { + int mid = (low + high) / 2; + if (arr[mid] > what) + high = mid - 1; + else if (arr[mid] < what) + low = mid + 1; + else + return mid; + } + return -1; // indicate not found +} diff --git a/Task/Binary-search/C++/binary-search-3.cpp b/Task/Binary-search/C++/binary-search-3.cpp new file mode 100644 index 0000000000..761e9a6835 --- /dev/null +++ b/Task/Binary-search/C++/binary-search-3.cpp @@ -0,0 +1 @@ +#include diff --git a/Task/Binary-search/C++/binary-search-4.cpp b/Task/Binary-search/C++/binary-search-4.cpp new file mode 100644 index 0000000000..1738a3ecf9 --- /dev/null +++ b/Task/Binary-search/C++/binary-search-4.cpp @@ -0,0 +1 @@ +int *ptr = std::lower_bound(array, array+len, what); // a custom comparator can be given as fourth arg diff --git a/Task/Binary-search/C++/binary-search-5.cpp b/Task/Binary-search/C++/binary-search-5.cpp new file mode 100644 index 0000000000..ba028d6dda --- /dev/null +++ b/Task/Binary-search/C++/binary-search-5.cpp @@ -0,0 +1 @@ +int *ptr = std::upper_bound(array, array+len, what); // a custom comparator can be given as fourth arg diff --git a/Task/Binary-search/C++/binary-search-6.cpp b/Task/Binary-search/C++/binary-search-6.cpp new file mode 100644 index 0000000000..6494a063b4 --- /dev/null +++ b/Task/Binary-search/C++/binary-search-6.cpp @@ -0,0 +1 @@ +std::pair bounds = std::equal_range(array, array+len, what); // a custom comparator can be given as fourth arg diff --git a/Task/Binary-search/C++/binary-search-7.cpp b/Task/Binary-search/C++/binary-search-7.cpp new file mode 100644 index 0000000000..ca2f84ab81 --- /dev/null +++ b/Task/Binary-search/C++/binary-search-7.cpp @@ -0,0 +1 @@ +bool found = std::binary_search(array, array+len, what); // a custom comparator can be given as fourth arg diff --git a/Task/Binary-search/Common-Lisp/binary-search-1.lisp b/Task/Binary-search/Common-Lisp/binary-search-1.lisp new file mode 100644 index 0000000000..9b4943f3ea --- /dev/null +++ b/Task/Binary-search/Common-Lisp/binary-search-1.lisp @@ -0,0 +1,14 @@ +(defun binary-search (value array) + (let ((low 0) + (high (1- (length array)))) + + (do () ((< high low) nil) + (let ((middle (floor (/ (+ low high) 2)))) + + (cond ((> (aref array middle) value) + (setf high (1- middle))) + + ((< (aref array middle) value) + (setf low (1+ middle))) + + (t (return middle))))))) diff --git a/Task/Binary-search/Common-Lisp/binary-search-2.lisp b/Task/Binary-search/Common-Lisp/binary-search-2.lisp new file mode 100644 index 0000000000..ca92fe78c4 --- /dev/null +++ b/Task/Binary-search/Common-Lisp/binary-search-2.lisp @@ -0,0 +1,12 @@ +(defun binary-search (value array &optional (low 0) (high (1- (length array)))) + (if (< high low) + nil + (let ((middle (floor (/ (+ low high) 2)))) + + (cond ((> (aref array middle) value) + (binary-search value array low (1- middle))) + + ((< (aref array middle) value) + (binary-search value array (1+ middle) high)) + + (t middle))))) diff --git a/Task/Binary-search/D/binary-search.d b/Task/Binary-search/D/binary-search.d new file mode 100644 index 0000000000..f2500674b1 --- /dev/null +++ b/Task/Binary-search/D/binary-search.d @@ -0,0 +1,36 @@ +import std.stdio, std.array; + +// Recursive +bool binarySearch(T)(in T[] data, in T item) pure nothrow { + if (data.empty) + return false; + immutable i = data.length / 2; + immutable mid = data[i]; + if (mid > item) + return binarySearch(data[0 .. i], item); + if (mid < item) + return binarySearch(data[i+1 .. $], item); + return true; +} + +// Iterative +bool binarySearchIt(T)(const(T)[] data, in T item) pure nothrow { + while (!data.empty) { + immutable i = data.length / 2; + immutable mid = data[i]; + if (mid > item) + data = data[0 .. i]; + else if (mid < item) + data = data[i+1 .. $]; + else + return true; + } + return false; +} + +void main() { + immutable items = [2, 4, 6, 8, 9]; + foreach (x; [1, 8, 10, 9, 5, 2]) + writefln("%2d %5s %5s", x, binarySearch(items, x), + binarySearchIt(items, x)); +} diff --git a/Task/Binary-search/E/binary-search.e b/Task/Binary-search/E/binary-search.e new file mode 100644 index 0000000000..de4f557c90 --- /dev/null +++ b/Task/Binary-search/E/binary-search.e @@ -0,0 +1,14 @@ +/** Returns null if the value is not found. */ +def binarySearch(collection, value) { + var low := 0 + var high := collection.size() - 1 + while (low <= high) { + def mid := (low + high) // 2 + def comparison := value.op__cmp(collection[mid]) + if (comparison.belowZero()) { high := mid - 1 } \ + else if (comparison.aboveZero()) { low := mid + 1 } \ + else if (comparison.isZero()) { return mid } \ + else { throw("You expect me to binary search with a partial order?") } + } + return null +} diff --git a/Task/Binary-search/Euphoria/binary-search-1.euphoria b/Task/Binary-search/Euphoria/binary-search-1.euphoria new file mode 100644 index 0000000000..6c8719c37a --- /dev/null +++ b/Task/Binary-search/Euphoria/binary-search-1.euphoria @@ -0,0 +1,16 @@ +function binary_search(sequence s, object val, integer low, integer high) + integer mid, cmp + if high < low then + return 0 -- not found + else + mid = floor( (low + high) / 2 ) + cmp = compare(s[mid], val) + if cmp > 0 then + return binary_search(s, val, low, mid-1) + elsif cmp < 0 then + return binary_search(s, val, mid+1, high) + else + return mid + end if + end if +end function diff --git a/Task/Binary-search/Euphoria/binary-search-2.euphoria b/Task/Binary-search/Euphoria/binary-search-2.euphoria new file mode 100644 index 0000000000..4ffa8d6cb3 --- /dev/null +++ b/Task/Binary-search/Euphoria/binary-search-2.euphoria @@ -0,0 +1,17 @@ +function binary_search(sequence s, object val) + integer low, high, mid, cmp + low = 1 + high = length(s) + while low <= high do + mid = floor( (low + high) / 2 ) + cmp = compare(s[mid], val) + if cmp > 0 then + high = mid - 1 + elsif cmp < 0 then + low = mid + 1 + else + return mid + end if + end while + return 0 -- not found +end function diff --git a/Task/Binary-strings/Common-Lisp/binary-strings-1.lisp b/Task/Binary-strings/Common-Lisp/binary-strings-1.lisp new file mode 100644 index 0000000000..bd39b030a3 --- /dev/null +++ b/Task/Binary-strings/Common-Lisp/binary-strings-1.lisp @@ -0,0 +1,2 @@ +"string" +(coerce (#\s #\t #\r #\i #\n #\g) 'string) diff --git a/Task/Binary-strings/Common-Lisp/binary-strings-2.lisp b/Task/Binary-strings/Common-Lisp/binary-strings-2.lisp new file mode 100644 index 0000000000..140ec24f88 --- /dev/null +++ b/Task/Binary-strings/Common-Lisp/binary-strings-2.lisp @@ -0,0 +1 @@ +(defvar *string* "string") diff --git a/Task/Binary-strings/Common-Lisp/binary-strings-3.lisp b/Task/Binary-strings/Common-Lisp/binary-strings-3.lisp new file mode 100644 index 0000000000..4abd7e208a --- /dev/null +++ b/Task/Binary-strings/Common-Lisp/binary-strings-3.lisp @@ -0,0 +1 @@ +(equal "string" "string") diff --git a/Task/Binary-strings/Common-Lisp/binary-strings-4.lisp b/Task/Binary-strings/Common-Lisp/binary-strings-4.lisp new file mode 100644 index 0000000000..d673232cdf --- /dev/null +++ b/Task/Binary-strings/Common-Lisp/binary-strings-4.lisp @@ -0,0 +1 @@ +(copy-seq "string") diff --git a/Task/Binary-strings/Common-Lisp/binary-strings-5.lisp b/Task/Binary-strings/Common-Lisp/binary-strings-5.lisp new file mode 100644 index 0000000000..30eb766732 --- /dev/null +++ b/Task/Binary-strings/Common-Lisp/binary-strings-5.lisp @@ -0,0 +1,4 @@ +(defun string-empty-p (string) + (cond + ((= 0 (length string))t) + (nil))) diff --git a/Task/Binary-strings/Common-Lisp/binary-strings-6.lisp b/Task/Binary-strings/Common-Lisp/binary-strings-6.lisp new file mode 100644 index 0000000000..9487ecddfa --- /dev/null +++ b/Task/Binary-strings/Common-Lisp/binary-strings-6.lisp @@ -0,0 +1 @@ +(concatenate 'string "string" "b") diff --git a/Task/Binary-strings/Common-Lisp/binary-strings-7.lisp b/Task/Binary-strings/Common-Lisp/binary-strings-7.lisp new file mode 100644 index 0000000000..2139638b58 --- /dev/null +++ b/Task/Binary-strings/Common-Lisp/binary-strings-7.lisp @@ -0,0 +1,2 @@ +(subseq "string" 1 6) +"ring" diff --git a/Task/Binary-strings/D/binary-strings.d b/Task/Binary-strings/D/binary-strings.d new file mode 100644 index 0000000000..764ec93ff5 --- /dev/null +++ b/Task/Binary-strings/D/binary-strings.d @@ -0,0 +1,45 @@ +import std.array: empty; +import std.string: replace; + +void main() { + // String creation (destruction is usually handled by + // the garbage collector) + ubyte[] str1; + + // String assignments + str1 = cast(ubyte[])"blah"; + // hex string, same as "\x00\xFB\xCD\x32\xFD\x0A" + // whitespace and newlines are ignored + str1 = cast(ubyte[])x"00 FBCD 32FD 0A"; + + // String comparison + ubyte[] str2; + if (str1 == str2) {} // strings equal + + // String cloning and copying + str2 = str1.dup; // copy entire string or array + + // Check if a string is empty + if (str1.empty) {} // string empty + if (str1.length) {} // string not empty + if (!str1.length) {} // string empty + + // Append a ubyte to a string + str1 ~= x"0A"; + str1 ~= 'a'; + + // Extract a substring from a string + str1 = cast(ubyte[])"blork"; + // this takes off the first and last bytes and + // assigns them to the new ubyte string + // This is just a light slice, no string data copied + ubyte[] substr = str1[1 .. $-1]; + + // Replace every occurrence of a ubyte (or a string) + // in a string with another string + str1 = cast(ubyte[])"blah"; + replace(cast(char[])str1, "la", "al"); + + // Join strings + ubyte[] str3 = str1 ~ str2; +} diff --git a/Task/Binary-strings/E/binary-strings-1.e b/Task/Binary-strings/E/binary-strings-1.e new file mode 100644 index 0000000000..e40e14f095 --- /dev/null +++ b/Task/Binary-strings/E/binary-strings-1.e @@ -0,0 +1,2 @@ +? def int8 := +# value: int8 diff --git a/Task/Binary-strings/E/binary-strings-2.e b/Task/Binary-strings/E/binary-strings-2.e new file mode 100644 index 0000000000..1bec6b2a37 --- /dev/null +++ b/Task/Binary-strings/E/binary-strings-2.e @@ -0,0 +1,8 @@ +? def bstr := [].diverge(int8) +# value: [].diverge() + +? def bstr1 := [1,2,3].diverge(int8) +# value: [1, 2, 3].diverge() + +? def bstr2 := [-0x7F,0x2,0x3].diverge(int8) +# value: [-127, 2, 3].diverge() diff --git a/Task/Binary-strings/E/binary-strings-3.e b/Task/Binary-strings/E/binary-strings-3.e new file mode 100644 index 0000000000..111abce3ed --- /dev/null +++ b/Task/Binary-strings/E/binary-strings-3.e @@ -0,0 +1,2 @@ +? bstr1.snapshot() < bstr2.snapshot() +# value: false diff --git a/Task/Binary-strings/E/binary-strings-4.e b/Task/Binary-strings/E/binary-strings-4.e new file mode 100644 index 0000000000..068a4e424d --- /dev/null +++ b/Task/Binary-strings/E/binary-strings-4.e @@ -0,0 +1,5 @@ +? bstr1.size().isZero() +# value: false + +? bstr.size().isZero() +# value: true diff --git a/Task/Binary-strings/E/binary-strings-5.e b/Task/Binary-strings/E/binary-strings-5.e new file mode 100644 index 0000000000..f41ac6a521 --- /dev/null +++ b/Task/Binary-strings/E/binary-strings-5.e @@ -0,0 +1,3 @@ +? bstr.push(0) +? bstr +# value: [0].diverge() diff --git a/Task/Binary-strings/E/binary-strings-6.e b/Task/Binary-strings/E/binary-strings-6.e new file mode 100644 index 0000000000..0796ab2d7e --- /dev/null +++ b/Task/Binary-strings/E/binary-strings-6.e @@ -0,0 +1,6 @@ +? bstr1(1, 2) +# value: [2] + +? bstr.replace(0, bstr.size(), bstr2, 1, 3) +? bstr +# value: [2, 3].diverge() diff --git a/Task/Binary-strings/E/binary-strings-7.e b/Task/Binary-strings/E/binary-strings-7.e new file mode 100644 index 0000000000..c0da044745 --- /dev/null +++ b/Task/Binary-strings/E/binary-strings-7.e @@ -0,0 +1,3 @@ +? for i => byte ? (byte == 2) in bstr2 { bstr2[i] := -1 } +? bstr2 +# value: [-127, -1, 3].diverge() diff --git a/Task/Binary-strings/E/binary-strings-8.e b/Task/Binary-strings/E/binary-strings-8.e new file mode 100644 index 0000000000..1f49a33d4d --- /dev/null +++ b/Task/Binary-strings/E/binary-strings-8.e @@ -0,0 +1,3 @@ +? bstr1.append(bstr2) +? bstr1 +# value: [1, 2, 3, -127, 2, 3].diverge() diff --git a/Task/Bitmap-B-zier-curves-Cubic/D/bitmap-b-zier-curves-cubic.d b/Task/Bitmap-B-zier-curves-Cubic/D/bitmap-b-zier-curves-cubic.d new file mode 100644 index 0000000000..dbf3d945ee --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/D/bitmap-b-zier-curves-cubic.d @@ -0,0 +1,34 @@ +import grayscale_image, bitmap_bresenhams_line_algorithm; + +struct Pt { int x, y; } // Signed. + +void cubicBezier(size_t nSegments=20, Color) + (Image!Color im, + in Pt p1, in Pt p2, in Pt p3, in Pt p4, + in Color color) +pure nothrow if (nSegments > 0) { + Pt[nSegments + 1] points = void; + + foreach (immutable i, ref p; points) { + immutable double t = i / cast(double)nSegments, + a = (1.0 - t) ^^ 3, + b = 3.0 * t * (1.0 - t) ^^ 2, + c = 3.0 * t ^^ 2 * (1.0 - t), + d = t ^^ 3; + + alias T = typeof(Pt.x); + p = Pt(cast(T)(a * p1.x + b * p2.x + c * p3.x + d * p4.x), + cast(T)(a * p1.y + b * p2.y + c * p3.y + d * p4.y)); + } + + foreach (immutable i, immutable p; points[0 .. $ - 1]) + im.drawLine(p.x, p.y, points[i + 1].x, points[i + 1].y, color); +} + +void main() { + auto im = new Image!Gray(17, 17); + im.clear(Gray.white); + im.cubicBezier(Pt(16, 1), Pt(1, 4), Pt(3, 16), Pt(15, 11), + Gray.black); + im.textualShow(); +} diff --git a/Task/Bitmap-B-zier-curves-Quadratic/D/bitmap-b-zier-curves-quadratic.d b/Task/Bitmap-B-zier-curves-Quadratic/D/bitmap-b-zier-curves-quadratic.d new file mode 100644 index 0000000000..7b29f8b9b1 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/D/bitmap-b-zier-curves-quadratic.d @@ -0,0 +1,29 @@ +import grayscale_image, bitmap_bresenhams_line_algorithm; + +struct Pt { int x, y; } // Signed. + +void quadraticBezier(size_t nSegments=20, Color) + (Image!Color im, in Pt p1, in Pt p2, in Pt p3, + in Color color) +pure nothrow if (nSegments > 0) { + Pt[nSegments + 1] points = void; + + foreach (immutable i, ref p; points) { + immutable double t = i / cast(double)nSegments, + a = (1.0 - t) ^^ 2, + b = 2.0 * t * (1.0 - t), + c = t ^^ 2; + p = Pt(cast(typeof(Pt.x))(a * p1.x + b * p2.x + c * p3.x), + cast(typeof(Pt.y))(a * p1.y + b * p2.y + c * p3.y)); + } + + foreach (immutable i, immutable p; points[0 .. $ - 1]) + im.drawLine(p.x, p.y, points[i + 1].x, points[i + 1].y, color); +} + +void main() { + auto im = new Image!Gray(20, 20); + im.clear(Gray.white); + im.quadraticBezier(Pt(1,10), Pt(25,27), Pt(15,2), Gray.black); + im.textualShow(); +} diff --git a/Task/Bitmap-Bresenhams-line-algorithm/C++/bitmap-bresenhams-line-algorithm.cpp b/Task/Bitmap-Bresenhams-line-algorithm/C++/bitmap-bresenhams-line-algorithm.cpp new file mode 100644 index 0000000000..3421d234c1 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/C++/bitmap-bresenhams-line-algorithm.cpp @@ -0,0 +1,44 @@ +void Line( const float x1, const float y1, const float x2, const float y2, const Color& color ) +{ + // Bresenham's line algorithm + const bool steep = (fabs(y2 - y1) > fabs(x2 - x1)); + if(steep) + { + std::swap(x1, y1); + std::swap(x2, y2); + } + + if(x1 > x2) + { + std::swap(x1, x2); + std::swap(y1, y2); + } + + const float dx = x2 - x1; + const float dy = fabs(y2 - y1); + + float error = dx / 2.0f; + const int ystep = (y1 < y2) ? 1 : -1; + int y = (int)y1; + + const int maxX = (int)x2; + + for(int x=(int)x1; x dist-y dist-x))) + (when steep + (psetf x1 y1 y1 x1 + x2 y2 y2 x2)) + (when (> x1 x2) + (psetf x1 x2 x2 x1 + y1 y2 y2 y1)) + (let* ((delta-x (- x2 x1)) + (delta-y (abs (- y1 y2))) + (error (floor delta-x 2)) + (y-step (if (< y1 y2) 1 -1)) + (y y1)) + (loop + :for x :upfrom x1 :to x2 + :do (progn (if steep + (setf (rgb-pixel buffer x y) pixel) + (setf (rgb-pixel buffer y x) pixel)) + (setf error (- error delta-y)) + (when (< error 0) + (incf y y-step) + (incf error delta-x))))) + buffer)) diff --git a/Task/Bitmap-Bresenhams-line-algorithm/D/bitmap-bresenhams-line-algorithm.d b/Task/Bitmap-Bresenhams-line-algorithm/D/bitmap-bresenhams-line-algorithm.d new file mode 100644 index 0000000000..9b9fa72ff3 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/D/bitmap-bresenhams-line-algorithm.d @@ -0,0 +1,52 @@ +module bitmap_bresenhams_line_algorithm; + +import std.algorithm, std.math, bitmap; + +void drawLine(Color)(Image!Color img, + size_t x1, size_t y1, + in size_t x2, in size_t y2, + in Color color) +pure nothrow { + immutable int dx = x2 - x1; + immutable int ix = (dx > 0) - (dx < 0); + immutable size_t dx2 = abs(dx) * 2; + int dy = y2 - y1; + immutable int iy = (dy > 0) - (dy < 0); + immutable size_t dy2 = abs(dy) * 2; + img[x1, y1] = color; + + if (dx2 >= dy2) { + int error = dy2 - (dx2 / 2); + while (x1 != x2) { + if (error >= 0 && (error || (ix > 0))) { + error -= dx2; + y1 += iy; + } + + error += dy2; + x1 += ix; + img[x1, y1] = color; + } + } else { + int error = dx2 - (dy2 / 2); + while (y1 != y2) { + if (error >= 0 && (error || (iy > 0))) { + error -= dy2; + x1 += ix; + } + + error += dx2; + y1 += iy; + img[x1, y1] = color; + } + } +} + +version (bitmap_bresenhams_line_algorithm_main) { + void main() { + auto img = new Image!RGB(25, 22); + img.drawLine(5, 5, 15, 20, RGB.white); + img.drawLine(3, 20, 10, 12, RGB.white); + img.textualShow(); + } +} diff --git a/Task/Bitmap-Bresenhams-line-algorithm/E/bitmap-bresenhams-line-algorithm-1.e b/Task/Bitmap-Bresenhams-line-algorithm/E/bitmap-bresenhams-line-algorithm-1.e new file mode 100644 index 0000000000..590875fd03 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/E/bitmap-bresenhams-line-algorithm-1.e @@ -0,0 +1,30 @@ +def swap(&left, &right) { # From [[Generic swap]] + def t := left + left := right + right := t +} + +def drawLine(image, var x0, var y0, var x1, var y1, color) { + def steep := (y1 - y0).abs() > (x1 - x0).abs() + if (steep) { + swap(&x0, &y0) + swap(&x1, &y1) + } + if (x0 > x1) { + swap(&x0, &x1) + swap(&y0, &y1) + } + def deltax := x1 - x0 + def deltay := (y1 - y0).abs() + def ystep := if (y0 < y1) { 1 } else { -1 } + var error := deltax // 2 + var y := y0 + for x in x0..x1 { + if (steep) { image[y, x] := color } else { image[x, y] := color } + error -= deltay + if (error < 0) { + y += ystep + error += deltax + } + } +} diff --git a/Task/Bitmap-Bresenhams-line-algorithm/E/bitmap-bresenhams-line-algorithm-2.e b/Task/Bitmap-Bresenhams-line-algorithm/E/bitmap-bresenhams-line-algorithm-2.e new file mode 100644 index 0000000000..75fb26b91f --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/E/bitmap-bresenhams-line-algorithm-2.e @@ -0,0 +1,3 @@ +def i := makeImage(5, 20) +drawLine(i, 1, 1, 3, 18, makeColor.fromFloat(0,1,1)) +i.writePPM(()) diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Euphoria/bitmap-bresenhams-line-algorithm.euphoria b/Task/Bitmap-Bresenhams-line-algorithm/Euphoria/bitmap-bresenhams-line-algorithm.euphoria new file mode 100644 index 0000000000..279a27aa62 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Euphoria/bitmap-bresenhams-line-algorithm.euphoria @@ -0,0 +1,115 @@ +include std/console.e +include std/graphics.e +include std/math.e + +-- the new_image function and related code in the 25 or so +-- lines below are from http://rosettacode.org/wiki/Basic_bitmap_storage#Euphoria +-- as of friday, march 2, 2012 + +-- Some color constants: +constant + black = #000000, + white = #FFFFFF, + red = #FF0000, + green = #00FF00, + blue = #0000FF + +-- Create new image filled with some color +function new_image(integer width, integer height, atom fill_color) + return repeat(repeat(fill_color,height),width) +end function + +--grid used for drawing lines in this program +sequence screenData = new_image(16,16,black) + +--the line algorithm +function bresLine(sequence screenData, integer x0, integer y0, integer x1, integer y1, integer color) + + integer deltaX = abs(x1 - x0), deltaY = abs(y1 - y0) + integer stepX, stepY, lineError, error2 + + if x0 < x1 then + stepX = 1 + else + stepX = -1 + end if + + if y0 < y1 then + stepY = 1 + else + stepY = -1 + end if + + if deltaX > deltaY then + lineError = deltaX + else + lineError = -deltaY + end if + + lineError = round(lineError / 2, 1) + + while 1 do + + screenData[x0][y0] = color + + if (x0 = x1 and y0 = y1) then + exit + end if + + error2 = lineError + + if error2 > -deltaX then + lineError -= deltaY + x0 += stepX + end if + if error2 < deltaY then + lineError += deltaX + y0 += stepY + end if + end while + return screenData -- return modified version of the screenData sequence +end function + +--prevents console output wrapping to next line if it is too big for the screen +wrap(0) +--outer diamond +screenData = bresLine(screenData,8,1,16,8,white) +screenData = bresLine(screenData,16,8,8,16,white) +screenData = bresLine(screenData,8,16,1,8,white) +screenData = bresLine(screenData,1,8,8,1,white) +--inner diamond +screenData = bresLine(screenData,8,4,12,8,white) +screenData = bresLine(screenData,12,8,8,12,white) +screenData = bresLine(screenData,8,12,4,8,white) +screenData = bresLine(screenData,4,8,8,4,white) +-- center lines drawing from left to right, and the next from right to left. +screenData = bresLine(screenData,7,7,9,7,white) +screenData = bresLine(screenData,9,9,7,9,white) +--center dot +screenData = bresLine(screenData,8,8,8,8,white) + +--print to the standard console output +for i = 1 to 16 do + puts(1,"\n") + for j = 1 to 16 do + if screenData[j][i] = black then + printf(1, "%s", ".") + else + printf(1, "%s", "#") + end if + end for +end for + +puts(1,"\n\n") +any_key() + +--/* +--output was edited to replace the color's hex digits for clearer output graphics. +--to output all the hex digits, use printf(1,"%06x", screenData[j][i]) +--to output 'shortened' hex digits, use : +--printf(1, "%x", ( abs( ( (screenData[j][i] / #FFFFF) - 1 ) ) - 1 ) ) +--and +--printf(1,"%x", abs( ( (screenData[j][i] / #FFFFF) - 1 ) ) ) +-- +--,respectively in the last if check. +--*/ diff --git a/Task/Bitmap-Flood-fill/D/bitmap-flood-fill.d b/Task/Bitmap-Flood-fill/D/bitmap-flood-fill.d new file mode 100644 index 0000000000..8e3130adfa --- /dev/null +++ b/Task/Bitmap-Flood-fill/D/bitmap-flood-fill.d @@ -0,0 +1,31 @@ +import std.array, bitmap; + +void floodFill(Color)(Image!Color img, in uint x, in uint y, + in Color color) +/*pure nothrow*/ in { + assert (y < img.ny && x < img.nx); +} body { + immutable target = img[x, y]; + static struct Pos { uint x, y; } + auto stack = [Pos(x, y)]; + + while (!stack.empty) { + immutable p = stack.back; + stack.popBack(); + if (p.y < img.ny && p.x < img.nx && img[p.x, p.y] == target) { + img[p.x, p.y] = color; + stack.assumeSafeAppend(); // Not pure nor nothrow. + stack ~= Pos(p.x - 1, p.y); + stack ~= Pos(p.x + 1, p.y); + stack ~= Pos(p.x, p.y - 1); + stack ~= Pos(p.x, p.y + 1); + } + } +} + +void main() { + auto img = new Image!RGB(); + img.loadPPM6("Unfilledcirc.ppm"); + img.floodFill(200, 200, RGB(127, 0, 0)); + img.savePPM6("Unfilledcirc_flooded.ppm"); +} diff --git a/Task/Bitmap-Flood-fill/E/bitmap-flood-fill-1.e b/Task/Bitmap-Flood-fill/E/bitmap-flood-fill-1.e new file mode 100644 index 0000000000..f93a1f2976 --- /dev/null +++ b/Task/Bitmap-Flood-fill/E/bitmap-flood-fill-1.e @@ -0,0 +1,69 @@ +def floodFill(image, x, y, newColor) { + def matchColor := image[x, y] + def w := image.width() + def h := image.height() + + /** For any given pixel x,y, this algorithm first fills a contiguous + horizontal line segment of pixels containing that pixel, then + recursively scans the two adjacent rows over the same horizontal + interval. Let this be invocation 0, and the immediate recursive + invocations be 1, 2, 3, ..., # be pixels of the wrong color, and + * be where each scan starts; the fill ordering is as follows: + + --------------##########------- + -...1111111111*11####*33333...- + ###########000*000000000000...- + -...2222222222*22222##*4444...- + --------------------##--------- + + Each invocation returns the x coordinate of the rightmost pixel it filled, + or x0 if none were. + + Since it is recursive, this algorithm is unsuitable for large images + with small stacks. + */ + def fillScan(var x0, y) { + if (y >= 0 && y < h && x0 >= 0 && x0 < w) { + image[x0, y] := newColor + var x1 := x0 + + # Fill rightward + while (x1 < w - 1 && image.test(x1 + 1, y, matchColor)) { + x1 += 1 + image[x1, y] := newColor # This could be replaced with a horizontal-line drawing operation + } + + # Fill leftward + while (x0 > 0 && image.test(x0 - 1, y, matchColor)) { + x0 -= 1 + image[x0, y] := newColor + } + + if (x0 > x1) { return x0 } # Filled at most center + + # x0..x1 is now a run of newly-filled pixels. + + # println(`Filled $y $x0..$x1`) + # println(image) + + # Scan the lines above and below + for ynext in [y - 1, y + 1] { + if (ynext >= 0 && ynext < h) { + var x := x0 + while (x <= x1) { + if (image.test(x, ynext, matchColor)) { + x := fillScan(x, ynext) + } + x += 1 + } + } + } + + return x1 + } else { + return x0 + } + } + + fillScan(x, y) +} diff --git a/Task/Bitmap-Flood-fill/E/bitmap-flood-fill-2.e b/Task/Bitmap-Flood-fill/E/bitmap-flood-fill-2.e new file mode 100644 index 0000000000..0456c0fa67 --- /dev/null +++ b/Task/Bitmap-Flood-fill/E/bitmap-flood-fill-2.e @@ -0,0 +1,11 @@ +{ + println("Read") + def i := readPPM(()) + println("Fill 1") + floodFill(i, 100, 100, makeColor.fromFloat(1, 0, 0)) + println("Fill 2") + floodFill(i, 200, 200, makeColor.fromFloat(0, 1, 0)) + println("Write") + i.writePPM(()) + println("Done") +} diff --git a/Task/Bitmap-Histogram/D/bitmap-histogram.d b/Task/Bitmap-Histogram/D/bitmap-histogram.d new file mode 100644 index 0000000000..c1a5a1fe5e --- /dev/null +++ b/Task/Bitmap-Histogram/D/bitmap-histogram.d @@ -0,0 +1,47 @@ +import grayscale_image; + +Color findSingleChannelMedian(Color)(in Image!Color img) +nothrow if (Color.tupleof.length == 1) // Hack. +in { + assert(img !is null); +} body { + size_t[Color.max + 1] hist; + foreach (immutable c; img.image) + hist[c]++; + + // Slower indexes, but not significantly so. + auto from = Color(0); + auto to = Color(hist.length - 1); + + auto left = hist[from]; + auto right = hist[to]; + + while (from != to) + if (left < right) { + from++; + left += hist[from]; + } else { + to--; + right += hist[to]; + } + + return from; +} + +Image!Color binarizeInPlace(Color)(Image!Color img, + in Color thresh) +nothrow in { + assert(img !is null); +} body { + foreach (immutable i, ref c; img.image) + c = (c < thresh) ? Color.min : Color.max; + return img; +} + +void main() { + Image!RGB im; + im.loadPPM6("quantum_frog.ppm"); + auto img = im.rgb2grayImage(); + img.binarizeInPlace(img.findSingleChannelMedian()) + .savePGM("quantum_frog_bin.pgm"); +} diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Common-Lisp/bitmap-midpoint-circle-algorithm-1.lisp b/Task/Bitmap-Midpoint-circle-algorithm/Common-Lisp/bitmap-midpoint-circle-algorithm-1.lisp new file mode 100644 index 0000000000..74ac36453a --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Common-Lisp/bitmap-midpoint-circle-algorithm-1.lisp @@ -0,0 +1,29 @@ +(defun draw-circle (draw-function x0 y0 radius) + (labels ((foo (x y) + (funcall draw-function x y)) + (put (x y m) + (let ((x+ (+ x0 x)) + (x- (- x0 x)) + (y+ (+ y0 y)) + (y- (- y0 y)) + (x0y+ (+ x0 y)) + (x0y- (- x0 y)) + (xy0+ (+ y0 x)) + (xy0- (- y0 x))) + (foo x+ y+) + (foo x+ y-) + (foo x- y+) + (foo x- y-) + (foo x0y+ xy0+) + (foo x0y+ xy0-) + (foo x0y- xy0+) + (foo x0y- xy0-) + (multiple-value-bind (y m) (if (plusp m) + (values (1- y) (- m (* 8 y))) + (values y m)) + (when (<= x y) + (put (1+ x) + y + (+ m 4 (* 8 x)))))))) + (put 0 radius (- 5 (* 4 radius))) + (values))) diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Common-Lisp/bitmap-midpoint-circle-algorithm-2.lisp b/Task/Bitmap-Midpoint-circle-algorithm/Common-Lisp/bitmap-midpoint-circle-algorithm-2.lisp new file mode 100644 index 0000000000..6bfedff633 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Common-Lisp/bitmap-midpoint-circle-algorithm-2.lisp @@ -0,0 +1,5 @@ +CL-USER> (let ((buffer (make-array '(30 30) + :element-type 'bit))) + (draw-circle (lambda (x y) + (setf (bit buffer x y) 1)) 15 15 10) + buffer) diff --git a/Task/Bitmap-Midpoint-circle-algorithm/D/bitmap-midpoint-circle-algorithm.d b/Task/Bitmap-Midpoint-circle-algorithm/D/bitmap-midpoint-circle-algorithm.d new file mode 100644 index 0000000000..96c0649813 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/D/bitmap-midpoint-circle-algorithm.d @@ -0,0 +1,40 @@ +import bitmap: Image, RGB; + +void circle(Color)(Image!Color img, in int x0, in int y0, + in int radius, in Color color) pure nothrow { + int f = 1 - radius; + int ddfX = 1; + int ddfY = -2 * radius; + int x = 0; + int y = radius; + img[x0, y0 + radius] = color; + img[x0, y0 - radius] = color; + img[x0 + radius, y0] = color; + img[x0 - radius, y0] = color; + + while (x < y) { + if (f >= 0) { + y--; + ddfY += 2; + f += ddfY; + } + x++; + ddfX += 2; + f += ddfX; + img[x0 + x, y0 + y] = color; + img[x0 - x, y0 + y] = color; + img[x0 + x, y0 - y] = color; + img[x0 - x, y0 - y] = color; + img[x0 + y, y0 + x] = color; + img[x0 - y, y0 + x] = color; + img[x0 + y, y0 - x] = color; + img[x0 - y, y0 - x] = color; + } +} + +void main() { + auto img = new Image!RGB(25, 25); + img.clear(RGB.white); + circle(img, 12, 12, 12, RGB.black); + img.textualShow(); +} diff --git a/Task/Bitmap-Read-a-PPM-file/Common-Lisp/bitmap-read-a-ppm-file-1.lisp b/Task/Bitmap-Read-a-PPM-file/Common-Lisp/bitmap-read-a-ppm-file-1.lisp new file mode 100644 index 0000000000..511eba41d7 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Common-Lisp/bitmap-read-a-ppm-file-1.lisp @@ -0,0 +1,71 @@ +(in-package #:rgb-pixel-buffer) + +(defparameter *whitespaces-chars* '(#\SPACE #\RETURN #\TAB #\NEWLINE #\LINEFEED)) + +(defun read-header-chars (stream &optional (delimiter-list *whitespaces-chars*)) + (do ((c (read-char stream nil :eof) + (read-char stream nil :eof)) + (vals nil (if (or (null c) (char= c #\#)) vals (cons c vals)))) ;;don't collect comment chars + ((or (eql c :eof) (member c delimiter-list)) (map 'string #'identity (nreverse vals))) ;;return strings + (when (char= c #\#) ;;skip comments + (read-line stream)))) + +(defun read-ppm-file-header (file) + (with-open-file (s file :direction :input) + (do ((failure-count 0 (1+ failure-count)) + (tokens nil (let ((t1 (read-header-chars s))) + (if (> (length t1) 0) + (cons t1 tokens) + tokens)))) + ((>= (length tokens) 4) (values (nreverse tokens) + (file-position s))) + (when (>= failure-count 10) + (error (format nil "File ~a does not seem to be a proper ppm file - maybe too many comment lines" file))) + (when (= (length tokens) 1) + (when (not (or (string= (first tokens) "P6") (string= (first tokens) "P3"))) + (error (format nil "File ~a is not a ppm file - wrong magic-number. Read ~a instead of P6 or P3 " file (first tokens)))))))) + +(defun read-ppm-image (file) + (flet ((image-data-reader (stream start-position width height image-build-function read-function) + (file-position stream start-position) + (dotimes (row height) + (dotimes (col width) + (funcall image-build-function row col (funcall read-function stream)))))) + (multiple-value-bind (header file-pos) (read-ppm-file-header file) + (let* ((image-type (first header)) + (width (parse-integer (second header) :junk-allowed t)) + (height (parse-integer (third header) :junk-allowed t)) + (max-value (parse-integer (fourth header) :junk-allowed t)) + (image (make-rgb-pixel-buffer width height))) + (when (> max-value 255) + (error "unsupported depth - convert to 1byte depth with pamdepth")) + (cond ((string= "P6" image-type) + (with-open-file (stream file :direction :input :element-type '(unsigned-byte 8)) + (image-data-reader stream + file-pos + width + height + #'(lambda (w h val) + (setf (rgb-pixel image w h) val)) + #'(lambda (stream) + (make-rgb-pixel (read-byte stream) + (read-byte stream) + (read-byte stream)))) + image)) + ((string= "P3" image-type) + (with-open-file (stream file :direction :input) + (image-data-reader stream + file-pos + width + height + #'(lambda (w h val) + (setf (rgb-pixel image w h) val)) + #'(lambda (stream) + (make-rgb-pixel (read stream) + (read stream) + (read stream)))) + image)) + (t 'unsupported)) + image)))) + +(export 'read-ppm-image) diff --git a/Task/Bitmap-Read-a-PPM-file/Common-Lisp/bitmap-read-a-ppm-file-2.lisp b/Task/Bitmap-Read-a-PPM-file/Common-Lisp/bitmap-read-a-ppm-file-2.lisp new file mode 100644 index 0000000000..3b68f3d4cd --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Common-Lisp/bitmap-read-a-ppm-file-2.lisp @@ -0,0 +1 @@ +(read-ppm-image "feep.ppm") diff --git a/Task/Bitmap-Read-a-PPM-file/E/bitmap-read-a-ppm-file-1.e b/Task/Bitmap-Read-a-PPM-file/E/bitmap-read-a-ppm-file-1.e new file mode 100644 index 0000000000..d7a3da4ca2 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/E/bitmap-read-a-ppm-file-1.e @@ -0,0 +1,55 @@ +def chr := .asChar + +def readPPM(inputStream) { + # Proper native-to-E stream IO facilities have not been designed and + # implemented yet, so we are borrowing Java's. Poorly. This *will* be + # improved eventually. + + # Reads one header token, skipping comments and whitespace, and exactly + # one trailing whitespace character + def readToken() { + var token := "" + var c := chr(inputStream.read()) + while (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '#') { + if (c == '#') { + while (c != '\n') { c := chr(inputStream.read()) } + } + # skip over initial whitespace + c := chr(inputStream.read()) + } + while (!(c == ' ' || c == '\t' || c == '\r' || c == '\n')) { + if (c == '#') { + while (c != '\n') { c := chr(inputStream.read()) } + } else { + token += E.toString(c) + c := chr(inputStream.read()) + } + } + return token + } + + # Header + require(readToken() == "P6") + def width := __makeInt(readToken()) + def height := __makeInt(readToken()) + def maxval := __makeInt(readToken()) + + def size := width * height * 3 + + # Body + # See [[Basic bitmap storage]] for the definition and origin of sign() + def data := .fromType(, size) + if (maxval >= 256) { + for _ in 1..size { + data.push(sign((inputStream.read() * 256 + inputStream.read()) * 255 // maxval)) + } + } else { + for _ in 1..size { + data.push(sign(inputStream.read() * 255 // maxval)) + } + } + + def image := makeImage(width, height) + image.replace(data.snapshot()) + return image +} diff --git a/Task/Bitmap-Read-a-PPM-file/E/bitmap-read-a-ppm-file-2.e b/Task/Bitmap-Read-a-PPM-file/E/bitmap-read-a-ppm-file-2.e new file mode 100644 index 0000000000..58286649d5 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/E/bitmap-read-a-ppm-file-2.e @@ -0,0 +1,6 @@ +def readPPMTask(inputFile, outputFile) { + makeGrayscale \ + .fromColor(readPPM((inputFile))) \ + .toColor() \ + .writePPM((outputFile)) +} diff --git a/Task/Bitmap-Read-a-PPM-file/Euphoria/bitmap-read-a-ppm-file-1.euphoria b/Task/Bitmap-Read-a-PPM-file/Euphoria/bitmap-read-a-ppm-file-1.euphoria new file mode 100644 index 0000000000..43a403152e --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Euphoria/bitmap-read-a-ppm-file-1.euphoria @@ -0,0 +1,41 @@ +include get.e + +function get2(integer fn) + sequence temp + temp = get(fn) + return temp[2] - temp[1]*temp[1] +end function + +function read_ppm(sequence filename) + sequence image, line + integer dimx, dimy, maxcolor + atom fn + fn = open(filename, "rb") + if fn < 0 then + return -1 -- unable to open + end if + line = gets(fn) + if not equal(line,"P6\n") then + return -1 -- only ppm6 files are supported + end if + dimx = get2(fn) + if dimx < 0 then + return -1 + end if + dimy = get2(fn) + if dimy < 0 then + return -1 + end if + maxcolor = get2(fn) + if maxcolor != 255 then + return -1 -- maxcolors other then 255 are not supported + end if + image = repeat(repeat(0,dimy),dimx) + for y = 1 to dimy do + for x = 1 to dimx do + image[x][y] = getc(fn)*#10000 + getc(fn)*#100 + getc(fn) + end for + end for + close(fn) + return image +end function diff --git a/Task/Bitmap-Read-a-PPM-file/Euphoria/bitmap-read-a-ppm-file-2.euphoria b/Task/Bitmap-Read-a-PPM-file/Euphoria/bitmap-read-a-ppm-file-2.euphoria new file mode 100644 index 0000000000..e23aa5fafd --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Euphoria/bitmap-read-a-ppm-file-2.euphoria @@ -0,0 +1,5 @@ +sequence image +image = read_ppm("image.ppm") +image = to_gray(image) +image = to_color(image) +write_ppm("image_gray.ppm",image) diff --git a/Task/Bitmap-Write-a-PPM-file/Common-Lisp/bitmap-write-a-ppm-file.lisp b/Task/Bitmap-Write-a-PPM-file/Common-Lisp/bitmap-write-a-ppm-file.lisp new file mode 100644 index 0000000000..d922a0db8d --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Common-Lisp/bitmap-write-a-ppm-file.lisp @@ -0,0 +1,28 @@ +(defun write-rgb-buffer-to-ppm-file (filename buffer) + (with-open-file (stream filename + :element-type '(unsigned-byte 8) + :direction :output + :if-does-not-exist :create + :if-exists :supersede) + (let* ((dimensions (array-dimensions buffer)) + (width (first dimensions)) + (height (second dimensions)) + (header (format nil "P6~A~D ~D~A255~A" + #\newline + width height #\newline + #\newline))) + (loop + :for char :across header + :do (write-byte (char-code char) stream)) #| Assumes char-codes match ASCII |# + + (loop + :for x :upfrom 0 :below width + :do (loop :for y :upfrom 0 :below height + :do (let ((pixel (rgb-pixel buffer x y))) + (let ((red (rgb-pixel-red pixel)) + (green (rgb-pixel-green pixel)) + (blue (rgb-pixel-blue pixel))) + (write-byte red stream) + (write-byte green stream) + (write-byte blue stream))))))) + filename) diff --git a/Task/Bitmap-Write-a-PPM-file/Euphoria/bitmap-write-a-ppm-file-1.euphoria b/Task/Bitmap-Write-a-PPM-file/Euphoria/bitmap-write-a-ppm-file-1.euphoria new file mode 100644 index 0000000000..b7ab37e6f8 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Euphoria/bitmap-write-a-ppm-file-1.euphoria @@ -0,0 +1,15 @@ +constant dimx = 800, dimy = 800 +constant fn = open("first.ppm","wb") -- b - binary mode +sequence color +printf(fn, "P6\n%d %d\n255\n", {dimx,dimy}) +for j = 0 to dimy-1 do + for i = 0 to dimx-1 do + color = { + remainder(i,256), -- red + remainder(j,256), -- green + remainder(i*j,256) -- blue + } + puts(fn,color) + end for +end for +close(fn) diff --git a/Task/Bitmap-Write-a-PPM-file/Euphoria/bitmap-write-a-ppm-file-2.euphoria b/Task/Bitmap-Write-a-PPM-file/Euphoria/bitmap-write-a-ppm-file-2.euphoria new file mode 100644 index 0000000000..4a3c444ae5 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Euphoria/bitmap-write-a-ppm-file-2.euphoria @@ -0,0 +1,14 @@ +procedure write_ppm(sequence filename, sequence image) + integer fn,dimx,dimy + dimy = length(image[1]) + dimx = length(image) + fn = open(filename,"wb") + printf(fn, "P6\n%d %d\n255\n", {dimx,dimy}) + for y = 1 to dimy do + for x = 1 to dimx do + puts(fn, and_bits(image[x][y], {#FF0000,#FF00,#FF}) / + {#010000,#0100,#01}) -- unpack color triple + end for + end for + close(fn) +end procedure diff --git a/Task/Bitmap/C++/bitmap.cpp b/Task/Bitmap/C++/bitmap.cpp new file mode 100644 index 0000000000..fa8a1d5a2a --- /dev/null +++ b/Task/Bitmap/C++/bitmap.cpp @@ -0,0 +1,20 @@ +#include +#include +int main() +{ + using namespace boost::gil; + // create 30x40 image + rgb8_image_t img(30, 40); + + // fill with red + rgb8_pixel_t red(255, 0, 0); + fill_pixels(view(img), red); + + // set pixel at 10x20 to blue + rgb8_pixel_t blue(0, 0, 255); + view(img)(10, 20) = blue; + + // read the value of pixel at 11x20 + rgb8_pixel_t px = const_view(img)(11, 20); + std::cout << "the pixel at 11, 20 is " << (unsigned)px[0] << ':' << (unsigned)px[1] << ':' << (unsigned)px[2] << '\n'; +} diff --git a/Task/Bitmap/Common-Lisp/bitmap-1.lisp b/Task/Bitmap/Common-Lisp/bitmap-1.lisp new file mode 100644 index 0000000000..fc1c96fe22 --- /dev/null +++ b/Task/Bitmap/Common-Lisp/bitmap-1.lisp @@ -0,0 +1,7 @@ +(defpackage #:rgb-pixel-buffer + (:use #:common-lisp) + (:export #:rgb-pixel-component #:rgb-pixel #:rgb-pixel-buffer + #:+red+ #:+green+ #:+blue+ #:+black+ #:+white+ + #:make-rgb-pixel #:make-rgb-pixel-buffer #:rgb-pixel-buffer-width + #:rgb-pixel-buffer-height #:rgb-pixel-red #:rgb-pixel-green + #:rgb-pixel-blue #:fill-rgb-pixel-buffer)) diff --git a/Task/Bitmap/Common-Lisp/bitmap-2.lisp b/Task/Bitmap/Common-Lisp/bitmap-2.lisp new file mode 100644 index 0000000000..c50a1e9e8a --- /dev/null +++ b/Task/Bitmap/Common-Lisp/bitmap-2.lisp @@ -0,0 +1,69 @@ +(in-package #:rgb-pixel-buffer) + +(deftype rgb-pixel-component () + '(unsigned-byte 8)) + +(deftype rgb-pixel () + '(unsigned-byte 24)) + +(deftype rgb-pixel-buffer (&optional (width '*) (height '*)) + `(array rgb-pixel (,width ,height))) + +(defconstant +black+ 0) +(defconstant +white+ #xFFFFFF) +(defconstant +red+ #xFF0000) +(defconstant +green+ #x00FF00) +(defconstant +blue+ #x0000FF) + +(defun make-rgb-pixel (r g b) + (declare (type rgb-pixel-component r g b)) + (logior (ash r 16) (ash g 8) b)) + +(defun rgb-pixel-red (rgb) + (declare (type rgb-pixel rgb)) + (logand (ash rgb -16) #xFF)) + +(defun rgb-pixel-green (rgb) + (declare (type rgb-pixel rgb)) + (logand (ash rgb -8) #xFF)) + +(defun rgb-pixel-blue (rgb) + (declare (type rgb-pixel rgb)) + (logand rgb #xFF)) + +(defun make-rgb-pixel-buffer (width height &optional (initial-element +black+)) + (declare (type (integer 1) width height)) + (declare (type rgb-pixel initial-element)) + (make-array (list width height) + :element-type 'rgb-pixel + :initial-element initial-element)) + +(defun rgb-pixel-buffer-width (buffer) + (first (array-dimensions buffer))) + +(defun rgb-pixel-buffer-height (buffer) + (second (array-dimensions buffer))) + +(defun rgb-pixel (buffer x y) + (declare (type rgb-pixel-buffer buffer)) + (declare (type (integer 0) x y)) + (aref buffer x y)) + +(defun (setf rgb-pixel) (value buffer x y) + (declare (type rgb-pixel-buffer buffer)) + (declare (type rgb-pixel value)) + (declare (type (integer 0) x y)) + (setf (aref buffer x y) value)) + +(defun fill-rgb-pixel-buffer (buffer pixel) + (declare (type rgb-pixel-buffer buffer)) + (declare (type rgb-pixel pixel)) + (let* ((dimensions (array-dimensions buffer)) + (width (first dimensions)) + (height (second dimensions))) + (loop + :for y :of-type fixnum :upfrom 0 :below height + :do (loop + :for x :of-type fixnum :upfrom 0 :below width + :do (setf (rgb-pixel buffer x y) pixel))) + buffer)) diff --git a/Task/Bitmap/Common-Lisp/bitmap-3.lisp b/Task/Bitmap/Common-Lisp/bitmap-3.lisp new file mode 100644 index 0000000000..30c621b53d --- /dev/null +++ b/Task/Bitmap/Common-Lisp/bitmap-3.lisp @@ -0,0 +1,6 @@ +(defvar *buffer* (make-rgb-pixel-buffer 10 10)) +(fill-rgb-pixel-buffer *buffer* +white+) +(setf (rgb-pixel *buffer* 0 0) +red+) +(setf (rgb-pixel *buffer* 0 9) +red+) +(setf (rgb-pixel *buffer* 9 0) +red+) +(setf (rgb-pixel *buffer* 9 9) +red+) diff --git a/Task/Bitmap/D/bitmap.d b/Task/Bitmap/D/bitmap.d new file mode 100644 index 0000000000..5e8cb557a9 --- /dev/null +++ b/Task/Bitmap/D/bitmap.d @@ -0,0 +1,144 @@ +module bitmap; + +import std.stdio, std.array, std.exception, std.string, std.conv; + +final class Image(T) { + static if (__traits(compiles, { auto x = T.black; })) + T blackColor = T.black; + else + T blackColor = T.init; + + T[] image; + private size_t nx_, ny_; + + this(in int nxx=0, in int nyy=0, in bool inizialize=true) + pure nothrow { + allocate(nxx, nyy, inizialize); + } + + void allocate(in int nxx=0, in int nyy=0, in bool inizialize=true) + pure nothrow in { + assert(nxx >= 0 && nyy >= 0); + } body { + this.nx_ = nxx; + this.ny_ = nyy; + if (nxx * nyy > 0) { + if (inizialize) + image.length = nxx * nyy; + else // Optimization. + image = minimallyInitializedArray!(typeof(image)) + (nxx * nyy); + } + } + + static Image fromData(T[] data, in size_t nxx=0, in size_t nyy=0) + pure nothrow in { + assert(nxx >= 0 && nyy >= 0 && data.length == nxx * nyy); + } body { + auto result = new Image(); + result.image = data; + result.nx_ = nxx; + result.ny_ = nyy; + return result; + } + + @property size_t nx() const pure nothrow { return nx_; } + @property size_t ny() const pure nothrow { return ny_; } + + ref T opIndex(in size_t x, in size_t y) pure nothrow + in { + assert(x < nx_ && y < ny_); + } body { + return image[x + y * nx_]; + } + + T opIndex(in size_t x, in size_t y) const pure nothrow + in { + assert(x < nx_ && y < ny_); + } body { + return image[x + y * nx_]; + } + + T opIndexAssign(in T color, in size_t x, in size_t y) pure nothrow + in { + assert(x < nx_ && y < ny_); + } body { + return image[x + y * nx_] = color; + } + + void opIndexUnary(string op)(in size_t x, in size_t y) pure nothrow + if (op == "++" || op == "--") in { + assert(x < nx_ && y < ny_); + } body { + mixin("image[x + y * nx_] " ~ op ~ ";"); + } + + void clear(in T color=blackColor) pure nothrow { + image[] = color; + } + + /// The axis origin is at the top left. + void textualShow() const { + size_t i = 0; + foreach (immutable y; 0 .. ny_) { + foreach (immutable x; 0 .. nx_) + putchar(image[i++] == blackColor ? '#' : '.'); + putchar('\n'); + } + } +} + + +struct RGB { + ubyte r, g, b; + enum black = RGB(); + enum white = RGB(255, 255, 255); +} + + +Image!RGB loadPPM6(Image!RGB img, in string fileName) { + if (img is null) + img = new Image!RGB(); + auto f = File(fileName, "rb"); + enforce(f.readln().strip() == "P6"); + string line; + do { + line = f.readln(); + } while (line.length && line[0] == '#'); // Skip comments. + const size = line.split(); + enforce(size.length == 2); + img.allocate(size[0].to!uint(), size[1].to!uint()); + enforce(f.readln().strip() == "255"); + auto l = new ubyte[img.nx * 3]; + size_t i = 0; + foreach (immutable y; 0 .. img.ny) { + f.rawRead!ubyte(l); + foreach (immutable x; 0 .. img.nx) + img.image[i++] = RGB(l[x*3], l[x*3 + 1], l[x*3 + 2]); + } + return img; +} + + +void savePPM6(in Image!RGB img, in string fileName) +in { + assert(img !is null); + assert(img.nx > 0 && img.nx > 0); +} body { + auto f = File(fileName, "wb"); + f.writefln("P6\n%d %d\n255", img.nx, img.ny); + size_t i = 0; + foreach (immutable y; 0 .. img.ny) + foreach (immutable x; 0 .. img.nx) { + immutable p = img.image[i++]; + f.write(cast(char)p.r, cast(char)p.g, cast(char)p.b); + } +} + +version (bitmap_main) { + void main() { + auto img = new Image!RGB(30, 10); + img[4, 5] = RGB.white; + img.textualShow(); + } +} diff --git a/Task/Bitmap/E/bitmap-1.e b/Task/Bitmap/E/bitmap-1.e new file mode 100644 index 0000000000..647eedfd77 --- /dev/null +++ b/Task/Bitmap/E/bitmap-1.e @@ -0,0 +1,97 @@ +def makeFlexList := +def format := .format + +def CHANNELS := 3 +def UByte := 0..255 + +def makeColor { + to fromFloat(r, g, b) { + return makeColor.fromByte((r * 255).round(), + (g * 255).round(), + (b * 255).round()) + } + to fromByte(r :UByte, g :UByte, b :UByte) { + def color { + to __printOn(out) { + out.print(format("%02x%02x%02x", [color.rb(), color.gb(), color.bb()])) + } + to rf() { return r / 255 } + to gf() { return g / 255 } + to bf() { return b / 255 } + to rb() { return r } + to gb() { return g } + to bb() { return b } + } + return color + } +} + +/** Convert 0..255 into 0..127 -128..-1 */ +def sign(v) { + return v %% 256 - 2*(v & 128) +} + +def makeImage(width, height) { + # NOTE: The primary E implementation is in Java and Java's fixed-size integers only + # come in signed varieties. Therefore, there is a little bit of extra arithmetic. + # + # In an ideal E implementation we would specify the type 0..255, but this is not + # currently possible everywhere, or efficient. + + def storage := makeFlexList.fromType(, width * height * CHANNELS) + storage.setSize(width * height * CHANNELS) + + def X := 0..!width + def Y := 0..!height + + def flexImage { + to __printOn(out) { + for y in Y { + out.print("[") + for x in X { + out.print(flexImage[x, y], " ") + } + out.println("]") + } + } + to width() { return width } + to height() { return height } + to fill(color) { + for x in X { + for y in Y { + flexImage[x, y] := color + } + } + } + to get(x :X, y :Y) { + def base := (y * width + x) * CHANNELS + return makeColor.fromByte(storage[base + 0] %% 256, + storage[base + 1] %% 256, + storage[base + 2] %% 256) + } + /** Provided to make [[Flood fill]] slightly less insanely slow. */ + to test(x :X, y :Y, c) { + def base := (y * width + x) * CHANNELS + return storage[base + 0] <=> sign(c.rb()) && + storage[base + 1] <=> sign(c.gb()) && + storage[base + 2] <=> sign(c.bb()) + } + to put(x :X, y :Y, c) { + def base := (y * width + x) * CHANNELS + storage[base + 0] := sign(c.rb()) + storage[base + 1] := sign(c.gb()) + storage[base + 2] := sign(c.bb()) + } + to writePPM(outputStream) { + outputStream.write(`P6$\n$width $height$\n255$\n`.getBytes("US-ASCII")) + outputStream.write(storage.getArray()) + } + /** Used for [[Read ppm file]] */ + to replace(list :List) { + require(list.size() == width * height * CHANNELS) + storage(0) := list + } + } + + return flexImage +} diff --git a/Task/Bitmap/E/bitmap-2.e b/Task/Bitmap/E/bitmap-2.e new file mode 100644 index 0000000000..59837baa43 --- /dev/null +++ b/Task/Bitmap/E/bitmap-2.e @@ -0,0 +1,29 @@ +? def i := makeImage(3, 3) +# value: [000000 000000 000000 ] +# [000000 000000 000000 ] +# [000000 000000 000000 ] +# + +? i.fill(makeColor.fromFloat(1, 0, 0)) +? i +# value: [ff0000 ff0000 ff0000 ] +# [ff0000 ff0000 ff0000 ] +# [ff0000 ff0000 ff0000 ] +# + +? i[1, 1] := makeColor.fromFloat(0.5, 0.5, 0.5) +# value: 808080 + +? i +# value: [ff0000 ff0000 ff0000 ] +# [ff0000 808080 ff0000 ] +# [ff0000 ff0000 ff0000 ] +# + +? i[0, 1] +# value: ff0000 + +? i[1, 1] +# value: 808080 + +? i.writePPM(()) diff --git a/Task/Bitmap/Euphoria/bitmap.euphoria b/Task/Bitmap/Euphoria/bitmap.euphoria new file mode 100644 index 0000000000..6a7738a031 --- /dev/null +++ b/Task/Bitmap/Euphoria/bitmap.euphoria @@ -0,0 +1,23 @@ +-- Some color constants: +constant + black = #000000, + white = #FFFFFF, + red = #FF0000, + green = #00FF00, + blue = #0000FF + +-- Create new image filled with some color +function new_image(integer width, integer height, atom fill_color) + return repeat(repeat(fill_color,height),width) +end function + +-- Usage example: +sequence image +image = new_image(800,600,black) + +-- Set pixel color: +image[400][300] = red + +-- Get pixel color +sequence color +color = image[400][300] -- Now color is #FF0000 diff --git a/Task/Bitwise-IO/D/bitwise-io.d b/Task/Bitwise-IO/D/bitwise-io.d new file mode 100644 index 0000000000..cfcef91426 --- /dev/null +++ b/Task/Bitwise-IO/D/bitwise-io.d @@ -0,0 +1,131 @@ +import std.stdio: File; +import core.stdc.stdio: FILE, fputc, fgetc; + +/*********** +Bitwise I/O, the file must be in binary mode, and its FILE* +must be kept open during the usage of BitwiseFile. +*/ +struct BitwiseFile { + FILE* fp; + uint accu; + int bits; + + this(File f) + in { + assert(f.isOpen); + //assert(f.isBinary); + } body { + this.fp = f.getFP(); + } + + void write(const(ubyte)[] buf, size_t nBits, size_t shift) + nothrow { + auto accu = this.accu; + auto bits = this.bits; + auto bufPtr = buf.ptr; + + bufPtr += shift / 8; + shift %= 8; + + while (nBits || bits >= 8) { + while (bits >= 8) { + bits -= 8; + fputc(accu >> bits, this.fp); + accu &= (1 << bits) - 1; + } + while (bits < 8 && nBits) { + accu = (accu << 1) | + (((128 >> shift) & *bufPtr) >> (7 - shift)); + nBits--; + bits++; + shift++; + if (shift == 8) { + shift = 0; + bufPtr++; + } + } + } + + this.accu = accu; + this.bits = bits; + } + + size_t read(ubyte[] buf, size_t nBits, size_t shift) nothrow { + auto accu = this.accu; + auto bits = this.bits; + auto bufPtr = buf.ptr; + int i = 0; + + bufPtr += shift / 8; + shift %= 8; + + while (nBits) { + while (bits && nBits) { + immutable mask = 128u >> shift; + if (accu & (1 << (bits - 1))) + *bufPtr |= mask; + else + *bufPtr &= ~mask; + + nBits--; + bits--; + shift++; + + if (shift >= 8) { + shift = 0; + bufPtr++; + } + } + if (!nBits) + break; + accu = (accu << 8) | fgetc(this.fp); + bits += 8; + } + + this.accu = accu; + this.bits = bits; + return i; + } + + void detach() nothrow { + if (this.bits) { + this.accu <<= 8 - this.bits; + fputc(this.accu, this.fp); + } + this.fp = null; + this.accu = 0; + this.bits = 0; + } + + nothrow ~this() { + detach(); + } +} + +void main() { // Demo code. + import core.stdc.stdio: fopen, fclose; + import std.stdio; + + immutable data = cast(immutable(ubyte)[])"abcdefghijk".dup; + enum n = data.length; + + // For each ubyte in data, write 7 bits skipping 1. + auto fout = File("bitwise_io_test.bin", "wb"); + auto bf1 = BitwiseFile(fout); + foreach (immutable i; 0 .. n) + bf1.write(data[i .. $], 7, 1); + bf1.detach(); + fout.close(); + + // Read 7 bits and expand to each ubyte of result skipping 1 bit. + ubyte[n + 1] result = '\0'; + auto fin = File("bitwise_io_test.bin", "rb"); + auto bf2 = BitwiseFile(fin); + foreach (immutable i; 0 .. n) + bf2.read(result[i .. $], 7, 1); + bf2.detach(); + fin.close(); + + // Should be the same chars as 'data'. + writeln(cast(string)result); +} diff --git a/Task/Bitwise-operations/C++/bitwise-operations.cpp b/Task/Bitwise-operations/C++/bitwise-operations.cpp new file mode 100644 index 0000000000..4368565495 --- /dev/null +++ b/Task/Bitwise-operations/C++/bitwise-operations.cpp @@ -0,0 +1,14 @@ +#include + +void bitwise(int a, int b) +{ + std::cout << "a and b: " << (a & b) << '\n'; // Note: parentheses are needed because & has lower precedence than << + std::cout << "a or b: " << (a | b) << '\n'; + std::cout << "a xor b: " << (a ^ b) << '\n'; + std::cout << "not a: " << ~a << '\n'; + std::cout << "a shl b: " << (a << b) << '\n'; // Note: "<<" is used both for output and for left shift + std::cout << "a shr b: " << (a >> b) << '\n'; // typically arithmetic right shift, but not guaranteed + unsigned int c = a; + std::cout << "c sra b: " << (c >> b) << '\n'; // logical right shift (guaranteed) + // there are no rotation operators in C++ +} diff --git a/Task/Bitwise-operations/Common-Lisp/bitwise-operations.lisp b/Task/Bitwise-operations/Common-Lisp/bitwise-operations.lisp new file mode 100644 index 0000000000..f79d09727f --- /dev/null +++ b/Task/Bitwise-operations/Common-Lisp/bitwise-operations.lisp @@ -0,0 +1,9 @@ +(defun bitwise (a b) + (print (logand a b)) ; AND + (print (logior a b)) ; OR ("ior" = inclusive or) + (print (logxor a b)) ; XOR + (print (lognot a)) ; NOT + (print (ash a b)) ; arithmetic left shift (positive 2nd arg) + (print (ash a (- b))) ; arithmetic right shift (negative 2nd arg) + ; no logical shift +) diff --git a/Task/Bitwise-operations/D/bitwise-operations.d b/Task/Bitwise-operations/D/bitwise-operations.d new file mode 100644 index 0000000000..d617fd75e4 --- /dev/null +++ b/Task/Bitwise-operations/D/bitwise-operations.d @@ -0,0 +1,23 @@ +T rot(T)(in T x, in int shift) pure nothrow { + return (x >>> shift) | (x << (T.sizeof * 8 - shift)); +} + +void testBit(in int a, in int b) { + import std.stdio; + writefln("Input: a = %d, b = %d", a, b); + writefln("AND : %8b & %08b = %032b (%4d)", a, b, a & b, a & b); + writefln(" OR : %8b | %08b = %032b (%4d)", a, b, a | b, a | b); + writefln("XOR : %8b ^ %08b = %032b (%4d)", a, b, a ^ b, a ^ b); + writefln("LSH : %8b << %08b = %032b (%4d)", a, b, a << b, a << b); + writefln("RSH : %8b >> %08b = %032b (%4d)", a, b, a >> b, a >> b); + writefln("NOT : %8s ~ %08b = %032b (%4d)", "", a, ~a, ~a); + writefln("ROT : rot(%8b, %d) = %032b (%4d)", + a, b, rot(a, b), rot(a, b)); +} + +void main() { + immutable int a = 0b_1111_1111; // bit literal 255 + immutable int b = 0b_0000_0010; // bit literal 2 + + testBit(a, b); +} diff --git a/Task/Bitwise-operations/DWScript/bitwise-operations.dwscript b/Task/Bitwise-operations/DWScript/bitwise-operations.dwscript new file mode 100644 index 0000000000..d3182f4dd4 --- /dev/null +++ b/Task/Bitwise-operations/DWScript/bitwise-operations.dwscript @@ -0,0 +1,6 @@ +PrintLn('2 and 3 = '+IntToStr(2 and 3)); +PrintLn('2 or 3 = '+IntToStr(2 or 3)); +PrintLn('2 xor 3 = '+IntToStr(2 xor 3)); +PrintLn('not 2 = '+IntToStr(not 2)); +PrintLn('2 shl 3 = '+IntToStr(2 shl 3)); +PrintLn('2 shr 3 = '+IntToStr(2 shr 3)); diff --git a/Task/Bitwise-operations/Delphi/bitwise-operations.delphi b/Task/Bitwise-operations/Delphi/bitwise-operations.delphi new file mode 100644 index 0000000000..56dd920b49 --- /dev/null +++ b/Task/Bitwise-operations/Delphi/bitwise-operations.delphi @@ -0,0 +1,14 @@ +program Bitwise; + +{$APPTYPE CONSOLE} + +begin + Writeln('2 and 3 = ', 2 and 3); + Writeln('2 or 3 = ', 2 or 3); + Writeln('2 xor 3 = ', 2 xor 3); + Writeln('not 2 = ', not 2); + Writeln('2 shl 3 = ', 2 shl 3); + Writeln('2 shr 3 = ', 2 shr 3); +// there are no built-in rotation operators in Delphi + Readln; +end. diff --git a/Task/Bitwise-operations/E/bitwise-operations.e b/Task/Bitwise-operations/E/bitwise-operations.e new file mode 100644 index 0000000000..f4b09c5dd3 --- /dev/null +++ b/Task/Bitwise-operations/E/bitwise-operations.e @@ -0,0 +1,10 @@ +def bitwise(a :int, b :int) { + println(`Bitwise operations: + a AND b: ${a & b} + a OR b: ${a | b} + a XOR b: ${a ^ b} + NOT a: " + ${~a} + a left shift b: ${a << b} + a right shift b: ${a >> b} +`) +} diff --git a/Task/Bitwise-operations/Elena/bitwise-operations.elena b/Task/Bitwise-operations/Elena/bitwise-operations.elena new file mode 100644 index 0000000000..fb5b01ca12 --- /dev/null +++ b/Task/Bitwise-operations/Elena/bitwise-operations.elena @@ -0,0 +1,20 @@ +#define std'dictionary'*. +#define std'basic'*. + +#symbol BitwiseTest &former:anA &later:aB = +[ + 'program'output << anA << " and " << aB << " = " << anA and:aB << "%n". + 'program'output << anA << " or " << aB << " = " << anA or:aB << "%n". + 'program'output << anA << " xor " << aB << " = " << anA xor:aB << "%n". + 'program'output << "not " << anA << " = " << anA inverted << "%n". + 'program'output << anA << " shr " << aB << " = " << anA __shift'add:aB << "%n". + 'program'output << anA << " shl " << aB << " = " << anA __shift'subtract:aB << "%n". +]. + +#symbol Program = +[ + #var a := 'program'input >> Integer. + #var b := 'program'input >> Integer. + + BitwiseTest &&former:a &later:b. +]. diff --git a/Task/Boolean-values/CMake/boolean-values.cmake b/Task/Boolean-values/CMake/boolean-values.cmake new file mode 100644 index 0000000000..caf7533b0c --- /dev/null +++ b/Task/Boolean-values/CMake/boolean-values.cmake @@ -0,0 +1,8 @@ +foreach(var 1 42 ON yes True y Princess + 0 OFF no False n Princess-NOTFOUND) + if(var) + message(STATUS "${var} is true.") + else() + message(STATUS "${var} is false.") + endif() +endforeach(var) diff --git a/Task/Boolean-values/Clean/boolean-values.clean b/Task/Boolean-values/Clean/boolean-values.clean new file mode 100644 index 0000000000..c0de49de2c --- /dev/null +++ b/Task/Boolean-values/Clean/boolean-values.clean @@ -0,0 +1 @@ +::Bool = False | True diff --git a/Task/Boolean-values/E/boolean-values-1.e b/Task/Boolean-values/E/boolean-values-1.e new file mode 100644 index 0000000000..463575d1ec --- /dev/null +++ b/Task/Boolean-values/E/boolean-values-1.e @@ -0,0 +1,8 @@ +? if (true) { "a" } else { "b" } +# value: "a" + +? if (false) { "a" } else { "b" } +# value: "b" + +? if (90) { "a" } else { "b" } +# problem: the int 90 doesn't coerce to a boolean diff --git a/Task/Boolean-values/E/boolean-values-2.e b/Task/Boolean-values/E/boolean-values-2.e new file mode 100644 index 0000000000..6bb015e40a --- /dev/null +++ b/Task/Boolean-values/E/boolean-values-2.e @@ -0,0 +1,7 @@ +? def bowlian { +> to __conformTo(guard) { +> if (guard == boolean) { return true } +> } +> } +> if (bowlian) { "a" } else { "b" } +# value: "a" diff --git a/Task/Boolean-values/EGL/boolean-values.egl b/Task/Boolean-values/EGL/boolean-values.egl new file mode 100644 index 0000000000..45fd0d8c48 --- /dev/null +++ b/Task/Boolean-values/EGL/boolean-values.egl @@ -0,0 +1,20 @@ +myBool boolean = 0; +SysLib.writeStdout("myBool: " + StrLib.booleanAsString(myBool)); +myBool = 1; +SysLib.writeStdout("myBool: " + StrLib.booleanAsString(myBool)); +myBool = 2; +SysLib.writeStdout("myBool: " + StrLib.booleanAsString(myBool)); +myBool = false; +SysLib.writeStdout("myBool: " + StrLib.booleanAsString(myBool)); +myBool = true; +SysLib.writeStdout("myBool: " + StrLib.booleanAsString(myBool)); +myInt int = 0; +SysLib.writeStdout("myInt: " + StrLib.booleanAsString(myInt)); +myInt = 1; +SysLib.writeStdout("myInt: " + StrLib.booleanAsString(myInt)); +myInt = 2; +SysLib.writeStdout("myInt: " + StrLib.booleanAsString(myInt)); +myInt = false; +SysLib.writeStdout("myInt: " + StrLib.booleanAsString(myInt)); +myInt = true; +SysLib.writeStdout("myInt: " + StrLib.booleanAsString(myInt)); diff --git a/Task/Box-the-compass/C++/box-the-compass.cpp b/Task/Box-the-compass/C++/box-the-compass.cpp new file mode 100644 index 0000000000..385f8a9422 --- /dev/null +++ b/Task/Box-the-compass/C++/box-the-compass.cpp @@ -0,0 +1,59 @@ +#include +#include +#include +#include +#include +#include +#include +using std::string; +using namespace boost::assign; + +int get_Index(float angle) +{ + return static_cast(floor(angle / 11.25 +0.5 )) % 32 + 1; +} + +string get_Abbr_From_Index(int i) +{ + static boost::array points(list_of + ("N")("NbE")("NNE")("NEbN")("NE")("NEbE")("ENE")("EbN") + ("E")("EbS")("ESE")("SEbE")("SE")("SEbS")("SSE")("SbE") + ("S")("SbW")("SSW")("SWbS")("SW")("SWbW")("WSW")("WbS") + ("W")("WbN")("WNW")("NWbW")("NW")("NWbN")("NNW")("NbW")); + return points[i-1]; +} + +string Build_Name_From_Abbreviation(string a) +{ + string retval; + for (int i = 0; i < a.size(); ++i){ + if ((1 == i) && (a[i] != 'b') && (a.size() == 3)) retval += "-"; + switch (a[i]){ + case 'N' : retval += "north"; break; + case 'S' : retval += "south"; break; + case 'E' : retval += "east"; break; + case 'W' : retval += "west"; break; + case 'b' : retval += " by "; break; + } + } + retval[0] = toupper(retval[0]); + return retval; +} + +int main() +{ + boost::array headings(list_of + (0.0)(16.87)(16.88)(33.75)(50.62)(50.63)(67.5)(84.37)(84.38)(101.25) + (118.12)(118.13)(135.0)(151.87)(151.88)(168.75)(185.62)(185.63)(202.5) + (219.37)(219.38)(236.25)(253.12)(253.13)(270.0)(286.87)(286.88)(303.75) + (320.62)(320.63)(337.5)(354.37)(354.38)); + int i; + boost::format f("%1$4d %2$-20s %3$_7.2f"); + + BOOST_FOREACH(float a, headings) + { + i = get_Index(a); + std::cout << f % i % Build_Name_From_Abbreviation(get_Abbr_From_Index(i)) % a << std::endl; + } + return 0; +} diff --git a/Task/Box-the-compass/D/box-the-compass.d b/Task/Box-the-compass/D/box-the-compass.d new file mode 100644 index 0000000000..141b2cc2e4 --- /dev/null +++ b/Task/Box-the-compass/D/box-the-compass.d @@ -0,0 +1,34 @@ +import std.stdio, std.string, std.math, std.array; + +struct boxTheCompass { + immutable static string[32] points; + + /*pure nothrow*/ static this() { + immutable cardinal = ["north", "east", "south", "west"]; + immutable desc = ["1", "1 by 2", "1-C", "C by 1", "C", + "C by 2", "2-C", "2 by 1"]; + + foreach (immutable i; 0 .. 4) { + immutable s1 = cardinal[i]; + immutable s2 = cardinal[(i + 1) % 4]; + immutable sc = (s1 == "north" || s1 == "south") ? + (s1 ~ s2) : (s2 ~ s1); + foreach (immutable j; 0 .. 8) + points[i * 8 + j] = desc[j].replace("1", s1). + replace("2", s2).replace("C",sc); + } + } + + static string opCall(in double degrees) /*pure nothrow*/ { + immutable testD = (degrees / 11.25) + 0.5; + return capitalize(points[cast(int)floor(testD % 32)]); + } +} + +void main() { + foreach (immutable i; 0 .. 33) { + immutable heading = i * 11.25 + [0, 5.62, -5.62][i % 3]; + writefln("%s\t%18s\t%s", i % 32 + 1, + heading.boxTheCompass, heading); + } +} diff --git a/Task/Box-the-compass/Euphoria/box-the-compass.euphoria b/Task/Box-the-compass/Euphoria/box-the-compass.euphoria new file mode 100644 index 0000000000..89204975e6 --- /dev/null +++ b/Task/Box-the-compass/Euphoria/box-the-compass.euphoria @@ -0,0 +1,23 @@ +constant names = {"North","North by east","North-northeast","Northeast by north", + "Northeast","Northeast by east","East-northeast","East by north","East", + "East by south","East-southeast","Southeast by east","Southeast","Southeast by south", + "South-southeast","South by east","South","South by west","South-southwest", + "Southwest by south","Southwest","Southwest by west","West-southwest", + "West by south","West","West by north","West-northwest","Northwest by west", + "Northwest","Northwest by north","North-northwest","North by west"} + +function deg2ind(atom degree) + return remainder(floor(degree*32/360+.5),32)+1 +end function + +sequence degrees +degrees = {} +for i = 0 to 32 do + degrees &= i*11.25 + 5.62*(remainder(i+1,3)-1) +end for + +integer j +for i = 1 to length(degrees) do + j = deg2ind(degrees[i]) + printf(1, "%6.2f %2d %-22s\n", {degrees[i], j, names[j]}) +end for diff --git a/Task/Break-OO-privacy/C++/break-oo-privacy-1.cpp b/Task/Break-OO-privacy/C++/break-oo-privacy-1.cpp new file mode 100644 index 0000000000..2c079824df --- /dev/null +++ b/Task/Break-OO-privacy/C++/break-oo-privacy-1.cpp @@ -0,0 +1,67 @@ +#include + +class CWidget; // Forward-declare that we have a class named CWidget. + +class CFactory +{ + friend class CWidget; +private: + unsigned int m_uiCount; +public: + CFactory(); + ~CFactory(); + CWidget* GetWidget(); +}; + +class CWidget +{ +private: + CFactory& m_parent; + +private: + CWidget(); // Disallow the default constructor. + CWidget(const CWidget&); // Disallow the copy constructor + CWidget& operator=(const CWidget&); // Disallow the assignment operator. +public: + CWidget(CFactory& parent); + ~CWidget(); +}; + +// CFactory constructors and destructors. Very simple things. +CFactory::CFactory() : m_uiCount(0) {} +CFactory::~CFactory() {} + +// CFactory method which creates CWidgets. +CWidget* CFactory::GetWidget() +{ + // Create a new CWidget, tell it we're its parent. + return new CWidget(*this); +} + +// CWidget constructor +CWidget::CWidget(CFactory& parent) : m_parent(parent) +{ + ++m_parent.m_uiCount; + + std::cout << "Widget spawning. There are now " << m_parent.m_uiCount << " Widgets instanciated." << std::endl; +} + +CWidget::~CWidget() +{ + --m_parent.m_uiCount; + + std::cout << "Widget dieing. There are now " << m_parent.m_uiCount << " Widgets instanciated." << std::endl; +} + +int main() +{ + CFactory factory; + + CWidget* pWidget1 = factory.GetWidget(); + CWidget* pWidget2 = factory.GetWidget(); + delete pWidget1; + + CWidget* pWidget3 = factory.GetWidget(); + delete pWidget3; + delete pWidget2; +} diff --git a/Task/Break-OO-privacy/C++/break-oo-privacy-2.cpp b/Task/Break-OO-privacy/C++/break-oo-privacy-2.cpp new file mode 100644 index 0000000000..feaf314ed6 --- /dev/null +++ b/Task/Break-OO-privacy/C++/break-oo-privacy-2.cpp @@ -0,0 +1,6 @@ +Widget spawning. There are now 1 Widgets instanciated. +Widget spawning. There are now 2 Widgets instanciated. +Widget dieing. There are now 1 Widgets instanciated. +Widget spawning. There are now 2 Widgets instanciated. +Widget dieing. There are now 1 Widgets instanciated. +Widget dieing. There are now 0 Widgets instanciated. diff --git a/Task/Break-OO-privacy/C++/break-oo-privacy-3.cpp b/Task/Break-OO-privacy/C++/break-oo-privacy-3.cpp new file mode 100644 index 0000000000..1be215753f --- /dev/null +++ b/Task/Break-OO-privacy/C++/break-oo-privacy-3.cpp @@ -0,0 +1,66 @@ +#include + +class CWidget; // Forward-declare that we have a class named CWidget. + +class CFactory +{ +private: + unsigned int m_uiCount; +public: + CFactory(); + ~CFactory(); + CWidget* GetWidget(); +}; + +class CWidget +{ +private: + unsigned int* m_pCounter; + +private: + CWidget(); // Disallow the default constructor. + CWidget(const CWidget&); // Disallow the copy constructor + CWidget& operator=(const CWidget&); // Disallow the assignment operator. +public: + CWidget(unsigned int* pCounter); + ~CWidget(); +}; + +// CFactory constructors and destructors. Very simple things. +CFactory::CFactory() : m_uiCount(0) {} +CFactory::~CFactory() {} + +// CFactory method which creates CWidgets. +CWidget* CFactory::GetWidget() +{ + // Create a new CWidget, tell it we're its parent. + return new CWidget(&m_uiCount); +} + +// CWidget constructor +CWidget::CWidget(unsigned int* pCounter) : m_pCounter(pCounter) +{ + ++*m_pCounter; + + std::cout << "Widget spawning. There are now " << *m_pCounter<< " Widgets instanciated." << std::endl; +} + +CWidget::~CWidget() +{ + --*m_pCounter; + + std::cout << "Widget dieing. There are now " << *m_pCounter<< " Widgets instanciated." << std::endl; +} + +int main() +{ + CFactory factory; + + CWidget* pWidget1 = factory.GetWidget(); + CWidget* pWidget2 = factory.GetWidget(); + delete pWidget1; + + CWidget* pWidget3 = factory.GetWidget(); + delete pWidget3; + delete pWidget2; +} diff --git a/Task/Break-OO-privacy/C-sharp/break-oo-privacy-1.cs b/Task/Break-OO-privacy/C-sharp/break-oo-privacy-1.cs new file mode 100644 index 0000000000..2a027ec2fd --- /dev/null +++ b/Task/Break-OO-privacy/C-sharp/break-oo-privacy-1.cs @@ -0,0 +1,18 @@ +using System; +using System.Reflection; + +public class MyClass +{ + private int answer = 42; +} + +public class Program +{ + public static void Main() + { + var myInstance = new MyClass(); + var fieldInfo = typeof(MyClass).GetField("answer", BindingFlags.NonPublic | BindingFlags.Instance); + var answer = fieldInfo.GetValue(myInstance); + Console.WriteLine(answer); + } +} diff --git a/Task/Break-OO-privacy/C-sharp/break-oo-privacy-2.cs b/Task/Break-OO-privacy/C-sharp/break-oo-privacy-2.cs new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/Task/Break-OO-privacy/C-sharp/break-oo-privacy-2.cs @@ -0,0 +1 @@ +42 diff --git a/Task/Break-OO-privacy/Common-Lisp/break-oo-privacy.lisp b/Task/Break-OO-privacy/Common-Lisp/break-oo-privacy.lisp new file mode 100644 index 0000000000..a90a8494c4 --- /dev/null +++ b/Task/Break-OO-privacy/Common-Lisp/break-oo-privacy.lisp @@ -0,0 +1,44 @@ +(defpackage :funky + ;; only these symbols are public + (:export :widget :get-wobbliness) + ;; for convenience, bring common lisp symbols into funky + (:use :cl)) + +;; switch reader to funky package: all symbols that are +;; not from the CL package are interned in FUNKY. + +(in-package :funky) + +(defclass widget () + ;; :initarg -> slot "wobbliness" is initialized using :wobbliness keyword + ;; :initform -> if initarg is missing, slot defaults to 42 + ;; :reader -> a "getter" method called get-wobbliness is generated + ((wobbliness :initarg :wobbliness :initform 42 :reader get-wobbliness))) + +;; simulate being in another source file with its own package: +;; cool package gets external symbols from funky, and cl: +(defpackage :cool + (:use :funky :cl)) + +(in-package :cool) + +;; we can use the symbol funky:widget without any package prefix: +(defvar *w* (make-instance 'widget :wobbliness 36)) + +;; ditto with funky:get-wobbliness +(format t "wobbliness: ~a~%" (get-wobbliness *w*)) + +;; direct access to the slot requires fully qualified private symbol +;; and double colon: +(format t "wobbliness: ~a~%" (slot-value *w* 'funky::wobbliness)) + +;; if we use unqualified wobbliness, it's a different symbol: +;; it is cool::wobbliness interned in our local package. +;; we do not have funky:wobbliness because it's not exported by funky. +(unless (ignore-errors + (format t "wobbliness: ~a~%" (slot-value *w* 'wobbliness))) + (write-line "didn't work")) + +;; single colon results in error at read time! The expression is not +;; even read and evaluated. The symbol is internal and so cannot be used. +(format t "wobbliness: ~a~%" (slot-value *w* 'funky:wobbliness)) diff --git a/Task/Bulls-and-cows-Player/D/bulls-and-cows-player.d b/Task/Bulls-and-cows-Player/D/bulls-and-cows-player.d new file mode 100644 index 0000000000..5fcd81b5d0 --- /dev/null +++ b/Task/Bulls-and-cows-Player/D/bulls-and-cows-player.d @@ -0,0 +1,28 @@ +import std.stdio, std.random, std.algorithm, std.range, std.ascii; + +auto scoreCalc(in dchar[] guess, in dchar[] chosen) { + immutable bulls = guess.zip(chosen).count!q{ a[0] == a[1] }; + immutable cows = count!(p => p[0] != p[1] && chosen.canFind(p[0])) + (zip(guess, chosen)); + return [bulls, cows]; +} + +void main() { + auto d9 = "123456789"d.dup; + auto choices = cartesianProduct(d9, d9, d9, d9) + .map!(t => [t[]]) + .filter!(a => a.sort().uniq.walkLength == 4) + .array; + choices.randomShuffle; + + do { + const ans = choices[0]; + writef("My guess is %s. How many bulls and cows? ", ans); + const score = readln.filter!isDigit.map!q{ a-'0' }.array; + choices = choices.filter!(c => scoreCalc(c, ans) == score).array; + if (choices.empty) + return writeln("Nothing fits the scores you gave."); + } while (choices.length > 1); + + writeln("Solution found: ", choices[0]); +} diff --git a/Task/Bulls-and-cows-Player/Euphoria/bulls-and-cows-player.euphoria b/Task/Bulls-and-cows-Player/Euphoria/bulls-and-cows-player.euphoria new file mode 100644 index 0000000000..5cc5d4d04b --- /dev/null +++ b/Task/Bulls-and-cows-Player/Euphoria/bulls-and-cows-player.euphoria @@ -0,0 +1,84 @@ +include std/sequence.e + +constant line = "--------+--------------------\n" +constant digits = "123456789" +sequence list = {} + +function get_digits(integer n) + integer j + sequence d = digits, ret = "" + for i=1 to n do + j = rand(length(digits)-i) + ret &= d[i+j] + if j then + d[i+j] = d[i] + d[i] = ret[i] + end if + end for + return ret +end function + +function MASK(integer x) + return power(2,x-digits[1]) +end function + +function score(sequence pattern, sequence guess) + integer bits = 0, bull = 0, cow = 0 + for i = 1 to length(guess) do + if guess[i] != pattern[i] then + bits += MASK(pattern[i]) + else + bull += 1 + end if + end for + + for i = 1 to length(guess) do + cow += and_bits(bits,MASK(guess[i])) != 0 + end for + + return {bull, cow} +end function + +procedure pick(integer n, integer got, integer marker, sequence buf) + integer bits = 1 + if got >= n then + list = append(list,buf) + else + for i = 0 to length(digits)-1 do + if not and_bits(marker,bits) then + buf[got+1] = i+digits[1] + pick(n, got+1, or_bits(marker,bits), buf) + end if + bits *= 2 + end for + end if +end procedure + +function tester(sequence item, sequence data) + return equal(score(item,data[1]),data[2]) +end function + +constant tester_id = routine_id("tester") + +procedure game(sequence tgt) + integer p, n = length(tgt) + sequence buf = repeat(0,n), bc + list = {} + pick(n,0,0,buf) + p = 1 + bc = {0,0} + while bc[1] +#include +#include +#include + +bool contains_duplicates(std::string s) +{ + std::sort(s.begin(), s.end()); + return std::adjacent_find(s.begin(), s.end()) != s.end(); +} + +void game() +{ + typedef std::string::size_type index; + + std::string symbols = "0123456789"; + unsigned int const selection_length = 4; + + std::random_shuffle(symbols.begin(), symbols.end()); + std::string selection = symbols.substr(0, selection_length); + std::string guess; + while (std::cout << "Your guess? ", std::getline(std::cin, guess)) + { + if (guess.length() != selection_length + || guess.find_first_not_of(symbols) != std::string::npos + || contains_duplicates(guess)) + { + std::cout << guess << " is not a valid guess!"; + continue; + } + + unsigned int bulls = 0; + unsigned int cows = 0; + for (index i = 0; i != selection_length; ++i) + { + index pos = selection.find(guess[i]); + if (pos == i) + ++bulls; + else if (pos != std::string::npos) + ++cows; + } + std::cout << bulls << " bulls, " << cows << " cows.\n"; + if (bulls == selection_length) + { + std::cout << "Congratulations! You have won!\n"; + return; + } + } + std::cerr << "Oops! Something went wrong with input, or you've entered end-of-file!\nExiting ...\n"; + std::exit(EXIT_FAILURE); +} + +int main() +{ + std::cout << "Welcome to bulls and cows!\nDo you want to play? "; + std::string answer; + while (true) + { + while (true) + { + if (!std::getline(std::cin, answer)) + { + std::cout << "I can't get an answer. Exiting.\n"; + return EXIT_FAILURE; + } + if (answer == "yes" || answer == "Yes" || answer == "y" || answer == "Y") + break; + if (answer == "no" || answer == "No" || answer == "n" || answer == "N") + { + std::cout << "Ok. Goodbye.\n"; + return EXIT_SUCCESS; + } + std::cout << "Please answer yes or no: "; + } + game(); + std::cout << "Another game? "; + } +} diff --git a/Task/Bulls-and-cows/Common-Lisp/bulls-and-cows.lisp b/Task/Bulls-and-cows/Common-Lisp/bulls-and-cows.lisp new file mode 100644 index 0000000000..5bc6aa82b0 --- /dev/null +++ b/Task/Bulls-and-cows/Common-Lisp/bulls-and-cows.lisp @@ -0,0 +1,42 @@ +(defun get-number () + (do ((digits '())) + ((>= (length digits) 4) digits) + (pushnew (1+ (random 9)) digits))) + +(defun compute-score (guess number) + (let ((cows 0) + (bulls 0)) + (map nil (lambda (guess-digit number-digit) + (cond ((= guess-digit number-digit) (incf bulls)) + ((member guess-digit number) (incf cows)))) + guess number) + (values cows bulls))) + +(defun number->guess (number) + (when (integerp number) + (do ((digits '())) + ((zerop number) digits) + (multiple-value-bind (quotient remainder) (floor number 10) + (push remainder digits) + (setf number quotient))))) + +(defun valid-guess-p (guess) + (and (= 4 (length guess)) + (every (lambda (digit) (<= 1 digit 9)) guess) + (equal guess (remove-duplicates guess)))) + +(defun play-game (&optional (stream *query-io*)) + (do ((number (get-number)) + (cows 0) + (bulls 0)) + ((= 4 bulls)) + (format stream "~&Guess a 4-digit number: ") + (let ((guess (number->guess (read stream)))) + (cond ((not (valid-guess-p guess)) + (format stream "~&Malformed guess.")) + (t + (setf (values cows bulls) (compute-score guess number)) + (if (= 4 bulls) + (format stream "~&Correct, you win!") + (format stream "~&Score: ~a cows, ~a bulls." + cows bulls))))))) diff --git a/Task/Bulls-and-cows/D/bulls-and-cows.d b/Task/Bulls-and-cows/D/bulls-and-cows.d new file mode 100644 index 0000000000..11d22c87db --- /dev/null +++ b/Task/Bulls-and-cows/D/bulls-and-cows.d @@ -0,0 +1,36 @@ +import std.stdio, std.random, std.string, std.algorithm, + std.range, std.conv; + +void main() { + enum size = 4; + dchar[] ddigits = "123456789"d.dup; + //immutable chosen = array(randomCover(ddigits))[0 .. size]; + const chosen = randomCover(ddigits, rndGen).take(size).array(); + writeln("Guess a number composed of ", size, + " unique digits from 1 to 9 in random order."); + + int nGuesses; + while (true) { + nGuesses++; + dstring guess; + while (true) { + writef("\nNext guess (%d): ", nGuesses); + guess = readln().strip().dtext(); + if (guess.countchars(ddigits) == size && + guess.dup.sort().uniq().walkLength() == size) + break; + writefln("I need %d unique digits from 1 to 9, no spaces", size); + } + + if (guess == chosen) { + writefln("\nYou guessed correctly in %d attempts.", nGuesses); + break; + } + + immutable bulls = count!q{ a[0] == a[1] }(zip(guess, chosen)); + immutable cows = count!(i => guess[i] != chosen[i] && + chosen.canFind(guess[i])) + (iota(size)); + writefln(" %d Bulls\n %d Cows", bulls, cows); + } +} diff --git a/Task/Bulls-and-cows/E/bulls-and-cows-1.e b/Task/Bulls-and-cows/E/bulls-and-cows-1.e new file mode 100644 index 0000000000..2e327d0cf7 --- /dev/null +++ b/Task/Bulls-and-cows/E/bulls-and-cows-1.e @@ -0,0 +1,82 @@ +def Digit := 1..9 +def Number := Tuple[Digit,Digit,Digit,Digit] + +/** Choose a random number to be guessed. */ +def pick4(entropy) { + def digits := [1,2,3,4,5,6,7,8,9].diverge() + + # Partial Fisher-Yates shuffle + for i in 0..!4 { + def other := entropy.nextInt(digits.size() - i) + i + def t := digits[other] + digits[other] := digits[i] + digits[i] := t + } + return digits(0, 4) +} + +/** Compute the score of a guess. */ +def scoreGuess(actual :Number, guess :Number) { + var bulls := 0 + var cows := 0 + for i => digit in guess { + if (digit == actual[i]) { + bulls += 1 + } else if (actual.indexOf1(digit) != -1) { + cows += 1 + } + } + return [bulls, cows] +} + +/** Parse a guess string into a list of digits (Number). */ +def parseGuess(guessString, fail) :Number { + if (guessString.size() != 4) { + return fail(`I need four digits, not ${guessString.size()} digits.`) + } else { + var digits := [] + for c in guessString { + if (('1'..'9')(c)) { + digits with= c - '0' + } else { + return fail(`I need a digit from 1 to 9, not "$c".`) + } + } + return digits + } +} + +/** The game loop: asking for guesses and reporting scores and win conditions. + The return value is null or a broken reference if there was a problem. */ +def bullsAndCows(askUserForGuess, tellUser, entropy) { + def actual := pick4(entropy) + + def gameTurn() { + return when (def guessString := askUserForGuess <- ()) -> { + escape tellAndContinue { + + def guess := parseGuess(guessString, tellAndContinue) + def [bulls, cows] := scoreGuess(actual, guess) + + if (bulls == 4) { + tellUser <- (`You got it! The number is $actual!`) + null + } else { + tellAndContinue(`Your score for $guessString is $bulls bulls and $cows cows.`) + } + + } catch message { + # The parser or scorer has something to say, and the game continues afterward + when (tellUser <- (message)) -> { + gameTurn() + } + } + } catch p { + # Unexpected problem of some sort + tellUser <- ("Sorry, game crashed.") + throw(p) + } + } + + return gameTurn() +} diff --git a/Task/Bulls-and-cows/E/bulls-and-cows-2.e b/Task/Bulls-and-cows/E/bulls-and-cows-2.e new file mode 100644 index 0000000000..dba7e6f2ee --- /dev/null +++ b/Task/Bulls-and-cows/E/bulls-and-cows-2.e @@ -0,0 +1,15 @@ +def guiBullsAndCows() { + var lastGuess := "" + def op := + return bullsAndCows(fn { + lastGuess := op.showInputDialog(null, "Enter your guess:", lastGuess) + if (lastGuess == null) { + # canceled, so just fail to return an answer and let the game logic get GCed + Ref.promise()[0] + } else { + lastGuess + } + }, fn msg { + op.showMessageDialog(null, msg) + }, entropy) +} diff --git a/Task/Bulls-and-cows/Elena/bulls-and-cows.elena b/Task/Bulls-and-cows/Elena/bulls-and-cows.elena new file mode 100644 index 0000000000..dd78b21f4f --- /dev/null +++ b/Task/Bulls-and-cows/Elena/bulls-and-cows.elena @@ -0,0 +1,85 @@ +#define std'dictionary'*. +#define std'basic'*. +#define std'collections'*. +#define std'patterns'*. +#define ext'utils'*. +#define std'routines'arrays'*. + +#class EDigitProp +{ + #method get + [ + ^ self numeric - 30h. + ] +} +#symbol Digits : aLiteral + = Summing &&var:List &prop:EDigitProp start:Scan::aLiteral. + +#class GameMaster +{ + #field theNumbers. + + #initializer + [ + // generate secret number + #var aRandomNumbers := Randomized &&base:(1,2,3,4,5,6,7,8,9) &count:9. + + theNumbers := aRandomNumbers~earrayop read &from:0 &to:3 &:esubarray. + ] + + #method proceed : aGuess + [ + #if (aGuess count != 4)? + [ + 'program'output << "Not a valid guess.%n". + + ^ $self. + ]. + + #var aCows := Integer::0. + #var aBulls := Integer::0. + + #if It::aGuess run: aNumber = + [ + // check range + Control if:(aNumber > 0) if:(aNumber < 10). + + // check duplicates + #if (aNumber indexer'clone index'append:1)~EIt find:aNumber + [ + control fail. + ]. + + #if Control if:(aNumber == theNumbers@aNumber index) + [ + aBulls += 1. + ] + | if:(Scan::theNumbers == aNumber) + [ + aCows += 1. + ]. + ] + | [ + 'program'output << "Not a valid guess.%n". + + ^ $self. + ]. + + #if (aBulls == 4)? + [ + 'program'output << "%nCongratulations! You have won!". + + $self fail. + ] + | [ + 'program'output << "%nYour Score is " << aBulls << " bulls and " << aCows << " cows%n". + ]. + ] +} + +#symbol Program = +[ + #var aGameMaster := GameMaster. + + #while aGameMaster proceed:Digits::(ext'io'console << "Your Guess ?" >> String). +]. diff --git a/Task/Bulls-and-cows/Euphoria/bulls-and-cows.euphoria b/Task/Bulls-and-cows/Euphoria/bulls-and-cows.euphoria new file mode 100644 index 0000000000..9f0c4620ff --- /dev/null +++ b/Task/Bulls-and-cows/Euphoria/bulls-and-cows.euphoria @@ -0,0 +1,103 @@ +include std\text.e +include std\os.e +include std\sequence.e +include std\console.e + +sequence bcData = {0,0} --bull,cow score for the player +sequence goalNum = { {0,0,0,0}, {0,0,0,0}, 0} --computer's secret number digits (element 1), marked as bull/cow +--indexes in element 2, integer value of it in element 3 +sequence currentGuess = { {0,0,0,0}, {0,0,0,0}, 0} --player's guess, same format as goalNum +sequence removeChars = 0 & " 0\r\t\n" --characters to trim (remove) from user's input. \r, \t are single escaped characters, +--0 is ascii 0x0 and number zero is ascii 48, or 0x30. The rest are wysiwyg +integer tries = 0 --track number of tries to guess the number +sequence bcStrings ={"bull", "cow"} --stores singular and/or plural strings depending on score in bcData + +goalNum[1] = rand( {9,9,9,9} ) --rand function works on objects. here it outputs into each sequence element. +goalNum[3] = goalNum[1][1] * 1000 + goalNum[1][2] * 100 + goalNum[1][3] * 10 + goalNum[1][4] --convert digits to an integer +--and store it + +procedure getInputAndProcess(integer stage = 1) --object = 1 sets default value for the parameter if it isn't specified + + goalNum[2][1..4] = 0 --{0,0,0,0} --set these to unscaned (0) since the scanning will start over. + currentGuess[1][1..4] = 0 --{0,0,0,0} --these too, or they will contain old marks + currentGuess[2][1..4] = 0 + tries += 1 --equivalent to tries = tries + 1, but faster and shorter to write + bcData[1..2] = 0 -- {0,0} + + if stage <= 1 then --if this process was run for the first time or with no parameters, then.. + puts(1,"The program has thought of a four digit number using only digits 1 to 9.\nType your guess and press enter.\n") + end if + + while 1 label "guesscheck" do --labels can be used to specify a jump point from exit or retry, and help readability + currentGuess[1] = trim(gets(0), removeChars) --get user input, trim unwanted characters from it, store it in currentGuess[1] + currentGuess[1] = mapping( currentGuess[1], {49,50,51,52,53,54,55,56,57}, {1,2,3,4,5,6,7,8,9} ) --convert ascii codes to + -- integer digits they represent + integer tempF = find('0',currentGuess[1]) + if length(currentGuess[1]) != 4 or tempF != 0 then --if the input string is now more than 4 characters/integers, + --the input won't be used. + puts(1,"You probably typed too many digits or a 0. Try typing a new 4 digit number with only numbers 1 through 9.\n") + retry "guesscheck" + else + exit "guesscheck" + end if + end while + --convert separate digits to the one integer they represent and store it, like with goalNum[3] + currentGuess[3] = currentGuess[1][1] * 1000 + currentGuess[1][2] * 100 + currentGuess[1][3] * 10 + currentGuess[1][4] +--convert digits to the integer they represent, to print to a string later + + --check for bulls + for i = 1 to 4 do + if goalNum[1][i] = currentGuess[1][i] then + goalNum[2][i] = 1 + currentGuess[2][i] = 1 + bcData[1] += 1 + end if + end for + + --check for cows, but not slots marked as bulls or cows already. + for i = 1 to 4 label "iGuessElem"do --loop through each guessed digit + for j = 1 to 4 label "jGoalElem" do --but first go through each goal digit, comparing the first guessed digit, + --and then the other guessed digits 2 through 4 + + if currentGuess[2][i] = 1 then --if the guessed digit we're comparing right now has been marked as bull or cow already + continue "iGuessElem" --skip to the next guess digit without comparing this guess digit to the other goal digits + end if + + if goalNum[2][j] = 1 then --if the goal digit we're comparing to right now has been marked as a bull or cow already + continue "jGoalElem" --skip to the next goal digit + end if + + if currentGuess[1][i] = goalNum[1][j] then --if the guessed digit is the same as the goal one, + --it won't be a bull, so it's a cow + bcData[2] += 1 --score one more cow + goalNum[2][j] = 1 --mark this digit as a found cow in the subsequence that stores 0's or 1's as flags + continue "iGuessElem" --skip to the next guess digit, so that this digit won't try to check for + --matches(cow) with other goal digits + end if + + end for --this guess digit was compared to one goal digit , try comparing this guess digit with the next goal digit + end for --this guess digit was compared with all goal digits, compare the next guess digit to all the goal digits + + if bcData[1] = 1 then --uses singular noun when there is score of 1, else plural + bcStrings[1] = "bull" + else + bcStrings[1] = "bulls" + end if + + if bcData[2] = 1 then --the same kind of thing as above block + bcStrings[2] = "cow" + else + bcStrings[2] = "cows" + end if + + if bcData[1] < 4 then --if less than 4 bulls were found, the player hasn't won, else they have... + printf(1, "Guess #%d : You guessed %d . You found %d %s, %d %s. Type new guess.\n", {tries, currentGuess[3], bcData[1], bcStrings[1], bcData[2], bcStrings[2]} ) + getInputAndProcess(2) + else --else they have won and the procedure ends + printf(1, "The number was %d. You guessed %d in %d tries.\n", {goalNum[3], currentGuess[3], tries} ) + any_key()--wait for keypress before closing console window. + end if + +end procedure +--run the procedure +getInputAndProcess(1) diff --git a/Task/CRC-32/0DESCRIPTION b/Task/CRC-32/0DESCRIPTION new file mode 100644 index 0000000000..167bf56345 --- /dev/null +++ b/Task/CRC-32/0DESCRIPTION @@ -0,0 +1,3 @@ +Demonstrate a method of deriving the [[wp:Cyclic_Redundancy_Check|Cyclic Redundancy Check]] from within the language. The result should be in accordance with ISO 3309, [http://www.itu.int/rec/T-REC-V.42-200203-I/en ITU-T V.42], [http://tools.ietf.org/html/rfc1952 Gzip] and [http://www.w3.org/TR/2003/REC-PNG-20031110/ PNG]. Algorithms are described on [[wp:Computation of CRC|Computation of CRC]] in Wikipedia. This variant of CRC-32 uses LSB-first order, sets the initial CRC to FFFFFFFF16, and complements the final CRC. + +For the purpose of this task, generate a CRC-32 checksum for the ASCII encoded string "The quick brown fox jumps over the lazy dog" (without quotes). diff --git a/Task/CRC-32/1META.yaml b/Task/CRC-32/1META.yaml new file mode 100644 index 0000000000..0b9ae97960 --- /dev/null +++ b/Task/CRC-32/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Checksums diff --git a/Task/CRC-32/Ada/crc-32.ada b/Task/CRC-32/Ada/crc-32.ada new file mode 100644 index 0000000000..1346ffd67a --- /dev/null +++ b/Task/CRC-32/Ada/crc-32.ada @@ -0,0 +1,14 @@ +with Ada.Text_IO; use Ada.Text_IO; +with GNAT.CRC32; use GNAT.CRC32; +with Interfaces; use Interfaces; +procedure TestCRC is + package IIO is new Ada.Text_IO.Modular_IO (Unsigned_32); + crc : CRC32; + num : Unsigned_32; + str : String := "The quick brown fox jumps over the lazy dog"; +begin + Initialize (crc); + Update (crc, str); + num := Get_Value (crc); + IIO.Put (num, Base => 16); New_Line; +end TestCRC; diff --git a/Task/CRC-32/C/crc-32-1.c b/Task/CRC-32/C/crc-32-1.c new file mode 100644 index 0000000000..0e4502ed78 --- /dev/null +++ b/Task/CRC-32/C/crc-32-1.c @@ -0,0 +1,11 @@ +#include +#include +#include + +int main() +{ + const char *s = "The quick brown fox jumps over the lazy dog"; + printf("%lX\n", crc32(0, (const void*)s, strlen(s))); + + return 0; +} diff --git a/Task/CRC-32/C/crc-32-2.c b/Task/CRC-32/C/crc-32-2.c new file mode 100644 index 0000000000..c597aa01c5 --- /dev/null +++ b/Task/CRC-32/C/crc-32-2.c @@ -0,0 +1,47 @@ +#include +#include +#include + +uint32_t +rc_crc32(uint32_t crc, const char *buf, size_t len) +{ + static uint32_t table[256]; + static int have_table = 0; + uint32_t rem, octet; + int i, j; + const char *p, *q; + + /* This check is not thread safe; there is no mutex. */ + if (have_table == 0) { + /* Calculate CRC table. */ + for (i = 0; i < 256; i++) { + rem = i; /* remainder from polynomial division */ + for (j = 0; j < 8; j++) { + if (rem & 1) { + rem >>= 1; + rem ^= 0xedb88320; + } else + rem >>= 1; + } + table[i] = rem; + } + have_table = 1; + } + + crc = ~crc; + q = buf + len; + for (p = buf; p < q; p++) { + octet = *p; /* Cast to unsigned octet. */ + crc = (crc >> 8) ^ table[(crc & 0xff) ^ octet]; + } + return ~crc; +} + +int +main() +{ + const char *s = "The quick brown fox jumps over the lazy dog"; + printf("%" PRIX32 "\n", rc_crc32(0, s, strlen(s))); + + return 0; +} diff --git a/Task/CRC-32/Common-Lisp/crc-32.lisp b/Task/CRC-32/Common-Lisp/crc-32.lisp new file mode 100644 index 0000000000..d658f581af --- /dev/null +++ b/Task/CRC-32/Common-Lisp/crc-32.lisp @@ -0,0 +1,13 @@ +(ql:quickload :ironclad) + + +(defun write-seq-base-16 (seq &key ((:stream *standard-output*) + *standard-output*) + &aux (*print-base* 16)) + (map nil #'write seq)) + + +(write-seq-base-16 + (crypto:digest-sequence 'ironclad:crc32 + (crypto:ascii-string-to-byte-array + "The quick brown fox jumps over the lazy dog"))) diff --git a/Task/CRC-32/D/crc-32.d b/Task/CRC-32/D/crc-32.d new file mode 100644 index 0000000000..90999818b3 --- /dev/null +++ b/Task/CRC-32/D/crc-32.d @@ -0,0 +1,6 @@ +import std.stdio, std.digest.crc; + +void main() { + "The quick brown fox jumps over the lazy dog" + .crc32Of().crcHexString().writeln(); +} diff --git a/Task/CRC-32/Erlang/crc-32-1.erl b/Task/CRC-32/Erlang/crc-32-1.erl new file mode 100644 index 0000000000..ce7154f118 --- /dev/null +++ b/Task/CRC-32/Erlang/crc-32-1.erl @@ -0,0 +1,4 @@ +-module(crc32). +-export([test/0]). +test() -> + io:fwrite("~.16#~n",[erlang:crc32(<<"The quick brown fox jumps over the lazy dog">>)]). diff --git a/Task/CRC-32/Erlang/crc-32-2.erl b/Task/CRC-32/Erlang/crc-32-2.erl new file mode 100644 index 0000000000..89221cb644 --- /dev/null +++ b/Task/CRC-32/Erlang/crc-32-2.erl @@ -0,0 +1 @@ +16#414FA339 diff --git a/Task/CRC-32/Go/crc-32-1.go b/Task/CRC-32/Go/crc-32-1.go new file mode 100644 index 0000000000..5483f87d2a --- /dev/null +++ b/Task/CRC-32/Go/crc-32-1.go @@ -0,0 +1,12 @@ +package main + +import ( + "fmt" + "hash/crc32" +) + +func main() { + s := []byte("The quick brown fox jumps over the lazy dog") + result := crc32.ChecksumIEEE(s) + fmt.Printf("%X\n", result) +} diff --git a/Task/CRC-32/Go/crc-32-2.go b/Task/CRC-32/Go/crc-32-2.go new file mode 100644 index 0000000000..b6e1eeab3d --- /dev/null +++ b/Task/CRC-32/Go/crc-32-2.go @@ -0,0 +1,31 @@ +package main + +import "fmt" + +var table [256]uint32 + +func init() { + for i := range table { + word := uint32(i) + for j := 0; j < 8; j++ { + if word&1 == 1 { + word = (word >> 1) ^ 0xedb88320 + } else { + word >>= 1 + } + } + table[i] = word + } +} + +func crc32(s string) uint32 { + crc := ^uint32(0) + for i := 0; i < len(s); i++ { + crc = table[byte(crc)^s[i]] ^ (crc >> 8) + } + return ^crc +} + +func main() { + fmt.Printf("%0x\n", crc32("The quick brown fox jumps over the lazy dog")) +} diff --git a/Task/CRC-32/Java/crc-32.java b/Task/CRC-32/Java/crc-32.java new file mode 100644 index 0000000000..0c6dd5822e --- /dev/null +++ b/Task/CRC-32/Java/crc-32.java @@ -0,0 +1,10 @@ +import java.util.zip.* ; + +public class CRCMaker { + public static void main( String[ ] args ) { + String toBeEncoded = new String( "The quick brown fox jumps over the lazy dog" ) ; + CRC32 myCRC = new CRC32( ) ; + myCRC.update( toBeEncoded.getBytes( ) ) ; + System.out.println( "The CRC-32 value is : " + Long.toHexString( myCRC.getValue( ) ) + " !" ) ; + } +} diff --git a/Task/CRC-32/PHP/crc-32.php b/Task/CRC-32/PHP/crc-32.php new file mode 100644 index 0000000000..b6d7b8b8fa --- /dev/null +++ b/Task/CRC-32/PHP/crc-32.php @@ -0,0 +1 @@ +printf("%x\n", crc32("The quick brown fox jumps over the lazy dog")); diff --git a/Task/CRC-32/Perl/crc-32.pl b/Task/CRC-32/Perl/crc-32.pl new file mode 100644 index 0000000000..d567797f92 --- /dev/null +++ b/Task/CRC-32/Perl/crc-32.pl @@ -0,0 +1,9 @@ +#!/usr/bin/perl +use 5.010 ; +use strict ; +use warnings ; +use Digest::CRC qw( crc32 ) ; + +my $crc = Digest::CRC->new( type => "crc32" ) ; +$crc->add ( "The quick brown fox jumps over the lazy dog" ) ; +say "The checksum is " . $crc->hexdigest( ) ; diff --git a/Task/CRC-32/Python/crc-32-1.py b/Task/CRC-32/Python/crc-32-1.py new file mode 100644 index 0000000000..72b803c105 --- /dev/null +++ b/Task/CRC-32/Python/crc-32-1.py @@ -0,0 +1,3 @@ +>>> import zlib +>>> hex(zlib.crc32('The quick brown fox jumps over the lazy dog')) +'0x414fa339' diff --git a/Task/CRC-32/Python/crc-32-2.py b/Task/CRC-32/Python/crc-32-2.py new file mode 100644 index 0000000000..2d62317765 --- /dev/null +++ b/Task/CRC-32/Python/crc-32-2.py @@ -0,0 +1,3 @@ +>>> import binascii +>>> hex(binascii.crc32('The quick brown fox jumps over the lazy dog')) +'0x414fa339' diff --git a/Task/CRC-32/REXX/crc-32.rexx b/Task/CRC-32/REXX/crc-32.rexx new file mode 100644 index 0000000000..4f90bd73da --- /dev/null +++ b/Task/CRC-32/REXX/crc-32.rexx @@ -0,0 +1,37 @@ +/*REXX program to compute the CRC-32 (Cylic Redundancy Check, 32 bit),*/ +/* checksum for a given string [as described in ISO 3309, ITU-T V.42].*/ + a_string = 'The quick brown fox jumps over the lazy dog' + b_string = 'Generate CRC32 Checksum For Byte Array Example' +call show a_string +call show b_string +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────SHOW subroutine─────────────────────*/ +show: procedure; parse arg Xstring; say +checksum=CRC_32(Xstring) /*invoke CRC_32 to create a CRC*/ +say +say center(' input string [length of' length(Xstring) "bytes] ",79,'─') +say Xstring /*show the string on its own line*/ +say +checksum=bitxor(checksum,'ffFFffFF'x) /*final convolution for checksum.*/ +say 'hex CRC-32 checksum =' c2x(checksum) left('',15), + "dec CRC-32 checksum =" c2d(checksum) /*show CRC-32 in hex & dec*/ +return +/*──────────────────────────────────CRC_32 subroutine───────────────────*/ +CRC_32: procedure; parse arg !,$ /*2nd arg is for multi-invokes. */ + + do i=0 to 255; z=d2c(i) /*build the 8-bit indexed table. */ + r=right(z,4,'0'x) /*insure the R is 32 bits. */ + do j=0 for 8 /*handle each bit of rightmost 8.*/ + rb=x2b(c2x(r)) /*convert char ──► hex ──► binary*/ + _=right(rb,1) /*remember right-most bit for IF.*/ + r=x2c(b2x(0||left(rb,31))) /*shift it right (unsigned) 1 bit*/ + if _\==0 then r=bitxor(r,'edb88320'x) /*bit XOR grunt-work.*/ + end /*j*/ + !.z=r + end /*i*/ + +$=bitxor(word($ '0000000'x,1),'ffFFffFF'x) /*use user's CRC or default.*/ + do k=1 for length(!) /*start crunching the input data.*/ + ?=bitxor(right($,1),substr(!,k,1)); $=bitxor('0'x||left($,3),!.?) + end /*k*/ +return $ /*return with da money to invoker*/ diff --git a/Task/CRC-32/Ruby/crc-32-1.rb b/Task/CRC-32/Ruby/crc-32-1.rb new file mode 100644 index 0000000000..39aafa6489 --- /dev/null +++ b/Task/CRC-32/Ruby/crc-32-1.rb @@ -0,0 +1,3 @@ +require 'zlib' +printf "0x%08x\n", Zlib.crc32('The quick brown fox jumps over the lazy dog') +# => 0x414fa339 diff --git a/Task/CRC-32/Ruby/crc-32-2.rb b/Task/CRC-32/Ruby/crc-32-2.rb new file mode 100644 index 0000000000..e9ca3bd2c2 --- /dev/null +++ b/Task/CRC-32/Ruby/crc-32-2.rb @@ -0,0 +1,75 @@ +module CRC + # Divisor is a polynomial of degree 32 with coefficients modulo 2. + # We store Divisor in a 33-bit Integer; the polynomial is + # Divisor[32] + Divisor[31] * x + ... + Divisor[0] * x**32 + Divisor = [0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26, 32] \ + .inject(0) {|sum, exponent| sum + (1 << (32 - exponent))} + + # This table gives the crc (without conditioning) of every possible + # _octet_ from 0 to 255. Each _octet_ is a polynomial of degree 7, + # octet[7] + octet[6] * x + ... + octet[0] * x**7 + # Then remainder = Table[octet] is the remainder from + # _octet_ times x**32 divided by Divisor, + # remainder[31] + remainder[30] + ... + remainder[0] * x**31 + Table = Array.new(256) do |octet| + # Find remainder from polynomial long division. + # octet[ 7] * x**32 + ... + octet[0] * x**39 + # Divisor[32] * x**0 + ... + Divisor[0] * x**32 + remainder = octet + (0..7).each do |i| + # Find next term of quotient. To simplify the code, + # we assume that Divisor[0] is 1, and we only check + # remainder[i]. We save remainder, forget quotient. + if remainder[i].zero? + # Next term of quotient is 0 * x**(7 - i). + # No change to remainder. + else + # Next term of quotient is 1 * x**(7 - i). Multiply + # this term by Divisor, then subtract from remainder. + # * Multiplication uses left shift :<< to align + # the x**(39 - i) terms. + # * Subtraction uses bitwise exclusive-or :^. + remainder ^= (Divisor << i) + end + end + remainder >> 8 # Remove x**32 to x**39 terms. + end + + module_function + + def crc32(string, crc = 0) + # Pre-conditioning: Flip all 32 bits. Without this step, a string + # preprended with extra "\0" would have same crc32 value. + crc ^= 0xffff_ffff + + # Iterate octets to perform polynomial long division. + string.each_byte do |octet| + + # Update _crc_ by continuing its polynomial long division. + # Our current remainder is old _crc_ times x**8, plus + # new _octet_ times x**32, which is + # crc[32] * x**8 + crc[31] * x**9 + ... + crc[8] * x**31 \ + # + (crc[7] + octet[7]) * x**32 + ... \ + # + (crc[0] + octet[0]) * x**39 + # + # Our new _crc_ is the remainder from this polynomial divided by + # Divisor. We split the terms into part 1 for x**8 to x**31, and + # part 2 for x**32 to x**39, and divide each part separately. + # Then remainder 1 is trivial, and remainder 2 is in our Table. + + remainder_1 = crc >> 8 + remainder_2 = Table[(crc & 0xff) ^ octet] + + # Our new _crc_ is sum of both remainders. (This sum never + # overflows to x**32, so is not too big for Divisor.) + crc = remainder_1 ^ remainder_2 + end + + # Post-conditioning: Flip all 32 bits. If we later update _crc_, + # this step cancels the next pre-conditioning. + crc ^ 0xffff_ffff + end +end + +printf "0x%08x\n", CRC.crc32("The quick brown fox jumps over the lazy dog") +# => 0x414fa339 diff --git a/Task/CRC-32/Smalltalk/crc-32.st b/Task/CRC-32/Smalltalk/crc-32.st new file mode 100644 index 0000000000..32245cfad7 --- /dev/null +++ b/Task/CRC-32/Smalltalk/crc-32.st @@ -0,0 +1 @@ +CRC32Stream hashValueOf:'The quick brown fox jumps over the lazy dog' diff --git a/Task/CRC-32/Tcl/crc-32-1.tcl b/Task/CRC-32/Tcl/crc-32-1.tcl new file mode 100644 index 0000000000..cc710ecd34 --- /dev/null +++ b/Task/CRC-32/Tcl/crc-32-1.tcl @@ -0,0 +1,4 @@ +package require Tcl 8.6 + +set data "The quick brown fox jumps over the lazy dog" +puts [format "%x" [zlib crc32 $data]] diff --git a/Task/CRC-32/Tcl/crc-32-2.tcl b/Task/CRC-32/Tcl/crc-32-2.tcl new file mode 100644 index 0000000000..a52f27f431 --- /dev/null +++ b/Task/CRC-32/Tcl/crc-32-2.tcl @@ -0,0 +1,2 @@ +package require crc32 +puts [format "%x" [crc::crc32 $data]] diff --git a/Task/CSV-to-HTML-translation/0DESCRIPTION b/Task/CSV-to-HTML-translation/0DESCRIPTION new file mode 100644 index 0000000000..309283211c --- /dev/null +++ b/Task/CSV-to-HTML-translation/0DESCRIPTION @@ -0,0 +1,18 @@ +Consider a simplified CSV format where all rows are separated by a +newline and all columns are separated by commas. No commas are +allowed as field data, but the data may contain other characters +and character sequences that would normally be escaped when +converted to HTML + +The task is to create a function that takes a string representation of the CSV data +and returns a text string of an HTML table representing the CSV data. Use the following +data as the CSV text to convert, and show your output. +:Character,Speech +:The multitude,The messiah! Show us the messiah! +:Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +:The multitude,Who are you? +:Brians mother,I'm his mother; that's who! +:The multitude,Behold his mother! Behold his mother! + +For extra credit, ''optionally'' allow special formatting for the +first row of the table as if it is the tables header row (via preferably; CSS if you must). diff --git a/Task/CSV-to-HTML-translation/ALGOL-68/csv-to-html-translation-1.alg b/Task/CSV-to-HTML-translation/ALGOL-68/csv-to-html-translation-1.alg new file mode 100644 index 0000000000..63530099db --- /dev/null +++ b/Task/CSV-to-HTML-translation/ALGOL-68/csv-to-html-translation-1.alg @@ -0,0 +1,69 @@ +#!/usr/local/bin/a68g --script # + +[6]STRING rows := []STRING( + "Character,Speech", + "The multitude,The messiah! Show us the messiah!", + "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!", + "The multitude,Who are you?", + "Brians mother,I'm his mother; that's who!", + "The multitude,Behold his mother! Behold his mother!" +); + +[max abs char]STRING encoded; FOR i TO UPB encoded DO encoded[i]:=REPR i OD; +# encoded[ABS""""] := """; optional # + encoded[ABS "&"] := "&"; + encoded[ABS "<"] := "<"; +# encoded[ABS ">"] := ">"; optional # + +OP ENCODE = (STRING s)STRING: ( + STRING out := ""; + FOR i TO UPB s DO out+:= encoded[ABS s[i]] OD; + out +); + +PROC head = (STRING title)VOID: ( + printf(( + $""l$, + $""g""l$, title, + $""l$, + $""l$ + )) +); + +# define HTML tags using Algol68's "reverent" block structuring # +PROC html = VOID: print(("", new line)), + body = VOID: print(("", new line)), + table = VOID: print(("", new line)), + table row = VOID: print(("")), + th = (STRING s)VOID: printf(($""$, s)), + td = (STRING s)VOID: printf(($""$, s)), + elbat row = VOID: print(("", new line)), + elbat = VOID: print(("
"g""g"
", new line)), + ydob = VOID: print(("", new line)), + lmth = VOID: print(("", new line)); + +FILE row input; STRING row; CHAR ifs = ","; +associate(row input, row); make term(row input, ifs); + +html; + head("CSV to HTML translation - Extra Credit"); + body; + table; + FOR nr TO UPB rows DO + row := rows[nr]; + table row; + on logical file end(row input, (REF FILE row input)BOOL: row end); + FOR nf DO + STRING field; get(row input,field); + (nr=1|th|td)(ENCODE field); + get(row input, space) + OD; + row end: reset(row input); + elbat row + OD; + elbat; + ydob; +lmth diff --git a/Task/CSV-to-HTML-translation/ALGOL-68/csv-to-html-translation-2.alg b/Task/CSV-to-HTML-translation/ALGOL-68/csv-to-html-translation-2.alg new file mode 100644 index 0000000000..e1a893a163 --- /dev/null +++ b/Task/CSV-to-HTML-translation/ALGOL-68/csv-to-html-translation-2.alg @@ -0,0 +1,19 @@ + + +CSV to HTML translation - Extra Credit + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
+ + diff --git a/Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-1.awk b/Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-1.awk new file mode 100644 index 0000000000..62eea8c879 --- /dev/null +++ b/Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-1.awk @@ -0,0 +1,23 @@ +#!/usr/bin/awk -f +BEGIN { + FS="," + print "" +} + +{ + gsub(//, "\\>") + gsub(/&/, "\\>") + print "\t" + for(f = 1; f <= NF; f++) { + if(NR == 1 && header) { + printf "\t\t\n", $f + } + else printf "\t\t\n", $f + } + print "\t" +} + +END { + print "
%s%s
" +} diff --git a/Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-2.awk b/Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-2.awk new file mode 100644 index 0000000000..d289465df7 --- /dev/null +++ b/Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-2.awk @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother>lt;angry>gt;Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!>lt;/angry>gt;
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-3.awk b/Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-3.awk new file mode 100644 index 0000000000..bd5bc71a00 --- /dev/null +++ b/Task/CSV-to-HTML-translation/AWK/csv-to-html-translation-3.awk @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother>lt;angry>gt;Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!>lt;/angry>gt;
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-1.ada b/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-1.ada new file mode 100644 index 0000000000..158e12fe06 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-1.ada @@ -0,0 +1,40 @@ +with Ada.Strings.Fixed; +with Ada.Text_IO; +with Templates_Parser; + +procedure Csv2Html is + use type Templates_Parser.Vector_Tag; + + Chars : Templates_Parser.Vector_Tag; + Speeches : Templates_Parser.Vector_Tag; + + CSV_File : Ada.Text_IO.File_Type; +begin + -- read the csv data + Ada.Text_IO.Open (File => CSV_File, + Mode => Ada.Text_IO.In_File, + Name => "data.csv"); + + -- fill the tags + while not Ada.Text_IO.End_Of_File (CSV_File) loop + declare + Whole_Line : String := Ada.Text_IO.Get_Line (CSV_File); + Comma_Pos : Natural := Ada.Strings.Fixed.Index (Whole_Line, ","); + begin + Chars := Chars & Whole_Line (Whole_Line'First .. Comma_Pos - 1); + Speeches := Speeches & Whole_Line (Comma_Pos + 1 .. Whole_Line'Last); + end; + end loop; + + Ada.Text_IO.Close (CSV_File); + + -- build translation table and output html + declare + Translations : constant Templates_Parser.Translate_Table := + (1 => Templates_Parser.Assoc ("CHAR", Chars), + 2 => Templates_Parser.Assoc ("SPEECH", Speeches)); + begin + Ada.Text_IO.Put_Line + (Templates_Parser.Parse ("table.tmplt", Translations)); + end; +end Csv2Html; diff --git a/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-2.ada b/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-2.ada new file mode 100644 index 0000000000..4126ce0394 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-2.ada @@ -0,0 +1,8 @@ + +@@TABLE@@ + + + + +@@END_TABLE@@ +
@_WEB_ESCAPE:CHAR_@@_WEB_ESCAPE:SPEECH_@
diff --git a/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-3.ada b/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-3.ada new file mode 100644 index 0000000000..4238d95db6 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Ada/csv-to-html-translation-3.ada @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/AutoHotkey/csv-to-html-translation.ahk b/Task/CSV-to-HTML-translation/AutoHotkey/csv-to-html-translation.ahk new file mode 100644 index 0000000000..2935ace909 --- /dev/null +++ b/Task/CSV-to-HTML-translation/AutoHotkey/csv-to-html-translation.ahk @@ -0,0 +1,25 @@ +CSVData = +( +Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother! +) +TableData := "" +Loop Parse, CSVData,`n +{ + TableData .= "`n " + Loop Parse, A_LoopField, CSV + TableData .= "" + TableData .= "" +} +TableData .= "`n
" HTMLEncode(A_LoopField) "
" +HTMLEncode(str){ + static rep := "&gt;""quot" + Loop Parse, rep,; + StringReplace, str, str, % SubStr(A_LoopField, 1, 1), % "&" . SubStr(A_LoopField, 2) . ";", All + return str +} +MsgBox % clipboard := TableData diff --git a/Task/CSV-to-HTML-translation/AutoIt/csv-to-html-translation.autoit b/Task/CSV-to-HTML-translation/AutoIt/csv-to-html-translation.autoit new file mode 100644 index 0000000000..a7f613cb1e --- /dev/null +++ b/Task/CSV-to-HTML-translation/AutoIt/csv-to-html-translation.autoit @@ -0,0 +1,28 @@ + Local $ascarray[4] = [34,38,60,62] + $String = "Character,Speech" & @CRLF + $String &= "The multitude,The messiah! Show us the messiah!" & @CRLF + $String &= "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!" & @CRLF + $String &= "The multitude,Who are you?" & @CRLF + $String &= "Brians mother,I'm his mother; that's who!" & @CRLF + $String &= "The multitude,Behold his mother! Behold his mother!" + For $i = 0 To UBound($ascarray) -1 + $String = Stringreplace($String, chr($ascarray[$i]), "&#"&$ascarray[$i]&";") + Next + $newstring = "" & @CRLF + $crlfsplit = StringSplit($String, @CRLF, 1) + For $i = 1 To $crlfsplit[0] + If $i = 1 Then $newstring &= "" & @CRLF + $newstring &= "" & @CRLF + $komsplit = StringSplit($crlfsplit[$i], ",") + For $k = 1 To $komsplit[0] + If $i = 1 Then + $newstring &= "" & @CRLF + Else + $newstring &= "" & @CRLF + EndIf + Next + $newstring &= "" & @CRLF + If $i = 1 Then $newstring &= "" & @CRLF + Next + $newstring &= "
" &$komsplit[$k] & "" &$komsplit[$k] & "
" + ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $newstring = ' & $newstring & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console diff --git a/Task/CSV-to-HTML-translation/BBC-BASIC/csv-to-html-translation.bbc b/Task/CSV-to-HTML-translation/BBC-BASIC/csv-to-html-translation.bbc new file mode 100644 index 0000000000..fee9389160 --- /dev/null +++ b/Task/CSV-to-HTML-translation/BBC-BASIC/csv-to-html-translation.bbc @@ -0,0 +1,42 @@ + DATA "Character,Speech" + DATA "The multitude,The messiah! Show us the messiah!" + DATA "Brian's mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!" + DATA "The multitude,Who are you?" + DATA "Brian's mother,I'm his mother; that's who!" + DATA "The multitude,Behold his mother! Behold his mother!" + DATA "***" + + *SPOOL CSVtoHTML.htm + PRINT "" + PRINT "" + PRINT "" + PRINT "" + PRINT "" + + header% = TRUE + REPEAT + READ csv$ + IF csv$ = "***" THEN EXIT REPEAT + + IF header% PRINT "" ELSE PRINT "" + + header% = FALSE + UNTIL FALSE + + PRINT "
"; ELSE PRINT "
"; + FOR i% = 1 TO LEN(csv$) + c$ = MID$(csv$, i%, 1) + CASE c$ OF + WHEN ",": IF header% PRINT ""; ELSE PRINT ""; + WHEN "<": PRINT "<"; + WHEN ">": PRINT ">"; + WHEN "&": PRINT "&"; + OTHERWISE: PRINT c$; + ENDCASE + NEXT i% + IF header% PRINT "
" + PRINT "" + PRINT "" + *spool + + SYS "ShellExecute", @hwnd%, 0, "CSVtoHTML.htm", 0, 0, 1 diff --git a/Task/CSV-to-HTML-translation/C++/csv-to-html-translation-1.cpp b/Task/CSV-to-HTML-translation/C++/csv-to-html-translation-1.cpp new file mode 100644 index 0000000000..aa156642cd --- /dev/null +++ b/Task/CSV-to-HTML-translation/C++/csv-to-html-translation-1.cpp @@ -0,0 +1,32 @@ +#include +#include +#include + +std::string csvToHTML( const std::string & ) ; + +int main( ) { + std::string text = "Character,Speech\n" + "The multitude,The messiah! Show us the messiah!\n" + "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!\n" + "The multitude,Who are you?\n" + "Brians mother,I'm his mother; that's who!\n" + "The multitude,Behold his mother! Behold his mother!\n" ; + std::cout << csvToHTML( text ) ; + return 0 ; +} + +std::string csvToHTML( const std::string & csvtext ) { + //the order of the regexes and the replacements is decisive! + std::string regexes[ 5 ] = { "<" , ">" , "^(.+?)\\b" , "," , "\n" } ; + const char* replacements [ 5 ] = { "<" , ">" , " $1" , "", "\n" } ; + boost::regex e1( regexes[ 0 ] ) ; + std::string tabletext = boost::regex_replace( csvtext , e1 , + replacements[ 0 ] , boost::match_default | boost::format_all ) ; + for ( int i = 1 ; i < 5 ; i++ ) { + e1.assign( regexes[ i ] ) ; + tabletext = boost::regex_replace( tabletext , e1 , replacements[ i ] , boost::match_default | boost::format_all ) ; + } + tabletext = std::string( "\n" ) + tabletext ; + tabletext.append( "
\n" ) ; + return tabletext ; +} diff --git a/Task/CSV-to-HTML-translation/C++/csv-to-html-translation-2.cpp b/Task/CSV-to-HTML-translation/C++/csv-to-html-translation-2.cpp new file mode 100644 index 0000000000..b8844da62a --- /dev/null +++ b/Task/CSV-to-HTML-translation/C++/csv-to-html-translation-2.cpp @@ -0,0 +1,8 @@ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-1.cs b/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-1.cs new file mode 100644 index 0000000000..3542470753 --- /dev/null +++ b/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-1.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; + + class Program + { + private static string ConvertCsvToHtmlTable(string csvText) + { + //split the CSV, assume no commas or line breaks in text + List> splitString = new List>(); + List lineSplit = csvText.Split('\n').ToList(); + foreach (string line in lineSplit) + { + splitString.Add(line.Split(',').ToList()); + } + + //encode text safely, and create table + string tableResult = ""; + foreach(List splitLine in splitString) + { + tableResult += ""; + foreach(string splitText in splitLine) + { + tableResult += ""; + } + tableResult += ""; + } + tableResult += "
" + WebUtility.HtmlEncode(splitText) + "
"; + return tableResult; + } + } diff --git a/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-2.cs b/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-2.cs new file mode 100644 index 0000000000..4df156f635 --- /dev/null +++ b/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-2.cs @@ -0,0 +1 @@ +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-3.cs b/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-3.cs new file mode 100644 index 0000000000..e56d67f18d --- /dev/null +++ b/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-3.cs @@ -0,0 +1,54 @@ +using System; +using System.Linq; +using System.Net; + +namespace CsvToHtml +{ + class Program + { + static void Main(string[] args) + { + string csv = + @"Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother!"; + + Console.Write(ConvertCsvToHtmlTable(csv, true)); + } + + private static string ConvertCsvToHtmlTable(string csvText, bool formatHeaders) + { + var rows = + (from text in csvText.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries) /* Split the string by newline, + * removing any empty rows. */ + select text.Split(',')).ToArray(); // Split each row by comma. + + string output = ""; // Initialize the output with the value of "
". + + for (int index = 0; index < rows.Length; index++) // Iterate through each row. + { + var row = rows[index]; + var tag = (index == 0 && formatHeaders) ? "th" : "td"; /* Check if this is the first row, and if to format headers. + * If so, then set the tags as table headers. + * Otherwise, set the tags as table data. */ + + output += "\r\n\t"; // Add table row tag to output string. + + // Add escaped cell data with proper tags to output string for each cell in row. + output = row.Aggregate(output, + (current, cell) => + current + + string.Format("\r\n\t\t<{0}>{1}", tag, WebUtility.HtmlEncode(cell))); + + output += "\r\n\t"; // Add closing table row tag to output string. + } + + output += "\r\n
"; // Add closing table tag to output string. + + return output; + } + } +} diff --git a/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-4.cs b/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-4.cs new file mode 100644 index 0000000000..57a1a95782 --- /dev/null +++ b/Task/CSV-to-HTML-translation/C-sharp/csv-to-html-translation-4.cs @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/C/csv-to-html-translation-1.c b/Task/CSV-to-HTML-translation/C/csv-to-html-translation-1.c new file mode 100644 index 0000000000..226784fac0 --- /dev/null +++ b/Task/CSV-to-HTML-translation/C/csv-to-html-translation-1.c @@ -0,0 +1,29 @@ +#include + +const char *input = + "Character,Speech\n" + "The multitude,The messiah! Show us the messiah!\n" + "Brians mother,Now you listen here! He's not the messiah; " + "he's a very naughty boy! Now go away!\n" + "The multitude,Who are you?\n" + "Brians mother,I'm his mother; that's who!\n" + "The multitude,Behold his mother! Behold his mother!"; + +int main() +{ + const char *s; + printf("\n\n\n
"); + for (s = input; *s; s++) { + switch(*s) { + case '\n': printf("
"); break; + case ',': printf(""); break; + case '<': printf("<"); break; + case '>': printf(">"); break; + case '&': printf("&"); break; + default: putchar(*s); + } + } + puts("
"); + + return 0; +} diff --git a/Task/CSV-to-HTML-translation/C/csv-to-html-translation-2.c b/Task/CSV-to-HTML-translation/C/csv-to-html-translation-2.c new file mode 100644 index 0000000000..0964db10ff --- /dev/null +++ b/Task/CSV-to-HTML-translation/C/csv-to-html-translation-2.c @@ -0,0 +1,8 @@ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-1.coffee b/Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-1.coffee new file mode 100644 index 0000000000..ed257aadae --- /dev/null +++ b/Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-1.coffee @@ -0,0 +1,39 @@ +String::__defineGetter__ 'escaped', () -> + this.replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') // rosettacode doesn't like " + +text = ''' +Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother! +''' + +lines = (line.split ',' for line in text.split /[\n\r]+/g) + +header = lines.shift() + +console.log """ + + + + + + +""" + +for line in lines + [character, speech] = line + console.log """ + + + """ + +console.log """ + +
#{header[0]}#{header[1]}
#{character}#{speech.escaped}
+ """ diff --git a/Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-2.coffee b/Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-2.coffee new file mode 100644 index 0000000000..a411b451cd --- /dev/null +++ b/Task/CSV-to-HTML-translation/CoffeeScript/csv-to-html-translation-2.coffee @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>The multitudeWho are you?Brians motherI'm his mother; that's who!The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-1.lisp b/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-1.lisp new file mode 100644 index 0000000000..db8c7f95f8 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-1.lisp @@ -0,0 +1,53 @@ +(defvar *csv* "Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother!") + +(defun split-string (string delim-char) + (let ((result '())) + (do* ((start 0 (1+ end)) + (end (position delim-char string) + (position delim-char string :start start))) + ((not end) (reverse (cons (subseq string start) result))) + (push (subseq string start end) result)))) + +;;; HTML escape code modified from: +;;; http://www.gigamonkeys.com/book/practical-an-html-generation-library-the-interpreter.html + +(defun escape-char (char) + (case char + (#\& "&") + (#\< "<") + (#\> ">") + (t (format nil "&#~d;" (char-code char))))) + +(defun escape (in) + (let ((to-escape "<>&")) + (flet ((needs-escape-p (char) (find char to-escape))) + (with-output-to-string (out) + (loop for start = 0 then (1+ pos) + for pos = (position-if #'needs-escape-p in :start start) + do (write-sequence in out :start start :end pos) + when pos do (write-sequence (escape-char (char in pos)) out) + while pos))))) + +(defun html-row (values headerp) + (let ((tag (if headerp "th" "td"))) + (with-output-to-string (out) + (write-string "" out) + (dolist (val values) + (format out "<~A>~A" tag (escape val) tag)) + (write-string "" out)))) + +(defun csv->html (csv) + (let* ((lines (split-string csv #\Newline)) + (cols (split-string (first lines) #\,)) + (rows (mapcar (lambda (row) (split-string row #\,)) (rest lines)))) + (with-output-to-string (html) + (format html "~C" #\Newline) + (format html "~C~A~C" #\Tab (html-row cols t) #\Newline) + (dolist (row rows) + (format html "~C~A~C" #\Tab (html-row row nil) #\Newline)) + (write-string "
" html)))) diff --git a/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-2.lisp b/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-2.lisp new file mode 100644 index 0000000000..66cb3587a8 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Common-Lisp/csv-to-html-translation-2.lisp @@ -0,0 +1,8 @@ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/D/csv-to-html-translation-1.d b/Task/CSV-to-HTML-translation/D/csv-to-html-translation-1.d new file mode 100644 index 0000000000..34b41bff97 --- /dev/null +++ b/Task/CSV-to-HTML-translation/D/csv-to-html-translation-1.d @@ -0,0 +1,34 @@ +import std.stdio; + +dstring input = + "Character,Speech\n" + "The multitude,The messiah! Show us the messiah!\n" + "Brians mother,Now you listen here! He's not the messiah; " + "he's a very naughty boy! Now go away!\n" + "The multitude,Who are you?\n" + "Brians mother,I'm his mother; that's who!\n" + "The multitude,Behold his mother! Behold his mother!"; + +void main() { + bool theadDone; + write("\n\n\n\n"); + write("\n\n \n \n\n\n \n\n
"); + foreach (c; input) { + switch(c) { + case '\n': + if (theadDone) + write("
"); + else { + write("
"); + theadDone = true; + } + break; + case ',': write(""); break; + case '<': write("<"); break; + case '>': write(">"); break; + case '&': write("&"); break; + default: write(c); + } + } + write("
\n\n"); +} diff --git a/Task/CSV-to-HTML-translation/D/csv-to-html-translation-2.d b/Task/CSV-to-HTML-translation/D/csv-to-html-translation-2.d new file mode 100644 index 0000000000..86e94dc043 --- /dev/null +++ b/Task/CSV-to-HTML-translation/D/csv-to-html-translation-2.d @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
+ + + diff --git a/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-1.delphi b/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-1.delphi new file mode 100644 index 0000000000..4f85ca2713 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-1.delphi @@ -0,0 +1,173 @@ +program csv2html; + +{$APPTYPE CONSOLE} + +uses + SysUtils, + Classes; + +const + // Carriage Return/Line Feed + CRLF = #13#10; + + // The CSV data + csvData = + 'Character,Speech'+CRLF+ + 'The multitude,The messiah! Show us the messiah!'+CRLF+ + 'Brians mother,Now you listen here! He''s not the messiah; he''s a very naughty boy! Now go away!'+CRLF+ + 'The multitude,Who are you?'+CRLF+ + 'Brians mother,I''m his mother; that''s who!'+CRLF+ + 'The multitude,Behold his mother! Behold his mother!'; + + // HTML header + htmlHead = + ''+CRLF+ + ''+CRLF+ + ''+CRLF+ + ''+CRLF+ + 'CSV-to-HTML Conversion'+CRLF+ + ''+CRLF+ + ''+CRLF+ + ''+CRLF; + + // HTML footer + htmlFoot = + ''+CRLF+ + ''; + +{ Function to split a string into a list using a given delimiter } +procedure SplitString(S, Delim: string; Rslt: TStrings); +var + i: integer; + fld: string; +begin + fld := ''; + + for i := Length(S) downto 1 do + begin + if S[i] = Delim then + begin + Rslt.Insert(0,fld); + fld := ''; + end + else + fld := S[i]+fld; + end; + + if (fld <> '') then + Rslt.Insert(0,fld); +end; + +{ Simple CSV parser with option to specify that the first row is a header row } +procedure ParseCSV(const csvIn: string; htmlOut: TStrings; FirstRowIsHeader: Boolean = True); +const + rowstart = ''; + rowend = ''; + cellendstart = ''; + hcellendstart = ''; + hrowstart = ''; + hrowend = ''; +var + tmp,pieces: TStrings; + i: Integer; +begin + // HTML header + htmlOut.Text := htmlHead + CRLF + CRLF; + + // Start the HTML table + htmlOut.Text := htmlOut.Text + '' + CRLF; + + // Create stringlist + tmp := TStringList.Create; + try + // Assign CSV data to stringlist and fix occurences of '<' and '>' + tmp.Text := StringReplace(csvIn,'<','<',[rfReplaceAll]); + tmp.Text := StringReplace(tmp.Text,'>','>',[rfReplaceAll]); + + // Create stringlist to hold the parts of the split data + pieces := TStringList.Create; + try + + // Loop through the CSV rows + for i := 0 to Pred(tmp.Count) do + begin + // Split the current row + SplitString(tmp[i],',',pieces); + + // Check if first row and FirstRowIsHeader flag set + if (i = 0) and FirstRowIsHeader then + + // Render HTML + htmlOut.Text := htmlOut.Text + hrowstart + pieces[0] + hcellendstart + pieces[1] + hrowend + CRLF + else + htmlOut.Text := htmlOut.Text + rowstart + pieces[0] + cellendstart + pieces[1] + rowend + CRLF; + + end; + + // Finish the HTML table and end the HTML page + htmlOut.Text := htmlOut.Text + '
' + CRLF + htmlFoot; + + finally + pieces.Free; + end; + + finally + tmp.Free; + end; +end; + +var + HTML: TStrings; + +begin + // Create stringlist to hold HTML output + HTML := TStringList.Create; + try + Writeln('Basic:'); + Writeln(''); + + // Load and parse the CSV data + ParseCSV(csvData,HTML,False); + + // Output the HTML to the console + Writeln(HTML.Text); + + // Save the HTML to a file (in application's folder) + HTML.SaveToFile('csv2html_basic.html'); + + Writeln(''); + Writeln('====================================='); + Writeln(''); + + HTML.Clear; + + Writeln('Extra Credit:'); + Writeln(''); + + // Load and parse the CSV data + ParseCSV(csvData,HTML,True); + + // Output the HTML to the console + Writeln(HTML.Text); + + // Save the HTML to a file (in application's folder) + HTML.SaveToFile('csv2html_extra.html'); + Writeln(''); + Writeln('====================================='); + + finally + HTML.Free; + end; + + // Keep console window open + Readln; +end. diff --git a/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-2.delphi b/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-2.delphi new file mode 100644 index 0000000000..cd1cb2e117 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-2.delphi @@ -0,0 +1,29 @@ + + + + +CSV-to-HTML Conversion + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
+ + diff --git a/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-3.delphi b/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-3.delphi new file mode 100644 index 0000000000..0d86f389a9 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Delphi/csv-to-html-translation-3.delphi @@ -0,0 +1,29 @@ + + + + +CSV-to-HTML Conversion + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
+ + diff --git a/Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation.euphoria b/Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation.euphoria new file mode 100644 index 0000000000..6ab63d1683 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Euphoria/csv-to-html-translation.euphoria @@ -0,0 +1,20 @@ +constant input = "Character,Speech\n" & + "The multitude,The messiah! Show us the messiah!\n" & + "Brians mother,Now you listen here! He's not the messiah; " & + "he's a very naughty boy! Now go away!\n" & + "The multitude,Who are you?\n" & + "Brians mother,I'm his mother; that's who!\n" & + "The multitude,Behold his mother! Behold his mother!" + +puts(1,"\n\n\n
") +for i = 1 to length(input) do + switch input[i] do + case '\n' then puts(1,"
") + case ',' then puts(1,"") + case '<' then puts(1,"<") + case '>' then puts(1,">") + case '&' then puts(1,"&") + case else puts(1,input[i]) + end switch +end for +puts(1,"
") diff --git a/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-1.go b/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-1.go new file mode 100644 index 0000000000..b65171cc92 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-1.go @@ -0,0 +1,36 @@ +package main + +import ( + "bytes" + "encoding/csv" + "fmt" + "html/template" +) + +var c = `Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother!` + +func main() { + if h, err := csvToHtml(c); err != nil { + fmt.Println(err) + } else { + fmt.Print(h) + } +} + +func csvToHtml(c string) (string, error) { + data, err := csv.NewReader(bytes.NewBufferString(c)).ReadAll() + if err != nil { + return "", err + } + var b bytes.Buffer + err = template.Must(template.New("").Parse(` +{{range .}} {{range .}}{{end}} +{{end}}
{{.}}
+`)).Execute(&b, data) + return b.String(), err +} diff --git a/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-2.go b/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-2.go new file mode 100644 index 0000000000..ba30c892c3 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-2.go @@ -0,0 +1,56 @@ +package main + +import ( + "bytes" + "encoding/csv" + "flag" + "fmt" + "html/template" +) + +var csvStr = `Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother!` + +func main() { + headings := flag.Bool("h", false, "format first row as column headings") + flag.Parse() + if html, err := csvToHtml(csvStr, *headings); err != nil { + fmt.Println(err) + } else { + fmt.Print(html) + } +} + +func csvToHtml(csvStr string, headings bool) (string, error) { + data, err := csv.NewReader(bytes.NewBufferString(csvStr)).ReadAll() + if err != nil { + return "", err + } + tStr := tPlain + if headings { + tStr = tHeadings + } + var b bytes.Buffer + err = template.Must(template.New("").Parse(tStr)).Execute(&b, data) + return b.String(), err +} + +const ( + tPlain = ` +{{range .}} {{range .}}{{end}} +{{end}}
{{.}}
+` + tHeadings = `{{if .}} +{{range $x, $e := .}}{{if $x}} + {{range .}}{{end}}{{else}} + {{range .}}{{end}} + + {{end}}{{end}} + {{end}} +
{{.}}
{{.}}
+` +) diff --git a/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-3.go b/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-3.go new file mode 100644 index 0000000000..058e81090b --- /dev/null +++ b/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-3.go @@ -0,0 +1,12 @@ + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-4.go b/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-4.go new file mode 100644 index 0000000000..1a99c2b917 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Go/csv-to-html-translation-4.go @@ -0,0 +1,8 @@ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-1.hs b/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-1.hs new file mode 100644 index 0000000000..347eccc68a --- /dev/null +++ b/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-1.hs @@ -0,0 +1,26 @@ +--import Data.List.Split (splitOn) -- if the import is available +splitOn :: Char -> String -> [String] -- otherwise +splitOn delim = foldr (\x rest -> + if x == delim then "" : rest + else (x:head rest):tail rest) [""] + +htmlEscape :: String -> String +htmlEscape = concatMap escapeChar + where escapeChar '<' = "<" + escapeChar '>' = ">" + escapeChar '&' = "&" + escapeChar '"' = """ --" + escapeChar c = [c] + +toHtmlRow :: [String] -> String +toHtmlRow [] = "" +toHtmlRow cols = let htmlColumns = concatMap toHtmlCol cols + in "\n" ++ htmlColumns ++ "" + where toHtmlCol x = " " ++ htmlEscape x ++ "\n" + +csvToTable :: String -> String +csvToTable csv = let rows = map (splitOn ',') $ lines csv + html = unlines $ map toHtmlRow rows + in "\n" ++ html ++ "
" + +main = interact csvToTable diff --git a/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-2.hs b/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-2.hs new file mode 100644 index 0000000000..e1a1189b39 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-2.hs @@ -0,0 +1,11 @@ +import Data.List (unfoldr) +split p = unfoldr (\s -> case dropWhile p s of [] -> Nothing + ss -> Just $ break p ss) + +main = interact (\csv -> "\n" ++ + (unlines $ map ((\cols -> "\n" ++ + (concatMap (\x -> " \n") cols) + ++ "") . split (==',')) $ lines csv) ++ "
" ++ concatMap (\c -> + case c of {'<' -> "<"; '>' -> ">"; + '&' -> "&"; '"' -> """; _ -> [c]}) x + ++ "
") diff --git a/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-3.hs b/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-3.hs new file mode 100644 index 0000000000..165abe9fe6 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Haskell/csv-to-html-translation-3.hs @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-1.java b/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-1.java new file mode 100644 index 0000000000..348dee6b96 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-1.java @@ -0,0 +1,86 @@ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.PrintStream; + +class Csv2Html { + + public static String escapeChars(String lineIn) { + StringBuilder sb = new StringBuilder(); + int lineLength = lineIn.length(); + for (int i = 0; i < lineLength; i++) { + char c = lineIn.charAt(i); + switch (c) { + case '"': + sb.append("""); + break; + case '&': + sb.append("&"); + break; + case '\'': + sb.append("'"); + break; + case '<': + sb.append("<"); + break; + case '>': + sb.append(">"); + break; + default: sb.append(c); + } + } + return sb.toString(); + } + + public static void tableHeader(PrintStream ps, String[] columns) { + ps.print(""); + for (int i = 0; i < columns.length; i++) { + ps.print(""); + ps.print(columns[i]); + ps.print(""); + } + ps.println(""); + } + + public static void tableRow(PrintStream ps, String[] columns) { + ps.print(""); + for (int i = 0; i < columns.length; i++) { + ps.print(""); + ps.print(columns[i]); + ps.print(""); + } + ps.println(""); + } + + public static void main(String[] args) throws Exception { + boolean withTableHeader = (args.length != 0); + + InputStreamReader isr = new InputStreamReader(System.in); + BufferedReader br = new BufferedReader(isr); + PrintStream stdout = System.out; + + stdout.println(""); + stdout.println(""); + stdout.println(""); + stdout.println("Csv2Html"); + stdout.println(""); + stdout.println("

Csv2Html

"); + + stdout.println(""); + String stdinLine; + boolean firstLine = true; + while ((stdinLine = br.readLine()) != null) { + String[] columns = escapeChars(stdinLine).split(","); + if (withTableHeader == true && firstLine == true) { + tableHeader(stdout, columns); + firstLine = false; + } else { + tableRow(stdout, columns); + } + } + stdout.println("
"); + } +} diff --git a/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-2.java b/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-2.java new file mode 100644 index 0000000000..626f1fce22 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-2.java @@ -0,0 +1,18 @@ + + + +Csv2Html + +

Csv2Html

+ + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-3.java b/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-3.java new file mode 100644 index 0000000000..f97a531ff3 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Java/csv-to-html-translation-3.java @@ -0,0 +1,18 @@ + + + +Csv2Html + +

Csv2Html

+ + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-1.js b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-1.js new file mode 100644 index 0000000000..48a36f60a0 --- /dev/null +++ b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-1.js @@ -0,0 +1,30 @@ +var csv = "Character,Speech\n" + + "The multitude,The messiah! Show us the messiah!\n" + + "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!\n" + + "The multitude,Who are you?\n" + + "Brians mother,I'm his mother; that's who!\n" + + "The multitude,Behold his mother! Behold his mother!"; + +csv = csv.replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); + +var lines = csv.split(/[\n\r]+/g), + header = lines.shift().split(","), + line, + rows = "", + thead = ''+ + ''+header[0]+''+ + ''+header[1]+''+ + '\n'; + +for (var i=0, len=lines.length; i'+line[0]+''+ + ''+line[1]+''+ + '\n'; +} + +console.log('\n' + thead + '\n' + rows + '
' ); diff --git a/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-2.js b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-2.js new file mode 100644 index 0000000000..812deb6489 --- /dev/null +++ b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-2.js @@ -0,0 +1,9 @@ + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-3.js b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-3.js new file mode 100644 index 0000000000..2e07b4825f --- /dev/null +++ b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-3.js @@ -0,0 +1,20 @@ +function csv_to_table(s) { + function ce(t) { return document.createElement(t); } + function ap(t) { document.body.appendChild(t); } + var t = ce('table'), f = 0; //1; + s.split('\n').map(function(l) { + var r = ce(f ? 'tr': 'thead'); + l.split(',').map(function (w) { + var c = ce(f ? 'td' : 'th'); + c.textContent = w; + r.appendChild(c); + }); + t.appendChild(r); + f = 1; //0; + }); + //return t.innerHTML; + return t.outerHTML; +} +/* +but also with this changes is very dependent by javascript engine and/or browser version (in: IE>=9, chrome ) +*/ diff --git a/Task/CSV-to-HTML-translation/Lua/csv-to-html-translation-1.lua b/Task/CSV-to-HTML-translation/Lua/csv-to-html-translation-1.lua new file mode 100644 index 0000000000..f76b23a542 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Lua/csv-to-html-translation-1.lua @@ -0,0 +1,28 @@ +FS = "," -- field separator + +csv = [[ +Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother! +]] + +csv = csv:gsub( "<", "<" ) +csv = csv:gsub( ">", "&gr;" ) + +html = { "" } +for line in string.gmatch( csv, "(.-\n)" ) do + str = "" + for field in string.gmatch( line, "(.-)["..FS.."?\n?]" ) do + str = str .. "" + end + str = str .. "" + html[#html+1] = str; +end +html[#html+1] = "
" .. field .. "
" + +for _, line in pairs(html) do + print(line) +end diff --git a/Task/CSV-to-HTML-translation/Lua/csv-to-html-translation-2.lua b/Task/CSV-to-HTML-translation/Lua/csv-to-html-translation-2.lua new file mode 100644 index 0000000000..e0cdcdeb78 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Lua/csv-to-html-translation-2.lua @@ -0,0 +1,8 @@ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry&gr;Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry&gr;
The multitudeWho are you
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-1.m b/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-1.m new file mode 100644 index 0000000000..b7c304891e --- /dev/null +++ b/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-1.m @@ -0,0 +1,15 @@ +inputString = fileread(csvFileName); + % using multiple regular expressions to clear up special chars +htmlFriendly = regexprep(regexprep(regexprep(regexprep(inputString,... + '&','&'),... + '"','"'),... + '<','<'),... + '>','>'); + % split string into cell array +tableValues = regexp(regexp(htmlFriendly,'(\r\n|\r|\n)','split')',',','split'); + %%% print in html format %%% + % first line gets treated as header +fprintf(1,['\n\t' sprintf('\n\t\t',tableValues{1,:}{:})]) + % print remaining lines of csv as html table (rows 2:end in cell array of csv values) +cellfun(@(x)fprintf(1,['\n\t' sprintf('\n\t\t',x{:}) '\n\t']),tableValues(2:end)) +fprintf(1,'\n
%s
%s
') diff --git a/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-2.m b/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-2.m new file mode 100644 index 0000000000..23d05067d7 --- /dev/null +++ b/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-2.m @@ -0,0 +1 @@ +fprintf(1,['\n\t\n\t\t\n\t\t\n\t\n\t\t\n','\n','once'),',','\n\t\t\n\t\n
',regexprep(regexprep(regexprep(regexprep(regexprep(regexprep(regexprep(regexprep(fileread(cvsFileName),'&','&'),'"','"'),'<','<'),'>','>'),'(?<=(^[^\n\r]*)),',''),'(?)(\r\n|\r|\n)','\n\t
'),''),'
\n']) diff --git a/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-3.m b/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-3.m new file mode 100644 index 0000000000..fc8d987cac --- /dev/null +++ b/Task/CSV-to-HTML-translation/MATLAB/csv-to-html-translation-3.m @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Perl/csv-to-html-translation-1.pl b/Task/CSV-to-HTML-translation/Perl/csv-to-html-translation-1.pl new file mode 100644 index 0000000000..3bb2f03633 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Perl/csv-to-html-translation-1.pl @@ -0,0 +1,15 @@ +use HTML::Entities; + +sub row { + my $elem = shift; + my @cells = map {"<$elem>$_"} split ',', shift; + print '', @cells, "\n"; +} + +my ($first, @rest) = map + {my $x = $_; chomp $x; encode_entities $x} + ; +print "\n"; +row @ARGV ? 'th' : 'td', $first; +row 'td', $_ foreach @rest; +print "
\n"; diff --git a/Task/CSV-to-HTML-translation/Perl/csv-to-html-translation-2.pl b/Task/CSV-to-HTML-translation/Perl/csv-to-html-translation-2.pl new file mode 100644 index 0000000000..494c1ff1a6 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Perl/csv-to-html-translation-2.pl @@ -0,0 +1,8 @@ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-1.l b/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-1.l new file mode 100644 index 0000000000..54718c0810 --- /dev/null +++ b/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-1.l @@ -0,0 +1,8 @@ +(load "@lib/http.l") + +(in "text.csv" + ( 'myStyle NIL NIL + (prinl) + (while (split (line) ",") + ( NIL (ht:Prin (pack (car @))) (ht:Prin (pack (cadr @)))) + (prinl) ) ) ) diff --git a/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-2.l b/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-2.l new file mode 100644 index 0000000000..53c5bbca5f --- /dev/null +++ b/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-2.l @@ -0,0 +1,8 @@ +
+ + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-3.l b/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-3.l new file mode 100644 index 0000000000..d123d3eebe --- /dev/null +++ b/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-3.l @@ -0,0 +1,9 @@ +(load "@lib/http.l") + +(in "text.csv" + (when (split (line) ",") + ( 'myStyle NIL (mapcar '((S) (list NIL (pack S))) @) + (prinl) + (while (split (line) ",") + ( NIL (ht:Prin (pack (car @))) (ht:Prin (pack (cadr @)))) + (prinl) ) ) ) ) diff --git a/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-4.l b/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-4.l new file mode 100644 index 0000000000..d6f4dbe672 --- /dev/null +++ b/Task/CSV-to-HTML-translation/PicoLisp/csv-to-html-translation-4.l @@ -0,0 +1,7 @@ +
+ + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-1.pro b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-1.pro new file mode 100644 index 0000000000..06bf8c825f --- /dev/null +++ b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-1.pro @@ -0,0 +1,52 @@ +csv_html :- + L = "Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother!", + + csv_html(L, Out, []), + string_to_list(Str, Out), + writeln(Str). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% simple HTML +% +csv_html(L) --> + "\n", + csv_tr(L), + "
". + +csv_tr([]) --> []. + +csv_tr(L) --> + "\n", + csv_td(L, S), + "\n\n", + csv_tr(S). + +csv_td(L, S) --> + "", + csv_td_in(L, S), + "". + +csv_td_in([], []) --> []. + +csv_td_in([10|L], L) --> []. + +csv_td_in([44|L], S) --> + "", + csv_td_in(L,S). + +csv_td_in([60|T], S) --> + "<", + csv_td_in(T, S). + +csv_td_in([62|T], S) --> + ">", + csv_td_in(T, S). + +csv_td_in([H|T], S) --> + [H], + csv_td_in(T, S). diff --git a/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-2.pro b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-2.pro new file mode 100644 index 0000000000..32456f5753 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-2.pro @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!></angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-3.pro b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-3.pro new file mode 100644 index 0000000000..c5c27aeaa0 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-3.pro @@ -0,0 +1,90 @@ +csv_html_plus :- + L = +"Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother!", + + csv_html_plus(L, Out1, []), + string_to_list(Str1, Out1), + writeln(Str1). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% HTML + +% +csv_html_plus(L) --> + "\n", + csv_head(L, R), + csv_body(R), + "
". + + +csv_head(L, R) --> + "\n", + csv_head_tr(L, R), + "\n". + + +csv_head_tr(L, R) --> + "\n", + csv_head_th(L, R), + "\n\n". + + +csv_head_th(L, S) --> + "", + csv_head_th_in(L, S), + "". + +csv_head_th_in([], []) --> []. + +csv_head_th_in([10|L], L) --> []. + +csv_head_th_in([44|L], S) --> + "", + csv_head_th_in(L,S). + +csv_head_th_in([H|T], S) --> + [H], + csv_head_th_in(T, S). + + +csv_body(L) --> + "\n", + csv_body_tr(L), + "\n". + +csv_body_tr([]) --> []. + +csv_body_tr(L) --> + "\n", + csv_body_td(L, S), + "\n\n", + csv_body_tr(S). + +csv_body_td(L, S) --> + "", + csv_body_td_in(L, S), + "". + +csv_body_td_in([], []) --> []. + +csv_body_td_in([10|L], L) --> []. + +csv_body_td_in([44|L], S) --> + "", + csv_body_td_in(L,S). + +csv_body_td_in([60|T], S) --> + "<", + csv_body_td_in(T, S). + +csv_body_td_in([62|T], S) --> + ">", + csv_body_td_in(T, S). + +csv_body_td_in([H|T], S) --> + [H], + csv_body_td_in(T, S). diff --git a/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-4.pro b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-4.pro new file mode 100644 index 0000000000..cbebe3e1ad --- /dev/null +++ b/Task/CSV-to-HTML-translation/Prolog/csv-to-html-translation-4.pro @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!></angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-1.py b/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-1.py new file mode 100644 index 0000000000..44e185f541 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-1.py @@ -0,0 +1,28 @@ +csvtxt = '''\ +Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother!\ +''' + +from cgi import escape + +def _row2tr(row, attr=None): + cols = escape(row).split(',') + return ('' + + ''.join('%s' % data for data in cols) + + '') + +def csv2html(txt): + htmltxt = '\n' + for rownum, row in enumerate(txt.split('\n')): + htmlrow = _row2tr(row) + htmlrow = ' %s\n' % htmlrow + htmltxt += htmlrow + htmltxt += '
\n' + return htmltxt + +htmltxt = csv2html(csvtxt) +print(htmltxt) diff --git a/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-2.py b/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-2.py new file mode 100644 index 0000000000..d11d0b31e5 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-2.py @@ -0,0 +1,8 @@ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-3.py b/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-3.py new file mode 100644 index 0000000000..0c900393ac --- /dev/null +++ b/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-3.py @@ -0,0 +1,30 @@ +def _row2trextra(row, attr=None): + cols = escape(row).split(',') + attr_tr = attr.get('TR', '') + attr_td = attr.get('TD', '') + return (('' % attr_tr) + + ''.join('%s' % (attr_td, data) for data in cols) + + '') + +def csv2htmlextra(txt, header=True, attr=None): + ' attr is a dictionary mapping tags to attributes to add to that tag' + + attr_table = attr.get('TABLE', '') + attr_thead = attr.get('THEAD', '') + attr_tbody = attr.get('TBODY', '') + htmltxt = '\n' % attr_table + for rownum, row in enumerate(txt.split('\n')): + htmlrow = _row2trextra(row, attr) + rowclass = ('THEAD%s' % attr_thead) if (header and rownum == 0) else ('TBODY%s' % attr_tbody) + htmlrow = ' <%s>%s\n' % (rowclass, htmlrow, rowclass[:5]) + htmltxt += htmlrow + htmltxt += '\n' + return htmltxt + +htmltxt = csv2htmlextra(csvtxt, True, + dict(TABLE=' border="1" summary="csv2html extra program output"', + THEAD=' bgcolor="yellow"', + TBODY=' bgcolor="orange"' + ) + ) +print(htmltxt) diff --git a/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-4.py b/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-4.py new file mode 100644 index 0000000000..07b3ccd796 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Python/csv-to-html-translation-4.py @@ -0,0 +1,8 @@ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/REXX/csv-to-html-translation-1.rexx b/Task/CSV-to-HTML-translation/REXX/csv-to-html-translation-1.rexx new file mode 100644 index 0000000000..a51d3001ac --- /dev/null +++ b/Task/CSV-to-HTML-translation/REXX/csv-to-html-translation-1.rexx @@ -0,0 +1,38 @@ +/*REXX program to convert CSV ───> HTML table representing the CSV data.*/ +/*REXX program to convert CSV ───> HTML table representing the CSV data.*/ + +arg header_ . /*see if the user wants a header.*/ +wantsHdr= (header_=='HEADER') /*arg (low/upp/mix case)=HEADER ?*/ + + iFID='CSV_HTML.TXT' /*the input fileID. */ +if wantsHdr then oFID='OUTPUTH.HTML' /*output fileID with header, */ + else oFID='OUTPUT.HTML' /* " " without header. */ + + do rows=0 while lines(iFID)\==0 /*read the rows from a (txt) file*/ + row.rows=strip(linein(iFID)) + end /*rows*/ + +convFrom= '& < > "' /*special characters to convert. */ +convTo = '& < > "' /*what they are converted into. */ + +call write ,'' +call write ,'' + + do j=0 for rows; call write 5,'' + tx='td' + if wantsHdr & j==0 then tx='th' + + do while row.j\==''; parse var row.j yyy ',' row.j + do k=1 for words(convFrom) + yyy=changestr(word(convFrom,k),yyy,word(convTo,k)) + end /*k*/ + call write 10,'<'tx">"yyy'" + end /*forever*/ + end /*j*/ + +call write 5,'' +call write ,'
' +call write ,'' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────WRITE subroutine────────────────────*/ +write: call lineout oFID,left('',0||arg(1))arg(2); return diff --git a/Task/CSV-to-HTML-translation/REXX/csv-to-html-translation-2.rexx b/Task/CSV-to-HTML-translation/REXX/csv-to-html-translation-2.rexx new file mode 100644 index 0000000000..f1e6eb5a74 --- /dev/null +++ b/Task/CSV-to-HTML-translation/REXX/csv-to-html-translation-2.rexx @@ -0,0 +1,26 @@ +/*╔══════════════════════════════╗ CHANGESTR ╔═════════════════════════╗ +╔═╩══════════════════════════════╝ function ╚═════════════════════════╩═╗ +║ new string to be used──────────┐ ┌─────limit of # changes (times)║ +║ original string (haystack)────────┐ │ │ [default: ≈ one billian]║ +║ old string to be changed───┐ │ │ │ ┌───begin at this occurance #.║ +║ {O, H, and N can be null.} │ │ │ │ │ [default: 1st occurrance]║ +╚═╦════════════════════════════╗ │ │ │ │ │ ╔═══════════════════════╦═╝ + ╚════════════════════════════╝ ↓ ↓ ↓ ↓ ↓ ╚═══════════════════════╝*/ +changestr: procedure; parse arg o,h,n,t,b /* T and B are optional.*/ +$='' /*$: the returned string.*/ +t=word(t 999999999 , 1) /*maybe use the default? */ +b=word(b 1 , 1) /* " " " " */ +w=length(o) /*length of OLD string.*/ +if w==0 & t\=0 then return n || h /*changing a null char ? */ +#=0 /*# of changed occurances*/ + do j=1 until # >= t /*keep changing, T times.*/ + parse var h y (o) _ +(w) h /*parse the string ... */ + if _=='' then return $ || y /*no more left, return. */ + if jNow you listen here! He's not the messiah; he's a very naughty boy! Now go away!" + "The multitude,Who are you?" + "Brians mother,I'm his mother; that's who!" + "The multitude,Behold his mother! Behold his mother!") + "\n")) + +(define (CSV-lines->HTML-table csv) + (define csv-rows + (regexp-split "\n" csv)) + (define csv-row-cells + (map (lambda (row) (regexp-split "," row)) csv-rows)) + (define (cell-data->HTML-data data) + `(td () ,data)) + (define (row-data->HTML-row CSV-row) + `(tr () ,@(map cell-data->HTML-data CSV-row) "\n")) + `(table + (thead + ,(row-data->HTML-row (car csv-row-cells))) + (tbody ,@(map row-data->HTML-row (cdr csv-row-cells))))) + +(require xml) +(display (xexpr->string (CSV-lines->HTML-table e.g.-CSV))) diff --git a/Task/CSV-to-HTML-translation/Racket/csv-to-html-translation-2.rkt b/Task/CSV-to-HTML-translation/Racket/csv-to-html-translation-2.rkt new file mode 100644 index 0000000000..2791804673 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Racket/csv-to-html-translation-2.rkt @@ -0,0 +1,7 @@ + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Ruby/csv-to-html-translation-1.rb b/Task/CSV-to-HTML-translation/Ruby/csv-to-html-translation-1.rb new file mode 100644 index 0000000000..7291aee412 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Ruby/csv-to-html-translation-1.rb @@ -0,0 +1,17 @@ +require 'cgi' + +puts '' + +def row2html str, wrap = "td" + "" + + str.split(",").map { |cell| "<#{wrap}>#{CGI.escapeHTML cell}" }.join + + "" +end + +puts row2html gets.chomp, "th" if ARGV.delete "header" + +while str = gets + puts row2html str.chomp +end + +puts "
" diff --git a/Task/CSV-to-HTML-translation/Ruby/csv-to-html-translation-2.rb b/Task/CSV-to-HTML-translation/Ruby/csv-to-html-translation-2.rb new file mode 100644 index 0000000000..aad030a74f --- /dev/null +++ b/Task/CSV-to-HTML-translation/Ruby/csv-to-html-translation-2.rb @@ -0,0 +1,8 @@ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Scala/csv-to-html-translation-1.scala b/Task/CSV-to-HTML-translation/Scala/csv-to-html-translation-1.scala new file mode 100644 index 0000000000..62e12d1c9c --- /dev/null +++ b/Task/CSV-to-HTML-translation/Scala/csv-to-html-translation-1.scala @@ -0,0 +1,35 @@ +import scala.xml.Utility + + val header = + """ + +Csv2Html + + + """ + +def csv2html(csv:String, withHead:Boolean) = { + + def processRow = "" ++ (_:String).split(',').flatMap("" + Utility.escape(_) + "") ++ "" + + val (first::rest) = csv.lines.toList + + val tableHead = if (withHead) s"${processRow(first)}\n" else processRow(first) + + val tableContent = tableHead + rest.map(processRow).mkString("\n") + + s"$header$tableContent
" +} + + val csv = +"""Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother!""" + +csv2html(csv, true) diff --git a/Task/CSV-to-HTML-translation/Scala/csv-to-html-translation-2.scala b/Task/CSV-to-HTML-translation/Scala/csv-to-html-translation-2.scala new file mode 100644 index 0000000000..24c8274147 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Scala/csv-to-html-translation-2.scala @@ -0,0 +1,13 @@ + + +Csv2Html + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-1.tcl b/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-1.tcl new file mode 100644 index 0000000000..6b41ae0db4 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-1.tcl @@ -0,0 +1,24 @@ +package require Tcl 8.5 +package require csv +package require html +package require struct::queue + +set csvData "Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother!" + +struct::queue rows +foreach line [split $csvData "\n"] { + csv::split2queue rows $line +} +html::init +puts [subst { + [html::openTag table {summary="csv2html program output"}] + [html::while {[rows size]} { + [html::row {*}[html::quoteFormValue [rows get]]] + }] + [html::closeTag] +}] diff --git a/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-2.tcl b/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-2.tcl new file mode 100644 index 0000000000..748d62eea4 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-2.tcl @@ -0,0 +1,45 @@ +package require Tcl 8.5 +package require csv +package require html +package require struct::queue + +set csvData "Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother!" + +html::init { + table.border 1 + table.summary "csv2html program output" + tr.bgcolor orange +} + +# Helpers; the html package is a little primitive otherwise +proc table {contents {opts ""}} { + set out [html::openTag table $opts] + append out [uplevel 1 [list subst $contents]] + append out [html::closeTag] +} +proc tr {list {ropt ""}} { + set out [html::openTag tr $ropt] + foreach x $list {append out [html::cell "" $x td]} + append out [html::closeTag] +} + +# Parse the CSV data +struct::queue rows +foreach line [split $csvData "\n"] { + csv::split2queue rows $line +} + +# Generate the output +puts [subst { + [table { + [tr [html::quoteFormValue [rows get]] {bgcolor="yellow"}] + [html::while {[rows size]} { + [tr [html::quoteFormValue [rows get]]] + }] + }] +}] diff --git a/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-3.tcl b/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-3.tcl new file mode 100644 index 0000000000..3a4d5508b0 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Tcl/csv-to-html-translation-3.tcl @@ -0,0 +1,8 @@ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! </angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/Caesar-cipher/C++/caesar-cipher.cpp b/Task/Caesar-cipher/C++/caesar-cipher.cpp new file mode 100644 index 0000000000..a896bbf42b --- /dev/null +++ b/Task/Caesar-cipher/C++/caesar-cipher.cpp @@ -0,0 +1,45 @@ +#include +#include +#include +#include + +class MyTransform { +private : + int shift ; +public : + MyTransform( int s ) : shift( s ) { } + + char operator( )( char c ) { + if ( isspace( c ) ) + return ' ' ; + else { + static std::string letters( "abcdefghijklmnopqrstuvwxyz" ) ; + std::string::size_type found = letters.find(tolower( c )) ; + int shiftedpos = ( static_cast( found ) + shift ) % 26 ; + if ( shiftedpos < 0 ) //in case of decryption possibly + shiftedpos = 26 + shiftedpos ; + char shifted = letters[shiftedpos] ; + return shifted ; + } + } +} ; + +int main( ) { + std::string input ; + std::cout << "Which text is to be encrypted ?\n" ; + getline( std::cin , input ) ; + std::cout << "shift ?\n" ; + int myshift = 0 ; + std::cin >> myshift ; + std::cout << "Before encryption:\n" << input << std::endl ; + std::transform ( input.begin( ) , input.end( ) , input.begin( ) , + MyTransform( myshift ) ) ; + std::cout << "encrypted:\n" ; + std::cout << input << std::endl ; + myshift *= -1 ; //decrypting again + std::transform ( input.begin( ) , input.end( ) , input.begin( ) , + MyTransform( myshift ) ) ; + std::cout << "Decrypted again:\n" ; + std::cout << input << std::endl ; + return 0 ; +} diff --git a/Task/Caesar-cipher/Common-Lisp/caesar-cipher.lisp b/Task/Caesar-cipher/Common-Lisp/caesar-cipher.lisp new file mode 100644 index 0000000000..9327652e36 --- /dev/null +++ b/Task/Caesar-cipher/Common-Lisp/caesar-cipher.lisp @@ -0,0 +1,23 @@ +(defun encipher-char (ch key) + (let* + ((c (char-code ch)) + (la (char-code #\a)) (lz (char-code #\z)) + (ua (char-code #\A)) (uz (char-code #\Z)) + (base (cond + ((and (>= c la) (<= c lz)) la) + ((and (>= c ua) (<= c uz)) ua) + (t nil)))) + (if base (code-char (+ (mod (+ (- c base) key) 26) base)) ch))) + +(defun caesar-cipher (str key) + (map 'string #'(lambda (c) (encipher-char c key)) str)) + +(defun caesar-decipher (str key) (caesar-cipher str (- key))) + +(let* ((original-text "The five boxing wizards jump quickly") + (key 3) + (cipher-text (caesar-cipher original-text key)) + (recovered-text (caesar-decipher cipher-text key))) + (format t " Original: ~a ~%" original-text) + (format t "Encrypted: ~a ~%" cipher-text) + (format t "Decrypted: ~a ~%" recovered-text)) diff --git a/Task/Caesar-cipher/D/caesar-cipher-1.d b/Task/Caesar-cipher/D/caesar-cipher-1.d new file mode 100644 index 0000000000..447d25dc88 --- /dev/null +++ b/Task/Caesar-cipher/D/caesar-cipher-1.d @@ -0,0 +1,21 @@ +import std.stdio, std.traits; + +pure S rot(S)(in S s, in int key) if (isSomeString!S) { + auto res = s.dup; + + foreach (i, ref c; res) { + if ('a' <= c && c <= 'z') + c = ((c - 'a' + key) % 26 + 'a'); + else if ('A' <= c && c <= 'Z') + c = ((c - 'A' + key) % 26 + 'A'); + } + return cast(S) res; +} + +void main() { + int key = 3; + auto txt = "The five boxing wizards jump quickly"; + writeln("Original: ", txt); + writeln("Encrypted: ", txt.rot(key)); + writeln("Decrypted: ", txt.rot(key).rot(26 - key)); +} diff --git a/Task/Caesar-cipher/D/caesar-cipher-2.d b/Task/Caesar-cipher/D/caesar-cipher-2.d new file mode 100644 index 0000000000..19a7e72d2f --- /dev/null +++ b/Task/Caesar-cipher/D/caesar-cipher-2.d @@ -0,0 +1,20 @@ +import std.stdio, std.ascii; + +void inplaceRot(char[] txt, in int key) pure nothrow { + foreach (ref c; txt) { + if (isLower(c)) + c = (c - 'a' + key) % 26 + 'a'; + else if (isUpper(c)) + c = (c - 'A' + key) % 26 + 'A'; + } +} + +void main() { + enum key = 3; + auto txt = "The five boxing wizards jump quickly".dup; + writeln("Original: ", txt); + txt.inplaceRot(key); + writeln("Encrypted: ", txt); + txt.inplaceRot(26 - key); + writeln("Decrypted: ", txt); +} diff --git a/Task/Caesar-cipher/Dart/caesar-cipher.dart b/Task/Caesar-cipher/Dart/caesar-cipher.dart new file mode 100644 index 0000000000..c7ae682a2b --- /dev/null +++ b/Task/Caesar-cipher/Dart/caesar-cipher.dart @@ -0,0 +1,64 @@ +class Caesar { + int _key; + + Caesar(this._key); + + int _toCharCode(String s) { + return s.charCodeAt(0); + } + + String _fromCharCode(int ch) { + return new String.fromCharCodes([ch]); + } + + String _process(String msg, int offset) { + StringBuffer sb=new StringBuffer(); + for(int i=0;i=_toCharCode('A')&&ch<=_toCharCode('Z')) { + sb.add(_fromCharCode(_toCharCode("A")+(ch-_toCharCode("A")+offset)%26)); + } + else if(ch>=_toCharCode('a')&&ch<=_toCharCode('z')) { + sb.add(_fromCharCode(_toCharCode("a")+(ch-_toCharCode("a")+offset)%26)); + } else { + sb.add(msg[i]); + } + } + return sb.toString(); + } + + String encrypt(String msg) { + return _process(msg, _key); + } + + String decrypt(String msg) { + return _process(msg, 26-_key); + } +} + +void trip(String msg) { + Caesar cipher=new Caesar(10); + + String enc=cipher.encrypt(msg); + String dec=cipher.decrypt(enc); + print("\"$msg\" encrypts to:"); + print("\"$enc\" decrypts to:"); + print("\"$dec\""); + Expect.equals(msg,dec); +} + +main() { + Caesar c2=new Caesar(2); + print(c2.encrypt("HI")); + Caesar c20=new Caesar(20); + print(c20.encrypt("HI")); + + // try a few roundtrips + + trip(""); + trip("A"); + trip("z"); + trip("Caesar cipher"); + trip(".-:/\"\\!"); + trip("The Quick Brown Fox Jumps Over The Lazy Dog."); +} diff --git a/Task/Caesar-cipher/Elena/caesar-cipher.elena b/Task/Caesar-cipher/Elena/caesar-cipher.elena new file mode 100644 index 0000000000..4d5ebbe974 --- /dev/null +++ b/Task/Caesar-cipher/Elena/caesar-cipher.elena @@ -0,0 +1,59 @@ +#define std'dictionary'*. +#define std'basic'*. +#define std'patterns'*. +#define std'routines'strings'*. + +#define math'* = std'math'*. + +// --- subjects --- +#subject cipher_key. + +#symbol Letters = "abcdefghijklmnopqrstuvwxyz". +#symbol BigLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ". +#symbol TestText = "Pack my box with five dozen liquor jugs.". +#symbol Key = 12. + +#symbol EEncrypt : aKey = +{ + eval : aChar + [ + #var anIndex := Letters~eliteralop first_occ'find:aChar. + #if (-1) ifless:anIndex + [ + $next eval:(Letters @ (aKey + anIndex)~math'eops math'modulus:26). + ] + | [ + anIndex := BigLetters~eliteralop first_occ'find:aChar. + #if (-1) ifless:anIndex + [ + $next eval:(BigLetters @ (aKey + anIndex)~math'eops math'modulus:26). + ] + | [ + $next eval:aChar. + ]. + ]. + ] +}. + +#symbol Encrypted &literal:aLiteral &cipher_key:aKey + = __group(EEncrypt::aKey, Summing::String) start:Scan::aLiteral. + +#symbol Decrypted &literal:aLiteral &cipher_key:aKey + = __group(EEncrypt::(26 - aKey), Summing::String) start:Scan::aLiteral. + +#symbol Program = +[ + #var anS := TestText. + + 'program'output << "Original text :" << anS << "%n". + + anS := Encrypted &&literal:anS &cipher_key:Key. + + 'program'output << "Encrypted text:" << anS << "%n". + + anS := Decrypted &&literal:anS &cipher_key:Key. + + 'program'output << "Decrypted text:" << anS << "%n". + + 'program'input get. +]. diff --git a/Task/Caesar-cipher/Euphoria/caesar-cipher.euphoria b/Task/Caesar-cipher/Euphoria/caesar-cipher.euphoria new file mode 100644 index 0000000000..939241f9f7 --- /dev/null +++ b/Task/Caesar-cipher/Euphoria/caesar-cipher.euphoria @@ -0,0 +1,54 @@ +--caesar cipher for Rosetta Code wiki +--User:Lnettnay + +--usage eui caesar ->default text, key and encode flag +--usage eui caesar 'Text with spaces and punctuation!' 5 D +--If text has imbedded spaces must use apostophes instead of quotes so all punctuation works +--key = integer from 1 to 25, defaults to 13 +--flag = E (Encode) or D (Decode), defaults to E +--no error checking is done on key or flag + +include std/get.e +include std/types.e + + +sequence cmd = command_line() +sequence val +-- default text for encryption +sequence text = "The Quick Brown Fox Jumps Over The Lazy Dog." +atom key = 13 -- default to Rot-13 +sequence flag = "E" -- default to Encrypt +atom offset +atom num_letters = 26 -- number of characters in alphabet + +--get text +if length(cmd) >= 3 then + text = cmd[3] +end if + +--get key value +if length(cmd) >= 4 then + val = value(cmd[4]) + key = val[2] +end if + +--get Encrypt/Decrypt flag +if length(cmd) = 5 then + flag = cmd[5] + if compare(flag, "D") = 0 then + key = 26 - key + end if +end if + +for i = 1 to length(text) do + if t_alpha(text[i]) then + if t_lower(text[i]) then + offset = 'a' + else + offset = 'A' + end if + text[i] = remainder(text[i] - offset + key, num_letters) + offset + end if +end for + +printf(1,"%s\n",{text}) diff --git a/Task/Calendar-for-real-programmers/0DESCRIPTION b/Task/Calendar-for-real-programmers/0DESCRIPTION new file mode 100644 index 0000000000..1871142ebd --- /dev/null +++ b/Task/Calendar-for-real-programmers/0DESCRIPTION @@ -0,0 +1,22 @@ +Provide an algorithm as per the [[Calendar]] task, except the entire code for the algorithm must be presented entirely without lowercase. Also - as per many 1969 era [[wp:line printer#Paper (forms) handling|line printer]]s - format the calendar to nicely fill a page that is 132 characters wide. + +(Hint: manually convert the code from the [[Calendar]] task to all UPPERCASE) + +This task also is inspired by [http://www.ee.ryerson.ca/~elf/hack/realmen.html Real Programmers Don't Use PASCAL] by Ed Post, Datamation, volume 29 number 7, July 1983. + THE REAL PROGRAMMER'S NATURAL HABITAT + "Taped to the wall is a line-printer Snoopy calender for the year 1969." + +Moreover this task is further inspired by the ''long lost'' corollary article titled: + "Real programmers think in UPPERCASE"! + +Note: Whereas today we ''only'' need to worry about [[wp:ASCII|ASCII]], [[wp:UTF-8|UTF-8]], [[wp:UTF-16/UCS-2|UTF-16]], [[wp:UTF-32/UCS-4|UTF-32]], [[wp:UTF-7|UTF-7]] and [[wp:UTF-EBCDIC|UTF-EBCDIC]] encodings, in the 1960s having code in UPPERCASE was often mandatory as characters were often stuffed into [[wp:36-bit|36-bit]] words as 6 lots of [[wp:6-bit|6-bit]] characters. More extreme words sizes include [[wp:60-bit|60-bit]] words of the [[wp:CDC 6000 series|CDC 6000 series]] computers. The Soviets even had a national character set that was inclusive of all +[[wp:GOST_10859#4-bit code: Binary coded decimal|4-bit]], +[[wp:GOST_10859#5-bit code: with BCD & mathematical operators|5-bit]], +[[wp:GOST_10859#6-bit code: with only Cyrillic upper case letters|6-bit]] & +[[wp:GOST_10859#7-bit code: Cyrillic & Latin upper case letters|7-bit]] depending on how the file was opened... '''And''' one rogue Soviet university went further and built a [http://www.computer-museum.ru/english/setun.htm 1.5-bit] based computer. + +Of course... as us [[wp:Baby-Boom Generation|Boomers]] have turned into [[wp:Geezer|Geezer]]s we have become [[wp:All_caps#Computing|HARD OF HEARING]], and suffer from chronic [[wp:Presbyopia|Presbyopia]], hence programming in UPPERCASE is less to do with computer architecture and more to do with practically. :-) + +For economy of size, do not actually include Snoopy generation in either the code or the output, instead just output a place-holder. + +FYI: a nice ASCII art file of Snoopy can be found at [http://www.textfiles.com/artscene/asciiart/cursepic.art textfiles.com]. Save with a .txt extension. diff --git a/Task/Calendar-for-real-programmers/1META.yaml b/Task/Calendar-for-real-programmers/1META.yaml new file mode 100644 index 0000000000..0b8885a678 --- /dev/null +++ b/Task/Calendar-for-real-programmers/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Date and time diff --git a/Task/Calendar-for-real-programmers/ALGOL-68/calendar-for-real-programmers.alg b/Task/Calendar-for-real-programmers/ALGOL-68/calendar-for-real-programmers.alg new file mode 100644 index 0000000000..e3dbc47b23 --- /dev/null +++ b/Task/Calendar-for-real-programmers/ALGOL-68/calendar-for-real-programmers.alg @@ -0,0 +1,108 @@ +'PR' QUOTE 'PR' + +'PROC' PRINT CALENDAR = ('INT' YEAR, PAGE WIDTH)'VOID': 'BEGIN' + + ()'STRING' MONTH NAMES = ( + "JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE", + "JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"), + WEEKDAY NAMES = ("SU","MO","TU","WE","TH","FR","SA"); + 'FORMAT' WEEKDAY FMT = $G,N('UPB' WEEKDAY NAMES - 'LWB' WEEKDAY NAMES)(" "G)$; + + # 'JUGGLE' THE CALENDAR FORMAT TO FIT THE PRINTER/SCREEN WIDTH # + 'INT' DAY WIDTH = 'UPB' WEEKDAY NAMES(1), DAY GAP=1; + 'INT' MONTH WIDTH = (DAY WIDTH+DAY GAP) * 'UPB' WEEKDAY NAMES-1; + 'INT' MONTH HEADING LINES = 2; + 'INT' MONTH LINES = (31 'OVER' 'UPB' WEEKDAY NAMES+MONTH HEADING LINES+2); # +2 FOR HEAD/TAIL WEEKS # + 'INT' YEAR COLS = (PAGE WIDTH+1) 'OVER' (MONTH WIDTH+1); + 'INT' YEAR ROWS = ('UPB' MONTH NAMES-1)'OVER' YEAR COLS + 1; + 'INT' MONTH GAP = (PAGE WIDTH - YEAR COLS*MONTH WIDTH + 1)'OVER' YEAR COLS; + 'INT' YEAR WIDTH = YEAR COLS*(MONTH WIDTH+MONTH GAP)-MONTH GAP; + 'INT' YEAR LINES = YEAR ROWS*MONTH LINES; + + 'MODE' 'MONTHBOX' = (MONTH LINES, MONTH WIDTH)'CHAR'; + 'MODE' 'YEARBOX' = (YEAR LINES, YEAR WIDTH)'CHAR'; + + 'INT' WEEK START = 1; # 'SUNDAY' # + + 'PROC' DAYS IN MONTH = ('INT' YEAR, MONTH)'INT': + 'CASE' MONTH 'IN' 31, + 'IF' YEAR 'MOD' 4 'EQ' 0 'AND' YEAR 'MOD' 100 'NE' 0 'OR' YEAR 'MOD' 400 'EQ' 0 'THEN' 29 'ELSE' 28 'FI', + 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 + 'ESAC'; + + 'PROC' DAY OF WEEK = ('INT' YEAR, MONTH, DAY)'INT': 'BEGIN' + # 'DAY' OF THE WEEK BY 'ZELLER'’S 'CONGRUENCE' ALGORITHM FROM 1887 # + 'INT' Y := YEAR, M := MONTH, D := DAY, C; + 'IF' M <= 2 'THEN' M +:= 12; Y -:= 1 'FI'; + C := Y 'OVER' 100; + Y 'MODAB' 100; + (D - 1 + ((M + 1) * 26) 'OVER' 10 + Y + Y 'OVER' 4 + C 'OVER' 4 - 2 * C) 'MOD' 7 + 'END'; + + 'MODE' 'SIMPLEOUT' = 'UNION'('STRING', ()'STRING', 'INT'); + + 'PROC' CPUTF = ('REF'()'CHAR' OUT, 'FORMAT' FMT, 'SIMPLEOUT' ARGV)'VOID':'BEGIN' + 'FILE' F; 'STRING' S; ASSOCIATE(F,S); + PUTF(F, (FMT, ARGV)); + OUT(:'UPB' S):=S; + CLOSE(F) + 'END'; + + 'PROC' MONTH REPR = ('INT' YEAR, MONTH)'MONTHBOX':'BEGIN' + 'MONTHBOX' MONTH BOX; 'FOR' LINE 'TO' 'UPB' MONTH BOX 'DO' MONTH BOX(LINE,):=" "* 2 'UPB' MONTH BOX 'OD'; + 'STRING' MONTH NAME = MONTH NAMES(MONTH); + + # CENTER THE TITLE # + CPUTF(MONTH BOX(1,(MONTH WIDTH - 'UPB' MONTH NAME ) 'OVER' 2+1:), $G$, MONTH NAME); + CPUTF(MONTH BOX(2,), WEEKDAY FMT, WEEKDAY NAMES); + + 'INT' FIRST DAY := DAY OF WEEK(YEAR, MONTH, 1); + 'FOR' DAY 'TO' DAYS IN MONTH(YEAR, MONTH) 'DO' + 'INT' LINE = (DAY+FIRST DAY-WEEK START) 'OVER' 'UPB' WEEKDAY NAMES + MONTH HEADING LINES + 1; + 'INT' CHAR =((DAY+FIRST DAY-WEEK START) 'MOD' 'UPB' WEEKDAY NAMES)*(DAY WIDTH+DAY GAP) + 1; + CPUTF(MONTH BOX(LINE,CHAR:CHAR+DAY WIDTH-1),$G(-DAY WIDTH)$, DAY) + 'OD'; + MONTH BOX + 'END'; + + 'PROC' YEAR REPR = ('INT' YEAR)'YEARBOX':'BEGIN' + 'YEARBOX' YEAR BOX; + 'FOR' LINE 'TO' 'UPB' YEAR BOX 'DO' YEAR BOX(LINE,):=" "* 2 'UPB' YEAR BOX 'OD'; + 'FOR' MONTH ROW 'FROM' 0 'TO' YEAR ROWS-1 'DO' + 'FOR' MONTH COL 'FROM' 0 'TO' YEAR COLS-1 'DO' + 'INT' MONTH = MONTH ROW * YEAR COLS + MONTH COL + 1; + 'IF' MONTH > 'UPB' MONTH NAMES 'THEN' + DONE + 'ELSE' + 'INT' MONTH COL WIDTH = MONTH WIDTH+MONTH GAP; + YEAR BOX( + MONTH ROW*MONTH LINES+1 : (MONTH ROW+1)*MONTH LINES, + MONTH COL*MONTH COL WIDTH+1 : (MONTH COL+1)*MONTH COL WIDTH-MONTH GAP + ) := MONTH REPR(YEAR, MONTH) + 'FI' + 'OD' + 'OD'; + DONE: YEAR BOX + 'END'; + + 'INT' CENTER = (YEAR COLS*(MONTH WIDTH+MONTH GAP) - MONTH GAP - 1) 'OVER' 2; + 'INT' INDENT = (PAGE WIDTH - YEAR WIDTH) 'OVER' 2; + + PRINTF(( + $N(INDENT + CENTER - 9)K G L$, "(INSERT SNOOPY HERE)", + $N(INDENT + CENTER - 1)K 4D L$, YEAR, $L$, + $N(INDENT)K N(YEAR WIDTH)(G) L$, YEAR REPR(YEAR) + )) +'END'; + +MAIN: 'BEGIN' +'CO' INSPIRED BY HTTP://WWW.EE.RYERSON.CA/~ELF/hack/realmen.html + REAL PROGRAMMERS DONT USE PASCAL - ED POST + DATAMATION, VOLUME 29 NUMBER 7, JULY 1983 + THE REAL PROGRAMMERS NATURAL HABITAT +"TAPED TO THE WALL IS A LINE-PRINTER SNOOPY CALENDER FOR THE YEAR 1969" +'CO' + 'INT' MANKIND STEPPED ON THE MOON = 1969, + LINE PRINTER WIDTH = 132; # AS AT 1969! # + PRINT CALENDAR(MANKIND STEPPED ON THE MOON, LINE PRINTER WIDTH) +'END' diff --git a/Task/Calendar-for-real-programmers/Ada/calendar-for-real-programmers.ada b/Task/Calendar-for-real-programmers/Ada/calendar-for-real-programmers.ada new file mode 100644 index 0000000000..5fc5d7f293 --- /dev/null +++ b/Task/Calendar-for-real-programmers/Ada/calendar-for-real-programmers.ada @@ -0,0 +1,21 @@ +WITH PRINTABLE_CALENDAR; + +PROCEDURE REAL_CAL IS + + C: PRINTABLE_CALENDAR.CALENDAR := PRINTABLE_CALENDAR.INIT_132 + ((WEEKDAY_REP => + "MO TU WE TH FR SA SO", + MONTH_REP => + (" JANUARY ", " FEBRUARY ", + " MARCH ", " APRIL ", + " MAY ", " JUNE ", + " JULY ", " AUGUST ", + " SEPTEMBER ", " OCTOBER ", + " NOVEMBER ", " DECEMBER ") + )); + +BEGIN + C.PRINT_LINE_CENTERED("[SNOOPY]"); + C.NEW_LINE; + C.PRINT(1969, "NINETEEN-SIXTY-NINE"); +END REAL_CAL; diff --git a/Task/Calendar-for-real-programmers/BBC-BASIC/calendar-for-real-programmers.bbc b/Task/Calendar-for-real-programmers/BBC-BASIC/calendar-for-real-programmers.bbc new file mode 100644 index 0000000000..d3e15ee140 --- /dev/null +++ b/Task/Calendar-for-real-programmers/BBC-BASIC/calendar-for-real-programmers.bbc @@ -0,0 +1,47 @@ + VDU 23,22,1056;336;8,16,16,128 + + YEAR = 1969 + PRINT TAB(62) "[SNOOPY]" TAB(64); YEAR + DIM DOM(5), MJD(5), DM(5), MONTH$(11) + DAYS$ = "SU MO TU WE TH FR SA" + MONTH$() = "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", \ + \ "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER" + + FOR MONTH = 1 TO 7 STEP 6 + PRINT + FOR COL = 0 TO 5 + MJD(COL) = FNMJD(1, MONTH + COL, YEAR) + MONTH$ = MONTH$(MONTH + COL - 1) + PRINT TAB(COL*22 + 11 - LEN(MONTH$)/2) MONTH$; + NEXT + FOR COL = 0 TO 5 + PRINT TAB(COL*22 + 1) DAYS$; + DM(COL) = FNDIM(MONTH + COL, YEAR) + NEXT + DOM() = 1 + COL = 0 + REPEAT + DOW = FNDOW(MJD(COL)) + IF DOM(COL)<=DM(COL) THEN + PRINT TAB(COL*22 + DOW*3 + 1); DOM(COL); + DOM(COL) += 1 + MJD(COL) += 1 + ENDIF + IF DOW=6 OR DOM(COL)>DM(COL) COL = (COL + 1) MOD 6 + UNTIL DOM(0)>DM(0) AND DOM(1)>DM(1) AND DOM(2)>DM(2) AND \ + \ DOM(3)>DM(3) AND DOM(4)>DM(4) AND DOM(5)>DM(5) + PRINT + NEXT + END + + DEF FNMJD(D%,M%,Y%) : M% -= 3 : IF M% < 0 M% += 12 : Y% -= 1 + = D% + (153*M%+2)DIV5 + Y%*365 + Y%DIV4 - Y%DIV100 + Y%DIV400 - 678882 + + DEF FNDOW(J%) = (J%+2400002) MOD 7 + + DEF FNDIM(M%,Y%) + CASE M% OF + WHEN 2: = 28 - (Y%MOD4=0) + (Y%MOD100=0) - (Y%MOD400=0) + WHEN 4,6,9,11: = 30 + OTHERWISE = 31 + ENDCASE diff --git a/Task/Calendar-for-real-programmers/PHP/calendar-for-real-programmers.php b/Task/Calendar-for-real-programmers/PHP/calendar-for-real-programmers.php new file mode 100644 index 0000000000..4df621773a --- /dev/null +++ b/Task/Calendar-for-real-programmers/PHP/calendar-for-real-programmers.php @@ -0,0 +1,20 @@ + $DAYS[$M] ? " " : SPRINTF "%2D", $_ } + MAP { $_ - $START_DOW[$M] + 1 } + $R * 7 .. $R * 7 + 6; + } +} + +SUB P { WARN $_[0], "\\N" } +P UC " [INSERT SNOOPY HERE]"; +P " 1969"; +P ""; +FOREACH (UC(" JANUARY FEBRUARY MARCH APRIL MAY JUNE"), + UC(" JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER")) { + P $_; + MY @MS = SPLICE @MONTHS, 0, 6; + P JOIN " ", ((UC "SU MO TU WE TH FR SA") X 6); + P JOIN " ", MAP { SHIFT @$_ } @MS FOREACH 0 .. 5; +} + +\''; + +# LOWERCASE LETTERS +$E = '%' | '@'; +$C = '#' | '@'; +$H = '(' | '@'; +$O = '/' | '@'; +$T = '4' | '@'; +$R = '2' | '@'; +$A = '!' | '@'; +$Z = ':' | '@'; +$P = '0' | '@'; +$L = ',' | '@'; + +`${E}${C}${H}${O} $PROGRAM | ${T}${R} A-Z ${A}-${Z} | ${P}${E}${R}${L}`; diff --git a/Task/Calendar-for-real-programmers/Perl/calendar-for-real-programmers-2.pl b/Task/Calendar-for-real-programmers/Perl/calendar-for-real-programmers-2.pl new file mode 100644 index 0000000000..470c30e4e0 --- /dev/null +++ b/Task/Calendar-for-real-programmers/Perl/calendar-for-real-programmers-2.pl @@ -0,0 +1 @@ +$_=$ARGV[0]//1969;`\143\141\154 $_ >&2` diff --git a/Task/Calendar-for-real-programmers/PicoLisp/calendar-for-real-programmers.l b/Task/Calendar-for-real-programmers/PicoLisp/calendar-for-real-programmers.l new file mode 100644 index 0000000000..10df769426 --- /dev/null +++ b/Task/Calendar-for-real-programmers/PicoLisp/calendar-for-real-programmers.l @@ -0,0 +1,14 @@ +(DE CAL (YEAR) + (PRINL "====== " YEAR " ======") + (FOR DAT (RANGE (DATE YEAR 1 1) (DATE YEAR 12 31)) + (LET D (DATE DAT) + (TAB (3 3 4 8) + (WHEN (= 1 (CADDR D)) + (GET `(INTERN (PACK (MAPCAR CHAR (42 77 111 110)))) (CADR D)) ) + (CADDR D) + (DAY DAT `(INTERN (PACK (MAPCAR CHAR (42 68 97 121))))) + (WHEN (=0 (% (INC DAT) 7)) + (PACK (CHAR 87) "EEk " (WEEK DAT)) ) ) ) ) ) + +(CAL 1969) +(BYE) diff --git a/Task/Calendar-for-real-programmers/REXX/calendar-for-real-programmers.rexx b/Task/Calendar-for-real-programmers/REXX/calendar-for-real-programmers.rexx new file mode 100644 index 0000000000..176d0ebeaa --- /dev/null +++ b/Task/Calendar-for-real-programmers/REXX/calendar-for-real-programmers.rexx @@ -0,0 +1,170 @@ +/*REXX PROGRAM TO SHOW ANY YEAR'S (MONTHLY) CALENDAR (WITH/WITHOUT GRID)*/ +@ABC= +DO J=0 TO 255;_=D2C(J);IF DATATYPE(_,'L') THEN @ABC=@ABC||_;END +@ABCU=@ABC; UPPER @ABCU +DAYS_='SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY' +MONTHS_='JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER' +DAYS=; MONTHS= + DO J=1 FOR 7 + _=LOWER(WORD(DAYS_,J)) + DAYS=DAYS TRANSLATE(LEFT(_,1))SUBSTR(_,2) + END + DO J=1 FOR 12 + _=LOWER(WORD(MONTHS_,J)) + MONTHS=MONTHS TRANSLATE(LEFT(_,1))SUBSTR(_,2) + END +CALFILL=' '; MC=12; _='1 3 1234567890' "FB"X +PARSE VAR _ GRID CALSPACES # CHK . CV_ DAYS.1 DAYS.2 DAYS.3 DAYSN SD SW +_=0; PARSE VAR _ COLS 1 JD 1 LOWERCASE 1 MAXKALPUTS 1 NARROW 1, + NARROWER 1 NARROWEST 1 SHORT 1 SHORTER 1 SHORTEST 1, + SMALL 1 SMALLER 1 SMALLEST 1 UPPERCASE +PARSE ARG MM '/' DD "/" YYYY _ '(' OPS; UOPS=OPS +IF _\=='' | \IS#(MM) | \IS#(DD) | \IS#(YYYY) THEN CALL ERX 86 + +@CALMONTHS ='CALMON' || LOWER('THS') +@CALSPACES ='CALSP' || LOWER('ACES') +@DEPTH ='DEP' || LOWER('TH') +@GRIDS ='GRID' || LOWER('S') +@LOWERCASE ='LOW' || LOWER('ERCASE') +@NARROW ='NAR' || LOWER('ROW') +@NARROWER ='NARROWER' +@NARROWEST ='NARROWES' || LOWER('T') +@SHORT ='SHOR' || LOWER('T') +@SHORTER ='SHORTER' +@SHORTEST ='SHORTES' || LOWER('T') +@UPPERCASE ='UPP' || LOWER('ERCASE') +@WIDTH ='WID' || LOWER('TH') + DO WHILE OPS\==''; OPS=STRIP(OPS,'L'); PARSE VAR OPS _1 2 1 _ . 1 _O OPS + UPPER _ + SELECT + WHEN ABB(@CALMONTHS) THEN MC=NAI() + WHEN ABB(@CALSPACES) THEN CALSPACES=NAI() + WHEN ABB(@DEPTH) THEN SD=NAI() + WHEN ABBN(@GRIDS) THEN GRID=NO() + WHEN ABBN(@LOWERCASE) THEN LOWERCASE=NO() + WHEN ABBN(@NARROW) THEN NARROW=NO() + WHEN ABBN(@NARROWER) THEN NARROWER=NO() + WHEN ABBN(@NARROWEST) THEN NARROWEST=NO() + WHEN ABBN(@SHORT) THEN SHORT=NO() + WHEN ABBN(@SHORTER) THEN SHORTER=NO() + WHEN ABBN(@SHORTEST) THEN SHORTEST=NO() + WHEN ABBN(@SMALL) THEN SMALL=NO() + WHEN ABBN(@SMALLER) THEN SMALLER=NO() + WHEN ABBN(@SMALLEST) THEN SMALLEST=NO() + WHEN ABBN(@UPPERCASE) THEN UPPERCASE=NO() + WHEN ABB(@WIDTH) THEN SW=NAI() + OTHERWISE NOP + END /*SELECT*/ + END /*DO WHILE OPTS\== ...*/ + +MC=INT(MC,'MONTHSCALENDER'); IF MC>0 THEN CAL=1 +DAYS=' 'DAYS; MONTHS=' 'MONTHS +CYYYY=RIGHT(DATE(),4); HYY=LEFT(CYYYY,2); LYY=RIGHT(CYYYY,2) +DY.=31; _=30; PARSE VAR _ DY.4 1 DY.6 1 DY.9 1 DY.11; DY.2=28+LY(YYYY) +YY=RIGHT(YYYY,2); SD=P(SD 43); SW=P(SW 80); CW=10; CINDENT=1; CALWIDTH=76 +IF SMALL THEN DO; NARROW=1 ; SHORT=1 ; END +IF SMALLER THEN DO; NARROWER=1 ; SHORTER=1 ; END +IF SMALLEST THEN DO; NARROWEST=1; SHORTEST=1; END +IF SHORTEST THEN SHORTER=1 +IF SHORTER THEN SHORT =1 +IF NARROW THEN DO; CW=9; CINDENT=3; CALWIDTH=69; END +IF NARROWER THEN DO; CW=4; CINDENT=1; CALWIDTH=34; END +IF NARROWEST THEN DO; CW=2; CINDENT=1; CALWIDTH=20; END +CV_=CALWIDTH+CALSPACES+2 +CALFILL=LEFT(COPIES(CALFILL,CW),CW) + DO J=1 FOR 7; _=WORD(DAYS,J) + DO JW=1 FOR 3; _D=STRIP(SUBSTR(_,CW*JW-CW+1,CW)) + IF JW=1 THEN _D=CENTRE(_D,CW+1) + ELSE _D=LEFT(_D,CW+1) + DAYS.JW=DAYS.JW||_D + END /*JW*/ + __=DAYSN + IF NARROWER THEN DAYSN=__||CENTRE(LEFT(_,3),5) + IF NARROWEST THEN DAYSN=__||CENTER(LEFT(_,2),3) + END /*J*/ +_YYYY=YYYY; CALPUTS=0; CV=1; _MM=MM+0; MONTH=WORD(MONTHS,MM) +DY.2=28+LY(_YYYY); DIM=DY._MM; _DD=01; DOW=DOW(_MM,_DD,_YYYY); $DD=DD+0 + +/*─────────────────────────────NOW: THE BUSINESS OF THE BUILDING THE CAL*/ +CALL CALGEN + DO _J=2 TO MC + IF CV_\=='' THEN DO + CV=CV+CV_ + IF CV+CV_>=SW THEN DO; CV=1; CALL CALPUT + CALL FCALPUTS;CALL CALPB + END + ELSE CALPUTS=0 + END + ELSE DO;CALL CALPB;CALL CALPUT;CALL FCALPUTS;END + _MM=_MM+1; IF _MM==13 THEN DO; _MM=1; _YYYY=_YYYY+1; END + MONTH=WORD(MONTHS,_MM); DY.2=28+LY(_YYYY); DIM=DY._MM + DOW=DOW(_MM,_DD,_YYYY); $DD=0; CALL CALGEN + END /*_J*/ +CALL FCALPUTS +RETURN _ + +/*─────────────────────────────CALGEN SUBROUTINE────────────────────────*/ +CALGEN: CELLX=;CELLJ=;CELLM=;CALCELLS=0;CALLINE=0 +CALL CALPUT +CALL CALPUTL COPIES('─',CALWIDTH),"┌┐"; CALL CALHD +CALL CALPUTL MONTH ' ' _YYYY ; CALL CALHD +IF NARROWEST | NARROWER THEN CALL CALPUTL DAYSN + ELSE DO JW=1 FOR 3 + IF SPACE(DAYS.JW)\=='' THEN CALL CALPUTL DAYS.JW + END +CALFT=1; CALFB=0 + DO JF=1 FOR DOW-1; CALL CELLDRAW CALFILL,CALFILL; END + DO JY=1 FOR DIM; CALL CELLDRAW JY; END +CALFB=1 + DO 7; CALL CELLDRAW CALFILL,CALFILL; END +IF SD>32 & \SHORTER THEN CALL CALPUT +RETURN + +/*─────────────────────────────CELLDRAW SUBROUTINE──────────────────────*/ +CELLDRAW: PARSE ARG ZZ,CDDOY;ZZ=RIGHT(ZZ,2);CALCELLS=CALCELLS+1 +IF CALCELLS>7 THEN DO + CALLINE=CALLINE+1 + CELLX=SUBSTR(CELLX,2) + CELLJ=SUBSTR(CELLJ,2) + CELLM=SUBSTR(CELLM,2) + CELLB=TRANSLATE(CELLX,,")(─-"#) + IF CALLINE==1 THEN CALL CX + CALL CALCSM; CALL CALPUTL CELLX; CALL CALCSJ; CALL CX + CELLX=; CELLJ=; CELLM=; CALCELLS=1 + END +CDDOY=RIGHT(CDDOY,CW); CELLM=CELLM'│'CENTER('',CW) +CELLX=CELLX'│'CENTRE(ZZ,CW); CELLJ=CELLJ'│'CENTER('',CW) +RETURN + +/*═════════════════════════════GENERAL 1-LINE SUBS══════════════════════*/ +ABB:ARG ABBU;PARSE ARG ABB;RETURN ABBREV(ABBU,_,ABBL(ABB)) +ABBL:RETURN VERIFY(ARG(1)LEFT(@ABC,1),@ABC,'M')-1 +ABBN:PARSE ARG ABBN;RETURN ABB(ABBN)|ABB('NO'ABBN) +CALCSJ:IF SD>49&\SHORTER THEN CALL CALPUTL CELLB;IF SD>24&\SHORT THEN CALL CALPUTL CELLJ; RETURN +CALCSM:IF SD>24&\SHORT THEN CALL CALPUTL CELLM;IF SD>49&\SHORTER THEN CALL CALPUTL CELLB;RETURN +CALHD:IF SD>24&\SHORTER THEN CALL CALPUTL;IF SD>32&\SHORTEST THEN CALL CALPUTL;RETURN +CALPB:IF \GRID&SHORTEST THEN CALL PUT CHK;RETURN +CALPUT:CALPUTS=CALPUTS+1;MAXKALPUTS=MAX(MAXKALPUTS,CALPUTS);IF SYMBOL('CT.'CALPUTS)\=='VAR' THEN CT.CALPUTS=;CT.CALPUTS=OVERLAY(ARG(1),CT.CALPUTS,CV);RETURN +CALPUTL:CALL CALPUT COPIES(' ',CINDENT)LEFT(ARG(2)"│",1)CENTER(ARG(1),CALWIDTH)||RIGHT('│'ARG(2),1);RETURN +CX:CX_='├┤';CX=COPIES(COPIES('─',CW)'┼',7);IF CALFT THEN DO;CX=TRANSLATE(CX,'┬',"┼");CALFT=0;END;IF CALFB THEN DO;CX=TRANSLATE(CX,'┴',"┼");CX_='└┘';CALFB=0;END;CALL CALPUTL CX,CX_;RETURN +DOW:PROCEDURE;ARG M,D,Y;IF M<3 THEN DO;M=M+12;Y=Y-1;END;YL=LEFT(Y,2);YR=RIGHT(Y,2);W=(D+(M+1)*26%10+YR+YR%4+YL%4+5*YL)//7;IF W==0 THEN W=7;RETURN W +ER:PARSE ARG _1,_2;CALL '$ERR' "14"P(_1) P(WORD(_1,2) !FID(1)) _2;IF _1<0 THEN RETURN _1;EXIT RESULT +ERR:CALL ER '-'ARG(1),ARG(2);RETURN '' +ERX:CALL ER '-'ARG(1),ARG(2);EXIT '' +FCALPUTS: DO J=1 FOR MAXKALPUTS;CALL PUT CT.J;END;CT.=;MAXKALPUTS=0;CALPUTS=0;RETURN +INT:INT=NUMX(ARG(1),ARG(2));IF \ISINT(INT) THEN CALL ERX 92,ARG(1) ARG(2);RETURN INT/1 +IS#:RETURN VERIFY(ARG(1),#)==0 +ISINT:RETURN DATATYPE(ARG(1),'W') +LOWER:RETURN TRANSLATE(ARG(1),@ABC,@ABCU) +LY:ARG _;IF LENGTH(_)==2 THEN _=HYY||_;LY=_//4==0;IF LY==0 THEN RETURN 0;LY=((_//100\==0)|_//400==0);RETURN LY +NA:IF ARG(1)\=='' THEN CALL ERX 01,ARG(2);PARSE VAR OPS NA OPS;IF NA=='' THEN CALL ERX 35,_O;RETURN NA +NAI:RETURN INT(NA(),_O) +NAN:RETURN NUMX(NA(),_O) +NO:IF ARG(1)\=='' THEN CALL ERX 01,ARG(2);RETURN LEFT(_,2)\=='NO' +NUM:PROCEDURE;PARSE ARG X .,F,Q;IF X=='' THEN RETURN X;IF DATATYPE(X,'N') THEN RETURN X/1;X=SPACE(TRANSLATE(X,,','),0);IF DATATYPE(X,'N') THEN RETURN X/1;RETURN NUMNOT() +NUMNOT:IF Q==1 THEN RETURN X;IF Q=='' THEN CALL ER 53,X F;CALL ERX 53,X F +NUMX:RETURN NUM(ARG(1),ARG(2),1) +P:RETURN WORD(ARG(1),1) +PUT:_=ARG(1);_=TRANSLATE(_,,'_'CHK);IF \GRID THEN _=UNGRID(_);IF LOWERCASE THEN _=LOWER(_);IF UPPERCASE THEN UPPER _;IF SHORTEST&_=' ' THEN RETURN;CALL TELL _;RETURN +TELL:SAY ARG(1);RETURN +UNGRID:RETURN TRANSLATE(ARG(1),,"│║─═┤┐└┴┬├┼┘┌╔╗╚╝╟╢╞╡╫╪╤╧╥╨╠╣") diff --git a/Task/Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-1.rb b/Task/Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-1.rb new file mode 100644 index 0000000000..46b25450a4 --- /dev/null +++ b/Task/Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-1.rb @@ -0,0 +1,26 @@ +# loadup.rb - run UPPERCASE RUBY program + +class Object + alias lowercase_method_missing method_missing + + # Allow UPPERCASE method calls. + def method_missing(sym, *args, &block) + str = sym.to_s + if str == (down = str.downcase) + lowercase_method_missing sym, *args, &block + else + send down, *args, &block + end + end + + # RESCUE an exception without the 'rescue' keyword. + def RESCUE(_BEGIN, _CLASS, _RESCUE) + begin _BEGIN.CALL + rescue _CLASS + _RESCUE.CALL; end + end +end + +_PROGRAM = ARGV.SHIFT +_PROGRAM || ABORT("USAGE: #{$0} PROGRAM.RB ARGS...") +LOAD($0 = _PROGRAM) diff --git a/Task/Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-2.rb b/Task/Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-2.rb new file mode 100644 index 0000000000..36dcd44baa --- /dev/null +++ b/Task/Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-2.rb @@ -0,0 +1,84 @@ +# CAL.RB - CALENDAR +REQUIRE 'DATE'.DOWNCASE + +# FIND CLASSES. +OBJECT = [].CLASS.SUPERCLASS +DATE = OBJECT.CONST_GET('DATE'.DOWNCASE.CAPITALIZE) + +# CREATES A CALENDAR OF _YEAR_. RETURNS THIS CALENDAR AS A MULTI-LINE +# STRING FIT TO _COLUMNS_. +OBJECT.SEND(:DEFINE_METHOD, :CAL) {|_YEAR, _COLUMNS| + + # START AT JANUARY 1. + # + # DATE::ENGLAND MARKS THE SWITCH FROM JULIAN CALENDAR TO GREGORIAN + # CALENDAR AT 1752 SEPTEMBER 14. THIS REMOVES SEPTEMBER 3 TO 13 FROM + # YEAR 1752. (BY FORTUNE, IT KEEPS JANUARY 1.) + # + _DATE = DATE.NEW(_YEAR, 1, 1, DATE::ENGLAND) + + # COLLECT CALENDARS OF ALL 12 MONTHS. + _MONTHS = (1..12).COLLECT {|_MONTH| + _ROWS = [DATE::MONTHNAMES[_MONTH].UPCASE.CENTER(20), + "SU MO TU WE TH FR SA"] + + # MAKE ARRAY OF 42 DAYS, STARTING WITH SUNDAY. + _DAYS = [] + _DATE.WDAY.TIMES { _DAYS.PUSH " " } + CATCH(:BREAK) { + LOOP { + (_DATE.MONTH == _MONTH) || THROW(:BREAK) + _DAYS.PUSH("%2D".DOWNCASE % _DATE.MDAY) + _DATE += 1 }} + (42 - _DAYS.LENGTH).TIMES { _DAYS.PUSH " " } + + _DAYS.EACH_SLICE(7) {|_WEEK| _ROWS.PUSH(_WEEK.JOIN " ") } + _ROWS } + + # CALCULATE MONTHS PER ROW (MPR). + # 1. DIVIDE COLUMNS BY 22 COLUMNS PER MONTH, ROUNDED DOWN. (PRETEND + # TO HAVE 2 EXTRA COLUMNS; LAST MONTH USES ONLY 20 COLUMNS.) + # 2. DECREASE MPR IF 12 MONTHS WOULD FIT IN THE SAME MONTHS PER + # COLUMN (MPC). FOR EXAMPLE, IF WE CAN FIT 5 MPR AND 3 MPC, THEN + # WE USE 4 MPR AND 3 MPC. + _MPR = (_COLUMNS + 2).DIV 22 + _MPR = 12.DIV((12 + _MPR - 1).DIV _MPR) + + # USE 20 COLUMNS PER MONTH + 2 SPACES BETWEEN MONTHS. + _WIDTH = _MPR * 22 - 2 + + # JOIN MONTHS INTO CALENDAR. + _ROWS = ["[SNOOPY]".CENTER(_WIDTH), "#{_YEAR}".CENTER(_WIDTH)] + _MONTHS.EACH_SLICE(_MPR) {|_SLICE| + _SLICE[0].EACH_INDEX {|_I| + _ROWS.PUSH(_SLICE.MAP {|_A| _A[_I]}.JOIN " ") }} + _ROWS.JOIN("\012") } + + +(ARGV.LENGTH == 1) || ABORT("USAGE: #{$0} YEAR") + +# GUESS WIDTH OF TERMINAL. +# 1. OBEY ENVIRONMENT VARIABLE COLUMNS. +# 2. TRY TO REQUIRE 'IO/CONSOLE' FROM RUBY 1.9.3. +# 3. TRY TO RUN `TPUT CO`. +# 4. ASSUME 80 COLUMNS. +LOADERROR = OBJECT.CONST_GET('LOAD'.DOWNCASE.CAPITALIZE + + 'ERROR'.DOWNCASE.CAPITALIZE) +STANDARDERROR = OBJECT.CONST_GET('STANDARD'.DOWNCASE.CAPITALIZE + + 'ERROR'.DOWNCASE.CAPITALIZE) +_INTEGER = 'INTEGER'.DOWNCASE.CAPITALIZE +_TPUT_CO = 'TPUT CO'.DOWNCASE +_COLUMNS = RESCUE(PROC {SEND(_INTEGER, ENV["COLUMNS"] || "")}, + STANDARDERROR, + PROC { + RESCUE(PROC { + REQUIRE 'IO/CONSOLE'.DOWNCASE + IO.CONSOLE.WINSIZE[1] + }, LOADERROR, + PROC { + RESCUE(PROC { + SEND(_INTEGER, `#{_TPUT_CO}`) + }, STANDARDERROR, + PROC {80}) }) }) + +PUTS CAL(ARGV[0].TO_I, _COLUMNS) diff --git a/Task/Calendar-for-real-programmers/Tcl/calendar-for-real-programmers.tcl b/Task/Calendar-for-real-programmers/Tcl/calendar-for-real-programmers.tcl new file mode 100644 index 0000000000..da368f1bb7 --- /dev/null +++ b/Task/Calendar-for-real-programmers/Tcl/calendar-for-real-programmers.tcl @@ -0,0 +1,48 @@ +\146\157\162\145\141\143\150 42 [\151\156\146\157 \143\157\155\155\141\156\144\163] { + \145\166\141\154 " + \160\162\157\143 [\163\164\162\151\156\147 \164\157\165\160\160\145\162 $42] {\141\162\147\163} \{ + \163\145\164 \151 1 + \146\157\162\145\141\143\150 \141 \$\141\162\147\163 \{ + \151\146 \[\163\164\162\151\156\147 \155\141\164\143\150 _ \$\141\] \{\151\156\143\162 \151; \143\157\156\164\151\156\165\145\} + \151\146 \$\151%2 \{\154\141\160\160\145\156\144 \156\141\162\147\163 \[\163\164\162\151\156\147 \164\157\154\157\167\145\162 \$\141\]\} \{\154\141\160\160\145\156\144 \156\141\162\147\163 \$\141\} + \} + \165\160\154\145\166\145\154 \"$42 \$\156\141\162\147\163\" + \} + " + } + +PROC _ CPUTS {L S} { + UPVAR _ CAL CAL + APPEND _ CAL($L) $S + } +PROC _ CENTER {S LN} { + SET _ C [STRING LENGTH $S] + SET _ L [EXPR _ ($LN-$C)/2]; SET _ R [EXPR _ $LN-$L-$C] + FORMAT "%${L}S%${C}S%${R}S" _ "" $S "" + } +PROC _ CALENDAR {{YEAR 1969} {WIDTH 80}} { + ARRAY SET CAL "" + SET _ YRS [EXPR $YEAR-1584] + SET _ SDAY [EXPR (6+$YRS+(($YRS+3)/4)-(($YRS-17)/100+1)+(($YRS+383)/400))%7] + CPUTS 0 [CENTER "(SNOOPY)" [EXPR $WIDTH/25*25]]; CPUTS 1 "" + CPUTS 2 [CENTER "--- $YEAR ---" [EXPR $WIDTH/25*25]]; CPUTS 3 "" + FOR _ {SET _ NR 0} {$NR<=11} {INCR _ NR} { + SET _ LINE [EXPR ($NR/($WIDTH/25))*8+4] + SET _ NAME [LINDEX _ "JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER" $NR] + SET _ DAYS [EXPR 31-((($NR)%7)%2)-($NR==1)*(2-((($YEAR%4==0)&&($YEAR%100>0))||($YEAR%400==0)))] + CPUTS $LINE "[CENTER $NAME 20] " + CPUTS [INCR _ LINE] "MO TU WE TH FR SA SU "; INCR _ LINE + SET _ DAY [EXPR 1-$SDAY] + FOR _ {SET _ X 0} {$X<42} {INCR _ X} { + IF _ ($DAY>0)&&($DAY<=$DAYS) {CPUTS $LINE [FORMAT "%2d " $DAY]} {CPUTS $LINE " "} + IF _ (($X+1)%7)==0 {CPUTS $LINE " "; INCR _ LINE} + INCR _ DAY + } + SET _ SDAY [EXPR ($SDAY+($DAYS%7))%7] + } + FOR _ {SET _ X 0} {$X<[ARRAY SIZE _ CAL]} {INCR _ X} { + PUTS _ $CAL($X) + } + } + +CALENDAR diff --git a/Task/Calendar/D/calendar.d b/Task/Calendar/D/calendar.d new file mode 100644 index 0000000000..8647804dd7 --- /dev/null +++ b/Task/Calendar/D/calendar.d @@ -0,0 +1,41 @@ +import std.stdio, std.datetime, std.string, std.exception, std.conv; + +void printCalendar(in int year, in int cols) { + enforce(1 <= cols && cols <= 12); + + immutable rows = 12 / cols + (12 % cols != 0); + auto date = Date(year, 1, 1); + auto offs = cast(int)date.dayOfWeek(); + const monthNames = "January February March April May June " + "July August September October November December".split(" "); + + string[8][12] mons; + foreach (m; 0 .. 12) { + mons[m][0] = monthNames[m].center(21); + mons[m][1] = " Su Mo Tu We Th Fr Sa"; + immutable dim = date.daysInMonth(); + foreach (d; 1 .. 43) { + immutable day = d > offs && d <= offs + dim; + immutable str = day ? format(" %2s", d-offs) : " "; + mons[m][2 + (d - 1) / 7] ~= str; + } + offs = (offs + dim) % 7; + date.add!"months"(1); + } + + writeln("[Snoopy Picture]".center(cols * 24 + 4)); + writeln(text(year).center(cols * 24 + 4), "\n"); + foreach (r; 0 .. rows) { + auto s = new string[8]; + foreach (c; 0 .. cols) { + if (r * cols + c > 11) break; + foreach (i, line; mons[r * cols + c]) + s[i] ~= format(" %s", line); + } + writeln(s.join("\n"), "\n"); + } +} + +void main() { + printCalendar(1969, 3); +} diff --git a/Task/Call-a-foreign-language-function/0DESCRIPTION b/Task/Call-a-foreign-language-function/0DESCRIPTION new file mode 100644 index 0000000000..ead05b9dda --- /dev/null +++ b/Task/Call-a-foreign-language-function/0DESCRIPTION @@ -0,0 +1,11 @@ +Show how a [[Foreign function interface|foreign language function]] can be called from the language. + +As an example, consider calling functions defined in the [[C]] language. Create a string containing "Hello World!" of the string type typical to the language. Pass the string content to [[C]]'s strdup. The content can be copied if necessary. Get the result from strdup and print it using language means. Do not forget to free the result of strdup (allocated in the heap). + +Notes: +* It is not mandated if the [[C]] run-time library is to be loaded statically or dynamically. You are free to use either way. +* [[C++]] and [[C]] solutions can take some other language to communicate with. +* It is ''not'' mandatory to use strdup, especially if the foreign function interface being demonstrated makes that uninformative. + +See also: +* [[Use another language to call a function]] diff --git a/Task/Call-a-foreign-language-function/1META.yaml b/Task/Call-a-foreign-language-function/1META.yaml new file mode 100644 index 0000000000..f6d82c59ad --- /dev/null +++ b/Task/Call-a-foreign-language-function/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming environment operations diff --git a/Task/Call-a-foreign-language-function/Ada/call-a-foreign-language-function.ada b/Task/Call-a-foreign-language-function/Ada/call-a-foreign-language-function.ada new file mode 100644 index 0000000000..793acdfec7 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Ada/call-a-foreign-language-function.ada @@ -0,0 +1,15 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Interfaces.C; use Interfaces.C; +with Interfaces.C.Strings; use Interfaces.C.Strings; + +procedure Test_C_Interface is + function strdup (s1 : Char_Array) return Chars_Ptr; + pragma Import (C, strdup, "_strdup"); + + S1 : constant String := "Hello World!"; + S2 : Chars_Ptr; +begin + S2 := strdup (To_C (S1)); + Put_Line (Value (S2)); + Free (S2); +end Test_C_Interface; diff --git a/Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-1.aikido b/Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-1.aikido new file mode 100644 index 0000000000..3dc9bab4df --- /dev/null +++ b/Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-1.aikido @@ -0,0 +1,13 @@ +#include +extern "C" { // need C linkage + +// define the function using a macro defined in aikido.h +AIKIDO_NATIVE(strdup) { + aikido::string *s = paras[0].str; + char *p = strdup (s->c_str()); + aikido::string *result = new aikido::string(p); + free (p); + return result; +} + +} diff --git a/Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-2.aikido b/Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-2.aikido new file mode 100644 index 0000000000..3e1c00380e --- /dev/null +++ b/Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-2.aikido @@ -0,0 +1,2 @@ +native function strdup(s) +println (strdup ("Hello World!")) diff --git a/Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-3.aikido b/Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-3.aikido new file mode 100644 index 0000000000..aabd4298ed --- /dev/null +++ b/Task/Call-a-foreign-language-function/Aikido/call-a-foreign-language-function-3.aikido @@ -0,0 +1,14 @@ +native function strdup (s) // declare native +native function free(p) // also need to free the result + +var s = strdup ("hello world\n") +var p = s // this is an integer type +for (;;) { + var ch = peek (p, 1) // read a single character + if (ch == 0) { + break + } + print (cast(ch)) // print as a character + p++ +} +free (s) // done with the memory now diff --git a/Task/Call-a-foreign-language-function/AutoHotkey/call-a-foreign-language-function.ahk b/Task/Call-a-foreign-language-function/AutoHotkey/call-a-foreign-language-function.ahk new file mode 100644 index 0000000000..65e5be3e93 --- /dev/null +++ b/Task/Call-a-foreign-language-function/AutoHotkey/call-a-foreign-language-function.ahk @@ -0,0 +1,4 @@ +; Example: Calls the Windows API function "MessageBox" and report which button the user presses. + +WhichButton := DllCall("MessageBox", "int", "0", "str", "Press Yes or No", "str", "Title of box", "int", 4) +MsgBox You pressed button #%WhichButton%. diff --git a/Task/Call-a-foreign-language-function/BBC-BASIC/call-a-foreign-language-function.bbc b/Task/Call-a-foreign-language-function/BBC-BASIC/call-a-foreign-language-function.bbc new file mode 100644 index 0000000000..fba9058182 --- /dev/null +++ b/Task/Call-a-foreign-language-function/BBC-BASIC/call-a-foreign-language-function.bbc @@ -0,0 +1,7 @@ + SYS "LoadLibrary", "MSVCRT.DLL" TO msvcrt% + SYS "GetProcAddress", msvcrt%, "_strdup" TO `strdup` + SYS "GetProcAddress", msvcrt%, "free" TO `free` + + SYS `strdup`, "Hello World!" TO address% + PRINT $$address% + SYS `free`, address% diff --git a/Task/Call-a-foreign-language-function/C++/call-a-foreign-language-function-1.cpp b/Task/Call-a-foreign-language-function/C++/call-a-foreign-language-function-1.cpp new file mode 100644 index 0000000000..7061ba9c4f --- /dev/null +++ b/Task/Call-a-foreign-language-function/C++/call-a-foreign-language-function-1.cpp @@ -0,0 +1,2 @@ +FUNCTION MULTIPLY(X, Y) +DOUBLE PRECISION MULTIPLY, X, Y diff --git a/Task/Call-a-foreign-language-function/C++/call-a-foreign-language-function-2.cpp b/Task/Call-a-foreign-language-function/C++/call-a-foreign-language-function-2.cpp new file mode 100644 index 0000000000..84eb3d667d --- /dev/null +++ b/Task/Call-a-foreign-language-function/C++/call-a-foreign-language-function-2.cpp @@ -0,0 +1,42 @@ +#include // for C memory management +#include // for C++ strings +#include // for output + +// C functions must be defined extern "C" +extern "C" char* strdup1(char const*); + +// Fortran functions must also be defined extern "C" to prevent name +// mangling; in addition, all fortran names are converted to lowercase +// and get an undescore appended. Fortran takes all arguments by +// reference, which translates to pointers in C and C++ (C++ +// references generally work, too, but that may depend on the C++ +// compiler) +extern "C" double multiply_(double* x, double* y); + +// to simplify the use and reduce the probability of errors, a simple +// inline forwarder like this can be used: +inline double multiply(double x, double y) +{ + return multiply_(&x, &y); +} + +int main() +{ + std::string msg = "The product of 3 and 5 is "; + + // call to C function (note that this should not be assigned + // directly to a C++ string, because strdup1 allocates memory, and + // we would leak the memory if we wouldn't save the pointer itself + char* msg2 = strdup1(msg.c_str()); + + // C strings can be directly output to std::cout, so we don't need + // to put it back into a string to output it. + std::cout << msg2; + + // call the FORTRAN function (through the wrapper): + std::cout << multiply(3, 5) << std::endl; + + // since strdup1 allocates with malloc, it must be deallocated with + // free, not delete, nor delete[], nor operator delete + std::free(msg2); +} diff --git a/Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-1.cmake b/Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-1.cmake new file mode 100644 index 0000000000..39b99fb960 --- /dev/null +++ b/Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-1.cmake @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 2.6) +project("outer project" C) + +# Compile cmDIV. +try_compile( + compiled_div # result variable + ${CMAKE_BINARY_DIR}/div # bindir + ${CMAKE_SOURCE_DIR}/div # srcDir + div) # projectName +if(NOT compiled_div) + message(FATAL_ERROR "Failed to compile cmDIV") +endif() + +# Load cmDIV. +load_command(DIV ${CMAKE_BINARY_DIR}/div) +if(NOT CMAKE_LOADED_COMMAND_DIV) + message(FATAL_ERROR "Failed to load cmDIV") +endif() + +# Try div() command. +div(quot rem 2012 500) +message(" + 2012 / 500 = ${quot} + 2012 % 500 = ${rem} +") diff --git a/Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-2.cmake b/Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-2.cmake new file mode 100644 index 0000000000..be2093fc7b --- /dev/null +++ b/Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-2.cmake @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.6) +project(div C) + +# Find cmCPluginAPI.h +include_directories(${CMAKE_ROOT}/include) + +# Compile cmDIV from div-command.c +add_library(cmDIV MODULE div-command.c) diff --git a/Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-3.cmake b/Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-3.cmake new file mode 100644 index 0000000000..a983f85477 --- /dev/null +++ b/Task/Call-a-foreign-language-function/CMake/call-a-foreign-language-function-3.cmake @@ -0,0 +1,55 @@ +#include +#include +#include + +static cmCAPI *api; + +/* + * Respond to DIV(quotient remainder numerator denominator). + */ +static int +initial_pass(void *info, void *mf, int argc, char *argv[]) +{ + div_t answer; + int count, i, j, n[2]; + char buf[512], c; + + if (argc != 4) { + api->SetError(info, "Wrong number of arguments"); + return 0; /* failure */ + } + + /* Parse numerator and denominator. */ + for(i = 2, j = 0; i < 4; i++, j++) { + count = sscanf(argv[i], "%d%1s", &n[j], c); + if (count != 1) { + snprintf(buf, sizeof buf, + "Not an integer: %s", argv[i]); + api->SetError(info, buf); + return 0; /* failure */ + } + } + + /* Call div(). */ + if (n[1] == 0) { + api->SetError(info, "Division by zero"); + return 0; /* failure */ + } + answer = div(n[0], n[1]); + + /* Set variables to answer. */ + snprintf(buf, sizeof buf, "%d", answer.quot); + api->AddDefinition(mf, argv[0], buf); + snprintf(buf, sizeof buf, "%d", answer.rem); + api->AddDefinition(mf, argv[1], buf); + + return 1; /* success */ +} + +CM_PLUGIN_EXPORT void +DIVInit(cmLoadedCommandInfo *info) +{ + info->Name = "DIV"; + info->InitialPass = initial_pass; + api = info->CAPI; +} diff --git a/Task/Call-a-foreign-language-function/Common-Lisp/call-a-foreign-language-function.lisp b/Task/Call-a-foreign-language-function/Common-Lisp/call-a-foreign-language-function.lisp new file mode 100644 index 0000000000..1e4c1b5cb2 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Common-Lisp/call-a-foreign-language-function.lisp @@ -0,0 +1,7 @@ +CL-USER> (let* ((string "Hello World!") + (c-string (cffi:foreign-funcall "strdup" :string string :pointer))) + (unwind-protect (write-line (cffi:foreign-string-to-lisp c-string)) + (cffi:foreign-funcall "free" :pointer c-string :void)) + (values)) +Hello World! +; No value diff --git a/Task/Call-a-foreign-language-function/D/call-a-foreign-language-function.d b/Task/Call-a-foreign-language-function/D/call-a-foreign-language-function.d new file mode 100644 index 0000000000..ae8e6ddda1 --- /dev/null +++ b/Task/Call-a-foreign-language-function/D/call-a-foreign-language-function.d @@ -0,0 +1,36 @@ +import std.stdio: writeln; +import std.string: toStringz; +import std.conv: to; + +extern(C) { + char* strdup(in char* s1); + void free(void* ptr); +} + +void main() { + // We could use char* here (as in D string literals are + // null-terminated) but we want to comply with the "of the + // string type typical to the language" part. + // Note: D supports 0-values inside a string, C doesn't. + auto input = "Hello World!"; + + // Method 1 (preferred): + // toStringz converts D strings to null-terminated C strings. + char* str1 = strdup(toStringz(input)); + + // Method 2: + // D strings are not null-terminated, so we append '\0'. + // .ptr returns a pointer to the 1st element of the array, + // just as &array[0] + // This has to be done because D dynamic arrays are + // represented with: { size_t length; T* pointer; } + char* str2 = strdup((input ~ '\0').ptr); + + // We could have just used printf here, but the task asks to + // "print it using language means": + writeln("str1: ", to!string(str1)); + writeln("str2: ", to!string(str2)); + + free(str1); + free(str2); +} diff --git a/Task/Call-a-foreign-language-function/Delphi/call-a-foreign-language-function-1.delphi b/Task/Call-a-foreign-language-function/Delphi/call-a-foreign-language-function-1.delphi new file mode 100644 index 0000000000..ebe3b5d887 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Delphi/call-a-foreign-language-function-1.delphi @@ -0,0 +1 @@ +{$O myhello.obj} diff --git a/Task/Call-a-foreign-language-function/Delphi/call-a-foreign-language-function-2.delphi b/Task/Call-a-foreign-language-function/Delphi/call-a-foreign-language-function-2.delphi new file mode 100644 index 0000000000..4f0481ec95 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Delphi/call-a-foreign-language-function-2.delphi @@ -0,0 +1 @@ +procedure Hello(S: PChar); stdcall; external; diff --git a/Task/Call-a-foreign-language-function/Forth/call-a-foreign-language-function.fth b/Task/Call-a-foreign-language-function/Forth/call-a-foreign-language-function.fth new file mode 100644 index 0000000000..046b3444e9 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Forth/call-a-foreign-language-function.fth @@ -0,0 +1,23 @@ +c-library cstrings + +\c #include +c-function strdup strdup a -- a ( c-string -- duped string ) +c-function strlen strlen a -- n ( c-string -- length ) + +end-c-library + +\ convenience function (not used here) +: c-string ( addr u -- addr' ) + tuck pad swap move pad + 0 swap c! pad ; + +create test s" testing" mem, 0 c, + +test strdup value duped + +test . +test 7 type \ testing +cr +duped . \ different address +duped dup strlen type \ testing + +duped free throw \ gforth ALLOCATE and FREE map directly to C's malloc() and free() diff --git a/Task/Call-a-foreign-language-function/Go/call-a-foreign-language-function.go b/Task/Call-a-foreign-language-function/Go/call-a-foreign-language-function.go new file mode 100644 index 0000000000..d15c8d3fe6 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Go/call-a-foreign-language-function.go @@ -0,0 +1,28 @@ +package main + +// #include +// #include +import "C" +import ( + "fmt" + "unsafe" +) + +func main() { + // a go string + go1 := "hello C" + // allocate in C and convert from Go representation to C representation + c1 := C.CString(go1) + // go string can now be garbage collected + go1 = "" + // strdup, per task. this calls the function in the C library. + c2 := C.strdup(c1) + // free the source C string. again, this is free() in the C library. + C.free(unsafe.Pointer(c1)) + // create a new Go string from the C copy + go2 := C.GoString(c2) + // free the C copy + C.free(unsafe.Pointer(c2)) + // demonstrate we have string contents intact + fmt.Println(go2) +} diff --git a/Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-1.hs b/Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-1.hs new file mode 100644 index 0000000000..1021bfff3a --- /dev/null +++ b/Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-1.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Foreign (free) +import Foreign.C.String (CString, withCString, peekCString) + +-- import the strdup function itself +-- the "unsafe" means "assume this foreign function never calls back into Haskell and avoid extra bookkeeping accordingly" +foreign import ccall unsafe "string.h strdup" strdup :: CString -> IO CString + +testC = withCString "Hello World!" -- marshall the Haskell string "Hello World!" into a C string... + (\s -> -- ... and name it s + do s2 <- strdup s + s2_hs <- peekCString s2 -- marshall the C string called s2 into a Haskell string named s2_hs + putStrLn s2_hs + free s2) -- s is automatically freed by withCString once done diff --git a/Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-2.hs b/Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-2.hs new file mode 100644 index 0000000000..a71f1f2854 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-2.hs @@ -0,0 +1,18 @@ +#include +#include "icall.h" // a header routine from the Unicon sources - provides helpful type-conversion macros + +int strdup_wrapper (int argc, descriptor *argv) +{ + ArgString (1); // check that the first argument is a string + + RetString (strdup (StringVal(argv[1]))); // call strdup, convert and return result +} + +// and strcat, for a result that does not equal the input +int strcat_wrapper (int argc, descriptor *argv) +{ + ArgString (1); + ArgString (2); + char * result = strcat (StringVal(argv[1]), StringVal(argv[2])); + RetString (result); +} diff --git a/Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-3.hs b/Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-3.hs new file mode 100644 index 0000000000..32cf97f767 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Haskell/call-a-foreign-language-function-3.hs @@ -0,0 +1,23 @@ +$define LIB "libstrdup-wrapper.so" + +# the unicon wrapper to access the C function +procedure strdup (str) + static f + initial { + f := loadfunc (LIB, "strdup_wrapper") // pick out the wrapped function from the shared library + } + return f(str) // call the wrapped function +end + +procedure strcat (str1, str2) + static f + initial { + f := loadfunc (LIB, "strcat_wrapper") + } + return f(str1, str2) +end + +procedure main () + write (strdup ("abc")) + write (strcat ("abc", "def")) +end diff --git a/Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-1.java b/Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-1.java new file mode 100644 index 0000000000..c9f66d637e --- /dev/null +++ b/Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-1.java @@ -0,0 +1,12 @@ +public class JNIDemo +{ + static + { System.loadLibrary("JNIDemo"); } + + public static void main(String[] args) + { + System.out.println(callStrdup("Hello World!")); + } + + private static native String callStrdup(String s); +} diff --git a/Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-2.java b/Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-2.java new file mode 100644 index 0000000000..3b575db0e5 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-2.java @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class JNIDemo */ + +#ifndef _Included_JNIDemo +#define _Included_JNIDemo +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: JNIDemo + * Method: callStrdup + * Signature: (Ljava/lang/String;)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_JNIDemo_callStrdup + (JNIEnv *, jclass, jstring); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-3.java b/Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-3.java new file mode 100644 index 0000000000..c12f0a5f42 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Java/call-a-foreign-language-function-3.java @@ -0,0 +1,43 @@ +#include "string.h" +#include "JNIDemo.h" + +void throwByName(JNIEnv* env, const char* className, const char* msg) +{ + jclass exceptionClass = (*env)->FindClass(env, className); + if (exceptionClass != NULL) + { + (*env)->ThrowNew(env, exceptionClass, msg); + (*env)->DeleteLocalRef(env, exceptionClass); + } + return; +} + +JNIEXPORT jstring JNICALL Java_JNIDemo_callStrdup(JNIEnv *env, jclass cls, jstring s) +{ + const jbyte* utf8String; + char* dupe; + jstring dupeString; + + if (s == NULL) + { + throwByName(env, "java/lang/NullPointerException", "String is null"); + return NULL; + } + + // Convert from UTF-16 to UTF-8 (C-style) + utf8String = (*env)->GetStringUTFChars(env, s, NULL); + + // Duplicate + dupe = strdup(utf8String); + + // Free the UTF-8 string back to the JVM + (*env)->ReleaseStringUTFChars(env, s, utf8String); + + // Convert the duplicate string from strdup to a Java String + dupeString = (*env)->NewStringUTF(env, dupe); + + // Free the duplicate c-string back to the C runtime heap + free(dupe); + + return dupeString; +} diff --git a/Task/Call-a-foreign-language-function/Perl/call-a-foreign-language-function-1.pl b/Task/Call-a-foreign-language-function/Perl/call-a-foreign-language-function-1.pl new file mode 100644 index 0000000000..83771ce1d1 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Perl/call-a-foreign-language-function-1.pl @@ -0,0 +1,11 @@ +use Inline C => q{ + char *copy; + char * c_dup(char *orig) { + return copy = strdup(orig); + } + void c_free() { + free(copy); + } +}; +print c_dup('Hello'), "\n"; +c_free(); diff --git a/Task/Call-a-foreign-language-function/Perl/call-a-foreign-language-function-2.pl b/Task/Call-a-foreign-language-function/Perl/call-a-foreign-language-function-2.pl new file mode 100644 index 0000000000..0bd907e642 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Perl/call-a-foreign-language-function-2.pl @@ -0,0 +1,8 @@ +use Inline C => q{ + void c_hello (char *text) { + char *copy = strdup(text); + printf("Hello, %s!\n", copy); + free(copy); + } +}; +c_hello 'world'; diff --git a/Task/Call-a-foreign-language-function/PicoLisp/call-a-foreign-language-function-1.l b/Task/Call-a-foreign-language-function/PicoLisp/call-a-foreign-language-function-1.l new file mode 100644 index 0000000000..db4359b564 --- /dev/null +++ b/Task/Call-a-foreign-language-function/PicoLisp/call-a-foreign-language-function-1.l @@ -0,0 +1,19 @@ +(load "@lib/gcc.l") + +(gcc "str" NIL # The 'gcc' function passes all text + 'duptest ) # until /**/ to the C compiler + +any duptest(any ex) { + any x = evSym(cdr(ex)); // Accept a symbol (string) + char str[bufSize(x)]; // Create a buffer to unpack the name + char *s; + + bufString(x, str); // Upack the string + s = strdup(str); // Make a duplicate + x = mkStr(s); // Build a new Lisp string + free(s); // Dispose the duplicate + return x; +} +/**/ + +(println 'Duplicate (duptest "Hello world!")) diff --git a/Task/Call-a-foreign-language-function/PicoLisp/call-a-foreign-language-function-2.l b/Task/Call-a-foreign-language-function/PicoLisp/call-a-foreign-language-function-2.l new file mode 100644 index 0000000000..1645d11d24 --- /dev/null +++ b/Task/Call-a-foreign-language-function/PicoLisp/call-a-foreign-language-function-2.l @@ -0,0 +1,17 @@ +(load "@lib/native.l") + +(gcc "str" NIL + (duptest (Str) duptest 'S Str) ) + +#include +#include + +char *duptest(char *str) { + static char *s; + + free(s); // We simply dispose the result of the last call + return s = strdup(str); +} +/**/ + +(println 'Duplicate (duptest "Hello world!")) diff --git a/Task/Call-a-foreign-language-function/Python/call-a-foreign-language-function.py b/Task/Call-a-foreign-language-function/Python/call-a-foreign-language-function.py new file mode 100644 index 0000000000..fbff0fd6a3 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Python/call-a-foreign-language-function.py @@ -0,0 +1,4 @@ +import ctypes +libc = ctypes.CDLL("/lib/libc.so.6") +libc.strcmp("abc", "def") # -1 +libc.strcmp("hello", "hello") # 0 diff --git a/Task/Call-a-foreign-language-function/Racket/call-a-foreign-language-function.rkt b/Task/Call-a-foreign-language-function/Racket/call-a-foreign-language-function.rkt new file mode 100644 index 0000000000..30eb717c78 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Racket/call-a-foreign-language-function.rkt @@ -0,0 +1,41 @@ +#lang racket/base +(require ffi/unsafe) + +(provide strdup) + +;; Helper: create a Racket string from a C string pointer. +(define make-byte-string + (get-ffi-obj "scheme_make_byte_string" #f (_fun _pointer -> _scheme))) + +;; Take special care not to allow NULL (#f) to be passed as an input, +;; as that will crash strdup. +(define _string/no-null + (make-ctype _pointer + (lambda (x) + (unless (string? x) + (raise-argument-error '_string/no-null "string" x)) + (string->bytes/utf-8 x)) + ;; We don't use _string/no-null as an output type, so don't care: + (lambda (x) x))) + +; Make a Scheme string from the C string, and free immediately. +(define _string/free + (make-ctype _pointer + ;; We don't use this as an input type, so we don't care. + (lambda (x) x) + (lambda (x) + (cond + [x + (define s (bytes->string/utf-8 (make-byte-string x))) + (free x) + s] + [else + ;; We should never get null from strdup unless we're out of + ;; memory: + (error 'string/free "Out of memory")])))) + +(define strdup + (get-ffi-obj "strdup" #f (_fun _string/no-null -> _string/free))) + +;; Let's try it: +(strdup "Hello World!") diff --git a/Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-1.rb b/Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-1.rb new file mode 100644 index 0000000000..2f9d31de36 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-1.rb @@ -0,0 +1,14 @@ +require 'ffi' + +module LibC + extend FFI::Library + ffi_lib FFI::Platform::LIBC + + attach_function :strdup, [:string], :pointer + attach_function :free, [:pointer], :void +end + +string = "Hello, World!" +duplicate = LibC.strdup(string) +puts duplicate.get_string(0) +LibC.free(duplicate) diff --git a/Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-2.rb b/Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-2.rb new file mode 100644 index 0000000000..945e85b822 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-2.rb @@ -0,0 +1,19 @@ +require 'dl' +require 'fiddle' + +# Declare strdup(). +# * DL::Handle['strdup'] is the address of the function. +# * The function takes a pointer and returns a pointer. +strdup = Fiddle::Function.new(DL::Handle['strdup'], + [DL::TYPE_VOIDP], DL::TYPE_VOIDP) + +# Call strdup(). +# * Fiddle converts our Ruby string to a C string. +# * Fiddle returns a DL::CPtr. +duplicate = strdup.call("This is a string!") + +# DL::CPtr#to_s converts our C string to a Ruby string. +puts duplicate.to_s + +# We must call free(), because strdup() allocated memory. +DL.free duplicate diff --git a/Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-3.rb b/Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-3.rb new file mode 100644 index 0000000000..0ea7d3195e --- /dev/null +++ b/Task/Call-a-foreign-language-function/Ruby/call-a-foreign-language-function-3.rb @@ -0,0 +1,33 @@ +require 'rubygems' +require 'inline' + +class InlineTester + def factorial_ruby(n) + (1..n).inject(1, :*) + end + + inline do |builder| + builder.c <<-'END_C' + long factorial_c(int max) { + long result = 1; + int i; + for (i = 1; i <= max; ++i) + result *= i; + return result; + } + END_C + end + + inline do |builder| + builder.include %q("math.h") + builder.c <<-'END_C' + int my_ilogb(double value) { + return ilogb(value); + } + END_C + end +end + +t = InlineTester.new +11.upto(14) {|n| p [n, t.factorial_ruby(n), t.factorial_c(n)]} +p t.my_ilogb(1000) diff --git a/Task/Call-a-foreign-language-function/Tcl/call-a-foreign-language-function.tcl b/Task/Call-a-foreign-language-function/Tcl/call-a-foreign-language-function.tcl new file mode 100644 index 0000000000..6dd56d6448 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Tcl/call-a-foreign-language-function.tcl @@ -0,0 +1,8 @@ +package require critcl +critcl::code { + #include +} +critcl::cproc tcl::mathfunc::ilogb {double value} int { + return ilogb(value); +} +package provide ilogb 1.0 diff --git a/Task/Call-a-function-in-a-shared-library/0DESCRIPTION b/Task/Call-a-function-in-a-shared-library/0DESCRIPTION new file mode 100644 index 0000000000..d1064ca801 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/0DESCRIPTION @@ -0,0 +1,6 @@ +Show how to call a function in a shared library (without dynamically linking to it at compile-time). In particular, show how to call the shared library function if the library is available, otherwise use an internal equivalent function. + +This is a special case of [[Call foreign language function|calling a foreign language function]] where the focus is close to the ABI level and not at the normal API level. + +===Related tasks=== +* [[OpenGL]] -- OpenGL is usually maintained as a shared library. diff --git a/Task/Call-a-function-in-a-shared-library/1META.yaml b/Task/Call-a-function-in-a-shared-library/1META.yaml new file mode 100644 index 0000000000..f6d82c59ad --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming environment operations diff --git a/Task/Call-a-function-in-a-shared-library/Ada/call-a-function-in-a-shared-library-1.ada b/Task/Call-a-function-in-a-shared-library/Ada/call-a-function-in-a-shared-library-1.ada new file mode 100644 index 0000000000..94b927e311 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Ada/call-a-function-in-a-shared-library-1.ada @@ -0,0 +1,45 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Interfaces; use Interfaces; +with Interfaces.C; use Interfaces.C; +with System; use System; + +with Ada.Unchecked_Conversion; + +procedure Shared_Library_Call is + -- + -- Interface to kernel32.dll which is resposible for loading DLLs under Windows. + -- There are ready to use Win32 binding. We don't want to use them here. + -- + type HANDLE is new Unsigned_32; + function LoadLibrary (lpFileName : char_array) return HANDLE; + pragma Import (stdcall, LoadLibrary, "LoadLibrary", "_LoadLibraryA@4"); + + function GetProcAddress (hModule : HANDLE; lpProcName : char_array) + return Address; + pragma Import (stdcall, GetProcAddress, "GetProcAddress", "_GetProcAddress@8"); + -- + -- The interface of the function we want to call. It is a pointer (access type) + -- because we will link it dynamically. The function is from User32.dll + -- + type MessageBox is access function + ( hWnd : Address := Null_Address; + lpText : char_array; + lpCaption : char_array := To_C ("Greeting"); + uType : Unsigned_16 := 0 + ) return Integer_16; + pragma Convention (Stdcall, MessageBox); + function To_MessageBox is new Ada.Unchecked_Conversion (Address, MessageBox); + + Library : HANDLE := LoadLibrary (To_C ("user32.dll")); + Pointer : Address := GetProcAddress (Library, To_C ("MessageBoxA")); +begin + if Pointer /= Null_Address then + declare + Result : Integer_16; + begin + Result := To_MessageBox (Pointer) (lpText => To_C ("Hello!")); + end; + else + Put_Line ("Unable to load the library " & HANDLE'Image (Library)); + end if; +end Shared_Library_Call; diff --git a/Task/Call-a-function-in-a-shared-library/Ada/call-a-function-in-a-shared-library-2.ada b/Task/Call-a-function-in-a-shared-library/Ada/call-a-function-in-a-shared-library-2.ada new file mode 100644 index 0000000000..19c2015e54 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Ada/call-a-function-in-a-shared-library-2.ada @@ -0,0 +1,49 @@ +with Ada.Environment_Variables; use Ada.Environment_Variables; +with Ada.Text_IO; use Ada.Text_IO; +with Interfaces; use Interfaces; +with Interfaces.C; use Interfaces.C; +with System; use System; + +with Ada.Unchecked_Conversion; + +procedure Shared_Library_Call is + -- + -- Interface to libdl to load dynamically linked libraries + -- + function dlopen (FileName : char_array; Flag : int) return Address; + pragma Import (C, dlopen); + + function dlsym (Handle : address; Symbol : char_array) return Address; + pragma Import (C, dlsym); + -- + -- The interfaces of the functions we want to call. These are pointers + -- (access type) because we will link it dynamically. The functions + -- come from libX11.so. + -- + type XOpenDisplay is access function (Display_Name : char_array) return Address; + pragma Convention (C, XOpenDisplay); + function To_Ptr is new Ada.Unchecked_Conversion (Address, XOpenDisplay); + + type XDisplayWidth is access function (Display : Address; Screen : int) return int; + pragma Convention (C, XDisplayWidth); + function To_Ptr is new Ada.Unchecked_Conversion (Address, XDisplayWidth); + + Library : Address := dlopen (To_C ("libX11.so"), 1); + OpenDisplay : XOpenDisplay := To_Ptr (dlsym (Library, To_C ("XOpenDisplay"))); + DisplayWidth : XDisplayWidth := To_Ptr (dlsym (Library, To_C ("XDisplayWidth"))); +begin + if OpenDisplay /= null and then DisplayWidth /= null then + declare + Display : Address; + begin + Display := OpenDisplay (To_C (Value ("DISPLAY"))); + if Display = Null_Address then + Put_Line ("Unable to open display " & Value ("DISPLAY")); + else + Put_Line (Value ("DISPLAY") & " width is" & int'image (DisplayWidth (Display, 0))); + end if; + end; + else + Put_Line ("Unable to load the library"); + end if; +end Shared_Library_Call; diff --git a/Task/Call-a-function-in-a-shared-library/AutoHotkey/call-a-function-in-a-shared-library-1.ahk b/Task/Call-a-function-in-a-shared-library/AutoHotkey/call-a-function-in-a-shared-library-1.ahk new file mode 100644 index 0000000000..a1b243b524 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/AutoHotkey/call-a-function-in-a-shared-library-1.ahk @@ -0,0 +1,3 @@ +ahkdll := DllCall("LoadLibrary", "str", "AutoHotkey.dll") +clientHandle := DllCall("AutoHotkey\ahkdll", "str", "dllclient.ahk", "str" +, "", "str", "parameter1 parameter2", "Cdecl Int") diff --git a/Task/Call-a-function-in-a-shared-library/AutoHotkey/call-a-function-in-a-shared-library-2.ahk b/Task/Call-a-function-in-a-shared-library/AutoHotkey/call-a-function-in-a-shared-library-2.ahk new file mode 100644 index 0000000000..b17aab24db --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/AutoHotkey/call-a-function-in-a-shared-library-2.ahk @@ -0,0 +1 @@ +Msgbox, hello from client diff --git a/Task/Call-a-function-in-a-shared-library/BBC-BASIC/call-a-function-in-a-shared-library.bbc b/Task/Call-a-function-in-a-shared-library/BBC-BASIC/call-a-function-in-a-shared-library.bbc new file mode 100644 index 0000000000..a48933737e --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/BBC-BASIC/call-a-function-in-a-shared-library.bbc @@ -0,0 +1 @@ + SYS "MessageBox", @hwnd%, "This is a test message", 0, 0 diff --git a/Task/Call-a-function-in-a-shared-library/C/call-a-function-in-a-shared-library-1.c b/Task/Call-a-function-in-a-shared-library/C/call-a-function-in-a-shared-library-1.c new file mode 100644 index 0000000000..1b7bace5cc --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/C/call-a-function-in-a-shared-library-1.c @@ -0,0 +1,36 @@ +#include +#include +#include + +int myopenimage(const char *in) +{ + static int handle=0; + fprintf(stderr, "internal openimage opens %s...\n", in); + return handle++; +} + +int main() +{ + void *imglib; + int (*extopenimage)(const char *); + int imghandle; + + imglib = dlopen("./fakeimglib.so", RTLD_LAZY); + if ( imglib != NULL ) { + /* extopenimage = (int (*)(const char *))dlsym(imglib,...) + "man dlopen" says that C99 standard leaves casting from + "void *" to a function pointer undefined. The following is the + POSIX.1-2003 workaround found in man */ + *(void **)(&extopenimage) = dlsym(imglib, "openimage"); + /* the following works with gcc, gives no warning even with + -Wall -std=c99 -pedantic options... :D */ + /* extopenimage = dlsym(imglib, "openimage"); */ + imghandle = extopenimage("fake.img"); + } else { + imghandle = myopenimage("fake.img"); + } + printf("opened with handle %d\n", imghandle); + /* ... */ + if (imglib != NULL ) dlclose(imglib); + return EXIT_SUCCESS; +} diff --git a/Task/Call-a-function-in-a-shared-library/C/call-a-function-in-a-shared-library-2.c b/Task/Call-a-function-in-a-shared-library/C/call-a-function-in-a-shared-library-2.c new file mode 100644 index 0000000000..468a48fc06 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/C/call-a-function-in-a-shared-library-2.c @@ -0,0 +1,8 @@ +#include +/* gcc -shared -nostartfiles fakeimglib.c -o fakeimglib.so */ +int openimage(const char *s) +{ + static int handle = 100; + fprintf(stderr, "opening %s\n", s); + return handle++; +} diff --git a/Task/Call-a-function-in-a-shared-library/Common-Lisp/call-a-function-in-a-shared-library.lisp b/Task/Call-a-function-in-a-shared-library/Common-Lisp/call-a-function-in-a-shared-library.lisp new file mode 100644 index 0000000000..cfc500c2ae --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Common-Lisp/call-a-function-in-a-shared-library.lisp @@ -0,0 +1,7 @@ +CL-USER> (cffi:load-foreign-library "libX11.so") +# +CL-USER> (cffi:foreign-funcall "XOpenDisplay" + :string #+sbcl (sb-posix:getenv "DISPLAY") + #-sbcl ":0.0" + :pointer) +#.(SB-SYS:INT-SAP #X00650FD0) diff --git a/Task/Call-a-function-in-a-shared-library/D/call-a-function-in-a-shared-library.d b/Task/Call-a-function-in-a-shared-library/D/call-a-function-in-a-shared-library.d new file mode 100644 index 0000000000..1e047e20ac --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/D/call-a-function-in-a-shared-library.d @@ -0,0 +1,9 @@ +pragma(lib, "user32.lib"); + +import std.stdio, std.c.windows.windows; + +extern(Windows) UINT GetDoubleClickTime(); + +void main() { + writeln(GetDoubleClickTime()); +} diff --git a/Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-1.delphi b/Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-1.delphi new file mode 100644 index 0000000000..64b5f7cd18 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-1.delphi @@ -0,0 +1 @@ +procedure DoSomething; external 'MYLIB.DLL'; diff --git a/Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-2.delphi b/Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-2.delphi new file mode 100644 index 0000000000..e117c64bdc --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-2.delphi @@ -0,0 +1 @@ +procedure DoSomething; external 'MYLIB.DLL' delayed; diff --git a/Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-3.delphi b/Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-3.delphi new file mode 100644 index 0000000000..89213f5cb1 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Delphi/call-a-function-in-a-shared-library-3.delphi @@ -0,0 +1,12 @@ +var + lLibraryHandle: THandle; + lDoSomething: procedure; stdcall; +begin + lLibraryHandle := LoadLibrary('MYLIB.DLL'); + if lLibraryHandle >= 32 then { success } + begin + lDoSomething := GetProcAddress(lLibraryHandle, 'DoSomething'); + lDoSomething(); + FreeLibrary(lLibraryHandle); + end; +end; diff --git a/Task/Call-a-function-in-a-shared-library/Java/call-a-function-in-a-shared-library-1.java b/Task/Call-a-function-in-a-shared-library/Java/call-a-function-in-a-shared-library-1.java new file mode 100644 index 0000000000..977e206151 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Java/call-a-function-in-a-shared-library-1.java @@ -0,0 +1,8 @@ +public class LoadLib{ + private static native void functionInSharedLib(); //change return type or parameters as necessary + + public static void main(String[] args){ + System.loadLibrary("Path/to/library/here/lib.dll"); + functionInSharedLib(); + } +} diff --git a/Task/Call-a-function-in-a-shared-library/Java/call-a-function-in-a-shared-library-2.java b/Task/Call-a-function-in-a-shared-library/Java/call-a-function-in-a-shared-library-2.java new file mode 100644 index 0000000000..c7f40b2785 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Java/call-a-function-in-a-shared-library-2.java @@ -0,0 +1,15 @@ +import com.sun.jna.Library; +import com.sun.jna.Native; + +public class LoadLibJNA{ + private interface YourSharedLibraryName extends Library{ + //put shared library functions here with no definition + public void sharedLibraryfunction(); + } + + public static void main(String[] args){ + YourSharedLibraryName lib = (YourSharedLibraryName)Native.loadLibrary("sharedLibrary",//as in "sharedLibrary.dll" + YourSharedLibraryName.class); + lib.sharedLibraryFunction(); + } +} diff --git a/Task/Call-a-function-in-a-shared-library/PicoLisp/call-a-function-in-a-shared-library-1.l b/Task/Call-a-function-in-a-shared-library/PicoLisp/call-a-function-in-a-shared-library-1.l new file mode 100644 index 0000000000..fc9bae9481 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/PicoLisp/call-a-function-in-a-shared-library-1.l @@ -0,0 +1,26 @@ +(load "@lib/gcc.l") + +(gcc "x11" '("-lX11") 'xOpenDisplay 'xCloseDisplay) + +#include + +any xOpenDisplay(any ex) { + any x = evSym(cdr(ex)); // Get display name + char display[bufSize(x)]; // Create a buffer for the name + + bufString(x, display); // Upack the name + return boxCnt((long)XOpenDisplay(display)); +} + +any xCloseDisplay(any ex) { + return boxCnt(XCloseDisplay((Display*)evCnt(ex, cdr(ex)))); +} +/**/ + +# With that we can open and close the display: +: (setq Display (xOpenDisplay ":0.7")) # Wrong +-> 0 +: (setq Display (xOpenDisplay ":0.0")) # Correct +-> 158094320 +: (xCloseDisplay Display) +-> 0 diff --git a/Task/Call-a-function-in-a-shared-library/PicoLisp/call-a-function-in-a-shared-library-2.l b/Task/Call-a-function-in-a-shared-library/PicoLisp/call-a-function-in-a-shared-library-2.l new file mode 100644 index 0000000000..756a0ed699 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/PicoLisp/call-a-function-in-a-shared-library-2.l @@ -0,0 +1,4 @@ +: (setq Display (native "/usr/lib/libX11.so.6" "XOpenDisplay" 'N ":0.0")) +-> 6502688 +: (native "/usr/lib/libX11.so.6" "XCloseDisplay" 'I Display) +-> 0 diff --git a/Task/Call-a-function-in-a-shared-library/Python/call-a-function-in-a-shared-library.py b/Task/Call-a-function-in-a-shared-library/Python/call-a-function-in-a-shared-library.py new file mode 100644 index 0000000000..c456307e3d --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Python/call-a-function-in-a-shared-library.py @@ -0,0 +1,4 @@ +import ctypes + +user32_dll = ctypes.cdll.LoadLibrary('User32.dll') +print user32_dll.GetDoubleClickTime() diff --git a/Task/Call-a-function-in-a-shared-library/Racket/call-a-function-in-a-shared-library.rkt b/Task/Call-a-function-in-a-shared-library/Racket/call-a-function-in-a-shared-library.rkt new file mode 100644 index 0000000000..ab4e42bf71 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Racket/call-a-function-in-a-shared-library.rkt @@ -0,0 +1,6 @@ +#lang racket +(require ffi/unsafe) +(define libm (ffi-lib "libm")) ; get a handle for the C math library +; look up sqrt in the math library. if we can't find it, return the builtin sqrt +(define extern-sqrt (get-ffi-obj 'sqrt libm (_fun _double -> _double) + (lambda () sqrt))) diff --git a/Task/Call-a-function-in-a-shared-library/Ruby/call-a-function-in-a-shared-library-1.rb b/Task/Call-a-function-in-a-shared-library/Ruby/call-a-function-in-a-shared-library-1.rb new file mode 100644 index 0000000000..f8fe6d9c5c --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Ruby/call-a-function-in-a-shared-library-1.rb @@ -0,0 +1,11 @@ +require 'dl/import' + +FakeImgLib = DL.dlopen("/path/to/fakeimg.so") + +module FakeImage + def self.openimage filename + FakeImgLib["openimage", "IS"].call(filename)[0] + end +end + +handle = FakeImage.openimage("path/to/image") diff --git a/Task/Call-a-function-in-a-shared-library/Ruby/call-a-function-in-a-shared-library-2.rb b/Task/Call-a-function-in-a-shared-library/Ruby/call-a-function-in-a-shared-library-2.rb new file mode 100644 index 0000000000..8e46956994 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Ruby/call-a-function-in-a-shared-library-2.rb @@ -0,0 +1,8 @@ +require 'ffi' +module FakeImgLib + extend FFI::Library + ffi_lib "path/to/fakeimglib.so" + attach_function :openimage, [:string], :int +end + +handle = FakeImgLib.openimage("path/to/image") diff --git a/Task/Call-a-function-in-a-shared-library/Smalltalk/call-a-function-in-a-shared-library.st b/Task/Call-a-function-in-a-shared-library/Smalltalk/call-a-function-in-a-shared-library.st new file mode 100644 index 0000000000..879516bf38 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Smalltalk/call-a-function-in-a-shared-library.st @@ -0,0 +1,14 @@ +DLD addLibrary: 'fakeimglib'. + +Object subclass: ExtLib [ + ExtLib class >> openimage: aString [ + (CFunctionDescriptor isFunction: 'openimage') + ifTrue: [ + (CFunctionDescriptor for: 'openimage' + returning: #int + withArgs: #( #string ) ) callInto: (ValueHolder null). + ] ifFalse: [ ('internal open image %1' % { aString }) displayNl ] + ] +]. + +ExtLib openimage: 'test.png'. diff --git a/Task/Call-a-function-in-a-shared-library/Tcl/call-a-function-in-a-shared-library.tcl b/Task/Call-a-function-in-a-shared-library/Tcl/call-a-function-in-a-shared-library.tcl new file mode 100644 index 0000000000..34a456de41 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Tcl/call-a-function-in-a-shared-library.tcl @@ -0,0 +1,8 @@ +package require Ffidl + +if {[catch { + ffidl::callout OpenImage {pointer-utf8} int [ffidl::symbol fakeimglib.so openimage] +}]} then { + # Create the OpenImage command by other means here... +} +set handle [OpenImage "/the/file/name"] diff --git a/Task/Call-a-function/0DESCRIPTION b/Task/Call-a-function/0DESCRIPTION new file mode 100644 index 0000000000..30eb7d3ec6 --- /dev/null +++ b/Task/Call-a-function/0DESCRIPTION @@ -0,0 +1,15 @@ +The task is to demonstrate the different syntax and semantics provided for calling a function. This may include: +* Calling a function that requires no arguments +* Calling a function with a fixed number of arguments +* Calling a function with [[Optional parameters|optional arguments]] +* Calling a function with a [[Variadic function|variable number of arguments]] +* Calling a function with [[Named parameters|named arguments]] +* Using a function in statement context +* Using a function in [[First-class functions|first-class context]] within an expression +* Obtaining the return value of a function +* Distinguishing built-in functions and user-defined functions +* Distinguishing subroutines and functions +* Stating whether arguments are [[:Category:Parameter passing|passed]] by value or by reference +* Is partial application possible and how + +This task is ''not'' about [[Function definition|defining functions]]. diff --git a/Task/Call-a-function/1META.yaml b/Task/Call-a-function/1META.yaml new file mode 100644 index 0000000000..2233b6b2e3 --- /dev/null +++ b/Task/Call-a-function/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Functions and subroutines diff --git a/Task/Call-a-function/AWK/call-a-function.awk b/Task/Call-a-function/AWK/call-a-function.awk new file mode 100644 index 0000000000..0c66f45417 --- /dev/null +++ b/Task/Call-a-function/AWK/call-a-function.awk @@ -0,0 +1,4 @@ +BEGIN { + sayhello() # Call a function with no parameters in statement context + b=squareit(3) # Obtain the return value from a function with a single parameter in first class context +} diff --git a/Task/Call-a-function/ActionScript/call-a-function.as b/Task/Call-a-function/ActionScript/call-a-function.as new file mode 100644 index 0000000000..ee37a5ba82 --- /dev/null +++ b/Task/Call-a-function/ActionScript/call-a-function.as @@ -0,0 +1,3 @@ + myfunction(); /* function with no arguments in statement context */ + myfunction(6,b); // function with two arguments in statement context + stringit("apples"); //function with a string argument diff --git a/Task/Call-a-function/Ada/call-a-function-1.ada b/Task/Call-a-function/Ada/call-a-function-1.ada new file mode 100644 index 0000000000..2c7f62fc2f --- /dev/null +++ b/Task/Call-a-function/Ada/call-a-function-1.ada @@ -0,0 +1 @@ +S: String := Ada.Text_IO.Get_Line; diff --git a/Task/Call-a-function/Ada/call-a-function-2.ada b/Task/Call-a-function/Ada/call-a-function-2.ada new file mode 100644 index 0000000000..9f7a9920f7 --- /dev/null +++ b/Task/Call-a-function/Ada/call-a-function-2.ada @@ -0,0 +1,5 @@ +function F(X: Integer; Y: Integer := 0) return Integer; -- Y is optional +... +A : Integer := F(12); +B : Integer := F(12, 0); -- the same as A +C : Integer := F(12, 1); -- something different diff --git a/Task/Call-a-function/Ada/call-a-function-3.ada b/Task/Call-a-function/Ada/call-a-function-3.ada new file mode 100644 index 0000000000..d325032344 --- /dev/null +++ b/Task/Call-a-function/Ada/call-a-function-3.ada @@ -0,0 +1,12 @@ +type Integer_Array is array (Positive range <>) of Integer; +function Sum(A: Integer_Array) return Integer is + S: Integer := 0; +begin + for I in A'Range loop + S := S + A(I); + end loop; + return S; +end Sum; +... +A := Sum((1,2,3)); -- A = 6 +B := Sum((1,2,3,4)); -- B = 10 diff --git a/Task/Call-a-function/Ada/call-a-function-4.ada b/Task/Call-a-function/Ada/call-a-function-4.ada new file mode 100644 index 0000000000..cfb52c391a --- /dev/null +++ b/Task/Call-a-function/Ada/call-a-function-4.ada @@ -0,0 +1,9 @@ +function H (Int: Integer; + Fun: not null access function (X: Integer; Y: Integer) + return Integer); + return Integer; + +... + +X := H(A, F'Access) -- assuming X and A are Integers, and F is a function + -- taking two Integers and returning an Integer. diff --git a/Task/Call-a-function/Ada/call-a-function-5.ada b/Task/Call-a-function/Ada/call-a-function-5.ada new file mode 100644 index 0000000000..0850c849f8 --- /dev/null +++ b/Task/Call-a-function/Ada/call-a-function-5.ada @@ -0,0 +1,3 @@ +Positional := H(A, F'Access); +Named := H(Int => A, Fun => F'Access); +Mixed := H(A, Fun=>F'Access); diff --git a/Task/Call-a-function/AutoHotkey/call-a-function.ahk b/Task/Call-a-function/AutoHotkey/call-a-function.ahk new file mode 100644 index 0000000000..4ebc20af07 --- /dev/null +++ b/Task/Call-a-function/AutoHotkey/call-a-function.ahk @@ -0,0 +1,39 @@ +; Call a function without arguments: +f() + +; Call a function with a fixed number of arguments: +f("string", var, 15.5) + +; Call a function with optional arguments: +f("string", var, 15.5) + +; Call a function with a variable number of arguments: +f("string", var, 15.5) + +; Call a function with named arguments: + ; AutoHotkey does not have named arguments. However, in v1.1+, + ; we can pass an object to the function: +f({named: "string", otherName: var, thirdName: 15.5}) + +; Use a function in statement context: +f(1), f(2) ; What is statement context? + +; No first-class functions in AHK + +; Obtaining the return value of a function: +varThatGetsReturnValue := f(1, "a") + +; Cannot distinguish built-in functions + +; Subroutines are called with GoSub; functions are called as above. +; Subroutines cannot be passed variables + +; Stating whether arguments are passed by value or by reference: +; [v1.1.01+]: The IsByRef() function can be used to determine +; whether the caller supplied a variable for a given ByRef parameter. +; A variable cannot be passed by value to a byRef parameter. Instead, do this: +f(tmp := varIdoNotWantChanged) +; the function f will receive the value of varIdoNotWantChanged, but any +; modifications will be made to the variable tmp. + +; Partial application is impossible. diff --git a/Task/Call-a-function/C/call-a-function.c b/Task/Call-a-function/C/call-a-function.c new file mode 100644 index 0000000000..9bcdfa4817 --- /dev/null +++ b/Task/Call-a-function/C/call-a-function.c @@ -0,0 +1,48 @@ +/* function with no argument */ +f(); + +/* fix number of arguments */ +g(1, 2, 3); + +/* Optional arguments: err... + Feel free to make sense of the following. I can't. */ +int op_arg(); +int main() +{ + op_arg(1); + op_arg(1, 2); + op_arg(1, 2, 3); + return 0; +} +int op_arg(int a, int b) +{ + printf("%d %d %d\n", a, b, (&b)[1]); + return a; +} /* end of sensible code */ + +/* Variadic function: how the args list is handled solely depends on the function */ +void h(int a, ...) +{ + va_list ap; + va_start(ap); + ... +} +/* call it as: (if you feed it something it doesn't expect, don't count on it working) */ +h(1, 2, 3, 4, "abcd", (void*)0); + +/* named arguments: no such thing */ +/* statement context: is that a real phrase? */ + +/* as a first-class object (i.e. function pointer) */ +printf("%p", f); /* that's the f() above */ + +/* return value */ +double a = asin(1); + +/* built-in functions: no such thing. Compiler may interally give special treatment + to bread-and-butter functions such as memcpy(), but that's not a C built-in per se */ + +/* subroutines: no such thing. You can goto places, but I doubt that counts. */ + +/* Scalar values are passed by value by default. However, arrays are passed by reference. */ +/* Pointers *sort of* work like references, though. */ diff --git a/Task/Call-a-function/JavaScript/call-a-function-1.js b/Task/Call-a-function/JavaScript/call-a-function-1.js new file mode 100644 index 0000000000..dc445c5d17 --- /dev/null +++ b/Task/Call-a-function/JavaScript/call-a-function-1.js @@ -0,0 +1,3 @@ +var foo = function() { return arguments.length }; +foo() // 0 +foo(1, 2, 3) // 3 diff --git a/Task/Call-a-function/JavaScript/call-a-function-2.js b/Task/Call-a-function/JavaScript/call-a-function-2.js new file mode 100644 index 0000000000..8ecfc7edc6 --- /dev/null +++ b/Task/Call-a-function/JavaScript/call-a-function-2.js @@ -0,0 +1 @@ +var squares = [1, 2, 3].map(function (n) { return n * n }); // [1, 4, 9] diff --git a/Task/Call-a-function/JavaScript/call-a-function-3.js b/Task/Call-a-function/JavaScript/call-a-function-3.js new file mode 100644 index 0000000000..8b82365e6e --- /dev/null +++ b/Task/Call-a-function/JavaScript/call-a-function-3.js @@ -0,0 +1,5 @@ +var make_adder = function(m) { + return function(n) { return m + n } +}; +var add42 = make_adder(42); +add42(10) // 52 diff --git a/Task/Call-a-function/JavaScript/call-a-function-4.js b/Task/Call-a-function/JavaScript/call-a-function-4.js new file mode 100644 index 0000000000..45ea854a7f --- /dev/null +++ b/Task/Call-a-function/JavaScript/call-a-function-4.js @@ -0,0 +1,4 @@ +foo.toString() +"function () { return arguments.length }" +alert.toString() +"function alert() { [native code] }" diff --git a/Task/Call-a-function/JavaScript/call-a-function-5.js b/Task/Call-a-function/JavaScript/call-a-function-5.js new file mode 100644 index 0000000000..887fa5936e --- /dev/null +++ b/Task/Call-a-function/JavaScript/call-a-function-5.js @@ -0,0 +1,6 @@ +var mutate = function(victim) { + victim[0] = null; + victim = 42; +}; +var foo = [1, 2, 3]; +mutate(foo) // foo is now [null, 2, 3], not 42 diff --git a/Task/Call-a-function/MATLAB/call-a-function.m b/Task/Call-a-function/MATLAB/call-a-function.m new file mode 100644 index 0000000000..df2ab8179c --- /dev/null +++ b/Task/Call-a-function/MATLAB/call-a-function.m @@ -0,0 +1,49 @@ + % Calling a function that requires no arguments + function a=foo(); + a=4; + end; + x = foo(); + % Calling a function with a fixed number of arguments + function foo(a,b,c); + %% function definition; + end; + foo(x,y,z); + % Calling a function with optional arguments + function foo(a,b,c); + if nargin<2, b=0; end; + if nargin<3, c=0; end; + %% function definition; + end; + foo(x,y); + % Calling a function with a variable number of arguments + function foo(varargin); + for k=1:length(varargin) + arg{k} = varargin{k}; + end; + foo(x,y); + % Calling a function with named arguments + %% does not apply + % Using a function in statement context + %% does not apply + % Using a function in first-class context within an expression + % Obtaining the return value of a function + function [a,b]=foo(); + a=4; + b='result string'; + end; + [x,y] = foo(); + % Distinguishing built-in functions and user-defined functions + fun = 'foo'; + if (exist(fun,'builtin')) + printf('function %s is a builtin\n'); + elseif (exist(fun,'file')) + printf('function %s is user-defined\n'); + elseif (exist(fun,'var')) + printf('function %s is a variable\n'); + else + printf('%s is not a function or variable.\n'); + end + % Distinguishing subroutines and functions + % there are only scripts and functions, any function declaration starts with the keyword function, otherwise it is a script that runs in the workspace + % Stating whether arguments are passed by value or by reference + % arguments are passed by value, however Matlab has delayed evaluation, such that a copy of large data structures are done only when an element is written to. diff --git a/Task/Call-a-function/PicoLisp/call-a-function-1.l b/Task/Call-a-function/PicoLisp/call-a-function-1.l new file mode 100644 index 0000000000..d3034e7f7b --- /dev/null +++ b/Task/Call-a-function/PicoLisp/call-a-function-1.l @@ -0,0 +1,2 @@ +(foo) +(bar 1 'arg 2 'mumble) diff --git a/Task/Call-a-function/PicoLisp/call-a-function-2.l b/Task/Call-a-function/PicoLisp/call-a-function-2.l new file mode 100644 index 0000000000..fba68e22b2 --- /dev/null +++ b/Task/Call-a-function/PicoLisp/call-a-function-2.l @@ -0,0 +1,2 @@ +(mapc println Lst) # The value of 'printlin' is a number +(apply '((A B C) (foo (+ A (* B C)))) (3 5 7)) # A list is passed diff --git a/Task/Call-a-function/PicoLisp/call-a-function-3.l b/Task/Call-a-function/PicoLisp/call-a-function-3.l new file mode 100644 index 0000000000..9bde056d1f --- /dev/null +++ b/Task/Call-a-function/PicoLisp/call-a-function-3.l @@ -0,0 +1 @@ +(setq A (+ 3 4) B (* 3 4)) diff --git a/Task/Call-a-function/Python/call-a-function.py b/Task/Call-a-function/Python/call-a-function.py new file mode 100644 index 0000000000..2906bd6592 --- /dev/null +++ b/Task/Call-a-function/Python/call-a-function.py @@ -0,0 +1,51 @@ +def no_args(): + pass +# call +no_args() + +def fixed_args(x, y): + print('x=%r, y=%r' % (x, y)) +# call +fixed_args(1, 2) # x=1, y=2 + +def opt_args(x=1): + print(x) +# calls +opt_args() # 1 +opt_args(3.141) # 3.141 + +def var_args(*v): + print(v) +# calls +var_args(1, 2, 3) # (1, 2, 3) +var_args(1, (2,3)) # (1, (2, 3)) +var_args() # () + +## Named arguments +fixed_args(y=2, x=1) # x=1, y=2 + +## As a statement +if 1: + no_args() + +## First-class within an expression +assert no_args() is None + +def return_something(): + return 1 +x = return_something() + +def is_builtin(x): + print(x.__name__ in dir(__builtins__)) +# calls +is_builtin(pow) # True +is_builtin(is_builtin) # False + +## A subroutine is merely a function that has no explicit +## return statement and will return None. + +## Python uses "Call by Object Reference". +## See, for example, http://www.python-course.eu/passing_arguments.php + +## For partial function application see: +## http://rosettacode.org/wiki/Partial_function_application#Python diff --git a/Task/Call-a-function/REXX/call-a-function.rexx b/Task/Call-a-function/REXX/call-a-function.rexx new file mode 100644 index 0000000000..cd2968ce8b --- /dev/null +++ b/Task/Call-a-function/REXX/call-a-function.rexx @@ -0,0 +1,137 @@ +/*REXX program to demonstrate various methods of calling a REXX function*/ +/*┌────────────────────────────────────────────────────────────────────┐ + │ Calling a function that REQUIRES no arguments. │ + │ │ + │ In the REXX language, there is no way to require the caller to not │ + │ pass arguments, but the programmer can check if any arguments were │ + │ (or weren't) passed. │ + └────────────────────────────────────────────────────────────────────┘*/ +yr=yearFunc() +say 'year=' yr +exit + +yearFunc: procedure +if arg()\==0 then call sayErr "SomeFunc function won't accept arguments." +return left(date('Sorted'),3) +/*┌────────────────────────────────────────────────────────────────────┐ + │ Calling a function with a fixed number of arguments. │ + │ │ + │ I take this to mean that the function requires a fixed number of │ + │ arguments. As above, REXX doesn't enforce calling (or invoking) │ + │ a (any) function with a certain number of arguments, but the │ + │ programmer can check if the correct number of arguments have been │ + │ specified (or not). │ + └────────────────────────────────────────────────────────────────────┘*/ +ggg=FourFunc(12,abc,6+q,zz%2,'da 5th disagreement') +say 'ggg squared=' ggg**2 +exit + +FourFunc: procedure; parse arg a1,a2,a3; a4=arg(4) /*another way get a4*/ + +if arg()\==4 then do + call sayErr "FourFunc function requires 4 arguments," + call sayErr "but instead it found" arg() 'arguments.' + exit 13 + end +return a1+a2+a3+a4 +/*┌────────────────────────────────────────────────────────────────────┐ + │ Calling a function with optional arguments. │ + │ │ + │ Note that not passing an argument isn't the same as passing a null │ + │ argument (a REXX variable whose value is length zero). │ + └────────────────────────────────────────────────────────────────────┘*/ +x=12; w=x/2; y=x**2; z=x//7 /* z is x modulo seven.*/ +say 'sum of w, x, y, & z=' SumIt(w,x,y,,z) /*pass 5 args, 4th is null*/ +exit + +SumIt: procedure; sum=0 + + do j=1 for arg() + if arg(j,'E') then sum=sum+arg(j) /*the Jth arg may have been omitted*/ + end + +return sum +/*┌────────────────────────────────────────────────────────────────────┐ + │ Calling a function with a variable number of arguments. │ + │ │ + │ This situation isn't any different then the previous example. │ + │ It's up to the programmer to code how to utilize the arguments. │ + └────────────────────────────────────────────────────────────────────┘*/ +/*┌────────────────────────────────────────────────────────────────────┐ + │ Calling a function with named arguments. │ + │ │ + │ REXX allows almost anything to be passed, so the following is one │ + │ way this can be accomplished. │ + └────────────────────────────────────────────────────────────────────┘*/ +what=parserFunc('name=Luna',"gravity=.1654",'moon=yes') +say 'name=' common.name +gr=common.gr +say 'gravity=' gr +exit + +parseFunc: procedure expose common. + do j=1 for arg() + parse var arg(j) name '=' val + upper name + call value 'COMMON.'name,val + end +return arg() +/*┌────────────────────────────────────────────────────────────────────┐ + │ Calling a function in statement context. │ + │ │ + │ REXX allows functions to be called (invoked) two ways, the first │ + │ example (above) is calling a function in statement context. │ + └────────────────────────────────────────────────────────────────────┘*/ +/*┌────────────────────────────────────────────────────────────────────┐ + │ Calling a function in within an expression. │ + │ │ + │ This is a variant of the first example. │ + └────────────────────────────────────────────────────────────────────┘*/ +yr=yearFunc()+20 +say 'two decades from now, the year will be:' yr +exit +/*┌────────────────────────────────────────────────────────────────────┐ + │ Obtaining the return value of a function. │ + │ │ + │ There are two ways to get the (return) value of a function. │ + └────────────────────────────────────────────────────────────────────┘*/ +currYear=yearFunc() +say 'the current year is' currYear + +call yearFunc +say 'the current year is' result +/*┌────────────────────────────────────────────────────────────────────┐ + │ Distinguishing built-in functions and user-defined functions. │ + │ │ + │ One objective of the REXX language is to allow the user to use any │ + │ function (or subroutine) name whether or not there is a built-in │ + │ function with the same name (there isn't a penality for this). │ + └────────────────────────────────────────────────────────────────────┘*/ +qqq=date() /*number of real dates that Bob was on. */ +say "Bob's been out" qqq 'times.' +www='DATE'('USA') /*returns date in format mm/dd/yyy */ +exit /*any function in quotes is external. */ + +date: return 4 +/*┌────────────────────────────────────────────────────────────────────┐ + │ Distinguishing subroutines and functions. │ + │ │ + │ There is no programatic difference between subroutines and │ + │ functions if the subroutine returns a value (which effectively │ + │ makes it a function). REXX allows you to call a function as if │ + │ it were a subroutine. │ + └────────────────────────────────────────────────────────────────────┘*/ +/*┌────────────────────────────────────────────────────────────────────┐ + │ In REXX, all arguments are passed by value, never by name, but it │ + │ is possible to accomplish this if the variable's name is passed │ + │ and the subroutine/function could use the built-in-function VALUE │ + │ to retrieve the variable's value. │ + └────────────────────────────────────────────────────────────────────┘*/ +/*┌────────────────────────────────────────────────────────────────────┐ + │ In the REXX language, partial application is possible, depending │ + │ how partial application is defined; I prefer the 1st definition (as│ + │ (as per the "discussion" for "Partial Function Application" task: │ + │ 1. The "syntactic sugar" that allows one to write (some examples│ + │ are: map (f 7 9) [1..9] │ + │ or: map(f(7,_,9),{1,...,9}) │ + └────────────────────────────────────────────────────────────────────┘*/ diff --git a/Task/Call-a-function/Smalltalk/call-a-function.st b/Task/Call-a-function/Smalltalk/call-a-function.st new file mode 100644 index 0000000000..3dc2fea392 --- /dev/null +++ b/Task/Call-a-function/Smalltalk/call-a-function.st @@ -0,0 +1 @@ +f valueWithArguments: arguments. diff --git a/Task/Call-a-function/Tcl/call-a-function-1.tcl b/Task/Call-a-function/Tcl/call-a-function-1.tcl new file mode 100644 index 0000000000..dc1deca34c --- /dev/null +++ b/Task/Call-a-function/Tcl/call-a-function-1.tcl @@ -0,0 +1,7 @@ +aCallToACommandWithNoArguments +aCallToACommandWithOne argument +aCallToACommandWith arbitrarily many arguments +aCallToACommandWith {*}$manyArgumentsComingFromAListInAVariable +aCallToACommandWith -oneNamed argument -andAnother namedArgument +aCallToACommandWith theNameOfAnotherCommand +aCallToOneCommand [withTheResultOfAnother] diff --git a/Task/Call-a-function/Tcl/call-a-function-2.tcl b/Task/Call-a-function/Tcl/call-a-function-2.tcl new file mode 100644 index 0000000000..8502ff991a --- /dev/null +++ b/Task/Call-a-function/Tcl/call-a-function-2.tcl @@ -0,0 +1,2 @@ +expr {func() + [cmd]} +expr {func(1,2,3} + [cmd a b c]} diff --git a/Task/Call-an-object-method/0DESCRIPTION b/Task/Call-an-object-method/0DESCRIPTION new file mode 100644 index 0000000000..cc4d8109cc --- /dev/null +++ b/Task/Call-an-object-method/0DESCRIPTION @@ -0,0 +1,3 @@ +In [[object-oriented programming]] a method is a function associated with a particular class or object. In most forms of object oriented implementations methods can be static, associated with the class itself; or instance, associated with an instance of a class. + +Show how to call a static or class method, and an instance method of a class. diff --git a/Task/Call-an-object-method/1META.yaml b/Task/Call-an-object-method/1META.yaml new file mode 100644 index 0000000000..ece24ffc0a --- /dev/null +++ b/Task/Call-an-object-method/1META.yaml @@ -0,0 +1,5 @@ +--- +category: +- Object oriented +- Encyclopedia +note: Basic language learning diff --git a/Task/Call-an-object-method/ActionScript/call-an-object-method.as b/Task/Call-an-object-method/ActionScript/call-an-object-method.as new file mode 100644 index 0000000000..03cc43e8a9 --- /dev/null +++ b/Task/Call-an-object-method/ActionScript/call-an-object-method.as @@ -0,0 +1,5 @@ +// Static +MyClass.method(someParameter); + +// Instance +myInstance.method(someParameter); diff --git a/Task/Call-an-object-method/AutoHotkey/call-an-object-method.ahk b/Task/Call-an-object-method/AutoHotkey/call-an-object-method.ahk new file mode 100644 index 0000000000..058c9bf921 --- /dev/null +++ b/Task/Call-an-object-method/AutoHotkey/call-an-object-method.ahk @@ -0,0 +1,10 @@ +class myClass +{ + Method(someParameter){ + MsgBox % SomeParameter + } +} + +myClass.method("hi") +myInstance := new myClass +myInstance.Method("bye") diff --git a/Task/Call-an-object-method/C++/call-an-object-method.cpp b/Task/Call-an-object-method/C++/call-an-object-method.cpp new file mode 100644 index 0000000000..16ce9e564a --- /dev/null +++ b/Task/Call-an-object-method/C++/call-an-object-method.cpp @@ -0,0 +1,5 @@ +// Static +MyClass::method(someParameter); + +// Instance +myInstance.method(someParameter); diff --git a/Task/Call-an-object-method/D/call-an-object-method.d b/Task/Call-an-object-method/D/call-an-object-method.d new file mode 100644 index 0000000000..d4d28f9ca4 --- /dev/null +++ b/Task/Call-an-object-method/D/call-an-object-method.d @@ -0,0 +1,37 @@ +struct Cat { + static int staticMethod() { + return 2; + } + + string dynamicMethod() { // Never virtual. + return "Mew!"; + } +} + +class Dog { + static int staticMethod() { + return 5; + } + + string dynamicMethod() { // Virtual method. + return "Woof!"; + } +} + +void main() { + // Static methods calls: + assert(Cat.staticMethod() == 2); + assert(Dog.staticMethod() == 5); + + Cat c; // This is a value on the stack. + Dog d; // This is just a reference, set to null. + + // Other static method calls, discouraged: + assert(c.staticMethod() == 2); + assert(d.staticMethod() == 5); + + // Instance method calls: + assert(c.dynamicMethod() == "Mew!"); + d = new Dog; + assert(d.dynamicMethod() == "Woof!"); +} diff --git a/Task/Call-an-object-method/E/call-an-object-method.e b/Task/Call-an-object-method/E/call-an-object-method.e new file mode 100644 index 0000000000..8e517fb94d --- /dev/null +++ b/Task/Call-an-object-method/E/call-an-object-method.e @@ -0,0 +1 @@ +someObject.someMethod(someParameter) diff --git a/Task/Call-an-object-method/Forth/call-an-object-method.fth b/Task/Call-an-object-method/Forth/call-an-object-method.fth new file mode 100644 index 0000000000..be4ba7e82f --- /dev/null +++ b/Task/Call-an-object-method/Forth/call-an-object-method.fth @@ -0,0 +1,40 @@ +include lib/compare.4th +include 4pp/lib/foos.4pp + +[ASSERT] \ enable assertions + +:: Cat + class + method: dynamicCat \ virtual method + end-class { + + :static staticCat { 2 } ; \ static method + :method { s" Mew!" } ; defines dynamicCat + } \ for unrelated classes, +; \ method names have to differ + +:: Dog + class + method: dynamicDog \ virtual method + end-class { + + :static staticDog { 5 } ; + :method { s" Woof!" } ; defines dynamicDog + } \ for unrelated classes, +; \ method names have to differ + +static Cat c \ create two static objects +static Dog d + +: main + assert( class -> staticCat 2 = ) \ check for valid method return + assert( class -> staticDog 5 = ) \ of a static method + + assert( c -> staticCat 2 = ) \ check for valid method return + assert( d -> staticDog 5 = ) \ of a static method + + assert( c => dynamicCat s" Mew!" compare 0= ) + assert( d => dynamicDog s" Woof!" compare 0= ) +; \ same for dynamic methods + +main diff --git a/Task/Call-an-object-method/Go/call-an-object-method-1.go b/Task/Call-an-object-method/Go/call-an-object-method-1.go new file mode 100644 index 0000000000..34e3bc76bb --- /dev/null +++ b/Task/Call-an-object-method/Go/call-an-object-method-1.go @@ -0,0 +1,29 @@ +type Foo int // some custom type + +// method on the type itself; can be called on that type or its pointer +func (self Foo) ValueMethod(x int) { } + +// method on the pointer to the type; can be called on pointers +func (self *Foo) PointerMethod(x int) { } + + +var myValue Foo +var myPointer *Foo = new(Foo) + +// Calling value method on value +myValue.ValueMethod(someParameter) +// Calling pointer method on pointer +myPointer.PointerMethod(someParameter) + +// Value methods can always be called on pointers +// equivalent to (*myPointer).ValueMethod(someParameter) +myPointer.ValueMethod(someParameter) + +// In a special case, pointer methods can be called on values that are addressable (i.e. lvalues) +// equivalent to (&myValue).PointerMethod(someParameter) +myValue.PointerMethod(someParameter) + +// You can get the method out of the type as a function, and then explicitly call it on the object +Foo.ValueMethod(myValue, someParameter) +(*Foo).PointerMethod(myPointer, someParameter) +(*Foo).ValueMethod(myPointer, someParameter) diff --git a/Task/Call-an-object-method/Go/call-an-object-method-2.go b/Task/Call-an-object-method/Go/call-an-object-method-2.go new file mode 100644 index 0000000000..ccccfac584 --- /dev/null +++ b/Task/Call-an-object-method/Go/call-an-object-method-2.go @@ -0,0 +1,29 @@ +package box + +import "sync/atomic" + +var sn uint32 + +type box struct { + Contents string + secret uint32 +} + +func New() (b *box) { + b = &box{secret: atomic.AddUint32(&sn, 1)} + switch sn { + case 1: + b.Contents = "rabbit" + case 2: + b.Contents = "rock" + } + return +} + +func (b *box) TellSecret() uint32 { + return b.secret +} + +func Count() uint32 { + return atomic.LoadUint32(&sn) +} diff --git a/Task/Call-an-object-method/Go/call-an-object-method-3.go b/Task/Call-an-object-method/Go/call-an-object-method-3.go new file mode 100644 index 0000000000..6fdf6510ad --- /dev/null +++ b/Task/Call-an-object-method/Go/call-an-object-method-3.go @@ -0,0 +1,16 @@ +package main + +import "box" + +func main() { + // Call constructor. Technically it's just an exported function, + // but it's a Go idiom to naming a function New that serves the purpose + // of a constructor. + b := box.New() + + // Call instance method. In Go terms, simply a method. + b.TellSecret() + + // Call class method. In Go terms, another exported function. + box.Count() +} diff --git a/Task/Call-an-object-method/Go/call-an-object-method-4.go b/Task/Call-an-object-method/Go/call-an-object-method-4.go new file mode 100644 index 0000000000..4a825cfda1 --- /dev/null +++ b/Task/Call-an-object-method/Go/call-an-object-method-4.go @@ -0,0 +1,23 @@ +procedure main() + + foo_m1() # equivalent of class method, not normally used + bar := foo() # create instance + bar.m2() # call method m2 with self=bar +end + + +class foo(cp1,cp2) + method m1(m1p1,m1p2) + local ml1 + static ms1 + ml1 := m1p1 + # do something + return + end + method m2(m2p1) + # do something else + return + end +initially + L := [cp1] +end diff --git a/Task/Call-an-object-method/Java/call-an-object-method-1.java b/Task/Call-an-object-method/Java/call-an-object-method-1.java new file mode 100644 index 0000000000..2e0791cb9f --- /dev/null +++ b/Task/Call-an-object-method/Java/call-an-object-method-1.java @@ -0,0 +1 @@ +ClassWithStaticMethod.staticMethodName(argument1, argument2);//for methods with no arguments, use empty parentheses diff --git a/Task/Call-an-object-method/Java/call-an-object-method-2.java b/Task/Call-an-object-method/Java/call-an-object-method-2.java new file mode 100644 index 0000000000..6251223b10 --- /dev/null +++ b/Task/Call-an-object-method/Java/call-an-object-method-2.java @@ -0,0 +1,4 @@ +ClassWithMethod varName = new ClassWithMethod(); +varName.methodName(argument1, argument2); +//or +new ClassWithMethod().methodName(argument1, argument2); diff --git a/Task/Call-an-object-method/PHP/call-an-object-method.php b/Task/Call-an-object-method/PHP/call-an-object-method.php new file mode 100644 index 0000000000..5177f8a2df --- /dev/null +++ b/Task/Call-an-object-method/PHP/call-an-object-method.php @@ -0,0 +1,9 @@ +// Static method +MyClass::method($someParameter); +// In PHP 5.3+, static method can be called on a string of the class name +$foo = 'MyClass'; +$foo::method($someParameter); + + +// Instance method +$myInstance->method($someParameter); diff --git a/Task/Call-an-object-method/Perl/call-an-object-method.pl b/Task/Call-an-object-method/Perl/call-an-object-method.pl new file mode 100644 index 0000000000..f85a64e0a2 --- /dev/null +++ b/Task/Call-an-object-method/Perl/call-an-object-method.pl @@ -0,0 +1,17 @@ +# Class method +MyClass->classMethod($someParameter); +# Equivalently using a class name +my $foo = 'MyClass'; +$foo->classMethod($someParameter); + + +# Instance method +$myInstance->method($someParameter); + +# Calling a method with no parameters +$myInstance->anotherMethod; + +# Class and instance method calls are made behind the scenes by getting the function from +# the package and calling it on the class name or object reference explicitly +MyClass::classMethod('MyClass', $someParameter); +MyClass::method($myInstance, $someParameter); diff --git a/Task/Call-an-object-method/PicoLisp/call-an-object-method.l b/Task/Call-an-object-method/PicoLisp/call-an-object-method.l new file mode 100644 index 0000000000..3b458c6812 --- /dev/null +++ b/Task/Call-an-object-method/PicoLisp/call-an-object-method.l @@ -0,0 +1,2 @@ +(foo> MyClass) +(foo> MyObject) diff --git a/Task/Call-an-object-method/Python/call-an-object-method.py b/Task/Call-an-object-method/Python/call-an-object-method.py new file mode 100644 index 0000000000..ab14e49f17 --- /dev/null +++ b/Task/Call-an-object-method/Python/call-an-object-method.py @@ -0,0 +1,24 @@ +class MyClass(object): + @classmethod + def myClassMethod(self, x): + pass + @staticmethod + def myStaticMethod(x): + pass + def myMethod(self, x): + return 42 + x + +myInstance = MyClass() + +# Instance method +myInstance.myMethod(someParameter) +# A method can also be retrieved as an attribute from the class, and then explicitly called on an instance: +MyClass.myMethod(myInstance, someParameter) + + +# Class or static methods +MyClass.myClassMethod(someParameter) +MyClass.myStaticMethod(someParameter) +# You can also call class or static methods on an instance, which will simply call it on the instance's class +myInstance.myClassMethod(someParameter) +myInstance.myStaticMethod(someParameter) diff --git a/Task/Call-an-object-method/Racket/call-an-object-method.rkt b/Task/Call-an-object-method/Racket/call-an-object-method.rkt new file mode 100644 index 0000000000..86a42aa7b9 --- /dev/null +++ b/Task/Call-an-object-method/Racket/call-an-object-method.rkt @@ -0,0 +1,4 @@ +#lang racket/gui + +(define timer (new timer%)) +(send timer start 100) diff --git a/Task/Call-an-object-method/Ruby/call-an-object-method.rb b/Task/Call-an-object-method/Ruby/call-an-object-method.rb new file mode 100644 index 0000000000..64ce7ef4f9 --- /dev/null +++ b/Task/Call-an-object-method/Ruby/call-an-object-method.rb @@ -0,0 +1,16 @@ +# Class method +MyClass.some_method(some_parameter) + +# Class may be computed at runtime +foo = MyClass +foo.some_method(some_parameter) + + +# Instance method +my_instance.method(some_parameter) + +# The parentheses are optional +my_instance.method some_parameter + +# Calling a method with no parameters +my_instance.another_method diff --git a/Task/Call-an-object-method/Smalltalk/call-an-object-method-1.st b/Task/Call-an-object-method/Smalltalk/call-an-object-method-1.st new file mode 100644 index 0000000000..8fe75164a3 --- /dev/null +++ b/Task/Call-an-object-method/Smalltalk/call-an-object-method-1.st @@ -0,0 +1,17 @@ +" Class " +MyClass selector: someArgument . +" or equivalently " +foo := MyClass . +foo selector: someArgument. + +" Instance " +myInstance selector: someArgument. + +" Message with multiple arguments " +myInstance fooWithRed:arg1 green:arg2 blue:arg3 . + +" Message with no arguments " +myInstance selector. + +" Binary (operator) message" +myInstance + argument . diff --git a/Task/Call-an-object-method/Smalltalk/call-an-object-method-2.st b/Task/Call-an-object-method/Smalltalk/call-an-object-method-2.st new file mode 100644 index 0000000000..05e53d78b5 --- /dev/null +++ b/Task/Call-an-object-method/Smalltalk/call-an-object-method-2.st @@ -0,0 +1 @@ +theCar := (someCondition ifTrue:[ Ford ] ifFalse: [ Jaguar ]) new. diff --git a/Task/Call-an-object-method/Smalltalk/call-an-object-method-3.st b/Task/Call-an-object-method/Smalltalk/call-an-object-method-3.st new file mode 100644 index 0000000000..81f3bc8105 --- /dev/null +++ b/Task/Call-an-object-method/Smalltalk/call-an-object-method-3.st @@ -0,0 +1,2 @@ +whichMessage := #( #'red' #'green' #'blue') at: computedIndex. +foo perform: whichMessage diff --git a/Task/Call-an-object-method/Smalltalk/call-an-object-method-4.st b/Task/Call-an-object-method/Smalltalk/call-an-object-method-4.st new file mode 100644 index 0000000000..4300e5ea69 --- /dev/null +++ b/Task/Call-an-object-method/Smalltalk/call-an-object-method-4.st @@ -0,0 +1,2 @@ +theMessage := ('handleFileType' , suffix) asSymbol. +foo perform: theMessage. diff --git a/Task/Call-an-object-method/Smalltalk/call-an-object-method-5.st b/Task/Call-an-object-method/Smalltalk/call-an-object-method-5.st new file mode 100644 index 0000000000..0f74982555 --- /dev/null +++ b/Task/Call-an-object-method/Smalltalk/call-an-object-method-5.st @@ -0,0 +1,5 @@ +[ + foo perform: theMessage +] on: MessageNotUnderstood do:[ + Dialog information: 'sorry' +] diff --git a/Task/Call-an-object-method/Tcl/call-an-object-method.tcl b/Task/Call-an-object-method/Tcl/call-an-object-method.tcl new file mode 100644 index 0000000000..8317ba7712 --- /dev/null +++ b/Task/Call-an-object-method/Tcl/call-an-object-method.tcl @@ -0,0 +1,6 @@ +package require Tcl 8.6 +# "Static" (on class object) +MyClass mthd someParameter + +# Instance +$myInstance mthd someParameter diff --git a/Task/Canny-edge-detector/0DESCRIPTION b/Task/Canny-edge-detector/0DESCRIPTION new file mode 100644 index 0000000000..2a867eba92 --- /dev/null +++ b/Task/Canny-edge-detector/0DESCRIPTION @@ -0,0 +1,8 @@ +'''Task:''' Write a program that performs so-called [[wp:Canny edge detector|canny edge detection]] on an image. + +A possible algorithm consists of the following steps: + +# '''Noise reduction.''' May be performed by [[wp:Gaussian blur|Gaussian filter]]. +# Compute '''intensity gradient''' (matrices G_x and G_y) and its '''magnitude''' G.
   G=\sqrt{G_x^2+G_y^2}
May be performed by [[image convolution|convolution of an image]] with [[wp:Sobel operator|Sobel operators]]. +# '''Non-maximum suppression.''' For each pixel compute the orientation of intensity gradient vector: \theta = {\rm atan2}\left(G_y, \, G_x\right). Transform angle \theta to one of four directions: 0, 45, 90, 135 degrees. Compute new array N: if
   G\left(p_a\right)
where p is the current pixel, p_a and p_b are the two neighbour pixels in the direction of gradient, then N(p) = G(p), otherwise N(p) = 0. Nonzero pixels in resulting array correspond to local maxima of G in direction \theta(p). +# '''Tracing edges with hysteresis.''' At this stage two thresholds for the values of G are introduced: T_{min} and T_{max}. Starting from pixels with N(p) \geqslant T_{max} find all paths of pixels with N(p) \geqslant T_{min} and put them to the resulting image. diff --git a/Task/Canny-edge-detector/C/canny-edge-detector.c b/Task/Canny-edge-detector/C/canny-edge-detector.c new file mode 100644 index 0000000000..00f3d0d7e7 --- /dev/null +++ b/Task/Canny-edge-detector/C/canny-edge-detector.c @@ -0,0 +1,453 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_BRIGHTNESS 255 + +// C99 doesn't define M_PI (GNU-C99 does) +#define M_PI 3.14159265358979323846264338327 + +/* + * Loading part taken from + * http://www.vbforums.com/showthread.php?t=261522 + * BMP info: + * http://en.wikipedia.org/wiki/BMP_file_format + * + * Note: the magic number has been removed from the bmpfile_header_t + * structure since it causes alignment problems + * bmpfile_magic_t should be written/read first + * followed by the + * bmpfile_header_t + * [this avoids compiler-specific alignment pragmas etc.] + */ + +typedef struct { + uint8_t magic[2]; +} bmpfile_magic_t; + +typedef struct { + uint32_t filesz; + uint16_t creator1; + uint16_t creator2; + uint32_t bmp_offset; +} bmpfile_header_t; + +typedef struct { + uint32_t header_sz; + int32_t width; + int32_t height; + uint16_t nplanes; + uint16_t bitspp; + uint32_t compress_type; + uint32_t bmp_bytesz; + int32_t hres; + int32_t vres; + uint32_t ncolors; + uint32_t nimpcolors; +} bitmap_info_header_t; + +typedef struct { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t nothing; +} rgb_t; + +// Use short int instead `unsigned char' so that we can +// store negative values. +typedef short int pixel_t; + +pixel_t *load_bmp(const char *filename, + bitmap_info_header_t *bitmapInfoHeader) +{ + FILE *filePtr = fopen(filename, "rb"); + if (filePtr == NULL) { + perror("fopen()"); + return NULL; + } + + bmpfile_magic_t mag; + if (fread(&mag, sizeof(bmpfile_magic_t), 1, filePtr) != 1) { + fclose(filePtr); + return NULL; + } + + // verify that this is a bmp file by check bitmap id + // warning: dereferencing type-punned pointer will break + // strict-aliasing rules [-Wstrict-aliasing] + if (*((uint16_t*)mag.magic) != 0x4D42) { + fprintf(stderr, "Not a BMP file: magic=%c%c\n", + mag.magic[0], mag.magic[1]); + fclose(filePtr); + return NULL; + } + + bmpfile_header_t bitmapFileHeader; // our bitmap file header + // read the bitmap file header + if (fread(&bitmapFileHeader, sizeof(bmpfile_header_t), + 1, filePtr) != 1) { + fclose(filePtr); + return NULL; + } + + // read the bitmap info header + if (fread(bitmapInfoHeader, sizeof(bitmap_info_header_t), + 1, filePtr) != 1) { + fclose(filePtr); + return NULL; + } + + if (bitmapInfoHeader->compress_type != 0) + fprintf(stderr, "Warning, compression is not supported.\n"); + + // move file point to the beginning of bitmap data + if (fseek(filePtr, bitmapFileHeader.bmp_offset, SEEK_SET)) { + fclose(filePtr); + return NULL; + } + + // allocate enough memory for the bitmap image data + pixel_t *bitmapImage = malloc(bitmapInfoHeader->bmp_bytesz * + sizeof(pixel_t)); + + // verify memory allocation + if (bitmapImage == NULL) { + fclose(filePtr); + return NULL; + } + + // read in the bitmap image data + size_t pad, count=0; + unsigned char c; + pad = 4*ceil(bitmapInfoHeader->bitspp*bitmapInfoHeader->width/32.) - bitmapInfoHeader->width; + for(size_t i=0; iheight; i++){ + for(size_t j=0; jwidth; j++){ + if (fread(&c, sizeof(unsigned char), 1, filePtr) != 1) { + fclose(filePtr); + return NULL; + } + bitmapImage[count++] = (pixel_t) c; + } + fseek(filePtr, pad, SEEK_CUR); + } + + // If we were using unsigned char as pixel_t, then: + // fread(bitmapImage, 1, bitmapInfoHeader->bmp_bytesz, filePtr); + + // close file and return bitmap image data + fclose(filePtr); + return bitmapImage; +} + +// Return: true on error. +bool save_bmp(const char *filename, const bitmap_info_header_t *bmp_ih, + const pixel_t *data) +{ + FILE* filePtr = fopen(filename, "wb"); + if (filePtr == NULL) + return true; + + bmpfile_magic_t mag = {{0x42, 0x4d}}; + if (fwrite(&mag, sizeof(bmpfile_magic_t), 1, filePtr) != 1) { + fclose(filePtr); + return true; + } + + const uint32_t offset = sizeof(bmpfile_magic_t) + + sizeof(bmpfile_header_t) + + sizeof(bitmap_info_header_t) + + ((1U << bmp_ih->bitspp) * 4); + + const bmpfile_header_t bmp_fh = { + .filesz = offset + bmp_ih->bmp_bytesz, + .creator1 = 0, + .creator2 = 0, + .bmp_offset = offset + }; + + if (fwrite(&bmp_fh, sizeof(bmpfile_header_t), 1, filePtr) != 1) { + fclose(filePtr); + return true; + } + if (fwrite(bmp_ih, sizeof(bitmap_info_header_t), 1, filePtr) != 1) { + fclose(filePtr); + return true; + } + + // Palette + for (size_t i = 0; i < (1U << bmp_ih->bitspp); i++) { + const rgb_t color = {(uint8_t)i, (uint8_t)i, (uint8_t)i}; + if (fwrite(&color, sizeof(rgb_t), 1, filePtr) != 1) { + fclose(filePtr); + return true; + } + } + + // We use int instead of uchar, so we can't write img + // in 1 call any more. + // fwrite(data, 1, bmp_ih->bmp_bytesz, filePtr); + + // Padding: http://en.wikipedia.org/wiki/BMP_file_format#Pixel_storage + size_t pad = 4*ceil(bmp_ih->bitspp*bmp_ih->width/32.) - bmp_ih->width; + unsigned char c; + for(size_t i=0; i < bmp_ih->height; i++) { + for(size_t j=0; j < bmp_ih->width; j++) { + c = (unsigned char) data[j + bmp_ih->width*i]; + if (fwrite(&c, sizeof(char), 1, filePtr) != 1) { + fclose(filePtr); + return true; + } + } + c = 0; + for(size_t j=0; j kn && ny > kn); + const int khalf = kn / 2; + float min = FLT_MAX, max = -FLT_MAX; + + if (normalize) + for (int m = khalf; m < nx - khalf; m++) + for (int n = khalf; n < ny - khalf; n++) { + float pixel = 0.0; + size_t c = 0; + for (int j = -khalf; j <= khalf; j++) + for (int i = -khalf; i <= khalf; i++) { + pixel += in[(n - j) * nx + m - i] * kernel[c]; + c++; + } + if (pixel < min) + min = pixel; + if (pixel > max) + max = pixel; + } + + for (int m = khalf; m < nx - khalf; m++) + for (int n = khalf; n < ny - khalf; n++) { + float pixel = 0.0; + size_t c = 0; + for (int j = -khalf; j <= khalf; j++) + for (int i = -khalf; i <= khalf; i++) { + pixel += in[(n - j) * nx + m - i] * kernel[c]; + c++; + } + + if (normalize) + pixel = MAX_BRIGHTNESS * (pixel - min) / (max - min); + out[n * nx + m] = (pixel_t)pixel; + } +} + +/* + * gaussianFilter: + * http://www.songho.ca/dsp/cannyedge/cannyedge.html + * determine size of kernel (odd #) + * 0.0 <= sigma < 0.5 : 3 + * 0.5 <= sigma < 1.0 : 5 + * 1.0 <= sigma < 1.5 : 7 + * 1.5 <= sigma < 2.0 : 9 + * 2.0 <= sigma < 2.5 : 11 + * 2.5 <= sigma < 3.0 : 13 ... + * kernelSize = 2 * int(2*sigma) + 3; + */ +void gaussian_filter(const pixel_t *in, pixel_t *out, + const int nx, const int ny, const float sigma) +{ + const int n = 2 * (int)(2 * sigma) + 3; + const float mean = (float)floor(n / 2.0); + float kernel[n * n]; // variable length array + + fprintf(stderr, "gaussian_filter: kernel size %d, sigma=%g\n", + n, sigma); + size_t c = 0; + for (int i = 0; i < n; i++) + for (int j = 0; j < n; j++) { + kernel[c] = exp(-0.5 * (pow((i - mean) / sigma, 2.0) + + pow((j - mean) / sigma, 2.0))) + / (2 * M_PI * sigma * sigma); + c++; + } + + convolution(in, out, kernel, nx, ny, n, true); +} + +/* + * Links: + * http://en.wikipedia.org/wiki/Canny_edge_detector + * http://www.tomgibara.com/computer-vision/CannyEdgeDetector.java + * http://fourier.eng.hmc.edu/e161/lectures/canny/node1.html + * http://www.songho.ca/dsp/cannyedge/cannyedge.html + * + * Note: T1 and T2 are lower and upper thresholds. + */ +pixel_t *canny_edge_detection(const pixel_t *in, + const bitmap_info_header_t *bmp_ih, + const int tmin, const int tmax, + const float sigma) +{ + const int nx = bmp_ih->width; + const int ny = bmp_ih->height; + + pixel_t *G = calloc(nx * ny * sizeof(pixel_t), 1); + pixel_t *after_Gx = calloc(nx * ny * sizeof(pixel_t), 1); + pixel_t *after_Gy = calloc(nx * ny * sizeof(pixel_t), 1); + pixel_t *nms = calloc(nx * ny * sizeof(pixel_t), 1); + pixel_t *out = malloc(bmp_ih->bmp_bytesz * sizeof(pixel_t)); + + if (G == NULL || after_Gx == NULL || after_Gy == NULL || + nms == NULL || out == NULL) { + fprintf(stderr, "canny_edge_detection:" + " Failed memory allocation(s).\n"); + exit(1); + } + + gaussian_filter(in, out, nx, ny, sigma); + + const float Gx[] = {-1, 0, 1, + -2, 0, 2, + -1, 0, 1}; + + convolution(out, after_Gx, Gx, nx, ny, 3, false); + + const float Gy[] = { 1, 2, 1, + 0, 0, 0, + -1,-2,-1}; + + convolution(out, after_Gy, Gy, nx, ny, 3, false); + + for (int i = 1; i < nx - 1; i++) + for (int j = 1; j < ny - 1; j++) { + const int c = i + nx * j; + // G[c] = abs(after_Gx[c]) + abs(after_Gy[c]); + G[c] = (pixel_t)hypot(after_Gx[c], after_Gy[c]); + } + + // Non-maximum suppression, straightforward implementation. + for (int i = 1; i < nx - 1; i++) + for (int j = 1; j < ny - 1; j++) { + const int c = i + nx * j; + const int nn = c - nx; + const int ss = c + nx; + const int ww = c + 1; + const int ee = c - 1; + const int nw = nn + 1; + const int ne = nn - 1; + const int sw = ss + 1; + const int se = ss - 1; + + const float dir = (float)(fmod(atan2(after_Gy[c], + after_Gx[c]) + M_PI, + M_PI) / M_PI) * 8; + + if (((dir <= 1 || dir > 7) && G[c] > G[ee] && + G[c] > G[ww]) || // 0 deg + ((dir > 1 && dir <= 3) && G[c] > G[nw] && + G[c] > G[se]) || // 45 deg + ((dir > 3 && dir <= 5) && G[c] > G[nn] && + G[c] > G[ss]) || // 90 deg + ((dir > 5 && dir <= 7) && G[c] > G[ne] && + G[c] > G[sw])) // 135 deg + nms[c] = G[c]; + else + nms[c] = 0; + } + + // Reuse array + // used as a stack. nx*ny/2 elements should be enough. + int *edges = (int*) after_Gy; + memset(out, 0, sizeof(pixel_t) * nx * ny); + memset(edges, 0, sizeof(pixel_t) * nx * ny); + + // Tracing edges with hysteresis . Non-recursive implementation. + size_t c = 1; + for (int j = 1; j < ny - 1; j++) + for (int i = 1; i < nx - 1; i++) { + if (nms[c] >= tmax && out[c] == 0) { // trace edges + out[c] = MAX_BRIGHTNESS; + int nedges = 1; + edges[0] = c; + + do { + nedges--; + const int t = edges[nedges]; + + int nbs[8]; // neighbours + nbs[0] = t - nx; // nn + nbs[1] = t + nx; // ss + nbs[2] = t + 1; // ww + nbs[3] = t - 1; // ee + nbs[4] = nbs[0] + 1; // nw + nbs[5] = nbs[0] - 1; // ne + nbs[6] = nbs[1] + 1; // sw + nbs[7] = nbs[1] - 1; // se + + for (int k = 0; k < 8; k++) + if (nms[nbs[k]] >= tmin && out[nbs[k]] == 0) { + out[nbs[k]] = MAX_BRIGHTNESS; + edges[nedges] = nbs[k]; + nedges++; + } + } while (nedges > 0); + } + c++; + } + + free(after_Gx); + free(after_Gy); + free(G); + free(nms); + + return out; +} + +int main(const int argc, const char ** const argv) +{ + if (argc < 2) { + printf("Usage: %s image.bmp\n", argv[0]); + return 1; + } + + static bitmap_info_header_t ih; + const pixel_t *in_bitmap_data = load_bmp(argv[1], &ih); + if (in_bitmap_data == NULL) { + fprintf(stderr, "main: BMP image not loaded.\n"); + return 1; + } + + printf("Info: %d x %d x %d\n", ih.width, ih.height, ih.bitspp); + + const pixel_t *out_bitmap_data = + canny_edge_detection(in_bitmap_data, &ih, 45, 50, 1.0f); + if (out_bitmap_data == NULL) { + fprintf(stderr, "main: failed canny_edge_detection.\n"); + return 1; + } + + if (save_bmp("out.bmp", &ih, out_bitmap_data)) { + fprintf(stderr, "main: BMP image not saved.\n"); + return 1; + } + + free((pixel_t*)in_bitmap_data); + free((pixel_t*)out_bitmap_data); + return 0; +} diff --git a/Task/Canny-edge-detector/D/canny-edge-detector.d b/Task/Canny-edge-detector/D/canny-edge-detector.d new file mode 100644 index 0000000000..d8e63c5629 --- /dev/null +++ b/Task/Canny-edge-detector/D/canny-edge-detector.d @@ -0,0 +1,201 @@ +import core.stdc.stdio, std.math, std.typecons, std.string, + std.algorithm, std.ascii, std.array, bitmap, grayscale_image; + +enum maxBrightness = 255; + +alias short Pixel; + +// If normalize is true, map pixels to range 0...maxBrightness. +void convolution(bool normalize)(in Pixel[] inp, Pixel[] outp, + in float[] kernel, + in int nx, in int ny, in int kn) +pure nothrow in { + assert(kernel.length == kn ^^ 2); + assert(kn % 2 == 1); + assert(nx > kn && ny > kn); + assert(inp.length == outp.length); +} body { + //immutable int kn = sqrti(kernel.length); + immutable int khalf = kn / 2; + + static if (normalize) { + float pMin = float.max, pMax = -float.max; + + foreach (immutable m; khalf .. nx - khalf) { + foreach (immutable n; khalf .. ny - khalf) { + float pixel = 0.0; + size_t c; + foreach (immutable j; -khalf .. khalf + 1) { + foreach (immutable i; -khalf .. khalf + 1) { + pixel += inp[(n - j) * nx + m - i] * kernel[c]; + c++; + } + } + + if (pixel < pMin) pMin = pixel; + if (pixel > pMax) pMax = pixel; + } + } + } + + foreach (immutable m; khalf .. nx - khalf) { + foreach (immutable n; khalf .. ny - khalf) { + float pixel = 0.0; + size_t c; + foreach (immutable j; -khalf .. khalf + 1) { + foreach (immutable i; -khalf .. khalf + 1) { + pixel += inp[(n - j) * nx + m - i] * kernel[c]; + c++; + } + } + + static if (normalize) + pixel = maxBrightness * (pixel - pMin) / (pMax - pMin); + outp[n * nx + m] = cast(Pixel)pixel; + } + } +} + + +void gaussianFilter(in Pixel[] inp, Pixel[] outp, + in int nx, in int ny, in float sigma) +/*pure*/ nothrow in { + assert(inp.length == outp.length); +} body { + immutable int n = 2 * cast(int)(2 * sigma) + 3; + immutable float mean = cast(float)floor(n / 2.0); // Not pure. + auto kernel = new float[n * n]; + + debug fprintf(stderr, + "gaussianFilter: kernel size %d, sigma=%g\n", + n, sigma); + + size_t c; + foreach (immutable i; 0 .. n) { + foreach (immutable j; 0 .. n) { + kernel[c] = exp(-0.5 * (((i - mean) / sigma) ^^ 2 + + ((j - mean) / sigma) ^^ 2)) + / (2 * PI * sigma * sigma); + c++; + } + } + + convolution!true(inp, outp, kernel, nx, ny, n); +} + + +Image!Pixel cannyEdgeDetection(in Image!Pixel inp, + in int tMin, in int tMax, + in float sigma) +nothrow in { + assert(inp !is null); +} body { + immutable int nx = inp.nx; + immutable int ny = inp.ny; + auto outp = new Pixel[nx * ny]; + + gaussianFilter(inp.image, outp, nx, ny, sigma); + + immutable float[] Gx = [-1, 0, 1, + -2, 0, 2, + -1, 0, 1]; + auto after_Gx = new Pixel[nx * ny]; + convolution!false(outp, after_Gx, Gx, nx, ny, 3); + + immutable float[] Gy = [ 1, 2, 1, + 0, 0, 0, + -1,-2,-1]; + auto after_Gy = new Pixel[nx * ny]; + convolution!false(outp, after_Gy, Gy, nx, ny, 3); + + auto G = new Pixel[nx * ny]; + foreach (i; 1 .. nx - 1) + foreach (j; 1 .. ny - 1) { + immutable size_t c = i + nx * j; + G[c] = cast(Pixel)hypot(after_Gx[c], after_Gy[c]); + } + + // Non-maximum suppression, straightforward implementation. + auto nms = new Pixel[nx * ny]; + foreach (immutable i; 1 .. nx - 1) + foreach (immutable j; 1 .. ny - 1) { + immutable int c = i + nx * j, + nn = c - nx, + ss = c + nx, + ww = c + 1, + ee = c - 1, + nw = nn + 1, + ne = nn - 1, + sw = ss + 1, + se = ss - 1; + + immutable float dir = + cast(float)(fmod(atan2(cast(double)after_Gy[c], + cast(double)after_Gx[c]) + PI, + PI) / PI) * 8; + + if (((dir <= 1 || dir > 7) && G[c] > G[ee] && + G[c] > G[ww]) || // 0 deg. + ((dir > 1 && dir <= 3) && G[c] > G[nw] && + G[c] > G[se]) || // 45 deg. + ((dir > 3 && dir <= 5) && G[c] > G[nn] && + G[c] > G[ss]) || // 90 deg. + ((dir > 5 && dir <= 7) && G[c] > G[ne] && + G[c] > G[sw])) // 135 deg. + nms[c] = G[c]; + else + nms[c] = 0; + } + + // Reuse array used as a stack. nx*ny/2 elements should be enough. + int[] edges = (cast(int*)after_Gy.ptr)[0 .. after_Gy.length / 2]; + outp[] = Pixel.init; + edges[] = 0; + + // Tracing edges with hysteresis. Non-recursive implementation. + size_t c = 1; + foreach (immutable j; 1 .. ny - 1) { + foreach (immutable i; 1 .. nx - 1) { + if (nms[c] >= tMax && outp[c] == 0) { // Trace edges. + outp[c] = maxBrightness; + int nedges = 1; + edges[0] = c; + + do { + nedges--; + immutable int t = edges[nedges]; + + int[8] neighbours = void; + neighbours[0] = t - nx; // nn + neighbours[1] = t + nx; // ss + neighbours[2] = t + 1; // ww + neighbours[3] = t - 1; // ee + neighbours[4] = neighbours[0] + 1; // nw + neighbours[5] = neighbours[0] - 1; // ne + neighbours[6] = neighbours[1] + 1; // sw + neighbours[7] = neighbours[1] - 1; // se + + foreach (immutable k; 0 .. 8) + if (nms[neighbours[k]] >= tMin && + outp[neighbours[k]] == 0) { + outp[neighbours[k]] = maxBrightness; + edges[nedges] = neighbours[k]; + nedges++; + } + } while (nedges > 0); + } + c++; + } + } + + return Image!Pixel.fromData(outp, nx, ny); +} + + +void main(in string[] args) { + immutable fileName = (args.length == 2) ? args[1] : "lena.pgm"; + Image!Pixel imIn; + imIn.loadPGM(fileName); + printf("Image sizes: %d x %d\n", imIn.nx, imIn.ny); + cannyEdgeDetection(imIn, 45, 50, 1.0f).savePGM("lena_canny.pgm"); +} diff --git a/Task/Canny-edge-detector/Tcl/canny-edge-detector.tcl b/Task/Canny-edge-detector/Tcl/canny-edge-detector.tcl new file mode 100644 index 0000000000..ad354aca1a --- /dev/null +++ b/Task/Canny-edge-detector/Tcl/canny-edge-detector.tcl @@ -0,0 +1,17 @@ +package require crimp +package require crimp::pgm + +proc readPGM {filename} { + set f [open $filename rb] + set data [read $f] + close $f + return [crimp read pgm $data] +} +proc writePGM {filename image} { + crimp write 2file pgm-raw $filename $image +} + +proc cannyFilterFile {{inputFile "lena.pgm"} {outputFile "lena_canny.pgm"}} { + writePGM $outputFile [crimp filter canny sobel [readPGM $inputFile]] +} +cannyFilterFile {*}$argv diff --git a/Task/Carmichael-3-strong-pseudoprimes/0DESCRIPTION b/Task/Carmichael-3-strong-pseudoprimes/0DESCRIPTION new file mode 100644 index 0000000000..d1da1f67b2 --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/0DESCRIPTION @@ -0,0 +1,18 @@ +A lot of composite numbers can be separated from primes by Fermat's Little Theorem, but there are some that completely confound it. The [[Miller-Rabin primality test|Miller Rabin Test]] uses a combination of Fermat's Little Theorem and Chinese Division Theorem to overcome this. + +The purpose of this task is to investigate such numbers using a method based on [[wp:Carmichael number|Carmichael numbers]], as suggested in [http://www.maths.lancs.ac.uk/~jameson/carfind.pdf Notes by G.J.O Jameson March 2010]. + +The objective is to find Carmichael numbers of the form Prime_1 \times Prime_2 \times Prime_3 (where Prime_1 < Prime_2 < Prime_3) for all Prime_1 up to 61 (see page 7 of [http://www.maths.lancs.ac.uk/~jameson/carfind.pdf Notes by G.J.O Jameson March 2010] for solutions). + +'''Pseudocode:'''
For a given Prime_1 + +for 1 < h3 < Prime1 +:for 0 < d < h3+Prime1 +::if (h3+Prime1)*(Prime1-1) mod d == 0 and -Prime1 squared mod h3 == d mod h3 +::then +:::Prime2 = 1 + ((Prime1-1) * (h3+Prime1)/d) +:::next d if Prime2 is not prime +:::Prime3 = 1 + (Prime1*Prime2/h3) +:::next d if Prime3 is not prime +:::next d if (Prime2*Prime3) mod (Prime1-1) not equal 1 +:::Prime1 * Prime2 * Prime3 is a Carmichael Number diff --git a/Task/Carmichael-3-strong-pseudoprimes/Ada/carmichael-3-strong-pseudoprimes.ada b/Task/Carmichael-3-strong-pseudoprimes/Ada/carmichael-3-strong-pseudoprimes.ada new file mode 100644 index 0000000000..0a15563767 --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/Ada/carmichael-3-strong-pseudoprimes.ada @@ -0,0 +1,41 @@ +with Ada.Text_IO, Miller_Rabin; + +procedure Nemesis is + + type Number is range 0 .. 2**40-1; -- sufficiently large for the task + + function Is_Prime(N: Number) return Boolean is + package MR is new Miller_Rabin(Number); use MR; + begin + return MR.Is_Prime(N) = Probably_Prime; + end Is_Prime; + +begin + for P1 in Number(2) .. 61 loop + if Is_Prime(P1) then + for H3 in Number(1) .. P1 loop + declare + G: Number := H3 + P1; + P2, P3: Number; + begin + Inner: + for D in 1 .. G-1 loop + if ((H3+P1) * (P1-1)) mod D = 0 and then + (-(P1 * P1)) mod H3 = D mod H3 + then + P2 := 1 + ((P1-1) * G / D); + P3 := 1 +(P1*P2/H3); + if Is_Prime(P2) and then Is_Prime(P3) + and then (P2*P3) mod (P1-1) = 1 + then + Ada.Text_IO.Put_Line + ( Number'Image(P1) & " *" & Number'Image(P2) & " *" & + Number'Image(P3) & " = " & Number'Image(P1*P2*P3) ); + end if; + end if; + end loop Inner; + end; + end loop; + end if; + end loop; +end Nemesis; diff --git a/Task/Carmichael-3-strong-pseudoprimes/D/carmichael-3-strong-pseudoprimes.d b/Task/Carmichael-3-strong-pseudoprimes/D/carmichael-3-strong-pseudoprimes.d new file mode 100644 index 0000000000..b674ff462f --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/D/carmichael-3-strong-pseudoprimes.d @@ -0,0 +1,23 @@ +import std.stdio, sieve_of_eratosthenes3; + +int mod(in int n, in int m) pure nothrow { + return ((n % m) + m) % m; +} + +void main() { + foreach (immutable p; 2 .. 62) { + if (!p.IsPrime) continue; + foreach (immutable h3; 2 .. p) { + immutable g = h3 + p; + foreach (immutable d; 1 .. g) { + if ((g * (p - 1)) % d != 0 || mod(-p * p, h3) != d % h3) + continue; + immutable q = 1 + (p - 1) * g / d; + if (!q.IsPrime) continue; + immutable r = 1 + (p * q / h3); + if (!r.IsPrime || (q * r) % (p - 1) != 1) continue; + writeln(p, " x ", q, " x ", r); + } + } + } +} diff --git a/Task/Carmichael-3-strong-pseudoprimes/Haskell/carmichael-3-strong-pseudoprimes.hs b/Task/Carmichael-3-strong-pseudoprimes/Haskell/carmichael-3-strong-pseudoprimes.hs new file mode 100644 index 0000000000..edb779d13b --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/Haskell/carmichael-3-strong-pseudoprimes.hs @@ -0,0 +1,18 @@ +#!/usr/bin/runhaskell + +import Data.Numbers.Primes +import Control.Monad (guard) + +carmichaels = do + p <- takeWhile (<= 61) primes + h3 <- [2..(p-1)] + let g = h3 + p + d <- [1..(g-1)] + guard $ (g * (p - 1)) `mod` d == 0 && (-1 * p * p) `mod` h3 == d `mod` h3 + let q = 1 + (((p - 1) * g) `div` d) + guard $ isPrime q + let r = 1 + ((p * q) `div` h3) + guard $ isPrime r && (q * r) `mod` (p - 1) == 1 + return (p, q, r) + +main = putStr $ unlines $ map show carmichaels diff --git a/Task/Carmichael-3-strong-pseudoprimes/Python/carmichael-3-strong-pseudoprimes.py b/Task/Carmichael-3-strong-pseudoprimes/Python/carmichael-3-strong-pseudoprimes.py new file mode 100644 index 0000000000..66cc034699 --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/Python/carmichael-3-strong-pseudoprimes.py @@ -0,0 +1,71 @@ +class Isprime(): + ''' + Extensible sieve of Erastosthenes + + >>> isprime.check(11) + True + >>> isprime.multiples + {2, 4, 6, 8, 9, 10} + >>> isprime.primes + [2, 3, 5, 7, 11] + >>> isprime(13) + True + >>> isprime.multiples + {2, 4, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 18, 20, 21, 22} + >>> isprime.primes + [2, 3, 5, 7, 11, 13, 17, 19] + >>> isprime.nmax + 22 + >>> + ''' + multiples = {2} + primes = [2] + nmax = 2 + + def __init__(self, nmax): + if nmax > self.nmax: + self.check(nmax) + + def check(self, n): + if type(n) == float: + if not n.is_integer(): return False + n = int(n) + multiples = self.multiples + if n <= self.nmax: + return n not in multiples + else: + # Extend the sieve + primes, nmax = self.primes, self.nmax + newmax = max(nmax*2, n) + for p in primes: + multiples.update(range(p*((nmax + p + 1) // p), newmax+1, p)) + for i in range(nmax+1, newmax+1): + if i not in multiples: + primes.append(i) + multiples.update(range(i*2, newmax+1, i)) + self.nmax = newmax + return n not in multiples + + __call__ = check + + +def carmichael(p1): + ans = [] + if isprime(p1): + for h3 in range(2, p1): + g = h3 + p1 + for d in range(1, g): + if (g * (p1 - 1)) % d == 0 and (-p1 * p1) % h3 == d % h3: + p2 = 1 + ((p1 - 1)* g // d) + if isprime(p2): + p3 = 1 + (p1 * p2 // h3) + if isprime(p3): + if (p2 * p3) % (p1 - 1) == 1: + #print('%i X %i X %i' % (p1, p2, p3)) + ans += [tuple(sorted((p1, p2, p3)))] + return ans + +isprime = Isprime(2) + +ans = sorted(sum((carmichael(n) for n in range(62) if isprime(n)), [])) +print(',\n'.join(repr(ans[i:i+5])[1:-1] for i in range(0, len(ans)+1, 5))) diff --git a/Task/Carmichael-3-strong-pseudoprimes/REXX/carmichael-3-strong-pseudoprimes-1.rexx b/Task/Carmichael-3-strong-pseudoprimes/REXX/carmichael-3-strong-pseudoprimes-1.rexx new file mode 100644 index 0000000000..baddfac89a --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/REXX/carmichael-3-strong-pseudoprimes-1.rexx @@ -0,0 +1,37 @@ +/*REXX program calculates Carmichael 3-strong pseudoprimes (up to N).*/ +numeric digits 30 /*in case user wants bigger nums.*/ +parse arg N .; if N=='' then N=61 /*allow user to specify the limit*/ +if 1=='f1'x then times='af'x /*if EBCDIC machine, use a bullet*/ + else times='f9'x /* " ASCII " " " " */ +carms=0 /*number of Carmichael #s so far.*/ +!.=0 /*a method of prime memoization. */ + do p=3 to N by 2; if \isPrime(p) then iterate /*Not prime? Skip.*/ + pm=p-1; nps=-p*p; @.=0; min=1e9; max=0 /*some handy-dandy variables.*/ + do h3=2 to pm; g=h3+p /*find Carmichael #s for this P. */ + do d=1 to g-1 + if g*pm//d\==0 then iterate + if ((nps//h3)+h3)//h3\==d//h3 then iterate + q=1+pm*g%d; if \isPrime(q) then iterate + r=1+p*q%h3; if q*r//pm\==1 then iterate + if \isPrime(r) then iterate + carms=carms+1 /*bump the Carmichael # counter. */ + min=min(min,q); max=max(max,q); @.q=r /*build a list.*/ + end /*d*/ + end /*h3*/ + /*display a list of some Carm #s.*/ + do j=min to max by 2; if @.j==0 then iterate /*one of the #s?*/ + say '──────── a Carmichael number: ' p times j times @.j + end /*j*/ + say /*show bueatification blank line.*/ + end /*p*/ +say; say carms ' Carmichael numbers found.' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────ISPRIME subroutine──────────────────*/ +isPrime: procedure expose !.; parse arg x; if !.x then return 1 +if wordpos(x,'2 3 5 7 11 13')\==0 then do; !.x=1; return 1; end +if x<17 then return 0; if x//2==0 then return 0; if x//3==0 then return 0 +if right(x,1)==5 then return 0; if x//7==0 then return 0 + do i=11 by 6 until i*i>x; if x// i ==0 then return 0 + if x//(i+2) ==0 then return 0 + end /*i*/ +!.x=1; return 1 diff --git a/Task/Carmichael-3-strong-pseudoprimes/REXX/carmichael-3-strong-pseudoprimes-2.rexx b/Task/Carmichael-3-strong-pseudoprimes/REXX/carmichael-3-strong-pseudoprimes-2.rexx new file mode 100644 index 0000000000..72af76c507 --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/REXX/carmichael-3-strong-pseudoprimes-2.rexx @@ -0,0 +1,40 @@ +/*REXX program calculates Carmichael 3-strong pseudoprimes (up to N).*/ +numeric digits 30 /*in case user wants bigger nums.*/ +parse arg N .; if N=='' then N=61 /*allow user to specify the limit*/ +if 1=='f1'x then times='af'x /*if EBCDIC machine, use a bullet*/ + else times='f9'x /* " ASCII " " " " */ +carms=0 /*number of Carmichael #s so far.*/ +!.=0 /*a method of prime memoization. */ + /*Carmichael numbers aren't even.*/ + do p=3 to N by 2; if \isPrime(p) then iterate /*Not prime? Skip.*/ + pm=p-1; nps=-p*p; @.=0; min=1e9; max=0 /*some handy-dandy variables.*/ + + do h3=2 to pm; g=h3+p /*find Carmichael #s for this P. */ + do d=1 to g-1 + if g*pm//d\==0 then iterate + if ((nps//h3)+h3)//h3\==d//h3 then iterate + q=1+pm*g%d; if \isPrime(q) then iterate + r=1+p*q%h3; if q*r//pm\==1 then iterate + if \isPrime(r) then iterate + carms=carms+1 /*bump the Carmichael # counter. */ + min=min(min,q); max=max(max,q); @.q=r /*build a list.*/ + end /*d*/ + end /*h3*/ + /*display a list of some Carm #s.*/ + do j=min to max by 2; if @.j==0 then iterate /*one of the #s?*/ + say '──────── a Carmichael number: ' p times j times @.j + end /*j*/ + say /*show bueatification blank line.*/ + end /*p*/ + +say; say carms ' Carmichael numbers found.' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────ISPRIME subroutine──────────────────*/ +isPrime: procedure expose !.; parse arg x; if !.x then return 1 +if wordpos(x,'2 3 5 7 11 13')\==0 then do; !.x=1; return 1; end +if x<17 then return 0; if x//2==0 then return 0; if x//3==0 then return 0 +if right(x,1)==5 then return 0; if x//7==0 then return 0 + do i=11 by 6 until i*i>x; if x// i ==0 then return 0 + if x//(i+2) ==0 then return 0 + end /*i*/ +!.x=1; return 1 diff --git a/Task/Carmichael-3-strong-pseudoprimes/Ruby/carmichael-3-strong-pseudoprimes.rb b/Task/Carmichael-3-strong-pseudoprimes/Ruby/carmichael-3-strong-pseudoprimes.rb new file mode 100644 index 0000000000..5ff00fb73a --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/Ruby/carmichael-3-strong-pseudoprimes.rb @@ -0,0 +1,21 @@ +# Generate Charmichael Numbers +# +# Nigel_Galloway +# November 30th., 2012. +# +require 'prime' + +Integer.each_prime(61) {|p| + (2...p).each {|h3| + g = h3 + p + (1...g).each {|d| + next if (g*(p-1)) % d != 0 or (-1*p*p) % h3 != d % h3 + q = 1 + ((p - 1) * g / d) + next if not q.prime? + r = 1 + (p * q / h3) + next if not r.prime? or not (q * r) % (p - 1) == 1 + puts "#{p} X #{q} X #{r}" + } + } + puts "" +} diff --git a/Task/Carmichael-3-strong-pseudoprimes/Tcl/carmichael-3-strong-pseudoprimes-1.tcl b/Task/Carmichael-3-strong-pseudoprimes/Tcl/carmichael-3-strong-pseudoprimes-1.tcl new file mode 100644 index 0000000000..0c44ef4c9f --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/Tcl/carmichael-3-strong-pseudoprimes-1.tcl @@ -0,0 +1,23 @@ +proc carmichael {limit {rounds 10}} { + set carmichaels {} + for {set p1 2} {$p1 <= $limit} {incr p1} { + if {![miller_rabin $p1 $rounds]} continue + for {set h3 2} {$h3 < $p1} {incr h3} { + set g [expr {$h3 + $p1}] + for {set d 1} {$d < $h3+$p1} {incr d} { + if {(($h3+$p1)*($p1-1))%$d != 0} continue + if {(-($p1**2))%$h3 != $d%$h3} continue + + set p2 [expr {1 + ($p1-1)*$g/$d}] + if {![miller_rabin $p2 $rounds]} continue + + set p3 [expr {1 + $p1*$p2/$h3}] + if {![miller_rabin $p3 $rounds]} continue + + if {($p2*$p3)%($p1-1) != 1} continue + lappend carmichaels $p1 $p2 $p3 [expr {$p1*$p2*$p3}] + } + } + } + return $carmichaels +} diff --git a/Task/Carmichael-3-strong-pseudoprimes/Tcl/carmichael-3-strong-pseudoprimes-2.tcl b/Task/Carmichael-3-strong-pseudoprimes/Tcl/carmichael-3-strong-pseudoprimes-2.tcl new file mode 100644 index 0000000000..b30be78544 --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/Tcl/carmichael-3-strong-pseudoprimes-2.tcl @@ -0,0 +1,5 @@ +set results [carmichael 61 2] +puts "[expr {[llength $results]/4}] Carmichael numbers found" +foreach {p1 p2 p3 c} $results { + puts "$p1 x $p2 x $p3 = $c" +} diff --git a/Task/Case-sensitivity-of-identifiers/0DESCRIPTION b/Task/Case-sensitivity-of-identifiers/0DESCRIPTION new file mode 100644 index 0000000000..578a528f95 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/0DESCRIPTION @@ -0,0 +1,10 @@ +Three dogs (Are there three dogs or one dog?) is a code snippet used to illustrate the lettercase sensitivity of the programming language. For a case-sensitive language, the identifiers dog, Dog and DOG are all different and we should get the output: + +The three dogs are named Benjamin, Samba and Bernie. + +For a language that is lettercase insensitive, we get the following output: + +There is just one dog named Bernie. + +;Cf.: +* [[Unicode variable names]] diff --git a/Task/Case-sensitivity-of-identifiers/1META.yaml b/Task/Case-sensitivity-of-identifiers/1META.yaml new file mode 100644 index 0000000000..dfd83ba92a --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Case Sensitivity diff --git a/Task/Case-sensitivity-of-identifiers/AWK/case-sensitivity-of-identifiers.awk b/Task/Case-sensitivity-of-identifiers/AWK/case-sensitivity-of-identifiers.awk new file mode 100644 index 0000000000..888a97e8da --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/AWK/case-sensitivity-of-identifiers.awk @@ -0,0 +1,6 @@ +BEGIN { + dog = "Benjamin" + Dog = "Samba" + DOG = "Bernie" + printf "The three dogs are named %s, %s and %s.\n", dog, Dog, DOG +} diff --git a/Task/Case-sensitivity-of-identifiers/Ada/case-sensitivity-of-identifiers.ada b/Task/Case-sensitivity-of-identifiers/Ada/case-sensitivity-of-identifiers.ada new file mode 100644 index 0000000000..76dfe613ba --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Ada/case-sensitivity-of-identifiers.ada @@ -0,0 +1,6 @@ +with Ada.Text_IO; +procedure Dogs is + Dog : String := "Bernie"; +begin + Ada.Text_IO.Put_Line ("There is just one dog named " & DOG); +end Dogs; diff --git a/Task/Case-sensitivity-of-identifiers/AutoHotkey/case-sensitivity-of-identifiers.ahk b/Task/Case-sensitivity-of-identifiers/AutoHotkey/case-sensitivity-of-identifiers.ahk new file mode 100644 index 0000000000..4c78c8beaf --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/AutoHotkey/case-sensitivity-of-identifiers.ahk @@ -0,0 +1,4 @@ +dog := "Benjamin" +Dog := "Samba" +DOG := "Bernie" +MsgBox There is just one dog named %dOG% diff --git a/Task/Case-sensitivity-of-identifiers/BBC-BASIC/case-sensitivity-of-identifiers.bbc b/Task/Case-sensitivity-of-identifiers/BBC-BASIC/case-sensitivity-of-identifiers.bbc new file mode 100644 index 0000000000..c8e8572834 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/BBC-BASIC/case-sensitivity-of-identifiers.bbc @@ -0,0 +1,4 @@ + dog$ = "Benjamin" + Dog$ = "Samba" + DOG$ = "Bernie" + PRINT "The three dogs are " dog$ ", " Dog$ " and " DOG$ "." diff --git a/Task/Case-sensitivity-of-identifiers/Brlcad/case-sensitivity-of-identifiers.brlcad b/Task/Case-sensitivity-of-identifiers/Brlcad/case-sensitivity-of-identifiers.brlcad new file mode 100644 index 0000000000..62cb95eef8 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Brlcad/case-sensitivity-of-identifiers.brlcad @@ -0,0 +1,6 @@ +opendb dogs.g y # Create a database to hold our dogs +units ft # The dogs are measured in feet +in dog.s sph 0 0 0 1 # Benjie is a little Scottie dog +in Dog.s sph 4 0 0 3 # Samba is a Labrador +in DOG.s sph 13 0 0 5 # Bernie is massive. He is a New Foundland +echo The three dogs are named Benjamin, Samba and Bernie diff --git a/Task/Case-sensitivity-of-identifiers/C-sharp/case-sensitivity-of-identifiers.cs b/Task/Case-sensitivity-of-identifiers/C-sharp/case-sensitivity-of-identifiers.cs new file mode 100644 index 0000000000..1b0acc88ea --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/C-sharp/case-sensitivity-of-identifiers.cs @@ -0,0 +1,12 @@ +using System; + +class Program +{ + static void Main(string[] args) + { + string dog = "Benjamin"; + string Dog = "Samba"; + string DOG = "Bernie"; + Console.WriteLine(string.Format("The three dogs are named {0}, {1}, and {2}.", dog, Dog, DOG)); + } +} diff --git a/Task/Case-sensitivity-of-identifiers/C/case-sensitivity-of-identifiers.c b/Task/Case-sensitivity-of-identifiers/C/case-sensitivity-of-identifiers.c new file mode 100644 index 0000000000..b19132355f --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/C/case-sensitivity-of-identifiers.c @@ -0,0 +1,11 @@ +#include + +static const char *dog = "Benjamin"; +static const char *Dog = "Samba"; +static const char *DOG = "Bernie"; + +int main() +{ + printf("The three dogs are named %s, %s and %s.\n", dog, Dog, DOG); + return 0; +} diff --git a/Task/Case-sensitivity-of-identifiers/COBOL/case-sensitivity-of-identifiers.cobol b/Task/Case-sensitivity-of-identifiers/COBOL/case-sensitivity-of-identifiers.cobol new file mode 100644 index 0000000000..fa4d953536 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/COBOL/case-sensitivity-of-identifiers.cobol @@ -0,0 +1,21 @@ +* Case sensitivity of identifiers + *>* Commented-out lines in the working storage + *>* are considered as invalid redefinitions + *>* of ''dog'' that can only be ambiguously + *>* referenced in the procedure body. + + IDENTIFICATION DIVISION. + PROGRAM-ID. case-sensitivity. + DATA DIVISION. + WORKING-STORAGE SECTION. + *>* 01 dog PICTURE X(8) VALUE IS "Benjamin". + *>* 01 Dog PICTURE X(5) VALUE IS "Samba". + 01 DOG PICTURE X(6) VALUE IS "Bernie". + PROCEDURE DIVISION. + DISPLAY + *>* "The three dogs are named " + *>* dog ", " Dog " and " DOG "." + "There is just one dog named " DOG "." + END-DISPLAY + STOP RUN. + END PROGRAM case-sensitivity. diff --git a/Task/Case-sensitivity-of-identifiers/CoffeeScript/case-sensitivity-of-identifiers-1.coffee b/Task/Case-sensitivity-of-identifiers/CoffeeScript/case-sensitivity-of-identifiers-1.coffee new file mode 100644 index 0000000000..c1fbf553b3 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/CoffeeScript/case-sensitivity-of-identifiers-1.coffee @@ -0,0 +1,4 @@ +dog="Benjamin" +Dog = "Samba" +DOG = "Bernie" +console.log "The three dogs are names #{dog}, #{Dog}, and #{DOG}." diff --git a/Task/Case-sensitivity-of-identifiers/CoffeeScript/case-sensitivity-of-identifiers-2.coffee b/Task/Case-sensitivity-of-identifiers/CoffeeScript/case-sensitivity-of-identifiers-2.coffee new file mode 100644 index 0000000000..55725ef0ca --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/CoffeeScript/case-sensitivity-of-identifiers-2.coffee @@ -0,0 +1,2 @@ +> coffee foo.coffee +The three dogs are names Benjamin, Samba, and Bernie. diff --git a/Task/Case-sensitivity-of-identifiers/Common-Lisp/case-sensitivity-of-identifiers.lisp b/Task/Case-sensitivity-of-identifiers/Common-Lisp/case-sensitivity-of-identifiers.lisp new file mode 100644 index 0000000000..91e4831189 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Common-Lisp/case-sensitivity-of-identifiers.lisp @@ -0,0 +1,15 @@ +CL-USER> (let* ((dog "Benjamin") (Dog "Samba") (DOG "Bernie")) + (format nil "There is just one dog named ~a." dog)) +; in: LAMBDA NIL +; (LET* ((DOG "Benjamin") (DOG "Samba") (DOG "Bernie")) +; (FORMAT NIL "There is just one dog named ~a." DOG)) +; +; caught STYLE-WARNING: +; The variable DOG is defined but never used. +; +; caught STYLE-WARNING: +; The variable DOG is defined but never used. +; +; compilation unit finished +; caught 2 STYLE-WARNING conditions +"There is just one dog named Bernie." diff --git a/Task/Case-sensitivity-of-identifiers/D/case-sensitivity-of-identifiers.d b/Task/Case-sensitivity-of-identifiers/D/case-sensitivity-of-identifiers.d new file mode 100644 index 0000000000..c140100011 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/D/case-sensitivity-of-identifiers.d @@ -0,0 +1,10 @@ +import std.stdio; + +void main() { + string dog = "Benjamin"; + // identifiers that start with capital letters are type names + string Dog = "Samba"; + string DOG = "Bernie"; + writefln("There are three dogs named ", + dog, ", ", Dog, ", and ", DOG, "'"); +} diff --git a/Task/Case-sensitivity-of-identifiers/DWScript/case-sensitivity-of-identifiers.dwscript b/Task/Case-sensitivity-of-identifiers/DWScript/case-sensitivity-of-identifiers.dwscript new file mode 100644 index 0000000000..dd2078f48c --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/DWScript/case-sensitivity-of-identifiers.dwscript @@ -0,0 +1,7 @@ +var dog : String; + +dog := 'Benjamin'; +Dog := 'Samba'; +DOG := 'Bernie'; + +PrintLn('There is just one dog named ' + dog); diff --git a/Task/Case-sensitivity-of-identifiers/Delphi/case-sensitivity-of-identifiers.delphi b/Task/Case-sensitivity-of-identifiers/Delphi/case-sensitivity-of-identifiers.delphi new file mode 100644 index 0000000000..f5d676af08 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Delphi/case-sensitivity-of-identifiers.delphi @@ -0,0 +1,12 @@ +program CaseSensitiveIdentifiers; + +{$APPTYPE CONSOLE} + +var + dog: string; +begin + dog := 'Benjamin'; + Dog := 'Samba'; + DOG := 'Bernie'; + Writeln('There is just one dog named ' + dog); +end. diff --git a/Task/Case-sensitivity-of-identifiers/Euphoria/case-sensitivity-of-identifiers.euphoria b/Task/Case-sensitivity-of-identifiers/Euphoria/case-sensitivity-of-identifiers.euphoria new file mode 100644 index 0000000000..7bbee06105 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Euphoria/case-sensitivity-of-identifiers.euphoria @@ -0,0 +1,5 @@ +-- These variables are all different +sequence dog = "Benjamin" +sequence Dog = "Samba" +sequence DOG = "Bernie" +printf( 1, "The three dogs are named %s, %s and %s\n", {dog, Dog, DOG} ) diff --git a/Task/Case-sensitivity-of-identifiers/Fortran/case-sensitivity-of-identifiers.f b/Task/Case-sensitivity-of-identifiers/Fortran/case-sensitivity-of-identifiers.f new file mode 100644 index 0000000000..1bcf36d9d9 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Fortran/case-sensitivity-of-identifiers.f @@ -0,0 +1,16 @@ +program Example + implicit none + + character(8) :: dog, Dog, DOG + + dog = "Benjamin" + Dog = "Samba" + DOG = "Bernie" + + if (dog == DOG) then + write(*,*) "There is just one dog named ", dog + else + write(*,*) "The three dogs are named ", dog, Dog, " and ", DOG + end if + +end program Example diff --git a/Task/Case-sensitivity-of-identifiers/Go/case-sensitivity-of-identifiers-1.go b/Task/Case-sensitivity-of-identifiers/Go/case-sensitivity-of-identifiers-1.go new file mode 100644 index 0000000000..46806ae080 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Go/case-sensitivity-of-identifiers-1.go @@ -0,0 +1,19 @@ +package dogs + +import "fmt" + +// Three variables, three different names. +// (It wouldn't compile if the compiler saw the variable names as the same.) +var dog = "Salt" +var Dog = "Pepper" +var DOG = "Mustard" + +func PackageSees() map[*string]int { + // Print dogs visible from here. + fmt.Println("Package sees:", dog, Dog, DOG) + // Return addresses of the variables visible from here. + // The point of putting them in a map is that maps store only + // unique keys, so it will end up with three items only if + // the variables really represent different places in memory. + return map[*string]int{&dog: 1, &Dog: 1, &DOG: 1} +} diff --git a/Task/Case-sensitivity-of-identifiers/Go/case-sensitivity-of-identifiers-2.go b/Task/Case-sensitivity-of-identifiers/Go/case-sensitivity-of-identifiers-2.go new file mode 100644 index 0000000000..1242871706 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Go/case-sensitivity-of-identifiers-2.go @@ -0,0 +1,47 @@ +package main + +import ( + . "dogs" + "fmt" +) + +func main() { + // with the dogs package imported, there are three dogs. + d := PackageSees() + fmt.Println("There are", len(d), "dogs.\n") + + // Declaration of new variable dog. It lives in this package, main. + dog := "Benjamin" + d = PackageSees() + fmt.Println("Main sees: ", dog, Dog, DOG) + // Four dogs now. two of the three visible from here are the + // the same as ones in the dogs package. + d[&dog] = 1 + d[&Dog] = 1 + d[&DOG] = 1 + fmt.Println("There are", len(d), "dogs.\n") + + // Not a declaration, just an assigment. This assigns a new value to + // the variable Dog declared in the package. Dog is visible because + // it begins with an upper case letter. + Dog = "Samba" + // same four dogs, same three visible, one just has a new name. + d = PackageSees() + fmt.Println("Main sees: ", dog, Dog, DOG) + d[&dog] = 1 + d[&Dog] = 1 + d[&DOG] = 1 + fmt.Println("There are", len(d), "dogs.\n") + + // Of course you can still declare a variable if you want to. This + // declares a new variable, shadowing DOG in the package and rendering + // it inaccessable even though it begins with an upper case letter. + var DOG = "Bernie" + // five dogs now. three visible from here. + d = PackageSees() + fmt.Println("Main sees: ", dog, Dog, DOG) + d[&dog] = 1 + d[&Dog] = 1 + d[&DOG] = 1 + fmt.Println("There are", len(d), "dogs.") +} diff --git a/Task/Case-sensitivity-of-identifiers/Haskell/case-sensitivity-of-identifiers.hs b/Task/Case-sensitivity-of-identifiers/Haskell/case-sensitivity-of-identifiers.hs new file mode 100644 index 0000000000..e65c04d915 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Haskell/case-sensitivity-of-identifiers.hs @@ -0,0 +1,6 @@ +import Text.Printf + +main = printf "The three dogs are named %s, %s and %s.\n" dog dOG dOg + where dog = "Benjamin" + dOG = "Samba" + dOg = "Bernie" diff --git a/Task/Case-sensitivity-of-identifiers/Java/case-sensitivity-of-identifiers.java b/Task/Case-sensitivity-of-identifiers/Java/case-sensitivity-of-identifiers.java new file mode 100644 index 0000000000..c9b24466b7 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Java/case-sensitivity-of-identifiers.java @@ -0,0 +1,5 @@ +String dog = "Benjamin"; +String Dog = "Samba"; //in general, identifiers that start with capital letters are class names +String DOG = "Bernie"; //in general, identifiers in all caps are constants +//the conventions listed in comments here are not enforced by the language +System.out.println("There are three dogs named " + dog + ", " + Dog + ", and " + DOG + "'"); diff --git a/Task/Case-sensitivity-of-identifiers/JavaScript/case-sensitivity-of-identifiers.js b/Task/Case-sensitivity-of-identifiers/JavaScript/case-sensitivity-of-identifiers.js new file mode 100644 index 0000000000..312cf8a4d3 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/JavaScript/case-sensitivity-of-identifiers.js @@ -0,0 +1,4 @@ +var dog="Benjamin"; +var Dog = "Samba"; +var DOG = "Bernie"; +document.write("The three dogs are named " + dog + ", " + Dog + ", and " + DOG + "."); diff --git a/Task/Case-sensitivity-of-identifiers/Lua/case-sensitivity-of-identifiers.lua b/Task/Case-sensitivity-of-identifiers/Lua/case-sensitivity-of-identifiers.lua new file mode 100644 index 0000000000..a2eb77372f --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Lua/case-sensitivity-of-identifiers.lua @@ -0,0 +1,5 @@ +dog = "Benjamin" +Dog = "Samba" +DOG = "Bernie" + +print( "There are three dogs named "..dog..", "..Dog.." and "..DOG.."." ) diff --git a/Task/Case-sensitivity-of-identifiers/MATLAB/case-sensitivity-of-identifiers.m b/Task/Case-sensitivity-of-identifiers/MATLAB/case-sensitivity-of-identifiers.m new file mode 100644 index 0000000000..3c0fb893fe --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/MATLAB/case-sensitivity-of-identifiers.m @@ -0,0 +1,5 @@ + dog = 'Benjamin'; + Dog = 'Samba'; + DOG = 'Bernie'; + + printf('There are three dogs %s, %s, %s.\n',dog, Dog, DOG); diff --git a/Task/Case-sensitivity-of-identifiers/Perl/case-sensitivity-of-identifiers.pl b/Task/Case-sensitivity-of-identifiers/Perl/case-sensitivity-of-identifiers.pl new file mode 100644 index 0000000000..a41ea57151 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Perl/case-sensitivity-of-identifiers.pl @@ -0,0 +1,5 @@ +# These variables are all different +$dog='Benjamin'; +$Dog='Samba'; +$DOG='Bernie'; +print "The three dogs are named $dog, $Dog, and $DOG \n" diff --git a/Task/Case-sensitivity-of-identifiers/PicoLisp/case-sensitivity-of-identifiers.l b/Task/Case-sensitivity-of-identifiers/PicoLisp/case-sensitivity-of-identifiers.l new file mode 100644 index 0000000000..658fb2575d --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/PicoLisp/case-sensitivity-of-identifiers.l @@ -0,0 +1,2 @@ +(let (dog "Benjamin" Dog "Samba" DOG "Bernie") + (prinl "The three dogs are named " dog ", " Dog " and " DOG) ) diff --git a/Task/Case-sensitivity-of-identifiers/Prolog/case-sensitivity-of-identifiers.pro b/Task/Case-sensitivity-of-identifiers/Prolog/case-sensitivity-of-identifiers.pro new file mode 100644 index 0000000000..0e4fbb99dc --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Prolog/case-sensitivity-of-identifiers.pro @@ -0,0 +1,5 @@ +three_dogs :- + DoG = 'Benjamin', + Dog = 'Samba', + DOG = 'Bernie', + format('The three dogs are named ~w, ~w and ~w.~n', [DoG, Dog, DOG]). diff --git a/Task/Case-sensitivity-of-identifiers/Python/case-sensitivity-of-identifiers.py b/Task/Case-sensitivity-of-identifiers/Python/case-sensitivity-of-identifiers.py new file mode 100644 index 0000000000..a11aa53739 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Python/case-sensitivity-of-identifiers.py @@ -0,0 +1,4 @@ +>>> dog = 'Benjamin'; Dog = 'Samba'; DOG = 'Bernie' +>>> print ('The three dogs are named ',dog,', ',Dog,', and ',DOG) +The three dogs are named Benjamin , Samba , and Bernie +>>> diff --git a/Task/Case-sensitivity-of-identifiers/R/case-sensitivity-of-identifiers.r b/Task/Case-sensitivity-of-identifiers/R/case-sensitivity-of-identifiers.r new file mode 100644 index 0000000000..a555c71b71 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/R/case-sensitivity-of-identifiers.r @@ -0,0 +1,14 @@ +dog <- 'Benjamin' +Dog <- 'Samba' +DOG <- 'Bernie' + +# Having fun with cats and dogs +cat('The three dogs are named ') +cat(dog) +cat(', ') +cat(Dog) +cat(' and ') +cat(DOG) +cat('.\n') +# In one line it would be: +# cat('The three dogs are named ', dog, ', ', Dog, ' and ', DOG, '.\n', sep = '') diff --git a/Task/Case-sensitivity-of-identifiers/REXX/case-sensitivity-of-identifiers.rexx b/Task/Case-sensitivity-of-identifiers/REXX/case-sensitivity-of-identifiers.rexx new file mode 100644 index 0000000000..54ac252809 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/REXX/case-sensitivity-of-identifiers.rexx @@ -0,0 +1,22 @@ +/*demonstrate case insensative REXX variable names. (for the most part).*/ +dog = 'Benjamin' +Dog = 'Samba' +DOG = 'Bernie' + +say copies('-',20) /*show a sep for visual clarity. */ +say 'dog=' dog +say 'Dog=' Dog +say 'DOG=' DOG +say copies('-',20) /*show a sep for visual clarity. */ +say + +x='dog'; dogname.x='Benjamin' +x='Dog'; dogname.x='Samba' +x='DOG'; dogname.x='Bernie' + +say copies('=',20) /*show a sep for visual clarity. */ +_='dog'; say 'dog=' dogname._ +_='Dog'; say 'Dog=' dogname._ +_='DOG'; say 'DOG=' dogname._ +say copies('=',20) /*show a sep for visual clarity. */ + /*stick a fork in it, we're done.*/ diff --git a/Task/Case-sensitivity-of-identifiers/Racket/case-sensitivity-of-identifiers-1.rkt b/Task/Case-sensitivity-of-identifiers/Racket/case-sensitivity-of-identifiers-1.rkt new file mode 100644 index 0000000000..0e4697593e --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Racket/case-sensitivity-of-identifiers-1.rkt @@ -0,0 +1,8 @@ +#lang racket +(define dog "Benjamin") +(define Dog "Samba") +(define DOG "Bernie") + +(if (equal? dog DOG) + (displayln (~a "There is one dog named " DOG ".")) + (displayln (~a "The three dogs are named " dog ", " Dog ", and, " DOG "."))) diff --git a/Task/Case-sensitivity-of-identifiers/Racket/case-sensitivity-of-identifiers-2.rkt b/Task/Case-sensitivity-of-identifiers/Racket/case-sensitivity-of-identifiers-2.rkt new file mode 100644 index 0000000000..4d0fb65277 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Racket/case-sensitivity-of-identifiers-2.rkt @@ -0,0 +1,9 @@ +#lang racket +#ci(module dogs racket + (define dog "Benjamin") + (set! Dog "Samba") + (set! DOG "Bernie") + (if (equal? dog DOG) + (displayln (~a "There is one dog named " DOG ".")) + (displayln (~a "The three dogs are named " dog ", " Dog ", and, " DOG ".")))) +(require 'dogs) diff --git a/Task/Case-sensitivity-of-identifiers/Ruby/case-sensitivity-of-identifiers.rb b/Task/Case-sensitivity-of-identifiers/Ruby/case-sensitivity-of-identifiers.rb new file mode 100644 index 0000000000..0ec2542fad --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Ruby/case-sensitivity-of-identifiers.rb @@ -0,0 +1,14 @@ +module FiveDogs + dog = "Benjamin" + dOg = "Dogley" + doG = "Fido" + Dog = "Samba" # this constant is FiveDogs::Dog + DOG = "Bernie" # this constant is FiveDogs::DOG + + names = [dog, dOg, doG, Dog, DOG] + names.uniq! + puts "There are %d dogs named %s." % [names.length, names.join(", ")] + puts + puts "The local variables are %s." % local_variables.join(", ") + puts "The constants are %s." % constants.join(", ") +end diff --git a/Task/Case-sensitivity-of-identifiers/Sather/case-sensitivity-of-identifiers.sa b/Task/Case-sensitivity-of-identifiers/Sather/case-sensitivity-of-identifiers.sa new file mode 100644 index 0000000000..f71f39cf49 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Sather/case-sensitivity-of-identifiers.sa @@ -0,0 +1,9 @@ +class MAIN is + main is + dog ::= "Benjamin"; + Dog ::= "Samba"; + DOG ::= "Bernie"; + #OUT + #FMT("The three dogs are %s, %s and %s\n", + dog, Dog, DOG); + end; +end; diff --git a/Task/Case-sensitivity-of-identifiers/Scala/case-sensitivity-of-identifiers.scala b/Task/Case-sensitivity-of-identifiers/Scala/case-sensitivity-of-identifiers.scala new file mode 100644 index 0000000000..8a74ea2a2a --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Scala/case-sensitivity-of-identifiers.scala @@ -0,0 +1,4 @@ +val dog = "Benjamin" +val Dog = "Samba" +val DOG = "Bernie" +println("There are three dogs named " + dog + ", " + Dog + ", and " + DOG + ".") diff --git a/Task/Case-sensitivity-of-identifiers/Scheme/case-sensitivity-of-identifiers.ss b/Task/Case-sensitivity-of-identifiers/Scheme/case-sensitivity-of-identifiers.ss new file mode 100644 index 0000000000..8784a3e2d8 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Scheme/case-sensitivity-of-identifiers.ss @@ -0,0 +1,15 @@ +(define dog "Benjamin") +(define Dog "Samba") +(define DOG "Bernie") + +(if (eq? dog DOG) + (begin (display "There is one dog named ") + (display DOG) + (display ".") + (newline)) + (begin (display "The three dogs are named ") + (display dog) (display ", ") + (display Dog) (display " and ") + (display DOG) + (display ".") + (newline))) diff --git a/Task/Case-sensitivity-of-identifiers/Smalltalk/case-sensitivity-of-identifiers.st b/Task/Case-sensitivity-of-identifiers/Smalltalk/case-sensitivity-of-identifiers.st new file mode 100644 index 0000000000..c5a282cfa8 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Smalltalk/case-sensitivity-of-identifiers.st @@ -0,0 +1,6 @@ +|dog Dog DOG| +dog := 'Benjamin'. +Dog := 'Samba'. +DOG := 'Bernie'. +( 'The three dogs are named %1, %2 and %3' % + { dog . Dog . DOG } ) displayNl. diff --git a/Task/Case-sensitivity-of-identifiers/Tcl/case-sensitivity-of-identifiers.tcl b/Task/Case-sensitivity-of-identifiers/Tcl/case-sensitivity-of-identifiers.tcl new file mode 100644 index 0000000000..5407b8e6af --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Tcl/case-sensitivity-of-identifiers.tcl @@ -0,0 +1,4 @@ +set dog "Benjamin" +set Dog "Samba" +set DOG "Bernie" +puts "The three dogs are named $dog, $Dog and $DOG" diff --git a/Task/Catmull-Clark-subdivision-surface/0DESCRIPTION b/Task/Catmull-Clark-subdivision-surface/0DESCRIPTION new file mode 100644 index 0000000000..44eddf95e4 --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/0DESCRIPTION @@ -0,0 +1,42 @@ +Implement the Catmull-Clark surface subdivision ([[wp:Catmull–Clark_subdivision_surface|description on Wikipedia]]), which is an algorithm that maps from a surface (described as a set of points and a set of polygons with vertices at those points) to another more refined surface. The resulting surface will always consist of a mesh of quadrilaterals. + +The process for computing the new locations of the points works as follows when the surface is free of holes: +[[Image:CatmullClark_subdiv_0.png|thumb|Starting cubic mesh; the meshes below are derived from this.]] +[[Image:CatmullClark_subdiv_1.png|thumb|After one round of the Catmull-Clark algorithm applied to a cubic mesh.]] +[[Image:CatmullClark_subdiv_2.png|thumb|After two rounds of the Catmull-Clark algorithm. As can be seen, this is converging to a surface that looks nearly spherical.]] +# for each face, a ''face point'' is created which is the average of all the points of the face. +# for each edge, an ''edge point'' is created which is the average between the center of the edge and the center of the segment made with the face points of the two adjacent faces. +# for each vertex point, its coordinates are updated from (new_coords): +## the old coordinates (old_coords), +## the average of the face points of the faces the point belongs to (avg_face_points), +## the average of the centers of edges the point belongs to (avg_mid_edges), +## how many faces a point belongs to (n), then use this formula: + m1 = (n - 3) / n + m2 = 1 / n + m3 = 2 / n + new_coords = (m1 * old_coords) + + (m2 * avg_face_points) + + (m3 * avg_mid_edges) + +Then each face is replaced by new faces made with the new points, +* for a triangle face (a,b,c): + (a, edge_pointab, face_pointabc, edge_pointca) + (b, edge_pointbc, face_pointabc, edge_pointab) + (c, edge_pointca, face_pointabc, edge_pointbc) +* for a quad face (a,b,c,d): + (a, edge_pointab, face_pointabcd, edge_pointda) + (b, edge_pointbc, face_pointabcd, edge_pointab) + (c, edge_pointcd, face_pointabcd, edge_pointbc) + (d, edge_pointda, face_pointabcd, edge_pointcd) + +When there is a hole, we can detect it as follows: +* an edge is the border of a hole if it belongs to only one face, +* a point is on the border of a hole if nfaces != nedges with nfaces the number of faces the point belongs to, and nedges the number of edges a point belongs to. + +On the border of a hole the subdivision occurs as follows: +# for the edges that are on the border of a hole, the edge point is just the middle of the edge. +# for the vertex points that are on the border of a hole, the new coordinates are calculated as follows: +## in all the edges the point belongs to, only take in account the middles of the edges that are on the border of the hole +## calculate the average between these points (on the hole boundary) and the old coordinates (also on the hole boundary). + +For edges and vertices not next to a hole, the standard algorithm from above is used. diff --git a/Task/Catmull-Clark-subdivision-surface/1META.yaml b/Task/Catmull-Clark-subdivision-surface/1META.yaml new file mode 100644 index 0000000000..73dee3a70d --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/1META.yaml @@ -0,0 +1,6 @@ +--- +category: +- Graphics algorithms +note: 3D +requires: +- Graphics diff --git a/Task/Catmull-Clark-subdivision-surface/C/catmull-clark-subdivision-surface.c b/Task/Catmull-Clark-subdivision-surface/C/catmull-clark-subdivision-surface.c new file mode 100644 index 0000000000..951cbe0c2a --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/C/catmull-clark-subdivision-surface.c @@ -0,0 +1,93 @@ +vertex face_point(face f) +{ + int i; + vertex v; + + if (!f->avg) { + f->avg = vertex_new(); + foreach(i, v, f->v) + if (!i) f->avg->pos = v->pos; + else vadd(f->avg->pos, v->pos); + + vdiv(f->avg->pos, len(f->v)); + } + return f->avg; +} + +#define hole_edge(e) (len(e->f)==1) +vertex edge_point(edge e) +{ + int i; + face f; + + if (!e->e_pt) { + e->e_pt = vertex_new(); + e->avg = e->v[0]->pos; + vadd(e->avg, e->v[1]->pos); + e->e_pt->pos = e->avg; + + if (!hole_edge(e)) { + foreach (i, f, e->f) + vadd(e->e_pt->pos, face_point(f)->pos); + vdiv(e->e_pt->pos, 4); + } else + vdiv(e->e_pt->pos, 2); + + vdiv(e->avg, 2); + } + + return e->e_pt; +} + +#define hole_vertex(v) (len((v)->f) != len((v)->e)) +vertex updated_point(vertex v) +{ + int i, n = 0; + edge e; + face f; + coord_t sum = {0, 0, 0}; + + if (v->v_new) return v->v_new; + + v->v_new = vertex_new(); + if (hole_vertex(v)) { + v->v_new->pos = v->pos; + foreach(i, e, v->e) { + if (!hole_edge(e)) continue; + vadd(v->v_new->pos, edge_point(e)->pos); + n++; + } + vdiv(v->v_new->pos, n + 1); + } else { + n = len(v->f); + foreach(i, f, v->f) + vadd(sum, face_point(f)->pos); + foreach(i, e, v->e) + vmadd(sum, edge_point(e)->pos, 2, sum); + vdiv(sum, n); + vmadd(sum, v->pos, n - 3, sum); + vdiv(sum, n); + v->v_new->pos = sum; + } + + return v->v_new; +} + +model catmull(model m) +{ + int i, j, a, b, c, d; + face f; + vertex v, x; + + model nm = model_new(); + foreach (i, f, m->f) { + foreach(j, v, f->v) { + _get_idx(a, updated_point(v)); + _get_idx(b, edge_point(elem(f->e, (j + 1) % len(f->e)))); + _get_idx(c, face_point(f)); + _get_idx(d, edge_point(elem(f->e, j))); + model_add_face(nm, 4, a, b, c, d); + } + } + return nm; +} diff --git a/Task/Catmull-Clark-subdivision-surface/Tcl/catmull-clark-subdivision-surface.tcl b/Task/Catmull-Clark-subdivision-surface/Tcl/catmull-clark-subdivision-surface.tcl new file mode 100644 index 0000000000..bebdab4a58 --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/Tcl/catmull-clark-subdivision-surface.tcl @@ -0,0 +1,122 @@ +package require Tcl 8.5 + +# Use math functions and operators as commands (Lisp-like). +namespace path {tcl::mathfunc tcl::mathop} + +# Add 3 points. +proc add3 {A B C} { + lassign $A Ax Ay Az + lassign $B Bx By Bz + lassign $C Cx Cy Cz + list [+ $Ax $Bx $Cx] [+ $Ay $By $Cy] [+ $Az $Bz $Cz] +} + +# Multiply a point by a constant. +proc mulC {m A} { + lassign $A x y z + list [* $m $x] [* $m $y] [* $m $z] +} + +# Take the centroid of a set of points. +# Note that each of the arguments is a *list* of coordinate triples +# This makes things easier later. +proc centroid args { + set x [set y [set z 0.0]] + foreach plist $args { + incr n [llength $plist] + foreach p $plist { + lassign $p px py pz + set x [+ $x $px] + set y [+ $y $py] + set z [+ $z $pz] + } + } + set n [double $n] + list [/ $x $n] [/ $y $n] [/ $z $n] +} + +# Select from the list the value from each of the indices in the *lists* +# in the trailing arguments. +proc selectFrom {list args} { + foreach is $args {foreach i $is {lappend r [lindex $list $i]}} + return $r +} + +# Rotate a list. +proc lrot {list {n 1}} { + set n [% $n [llength $list]] + list {*}[lrange $list $n end] {*}[lrange $list 0 [incr n -1]] +} + +# Generate an edge by putting the smaller coordinate index first. +proc edge {a b} { + list [min $a $b] [max $a $b] +} + +# Perform one step of Catmull-Clark subdivision of a surface. +proc CatmullClark {points faces} { + # Generate the new face-points and list of edges, plus some lookup tables. + set edges {} + foreach f $faces { + set ps [selectFrom $points $f] + set fp [centroid $ps] + lappend facepoints $fp + foreach p $ps { + lappend fp4p($p) $fp + } + foreach p1 $f p2 [lrot $f] { + set e [edge $p1 $p2] + if {$e ni $edges} { + lappend edges $e + } + lappend fp4e($e) $fp + } + } + + # Generate the new edge-points and mid-points of edges, and a few more + # lookup tables. + set i [+ [llength $points] [llength $faces]] + foreach e $edges { + set ep [selectFrom $points $e] + if {[llength $fp4e($e)] > 1} { + set mid [centroid $ep $fp4e($e)] + } else { + set mid [centroid $ep] + foreach p $ep { + lappend ep_heavy($p) $mid + } + } + lappend edgepoints $mid + set en4e($e) $i + foreach p $ep { + lappend ep4p($p) $mid + } + incr i + } + + # Generate the new vertex points with our lookup tables. + foreach p $points { + if {[llength $fp4p($p)] >= 4} { + set n [llength $fp4p($p)] + lappend newPoints [add3 [mulC [/ [- $n 3.0] $n] $p] \ + [mulC [/ 1.0 $n] [centroid $fp4p($p)]] \ + [mulC [/ 2.0 $n] [centroid $ep4p($p)]]] + } else { + # Update a point on the edge of a hole. This formula is not + # described on the WP page, but produces a nice result. + lappend newPoints [centroid $ep_heavy($p) [list $p $p]] + } + } + + # Now compute the new set of quadrilateral faces. + set i [llength $points] + foreach f $faces { + foreach a $f b [lrot $f] c [lrot $f -1] { + lappend newFaces [list \ + $a $en4e([edge $a $b]) $i $en4e([edge $c $a])] + } + incr i + } + + list [concat $newPoints $facepoints $edgepoints] $newFaces +} diff --git a/Task/Character-codes/0DESCRIPTION b/Task/Character-codes/0DESCRIPTION new file mode 100644 index 0000000000..8f49990e6e --- /dev/null +++ b/Task/Character-codes/0DESCRIPTION @@ -0,0 +1 @@ +Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses). For example, the character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode). Conversely, given a code, print out the corresponding character. diff --git a/Task/Character-codes/1META.yaml b/Task/Character-codes/1META.yaml new file mode 100644 index 0000000000..f13cf9d6db --- /dev/null +++ b/Task/Character-codes/1META.yaml @@ -0,0 +1,5 @@ +--- +category: +- Basic language learning +- String manipulation +note: Text processing diff --git a/Task/Character-codes/ABAP/character-codes.abap b/Task/Character-codes/ABAP/character-codes.abap new file mode 100644 index 0000000000..a919731a33 --- /dev/null +++ b/Task/Character-codes/ABAP/character-codes.abap @@ -0,0 +1,7 @@ +report zcharcode +data: c value 'A', n type i. +field-symbols type x. + +assign c to casting. +move to n. +write: c, '=', n left-justified. diff --git a/Task/Character-codes/ACL2/character-codes.acl2 b/Task/Character-codes/ACL2/character-codes.acl2 new file mode 100644 index 0000000000..ec9a152732 --- /dev/null +++ b/Task/Character-codes/ACL2/character-codes.acl2 @@ -0,0 +1,2 @@ +(cw "~x0" (char-code #\a)) +(cw "~x0" (code-char 97)) diff --git a/Task/Character-codes/ALGOL-68/character-codes-1.alg b/Task/Character-codes/ALGOL-68/character-codes-1.alg new file mode 100644 index 0000000000..41dd738b89 --- /dev/null +++ b/Task/Character-codes/ALGOL-68/character-codes-1.alg @@ -0,0 +1,4 @@ +main:( + printf(($gl$, ABS "a")); # for ASCII this prints "+97" EBCDIC prints "+129" # + printf(($gl$, REPR 97)) # for ASCII this prints "a"; EBCDIC prints "/" # +) diff --git a/Task/Character-codes/ALGOL-68/character-codes-2.alg b/Task/Character-codes/ALGOL-68/character-codes-2.alg new file mode 100644 index 0000000000..d7450669ea --- /dev/null +++ b/Task/Character-codes/ALGOL-68/character-codes-2.alg @@ -0,0 +1,4 @@ +FILE tape; +INT errno = open(tape, "/dev/tape1", stand out channel) +make conv(tape, ebcdic conv); +FOR record DO getf(tape, ( ~ )) OD; ~ # etc ... # diff --git a/Task/Character-codes/ALGOL-68/character-codes-3.alg b/Task/Character-codes/ALGOL-68/character-codes-3.alg new file mode 100644 index 0000000000..5508efe807 --- /dev/null +++ b/Task/Character-codes/ALGOL-68/character-codes-3.alg @@ -0,0 +1 @@ + make conv(tape, stand conv(stand out channel)) diff --git a/Task/Character-codes/AWK/character-codes.awk b/Task/Character-codes/AWK/character-codes.awk new file mode 100644 index 0000000000..81d1738633 --- /dev/null +++ b/Task/Character-codes/AWK/character-codes.awk @@ -0,0 +1,13 @@ +function ord(c) +{ + return chmap[c] +} +BEGIN { + for(i=0; i < 256; i++) { + chmap[sprintf("%c", i)] = i + } + print ord("a"), ord("b") + printf "%c %c\n", 97, 98 + s = sprintf("%c%c", 97, 98) + print s +} diff --git a/Task/Character-codes/ActionScript/character-codes.as b/Task/Character-codes/ActionScript/character-codes.as new file mode 100644 index 0000000000..126107a4cb --- /dev/null +++ b/Task/Character-codes/ActionScript/character-codes.as @@ -0,0 +1,2 @@ +trace(String.fromCharCode(97)); //prints 'a' +trace("a".charCodeAt(0));//prints '97' diff --git a/Task/Character-codes/Ada/character-codes.ada b/Task/Character-codes/Ada/character-codes.ada new file mode 100644 index 0000000000..1ca9ae2042 --- /dev/null +++ b/Task/Character-codes/Ada/character-codes.ada @@ -0,0 +1,6 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Char_Code is +begin + Put_Line (Character'Val (97) & " =" & Integer'Image (Character'Pos ('a'))); +end Char_Code; diff --git a/Task/Character-codes/Aime/character-codes.aime b/Task/Character-codes/Aime/character-codes.aime new file mode 100644 index 0000000000..698a019061 --- /dev/null +++ b/Task/Character-codes/Aime/character-codes.aime @@ -0,0 +1,6 @@ +# prints "97" +o_integer('a'); +o_byte('\n'); +# prints "a" +o_byte(97); +o_byte('\n'); diff --git a/Task/Character-codes/AutoHotkey/character-codes.ahk b/Task/Character-codes/AutoHotkey/character-codes.ahk new file mode 100644 index 0000000000..2bf41d5958 --- /dev/null +++ b/Task/Character-codes/AutoHotkey/character-codes.ahk @@ -0,0 +1,2 @@ +MsgBox % Chr(97) +MsgBox % Asc("a") diff --git a/Task/Character-codes/BASIC/character-codes-1.bas b/Task/Character-codes/BASIC/character-codes-1.bas new file mode 100644 index 0000000000..da64d8d813 --- /dev/null +++ b/Task/Character-codes/BASIC/character-codes-1.bas @@ -0,0 +1,4 @@ +charCode = 97 +char = "a" +PRINT CHR$(charCode) 'prints a +PRINT ASC(char) 'prints 97 diff --git a/Task/Character-codes/BASIC/character-codes-2.bas b/Task/Character-codes/BASIC/character-codes-2.bas new file mode 100644 index 0000000000..481d35a582 --- /dev/null +++ b/Task/Character-codes/BASIC/character-codes-2.bas @@ -0,0 +1,4 @@ +10 LET c = 97: REM c is a character code +20 LET d$ = "b": REM d$ holds the character +30 PRINT CHR$(c): REM this prints a +40 PRINT CODE(d$): REM this prints 98 diff --git a/Task/Character-codes/BBC-BASIC/character-codes.bbc b/Task/Character-codes/BBC-BASIC/character-codes.bbc new file mode 100644 index 0000000000..80c2f7b0b0 --- /dev/null +++ b/Task/Character-codes/BBC-BASIC/character-codes.bbc @@ -0,0 +1,4 @@ + charCode = 97 + char$ = "a" + PRINT CHR$(charCode) : REM prints a + PRINT ASC(char$) : REM prints 97 diff --git a/Task/Character-codes/Befunge/character-codes.bf b/Task/Character-codes/Befunge/character-codes.bf new file mode 100644 index 0000000000..a4c2474d94 --- /dev/null +++ b/Task/Character-codes/Befunge/character-codes.bf @@ -0,0 +1 @@ +"A". 88*1+, diff --git a/Task/Character-codes/C++/character-codes.cpp b/Task/Character-codes/C++/character-codes.cpp new file mode 100644 index 0000000000..f9b5da82a4 --- /dev/null +++ b/Task/Character-codes/C++/character-codes.cpp @@ -0,0 +1,7 @@ +#include + +int main() { + std::cout << (int)'a' << std::endl; // prints "97" + std::cout << (char)97 << std::endl; // prints "a" + return 0; +} diff --git a/Task/Character-codes/C/character-codes.c b/Task/Character-codes/C/character-codes.c new file mode 100644 index 0000000000..9b64a16e2c --- /dev/null +++ b/Task/Character-codes/C/character-codes.c @@ -0,0 +1,7 @@ +#include + +int main() { + printf("%d\n", 'a'); /* prints "97" */ + printf("%c\n", 97); /* prints "a"; we don't have to cast because printf is type agnostic */ + return 0; +} diff --git a/Task/Character-codes/Clojure/character-codes.clj b/Task/Character-codes/Clojure/character-codes.clj new file mode 100644 index 0000000000..fd93a67555 --- /dev/null +++ b/Task/Character-codes/Clojure/character-codes.clj @@ -0,0 +1,6 @@ +(print (int \a)) ; prints "97" +(print (char 97)) ; prints \a + +; Unicode is also available, as Clojure uses the underlying java Strings & chars +(print (int \π)) ; prints 960 +(print (char 960)) ; prints \π diff --git a/Task/Character-codes/CoffeeScript/character-codes.coffee b/Task/Character-codes/CoffeeScript/character-codes.coffee new file mode 100644 index 0000000000..11080e4bf5 --- /dev/null +++ b/Task/Character-codes/CoffeeScript/character-codes.coffee @@ -0,0 +1,2 @@ +console.log 'a'.charCodeAt 0 # 97 +console.log String.fromCharCode 97 # a diff --git a/Task/Character-codes/Common-Lisp/character-codes.lisp b/Task/Character-codes/Common-Lisp/character-codes.lisp new file mode 100644 index 0000000000..eb1d52d582 --- /dev/null +++ b/Task/Character-codes/Common-Lisp/character-codes.lisp @@ -0,0 +1,2 @@ +(princ (char-code #\a)) ; prints "97" +(princ (code-char 97)) ; prints "a" diff --git a/Task/Character-codes/D/character-codes.d b/Task/Character-codes/D/character-codes.d new file mode 100644 index 0000000000..3a902cddce --- /dev/null +++ b/Task/Character-codes/D/character-codes.d @@ -0,0 +1,13 @@ +import std.stdio, std.utf; + +void main() { + string test = "a"; + size_t index = 0; + + // Get four-byte utf32 value for index 0 + // this returns dchar, so cast it to numeric. + writeln(cast(uint)test.decode(index)); + + // 'index' has moved to next character position in input. + assert(index == 1); +} diff --git a/Task/Character-codes/DWScript/character-codes.dwscript b/Task/Character-codes/DWScript/character-codes.dwscript new file mode 100644 index 0000000000..e108c08947 --- /dev/null +++ b/Task/Character-codes/DWScript/character-codes.dwscript @@ -0,0 +1,2 @@ +PrintLn(Ord('a')); +PrintLn(Chr(97)); diff --git a/Task/Character-codes/Delphi/character-codes.delphi b/Task/Character-codes/Delphi/character-codes.delphi new file mode 100644 index 0000000000..4dfc745f20 --- /dev/null +++ b/Task/Character-codes/Delphi/character-codes.delphi @@ -0,0 +1,19 @@ +program Project1; + +{$APPTYPE CONSOLE} + +uses + SysUtils; +var + aChar:Char; + aCode:Byte; + uChar:WideChar; + uCode:Word; +begin + aChar := Chr(97); Writeln(aChar); + aCode := Ord(aChar); Writeln(aCode); + uChar := WideChar(97); Writeln(uChar); + uCode := Ord(uChar); Writeln(uCode); + + Readln; +end. diff --git a/Task/Character-codes/E/character-codes.e b/Task/Character-codes/E/character-codes.e new file mode 100644 index 0000000000..77a7494bef --- /dev/null +++ b/Task/Character-codes/E/character-codes.e @@ -0,0 +1,5 @@ +? 'a'.asInteger() +# value: 97 + +? .asChar(97) +# value: 'a' diff --git a/Task/Character-codes/Elena/character-codes.elena b/Task/Character-codes/Elena/character-codes.elena new file mode 100644 index 0000000000..ac210fa604 --- /dev/null +++ b/Task/Character-codes/Elena/character-codes.elena @@ -0,0 +1,8 @@ +#define std'dictionary'*. +#define std'basic'*. + +#symbol Program => +[ + 'program'output << WideCharVar::"a" numeric. + 'program'output << WideCharVar::97. +]. diff --git a/Task/Character-codes/Erlang/character-codes-1.erl b/Task/Character-codes/Erlang/character-codes-1.erl new file mode 100644 index 0000000000..c08370ef49 --- /dev/null +++ b/Task/Character-codes/Erlang/character-codes-1.erl @@ -0,0 +1,4 @@ +1> F = fun([X]) -> X end. +#Fun +2> F("a"). +97 diff --git a/Task/Character-codes/Erlang/character-codes-2.erl b/Task/Character-codes/Erlang/character-codes-2.erl new file mode 100644 index 0000000000..dbfddb5fe0 --- /dev/null +++ b/Task/Character-codes/Erlang/character-codes-2.erl @@ -0,0 +1,2 @@ +3> $a. +97 diff --git a/Task/Character-codes/Euphoria/character-codes.euphoria b/Task/Character-codes/Euphoria/character-codes.euphoria new file mode 100644 index 0000000000..48741c5aba --- /dev/null +++ b/Task/Character-codes/Euphoria/character-codes.euphoria @@ -0,0 +1,2 @@ +printf(1,"%d\n", 'a') -- prints "97" +printf(1,"%s\n", 97) -- prints "a" diff --git a/Task/Character-codes/Forth/character-codes.fth b/Task/Character-codes/Forth/character-codes.fth new file mode 100644 index 0000000000..300e8919ca --- /dev/null +++ b/Task/Character-codes/Forth/character-codes.fth @@ -0,0 +1,3 @@ +char a +dup . \ 97 +emit \ a diff --git a/Task/Character-codes/Fortran/character-codes.f b/Task/Character-codes/Fortran/character-codes.f new file mode 100644 index 0000000000..76e9f096de --- /dev/null +++ b/Task/Character-codes/Fortran/character-codes.f @@ -0,0 +1,2 @@ +WRITE(*,*) ACHAR(97), IACHAR("a") +WRITE(*,*) CHAR(97), ICHAR("a") diff --git a/Task/Character-codes/Go/character-codes-1.go b/Task/Character-codes/Go/character-codes-1.go new file mode 100644 index 0000000000..bb482c0a4a --- /dev/null +++ b/Task/Character-codes/Go/character-codes-1.go @@ -0,0 +1,2 @@ +fmt.Println('a') // prints "97" +fmt.Println('π') // prints "960" diff --git a/Task/Character-codes/Go/character-codes-2.go b/Task/Character-codes/Go/character-codes-2.go new file mode 100644 index 0000000000..3653ecac18 --- /dev/null +++ b/Task/Character-codes/Go/character-codes-2.go @@ -0,0 +1,16 @@ +package main + +import "fmt" + +func main() { + // yes, there is more concise syntax, but this makes + // the data types very clear. + var b byte = 'a' + var r rune = 'π' + var s string = "aπ" + + fmt.Println(b, r, s) + for _, c := range s { // this gives c the type rune + fmt.Println(c) + } +} diff --git a/Task/Character-codes/Go/character-codes-3.go b/Task/Character-codes/Go/character-codes-3.go new file mode 100644 index 0000000000..6da1b155d2 --- /dev/null +++ b/Task/Character-codes/Go/character-codes-3.go @@ -0,0 +1,3 @@ +b := byte(97) +r := rune(960) +fmt.Printf("%c %c\n%c %c\n", 97, 960, b, r) diff --git a/Task/Character-codes/Go/character-codes-4.go b/Task/Character-codes/Go/character-codes-4.go new file mode 100644 index 0000000000..538a423d08 --- /dev/null +++ b/Task/Character-codes/Go/character-codes-4.go @@ -0,0 +1,3 @@ +fmt.Println(string(97)) // prints "a" +fmt.Println(string(960)) // prints "π" +fmt.Println(string([]rune{97, 960})) // prints "aπ" diff --git a/Task/Character-codes/Haskell/character-codes.hs b/Task/Character-codes/Haskell/character-codes.hs new file mode 100644 index 0000000000..1ee2554a76 --- /dev/null +++ b/Task/Character-codes/Haskell/character-codes.hs @@ -0,0 +1,7 @@ +import Data.Char + +main = do + print (ord 'a') -- prints "97" + print (chr 97) -- prints "'a'" + print (ord 'π') -- prints "960" + print (chr 960) -- prints "'\960'" diff --git a/Task/Character-codes/Java/character-codes-1.java b/Task/Character-codes/Java/character-codes-1.java new file mode 100644 index 0000000000..d8983b6c07 --- /dev/null +++ b/Task/Character-codes/Java/character-codes-1.java @@ -0,0 +1,6 @@ +public class Foo { + public static void main(String[] args) { + System.out.println((int)'a'); // prints "97" + System.out.println((char)97); // prints "a" + } +} diff --git a/Task/Character-codes/Java/character-codes-2.java b/Task/Character-codes/Java/character-codes-2.java new file mode 100644 index 0000000000..390a80f999 --- /dev/null +++ b/Task/Character-codes/Java/character-codes-2.java @@ -0,0 +1,6 @@ +public class Bar { + public static void main(String[] args) { + System.out.println((int)'π'); // prints "960" + System.out.println((char)960); // prints "π" + } +} diff --git a/Task/Character-codes/JavaScript/character-codes.js b/Task/Character-codes/JavaScript/character-codes.js new file mode 100644 index 0000000000..7f6c2629b9 --- /dev/null +++ b/Task/Character-codes/JavaScript/character-codes.js @@ -0,0 +1,2 @@ +document.write('a'.charCodeAt(0)); // prints "97" +document.write(String.fromCharCode(97)); // prints "a" diff --git a/Task/Character-codes/Lua/character-codes.lua b/Task/Character-codes/Lua/character-codes.lua new file mode 100644 index 0000000000..edbea3c2c9 --- /dev/null +++ b/Task/Character-codes/Lua/character-codes.lua @@ -0,0 +1,2 @@ +print(string.byte("a")) -- prints "97" +print(string.char(97)) -- prints "a" diff --git a/Task/Character-codes/MATLAB/character-codes-1.m b/Task/Character-codes/MATLAB/character-codes-1.m new file mode 100644 index 0000000000..016fa8589b --- /dev/null +++ b/Task/Character-codes/MATLAB/character-codes-1.m @@ -0,0 +1 @@ +character = char(asciiNumber) diff --git a/Task/Character-codes/MATLAB/character-codes-2.m b/Task/Character-codes/MATLAB/character-codes-2.m new file mode 100644 index 0000000000..ae0fcb3698 --- /dev/null +++ b/Task/Character-codes/MATLAB/character-codes-2.m @@ -0,0 +1 @@ +asciiNumber = double(character) diff --git a/Task/Character-codes/MATLAB/character-codes-3.m b/Task/Character-codes/MATLAB/character-codes-3.m new file mode 100644 index 0000000000..206e2ba1ee --- /dev/null +++ b/Task/Character-codes/MATLAB/character-codes-3.m @@ -0,0 +1,3 @@ +asciiNumber = uint16(character) +asciiNumber = uint32(character) +asciiNumber = uint64(character) diff --git a/Task/Character-codes/MATLAB/character-codes-4.m b/Task/Character-codes/MATLAB/character-codes-4.m new file mode 100644 index 0000000000..9f4ff22128 --- /dev/null +++ b/Task/Character-codes/MATLAB/character-codes-4.m @@ -0,0 +1,17 @@ +>> char(87) + +ans = + +W + +>> double('W') + +ans = + + 87 + +>> uint16('W') + +ans = + + 87 diff --git a/Task/Character-codes/PHP/character-codes.php b/Task/Character-codes/PHP/character-codes.php new file mode 100644 index 0000000000..28765a1dc3 --- /dev/null +++ b/Task/Character-codes/PHP/character-codes.php @@ -0,0 +1,2 @@ +echo ord('a'), "\n"; // prints "97" +echo chr(97), "\n"; // prints "a" diff --git a/Task/Character-codes/Perl/character-codes.pl b/Task/Character-codes/Perl/character-codes.pl new file mode 100644 index 0000000000..b719ed390e --- /dev/null +++ b/Task/Character-codes/Perl/character-codes.pl @@ -0,0 +1,2 @@ +print ord('a'), "\n"; # prints "97" +print chr(97), "\n"; # prints "a" diff --git a/Task/Character-codes/PicoLisp/character-codes.l b/Task/Character-codes/PicoLisp/character-codes.l new file mode 100644 index 0000000000..c8a90d5409 --- /dev/null +++ b/Task/Character-codes/PicoLisp/character-codes.l @@ -0,0 +1,10 @@ +: (char "a") +-> 97 +: (char "字") +-> 23383 +: (char 23383) +-> "字" +: (chop "文字") +-> ("文" "字") +: (mapcar char @) +-> (25991 23383) diff --git a/Task/Character-codes/Python/character-codes-1.py b/Task/Character-codes/Python/character-codes-1.py new file mode 100644 index 0000000000..2a83cb9de0 --- /dev/null +++ b/Task/Character-codes/Python/character-codes-1.py @@ -0,0 +1,2 @@ +print ord('a') # prints "97" +print chr(97) # prints "a" diff --git a/Task/Character-codes/Python/character-codes-2.py b/Task/Character-codes/Python/character-codes-2.py new file mode 100644 index 0000000000..6753119d31 --- /dev/null +++ b/Task/Character-codes/Python/character-codes-2.py @@ -0,0 +1,2 @@ +print ord(u'π') # prints "960" +print unichr(960) # prints "π" diff --git a/Task/Character-codes/Python/character-codes-3.py b/Task/Character-codes/Python/character-codes-3.py new file mode 100644 index 0000000000..e4346f4a45 --- /dev/null +++ b/Task/Character-codes/Python/character-codes-3.py @@ -0,0 +1,4 @@ +print(ord('a')) # prints "97" +print(ord('π')) # prints "960" +print(chr(97)) # prints "a" +print(chr(960)) # prints "π" diff --git a/Task/Character-codes/R/character-codes.r b/Task/Character-codes/R/character-codes.r new file mode 100644 index 0000000000..444acde1ce --- /dev/null +++ b/Task/Character-codes/R/character-codes.r @@ -0,0 +1,2 @@ +ascii <- as.integer(charToRaw("hello world")); ascii +text <- rawToChar(as.raw(ascii)); text diff --git a/Task/Character-codes/REXX/character-codes.rexx b/Task/Character-codes/REXX/character-codes.rexx new file mode 100644 index 0000000000..20eab4e4a9 --- /dev/null +++ b/Task/Character-codes/REXX/character-codes.rexx @@ -0,0 +1,14 @@ +yyy='c' /*assign a lowercase c to YYY.*/ +yyy='34'x /*assign hexadecimal 34 to YYY.*/ + /*the X can be upper/lowercase.*/ +yyy=x2c(34) /* (same as above) */ +yyy='00110100'b /* (same as above) */ +yyy='0011 0100'b /* (same as above) */ + /*the B can be upper/lowercase.*/ +yyy=d2c(97) /*assign decimal code 97 to YYY.*/ + +say yyy /*displays the value of YYY. */ +say c2x(yyy) /*displays the value of YYY in hexadecimal. */ +say c2d(yyy) /*displays the value of YYY in decimal. */ +say x2b(c2x(yyy)) /*displays the value of YYY in binary (bit string). */ + /*Note: some REXXes support the c2b bif */ diff --git a/Task/Character-codes/Ruby/character-codes-1.rb b/Task/Character-codes/Ruby/character-codes-1.rb new file mode 100644 index 0000000000..593e2b030b --- /dev/null +++ b/Task/Character-codes/Ruby/character-codes-1.rb @@ -0,0 +1,6 @@ +> ?a +=> 97 +> "a"[0] +=> 97 +> 97.chr +=> "a" diff --git a/Task/Character-codes/Ruby/character-codes-2.rb b/Task/Character-codes/Ruby/character-codes-2.rb new file mode 100644 index 0000000000..1a7d5c6087 --- /dev/null +++ b/Task/Character-codes/Ruby/character-codes-2.rb @@ -0,0 +1,4 @@ +> "a".ord +=> 97 +> 97.chr +=> "a" diff --git a/Task/Character-codes/Sather/character-codes.sa b/Task/Character-codes/Sather/character-codes.sa new file mode 100644 index 0000000000..bb3e614bbe --- /dev/null +++ b/Task/Character-codes/Sather/character-codes.sa @@ -0,0 +1,7 @@ +class MAIN is + main is + #OUT + 'a'.int + "\n"; -- or + #OUT + 'a'.ascii_int + "\n"; + #OUT + CHAR::from_ascii_int(97) + "\n"; + end; +end; diff --git a/Task/Character-codes/Scala/character-codes-1.scala b/Task/Character-codes/Scala/character-codes-1.scala new file mode 100644 index 0000000000..4d04fe0f74 --- /dev/null +++ b/Task/Character-codes/Scala/character-codes-1.scala @@ -0,0 +1,5 @@ +scala> 'a' toInt +res9: Int = 97 + +scala> 97 toChar +res10: Char = a diff --git a/Task/Character-codes/Scala/character-codes-2.scala b/Task/Character-codes/Scala/character-codes-2.scala new file mode 100644 index 0000000000..51d510c148 --- /dev/null +++ b/Task/Character-codes/Scala/character-codes-2.scala @@ -0,0 +1,7 @@ +def charToInt(c: Char, next: Char): Option[Int] = (c, next) match { + case _ if (c.isHighSurrogate && next.isLowSurrogate) => Some(java.lang.Character.toCodePoint(c, next)) + case _ if (c.isLowSurrogate) => None + case _ => Some(c.toInt) +} + +def intToChars(n: Int): Array[Char] = java.lang.Character.toChars(n) diff --git a/Task/Character-codes/Scheme/character-codes.ss b/Task/Character-codes/Scheme/character-codes.ss new file mode 100644 index 0000000000..b0721ed4be --- /dev/null +++ b/Task/Character-codes/Scheme/character-codes.ss @@ -0,0 +1,2 @@ +(display (char->integer #\a)) (newline) ; prints "97" +(display (integer->char 97)) (newline) ; prints "a" diff --git a/Task/Character-codes/Smalltalk/character-codes.st b/Task/Character-codes/Smalltalk/character-codes.st new file mode 100644 index 0000000000..be49d0c7c4 --- /dev/null +++ b/Task/Character-codes/Smalltalk/character-codes.st @@ -0,0 +1,2 @@ +($a asInteger) displayNl. "output 97" +(Character value: 97) displayNl. "output a" diff --git a/Task/Character-codes/Tcl/character-codes.tcl b/Task/Character-codes/Tcl/character-codes.tcl new file mode 100644 index 0000000000..949c5ff094 --- /dev/null +++ b/Task/Character-codes/Tcl/character-codes.tcl @@ -0,0 +1,6 @@ +# ASCII +puts [scan "a" %c] ;# ==> 97 +puts [format %c 97] ;# ==> a +# Unicode is the same +puts [scan "π" %c] ;# ==> 960 +puts [format %c 960] ;# ==> π diff --git a/Task/Character-matching/0DESCRIPTION b/Task/Character-matching/0DESCRIPTION new file mode 100644 index 0000000000..907f0168bf --- /dev/null +++ b/Task/Character-matching/0DESCRIPTION @@ -0,0 +1,10 @@ +{{basic data operation}} +Given two strings, demonstrate the following 3 types of matchings: + +# Determining if the first string starts with second string +# Determining if the first string contains the second string at any location +# Determining if the first string ends with the second string + +Optional requirements: +# Print the location of the match for part 2 +# Handle multiple occurrences of a string for part 2. diff --git a/Task/Character-matching/1META.yaml b/Task/Character-matching/1META.yaml new file mode 100644 index 0000000000..ae625822b7 --- /dev/null +++ b/Task/Character-matching/1META.yaml @@ -0,0 +1,2 @@ +--- +note: String manipulation diff --git a/Task/Character-matching/ALGOL-68/character-matching.alg b/Task/Character-matching/ALGOL-68/character-matching.alg new file mode 100644 index 0000000000..b45fab54ba --- /dev/null +++ b/Task/Character-matching/ALGOL-68/character-matching.alg @@ -0,0 +1,18 @@ +# define some appropriate OPerators # +PRIO STARTSWITH = 5, ENDSWITH = 5; +OP STARTSWITH = (STRING str, prefix)BOOL: # assuming LWB = 1 # + IF UPB str < UPB prefix THEN FALSE ELSE str[:UPB prefix]=prefix FI; +OP ENDSWITH = (STRING str, suffix)BOOL: # assuming LWB = 1 # + IF UPB str < UPB suffix THEN FALSE ELSE str[UPB str-UPB suffix+1:]=suffix FI; + +INT loc, loc2; + +print(( + "abcd" STARTSWITH "ab", # returns TRUE # + "abcd" ENDSWITH "zn", # returns FALSE # + string in string("bb",loc,"abab"), # returns FALSE # + string in string("ab",loc,"abab"), # returns TRUE # + (string in string("bb",loc,"abab")|loc|-1), # returns -1 # + (string in string("ab",loc,"abab")|loc|-1), # returns +1 # + (string in string("ab",loc2,"abab"[loc+1:])|loc+loc2|-1) # returns +3 # +)) diff --git a/Task/Character-matching/Ada/character-matching.ada b/Task/Character-matching/Ada/character-matching.ada new file mode 100644 index 0000000000..58dd623b2d --- /dev/null +++ b/Task/Character-matching/Ada/character-matching.ada @@ -0,0 +1,20 @@ +with Ada.Strings.Fixed; use Ada.Strings.Fixed; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Match_Strings is + S1 : constant String := "abcd"; + S2 : constant String := "abab"; + S3 : constant String := "ab"; +begin + if S1'Length >= S3'Length and then S1 (S1'First..S1'First + S3'Length - 1) = S3 then + Put_Line (''' & S1 & "' starts with '" & S3 & '''); + end if; + if S2'Length >= S3'Length and then S2 (S2'Last - S3'Length + 1..S2'Last) = S3 then + Put_Line (''' & S2 & "' ends with '" & S3 & '''); + end if; + Put_Line (''' & S3 & "' first appears in '" & S1 & "' at" & Integer'Image (Index (S1, S3))); + Put_Line + ( ''' & S3 & "' appears in '" & S2 & ''' & + Integer'Image (Ada.Strings.Fixed.Count (S2, S3)) & " times" + ); +end Match_Strings; diff --git a/Task/Character-matching/AutoHotkey/character-matching.ahk b/Task/Character-matching/AutoHotkey/character-matching.ahk new file mode 100644 index 0000000000..09e0ee557b --- /dev/null +++ b/Task/Character-matching/AutoHotkey/character-matching.ahk @@ -0,0 +1,14 @@ +String1 = abcd +String2 = abab + +If (SubStr(String1,1,StrLen(String2)) = String2) + MsgBox, "%String1%" starts with "%String2%". +IfInString, String1, %String2% +{ + Position := InStr(String1,String2) + StringReplace, String1, String1, %String2%, %String2%, UseErrorLevel + MsgBox, "%String1%" contains "%String2%" at position %Position%`, and appears %ErrorLevel% times. +} +StringRight, TempVar, String1, StrLen(String2) +If TempVar = %String2% + MsgBox, "%String1%" ends with "%String2%". diff --git a/Task/Character-matching/AutoIt/character-matching.autoit b/Task/Character-matching/AutoIt/character-matching.autoit new file mode 100644 index 0000000000..fa7682fa58 --- /dev/null +++ b/Task/Character-matching/AutoIt/character-matching.autoit @@ -0,0 +1,29 @@ +$string1 = "arduinoardblobard" +$string2 = "ard" + +; == Determining if the first string starts with second string +If StringLeft($string1, StringLen($string2)) = $string2 Then + ConsoleWrite("1st string starts with 2nd string." & @CRLF) +Else + ConsoleWrite("1st string does'nt starts with 2nd string." & @CRLF) +EndIf + +; == Determining if the first string contains the second string at any location +; == Print the location of the match for part 2 +; == Handle multiple occurrences of a string for part 2 +$start = 1 +$count = 0 +$pos = StringInStr($string1, $string2) +While $pos + $count += 1 + ConsoleWrite("1st string contains 2nd string at position: " & $pos & @CRLF) + $pos = StringInStr($string1, $string2, 0, 1, $start + $pos + StringLen($string2)) +WEnd +If $count = 0 Then ConsoleWrite("1st string does'nt contain 2nd string." & @CRLF) + +; == Determining if the first string ends with the second string +If StringRight($string1, StringLen($string2)) = $string2 Then + ConsoleWrite("1st string ends with 2nd string." & @CRLF) +Else + ConsoleWrite("1st string does'nt ends with 2nd string." & @CRLF) +EndIf diff --git a/Task/Character-matching/BASIC/character-matching.bas b/Task/Character-matching/BASIC/character-matching.bas new file mode 100644 index 0000000000..10447b51ff --- /dev/null +++ b/Task/Character-matching/BASIC/character-matching.bas @@ -0,0 +1,27 @@ +first$ = "qwertyuiop" + +'Determining if the first string starts with second string +second$ = "qwerty" +IF LEFT$(first$, LEN(second$)) = second$ THEN + PRINT "'"; first$; "' starts with '"; second$; "'" +ELSE + PRINT "'"; first$; "' does not start with '"; second$; "'" +END IF + +'Determining if the first string contains the second string at any location +'Print the location of the match for part 2 +second$ = "wert" +x = INSTR(first$, second$) +IF x THEN + PRINT "'"; first$; "' contains '"; second$; "' at position "; x +ELSE + PRINT "'"; first$; "' does not contain '"; second$; "'" +END IF + +' Determining if the first string ends with the second string +second$ = "random garbage" +IF RIGHT$(first$, LEN(second$)) = second$ THEN + PRINT "'"; first$; "' ends with '"; second$; "'" +ELSE + PRINT "'"; first$; "' does not end with '"; second$; "'" +END IF diff --git a/Task/Character-matching/BBC-BASIC/character-matching.bbc b/Task/Character-matching/BBC-BASIC/character-matching.bbc new file mode 100644 index 0000000000..601228986f --- /dev/null +++ b/Task/Character-matching/BBC-BASIC/character-matching.bbc @@ -0,0 +1,32 @@ + first$ = "The fox jumps over the dog" + + FOR test% = 1 TO 3 + READ second$ + starts% = FN_first_starts_with_second(first$, second$) + IF starts% PRINT """" first$ """ starts with """ second$ """" + ends% = FN_first_ends_with_second(first$, second$) + IF ends% PRINT """" first$ """ ends with """ second$ """" + where% = FN_first_contains_second_where(first$, second$) + IF where% PRINT """" first$ """ contains """ second$ """ at position " ; where% + howmany% = FN_first_contains_second_howmany(first$, second$) + IF howmany% PRINT """" first$ """ contains """ second$ """ " ; howmany% " time(s)" + NEXT + DATA "The", "he", "dog" + END + + DEF FN_first_starts_with_second(A$, B$) + = B$ = LEFT$(A$, LEN(B$)) + + DEF FN_first_ends_with_second(A$, B$) + = B$ = RIGHT$(A$, LEN(B$)) + + DEF FN_first_contains_second_where(A$, B$) + = INSTR(A$, B$) + + DEF FN_first_contains_second_howmany(A$, B$) + LOCAL I%, N% : I% = 0 + REPEAT + I% = INSTR(A$, B$, I%+1) + IF I% THEN N% += 1 + UNTIL I% = 0 + = N% diff --git a/Task/Character-matching/Bracmat/character-matching.bracmat b/Task/Character-matching/Bracmat/character-matching.bracmat new file mode 100644 index 0000000000..e31e239b1c --- /dev/null +++ b/Task/Character-matching/Bracmat/character-matching.bracmat @@ -0,0 +1,9 @@ +( (sentence="I want a number such that that number will be even.") +& out$(@(!sentence:I ?) & "sentence starts with 'I'" | "sentence does not start with 'I'") +& out$(@(!sentence:? such ?) & "sentence contains 'such'" | "sentence does not contain 'such'") +& out$(@(!sentence:? "even.") & "sentence ends with 'even.'" | "sentence does not end with 'even.'") +& 0:?N +& ( @(!sentence:? be (? & !N+1:?N & ~)) + | out$str$("sentence contains " !N " occurrences of 'be'") + ) +) diff --git a/Task/Character-matching/C++/character-matching.cpp b/Task/Character-matching/C++/character-matching.cpp new file mode 100644 index 0000000000..2236370d64 --- /dev/null +++ b/Task/Character-matching/C++/character-matching.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; + +string s1="abcd"; +string s2="abab"; +string s3="ab"; +//Beginning +s1.compare(0,s3.size(),s3)==0; +//End +s1.compare(s1.size()-s3.size(),s3.size(),s3)==0; +//Anywhere +s1.find(s2)//returns string::npos +int loc=s2.find(s3)//returns 0 +loc=s2.find(s3,loc+1)//returns 2 diff --git a/Task/Character-matching/C/character-matching-1.c b/Task/Character-matching/C/character-matching-1.c new file mode 100644 index 0000000000..bbd2ebc93d --- /dev/null +++ b/Task/Character-matching/C/character-matching-1.c @@ -0,0 +1,32 @@ +#include +#include + +int startsWith(const char* container, const char* target) +{ + size_t clen = strlen(container), tlen = strlen(target); + if (clen < tlen) + return 0; + return strncmp(container, target, tlen) == 0; +} + +int endsWith(const char* container, const char* target) +{ + size_t clen = strlen(container), tlen = strlen(target); + if (clen < tlen) + return 0; + return strncmp(container + clen - tlen, target, tlen) == 0; +} + +int doesContain(const char* container, const char* target) +{ + return strstr(container, target) != 0; +} + +int main(void) +{ + printf("Starts with Test ( Hello,Hell ) : %d\n", startsWith("Hello","Hell")); + printf("Ends with Test ( Code,ode ) : %d\n", endsWith("Code","ode")); + printf("Contains Test ( Google,msn ) : %d\n", doesContain("Google","msn")); + + return 0; +} diff --git a/Task/Character-matching/C/character-matching-2.c b/Task/Character-matching/C/character-matching-2.c new file mode 100644 index 0000000000..8fa9244077 --- /dev/null +++ b/Task/Character-matching/C/character-matching-2.c @@ -0,0 +1,44 @@ +#include + +/* returns 0 if no match, 1 if matched, -1 if matched and at end */ +int s_cmp(const char *a, const char *b) +{ + char c1 = 0, c2 = 0; + while (c1 == c2) { + c1 = *(a++); + if ('\0' == (c2 = *(b++))) + return c1 == '\0' ? -1 : 1; + } + return 0; +} + +/* returns times matched */ +int s_match(const char *a, const char *b) +{ + int i = 0, count = 0; + printf("matching `%s' with `%s':\n", a, b); + + while (a[i] != '\0') { + switch (s_cmp(a + i, b)) { + case -1: + printf("matched: pos %d (at end)\n\n", i); + return ++count; + case 1: + printf("matched: pos %d\n", i); + ++count; + break; + } + i++; + } + printf("end match\n\n"); + return count; +} + +int main() +{ + s_match("A Short String", "ort S"); + s_match("aBaBaBaBa", "aBa"); + s_match("something random", "Rand"); + + return 0; +} diff --git a/Task/Character-matching/Clojure/character-matching.clj b/Task/Character-matching/Clojure/character-matching.clj new file mode 100644 index 0000000000..fe95e6e5f7 --- /dev/null +++ b/Task/Character-matching/Clojure/character-matching.clj @@ -0,0 +1,10 @@ +(def evals '((. "abcd" startsWith "ab") + (. "abcd" endsWith "zn") + (. "abab" contains "bb") + (. "abab" contains "ab") + (. "abab" indexOf "bb") + (let [loc (. "abab" indexOf "ab")] + (. "abab" indexOf "ab" (dec loc))))) + +user> (for [i evals] [i (eval i)]) +([(. "abcd" startsWith "ab") true] [(. "abcd" endsWith "zn") false] [(. "abab" contains "bb") false] [(. "abab" contains "ab") true] [(. "abab" indexOf "bb") -1] [(let [loc (. "abab" indexOf "ab")] (. "abab" indexOf "ab" (dec loc))) 0]) diff --git a/Task/Character-matching/CoffeeScript/character-matching.coffee b/Task/Character-matching/CoffeeScript/character-matching.coffee new file mode 100644 index 0000000000..6517b7a3b0 --- /dev/null +++ b/Task/Character-matching/CoffeeScript/character-matching.coffee @@ -0,0 +1,20 @@ +matchAt = (s, frag, i) -> + s[i...i+frag.length] == frag + +startsWith = (s, frag) -> + matchAt s, frag, 0 + +endsWith = (s, frag) -> + matchAt s, frag, s.length - frag.length + +matchLocations = (s, frag) -> + (i for i in [0..s.length - frag.length] when matchAt s, frag, i) + +console.log startsWith "tacoloco", "taco" # true +console.log startsWith "taco", "tacoloco" # false +console.log startsWith "tacoloco", "talk" # false +console.log endsWith "tacoloco", "loco" # true +console.log endsWith "loco", "tacoloco" # false +console.log endsWith "tacoloco", "yoco" # false +console.log matchLocations "bababab", "bab" # [0,2,4] +console.log matchLocations "xxx", "x" # [0,1,2] diff --git a/Task/Character-matching/D/character-matching.d b/Task/Character-matching/D/character-matching.d new file mode 100644 index 0000000000..c0d3877c43 --- /dev/null +++ b/Task/Character-matching/D/character-matching.d @@ -0,0 +1,16 @@ +import std.stdio: writeln; +import std.algorithm: startsWith, endsWith, find, countUntil; + +void main() { + writeln("abcd".startsWith("ab")); // true + writeln("abcd".endsWith("zn")); // false + writeln("abab".find("bb")); // empty array (no match) + writeln("abcd".find("bc")); // "bcd" (substring start + // at match) + writeln("abab".countUntil("bb")); // -1 (no match) + writeln("abab".countUntil("ba")); // 1 (index of 1st match) + + // std.algorithm.startsWith also works on arrays and ranges: + writeln([1, 2, 3].countUntil(3)); // 2 + writeln([1, 2, 3].countUntil([2, 3])); // 1 +} diff --git a/Task/Character-matching/Delphi/character-matching.delphi b/Task/Character-matching/Delphi/character-matching.delphi new file mode 100644 index 0000000000..031cba833a --- /dev/null +++ b/Task/Character-matching/Delphi/character-matching.delphi @@ -0,0 +1,13 @@ +program CharacterMatching; + +{$APPTYPE CONSOLE} + +uses StrUtils; + +begin + WriteLn(AnsiStartsText('ab', 'abcd')); // True + WriteLn(AnsiEndsText('zn', 'abcd')); // False + WriteLn(AnsiContainsText('abcd', 'bb')); // False + Writeln(AnsiContainsText('abcd', 'ab')); // True + WriteLn(Pos('ab', 'abcd')); // 1 +end. diff --git a/Task/Character-matching/E/character-matching.e b/Task/Character-matching/E/character-matching.e new file mode 100644 index 0000000000..615d3a24fe --- /dev/null +++ b/Task/Character-matching/E/character-matching.e @@ -0,0 +1,11 @@ +def f(string1, string2) { + println(string1.startsWith(string2)) + + var index := 0 + while ((index := string1.startOf(string2, index)) != -1) { + println(`at $index`) + index += 1 + } + + println(string1.endsWith(string2)) +} diff --git a/Task/Character-matching/Elena/character-matching.elena b/Task/Character-matching/Elena/character-matching.elena new file mode 100644 index 0000000000..180bef46ce --- /dev/null +++ b/Task/Character-matching/Elena/character-matching.elena @@ -0,0 +1,22 @@ +#define std'dictionary'*. +#define std'routines'strings'*. + +// --- Program --- + +#symbol Program = +[ + #if "hello"~eliteralop starting_with'if:"hel" + [ + 'program'output << "hello starts with hel%n". + ]. + + #if "hello"~eliteralop ending_with'if:"llo" + [ + 'program'output << "hello ends with llo%n". + ]. + + #if (-1) ifequal:("hello"~eliteralop first_occ'find:"el") + | [ + 'program'output << "hello contains el%n". + ]. +]. diff --git a/Task/Character-matching/Erlang/character-matching.erl b/Task/Character-matching/Erlang/character-matching.erl new file mode 100644 index 0000000000..59577c4061 --- /dev/null +++ b/Task/Character-matching/Erlang/character-matching.erl @@ -0,0 +1,28 @@ +-module(character_matching). +-export([starts_with/2,ends_with/2,contains/2]). + +%% Both starts_with and ends_with are mappings to 'lists:prefix/2' and +%% 'lists:suffix/2', respectively. + +starts_with(S1,S2) -> + lists:prefix(S2,S1). + +ends_with(S1,S2) -> + lists:suffix(S2,S1). + +contains(S1,S2) -> + contains(S1,S2,1,[]). + +%% While S1 is at least as long as S2 we check if S2 is its prefix, +%% storing the result if it is. When S1 is shorter than S2, we return +%% the result. NB: this will work on any arbitrary list in erlang +%% since it makes no distinction between strings and lists. +contains([_|T]=S1,S2,N,Acc) when length(S2) =< length(S1) -> + case starts_with(S1,S2) of + true -> + contains(T,S2,N+1,[N|Acc]); + false -> + contains(T,S2,N+1,Acc) + end; +contains(_S1,_S2,_N,Acc) -> + Acc. diff --git a/Task/Character-matching/Euphoria/character-matching.euphoria b/Task/Character-matching/Euphoria/character-matching.euphoria new file mode 100644 index 0000000000..cc361a5961 --- /dev/null +++ b/Task/Character-matching/Euphoria/character-matching.euphoria @@ -0,0 +1,30 @@ +sequence first, second +integer x + +first = "qwertyuiop" + +-- Determining if the first string starts with second string +second = "qwerty" +if match(second, first) = 1 then + printf(1, "'%s' starts with '%s'\n", {first, second}) +else + printf(1, "'%s' does not start with '%s'\n", {first, second}) +end if + +-- Determining if the first string contains the second string at any location +-- Print the location of the match for part 2 +second = "wert" +x = match(second, first) +if x then + printf(1, "'%s' contains '%s' at position %d\n", {first, second, x}) +else + printf(1, "'%s' does not contain '%s'\n", {first, second}) +end if + +-- Determining if the first string ends with the second string +second = "uio" +if length(second)<=length(first) and match_from(second, first, length(first)-length(second)+1) then + printf(1, "'%s' ends with '%s'\n", {first, second}) +else + printf(1, "'%s' does not end with '%s'\n", {first, second}) +end if diff --git a/Task/Character-matching/Forth/character-matching.fth b/Task/Character-matching/Forth/character-matching.fth new file mode 100644 index 0000000000..bfb3da31c0 --- /dev/null +++ b/Task/Character-matching/Forth/character-matching.fth @@ -0,0 +1,5 @@ +: starts-with ( a l a2 l2 -- ? ) + tuck 2>r min 2r> compare 0= ; +: ends-with ( a l a2 l2 -- ? ) + tuck 2>r negate over + 0 max /string 2r> compare 0= ; +\ use SEARCH ( a l a2 l2 -- a3 l3 ? ) for contains diff --git a/Task/Character-matching/Go/character-matching.go b/Task/Character-matching/Go/character-matching.go new file mode 100644 index 0000000000..fa3a350917 --- /dev/null +++ b/Task/Character-matching/Go/character-matching.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "strings" +) + +func match(first, second string) { + fmt.Printf("1. %s starts with %s: %t\n", + first, second, strings.HasPrefix(first, second)) + i := strings.Index(first, second) + fmt.Printf("2. %s contains %s: %t,\n", first, second, i >= 0) + if i >= 0 { + fmt.Printf("2.1. at location %d,\n", i) + for start := i+1;; { + if i = strings.Index(first[start:], second); i < 0 { + break + } + fmt.Printf("2.2. at location %d,\n", start+i) + start += i+1 + } + fmt.Println("2.2. and that's all") + } + fmt.Printf("3. %s ends with %s: %t\n", + first, second, strings.HasSuffix(first, second)) +} + +func main() { + match("abracadabra", "abr") +} diff --git a/Task/Character-matching/Haskell/character-matching-1.hs b/Task/Character-matching/Haskell/character-matching-1.hs new file mode 100644 index 0000000000..5432bd372c --- /dev/null +++ b/Task/Character-matching/Haskell/character-matching-1.hs @@ -0,0 +1,12 @@ +> import Data.List +> "abc" `isPrefixOf` "abcdefg" +True +> "efg" `isSuffixOf` "abcdefg" +True +> "bcd" `isInfixOf` "abcdefg" +True +> "abc" `isInfixOf` "abcdefg" -- Prefixes and suffixes are also infixes +True +> let infixes a b = findIndices (isPrefixOf a) $ tails b +> infixes "ab" "abcdefabqqab" +[0,6,10] diff --git a/Task/Character-matching/Haskell/character-matching-2.hs b/Task/Character-matching/Haskell/character-matching-2.hs new file mode 100644 index 0000000000..11301997f2 --- /dev/null +++ b/Task/Character-matching/Haskell/character-matching-2.hs @@ -0,0 +1,10 @@ +procedure main() + + write("Matching s2 :=",image(s2 := "ab")," within s1:= ",image(s1 := "abcdabab")) + + write("Test #1 beginning ",if match(s2,s1) then "matches " else "failed") + writes("Test #2 all matches at positions [") + every writes(" ",find(s2,s1)|"]\n") + write("Test #3 ending ", if s1[0-:*s2] == s2 then "matches" else "fails") + +end diff --git a/Task/Character-matching/Java/character-matching.java b/Task/Character-matching/Java/character-matching.java new file mode 100644 index 0000000000..b448d0370d --- /dev/null +++ b/Task/Character-matching/Java/character-matching.java @@ -0,0 +1,7 @@ +"abcd".startsWith("ab") //returns true +"abcd".endsWith("zn") //returns false +"abab".contains("bb") //returns false +"abab".contains("ab") //returns true +int loc = "abab".indexOf("bb") //returns -1 +loc = "abab".indexOf("ab") //returns 0 +loc = "abab".indexOf("ab",loc+1) //returns 2 diff --git a/Task/Character-matching/JavaScript/character-matching.js b/Task/Character-matching/JavaScript/character-matching.js new file mode 100644 index 0000000000..1ac2df4784 --- /dev/null +++ b/Task/Character-matching/JavaScript/character-matching.js @@ -0,0 +1,27 @@ +var stringA = "tacoloco" + , stringB = "co" + , q1, q2, q2multi, m + , q2matches = [] + +// stringA starts with stringB +q1 = stringA.substring(0, stringB.length) == stringB + +// stringA contains stringB +q2 = stringA.indexOf(stringB) + +// multiple matches +q2multi = new RegExp(stringB,'g') + +while(m = q2multi.exec(stringA)){ + q2matches.push(m.index) +} + +// stringA ends with stringB +q3 = stringA.substr(-stringB.length) == stringB + +console.log("1: Does '"+stringA+"' start with '"+stringB+"'? " + ( q1 ? "Yes." : "No.")) +console.log("2: Is '"+stringB+"' contained in '"+stringA+"'? " + (~q2 ? "Yes, at index "+q2+"." : "No.")) +if (~q2 && q2matches.length > 1){ + console.log(" In fact, it happens "+q2matches.length+" times within '"+stringA+"', at index"+(q2matches.length > 1 ? "es" : "")+" "+q2matches.join(', ')+".") +} +console.log("3: Does '"+stringA+"' end with '"+stringB+"'? " + ( q3 ? "Yes." : "No.")) diff --git a/Task/Character-matching/Lua/character-matching.lua b/Task/Character-matching/Lua/character-matching.lua new file mode 100644 index 0000000000..52c0b55593 --- /dev/null +++ b/Task/Character-matching/Lua/character-matching.lua @@ -0,0 +1,13 @@ +s1 = "string" +s2 = "str" +s3 = "ing" +s4 = "xyz" + +print( "s1 starts with s2: ", string.find( s1, s2 ) == 1 ) +print( "s1 starts with s3: ", string.find( s1, s3 ) == 1, "\n" ) + +print( "s1 contains s3: ", string.find( s1, s3 ) ~= nil ) +print( "s1 contains s3: ", string.find( s1, s4 ) ~= nil, "\n" ) + +print( "s1 ends with s2: ", select( 2, string.find( s1, s2 ) ) == string.len( s1 ) ) +print( "s1 ends with s3: ", select( 2, string.find( s1, s3 ) ) == string.len( s1 ) ) diff --git a/Task/Character-matching/MATLAB/character-matching.m b/Task/Character-matching/MATLAB/character-matching.m new file mode 100644 index 0000000000..2d4d5b0d69 --- /dev/null +++ b/Task/Character-matching/MATLAB/character-matching.m @@ -0,0 +1,11 @@ + % 1. Determining if the first string starts with second string + strcmp(str1,str2,length(str2)) + % 2. Determining if the first string contains the second string at any location + ~isempty(strfind(s1,s2)) + % 3. Determining if the first string ends with the second string + ( (length(str1)>=length(str2)) && strcmp(str1(end+[1-length(str2):0]),str2) ) + + % 1. Print the location of the match for part 2 + disp(strfind(s1,s2)) + % 2. Handle multiple occurrences of a string for part 2. + ix = strfind(s1,s2); % ix is a vector containing the starting positions of s2 within s1 diff --git a/Task/Character-matching/Perl/character-matching.pl b/Task/Character-matching/Perl/character-matching.pl new file mode 100644 index 0000000000..419de1ebe2 --- /dev/null +++ b/Task/Character-matching/Perl/character-matching.pl @@ -0,0 +1,8 @@ +# the first four examples use regular expressions, so make sure to escape any special regex characters in the substring +"abcd" =~ /^ab/ #returns true +"abcd" =~ /zn$/ #returns false +"abab" =~ /bb/ #returns false +"abab" =~ /ab/ #returns true +my $loc = index("abab", "bb") #returns -1 +$loc = index("abab", "ab") #returns 0 +$loc = index("abab", "ab", $loc+1) #returns 2 diff --git a/Task/Character-matching/PicoLisp/character-matching.l b/Task/Character-matching/PicoLisp/character-matching.l new file mode 100644 index 0000000000..19279c8f3f --- /dev/null +++ b/Task/Character-matching/PicoLisp/character-matching.l @@ -0,0 +1,24 @@ +: (pre? "ab" "abcd") +-> "abcd" +: (pre? "xy" "abcd") +-> NIL + +: (sub? "bc" "abcd") +-> "abcd" +: (sub? "xy" "abcd") +-> NIL + +: (tail (chop "cd") (chop "abcd")) +-> ("c" "d") +: (tail (chop "xy") (chop "abcd")) +-> NIL + + +(de positions (Pat Str) + (setq Pat (chop Pat)) + (make + (for ((I . L) (chop Str) L (cdr L)) + (and (head Pat L) (link I)) ) ) ) + +: (positions "bc" "abcdabcd") +-> (2 6) diff --git a/Task/Character-matching/Python/character-matching.py b/Task/Character-matching/Python/character-matching.py new file mode 100644 index 0000000000..012f120d69 --- /dev/null +++ b/Task/Character-matching/Python/character-matching.py @@ -0,0 +1,7 @@ +"abcd".startswith("ab") #returns True +"abcd".endswith("zn") #returns False +"bb" in "abab" #returns False +"ab" in "abab" #returns True +loc = "abab".find("bb") #returns -1 +loc = "abab".find("ab") #returns 0 +loc = "abab".find("ab",loc+1) #returns 2 diff --git a/Task/Character-matching/REXX/character-matching.rexx b/Task/Character-matching/REXX/character-matching.rexx new file mode 100644 index 0000000000..910f0680d2 --- /dev/null +++ b/Task/Character-matching/REXX/character-matching.rexx @@ -0,0 +1,36 @@ +/*REXX program demonstrates some basic character string testing. */ +parse arg a b +say 'string A=' a +say 'string B=' b +say + +if left(A,length(b))==b then say 'string A starts with string B' + else say "string A doesn't start with string B" +say + + /*another method, however a wee bit obtuse. */ +/*¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬ +if compare(a,b)==length(b) then say 'string A starts with string B' + else say "string A doesn't start with string B" +¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬*/ + +p=pos(b,a) +if p\==0 then say 'string A contains string B (starting in position' p")" + else say "string A doesn't contains string B" +say + +if right(A,length(b))==b then say 'string A ends with string B' + else say "string A doesn't end with string B" +say +Ps=''; p=0; do forever until p==0 + p = pos(b, a, p+1) + if p\==0 then Ps = Ps',' p + end /*forever until p==0*/ +Ps = space(strip(Ps,'L',",")) +times = words(Ps) +if times\==0 then say 'string A contains string B', + times 'time'left('s',times>1), + "(at position"left('s',times>1) Ps')' + else say "string A doesn't contains string B" + + /*stick a fork in it, we're done.*/ diff --git a/Task/Character-matching/Racket/character-matching.rkt b/Task/Character-matching/Racket/character-matching.rkt new file mode 100644 index 0000000000..11cd5b578d --- /dev/null +++ b/Task/Character-matching/Racket/character-matching.rkt @@ -0,0 +1,6 @@ +#lang racket +(require srfi/13) +(string-prefix? "ab" "abcd") +(string-suffix? "cd" "abcd") +(string-contains "abab" "bb") +(string-contains "abab" "ba") diff --git a/Task/Character-matching/Ruby/character-matching.rb b/Task/Character-matching/Ruby/character-matching.rb new file mode 100644 index 0000000000..b5b9fa6259 --- /dev/null +++ b/Task/Character-matching/Ruby/character-matching.rb @@ -0,0 +1,8 @@ +p 'abcd'.start_with?('ab') #returns true +p 'abcd'.end_with?('ab') #returns false +p 'abab'.include?('bb') #returns false +p 'abab'.include?('ab') #returns true +p 'abab'.index('bb') #returns nil +p 'abab'.index('ab') #returns 0 +p 'abab'.index('ab', 1) #returns 2 +p 'abab'.rindex('ab') #returns 2 diff --git a/Task/Character-matching/Scala/character-matching.scala b/Task/Character-matching/Scala/character-matching.scala new file mode 100644 index 0000000000..bfd30485d9 --- /dev/null +++ b/Task/Character-matching/Scala/character-matching.scala @@ -0,0 +1,8 @@ +"abcd".startsWith("ab") //returns true +"abcd".endsWith("zn") //returns false +"abab".contains("bb") //returns false +"abab".contains("ab") //returns true + +var loc="abab".indexOf("bb") //returns -1 +loc = "abab".indexOf("ab") //returns 0 +loc = "abab".indexOf("ab", loc+1) //returns 2 diff --git a/Task/Character-matching/Smalltalk/character-matching.st b/Task/Character-matching/Smalltalk/character-matching.st new file mode 100644 index 0000000000..1bbd4d6211 --- /dev/null +++ b/Task/Character-matching/Smalltalk/character-matching.st @@ -0,0 +1,5 @@ +a startsWith: b +a includesSubCollection: b +a endsWith: b +a indexOfSubCollection: b +a indexOfSubCollection: b startingAt: pos diff --git a/Task/Character-matching/Tcl/character-matching-1.tcl b/Task/Character-matching/Tcl/character-matching-1.tcl new file mode 100644 index 0000000000..3c474db3f9 --- /dev/null +++ b/Task/Character-matching/Tcl/character-matching-1.tcl @@ -0,0 +1,3 @@ +set isPrefix [string equal -length [string length $needle] $haystack $needle] +set isContained [expr {[string first $needle $haystack] >= 0}] +set isSuffix [string equal $needle [string range $haystack end-[expr {[string length $needle]-1}] end]] diff --git a/Task/Character-matching/Tcl/character-matching-2.tcl b/Task/Character-matching/Tcl/character-matching-2.tcl new file mode 100644 index 0000000000..da26c894fe --- /dev/null +++ b/Task/Character-matching/Tcl/character-matching-2.tcl @@ -0,0 +1,3 @@ +set isPrefix [string match $needle* $haystack] +set isContained [string match *$needle* $haystack] +set isSuffix [string match *$needle $haystack] diff --git a/Task/Character-matching/Tcl/character-matching-3.tcl b/Task/Character-matching/Tcl/character-matching-3.tcl new file mode 100644 index 0000000000..41f907d26a --- /dev/null +++ b/Task/Character-matching/Tcl/character-matching-3.tcl @@ -0,0 +1 @@ +set isContained [regexp ***=$needle $haystack] diff --git a/Task/Character-matching/Tcl/character-matching-4.tcl b/Task/Character-matching/Tcl/character-matching-4.tcl new file mode 100644 index 0000000000..3b2478078b --- /dev/null +++ b/Task/Character-matching/Tcl/character-matching-4.tcl @@ -0,0 +1,12 @@ +set matchLocations [regexp -indices -all -inline ***=$needle $haystack] +# Each match location is a pair, being the index into the string where the needle started +# to match and the index where the needle finished matching + +set isContained [expr {[llength $matchLocations] > 0}] +set isPrefix [expr {[lindex $matchLocations 0 0] == 0}] +set isSuffix [expr {[lindex $matchLocations end 1] == [string length $haystack]-1}] +set firstMatchStart [lindex $matchLocations 0 0] +puts "Found \"$needle\" in \"$haystack\" at $firstMatchStart" +foreach location $matchLocations { + puts "needle matched at index [lindex $location 0]" +} diff --git a/Task/Chat-server/0DESCRIPTION b/Task/Chat-server/0DESCRIPTION new file mode 100644 index 0000000000..75d20e7776 --- /dev/null +++ b/Task/Chat-server/0DESCRIPTION @@ -0,0 +1 @@ +Write a server for a minimal text based chat. People should be able to connect via ‘telnet’, sign on with a nickname, and type messages which will then be seen by all other connected users. Arrivals and departures of chat members should generate appropriate notification messages. diff --git a/Task/Chat-server/1META.yaml b/Task/Chat-server/1META.yaml new file mode 100644 index 0000000000..688669690e --- /dev/null +++ b/Task/Chat-server/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Networking and Web Interaction diff --git a/Task/Chat-server/Ada/chat-server.ada b/Task/Chat-server/Ada/chat-server.ada new file mode 100644 index 0000000000..1c9f22cabc --- /dev/null +++ b/Task/Chat-server/Ada/chat-server.ada @@ -0,0 +1,85 @@ +with Ada.Containers.Vectors; +with Ada.Command_Line; use Ada.Command_Line; +with Ada.Exceptions; use Ada.Exceptions; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Sockets; use Sockets; + +procedure Chat_Server is + + package Client_Vectors is new Ada.Containers.Vectors + (Element_Type => Socket_FD, Index_Type => Positive); + All_Clients : Client_Vectors.Vector; + + procedure Write (S : String) is + procedure Output (Position : Client_Vectors.Cursor) is + Sock : Socket_FD := Client_Vectors.Element (Position); + begin + Put_Line (Sock, S); + end Output; + begin + All_Clients.Iterate (Output'Access); + end Write; + + task type Client_Task is + entry Start (FD : Socket_FD); + end Client_Task; + + task body Client_Task is + Sock : Socket_FD; + Sock_ID : Positive; + Name : Unbounded_String; + begin + select + accept Start (FD : Socket_FD) do + Sock := FD; + end Start; + or + terminate; + end select; + + while Name = Null_Unbounded_String loop + Put (Sock, "Enter Name:"); + Name := To_Unbounded_String (Get_Line (Sock)); + end loop; + Write (To_String (Name) & " joined."); + All_Clients.Append (Sock); + Sock_ID := All_Clients.Find_Index (Sock); + loop + declare + Input : String := Get_Line (Sock); + begin + Write (To_String (Name) & ": " & Input); + end; + end loop; + exception + when Connection_Closed => + Put_Line ("Connection closed"); + Shutdown (Sock, Both); + All_Clients.Delete (Sock_ID); + Write (To_String (Name) & " left."); + end Client_Task; + + Accepting_Socket : Socket_FD; + Incoming_Socket : Socket_FD; + + type Client_Access is access Client_Task; + Dummy : Client_Access; +begin + if Argument_Count /= 1 then + Raise_Exception (Constraint_Error'Identity, + "Usage: " & Command_Name & " port"); + end if; + Socket (Accepting_Socket, PF_INET, SOCK_STREAM); + Setsockopt (Accepting_Socket, SOL_SOCKET, SO_REUSEADDR, 1); + Bind (Accepting_Socket, Positive'Value (Argument (1))); + Listen (Accepting_Socket); + loop + Put_Line ("Waiting for new connection"); + Accept_Socket (Accepting_Socket, Incoming_Socket); + Put_Line ("New connection acknowledged"); + + Dummy := new Client_Task; + Dummy.Start (Incoming_Socket); + end loop; +end Chat_Server; diff --git a/Task/Chat-server/C/chat-server.c b/Task/Chat-server/C/chat-server.c new file mode 100644 index 0000000000..f0c48778bd --- /dev/null +++ b/Task/Chat-server/C/chat-server.c @@ -0,0 +1,248 @@ +#include +#include +#include +#include +#include +#include + +int tsocket; +struct sockaddr_in tsockinfo; +fd_set status, current; +void ClientText(int handle, char *buf, int buf_len); + +struct client +{ + char buffer[4096]; + int pos; + char name[32]; +} *connections[FD_SETSIZE]; + +void AddConnection(int handle) +{ + connections[handle] = malloc(sizeof(struct client)); + connections[handle]->buffer[0] = '\0'; + connections[handle]->pos = 0; + connections[handle]->name[0] = '\0'; +} + +void CloseConnection(int handle) +{ + char buf[512]; + int j; + + FD_CLR(handle, &status); + + if (connections[handle]->name[0]) + { + sprintf(buf, "* Disconnected: %s\r\n", connections[handle]->name); + + for (j = 0; j < FD_SETSIZE; j++) + { + if (handle != j && j != tsocket && FD_ISSET(j, &status)) + { + if (write(j, buf, strlen(buf)) < 0) + { + CloseConnection(j); + } + } + } + } else + { + printf ("-- Connection %d disconnected\n", handle); + } + if (connections[handle]) + { + free(connections[handle]); + } + close(handle); +} + +void strip(char *buf) +{ + char *x; + + x = strchr(buf, '\n'); + if (x) { *x='\0'; } + x = strchr(buf, '\r'); + if (x) { *x='\0'; } +} + +int RelayText(int handle) +{ + char *begin, *end; + int ret = 0; + begin = connections[handle]->buffer; + if (connections[handle]->pos == 4000) + { + if (begin[3999] != '\n') + begin[4000] = '\0'; + else { + begin[4000] = '\n'; + begin[4001] = '\0'; + } + } else { + begin[connections[handle]->pos] = '\0'; + } + + end = strchr(begin, '\n'); + while (end != NULL) + { + char output[8000]; + output[0] = '\0'; + if (!connections[handle]->name[0]) + { + strncpy(connections[handle]->name, begin, 31); + connections[handle]->name[31] = '\0'; + + strip(connections[handle]->name); + sprintf(output, "* Connected: %s\r\n", connections[handle]->name); + ret = 1; + } else + { + sprintf(output, "%s: %.*s\r\n", connections[handle]->name, + end-begin, begin); + ret = 1; + } + + if (output[0]) + { + int j; + for (j = 0; j < FD_SETSIZE; j++) + { + if (handle != j && j != tsocket && FD_ISSET(j, &status)) + { + if (write(j, output, strlen(output)) < 0) + { + CloseConnection(j); + } + } + } + } + begin = end+1; + end = strchr(begin, '\n'); + } + + strcpy(connections[handle]->buffer, begin); + connections[handle]->pos -= begin - connections[handle]->buffer; + return ret; +} + +void ClientText(int handle, char *buf, int buf_len) +{ + int i, j; + if (!connections[handle]) + return; + j = connections[handle]->pos; + + for (i = 0; i < buf_len; ++i, ++j) + { + connections[handle]->buffer[j] = buf[i]; + + if (j == 4000) + { + while (RelayText(handle)); + j = connections[handle]->pos; + } + } + connections[handle]->pos = j; + + while (RelayText(handle)); +} + + +int ChatLoop() +{ + int i, j; + FD_ZERO(&status); + + FD_SET(tsocket, &status); + FD_SET(0, &status); + + while(1) + { + current = status; + if (select(FD_SETSIZE, ¤t, NULL, NULL, NULL)==-1) + { + perror("Select"); + return 0; + } + for (i = 0; i < FD_SETSIZE; ++i) + { + if (FD_ISSET(i, ¤t)) + { + if (i == tsocket) + { + struct sockaddr_in cliinfo; + socklen_t addrlen = sizeof(cliinfo); + int handle; + handle = accept(tsocket, &cliinfo, &addrlen); + if (handle == -1) + { + perror ("Couldn't accept connection"); + } else if (handle > FD_SETSIZE) + { + printf ("Unable to accept new connection.\n"); + close(handle); + } + else + { + if (write(handle, "Enter name: ", 12) >= 0) + { + printf("-- New connection %d from %s:%hu\n", + handle, + inet_ntoa (cliinfo.sin_addr), + ntohs(cliinfo.sin_port)); + FD_SET(handle, &status); + + AddConnection(handle); + } + } + } /* Read data, relay to others. */ + else + { + char buf[512]; + int b; + + b = read(i, buf, 500); + if (b <= 0) + { + CloseConnection(i); + } + else + { + ClientText(i, buf, b); + } + } + } + } + } /* While 1 */ +} + +int main (int argc, char*argv[]) +{ + tsocket = socket(PF_INET, SOCK_STREAM, 0); + + tsockinfo.sin_family = AF_INET; + tsockinfo.sin_port = htons(7070); + if (argc > 1) + { + tsockinfo.sin_port = htons(atoi(argv[1])); + } + tsockinfo.sin_addr.s_addr = htonl(INADDR_ANY); + printf ("Socket %d on port %hu\n", tsocket, ntohs(tsockinfo.sin_port)); + + if (bind(tsocket, &tsockinfo, sizeof(tsockinfo)) == -1) + { + perror("Couldn't bind socket"); + return -1; + } + + if (listen(tsocket, 10) == -1) + { + perror("Couldn't listen to port"); + } + + ChatLoop(); + + return 0; +} diff --git a/Task/Chat-server/CoffeeScript/chat-server.coffee b/Task/Chat-server/CoffeeScript/chat-server.coffee new file mode 100644 index 0000000000..eeeaccb66c --- /dev/null +++ b/Task/Chat-server/CoffeeScript/chat-server.coffee @@ -0,0 +1,107 @@ +net = require("net") +sys = require("sys") +EventEmitter = require("events").EventEmitter + +isNicknameLegal = (nickname) -> + return false unless nickname.replace(/[A-Za-z0-9]*/, "") is "" + for used_nick of @chatters + return false if used_nick is nickname + true + +class ChatServer + constructor: -> + @chatters = {} + @server = net.createServer @handleConnection + @server.listen 1212, "localhost" + + handleConnection: (connection) => + console.log "Incoming connection from " + connection.remoteAddress + connection.setEncoding "utf8" + chatter = new Chatter(connection, this) + chatter.on "chat", @handleChat + chatter.on "join", @handleJoin + chatter.on "leave", @handleLeave + + handleChat: (chatter, message) => + @sendToEveryChatterExcept chatter, chatter.nickname + ": " + message + + handleJoin: (chatter) => + console.log chatter.nickname + " has joined the chat." + @sendToEveryChatter chatter.nickname + " has joined the chat." + @addChatter chatter + + handleLeave: (chatter) => + console.log chatter.nickname + " has left the chat." + @removeChatter chatter + @sendToEveryChatter chatter.nickname + " has left the chat." + + addChatter: (chatter) => + @chatters[chatter.nickname] = chatter + + removeChatter: (chatter) => + delete @chatters[chatter.nickname] + + sendToEveryChatter: (data) => + for nickname of @chatters + @chatters[nickname].send data + + sendToEveryChatterExcept: (chatter, data) => + for nickname of @chatters + @chatters[nickname].send data unless nickname is chatter.nickname + + +class Chatter extends EventEmitter + constructor: (socket, server) -> + EventEmitter.call this + @socket = socket + @server = server + @nickname = "" + @lineBuffer = new SocketLineBuffer(socket) + @lineBuffer.on "line", @handleNickname + @socket.on "close", @handleDisconnect + @send "Welcome! What is your nickname?" + + handleNickname: (nickname) => + if isNicknameLegal(nickname) + @nickname = nickname + @lineBuffer.removeAllListeners "line" + @lineBuffer.on "line", @handleChat + @send "Welcome to the chat, " + nickname + "!" + @emit "join", this + else + @send "Sorry, but that nickname is not legal or is already in use!" + @send "What is your nickname?" + + handleChat: (line) => + @emit "chat", this, line + + handleDisconnect: => + @emit "leave", this + + send: (data) => + @socket.write data + "\r\n" + + +class SocketLineBuffer extends EventEmitter + constructor: (socket) -> + EventEmitter.call this + @socket = socket + @buffer = "" + @socket.on "data", @handleData + + handleData: (data) => + console.log "Handling data", data + i = 0 + + while i < data.length + char = data.charAt(i) + @buffer += char + if char is "\n" + @buffer = @buffer.replace("\r\n", "") + @buffer = @buffer.replace("\n", "") + @emit "line", @buffer + console.log "incoming line: #{@buffer}" + @buffer = "" + i++ + +server = new ChatServer() diff --git a/Task/Chat-server/Erlang/chat-server.erl b/Task/Chat-server/Erlang/chat-server.erl new file mode 100644 index 0000000000..42d491c0ec --- /dev/null +++ b/Task/Chat-server/Erlang/chat-server.erl @@ -0,0 +1,63 @@ +-module(chat). + +-export([start/0, start/1]). + +-record(client, {name=none, socket=none}). + +start() -> start(8080). +start(Port) -> + register(server, spawn(fun() -> server() end)), + {ok, LSocket} = gen_tcp:listen(Port, [binary, {packet, 0}, {active, false}, {reuseaddr, true}]), + accept(LSocket). + +% main loop for message dispatcher +server() -> server([]). +server(Clients) -> + receive + {join, Client=#client{name = Name, socket = Socket}} -> + self() ! {say, Socket, "has joined." ++ [10, 13]}, + server(Clients ++ [Client]); + {leave, Socket} -> + {value, #client{name = Name}, List} = lists:keytake(Socket, 3, Clients), + self() ! {say, none, Message = "has left."}, + server(List); + {say, Socket, Data} -> + {value, #client{name = From}, List} = lists:keytake(Socket, 3, Clients), + Message = From ++ " : " ++ Data, + lists:map(fun(#client{socket = S}) -> + gen_tcp:send(S, Message) + end, List) + end, + server(Clients). + +% accepts connections then spawns the client handler +accept(LSocket) -> + {ok, Socket} = gen_tcp:accept(LSocket), + spawn(fun() -> connecting(Socket) end), + accept(LSocket). + +% when client is first connect send prompt for user name +connecting(Socket) -> + gen_tcp:send(Socket, "What is your name? "), + case listen(Socket) of + {ok, N} -> + Name = binary_to_list(N), + server ! {join, #client{name = lists:sublist(Name, 1, length(Name) - 2), socket = Socket} }, + client(Socket); + _ -> ok + end. + +% main client loop that listens for data +client(Socket) -> + case listen(Socket) of + {ok, Data} -> + server ! {say, Socket, binary_to_list(Data)}, + client(Socket); + _ -> server ! {leave, Socket} + end. + +% utility function that listens for data on a socket +listen(Socket) -> + case gen_tcp:recv(Socket, 0) of + Response -> Response + end. diff --git a/Task/Chat-server/Go/chat-server.go b/Task/Chat-server/Go/chat-server.go new file mode 100644 index 0000000000..103fa0edcf --- /dev/null +++ b/Task/Chat-server/Go/chat-server.go @@ -0,0 +1,148 @@ +package main + +import ( + "os" + "fmt" + "net" + "flag" + "bufio" + "bytes" +) + +// Quick and dirty error handling. +func error_(err error, r int) { + fmt.Printf("Error: %v\n", err) + + if r >= 0 { + os.Exit(r) + } +} + +// A type for storing the connections. +type clientMap map[string]net.Conn + +// A method that makes clientMap compatible with io.Writer, allowing it to be +// used with fmt.Fprintf(). +func (cm clientMap) Write(buf []byte) (n int, err error) { + for _, c := range cm { + // Write to each client in a seperate goroutine. + go c.Write(buf) + } + + n = len(buf) + + return +} + +// Check if a name exists; if it doesn't, add it. +func (cm clientMap) Add(name string, c net.Conn) bool { + for k := range cm { + if name == k { + return false + } + } + + cm[name] = c + + return true +} + +// A clientMap variable. +var clients clientMap + +func init() { + // Initialize the map. + clients = make(clientMap) +} + +func client(c net.Conn) { + // Close the connection when this function returns. + defer c.Close() + + br := bufio.NewReader(c) + + fmt.Fprintf(c, "Please enter your name: ") + + buf, err := br.ReadBytes('\n') + if err != nil { + error_(err, -1) + return + } + name := string(bytes.Trim(buf, " \t\n\r\x00")) + + if name == "" { + fmt.Fprintf(c, "!!! %v is invalid !!!\n", name) + } + + // Try to add the connection to the map. + if !clients.Add(name, c) { + fmt.Fprintf(c, "!!! %v is not available !!!\n", name) + return + } + + // Send a message telling the clients who connected. + fmt.Fprintf(clients, "+++ %v connected +++\n", name) + // Send a disconnected message when the function returns. + defer fmt.Fprintf(clients, "--- %v disconnected ---\n", name) + // Remove the client from the list. + defer delete(clients, name) + + for { + buf, err = br.ReadBytes('\n') + if err != nil { + break + } + buf = bytes.Trim(buf, " \t\n\r\x00") + + // Ignore empty messages. + if len(buf) == 0 { + continue + } + + switch { + // Support for '/me' type messages. + case string(buf[0:3]) == "/me": + buf = append([]byte(name), buf[3:]...) + default: + // Prepend the user-name and '> '. + buf = append([]byte(name+"> "), buf...) + } + + // Send the message to all the clients. + fmt.Fprintf(clients, "%v\n", string(buf)) + } +} + +func main() { + // Flags. Use -help for usage info. + var ( + port int + help bool + ) + flag.IntVar(&port, "port", 23, "Port to listen on") + flag.BoolVar(&help, "help", false, "Display this") + flag.Parse() + + if help { + flag.Usage() + return + } + + // Initialize a new listener. + lis, err := net.Listen("tcp", fmt.Sprintf(":%v", port)) + if err != nil { + error_(err, 1) + } + + // Begin the main loop. + for { + c, err := lis.Accept() + if err != nil { + error_(err, -1) + continue + } + + // Launch a new goroutine to handle the connection. + go client(c) + } +} diff --git a/Task/Chat-server/Java/chat-server.java b/Task/Chat-server/Java/chat-server.java new file mode 100644 index 0000000000..5402c5daa4 --- /dev/null +++ b/Task/Chat-server/Java/chat-server.java @@ -0,0 +1,152 @@ +import java.io.*; +import java.net.*; +import java.util.*; + +public class ChatServer implements Runnable +{ + private int port = 0; + private List clients = new ArrayList(); + + public ChatServer(int port) + { this.port = port; } + + public void run() + { + try + { + ServerSocket ss = new ServerSocket(port); + while (true) + { + Socket s = ss.accept(); + new Thread(new Client(s)).start(); + } + } + catch (Exception e) + { e.printStackTrace(); } + } + + private synchronized boolean registerClient(Client client) + { + for (Client otherClient : clients) + if (otherClient.clientName.equalsIgnoreCase(client.clientName)) + return false; + clients.add(client); + return true; + } + + private void deregisterClient(Client client) + { + boolean wasRegistered = false; + synchronized (this) + { wasRegistered = clients.remove(client); } + if (wasRegistered) + broadcast(client, "--- " + client.clientName + " left ---"); + } + + private synchronized String getOnlineListCSV() + { + StringBuilder sb = new StringBuilder(); + sb.append(clients.size()).append(" user(s) online: "); + for (int i = 0; i < clients.size(); i++) + sb.append((i > 0) ? ", " : "").append(clients.get(i).clientName); + return sb.toString(); + } + + private void broadcast(Client fromClient, String msg) + { + // Copy client list (don't want to hold lock while doing IO) + List clients = null; + synchronized (this) + { clients = new ArrayList(this.clients); } + for (Client client : clients) + { + if (client.equals(fromClient)) + continue; + try + { client.write(msg + "\r\n"); } + catch (Exception e) + { } + } + } + + public class Client implements Runnable + { + private Socket socket = null; + private Writer output = null; + private String clientName = null; + + public Client(Socket socket) + { + this.socket = socket; + } + + public void run() + { + try + { + socket.setSendBufferSize(16384); + socket.setTcpNoDelay(true); + BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream())); + output = new OutputStreamWriter(socket.getOutputStream()); + write("Please enter your name: "); + String line = null; + while ((line = input.readLine()) != null) + { + if (clientName == null) + { + line = line.trim(); + if (line.isEmpty()) + { + write("A name is required. Please enter your name: "); + continue; + } + clientName = line; + if (!registerClient(this)) + { + clientName = null; + write("Name already registered. Please enter your name: "); + continue; + } + write(getOnlineListCSV() + "\r\n"); + broadcast(this, "+++ " + clientName + " arrived +++"); + continue; + } + if (line.equalsIgnoreCase("/quit")) + return; + broadcast(this, clientName + "> " + line); + } + } + catch (Exception e) + { } + finally + { + deregisterClient(this); + output = null; + try + { socket.close(); } + catch (Exception e) + { } + socket = null; + } + } + + public void write(String msg) throws IOException + { + output.write(msg); + output.flush(); + } + + public boolean equals(Client client) + { + return (client != null) && (client instanceof Client) && (clientName != null) && (client.clientName != null) && clientName.equals(client.clientName); + } + } + + public static void main(String[] args) + { + int port = 4004; + if (args.length > 0) + port = Integer.parseInt(args[0]); + new ChatServer(port).run(); + } +} diff --git a/Task/Chat-server/JavaScript/chat-server.js b/Task/Chat-server/JavaScript/chat-server.js new file mode 100644 index 0000000000..f5797e9414 --- /dev/null +++ b/Task/Chat-server/JavaScript/chat-server.js @@ -0,0 +1,158 @@ +var net = require("net"); +var sys = require("sys"); +var EventEmitter = require("events").EventEmitter; + +/******************************************************************************* + * ChatServer + * + * Manages connections, users, and chat messages. + ******************************************************************************/ + +function ChatServer() { + this.chatters = {}; + this.server = net.createServer(this.handleConnection.bind(this)); + this.server.listen(1212, "localhost"); +} + +ChatServer.prototype.isNicknameLegal = function(nickname) { + // A nickname may contain letters or numbers only, + // and may only be used once. + if(nickname.replace(/[A-Za-z0-9]*/, '') != "") { + return false + } + for(used_nick in this.chatters) { + if(used_nick == nickname) { + return false; + } + } + return true; +}; + +ChatServer.prototype.handleConnection = function(connection) { + console.log("Incoming connection from " + connection.remoteAddress); + connection.setEncoding("utf8"); + + var chatter = new Chatter(connection, this); + chatter.on("chat", this.handleChat.bind(this)); + chatter.on("join", this.handleJoin.bind(this)); + chatter.on("leave", this.handleLeave.bind(this)); +}; + +ChatServer.prototype.handleChat = function(chatter, message) { + this.sendToEveryChatterExcept(chatter, chatter.nickname + ": " + message); +}; + +ChatServer.prototype.handleJoin = function(chatter) { + console.log(chatter.nickname + " has joined the chat."); + this.sendToEveryChatter(chatter.nickname + " has joined the chat."); + this.addChatter(chatter); +}; + +ChatServer.prototype.handleLeave = function(chatter) { + console.log(chatter.nickname + " has left the chat."); + this.removeChatter(chatter); + this.sendToEveryChatter(chatter.nickname + " has left the chat."); +}; + +ChatServer.prototype.addChatter = function(chatter) { + this.chatters[chatter.nickname] = chatter; +}; + +ChatServer.prototype.removeChatter = function(chatter) { + delete this.chatters[chatter.nickname]; +}; + +ChatServer.prototype.sendToEveryChatter = function(data) { + for(nickname in this.chatters) { + this.chatters[nickname].send(data); + } +}; + +ChatServer.prototype.sendToEveryChatterExcept = function(chatter, data) { + for(nickname in this.chatters) { + if(nickname != chatter.nickname) { + this.chatters[nickname].send(data); + } + } +}; + +/******************************************************************************* + * Chatter + * + * Represents a single user/connection in the chat server. + ******************************************************************************/ + +function Chatter(socket, server) { + EventEmitter.call(this); + + this.socket = socket; + this.server = server; + this.nickname = ""; + this.lineBuffer = new SocketLineBuffer(socket); + + this.lineBuffer.on("line", this.handleNickname.bind(this)); + this.socket.on("close", this.handleDisconnect.bind(this)); + + this.send("Welcome! What is your nickname?"); +}; + +sys.inherits(Chatter, EventEmitter); + +Chatter.prototype.handleNickname = function(nickname) { + if(server.isNicknameLegal(nickname)) { + this.nickname = nickname; + this.lineBuffer.removeAllListeners("line"); + this.lineBuffer.on("line", this.handleChat.bind(this)); + this.send("Welcome to the chat, " + nickname + "!"); + this.emit("join", this); + } else { + this.send("Sorry, but that nickname is not legal or is already in use!"); + this.send("What is your nickname?"); + } +}; + +Chatter.prototype.handleChat = function(line) { + this.emit("chat", this, line); +}; + +Chatter.prototype.handleDisconnect = function() { + this.emit("leave", this); +}; + +Chatter.prototype.send = function(data) { + this.socket.write(data + "\r\n"); +}; + +/******************************************************************************* + * SocketLineBuffer + * + * Listens for and buffers incoming data on a socket and emits a 'line' event + * whenever a complete line is detected. + ******************************************************************************/ + +function SocketLineBuffer(socket) { + EventEmitter.call(this); + + this.socket = socket; + this.buffer = ""; + + this.socket.on("data", this.handleData.bind(this)); +}; + +sys.inherits(SocketLineBuffer, EventEmitter); + +SocketLineBuffer.prototype.handleData = function(data) { + for(var i = 0; i < data.length; i++) { + var char = data.charAt(i); + this.buffer += char; + if(char == "\n") { + this.buffer = this.buffer.replace("\r\n", ""); + this.buffer = this.buffer.replace("\n", ""); + this.emit("line", this.buffer); + this.buffer = ""; + } + } +}; + +// Start the server! +server = new ChatServer(); diff --git a/Task/Chat-server/PicoLisp/chat-server.l b/Task/Chat-server/PicoLisp/chat-server.l new file mode 100644 index 0000000000..b92e8f333a --- /dev/null +++ b/Task/Chat-server/PicoLisp/chat-server.l @@ -0,0 +1,28 @@ +#!/usr/bin/picolisp /usr/lib/picolisp/lib.l + +(de chat Lst + (out *Sock + (mapc prin Lst) + (prinl) ) ) + +(setq *Port (port 4004)) + +(loop + (setq *Sock (listen *Port)) + (NIL (fork) (close *Port)) + (close *Sock) ) + +(out *Sock + (prin "Please enter your name: ") + (flush) ) +(in *Sock (setq *Name (line T))) + +(tell 'chat "+++ " *Name " arrived +++") + +(task *Sock + (in @ + (ifn (eof) + (tell 'chat *Name "> " (line T)) + (tell 'chat "--- " *Name " left ---") + (bye) ) ) ) +(wait) diff --git a/Task/Chat-server/Python/chat-server.py b/Task/Chat-server/Python/chat-server.py new file mode 100644 index 0000000000..3ae1f66f00 --- /dev/null +++ b/Task/Chat-server/Python/chat-server.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python + +import socket +import thread +import time + +HOST = "" +PORT = 4004 + +def accept(conn): + """ + Call the inner func in a thread so as not to block. Wait for a + name to be entered from the given connection. Once a name is + entered, set the connection to non-blocking and add the user to + the users dict. + """ + def threaded(): + while True: + conn.send("Please enter your name: ") + try: + name = conn.recv(1024).strip() + except socket.error: + continue + if name in users: + conn.send("Name entered is already in use.\n") + elif name: + conn.setblocking(False) + users[name] = conn + broadcast(name, "+++ %s arrived +++" % name) + break + thread.start_new_thread(threaded, ()) + +def broadcast(name, message): + """ + Send a message to all users from the given name. + """ + print message + for to_name, conn in users.items(): + if to_name != name: + try: + conn.send(message + "\n") + except socket.error: + pass + +# Set up the server socket. +server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) +server.setblocking(False) +server.bind((HOST, PORT)) +server.listen(1) +print "Listening on %s" % ("%s:%s" % server.getsockname()) + +# Main event loop. +users = {} +while True: + try: + # Accept new connections. + while True: + try: + conn, addr = server.accept() + except socket.error: + break + accept(conn) + # Read from connections. + for name, conn in users.items(): + try: + message = conn.recv(1024) + except socket.error: + continue + if not message: + # Empty string is given on disconnect. + del users[name] + broadcast(name, "--- %s leaves ---" % name) + else: + broadcast(name, "%s> %s" % (name, message.strip())) + time.sleep(.1) + except (SystemExit, KeyboardInterrupt): + break diff --git a/Task/Chat-server/Ruby/chat-server.rb b/Task/Chat-server/Ruby/chat-server.rb new file mode 100644 index 0000000000..931f424e3b --- /dev/null +++ b/Task/Chat-server/Ruby/chat-server.rb @@ -0,0 +1,68 @@ +require 'gserver' + +class ChatServer < GServer + def initialize *args + super + + #Keep a list for broadcasting messages + @chatters = [] + + #We'll need this for thread safety + @mutex = Mutex.new + end + + #Send message out to everyone but sender + def broadcast message, sender = nil + #Need to use \r\n for our Windows friends + message = message.strip << "\r\n" + + #Mutex for safety - GServer uses threads + @mutex.synchronize do + @chatters.each do |chatter| + begin + chatter.print message unless chatter == sender + rescue + @chatters.delete chatter + end + end + end + end + + #Handle each connection + def serve io + io.print 'Name: ' + name = io.gets + + #They might disconnect + return if name.nil? + + name.strip! + + broadcast "--+ #{name} has joined +--" + + #Add to our list of connections + @mutex.synchronize do + @chatters << io + end + + #Get and broadcast input until connection returns nil + loop do + message = io.gets + + if message + broadcast "#{name}> #{message}", io + else + break + end + end + + broadcast "--+ #{name} has left +--" + end +end + +#Start up the server on port 7000 +#Accept connections for any IP address +#Allow up to 100 connections +#Send information to stderr +#Turn on informational messages +ChatServer.new(7000, '0.0.0.0', 100, $stderr, true).start.join diff --git a/Task/Chat-server/Tcl/chat-server.tcl b/Task/Chat-server/Tcl/chat-server.tcl new file mode 100644 index 0000000000..395b0db550 --- /dev/null +++ b/Task/Chat-server/Tcl/chat-server.tcl @@ -0,0 +1,61 @@ +package require Tcl 8.6 + +# Write a message to everyone except the sender of the message +proc writeEveryoneElse {sender message} { + dict for {who ch} $::cmap { + if {$who ne $sender} { + puts $ch $message + } + } +} + +# How to read a line (up to 256 chars long) in a coroutine +proc cgets {ch var} { + upvar 1 $var v + while {[gets $ch v] < 0} { + if {[eof $ch] || [chan pending input $ch] > 256} { + return false + } + yield + } + return true +} + +# The chatting, as seen by one user +proc chat {ch addr port} { + ### CONNECTION CODE ### + #Log "connection from ${addr}:${port} on channel $ch" + fconfigure $ch -buffering none -blocking 0 -encoding utf-8 + fileevent $ch readable [info coroutine] + global cmap + try { + + ### GET THE NICKNAME OF THE USER ### + puts -nonewline $ch "Please enter your name: " + if {![cgets $ch name]} { + return + } + #Log "Mapping ${addr}:${port} to ${name} on channel $ch" + dict set cmap $name $ch + writeEveryoneElse $name "+++ $name arrived +++" + + ### MAIN CHAT LOOP ### + while {[cgets $ch line]} { + writeEveryoneElse $name "$name> $line" + } + + } finally { + ### DISCONNECTION CODE ### + if {[info exists name]} { + writeEveryoneElse $name "--- $name left ---" + dict unset cmap $name + } + close $ch + #Log "disconnection from ${addr}:${port} on channel $ch" + } +} + +# Service the socket by making corouines running [chat] +socket -server {coroutine c[incr count] chat} 4004 +set ::cmap {}; # Dictionary mapping nicks to channels +vwait forever; # Run event loop diff --git a/Task/Check-Machin-like-formulas/0DESCRIPTION b/Task/Check-Machin-like-formulas/0DESCRIPTION new file mode 100644 index 0000000000..97dece1003 --- /dev/null +++ b/Task/Check-Machin-like-formulas/0DESCRIPTION @@ -0,0 +1,30 @@ +[[wp:Machin-like_formula|Machin-like formulas]] are useful for efficiently computing numerical approximations to Pi. +Verify the following Machin-like formulas are correct by calculating the value of '''tan'''(''right hand side)'' for each equation using exact arithmetic and showing they equal 1: + +: {\pi\over4} = \arctan{1\over2} + \arctan{1\over3} +: {\pi\over4} = 2 \arctan{1\over3} + \arctan{1\over7} +: {\pi\over4} = 4 \arctan{1\over5} - \arctan{1\over239} +: {\pi\over4} = 5 \arctan{1\over7} + 2 \arctan{3\over79} +: {\pi\over4} = 5 \arctan{29\over278} + 7 \arctan{3\over79} +: {\pi\over4} = \arctan{1\over2} + \arctan{1\over5} + \arctan{1\over8} +: {\pi\over4} = 4 \arctan{1\over5} - \arctan{1\over70} + \arctan{1\over99} +: {\pi\over4} = 5 \arctan{1\over7} + 4 \arctan{1\over53} + 2 \arctan{1\over4443} +: {\pi\over4} = 6 \arctan{1\over8} + 2 \arctan{1\over57} + \arctan{1\over239} +: {\pi\over4} = 8 \arctan{1\over10} - \arctan{1\over239} - 4 \arctan{1\over515} +: {\pi\over4} = 12 \arctan{1\over18} + 8 \arctan{1\over57} - 5 \arctan{1\over239} +: {\pi\over4} = 16 \arctan{1\over21} + 3 \arctan{1\over239} + 4 \arctan{3\over1042} +: {\pi\over4} = 22 \arctan{1\over28} + 2 \arctan{1\over443} - 5 \arctan{1\over1393} - 10 \arctan{1\over11018} +: {\pi\over4} = 22 \arctan{1\over38} + 17 \arctan{7\over601} + 10 \arctan{7\over8149} +: {\pi\over4} = 44 \arctan{1\over57} + 7 \arctan{1\over239} - 12 \arctan{1\over682} + 24 \arctan{1\over12943} +: {\pi\over4} = 88 \arctan{1\over172} + 51 \arctan{1\over239} + 32 \arctan{1\over682} + 44 \arctan{1\over5357} + 68 \arctan{1\over12943} + +and confirm that the following formula is incorrect by showing '''tan'''(''right hand side)'' is ''not'' 1: + +: {\pi\over4} = 88 \arctan{1\over172} + 51 \arctan{1\over239} + 32 \arctan{1\over682} + 44 \arctan{1\over5357} + 68 \arctan{1\over12944} + +These identities are useful in calculating the values: +: \tan(a + b) = {\tan(a) + \tan(b) \over 1 - \tan(a) \tan(b)} +: \tan\left(\arctan{a\over b}\right) = {a\over b} +: \tan(-a) = -\tan(a) + +You can store the equations in any convenient data structure, but for extra credit parse them from human-readable [[Check_Machin-like_formulas/text_equations|text input]]. diff --git a/Task/Check-Machin-like-formulas/D/check-machin-like-formulas.d b/Task/Check-Machin-like-formulas/D/check-machin-like-formulas.d new file mode 100644 index 0000000000..ce6b4b8aed --- /dev/null +++ b/Task/Check-Machin-like-formulas/D/check-machin-like-formulas.d @@ -0,0 +1,72 @@ +import std.stdio, std.regex, std.conv, std.string, std.typecons, + std.array, std.range; +import arithmetic_rational: Rational; + +immutable equationText = +"pi/4 = arctan(1/2) + arctan(1/3) +pi/4 = 2*arctan(1/3) + arctan(1/7) +pi/4 = 4*arctan(1/5) - arctan(1/239) +pi/4 = 5*arctan(1/7) + 2*arctan(3/79) +pi/4 = 5*arctan(29/278) + 7*arctan(3/79) +pi/4 = arctan(1/2) + arctan(1/5) + arctan(1/8) +pi/4 = 4*arctan(1/5) - arctan(1/70) + arctan(1/99) +pi/4 = 5*arctan(1/7) + 4*arctan(1/53) + 2*arctan(1/4443) +pi/4 = 6*arctan(1/8) + 2*arctan(1/57) + arctan(1/239) +pi/4 = 8*arctan(1/10) - arctan(1/239) - 4*arctan(1/515) +pi/4 = 12*arctan(1/18) + 8*arctan(1/57) - 5*arctan(1/239) +pi/4 = 16*arctan(1/21) + 3*arctan(1/239) + 4*arctan(3/1042) +pi/4 = 22*arctan(1/28) + 2*arctan(1/443) - 5*arctan(1/1393) - 10*arctan(1/11018) +pi/4 = 22*arctan(1/38) + 17*arctan(7/601) + 10*arctan(7/8149) +pi/4 = 44*arctan(1/57) + 7*arctan(1/239) - 12*arctan(1/682) + 24*arctan(1/12943) +pi/4 = 88*arctan(1/172) + 51*arctan(1/239) + 32*arctan(1/682) + 44*arctan(1/5357) + 68*arctan(1/12943) +pi/4 = 88*arctan(1/172) + 51*arctan(1/239) + 32*arctan(1/682) + 44*arctan(1/5357) + 68*arctan(1/12944)"; + +alias Pair = Tuple!(int, Rational); + +Pair[][] parseEquations(in string text) { + auto r = regex(r"\s*(?P[+-])?\s*(?:(?P\d+)\s*\*)?\s*" ~ + r"arctan\((?P\d+)/(?P\d+)\)", "g"); + Pair[][] machins; + foreach (const line; text.splitLines()) { + Pair[] formula; + foreach (part; std.string.split(line, "=")[1].match(r)) { + immutable string mul = part["mul"]; + immutable string num = part["num"]; + immutable string denom = part["denom"]; + formula ~= Pair((part["sign"] == "-" ? -1 : 1) * + (mul.empty ? 1 : to!int(mul)), + Rational(to!int(num), + denom.empty ? 1 : to!int(denom))); + } + machins ~= formula; + } + return machins; +} + + +Rational tans(/*in*/ Pair[] xs) /*pure nothrow*/ { + static Rational tanEval(in int coef, /*in*/ Rational f) + /*pure nothrow*/ { + if (coef == 1) + return f; + if (coef < 0) + return -tanEval(-coef, f); + /*const*/ auto a = tanEval(coef / 2, f); + /*const*/ auto b = tanEval(coef - coef / 2, f); + return (a + b) / (1 - a * b); + } + + if (xs.length == 1) + return tanEval(xs[0].tupleof); + /*const*/ auto a = tans(xs[0 .. xs.length / 2]); + /*const*/ auto b = tans(xs[xs.length / 2 .. $]); + return (a + b) / (1 - a * b); +} + +void main() { + /*const*/ auto machins = parseEquations(equationText); + foreach (machin, eqn; zip(machins, equationText.splitLines())) { + /*const*/ auto ans = tans(machin); + writefln("%5s: %s", ans == 1 ? "OK" : "ERROR", eqn); + } +} diff --git a/Task/Check-Machin-like-formulas/Go/check-machin-like-formulas.go b/Task/Check-Machin-like-formulas/Go/check-machin-like-formulas.go new file mode 100644 index 0000000000..b193e21209 --- /dev/null +++ b/Task/Check-Machin-like-formulas/Go/check-machin-like-formulas.go @@ -0,0 +1,64 @@ +package main + +import ( + "fmt" + "math/big" +) + +type mTerm struct { + a, n, d int64 +} + +var testCases = [][]mTerm{ + {{1, 1, 2}, {1, 1, 3}}, + {{2, 1, 3}, {1, 1, 7}}, + {{4, 1, 5}, {-1, 1, 239}}, + {{5, 1, 7}, {2, 3, 79}}, + {{1, 1, 2}, {1, 1, 5}, {1, 1, 8}}, + {{4, 1, 5}, {-1, 1, 70}, {1, 1, 99}}, + {{5, 1, 7}, {4, 1, 53}, {2, 1, 4443}}, + {{6, 1, 8}, {2, 1, 57}, {1, 1, 239}}, + {{8, 1, 10}, {-1, 1, 239}, {-4, 1, 515}}, + {{12, 1, 18}, {8, 1, 57}, {-5, 1, 239}}, + {{16, 1, 21}, {3, 1, 239}, {4, 3, 1042}}, + {{22, 1, 28}, {2, 1, 443}, {-5, 1, 1393}, {-10, 1, 11018}}, + {{22, 1, 38}, {17, 7, 601}, {10, 7, 8149}}, + {{44, 1, 57}, {7, 1, 239}, {-12, 1, 682}, {24, 1, 12943}}, + {{88, 1, 172}, {51, 1, 239}, {32, 1, 682}, {44, 1, 5357}, {68, 1, 12943}}, + {{88, 1, 172}, {51, 1, 239}, {32, 1, 682}, {44, 1, 5357}, {68, 1, 12944}}, +} + +func main() { + for _, m := range testCases { + fmt.Printf("tan %v = %v\n", m, tans(m)) + } +} + +var one = big.NewRat(1, 1) + +func tans(m []mTerm) *big.Rat { + if len(m) == 1 { + return tanEval(m[0].a, big.NewRat(m[0].n, m[0].d)) + } + half := len(m) / 2 + a := tans(m[:half]) + b := tans(m[half:]) + r := new(big.Rat) + return r.Quo(new(big.Rat).Add(a, b), r.Sub(one, r.Mul(a, b))) +} + +func tanEval(coef int64, f *big.Rat) *big.Rat { + if coef == 1 { + return f + } + if coef < 0 { + r := tanEval(-coef, f) + return r.Neg(r) + } + ca := coef / 2 + cb := coef - ca + a := tanEval(ca, f) + b := tanEval(cb, f) + r := new(big.Rat) + return r.Quo(new(big.Rat).Add(a, b), r.Sub(one, r.Mul(a, b))) +} diff --git a/Task/Check-Machin-like-formulas/Haskell/check-machin-like-formulas-1.hs b/Task/Check-Machin-like-formulas/Haskell/check-machin-like-formulas-1.hs new file mode 100644 index 0000000000..314ba7bda9 --- /dev/null +++ b/Task/Check-Machin-like-formulas/Haskell/check-machin-like-formulas-1.hs @@ -0,0 +1,31 @@ +import Data.Ratio +import Data.List (foldl') + +tanPlus :: Fractional a => a -> a -> a +tanPlus a b = (a + b) / (1 - a * b) + +tanEval :: (Integral a, Fractional b) => (a, b) -> b +tanEval (0,_) = 0 +tanEval (coef,f) + | coef < 0 = -tanEval (-coef, f) + | odd coef = tanPlus f $ tanEval (coef - 1, f) + | otherwise = tanPlus a a + where a = tanEval (coef `div` 2, f) + +tans :: (Integral a, Fractional b) => [(a, b)] -> b +tans = foldl' tanPlus 0 . map tanEval + +machins = [ + [(1, 1%2), (1, 1%3)], + [(2, 1%3), (1, 1%7)], + [(12, 1%18), (8, 1%57), (-5, 1%239)], + [(88, 1%172), (51, 1%239), (32 , 1%682), (44, 1%5357), (68, 1%12943)]] + +not_machin = [(88, 1%172), (51, 1%239), (32 , 1%682), (44, 1%5357), (68, 1%12944)] + +main = do + putStrLn "Machins:" + mapM_ (\x -> putStrLn $ show (tans x) ++ " <-- " ++ show x) machins + + putStr "\nnot Machin: "; print not_machin + print (tans not_machin) diff --git a/Task/Check-Machin-like-formulas/Haskell/check-machin-like-formulas-2.hs b/Task/Check-Machin-like-formulas/Haskell/check-machin-like-formulas-2.hs new file mode 100644 index 0000000000..20852e24b4 --- /dev/null +++ b/Task/Check-Machin-like-formulas/Haskell/check-machin-like-formulas-2.hs @@ -0,0 +1,34 @@ +import Data.Ratio + +-- Private type. Do not use outside of the tans function +newtype Tan a = Tan a deriving (Eq, Show) +instance Fractional a => Num (Tan a) where + _ + _ = undefined + Tan a * Tan b = Tan $ (a + b) / (1 - a * b) + negate _ = undefined + abs _ = undefined + signum _ = undefined + fromInteger 1 = Tan 0 -- identity for the (*) above + fromInteger _ = undefined +instance Fractional a => Fractional (Tan a) where + fromRational _ = undefined + recip (Tan f) = Tan (-f) -- inverse for the (*) above + +tans :: (Integral a, Fractional b) => [(a, b)] -> b +tans xs = x where + Tan x = product [Tan f ^^ coef | (coef,f) <- xs] + +machins = [ + [(1, 1%2), (1, 1%3)], + [(2, 1%3), (1, 1%7)], + [(12, 1%18), (8, 1%57), (-5, 1%239)], + [(88, 1%172), (51, 1%239), (32 , 1%682), (44, 1%5357), (68, 1%12943)]] + +not_machin = [(88, 1%172), (51, 1%239), (32 , 1%682), (44, 1%5357), (68, 1%12944)] + +main = do + putStrLn "Machins:" + mapM_ (\x -> putStrLn $ show (tans x) ++ " <-- " ++ show x) machins + + putStr "\nnot Machin: "; print not_machin + print (tans not_machin) diff --git a/Task/Check-Machin-like-formulas/Python/check-machin-like-formulas.py b/Task/Check-Machin-like-formulas/Python/check-machin-like-formulas.py new file mode 100644 index 0000000000..76e86c61ca --- /dev/null +++ b/Task/Check-Machin-like-formulas/Python/check-machin-like-formulas.py @@ -0,0 +1,71 @@ +import re +from fractions import Fraction +from pprint import pprint as pp + + +equationtext = '''\ + pi/4 = arctan(1/2) + arctan(1/3) + pi/4 = 2*arctan(1/3) + arctan(1/7) + pi/4 = 4*arctan(1/5) - arctan(1/239) + pi/4 = 5*arctan(1/7) + 2*arctan(3/79) + pi/4 = 5*arctan(29/278) + 7*arctan(3/79) + pi/4 = arctan(1/2) + arctan(1/5) + arctan(1/8) + pi/4 = 4*arctan(1/5) - arctan(1/70) + arctan(1/99) + pi/4 = 5*arctan(1/7) + 4*arctan(1/53) + 2*arctan(1/4443) + pi/4 = 6*arctan(1/8) + 2*arctan(1/57) + arctan(1/239) + pi/4 = 8*arctan(1/10) - arctan(1/239) - 4*arctan(1/515) + pi/4 = 12*arctan(1/18) + 8*arctan(1/57) - 5*arctan(1/239) + pi/4 = 16*arctan(1/21) + 3*arctan(1/239) + 4*arctan(3/1042) + pi/4 = 22*arctan(1/28) + 2*arctan(1/443) - 5*arctan(1/1393) - 10*arctan(1/11018) + pi/4 = 22*arctan(1/38) + 17*arctan(7/601) + 10*arctan(7/8149) + pi/4 = 44*arctan(1/57) + 7*arctan(1/239) - 12*arctan(1/682) + 24*arctan(1/12943) + pi/4 = 88*arctan(1/172) + 51*arctan(1/239) + 32*arctan(1/682) + 44*arctan(1/5357) + 68*arctan(1/12943) + pi/4 = 88*arctan(1/172) + 51*arctan(1/239) + 32*arctan(1/682) + 44*arctan(1/5357) + 68*arctan(1/12944) +''' + +def parse_eqn(equationtext=equationtext): + eqn_re = re.compile(r"""(?mx) + (?P ^ \s* pi/4 \s* = \s*)? # LHS of equation + (?: # RHS + \s* (?P [+-])? \s* + (?: (?P \d+) \s* \*)? + \s* arctan\( (?P \d+) / (?P \d+) + )""") + + found = eqn_re.findall(equationtext) + machins, part = [], [] + for lhs, sign, mult, numer, denom in eqn_re.findall(equationtext): + if lhs and part: + machins.append(part) + part = [] + part.append( ( (-1 if sign == '-' else 1) * ( int(mult) if mult else 1), + Fraction(int(numer), (int(denom) if denom else 1)) ) ) + machins.append(part) + return machins + + +def tans(xs): + xslen = len(xs) + if xslen == 1: + return tanEval(*xs[0]) + aa, bb = xs[:xslen//2], xs[xslen//2:] + a, b = tans(aa), tans(bb) + return (a + b) / (1 - a * b) + +def tanEval(coef, f): + if coef == 1: + return f + if coef < 0: + return -tanEval(-coef, f) + ca = coef // 2 + cb = coef - ca + a, b = tanEval(ca, f), tanEval(cb, f) + return (a + b) / (1 - a * b) + + +if __name__ == '__main__': + machins = parse_eqn() + #pp(machins, width=160) + for machin, eqn in zip(machins, equationtext.split('\n')): + ans = tans(machin) + print('%5s: %s' % ( ('OK' if ans == 1 else 'ERROR'), eqn)) diff --git a/Task/Check-Machin-like-formulas/Tcl/check-machin-like-formulas.tcl b/Task/Check-Machin-like-formulas/Tcl/check-machin-like-formulas.tcl new file mode 100644 index 0000000000..93900a3aa6 --- /dev/null +++ b/Task/Check-Machin-like-formulas/Tcl/check-machin-like-formulas.tcl @@ -0,0 +1,79 @@ +package require Tcl 8.5 + +# Compute tan(atan(p)+atan(q)) using rationals +proc tadd {p q} { + lassign $p pp pq + lassign $q qp qq + set topp [expr {$pp*$qq + $qp*$pq}] + set topq [expr {$pq*$qq}] + set prodp [expr {$pp*$qp}] + set prodq [expr {$pq*$qq}] + set lowp [expr {$prodq - $prodp}] + set resultp [set gcd1 [expr {$topp * $prodq}]] + set resultq [set gcd2 [expr {$topq * $lowp}]] + # Critical! Normalize using the GCD + while {$gcd2 != 0} { + lassign [list $gcd2 [expr {$gcd1 % $gcd2}]] gcd1 gcd2 + } + list [expr {$resultp / abs($gcd1)}] [expr {$resultq / abs($gcd1)}] +} +proc termTan {n a b} { + if {$n < 0} { + set n [expr {-$n}] + set a [expr {-$a}] + } + if {$n == 1} { + return [list $a $b] + } + set k [expr {$n - [set m [expr {$n / 2}]]*2}] + set t2 [termTan $m $a $b] + set m2 [tadd $t2 $t2] + if {$k == 0} { + return $m2 + } + return [tadd [termTan $k $a $b] $m2] +} +proc machinTan {terms} { + set sum {0 1} + foreach term $terms { + set sum [tadd $sum [termTan {*}$term]] + } + return $sum +} + +# Assumes that the formula is in the very specific form below! +proc parseFormula {formula} { + set RE {(-?\s*\d*\s*\*?)\s*arctan\s*\(\s*(-?\s*\d+)\s*/\s*(-?\s*\d+)\s*\)} + set nospace {" " "" "*" ""} + foreach {all n a b} [regexp -inline -all $RE $formula] { + if {![regexp {\d} $n]} {append n 1} + lappend result [list [string map $nospace $n] [string map $nospace $a] [string map $nospace $b]] + } + return $result +} + +foreach formula { + "pi/4 = arctan(1/2) + arctan(1/3)" + "pi/4 = 2*arctan(1/3) + arctan(1/7)" + "pi/4 = 4*arctan(1/5) - arctan(1/239)" + "pi/4 = 5*arctan(1/7) + 2*arctan(3/79)" + "pi/4 = 5*arctan(29/278) + 7*arctan(3/79)" + "pi/4 = arctan(1/2) + arctan(1/5) + arctan(1/8)" + "pi/4 = 4*arctan(1/5) - arctan(1/70) + arctan(1/99)" + "pi/4 = 5*arctan(1/7) + 4*arctan(1/53) + 2*arctan(1/4443)" + "pi/4 = 6*arctan(1/8) + 2*arctan(1/57) + arctan(1/239)" + "pi/4 = 8*arctan(1/10) - arctan(1/239) - 4*arctan(1/515)" + "pi/4 = 12*arctan(1/18) + 8*arctan(1/57) - 5*arctan(1/239)" + "pi/4 = 16*arctan(1/21) + 3*arctan(1/239) + 4*arctan(3/1042)" + "pi/4 = 22*arctan(1/28) + 2*arctan(1/443) - 5*arctan(1/1393) - 10*arctan(1/11018)" + "pi/4 = 22*arctan(1/38) + 17*arctan(7/601) + 10*arctan(7/8149)" + "pi/4 = 44*arctan(1/57) + 7*arctan(1/239) - 12*arctan(1/682) + 24*arctan(1/12943)" + "pi/4 = 88*arctan(1/172) + 51*arctan(1/239) + 32*arctan(1/682) + 44*arctan(1/5357) + 68*arctan(1/12943)" + "pi/4 = 88*arctan(1/172) + 51*arctan(1/239) + 32*arctan(1/682) + 44*arctan(1/5357) + 68*arctan(1/12944)" +} { + if {[tcl::mathop::== {*}[machinTan [parseFormula $formula]]]} { + puts "Yes! '$formula' is true" + } else { + puts "No! '$formula' not true" + } +} diff --git a/Task/Check-that-file-exists/C++/check-that-file-exists.cpp b/Task/Check-that-file-exists/C++/check-that-file-exists.cpp new file mode 100644 index 0000000000..191daf0123 --- /dev/null +++ b/Task/Check-that-file-exists/C++/check-that-file-exists.cpp @@ -0,0 +1,25 @@ +#include "boost/filesystem.hpp" +#include +#include + +void testfile(std::string name) +{ + boost::filesystem::path file(name); + if (exists(file)) + { + if (is_directory(file)) + std::cout << name << " is a directory.\n"; + else + std::cout << name << " is a non-directory file.\n"; + } + else + std::cout << name << " does not exist.\n"; +} + +int main() +{ + testfile("input.txt"); + testfile("docs"); + testfile("/input.txt"); + testfile("/docs"); +} diff --git a/Task/Check-that-file-exists/Common-Lisp/check-that-file-exists-1.lisp b/Task/Check-that-file-exists/Common-Lisp/check-that-file-exists-1.lisp new file mode 100644 index 0000000000..127bd73324 --- /dev/null +++ b/Task/Check-that-file-exists/Common-Lisp/check-that-file-exists-1.lisp @@ -0,0 +1,11 @@ +(if (probe-file (make-pathname :name "input.txt")) + (print "rel file exists")) +(if (probe-file (make-pathname :directory '(:absolute "") :name "input.txt")) + (print "abs file exists")) + +(if (directory (make-pathname :directory '(:relative "docs"))) + (print "rel directory exists") + (print "rel directory is not known to exist")) +(if (directory (make-pathname :directory '(:absolute "docs"))) + (print "abs directory exists") + (print "abs directory is not known to exist")) diff --git a/Task/Check-that-file-exists/Common-Lisp/check-that-file-exists-2.lisp b/Task/Check-that-file-exists/Common-Lisp/check-that-file-exists-2.lisp new file mode 100644 index 0000000000..35c8153f9b --- /dev/null +++ b/Task/Check-that-file-exists/Common-Lisp/check-that-file-exists-2.lisp @@ -0,0 +1,3 @@ +(if (cl-fad:directory-exists-p (make-pathname :directory '(:relative "docs"))) + (print "rel directory exists") + (print "rel directory does not exist")) diff --git a/Task/Check-that-file-exists/D/check-that-file-exists.d b/Task/Check-that-file-exists/D/check-that-file-exists.d new file mode 100644 index 0000000000..f82efb82cf --- /dev/null +++ b/Task/Check-that-file-exists/D/check-that-file-exists.d @@ -0,0 +1,18 @@ +import std.stdio, std.file, std.path; + +void verify(in string name) { + if (name.exists()) + writeln("'", name, "' exists"); + else + writeln("'", name, "' doesn't exist"); +} + +void main() { + // check in current working dir + verify("input.txt"); + verify("docs"); + + // check in root + verify(dirSeparator ~ "input.txt"); + verify(dirSeparator ~ "docs"); +} diff --git a/Task/Check-that-file-exists/Delphi/check-that-file-exists.delphi b/Task/Check-that-file-exists/Delphi/check-that-file-exists.delphi new file mode 100644 index 0000000000..a22ac89644 --- /dev/null +++ b/Task/Check-that-file-exists/Delphi/check-that-file-exists.delphi @@ -0,0 +1,28 @@ +program EnsureFileExists; + +{$APPTYPE CONSOLE} + +uses + SysUtils; + +begin + if FileExists('input.txt') then + Writeln('File "input.txt" exists.') + else + Writeln('File "input.txt" does not exist.'); + + if FileExists('\input.txt') then + Writeln('File "\input.txt" exists.') + else + Writeln('File "\input.txt" does not exist.'); + + if DirectoryExists('docs') then + Writeln('Directory "docs" exists.') + else + Writeln('Directory "docs" does not exists.'); + + if DirectoryExists('\docs') then + Writeln('Directory "\docs" exists.') + else + Writeln('Directory "\docs" does not exists.'); +end. diff --git a/Task/Check-that-file-exists/E/check-that-file-exists.e b/Task/Check-that-file-exists/E/check-that-file-exists.e new file mode 100644 index 0000000000..9aaa27af1f --- /dev/null +++ b/Task/Check-that-file-exists/E/check-that-file-exists.e @@ -0,0 +1,11 @@ +for file in [, + ] { + require(file.exists(), fn { `$file is missing!` }) + require(!file.isDirectory(), fn { `$file is a directory!` }) +} + +for file in [, + ] { + require(file.exists(), fn { `$file is missing!` }) + require(file.isDirectory(), fn { `$file is not a directory!` }) +} diff --git a/Task/Check-that-file-exists/Euphoria/check-that-file-exists.euphoria b/Task/Check-that-file-exists/Euphoria/check-that-file-exists.euphoria new file mode 100644 index 0000000000..1925397350 --- /dev/null +++ b/Task/Check-that-file-exists/Euphoria/check-that-file-exists.euphoria @@ -0,0 +1,22 @@ +include file.e + +procedure ensure_exists(sequence name) + object x + sequence s + x = dir(name) + if sequence(x) then + if find('d',x[1][D_ATTRIBUTES]) then + s = "directory" + else + s = "file" + end if + printf(1,"%s %s exists.\n",{name,s}) + else + printf(1,"%s does not exist.\n",{name}) + end if +end procedure + +ensure_exists("input.txt") +ensure_exists("docs") +ensure_exists("/input.txt") +ensure_exists("/docs") diff --git a/Task/Checkpoint-synchronization/D/checkpoint-synchronization.d b/Task/Checkpoint-synchronization/D/checkpoint-synchronization.d new file mode 100644 index 0000000000..cd2b03ef40 --- /dev/null +++ b/Task/Checkpoint-synchronization/D/checkpoint-synchronization.d @@ -0,0 +1,24 @@ +import std.stdio; +import std.parallelism: taskPool, defaultPoolThreads, totalCPUs; + +void buildMechanism(uint nparts) { + auto details = new uint[nparts]; + foreach (i, ref detail; taskPool.parallel(details)) { + writeln("Build detail ", i); + detail = i; + } + + // This could be written more concisely via std.parallelism.reduce, + // but we want to see the checkpoint explicitly. + writeln("Checkpoint reached. Assemble details ..."); + uint sum = 0; + foreach (immutable detail; details) + sum += detail; + writeln("Mechanism with ", nparts, " parts finished: ", sum); +} + +void main() { + defaultPoolThreads = totalCPUs + 1; // totalCPUs - 1 on default. + buildMechanism(42); + buildMechanism(11); +} diff --git a/Task/Checkpoint-synchronization/E/checkpoint-synchronization.e b/Task/Checkpoint-synchronization/E/checkpoint-synchronization.e new file mode 100644 index 0000000000..6bf99b910b --- /dev/null +++ b/Task/Checkpoint-synchronization/E/checkpoint-synchronization.e @@ -0,0 +1,114 @@ +/** A flagSet solves this problem: There are N things, each in a true or false + * state, and we want to know whether they are all true (or all false), and be + * able to bulk-change all of them, and all this without allowing double- + * counting -- setting a flag twice is idempotent. + */ +def makeFlagSet() { + # Each flag object is either in the true set or the false set. + def trues := [].asSet().diverge() + def falses := [].asSet().diverge() + return def flagSet { + /** Add a flag to the set. */ + to join() { + def flag { + /** Get the value of this flag. */ + to get() :boolean { + + } + /** Set the value of this flag. */ + to put(v :boolean) { + def [del,add] := if (v) { [falses,trues] } else { [trues,falses] } + if (del.contains(flag)) { + del.remove(flag) + add.addElement(flag) + } + } + /** Remove this flag from the set. */ + to leave() :void { + trues.remove(flag) + falses.remove(flag) + } + } + falses.addElement(flag) + return flag + } + /** Are all the flags true (none false)? */ + to allTrue() { return falses.size().isZero() } + /** Are all the flags false (none true)? */ + to allFalse() { return trues.size().isZero() } + /** Set all the flags to the same value. */ + to setAll(v :boolean) { + def [del,add] := if (v) { [falses,trues] } else { [trues,falses] } + add.addAll(del) + del.removeAll(del) + } + } +} + +def makeCheckpoint() { + def [var continueSignal, var continueRes] := Ref.promise() + def readies := makeFlagSet() + + /** Check whether all tasks have reached the checkpoint, and if so send the + * signal and go to the next round. */ + def check() { + if (readies.allTrue()) { + readies.setAll(false) + + continueRes.resolve(null) # send the continue signal + + def [p, r] := Ref.promise() # prepare a new continue signal + continueSignal := p + continueRes := r + } + } + + return def checkpoint { + to join() { + def &flag := readies.join() + return def membership { + to leave() { + (&flag).leave() + check <- () + } + to deliver() { + flag := true + check <- () + return continueSignal + } + } + } + } +} + +def makeWorker(piece, checkpoint) { + def stops := timer.now() + 3000 + entropy.nextInt(2000) + var count := 0 + def checkpointMember := checkpoint <- join() + def stopped + def run() { + # Pretend to do something lengthy; up to 1000 ms. + timer.whenPast(timer.now() + entropy.nextInt(1000), fn { + if (timer.now() >= stops) { + checkpointMember <- leave() + bind stopped := true + } else { + count += 1 + println(`Delivering $piece#$count`) + when (checkpointMember <- deliver()) -> { + println(`Delivered $piece#$count`) + run() + } + } + }) + } + run() + return stopped +} + +def checkpoint := makeCheckpoint() +var waits := [] +for piece in 1..5 { + waits with= makeWorker(piece, checkpoint) +} +interp.waitAtTop(promiseAllFulfilled(waits)) diff --git a/Task/Cholesky-decomposition/0DESCRIPTION b/Task/Cholesky-decomposition/0DESCRIPTION new file mode 100644 index 0000000000..6648b11250 --- /dev/null +++ b/Task/Cholesky-decomposition/0DESCRIPTION @@ -0,0 +1,73 @@ +Every symmetric, positive definite matrix A can be decomposed into a product of a unique lower triangular matrix L and its transpose: + +:A = LL^T + +L is called the ''Cholesky factor'' of A, and can be interpreted as a generalized square root of A, as described in [[wp:Cholesky decomposition|Cholesky decomposition]]. + +In a 3x3 example, we have to solve the following system of equations: + +:\begin{align} +A &= +\begin{pmatrix} + a_{11} & a_{21} & a_{31}\\ + a_{21} & a_{22} & a_{32}\\ + a_{31} & a_{32} & a_{33}\\ +\end{pmatrix}\\ +& = +\begin{pmatrix} + l_{11} & 0 & 0 \\ + l_{21} & l_{22} & 0 \\ + l_{31} & l_{32} & l_{33}\\ +\end{pmatrix} +\begin{pmatrix} + l_{11} & l_{21} & l_{31} \\ + 0 & l_{22} & l_{32} \\ + 0 & 0 & l_{33} +\end{pmatrix} \equiv LL^T\\ +&= \begin{pmatrix} + l_{11}^2 & l_{21}l_{11} & l_{31}l_{11} \\ + l_{21}l_{11} & l_{21}^2 + l_{22}^2& l_{31}l_{21}+l_{32}l_{22} \\ + l_{31}l_{11} & l_{31}l_{21}+l_{32}l_{22} & l_{31}^2 + l_{32}^2+l_{33}^2 +\end{pmatrix}\end{align} + + +We can see that for the diagonal elements (l_{kk}) of L there is a calculation pattern: + +:l_{11} = \sqrt{a_{11}} +:l_{22} = \sqrt{a_{22} - l_{21}^2} +:l_{33} = \sqrt{a_{33} - (l_{31}^2 + l_{32}^2)} + +or in general: + +:l_{kk} = \sqrt{a_{kk} - \sum_{j=1}^{k-1} l_{kj}^2} + +For the elements below the diagonal (l_{ik}, where i > k ) there is also a calculation pattern: + +:l_{21} = \frac{1}{l_{11}} a_{21} +:l_{31} = \frac{1}{l_{11}} a_{31} +:l_{32} = \frac{1}{l_{22}} (a_{32} - l_{31}l_{21}) + +which can also be expressed in a general formula: + +:l_{ik} = \frac{1}{l_{kk}} \left ( a_{ik} - \sum_{j=1}^{k-1} l_{ij}l_{kj} \right ) + +'''Task description''' + +The task is to implement a routine which will return a lower Cholesky factor L for every given symmetric, positive definite nxn matrix A. You should then test it on the following two examples and include your output. + +Example 1: + +
+25  15  -5                 5   0   0
+15  18   0         -->     3   3   0
+-5   0  11                -1   1   3
+
+ +Example 2: + +
+18  22   54   42           4.24264    0.00000    0.00000    0.00000
+22  70   86   62   -->     5.18545    6.56591    0.00000    0.00000
+54  86  174  134          12.72792    3.04604    1.64974    0.00000
+42  62  134  106           9.89949    1.62455    1.84971    1.39262
+
diff --git a/Task/Cholesky-decomposition/1META.yaml b/Task/Cholesky-decomposition/1META.yaml new file mode 100644 index 0000000000..1e81690bbc --- /dev/null +++ b/Task/Cholesky-decomposition/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Matrices diff --git a/Task/Cholesky-decomposition/ALGOL-68/cholesky-decomposition.alg b/Task/Cholesky-decomposition/ALGOL-68/cholesky-decomposition.alg new file mode 100644 index 0000000000..fb1f190f7a --- /dev/null +++ b/Task/Cholesky-decomposition/ALGOL-68/cholesky-decomposition.alg @@ -0,0 +1,59 @@ +#!/usr/local/bin/a68g --script # + +MODE FIELD=LONG REAL; +PROC (FIELD)FIELD field sqrt = long sqrt; +INT field prec = 5; +FORMAT field fmt = $g(-(2+1+field prec),field prec)$; + +MODE MAT = [0,0]FIELD; + +PROC cholesky = (MAT a) MAT:( + [UPB a, 2 UPB a]FIELD l; + + FOR i FROM LWB a TO UPB a DO + FOR j FROM 2 LWB a TO i DO + FIELD s := 0; + FOR k FROM 2 LWB a TO j-1 DO + s +:= l[i,k] * l[j,k] + OD; + l[i,j] := IF i = j + THEN field sqrt(a[i,i] - s) + ELSE 1.0 / l[j,j] * (a[i,j] - s) FI + OD; + FOR j FROM i+1 TO 2 UPB a DO + l[i,j]:=0 # Not required if matrix is declared as triangular # + OD + OD; + l +); + +PROC print matrix v1 =(MAT a)VOID:( + FOR i FROM LWB a TO UPB a DO + FOR j FROM 2 LWB a TO 2 UPB a DO + printf(($g(-(2+1+field prec),field prec)$, a[i,j])) + OD; + printf($l$) + OD +); + +PROC print matrix =(MAT a)VOID:( + FORMAT vector fmt = $"("f(field fmt)n(2 UPB a-2 LWB a)(", " f(field fmt))")"$; + FORMAT matrix fmt = $"("f(vector fmt)n( UPB a- LWB a)(","lxf(vector fmt))")"$; + printf((matrix fmt, a)) +); + +main: ( + MAT m1 = ((25, 15, -5), + (15, 18, 0), + (-5, 0, 11)); + MAT c1 = cholesky(m1); + print matrix(c1); + printf($l$); + + MAT m2 = ((18, 22, 54, 42), + (22, 70, 86, 62), + (54, 86, 174, 134), + (42, 62, 134, 106)); + MAT c2 = cholesky(m2); + print matrix(c2) +) diff --git a/Task/Cholesky-decomposition/Ada/cholesky-decomposition-1.ada b/Task/Cholesky-decomposition/Ada/cholesky-decomposition-1.ada new file mode 100644 index 0000000000..84bcaf0a47 --- /dev/null +++ b/Task/Cholesky-decomposition/Ada/cholesky-decomposition-1.ada @@ -0,0 +1,9 @@ +with Ada.Numerics.Generic_Real_Arrays; +generic + with package Matrix is new Ada.Numerics.Generic_Real_Arrays (<>); +package Decomposition is + + -- decompose a square matrix A by A = L * Transpose (L) + procedure Decompose (A : Matrix.Real_Matrix; L : out Matrix.Real_Matrix); + +end Decomposition; diff --git a/Task/Cholesky-decomposition/Ada/cholesky-decomposition-2.ada b/Task/Cholesky-decomposition/Ada/cholesky-decomposition-2.ada new file mode 100644 index 0000000000..f37c631081 --- /dev/null +++ b/Task/Cholesky-decomposition/Ada/cholesky-decomposition-2.ada @@ -0,0 +1,33 @@ +with Ada.Numerics.Generic_Elementary_Functions; + +package body Decomposition is + package Math is new Ada.Numerics.Generic_Elementary_Functions + (Matrix.Real); + + procedure Decompose (A : Matrix.Real_Matrix; L : out Matrix.Real_Matrix) is + use type Matrix.Real_Matrix, Matrix.Real; + Order : constant Positive := A'Length (1); + S : Matrix.Real; + begin + L := (others => (others => 0.0)); + for I in 0 .. Order - 1 loop + for K in 0 .. I loop + S := 0.0; + for J in 0 .. K - 1 loop + S := S + + L (L'First (1) + I, L'First (2) + J) * + L (L'First (1) + K, L'First (2) + J); + end loop; + -- diagonals + if K = I then + L (L'First (1) + K, L'First (2) + K) := + Math.Sqrt (A (A'First (1) + K, A'First (2) + K) - S); + else + L (L'First (1) + I, L'First (2) + K) := + 1.0 / L (L'First (1) + K, L'First (2) + K) * + (A (A'First (1) + I, A'First (2) + K) - S); + end if; + end loop; + end loop; + end Decompose; +end Decomposition; diff --git a/Task/Cholesky-decomposition/Ada/cholesky-decomposition-3.ada b/Task/Cholesky-decomposition/Ada/cholesky-decomposition-3.ada new file mode 100644 index 0000000000..1f504b2c61 --- /dev/null +++ b/Task/Cholesky-decomposition/Ada/cholesky-decomposition-3.ada @@ -0,0 +1,45 @@ +with Ada.Numerics.Real_Arrays; +with Ada.Text_IO; +with Decomposition; +procedure Decompose_Example is + package Real_Decomposition is new Decomposition + (Matrix => Ada.Numerics.Real_Arrays); + + package Real_IO is new Ada.Text_IO.Float_IO (Float); + + procedure Print (M : Ada.Numerics.Real_Arrays.Real_Matrix) is + begin + for Row in M'Range (1) loop + for Col in M'Range (2) loop + Real_IO.Put (M (Row, Col), 4, 3, 0); + end loop; + Ada.Text_IO.New_Line; + end loop; + end Print; + + Example_1 : constant Ada.Numerics.Real_Arrays.Real_Matrix := + ((25.0, 15.0, -5.0), + (15.0, 18.0, 0.0), + (-5.0, 0.0, 11.0)); + L_1 : Ada.Numerics.Real_Arrays.Real_Matrix (Example_1'Range (1), + Example_1'Range (2)); + Example_2 : constant Ada.Numerics.Real_Arrays.Real_Matrix := + ((18.0, 22.0, 54.0, 42.0), + (22.0, 70.0, 86.0, 62.0), + (54.0, 86.0, 174.0, 134.0), + (42.0, 62.0, 134.0, 106.0)); + L_2 : Ada.Numerics.Real_Arrays.Real_Matrix (Example_2'Range (1), + Example_2'Range (2)); +begin + Real_Decomposition.Decompose (A => Example_1, + L => L_1); + Real_Decomposition.Decompose (A => Example_2, + L => L_2); + Ada.Text_IO.Put_Line ("Example 1:"); + Ada.Text_IO.Put_Line ("A:"); Print (Example_1); + Ada.Text_IO.Put_Line ("L:"); Print (L_1); + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line ("Example 2:"); + Ada.Text_IO.Put_Line ("A:"); Print (Example_2); + Ada.Text_IO.Put_Line ("L:"); Print (L_2); +end Decompose_Example; diff --git a/Task/Cholesky-decomposition/BBC-BASIC/cholesky-decomposition.bbc b/Task/Cholesky-decomposition/BBC-BASIC/cholesky-decomposition.bbc new file mode 100644 index 0000000000..d8eef0a5a5 --- /dev/null +++ b/Task/Cholesky-decomposition/BBC-BASIC/cholesky-decomposition.bbc @@ -0,0 +1,46 @@ + DIM m1(2,2) + m1() = 25, 15, -5, \ + \ 15, 18, 0, \ + \ -5, 0, 11 + PROCcholesky(m1()) + PROCprint(m1()) + PRINT + + @% = &2050A + DIM m2(3,3) + m2() = 18, 22, 54, 42, \ + \ 22, 70, 86, 62, \ + \ 54, 86, 174, 134, \ + \ 42, 62, 134, 106 + PROCcholesky(m2()) + PROCprint(m2()) + END + + DEF PROCcholesky(a()) + LOCAL i%, j%, k%, l(), s + DIM l(DIM(a(),1),DIM(a(),2)) + FOR i% = 0 TO DIM(a(),1) + FOR j% = 0 TO i% + s = 0 + FOR k% = 0 TO j%-1 + s += l(i%,k%) * l(j%,k%) + NEXT + IF i% = j% THEN + l(i%,j%) = SQR(a(i%,i%) - s) + ELSE + l(i%,j%) = (a(i%,j%) - s) / l(j%,j%) + ENDIF + NEXT j% + NEXT i% + a() = l() + ENDPROC + + DEF PROCprint(a()) + LOCAL row%, col% + FOR row% = 0 TO DIM(a(),1) + FOR col% = 0 TO DIM(a(),2) + PRINT a(row%,col%); + NEXT + PRINT + NEXT row% + ENDPROC diff --git a/Task/Cholesky-decomposition/C/cholesky-decomposition.c b/Task/Cholesky-decomposition/C/cholesky-decomposition.c new file mode 100644 index 0000000000..51f0c7b46b --- /dev/null +++ b/Task/Cholesky-decomposition/C/cholesky-decomposition.c @@ -0,0 +1,51 @@ +#include +#include +#include + +double *cholesky(double *A, int n) { + double *L = (double*)calloc(n * n, sizeof(double)); + if (L == NULL) + exit(EXIT_FAILURE); + + for (int i = 0; i < n; i++) + for (int j = 0; j < (i+1); j++) { + double s = 0; + for (int k = 0; k < j; k++) + s += L[i * n + k] * L[j * n + k]; + L[i * n + j] = (i == j) ? + sqrt(A[i * n + i] - s) : + (1.0 / L[j * n + j] * (A[i * n + j] - s)); + } + + return L; +} + +void show_matrix(double *A, int n) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) + printf("%2.5f ", A[i * n + j]); + printf("\n"); + } +} + +int main() { + int n = 3; + double m1[] = {25, 15, -5, + 15, 18, 0, + -5, 0, 11}; + double *c1 = cholesky(m1, n); + show_matrix(c1, n); + printf("\n"); + free(c1); + + n = 4; + double m2[] = {18, 22, 54, 42, + 22, 70, 86, 62, + 54, 86, 174, 134, + 42, 62, 134, 106}; + double *c2 = cholesky(m2, n); + show_matrix(c2, n); + free(c2); + + return 0; +} diff --git a/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-1.lisp b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-1.lisp new file mode 100644 index 0000000000..d790071373 --- /dev/null +++ b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-1.lisp @@ -0,0 +1,29 @@ +;; Calculates the Cholesky decomposition matrix L +;; for a positive-definite, symmetric nxn matrix A. +(defun chol (A) + (let* ((n (car (array-dimensions A))) + (L (make-array `(,n ,n) :initial-element 0))) + + (do ((k 0 (incf k))) ((> k (- n 1)) nil) + ;; First, calculate diagonal elements L_kk. + (setf (aref L k k) + (sqrt (- (aref A k k) + (do* ((j 0 (incf j)) + (sum (expt (aref L k j) 2) + (incf sum (expt (aref L k j) 2)))) + ((> j (- k 1)) sum))))) + + ;; Then, all elements below a diagonal element, L_ik, i=k+1..n. + (do ((i (+ k 1) (incf i))) + ((> i (- n 1)) nil) + + (setf (aref L i k) + (/ (- (aref A i k) + (do* ((j 0 (incf j)) + (sum (* (aref L i j) (aref L k j)) + (incf sum (* (aref L i j) (aref L k j))))) + ((> j (- k 1)) sum))) + (aref L k k))))) + + ;; Return the calculated matrix L. + L)) diff --git a/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-2.lisp b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-2.lisp new file mode 100644 index 0000000000..a8e349ca78 --- /dev/null +++ b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-2.lisp @@ -0,0 +1,6 @@ +;; Example 1: +(setf A (make-array '(3 3) :initial-contents '((25 15 -5) (15 18 0) (-5 0 11)))) +(chol A) +#2A((5.0 0 0) + (3.0 3.0 0) + (-1.0 1.0 3.0)) diff --git a/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-3.lisp b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-3.lisp new file mode 100644 index 0000000000..4d0c06c7ba --- /dev/null +++ b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-3.lisp @@ -0,0 +1,7 @@ +;; Example 2: +(setf B (make-array '(4 4) :initial-contents '((18 22 54 42) (22 70 86 62) (54 86 174 134) (42 62 134 106)))) +(chol B) +#2A((4.2426405 0 0 0) + (5.18545 6.565905 0 0) + (12.727922 3.0460374 1.6497375 0) + (9.899495 1.6245536 1.849715 1.3926151)) diff --git a/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-4.lisp b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-4.lisp new file mode 100644 index 0000000000..bac6294ff7 --- /dev/null +++ b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-4.lisp @@ -0,0 +1,11 @@ +;; case of matrix stored as a list of lists (inner lists are rows of matrix) +;; as above, returns the Cholesky decomposition matrix of a square positive-definite, symmetric matrix +(defun cholesky (m) + (let ((l (list (list (sqrt (caar m))))) x (j 0) i) + (dolist (cm (cdr m) (mapcar #'(lambda (x) (nconc x (make-list (- (length m) (length x)) :initial-element 0))) l)) + (setq x (list (/ (car cm) (caar l))) i 0) + (dolist (cl (cdr l)) + (setf (cdr (last x)) (list (/ (- (elt cm (incf i)) (*v x cl)) (car (last cl)))))) + (setf (cdr (last l)) (list (nconc x (list (sqrt (- (elt cm (incf j)) (*v x x)))))))))) +;; where *v is the scalar product defined as +(defun *v (v1 v2) (reduce #'+ (mapcar #'* v1 v2))) diff --git a/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-5.lisp b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-5.lisp new file mode 100644 index 0000000000..aa49f160d5 --- /dev/null +++ b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-5.lisp @@ -0,0 +1,10 @@ +;; example 1 +CL-USER> (setf a '((25 15 -5) (15 18 0) (-5 0 11))) +((25 15 -5) (15 18 0) (-5 0 11)) +CL-USER> (cholesky a) +((5 0 0) (3 3 0) (-1 1 3)) +CL-USER> (format t "~{~{~5d~}~%~}" (cholesky a)) + 5 0 0 + 3 3 0 + -1 1 3 +NIL diff --git a/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-6.lisp b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-6.lisp new file mode 100644 index 0000000000..ee6110777a --- /dev/null +++ b/Task/Cholesky-decomposition/Common-Lisp/cholesky-decomposition-6.lisp @@ -0,0 +1,11 @@ +;; example 2 +CL-USER> (setf a '((18 22 54 42) (22 70 86 62) (54 86 174 134) (42 62 134 106))) +((18 22 54 42) (22 70 86 62) (54 86 174 134) (42 62 134 106)) +CL-USER> (cholesky a) +((4.2426405 0 0 0) (5.18545 6.565905 0 0) (12.727922 3.0460374 1.6497375 0) (9.899495 1.6245536 1.849715 1.3926151)) +CL-USER> (format t "~{~{~10,5f~}~%~}" (cholesky a)) + 4.24264 0.00000 0.00000 0.00000 + 5.18545 6.56591 0.00000 0.00000 + 12.72792 3.04604 1.64974 0.00000 + 9.89950 1.62455 1.84971 1.39262 +NIL diff --git a/Task/Cholesky-decomposition/D/cholesky-decomposition.d b/Task/Cholesky-decomposition/D/cholesky-decomposition.d new file mode 100644 index 0000000000..e3d9b0c741 --- /dev/null +++ b/Task/Cholesky-decomposition/D/cholesky-decomposition.d @@ -0,0 +1,27 @@ +import std.stdio, std.math, std.numeric; + +T[][] cholesky(T)(in T[][] A) { + auto L = new T[][](A.length, A.length); + foreach (r, row; L) + row[r+1 .. $] = 0; + foreach (i; 0 .. A.length) + foreach (j; 0 .. i+1) { + T t = dotProduct(L[i][0..j], L[j][0..j]); + L[i][j] = (i == j) ? (A[i][i] - t) ^^ 0.5 : + (1.0 / L[j][j] * (A[i][j] - t)); + } + return L; +} + +void main() { + double[][] m1 = [[25, 15, -5], + [15, 18, 0], + [-5, 0, 11]]; + writefln("%(%(%2.0f %)\n%)\n", cholesky(m1)); + + double[][] m2 = [[18, 22, 54, 42], + [22, 70, 86, 62], + [54, 86, 174, 134], + [42, 62, 134, 106]]; + writefln("%(%(%f %)\n%)\n", cholesky(m2)); +} diff --git a/Task/Cholesky-decomposition/DWScript/cholesky-decomposition.dwscript b/Task/Cholesky-decomposition/DWScript/cholesky-decomposition.dwscript new file mode 100644 index 0000000000..a3b29bc512 --- /dev/null +++ b/Task/Cholesky-decomposition/DWScript/cholesky-decomposition.dwscript @@ -0,0 +1,46 @@ +function Cholesky(a : array of Float) : array of Float; +var + i, j, k, n : Integer; + s : Float; +begin + n:=Round(Sqrt(a.Length)); + Result:=new Float[n*n]; + for i:=0 to n-1 do begin + for j:=0 to i do begin + s:=0 ; + for k:=0 to j-1 do + s+=Result[i*n+k] * Result[j*n+k]; + if i=j then + Result[i*n+j]:=Sqrt(a[i*n+i]-s) + else Result[i*n+j]:=1/Result[j*n+j]*(a[i*n+j]-s); + end; + end; +end; + +procedure ShowMatrix(a : array of Float); +var + i, j, n : Integer; +begin + n:=Round(Sqrt(a.Length)); + for i:=0 to n-1 do begin + for j:=0 to n-1 do + Print(Format('%2.5f ', [a[i*n+j]])); + PrintLn(''); + end; +end; + +var m1 := new Float[9]; +m1 := [ 25.0, 15.0, -5.0, + 15.0, 18.0, 0.0, + -5.0, 0.0, 11.0 ]; +var c1 := Cholesky(m1); +ShowMatrix(c1); + +PrintLn(''); + +var m2 : array of Float := [ 18.0, 22.0, 54.0, 42.0, + 22.0, 70.0, 86.0, 62.0, + 54.0, 86.0, 174.0, 134.0, + 42.0, 62.0, 134.0, 106.0 ]; +var c2 := Cholesky(m2); +ShowMatrix(c2); diff --git a/Task/Cholesky-decomposition/Go/cholesky-decomposition-1.go b/Task/Cholesky-decomposition/Go/cholesky-decomposition-1.go new file mode 100644 index 0000000000..758c33df82 --- /dev/null +++ b/Task/Cholesky-decomposition/Go/cholesky-decomposition-1.go @@ -0,0 +1,105 @@ +package main + +import ( + "fmt" + "math" +) + +// symmetric and lower use a packed representation that stores only +// the lower triangle. + +type symmetric struct { + order int + ele []float64 +} + +type lower struct { + order int + ele []float64 +} + +// symmetric.print prints a square matrix from the packed representation, +// printing the upper triange as a transpose of the lower. +func (s *symmetric) print() { + const eleFmt = "%10.5f " + row, diag := 1, 0 + for i, e := range s.ele { + fmt.Printf(eleFmt, e) + if i == diag { + for j, col := diag+row, row; col < s.order; j += col { + fmt.Printf(eleFmt, s.ele[j]) + col++ + } + fmt.Println() + row++ + diag += row + } + } +} + +// lower.print prints a square matrix from the packed representation, +// printing the upper triangle as all zeros. +func (l *lower) print() { + const eleFmt = "%10.5f " + row, diag := 1, 0 + for i, e := range l.ele { + fmt.Printf(eleFmt, e) + if i == diag { + for j := row; j < l.order; j++ { + fmt.Printf(eleFmt, 0.) + } + fmt.Println() + row++ + diag += row + } + } +} + +// choleskyLower returns the cholesky decomposition of a symmetric real +// matrix. The matrix must be positive definite but this is not checked. +func (a *symmetric) choleskyLower() *lower { + l := &lower{a.order, make([]float64, len(a.ele))} + row, col := 1, 1 + dr := 0 // index of diagonal element at end of row + dc := 0 // index of diagonal element at top of column + for i, e := range a.ele { + if i < dr { + d := (e - l.ele[i]) / l.ele[dc] + l.ele[i] = d + ci, cx := col, dc + for j := i + 1; j <= dr; j++ { + cx += ci + ci++ + l.ele[j] += d * l.ele[cx] + } + col++ + dc += col + } else { + l.ele[i] = math.Sqrt(e - l.ele[i]) + row++ + dr += row + col = 1 + dc = 0 + } + } + return l +} + +func main() { + demo(&symmetric{3, []float64{ + 25, + 15, 18, + -5, 0, 11}}) + demo(&symmetric{4, []float64{ + 18, + 22, 70, + 54, 86, 174, + 42, 62, 134, 106}}) +} + +func demo(a *symmetric) { + fmt.Println("A:") + a.print() + fmt.Println("L:") + a.choleskyLower().print() +} diff --git a/Task/Cholesky-decomposition/Go/cholesky-decomposition-2.go b/Task/Cholesky-decomposition/Go/cholesky-decomposition-2.go new file mode 100644 index 0000000000..d7fa2ffab5 --- /dev/null +++ b/Task/Cholesky-decomposition/Go/cholesky-decomposition-2.go @@ -0,0 +1,81 @@ +package main + +import ( + "fmt" + "math/cmplx" +) + +type matrix struct { + ele []complex128 + stride int +} + +func matrixFromRows(rows [][]complex128) *matrix { + if len(rows) == 0 { + return &matrix{nil, 0} + } + m := &matrix{make([]complex128, len(rows)*len(rows[0])), len(rows[0])} + for rx, row := range rows { + copy(m.ele[rx*m.stride:(rx+1)*m.stride], row) + } + return m +} + +func like(a *matrix) *matrix { + return &matrix{make([]complex128, len(a.ele)), a.stride} +} + +func (m *matrix) print(heading string) { + if heading > "" { + fmt.Print("\n", heading, "\n") + } + for e := 0; e < len(m.ele); e += m.stride { + fmt.Printf("%7.2f ", m.ele[e:e+m.stride]) + fmt.Println() + } +} + +func (a *matrix) choleskyDecomp() *matrix { + l := like(a) + // Cholesky-Banachiewicz algorithm + for r, rxc0 := 0, 0; r < a.stride; r++ { + // calculate elements along row, up to diagonal + x := rxc0 + for c, cxc0 := 0, 0; c < r; c++ { + sum := a.ele[x] + for k := 0; k < c; k++ { + sum -= l.ele[rxc0+k] * cmplx.Conj(l.ele[cxc0+k]) + } + l.ele[x] = sum / l.ele[cxc0+c] + x++ + cxc0 += a.stride + } + // calcualate diagonal element + sum := a.ele[x] + for k := 0; k < r; k++ { + sum -= l.ele[rxc0+k] * cmplx.Conj(l.ele[rxc0+k]) + } + l.ele[x] = cmplx.Sqrt(sum) + rxc0 += a.stride + } + return l +} + +func main() { + demo("A:", matrixFromRows([][]complex128{ + {25, 15, -5}, + {15, 18, 0}, + {-5, 0, 11}, + })) + demo("A:", matrixFromRows([][]complex128{ + {18, 22, 54, 42}, + {22, 70, 86, 62}, + {54, 86, 174, 134}, + {42, 62, 134, 106}, + })) +} + +func demo(heading string, a *matrix) { + a.print(heading) + a.choleskyDecomp().print("Cholesky factor L:") +} diff --git a/Task/Cholesky-decomposition/Go/cholesky-decomposition-3.go b/Task/Cholesky-decomposition/Go/cholesky-decomposition-3.go new file mode 100644 index 0000000000..82c5332909 --- /dev/null +++ b/Task/Cholesky-decomposition/Go/cholesky-decomposition-3.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + + mat "github.com/skelterjohn/go.matrix" +) + +func main() { + demo(mat.MakeDenseMatrix([]float64{ + 25, 15, -5, + 15, 18, 0, + -5, 0, 11, + }, 3, 3)) + demo(mat.MakeDenseMatrix([]float64{ + 18, 22, 54, 42, + 22, 70, 86, 62, + 54, 86, 174, 134, + 42, 62, 134, 106, + }, 4, 4)) +} + +func demo(m *mat.DenseMatrix) { + fmt.Println("A:") + fmt.Println(m) + l, err := m.Cholesky() + if err != nil { + fmt.Println(err) + return + } + fmt.Println("L:") + fmt.Println(l) +} diff --git a/Task/Cholesky-decomposition/Haskell/cholesky-decomposition-1.hs b/Task/Cholesky-decomposition/Haskell/cholesky-decomposition-1.hs new file mode 100644 index 0000000000..059a8e2f81 --- /dev/null +++ b/Task/Cholesky-decomposition/Haskell/cholesky-decomposition-1.hs @@ -0,0 +1,29 @@ +module Cholesky (Arr, cholesky) where + +import Data.Array.IArray +import Data.Array.MArray +import Data.Array.Unboxed +import Data.Array.ST + +type Idx = (Int,Int) +type Arr = UArray Idx Double + +-- Return the (i,j) element of the lower triangular matrix. (We assume the +-- lower array bound is (0,0).) +get :: Arr -> Arr -> Idx -> Double +get a l (i,j) | i == j = sqrt $ a!(j,j) - dot + | i > j = (a!(i,j) - dot) / l!(j,j) + | otherwise = 0 + where dot = sum [l!(i,k) * l!(j,k) | k <- [0..j-1]] + +-- Return the lower triangular matrix of a Cholesky decomposition. We assume +-- the input is a real, symmetric, positive-definite matrix, with lower array +-- bounds of (0,0). +cholesky :: Arr -> Arr +cholesky a = let n = maxBnd a + in runSTUArray $ do + l <- thaw a + mapM_ (update a l) [(i,j) | i <- [0..n], j <- [0..n]] + return l + where maxBnd = fst . snd . bounds + update a l i = unsafeFreeze l >>= \l' -> writeArray l i (get a l' i) diff --git a/Task/Cholesky-decomposition/Haskell/cholesky-decomposition-2.hs b/Task/Cholesky-decomposition/Haskell/cholesky-decomposition-2.hs new file mode 100644 index 0000000000..fdf02c7050 --- /dev/null +++ b/Task/Cholesky-decomposition/Haskell/cholesky-decomposition-2.hs @@ -0,0 +1,17 @@ +import Data.Array.IArray +import Cholesky + +ex1, ex2 :: Arr +ex1 = listArray ((0,0),(2,2)) [25, 15, -5, + 15, 18, 0, + -5, 0, 11] + +ex2 = listArray ((0,0),(3,3)) [18, 22, 54, 42, + 22, 70, 86, 62, + 54, 86, 174, 134, + 42, 62, 134, 106] + +main :: IO () +main = do + print $ elems $ cholesky ex1 + print $ elems $ cholesky ex2 diff --git a/Task/Cholesky-decomposition/Java/cholesky-decomposition.java b/Task/Cholesky-decomposition/Java/cholesky-decomposition.java new file mode 100644 index 0000000000..56f9a0ccc3 --- /dev/null +++ b/Task/Cholesky-decomposition/Java/cholesky-decomposition.java @@ -0,0 +1,31 @@ +import java.util.Arrays; + +public class Cholesky { + public static double[][] chol(double[][] a){ + int m = a.length; + double[][] l = new double[m][m]; //automatically initialzed to 0's + for(int i = 0; i< m;i++){ + for(int k = 0; k < (i+1); k++){ + double sum = 0; + for(int j = 0; j < k; j++){ + sum += l[i][j] * l[k][j]; + } + l[i][k] = (i == k) ? Math.sqrt(a[i][i] - sum) : + (1.0 / l[k][k] * (a[i][k] - sum)); + } + } + return l; + } + + public static void main(String[] args){ + double[][] test1 = {{25, 15, -5}, + {15, 18, 0}, + {-5, 0, 11}}; + System.out.println(Arrays.deepToString(chol(test1))); + double[][] test2 = {{18, 22, 54, 42}, + {22, 70, 86, 62}, + {54, 86, 174, 134}, + {42, 62, 134, 106}}; + System.out.println(Arrays.deepToString(chol(test2))); + } +} diff --git a/Task/Cholesky-decomposition/MATLAB/cholesky-decomposition.m b/Task/Cholesky-decomposition/MATLAB/cholesky-decomposition.m new file mode 100644 index 0000000000..d7acfb3867 --- /dev/null +++ b/Task/Cholesky-decomposition/MATLAB/cholesky-decomposition.m @@ -0,0 +1,13 @@ + A = [ + 25 15 -5 + 15 18 0 + -5 0 11 ]; + + B = [ + 18 22 54 42 + 22 70 86 62 + 54 86 174 134 + 42 62 134 106 ]; + + [L] = chol(A,'lower') + [L] = chol(B,'lower') diff --git a/Task/Cholesky-decomposition/PicoLisp/cholesky-decomposition-1.l b/Task/Cholesky-decomposition/PicoLisp/cholesky-decomposition-1.l new file mode 100644 index 0000000000..5788ed8b16 --- /dev/null +++ b/Task/Cholesky-decomposition/PicoLisp/cholesky-decomposition-1.l @@ -0,0 +1,17 @@ +(scl 9) +(load "@lib/math.l") + +(de cholesky (A) + (let L (mapcar '(() (need (length A) 0)) A) + (for (I . R) A + (for J I + (let S (get R J) + (for K (inc J) + (dec 'S (*/ (get L I K) (get L J K) 1.0)) ) + (set (nth L I J) + (if (= I J) + (sqrt (* 1.0 S)) + (*/ S 1.0 (get L J J)) ) ) ) ) ) + (for R L + (for N R (prin (align 9 (round N 5)))) + (prinl) ) ) ) diff --git a/Task/Cholesky-decomposition/PicoLisp/cholesky-decomposition-2.l b/Task/Cholesky-decomposition/PicoLisp/cholesky-decomposition-2.l new file mode 100644 index 0000000000..26b6513a6d --- /dev/null +++ b/Task/Cholesky-decomposition/PicoLisp/cholesky-decomposition-2.l @@ -0,0 +1,11 @@ +(cholesky + '((25.0 15.0 -5.0) (15.0 18.0 0) (-5.0 0 11.0)) ) + +(prinl) + +(cholesky + (quote + (18.0 22.0 54.0 42.0) + (22.0 70.0 86.0 62.0) + (54.0 86.0 174.0 134.0) + (42.0 62.0 134.0 106.0) ) ) diff --git a/Task/Cholesky-decomposition/Python/cholesky-decomposition.py b/Task/Cholesky-decomposition/Python/cholesky-decomposition.py new file mode 100644 index 0000000000..7e30cf3617 --- /dev/null +++ b/Task/Cholesky-decomposition/Python/cholesky-decomposition.py @@ -0,0 +1,22 @@ +import math, pprint + +def cholesky(A): + L = [[0.0] * len(A) for _ in xrange(len(A))] + for i in xrange(len(A)): + for j in xrange(i+1): + s = sum(L[i][k] * L[j][k] for k in xrange(j)) + L[i][j] = math.sqrt(A[i][i] - s) if (i == j) else \ + (1.0 / L[j][j] * (A[i][j] - s)) + return L + +m1 = [[25, 15, -5], + [15, 18, 0], + [-5, 0, 11]] +pprint.pprint(cholesky(m1)) +print + +m2 = [[18, 22, 54, 42], + [22, 70, 86, 62], + [54, 86, 174, 134], + [42, 62, 134, 106]] +pprint.pprint(cholesky(m2)) diff --git a/Task/Cholesky-decomposition/R/cholesky-decomposition.r b/Task/Cholesky-decomposition/R/cholesky-decomposition.r new file mode 100644 index 0000000000..073eab3bf7 --- /dev/null +++ b/Task/Cholesky-decomposition/R/cholesky-decomposition.r @@ -0,0 +1,12 @@ +t(chol(matrix(c(25, 15, -5, 15, 18, 0, -5, 0, 11), nrow=3, ncol=3))) +# [,1] [,2] [,3] +# [1,] 5 0 0 +# [2,] 3 3 0 +# [3,] -1 1 3 + +t(chol(matrix(c(18, 22, 54, 42, 22, 70, 86, 62, 54, 86, 174, 134, 42, 62, 134, 106), nrow=4, ncol=4))) +# [,1] [,2] [,3] [,4] +# [1,] 4.242641 0.000000 0.000000 0.000000 +# [2,] 5.185450 6.565905 0.000000 0.000000 +# [3,] 12.727922 3.046038 1.649742 0.000000 +# [4,] 9.899495 1.624554 1.849711 1.392621 diff --git a/Task/Cholesky-decomposition/REXX/cholesky-decomposition.rexx b/Task/Cholesky-decomposition/REXX/cholesky-decomposition.rexx new file mode 100644 index 0000000000..74e4238b7c --- /dev/null +++ b/Task/Cholesky-decomposition/REXX/cholesky-decomposition.rexx @@ -0,0 +1,66 @@ +/*REXX program to perform the Cholesky decomposition on square matrix.*/ + +niner= '25 15 -5' , + '15 18 0' , + '-5 0 11' + call Cholesky niner +hexer= 18 22 54 42, + 22 70 86 62, + 54 86 174 134, + 42 62 134 106 + call Cholesky hexer +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────Cholesky subroutine──────────────*/ +Cholesky: procedure; arg !; call tell 'input array',! + + do row=1 for order + do col=1 for row; s=0 + do i=1 for col-1 + s=s+$.row.i*$.col.i + end /*i*/ + if row=col then $.row.row=sqrt($.row.row-s) + else $.row.col=1/$.col.col*(@.row.col-s) + end /*col*/ + end /*row*/ + +call tell 'Cholesky factor',,$.,'─' +return +/*─────────────────────────────────────TELL subroutine───&find the order*/ +tell: parse arg hdr,x,y,sep; #=0; if sep=='' then sep='═' +decPlaces = 5 /*number of decimal places past the decimal point. */ +width = 10 /*width of field to be used to display the elements*/ + +if y=='' then $.=0 + else do row=1 for order + do col=1 for order + x=x $.row.col + end /*row*/ + end /*col*/ +w=words(x) + + do order=1 until order**2>=w /*fast way to find the MAT order.*/ + end /*order*/ + +if order**2\==w then call err "matrix elements don't match its order" +say; say center(hdr, ((width+1)*w)%order, sep); say + + do row=1 for order; aLine= + do col=1 for order; #=#+1 + @.row.col=word(x,#) + if col<=row then $.row.col=@.row.col + aLine=aLine right( format(@.row.col,, decPlaces) /1, width) + end /*col*/ + say aLine + end /*row*/ +return +/*─────────────────────────────────────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 call err 'SQRT of negative #'; 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 +/*─────────────────────────────────────ERR subroutine───────────────────*/ +err: say; say; say '***error***!'; say; say arg(1); say; say; exit 13 diff --git a/Task/Cholesky-decomposition/Ruby/cholesky-decomposition.rb b/Task/Cholesky-decomposition/Ruby/cholesky-decomposition.rb new file mode 100644 index 0000000000..1c43daeb9f --- /dev/null +++ b/Task/Cholesky-decomposition/Ruby/cholesky-decomposition.rb @@ -0,0 +1,38 @@ +require 'matrix' + +class Matrix + def symmetric? + return false if not square? + (0 ... row_size).each do |i| + (0 .. i).each do |j| + return false if self[i,j] != self[j,i] + end + end + true + end + + def cholesky_factor + raise ArgumentError, "must provide symmetric matrix" unless symmetric? + l = Array.new(row_size) {Array.new(row_size, 0)} + (0 ... row_size).each do |k| + (0 ... row_size).each do |i| + if i == k + sum = (0 .. k-1).inject(0.0) {|sum, j| sum + l[k][j] ** 2} + val = Math.sqrt(self[k,k] - sum) + l[k][k] = val + elsif i > k + sum = (0 .. k-1).inject(0.0) {|sum, j| sum + l[i][j] * l[k][j]} + val = (self[k,i] - sum) / l[k][k] + l[i][k] = val + end + end + end + Matrix[*l] + end +end + +puts Matrix[[25,15,-5],[15,18,0],[-5,0,11]].cholesky_factor +puts Matrix[[18, 22, 54, 42], + [22, 70, 86, 62], + [54, 86, 174, 134], + [42, 62, 134, 106]].cholesky_factor diff --git a/Task/Cholesky-decomposition/Tcl/cholesky-decomposition-1.tcl b/Task/Cholesky-decomposition/Tcl/cholesky-decomposition-1.tcl new file mode 100644 index 0000000000..116ca697a5 --- /dev/null +++ b/Task/Cholesky-decomposition/Tcl/cholesky-decomposition-1.tcl @@ -0,0 +1,19 @@ +proc cholesky a { + set m [llength $a] + set n [llength [lindex $a 0]] + set l [lrepeat $m [lrepeat $n 0.0]] + for {set i 0} {$i < $m} {incr i} { + for {set k 0} {$k < $i+1} {incr k} { + set sum 0.0 + for {set j 0} {$j < $k} {incr j} { + set sum [expr {$sum + [lindex $l $i $j] * [lindex $l $k $j]}] + } + lset l $i $k [expr { + $i == $k + ? sqrt([lindex $a $i $i] - $sum) + : (1.0 / [lindex $l $k $k] * ([lindex $a $i $k] - $sum)) + }] + } + } + return $l +} diff --git a/Task/Cholesky-decomposition/Tcl/cholesky-decomposition-2.tcl b/Task/Cholesky-decomposition/Tcl/cholesky-decomposition-2.tcl new file mode 100644 index 0000000000..8990e44961 --- /dev/null +++ b/Task/Cholesky-decomposition/Tcl/cholesky-decomposition-2.tcl @@ -0,0 +1,13 @@ +set test1 { + {25 15 -5} + {15 18 0} + {-5 0 11} +} +puts [cholesky $test1] +set test2 { + {18 22 54 42} + {22 70 86 62} + {54 86 174 134} + {42 62 134 106} +} +puts [cholesky $test2] diff --git a/Task/Classes/C++/classes-1.cpp b/Task/Classes/C++/classes-1.cpp new file mode 100644 index 0000000000..6418b13555 --- /dev/null +++ b/Task/Classes/C++/classes-1.cpp @@ -0,0 +1,29 @@ +class MyClass +{ +public: + void someMethod(); // member function = method + MyClass(); // constructor +private: + int variable; // member variable = instance variable +}; + +// implementation of constructor +MyClass::MyClass(): + variable(0) +{ + // here could be more code +} + +// implementation of member function +void MyClass::someMethod() +{ + variable = 1; // alternatively: this->variable = 1 +} + +// Create an instance as variable +MyClass instance; + +// Create an instance on free store +MyClass* pInstance = new MyClass; +// Instances allocated with new must be explicitly destroyed when not needed any more: +delete pInstance; diff --git a/Task/Classes/C++/classes-2.cpp b/Task/Classes/C++/classes-2.cpp new file mode 100644 index 0000000000..3786e224d1 --- /dev/null +++ b/Task/Classes/C++/classes-2.cpp @@ -0,0 +1,8 @@ +class MyClass +{ +public: + MyClass(): variable(0) {} + void someMethod() { variable = 1; } +private: + int variable; +}; diff --git a/Task/Classes/C++/classes-3.cpp b/Task/Classes/C++/classes-3.cpp new file mode 100644 index 0000000000..4341aaf4f5 --- /dev/null +++ b/Task/Classes/C++/classes-3.cpp @@ -0,0 +1,6 @@ +class MyClass +{ +public: + virtual void someMethod(); // this is polymorphic + virtual ~MyClass(); // destructor +}; diff --git a/Task/Classes/Common-Lisp/classes.lisp b/Task/Classes/Common-Lisp/classes.lisp new file mode 100644 index 0000000000..ff7147e6f0 --- /dev/null +++ b/Task/Classes/Common-Lisp/classes.lisp @@ -0,0 +1,12 @@ +(defclass circle () + ((radius :initarg :radius + :initform 1.0 + :type number + :reader radius))) + +(defmethod area ((shape circle)) + (* pi (expt (radius shape) 2))) + +> (defvar *c* (make-instance 'circle :radius 2)) +> (area *c*) +12.566370614359172d0 diff --git a/Task/Classes/D/classes.d b/Task/Classes/D/classes.d new file mode 100644 index 0000000000..5dd8bd0e06 --- /dev/null +++ b/Task/Classes/D/classes.d @@ -0,0 +1,43 @@ +import std.stdio; + +class MyClass { + //constructor (not necessary if empty) + this() {} + + void someMethod() { + variable = 1; + } + + // getter method + @property int variable() const { + return variable_; + } + + // setter method + @property int variable(int newVariable) { + return variable_ = newVariable; + } + + private int variable_; +} + +void main() { + // On default class instances are allocated on the heap + // The GC will manage their lifetime + auto obj = new MyClass(); + + // prints 'variable = 0', ints are initialized to 0 by default + writeln("variable = ", obj.variable); + + // invoke the method + obj.someMethod(); + + // prints 'variable = 1' + writeln("variable = ", obj.variable); + + // set the variable using setter method + obj.variable = 99; + + // prints 'variable = 99' + writeln("variable = ", obj.variable); +} diff --git a/Task/Classes/DWScript/classes.dwscript b/Task/Classes/DWScript/classes.dwscript new file mode 100644 index 0000000000..a53527408c --- /dev/null +++ b/Task/Classes/DWScript/classes.dwscript @@ -0,0 +1,25 @@ +type + TMyClass = class + private + FSomeField: Integer; // by convention, fields are usually private and exposed as properties + public + constructor Create; + begin + FSomeField := -1; + end; + procedure SomeMethod; + property SomeField: Integer read FSomeField write FSomeField; + end; + +procedure TMyClass.SomeMethod; +begin + // do something +end; + + +var lMyClass: TMyClass; + +lMyClass := new TMyClass; // can also use TMyClass.Create + +lMyClass.SomeField := 99; +lMyClass.SomeMethod; diff --git a/Task/Classes/Delphi/classes.delphi b/Task/Classes/Delphi/classes.delphi new file mode 100644 index 0000000000..b05bc1bd64 --- /dev/null +++ b/Task/Classes/Delphi/classes.delphi @@ -0,0 +1,44 @@ +program SampleClass; + +{$APPTYPE CONSOLE} + +type + TMyClass = class + private + FSomeField: Integer; // by convention, fields are usually private and exposed as properties + public + constructor Create; + destructor Destroy; override; + procedure SomeMethod; + property SomeField: Integer read FSomeField write FSomeField; + end; + +constructor TMyClass.Create; +begin + FSomeField := -1 +end; + +destructor TMyClass.Destroy; +begin + // free resources, etc + + inherited Destroy; +end; + +procedure TMyClass.SomeMethod; +begin + // do something +end; + + +var + lMyClass: TMyClass; +begin + lMyClass := TMyClass.Create; + try + lMyClass.SomeField := 99; + lMyClass.SomeMethod(); + finally + lMyClass.Free; + end; +end. diff --git a/Task/Classes/E/classes-1.e b/Task/Classes/E/classes-1.e new file mode 100644 index 0000000000..f4fb7ad4d3 --- /dev/null +++ b/Task/Classes/E/classes-1.e @@ -0,0 +1,8 @@ +def makeColor(name :String) { + def color { + to colorize(thing :String) { + return `$name $thing` + } + } + return color +} diff --git a/Task/Classes/E/classes-2.e b/Task/Classes/E/classes-2.e new file mode 100644 index 0000000000..e4a369e219 --- /dev/null +++ b/Task/Classes/E/classes-2.e @@ -0,0 +1,5 @@ +? def red := makeColor("red") +# value: + +? red.colorize("apple") +# value: "red apple" diff --git a/Task/Closest-pair-problem/Common-Lisp/closest-pair-problem.lisp b/Task/Closest-pair-problem/Common-Lisp/closest-pair-problem.lisp new file mode 100644 index 0000000000..4d13a56b25 --- /dev/null +++ b/Task/Closest-pair-problem/Common-Lisp/closest-pair-problem.lisp @@ -0,0 +1,55 @@ +(defun point-distance (p1 p2) + (destructuring-bind (x1 . y1) p1 + (destructuring-bind (x2 . y2) p2 + (let ((dx (- x2 x1)) (dy (- y2 y1))) + (sqrt (+ (* dx dx) (* dy dy))))))) + +(defun closest-pair-bf (points) + (let ((pair (list (first points) (second points))) + (dist (point-distance (first points) (second points)))) + (dolist (p1 points (values pair dist)) + (dolist (p2 points) + (unless (eq p1 p2) + (let ((pdist (point-distance p1 p2))) + (when (< pdist dist) + (setf (first pair) p1 + (second pair) p2 + dist pdist)))))))) + +(defun closest-pair (points) + (labels + ((cp (xp &aux (length (length xp))) + (if (<= length 3) + (multiple-value-bind (pair distance) (closest-pair-bf xp) + (values pair distance (sort xp '< :key 'cdr))) + (let* ((xr (nthcdr (1- (floor length 2)) xp)) + (xm (/ (+ (caar xr) (caadr xr)) 2))) + (psetf xr (rest xr) + (rest xr) '()) + (multiple-value-bind (lpair ldist yl) (cp xp) + (multiple-value-bind (rpair rdist yr) (cp xr) + (multiple-value-bind (dist pair) + (if (< ldist rdist) + (values ldist lpair) + (values rdist rpair)) + (let* ((all-ys (merge 'vector yl yr '< :key 'cdr)) + (ys (remove-if #'(lambda (p) + (> (abs (- (car p) xm)) dist)) + all-ys)) + (ns (length ys))) + (dotimes (i ns) + (do ((k (1+ i) (1+ k))) + ((or (= k ns) + (> (- (cdr (aref ys k)) + (cdr (aref ys i))) + dist))) + (let ((pd (point-distance (aref ys i) + (aref ys k)))) + (when (< pd dist) + (setf dist pd + (first pair) (aref ys i) + (second pair) (aref ys k)))))) + (values pair dist all-ys))))))))) + (multiple-value-bind (pair distance) + (cp (sort (copy-list points) '< :key 'car)) + (values pair distance)))) diff --git a/Task/Closest-pair-problem/D/closest-pair-problem-1.d b/Task/Closest-pair-problem/D/closest-pair-problem-1.d new file mode 100644 index 0000000000..f75b27d8fc --- /dev/null +++ b/Task/Closest-pair-problem/D/closest-pair-problem-1.d @@ -0,0 +1,68 @@ +import std.stdio, std.typecons, std.math, std.algorithm, + std.array, std.random, std.traits; + +auto bruteForceClosestPair(T)(in T[] points) pure nothrow { + auto minD = Unqual!(typeof(T.re)).infinity; + Unqual!T minI, minJ; + foreach (i, p1; points[0 .. $-1]) + foreach (j, p2; points[i+1 .. $]) { + immutable dist = abs(p1 - p2); + if (dist < minD) { + minD = dist; + minI = p1; + minJ = p2; + } + } + return tuple(minD, minI, minJ); +} + +auto closestPair(T)(T[] points) /*pure nothrow*/ { + static Tuple!(typeof(T.re),T,T) inner(in T[] xP, /*in*/ T[] yP) { + if (xP.length <= 3) + return bruteForceClosestPair(xP); + const Pl = xP[0 .. xP.length/2]; + const Pr = xP[xP.length/2 .. $]; + immutable xDiv = Pl[$ - 1].re; + auto Yr = partition!(p => p.re <= xDiv)(yP); + immutable dl_pairl = inner(Pl, yP[0 .. yP.length - Yr.length]); + immutable dr_pairr = inner(Pr, Yr); + immutable dm_pairm= dl_pairl[0] abs(p.re - xDiv) < dm)().array(); + if (nextY.length > 1) { + auto minD = typeof(T.re).infinity; + size_t minI, minJ; + foreach (i; 0 .. nextY.length-1) + foreach (j; i+1 .. min(i+8, nextY.length)) { + immutable double dist = abs(nextY[i] - nextY[j]); + if (dist < minD) { + minD = dist; + minI = i; + minJ = j; + } + } + return dm <= minD ? dm_pairm : + Tuple!(typeof(T.re),T,T)(minD,nextY[minI],nextY[minJ]); + } else + return dm_pairm; + } + + sort!q{ a.re < b.re }(points); + auto xP = points.dup; + sort!q{ a.im < b.im }(points); + return inner(xP, points); +} + +void main() { + auto pts= [5+9i, 9+3i, 2, 8+4i, 7+4i, 9+10i, 1+9i, 8+2i, 10i, 9+6i]; + writeln(pts); + writeln("bruteForceClosestPair: ", bruteForceClosestPair(pts)); + writeln(" closestPair: ", closestPair(pts)); + + auto rnd = Random(1); // set seed + cdouble[10_000] points; + foreach (ref p; points) + p = uniform(0.0, 1000.0, rnd) + uniform(0.0, 1000.0, rnd) * 1i; + writeln("bruteForceClosestPair: ", bruteForceClosestPair(points)); + writeln(" closestPair: ", closestPair(points)); +} diff --git a/Task/Closest-pair-problem/D/closest-pair-problem-2.d b/Task/Closest-pair-problem/D/closest-pair-problem-2.d new file mode 100644 index 0000000000..29b19f0ae8 --- /dev/null +++ b/Task/Closest-pair-problem/D/closest-pair-problem-2.d @@ -0,0 +1,49 @@ +import core.stdc.stdio, core.stdc.stdlib, std.math; // for Phobos +//import tango.stdc.stdio, tango.stdc.stdlib, tango.math.Math; + +int bfClosestPair2(cdouble[] points, out size_t i1, out size_t i2) { + auto minD = typeof(points[0].re).infinity; + if (points.length < 2) { + i1 = i2 = size_t.max; + return -1; + } + size_t minI, minJ; + for (int i = 0; i < points.length-1; i++) { + auto points_i_re = points[i].re; + auto points_i_im = points[i].im; + for (int j = i+1; j < points.length; j++) { + auto dre = points_i_re - points[j].re; + auto dist = dre * dre; + if (dist < minD) { + auto dim = points_i_im - points[j].im; + dist += dim * dim; + if (dist < minD) { + minD = dist; + minI = i; + minJ = j; + } + } + } + } + + i1 = minI; + i2 = minJ; + return 0; +} + +void main() { + srand(31415); + auto pts = new cdouble[10_000]; + foreach (ref p; pts) + p = 1000.0 * (cast(double)rand() / (RAND_MAX + 1.0)) + + 1000.0i * (cast(double)rand() / (RAND_MAX + 1.0)); + + size_t i, j; + int err = bfClosestPair2(pts, i, j); + if (err < 0) + return; + double d = sqrt((pts[i].re - pts[j].re) * (pts[i].re - pts[j].re) + + (pts[i].im - pts[j].im) * (pts[i].im - pts[j].im)); + printf("Closest pair: dist: %lf p1, p2: (%lf, %lf), (%lf, %lf)\n", + d, pts[i].re, pts[i].im, pts[j].re, pts[j].im); +} diff --git a/Task/Collections/C++/collections-1.cpp b/Task/Collections/C++/collections-1.cpp new file mode 100644 index 0000000000..7b4ee144bb --- /dev/null +++ b/Task/Collections/C++/collections-1.cpp @@ -0,0 +1,8 @@ +int a[5]; // array of 5 ints (since int is POD, the members are not initialized) +a[0] = 1; // indexes start at 0 + +int primes[10] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 }; // arrays can be initialized on creation + +#include +std::string strings[4]; // std::string is no POD, therefore all array members are default-initialized + // (for std::string this means initialized with empty strings) diff --git a/Task/Collections/C++/collections-2.cpp b/Task/Collections/C++/collections-2.cpp new file mode 100644 index 0000000000..52e9e8a684 --- /dev/null +++ b/Task/Collections/C++/collections-2.cpp @@ -0,0 +1,5 @@ +#include + +std::vector v; // empty vector +v.push_back(5); // insert a 5 at the end +v.insert(v.begin(), 7); // insert a 7 at the beginning diff --git a/Task/Collections/C++/collections-3.cpp b/Task/Collections/C++/collections-3.cpp new file mode 100644 index 0000000000..be4403593f --- /dev/null +++ b/Task/Collections/C++/collections-3.cpp @@ -0,0 +1,6 @@ +#include + +std::deque d; // empty deque +d.push_back(5); // insert a 5 at the end +d.push_front(7); // insert a 7 at the beginning +d.insert(v.begin()+1, 6); // insert a 6 in the middle diff --git a/Task/Collections/C++/collections-4.cpp b/Task/Collections/C++/collections-4.cpp new file mode 100644 index 0000000000..08514dba98 --- /dev/null +++ b/Task/Collections/C++/collections-4.cpp @@ -0,0 +1,8 @@ +#include + +std::list l; // empty list +l.push_back(5); // insert a 5 at the end +l.push_front(7); // insert a 7 at the beginning +std::list::iterator i = l.begin(); +++l; +l.insert(i, 6); // insert a 6 in the middle diff --git a/Task/Collections/C++/collections-5.cpp b/Task/Collections/C++/collections-5.cpp new file mode 100644 index 0000000000..9bca0175df --- /dev/null +++ b/Task/Collections/C++/collections-5.cpp @@ -0,0 +1,6 @@ +#include + +std::set s; // empty set +s.insert(5); // insert a 5 +s.insert(7); // insert a 7 (automatically placed after the 5) +s.insert(5); // try to insert another 5 (will not change the set) diff --git a/Task/Collections/C++/collections-6.cpp b/Task/Collections/C++/collections-6.cpp new file mode 100644 index 0000000000..9c18407c42 --- /dev/null +++ b/Task/Collections/C++/collections-6.cpp @@ -0,0 +1,6 @@ +#include + +std::multiset m; // empty multiset +m.insert(5); // insert a 5 +m.insert(7); // insert a 7 (automatically placed after the 5) +m.insert(5); // insert a second 5 (now m contains two 5s, followed by one 7) diff --git a/Task/Collections/Common-Lisp/collections-1.lisp b/Task/Collections/Common-Lisp/collections-1.lisp new file mode 100644 index 0000000000..c114cff71f --- /dev/null +++ b/Task/Collections/Common-Lisp/collections-1.lisp @@ -0,0 +1,41 @@ +CL-USER> (let ((list '()) + (hash-table (make-hash-table))) + (push 1 list) + (push 2 list) + (push 3 list) + (format t "~S~%" (reverse list)) + (setf (gethash 'foo hash-table) 42) + (setf (gethash 'bar hash-table) 69) + (maphash (lambda (key value) + (format t "~S => ~S~%" key value)) + hash-table) + ;; or print the hash-table in readable form + ;; (inplementation-dependent) + (write hash-table :readably t) + ;; or describe it + (describe hash-table) + ;; describe the list as well + (describe list)) +;; FORMAT on a list +(1 2 3) +;; FORMAT on a hash-table +FOO => 42 +BAR => 69 +;; WRITE :readably t on a hash-table +#.(SB-IMPL::%STUFF-HASH-TABLE + (MAKE-HASH-TABLE :TEST 'EQL :SIZE '16 :REHASH-SIZE '1.5 + :REHASH-THRESHOLD '1.0 :WEAKNESS 'NIL) + '((BAR . 69) (FOO . 42))) +;; DESCRIBE on a hash-table +# + [hash-table] + +Occupancy: 0.1 +Rehash-threshold: 1.0 +Rehash-size: 1.5 +Size: 16 +Synchronized: no +;; DESCRIBE on a list +(3 2 1) + [list] +; No value diff --git a/Task/Collections/Common-Lisp/collections-2.lisp b/Task/Collections/Common-Lisp/collections-2.lisp new file mode 100644 index 0000000000..0c4f1128d9 --- /dev/null +++ b/Task/Collections/Common-Lisp/collections-2.lisp @@ -0,0 +1,36 @@ +;;; Obtained from Usenet, +;;; Message-ID: +;;; Posting by Kaz Kylheku, February 28, 2008. + +(eval-when (:compile-toplevel :load-toplevel :execute) + (defun bisect-list (list &optional (minimum-length 0)) + (do ((double-skipper (cddr list) (cddr double-skipper)) + (single-skipper list (cdr single-skipper)) + (length 2 (+ length (if (cdr double-skipper) 2 1)))) + ((null double-skipper) + (cond + ((< length minimum-length) + (values list nil)) + ((consp single-skipper) + (multiple-value-prog1 + (values list (cdr single-skipper)) + (setf (cdr single-skipper) nil))) + (t (values list nil)))))) + + (defun pop-deque-helper (facing-piece other-piece) + (if (null facing-piece) + (multiple-value-bind (head tail) (bisect-list other-piece 10) + (let ((remaining (if tail head)) + (moved (nreverse (or tail head)))) + (values (first moved) (rest moved) remaining))) + (values (first facing-piece) (rest facing-piece) other-piece)))) + +(defmacro pop-deque (facing-piece other-piece) + (let ((result (gensym)) + (new-facing (gensym)) + (new-other (gensym))) + `(multiple-value-bind (,result ,new-facing ,new-other) + (pop-deque-helper ,facing-piece ,other-piece) + (psetf ,facing-piece ,new-facing + ,other-piece ,new-other) + ,result))) diff --git a/Task/Collections/D/collections-1.d b/Task/Collections/D/collections-1.d new file mode 100644 index 0000000000..61e022e652 --- /dev/null +++ b/Task/Collections/D/collections-1.d @@ -0,0 +1,3 @@ +int[3] array; +array[0] = 5; +// array.length = 4; // compile-time error diff --git a/Task/Collections/D/collections-2.d b/Task/Collections/D/collections-2.d new file mode 100644 index 0000000000..bfa7623d63 --- /dev/null +++ b/Task/Collections/D/collections-2.d @@ -0,0 +1,6 @@ +int[] array; +array ~= 5; // append 5 +array.length = 3; +array[3] = 17; // runtime error: out of bounds. check removed in release mode. +array = [2, 17, 3]; +writefln(array.sort); // 2, 3, 17 diff --git a/Task/Collections/D/collections-3.d b/Task/Collections/D/collections-3.d new file mode 100644 index 0000000000..c96d6fe5bc --- /dev/null +++ b/Task/Collections/D/collections-3.d @@ -0,0 +1,8 @@ +int[int] array; +// array ~= 5; // it doesn't work that way! +array[5] = 17; +array[6] = 20; +// prints "[5, 6]" -> "[17, 20]" - although the order is not specified. +writefln(array.keys, " -> ", array.values); +assert(5 in array); // returns a pointer, by the way +if (auto ptr = 6 in array) writefln(*ptr); // 20 diff --git a/Task/Collections/E/collections.e b/Task/Collections/E/collections.e new file mode 100644 index 0000000000..e2bea6fad3 --- /dev/null +++ b/Task/Collections/E/collections.e @@ -0,0 +1,27 @@ +? def constList := [1,2,3,4,5] +# value: [1, 2, 3, 4, 5] + +? constList.with(6) +# value: [1, 2, 3, 4, 5, 6] + +? def flexList := constList.diverge() +# value: [1, 2, 3, 4, 5].diverge() + +? flexList.push(6) +? flexList +# value: [1, 2, 3, 4, 5, 6].diverge() + +? constList +# value: [1, 2, 3, 4, 5] + +? def constMap := [1 => 2, 3 => 4] +# value: [1 => 2, 3 => 4] + +? constMap[1] +# value: 2 + +? def constSet := [1, 2, 3, 2].asSet() +# value: [1, 2, 3].asSet() + +? constSet.contains(3) +# value: true diff --git a/Task/Color-of-a-screen-pixel/C++-CLI/color-of-a-screen-pixel.cpp b/Task/Color-of-a-screen-pixel/C++-CLI/color-of-a-screen-pixel.cpp new file mode 100644 index 0000000000..f91f85a33b --- /dev/null +++ b/Task/Color-of-a-screen-pixel/C++-CLI/color-of-a-screen-pixel.cpp @@ -0,0 +1,18 @@ +using namespace System; +using namespace System::Drawing; +using namespace System::Windows::Forms; + +[STAThreadAttribute] +int main() +{ + Point^ MousePoint = gcnew Point(); + Control^ TempControl = gcnew Control(); + MousePoint = TempControl->MousePosition; + Bitmap^ TempBitmap = gcnew Bitmap(1,1); + Graphics^ g = Graphics::FromImage(TempBitmap); + g->CopyFromScreen((Point)MousePoint, Point(0, 0), Size(1, 1)); + Color color = TempBitmap->GetPixel(0,0); + Console::WriteLine("R: "+color.R.ToString()); + Console::WriteLine("G: "+color.G.ToString()); + Console::WriteLine("B: "+color.B.ToString()); +} diff --git a/Task/Color-of-a-screen-pixel/Delphi/color-of-a-screen-pixel.delphi b/Task/Color-of-a-screen-pixel/Delphi/color-of-a-screen-pixel.delphi new file mode 100644 index 0000000000..f41461bc96 --- /dev/null +++ b/Task/Color-of-a-screen-pixel/Delphi/color-of-a-screen-pixel.delphi @@ -0,0 +1,71 @@ +program ScreenPixel; + +{$APPTYPE CONSOLE} + +uses + Windows, + SysUtils, + Graphics; + + +// Use this function in a GUI application to return the color +function GetPixelColourAsColor(const PixelCoords: TPoint): TColor; +var + dc: HDC; +begin + // Get Device Context of windows desktop + dc := GetDC(0); + // Read the color of the pixel at the given coordinates + Result := GetPixel(dc,PixelCoords.X,PixelCoords.Y); +end; + +// Use this function to get a string representation of the current colour +function GetPixelColourAsString(const PixelCoords: TPoint): string; +var + r,g,b: Byte; + col: TColor; +begin + col := GetPixelColourAsColor(PixelCoords); + + // Convert the Delphi TColor value to it's RGB components + r := col and $FF; + g := (col shr 8) and $FF; + b := (col shr 16) and $FF; + + // Format the result + Result := 'R('+IntToStr(r)+') G('+IntToStr(g)+') G('+IntToStr(b)+')'; + + { + Alternatively, format the result as follows to get a + string representation of the Delphi TColor value + + Result := ColorToString(GetPixel(dc,curP.X,curP.Y)); + } + +end; + +var + s: string; + P: TPoint; +begin + s := ''; + + Writeln('Move mouse over a pixel. Hit return to get colour of selected pixel.'); + + repeat + Readln(s); + if s = '' then + begin + GetCursorPos(P); + Writeln('Colour at cursor position X:'+ + IntToStr(P.X)+' Y:'+ + IntToStr(P.Y) +' = '+ + GetPixelColourAsString(P) + ); + Writeln(''); + Writeln('Move mouse and hit enter again.'); + end; + until + SameText(s,'quit'); + +end. diff --git a/Task/Color-quantization/0DESCRIPTION b/Task/Color-quantization/0DESCRIPTION new file mode 100644 index 0000000000..8eb80dbbb6 --- /dev/null +++ b/Task/Color-quantization/0DESCRIPTION @@ -0,0 +1,8 @@ +{{task}} +[[file:quantum_frog.png|full color|thumb|left|192px]][[file:quantum_frog_16.png|Example: Gimp 16 color|thumb|left|192px]] +[[wp:Color_quantization|Color quantization]] is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of [[wp:Cluster_analysis|cluster analysis]], if each RGB color value is considered as a coordinate triple in the 3D colorspace. There are some well know algorithms [http://web.cs.wpi.edu/~matt/courses/cs563/talks/color_quant/CQindex.html], each with its own advantages and drawbacks. + +'''Task''': Take an RGB color image and reduce its colors to some smaller number (< 256). For this task, use the frog as input and reduce colors to 16, and output the resulting colors. The chosen colors should be adaptive to the input image, meaning you should ''not'' use a fixed palette such as Web colors or Windows system palette. Dithering is not required. + +Note: the funny color bar on top of the frog image is intentional. +
diff --git a/Task/Color-quantization/1META.yaml b/Task/Color-quantization/1META.yaml new file mode 100644 index 0000000000..fb36ead2f0 --- /dev/null +++ b/Task/Color-quantization/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Raster graphics operations diff --git a/Task/Color-quantization/C/color-quantization.c b/Task/Color-quantization/C/color-quantization.c new file mode 100644 index 0000000000..7b68f03246 --- /dev/null +++ b/Task/Color-quantization/C/color-quantization.c @@ -0,0 +1,111 @@ +typedef struct oct_node_t oct_node_t, *oct_node; +struct oct_node_t{ + /* sum of all colors represented by this node. 64 bit in case of HUGE image */ + uint64_t r, g, b; + int count, heap_idx; + oct_node kids[8], parent; + unsigned char n_kids, kid_idx, flags, depth; +}; + +/* cmp function that decides the ordering in the heap. This is how we determine + which octree node to fold next, the heart of the algorithm. */ +inline int cmp_node(oct_node a, oct_node b) +{ + if (a->n_kids < b->n_kids) return -1; + if (a->n_kids > b->n_kids) return 1; + + int ac = a->count * (1 + a->kid_idx) >> a->depth; + int bc = b->count * (1 + b->kid_idx) >> b->depth; + return ac < bc ? -1 : ac > bc; +} + +/* adding a color triple to octree */ +oct_node node_insert(oct_node root, unsigned char *pix) +{ +# define OCT_DEPTH 8 + /* 8: number of significant bits used for tree. It's probably good enough + for most images to use a value of 5. This affects how many nodes eventually + end up in the tree and heap, thus smaller values helps with both speed + and memory. */ + + unsigned char i, bit, depth = 0; + for (bit = 1 << 7; ++depth < OCT_DEPTH; bit >>= 1) { + i = !!(pix[1] & bit) * 4 + !!(pix[0] & bit) * 2 + !!(pix[2] & bit); + if (!root->kids[i]) + root->kids[i] = node_new(i, depth, root); + + root = root->kids[i]; + } + + root->r += pix[0]; + root->g += pix[1]; + root->b += pix[2]; + root->count++; + return root; +} + +/* remove a node in octree and add its count and colors to parent node. */ +oct_node node_fold(oct_node p) +{ + if (p->n_kids) abort(); + oct_node q = p->parent; + q->count += p->count; + + q->r += p->r; + q->g += p->g; + q->b += p->b; + q->n_kids --; + q->kids[p->kid_idx] = 0; + return q; +} + +/* traverse the octree just like construction, but this time we replace the pixel + color with color stored in the tree node */ +void color_replace(oct_node root, unsigned char *pix) +{ + unsigned char i, bit; + + for (bit = 1 << 7; bit; bit >>= 1) { + i = !!(pix[1] & bit) * 4 + !!(pix[0] & bit) * 2 + !!(pix[2] & bit); + if (!root->kids[i]) break; + root = root->kids[i]; + } + + pix[0] = root->r; + pix[1] = root->g; + pix[2] = root->b; +} + +/* Building an octree and keep leaf nodes in a bin heap. Afterwards remove first node + in heap and fold it into its parent node (which may now be added to heap), until heap + contains required number of colors. */ +void color_quant(image im, int n_colors) +{ + int i; + unsigned char *pix = im->pix; + node_heap heap = { 0, 0, 0 }; + + oct_node root = node_new(0, 0, 0), got; + for (i = 0; i < im->w * im->h; i++, pix += 3) + heap_add(&heap, node_insert(root, pix)); + + while (heap.n > n_colors + 1) + heap_add(&heap, node_fold(pop_heap(&heap))); + + double c; + for (i = 1; i < heap.n; i++) { + got = heap.buf[i]; + c = got->count; + got->r = got->r / c + .5; + got->g = got->g / c + .5; + got->b = got->b / c + .5; + printf("%2d | %3llu %3llu %3llu (%d pixels)\n", + i, got->r, got->g, got->b, got->count); + } + + for (i = 0, pix = im->pix; i < im->w * im->h; i++, pix += 3) + color_replace(root, pix); + + node_free(); + free(heap.buf); +} diff --git a/Task/Color-quantization/D/color-quantization.d b/Task/Color-quantization/D/color-quantization.d new file mode 100644 index 0000000000..1b59bcc340 --- /dev/null +++ b/Task/Color-quantization/D/color-quantization.d @@ -0,0 +1,165 @@ +import core.stdc.stdio, std.stdio, std.ascii, std.algorithm, std.math, + std.typecons, std.range, std.conv, std.string, bitmap; + +struct Col { float r, g, b; } +alias Tuple!(Col, float, Col, Col[]) Cluster; +enum Axis { R, G, B } + +int round(in float x) /*pure*/ nothrow { + return cast(int)floor(x + 0.5); // Not pure. +} + +RGB roundRGB(in Col c) /*pure*/ nothrow { + return RGB(cast(ubyte)round(c.r), // Not pure. + cast(ubyte)round(c.g), + cast(ubyte)round(c.b)); +} + +Col meanRGB(Col[] pxList) pure nothrow { + static Col addRGB(in Col c1, in Col c2) pure nothrow { + return Col(c1.r + c2.r, c1.g + c2.g, c1.b + c2.b); + } + immutable Col tot = reduce!addRGB(Col(0,0,0), pxList); + immutable int n = pxList.walkLength(); + return Col(tot.r / n, tot.g / n, tot.b / n); +} + +Tuple!(Col, Col) extrems(/*in*/ Col[] lst) pure nothrow { + immutable minRGB = Col(float.infinity, + float.infinity, + float.infinity); + immutable maxRGB = Col(-float.infinity, + -float.infinity, + -float.infinity); + static Col f1(in Col c1, in Col c2) pure nothrow { + return Col(min(c1.r, c2.r), min(c1.g, c2.g), min(c1.b, c2.b)); + } + static Col f2(in Col c1, in Col c2) pure nothrow { + return Col(max(c1.r, c2.r), max(c1.g, c2.g), max(c1.b, c2.b)); + } + return typeof(return)(reduce!f1(minRGB, lst), + reduce!f2(maxRGB, lst)); +} + +Tuple!(float, Col) volumeAndDims(/*in*/ Col[] lst) pure nothrow { + immutable e = extrems(lst); + immutable Col r = Col(e[1].r - e[0].r, + e[1].g - e[0].g, + e[1].b - e[0].b); + return typeof(return)(r.r * r.g * r.b, r); +} + +Cluster makeCluster(Col[] pixel_list) pure nothrow { + immutable vol_dims = volumeAndDims(pixel_list); + immutable int len = pixel_list.length; + return Cluster(meanRGB(pixel_list), + len * vol_dims[0], + vol_dims[1], + pixel_list); +} + +Axis largestAxis(in Col c) pure nothrow { + static int fcmp(in float a, in float b) pure nothrow { + return (a > b) ? 1 : (a < b ? -1 : 0); + } + immutable int r1 = fcmp(c.r, c.g); + immutable int r2 = fcmp(c.r, c.b); + if (r1 == 1 && r2 == 1) return Axis.R; + if (r1 == -1 && r2 == 1) return Axis.G; + if (r1 == 1 && r2 == -1) return Axis.B; + return (fcmp(c.g, c.b) == 1) ? Axis.G : Axis.B; +} + +Tuple!(Cluster, Cluster) subdivide(in Col c, in float nVolProd, + in Col vol, Col[] pixels) +/*pure*/ nothrow { + bool delegate(immutable Col c) /*pure*/ nothrow partFunc; + final switch (largestAxis(vol)) { + case Axis.R: partFunc = c1 => c1.r < c.r; break; + case Axis.G: partFunc = c1 => c1.g < c.g; break; + case Axis.B: partFunc = c1 => c1.b < c.b; break; + } + Col[] px2 = pixels.partition!partFunc; // Not pure. + Col[] px1 = pixels[0 .. $ - px2.length]; + return typeof(return)(makeCluster(px1), makeCluster(px2)); +} + +Image!RGB colorQuantize(in Image!RGB img, in int n) +/*pure*/ nothrow { + immutable int width = img.nx; + immutable int height = img.ny; + + auto cols = new Col[width * height]; + foreach (immutable i, ref c; img.image) + cols[i] = Col(c.r, c.g, c.b); + Cluster[] clusters = [makeCluster(cols)]; + + immutable Col dumb = Col(0.0, 0.0, 0.0); + Cluster unused = Cluster(dumb, + -float.infinity, + dumb, (Col[]).init); + + while (clusters.length < n) { + Cluster cl = reduce!((c1,c2) => c1[1] > c2[1] ? c1 : c2) + (unused, clusters); + clusters = [subdivide(cl.tupleof).tupleof] ~ + remove!(c => c == cl, SwapStrategy.unstable)(clusters); + } + + static uint RGB2uint(in RGB c) pure nothrow { + uint r; + r |= c.r; + r |= c.g << 8; + r |= c.b << 16; + return r; + } + + uint[uint] pixMap; // faster than RGB[RGB] + ubyte[4] u4a, u4b; + foreach (const cluster; clusters) { + immutable ubyteMean = RGB2uint(roundRGB(cluster[0])); + foreach (immutable col; cluster[3]) + pixMap[RGB2uint(roundRGB(col))] = ubyteMean; + } + + auto result = new Image!RGB; + result.allocate(height, width); + + static RGB uintToRGB(in uint c) pure nothrow { + return RGB( c & 0xFF, + (c >> 8) & 0xFF, + (c >> 16) & 0xFF); + } + + foreach (immutable i; 0 .. height * width) { + immutable u3a = RGB(img.image[i].r, + img.image[i].g, + img.image[i].b); + result.image[i] = uintToRGB(pixMap[RGB2uint(u3a)]); + } + + return result; +} + +void main(in string[] args) { + string fileName; + int nCols; + switch (args.length) { + case 1: + fileName = "quantum_frog.ppm"; + nCols = 16; + break; + case 3: + fileName = args[1]; + nCols = to!int(args[2]); + break; + default: + writeln("Usage: color_quantization image.ppm ncolors"); + return; + } + + auto im = new Image!RGB; + im.loadPPM6(fileName); + const imq = colorQuantize(im, nCols); + imq.savePPM6("quantum_frog_quantized.ppm"); +} diff --git a/Task/Color-quantization/Racket/color-quantization.rkt b/Task/Color-quantization/Racket/color-quantization.rkt new file mode 100644 index 0000000000..4c72a75d98 --- /dev/null +++ b/Task/Color-quantization/Racket/color-quantization.rkt @@ -0,0 +1,326 @@ +#lang racket/base +(require racket/class + racket/draw) + +;; This is an implementation of the Octree Quantization algorithm. This implementation +;; follows the sketch in: +;; +;; Dean Clark. Color Quantization using Octrees. Dr. Dobbs Portal, January 1, 1996. +;; http://www.ddj.com/184409805 +;; +;; This code is adapted from the color quantizer in the implementation of Racket's +;; file/gif standard library. + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;; To view an example of the quantizer, run the following test submodule +;; in DrRacket: +(module+ test + (require racket/block net/url) + + (define frog + (block + (define url (string->url "http://rosettacode.org/mw/images/3/3f/Quantum_frog.png")) + (define frog-ip (get-pure-port url)) + (define bitmap (make-object bitmap% frog-ip)) + (close-input-port frog-ip) + bitmap)) + + ;; Display the original: + (print frog) + ;; And the quantized version (16 colors): + (print (quantize-bitmap frog 16))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;; quantize-bitmap: bitmap positive-number -> bitmap +;; Given a bitmap, returns a new bitmap quantized to, at most, n colors. +(define (quantize-bitmap bm n) + (let* ([width (send bm get-width)] + [height (send bm get-height)] + [len (* width height 4)] + [source-buffer (make-bytes len)] + [_ (send bm get-argb-pixels 0 0 width height source-buffer)] + [an-octree (make-octree-from-argb source-buffer n)] + [dest-buffer (make-bytes len)]) + (let quantize-bitmap-loop ([i 0]) + (when (< i len) + (let* ([i+1 (+ i 1)] + [i+2 (+ i 2)] + [i+3 (+ i 3)] + [a (bytes-ref source-buffer i)] + [r (bytes-ref source-buffer i+1)] + [g (bytes-ref source-buffer i+2)] + [b (bytes-ref source-buffer i+3)]) + (cond + [(alpha-opaque? a) + (let-values ([(new-r new-g new-b) + (octree-lookup an-octree r g b)]) + (bytes-set! dest-buffer i 255) + (bytes-set! dest-buffer i+1 new-r) + (bytes-set! dest-buffer i+2 new-g) + (bytes-set! dest-buffer i+3 new-b))] + [else + (bytes-set! dest-buffer i 0) + (bytes-set! dest-buffer i+1 0) + (bytes-set! dest-buffer i+2 0) + (bytes-set! dest-buffer i+3 0)])) + (quantize-bitmap-loop (+ i 4)))) + (let* ([new-bm (make-object bitmap% width height)] + [dc (make-object bitmap-dc% new-bm)]) + (send dc set-argb-pixels 0 0 width height dest-buffer) + (send dc set-bitmap #f) + new-bm))) + + + + + +;; make-octree-from-argb: bytes positive-number -> octree +;; Constructs an octree ready to quantize the colors from an-argb. +(define (make-octree-from-argb an-argb n) + (unless (> n 0) + (raise-type-error 'make-octree-from-argb "positive number" n)) + (let ([an-octree (new-octree)] + [len (bytes-length an-argb)]) + (let make-octree-loop ([i 0]) + (when (< i len) + (let ([a (bytes-ref an-argb i)] + [r (bytes-ref an-argb (+ i 1))] + [g (bytes-ref an-argb (+ i 2))] + [b (bytes-ref an-argb (+ i 3))]) + (when (alpha-opaque? a) + (octree-insert-color! an-octree r g b) + (let reduction-loop () + (when (> (octree-leaf-count an-octree) n) + (octree-reduce! an-octree) + (reduction-loop))))) + (make-octree-loop (+ i 4)))) + (octree-finalize! an-octree) + an-octree)) + + +;; alpha-opaque? byte -> boolean +;; Returns true if the alpha value is considered opaque. +(define (alpha-opaque? a) + (>= a 128)) + + + +;; The maximum level height of an octree. +(define MAX-LEVEL 7) + + + +;; A color is a (vector byte byte byte) + +;; An octree is a: +(define-struct octree (root ; node + leaf-count ; number + reduction-heads ; (vectorof (or/c node #f)) + palette) ; (vectorof (or/c color #f)) + #:mutable) +;; reduction-heads is used to accelerate the search for a reduction candidate. + + +;; A subtree node is a: +(define-struct node (leaf? ; bool + npixels ; number -- number of pixels this subtree node represents + redsum ; number + greensum ; number + bluesum ; number + children ; (vectorof (or/c #f node)) + next ; (or/c #f node) + palette-index) ; (or/c #f byte?) + #:mutable) +;; node-next is used to accelerate the search for a reduction candidate. + + +;; new-octree: -> octree +(define (new-octree) + (let* ([root-node (make-node #f ;; not a leaf + 0 ;; no pixels under us yet + 0 ;; red sum + 0 ;; green sum + 0 ;; blue sum + (make-vector 8 #f) ;; no children so far + #f ;; next + #f ;; palette-index + )] + [an-octree + (make-octree root-node + 0 ; no leaves so far + (make-vector (add1 MAX-LEVEL) #f) ; no reductions so far + (make-vector 256 #(0 0 0)))]) ; the palette + ;; Although we'll almost never reduce to this level, initialize the first + ;; reducible node to the root, for completeness sake. + (vector-set! (octree-reduction-heads an-octree) 0 root-node) + an-octree)) + + +;; rgb->index: natural-number byte byte byte -> octet +;; Given a level and an (r,g,b) triplet, returns an octet that can be used +;; as an index into our octree structure. +(define (rgb->index level r g b) + (bitwise-ior (bitwise-and 4 (arithmetic-shift r (- level 5))) + (bitwise-and 2 (arithmetic-shift g (- level 6))) + (bitwise-and 1 (arithmetic-shift b (- level 7))))) + + +;; octree-insert-color!: octree byte byte byte -> void +;; Accumulates a new r,g,b triplet into the octree. +(define (octree-insert-color! an-octree r g b) + (node-insert-color! (octree-root an-octree) an-octree r g b 0)) + + +;; node-insert-color!: node octree byte byte byte natural-number -> void +;; Adds a color to the node subtree. While we hit #f, we create new nodes. +;; If we hit an existing leaf, we accumulate our color into it. +(define (node-insert-color! a-node an-octree r g b level) + (let insert-color-loop ([a-node a-node] + [level level]) + (cond [(node-leaf? a-node) + ;; update the leaf with the new color + (set-node-npixels! a-node (add1 (node-npixels a-node))) + (set-node-redsum! a-node (+ (node-redsum a-node) r)) + (set-node-greensum! a-node (+ (node-greensum a-node) g)) + (set-node-bluesum! a-node (+ (node-bluesum a-node) b))] + [else + ;; create the child node if necessary + (let ([index (rgb->index level r g b)]) + (unless (vector-ref (node-children a-node) index) + (let ([new-node (make-node (= level MAX-LEVEL) ; leaf? + 0 ; npixels + 0 ; redsum + 0 ; greensum + 0 ; bluesum + (make-vector 8 #f) ; no children yet + #f ; and no next node yet + #f ; or palette index + )]) + (vector-set! (node-children a-node) index new-node) + (cond + [(= level MAX-LEVEL) + ;; If we added a leaf, mark it in the octree. + (set-octree-leaf-count! an-octree + (add1 (octree-leaf-count an-octree)))] + [else + ;; Attach the node as a reducible node if it's interior. + (set-node-next! + new-node (vector-ref (octree-reduction-heads an-octree) + (add1 level))) + (vector-set! (octree-reduction-heads an-octree) + (add1 level) + new-node)]))) + ;; and recur on the child node. + (insert-color-loop (vector-ref (node-children a-node) index) + (add1 level)))]))) + + +;; octree-reduce!: octree -> void +;; Reduces one of the subtrees, collapsing the children into a single node. +(define (octree-reduce! an-octree) + (node-reduce! (pop-reduction-candidate! an-octree) an-octree)) + + +;; node-reduce!: node octree -> void +;; Reduces the interior node. +(define (node-reduce! a-node an-octree) + (for ([child (in-vector (node-children a-node))] + #:when child) + (set-node-npixels! a-node (+ (node-npixels a-node) + (node-npixels child))) + (set-node-redsum! a-node (+ (node-redsum a-node) + (node-redsum child))) + (set-node-greensum! a-node (+ (node-greensum a-node) + (node-greensum child))) + (set-node-bluesum! a-node (+ (node-bluesum a-node) + (node-bluesum child))) + (set-octree-leaf-count! an-octree (sub1 (octree-leaf-count an-octree)))) + (set-node-leaf?! a-node #t) + (set-octree-leaf-count! an-octree (add1 (octree-leaf-count an-octree)))) + + +;; find-reduction-candidate!: octree -> node +;; Returns a bottom-level interior node for reduction. Also takes the +;; candidate out of the conceptual queue of reduction candidates. +(define (pop-reduction-candidate! an-octree) + (let loop ([i MAX-LEVEL]) + (cond + [(vector-ref (octree-reduction-heads an-octree) i) + => + (lambda (candidate-node) + (when (> i 0) + (vector-set! (octree-reduction-heads an-octree) i + (node-next candidate-node))) + candidate-node)] + [else + (loop (sub1 i))]))) + + +;; octree-finalize!: octree -> void +;; Finalization does a few things: +;; * Walks through the octree and reduces any interior nodes with just one leaf child. +;; Optimizes future lookups. +;; * Fills in the palette of the octree and the palette indexes of the leaf nodes. +;; * Note: palette index 0 is always reserved for the transparent color. +(define (octree-finalize! an-octree) + ;; Collapse one-leaf interior nodes. + (let loop ([a-node (octree-root an-octree)]) + (for ([child (in-vector (node-children a-node))] + #:when (and child (not (node-leaf? child)))) + (loop child) + (when (interior-node-one-leaf-child? a-node) + (node-reduce! a-node an-octree)))) + + ;; Attach palette entries. + (let ([current-palette-index 1]) + (let loop ([a-node (octree-root an-octree)]) + (cond [(node-leaf? a-node) + (let ([n (node-npixels a-node)]) + (vector-set! (octree-palette an-octree) current-palette-index + (vector (quotient (node-redsum a-node) n) + (quotient (node-greensum a-node) n) + (quotient (node-bluesum a-node) n))) + (set-node-palette-index! a-node current-palette-index) + (set! current-palette-index (add1 current-palette-index)))] + [else + (for ([child (in-vector (node-children a-node))] + #:when child) + (loop child))])))) + + +;; interior-node-one-leaf-child?: node -> boolean +(define (interior-node-one-leaf-child? a-node) + (let ([child-list (filter values (vector->list (node-children a-node)))]) + (and (= (length child-list) 1) + (node-leaf? (car child-list))))) + + +;; octree-lookup: octree byte byte byte -> (values byte byte byte) +;; Returns the palettized color. +(define (octree-lookup an-octree r g b) + (let* ([index (node-lookup-index (octree-root an-octree) an-octree r g b 0)] + [vec (vector-ref (octree-palette an-octree) index)]) + (values (vector-ref vec 0) + (vector-ref vec 1) + (vector-ref vec 2)))) + + + +;; node-lookup-index: node byte byte byte natural-number -> byte +;; Returns the palettized color index. +(define (node-lookup-index a-node an-octree r g b level) + (let loop ([a-node a-node] + [level level]) + (if (node-leaf? a-node) + (node-palette-index a-node) + (let ([child (vector-ref (node-children a-node) (rgb->index level r g b))]) + (unless child + (error 'node-lookup-index + "color (~a, ~a, ~a) not previously inserted" + r g b)) + (loop child (add1 level)))))) diff --git a/Task/Color-quantization/Tcl/color-quantization-1.tcl b/Task/Color-quantization/Tcl/color-quantization-1.tcl new file mode 100644 index 0000000000..a3a0ed3fc0 --- /dev/null +++ b/Task/Color-quantization/Tcl/color-quantization-1.tcl @@ -0,0 +1,78 @@ +package require Tcl 8.6 +package require Tk + +proc makeCluster {pixels} { + set rmin [set rmax [lindex $pixels 0 0]] + set gmin [set gmax [lindex $pixels 0 1]] + set bmin [set bmax [lindex $pixels 0 2]] + set rsum [set gsum [set bsum 0]] + foreach p $pixels { + lassign $p r g b + if {$r<$rmin} {set rmin $r} elseif {$r>$rmax} {set rmax $r} + if {$g<$gmin} {set gmin $g} elseif {$g>$gmax} {set gmax $g} + if {$b<$bmin} {set bmin $b} elseif {$b>$bmax} {set bmax $b} + incr rsum $r + incr gsum $g + incr bsum $b + } + set n [llength $pixels] + list [expr {double($n)*($rmax-$rmin)*($gmax-$gmin)*($bmax-$bmin)}] \ + [list [expr {$rsum/$n}] [expr {$gsum/$n}] [expr {$bsum/$n}]] \ + [list [expr {$rmax-$rmin}] [expr {$gmax-$gmin}] [expr {$bmax-$bmin}]] \ + $pixels +} + +proc colorQuant {img n} { + set width [image width $img] + set height [image height $img] + # Extract the pixels from the image + for {set x 0} {$x < $width} {incr x} { + for {set y 0} {$y < $height} {incr y} { + lappend pixels [$img get $x $y] + } + } + # Divide pixels into clusters + for {set cs [list [makeCluster $pixels]]} {[llength $cs] < $n} {} { + set cs [lsort -real -index 0 $cs] + lassign [lindex $cs end] score centroid volume pixels + lassign $centroid cr cg cb + lassign $volume vr vg vb + while 1 { + set p1 [set p2 {}] + if {$vr>$vg && $vr>$vb} { + foreach p $pixels { + if {[lindex $p 0]<$cr} {lappend p1 $p} {lappend p2 $p} + } + } elseif {$vg>$vb} { + foreach p $pixels { + if {[lindex $p 1]<$cg} {lappend p1 $p} {lappend p2 $p} + } + } else { + foreach p $pixels { + if {[lindex $p 2]<$cb} {lappend p1 $p} {lappend p2 $p} + } + } + if {[llength $p1] && [llength $p2]} break + # Partition failed! Perturb partition point away from the centroid and try again + set cr [expr {$cr + 20*rand() - 10}] + set cg [expr {$cg + 20*rand() - 10}] + set cb [expr {$cb + 20*rand() - 10}] + } + set cs [lreplace $cs end end [makeCluster $p1] [makeCluster $p2]] + } + # Produce map from pixel values to quantized values + foreach c $cs { + set centroid [format "#%02x%02x%02x" {*}[lindex $c 1]] + foreach p [lindex $c end] { + set map($p) $centroid + } + } + # Remap the source image + set newimg [image create photo -width $width -height $height] + for {set x 0} {$x < $width} {incr x} { + for {set y 0} {$y < $height} {incr y} { + $newimg put $map([$img get $x $y]) -to $x $y + } + } + return $newimg +} diff --git a/Task/Color-quantization/Tcl/color-quantization-2.tcl b/Task/Color-quantization/Tcl/color-quantization-2.tcl new file mode 100644 index 0000000000..f0a2d390ca --- /dev/null +++ b/Task/Color-quantization/Tcl/color-quantization-2.tcl @@ -0,0 +1,5 @@ +set src [image create photo -file quantum_frog.png] +set dst [colorQuant $src 16] +# Save as GIF now that quantization is done, then exit explicitly (no GUI desired) +$dst write quantum_frog_compressed.gif +exit diff --git a/Task/Colour-bars-Display/0DESCRIPTION b/Task/Colour-bars-Display/0DESCRIPTION new file mode 100644 index 0000000000..55cd61d5ab --- /dev/null +++ b/Task/Colour-bars-Display/0DESCRIPTION @@ -0,0 +1 @@ +The task is to display a series of vertical color bars across the width of the display. The color bars should either use the system palette, or the sequence of colors: Black, Red, Green, Blue, Magenta, Cyan, Yellow, White. diff --git a/Task/Colour-bars-Display/AutoHotkey/colour-bars-display.ahk b/Task/Colour-bars-Display/AutoHotkey/colour-bars-display.ahk new file mode 100644 index 0000000000..2e9d5b44c2 --- /dev/null +++ b/Task/Colour-bars-Display/AutoHotkey/colour-bars-display.ahk @@ -0,0 +1,93 @@ +#SingleInstance, Force +#NoEnv +SetBatchLines, -1 + +; Uncomment if Gdip.ahk is not in your standard library +;#Include, Gdip.ahk + +; Start gdi+ +If !pToken := Gdip_Startup() +{ + message = + ( LTrim + gdiplus error!, Gdiplus failed to start. + Please ensure you have gdiplus on your system. + ) + MsgBox, 48, %message% + ExitApp +} +OnExit, Exit + +; Set the width and height we want as our drawing area, to draw everything in. +; This will be the dimensions of our bitmap +Width := A_ScreenWidth, Height := A_ScreenHeight + +; Create a layered window +; (+E0x80000 : must be used for UpdateLayeredWindow to work!) +; that is always on top (+AlwaysOnTop), has no taskbar entry or caption +Gui, 1: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop + +; Show the window +Gui, 1: Show, NA + +; Get a handle to this window we have created in order to update it later +hwnd1 := WinExist() + +; Create a gdi bitmap with width and height of what we are going to +; draw into it. This is the entire drawing area for everything +hbm := CreateDIBSection(Width, Height) + +; Get a device context compatible with the screen +hdc := CreateCompatibleDC() + +; Select the bitmap into the device context +obm := SelectObject(hdc, hbm) + +; Get a pointer to the graphics of the bitmap, for use with drawing functions +G := Gdip_GraphicsFromHDC(hdc) + +; ARGB = Transparency, Red, Green, Blue +Colors := "0xFF000000,0xFFFF0000,0xFF00FF00,0xFF0000FF" +Colors .= ",0xFFFF00FF,0xFF00FFFF,0xFFFFFF00,0xFFFFFFFF" +; This list ^ is Black, Red, Green, Blue, Magenta, Cyan, Yellow, White +StringSplit Colors, Colors, `, +w := Width // Colors0 +Loop % Colors0 +{ + ; Create a brush to draw a rectangle + pBrush := Gdip_BrushCreateSolid(Colors%A_Index%) + + ; Fill the graphics of the bitmap with a rectangle using the brush created + Gdip_FillRectangle(G, pBrush, w*(A_Index-1), 0, w, height) + + ; Delete the brush as it is no longer needed and wastes memory + Gdip_DeleteBrush(pBrush) +} +; Update the specified window we have created (hwnd1) with a handle to our +; bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen +; So this will position our gui at (0,0) with the Width and +; Height specified earlier +UpdateLayeredWindow(hwnd1, hdc, 0, 0, Width, Height) + + +; Select the object back into the hdc +SelectObject(hdc, obm) + +; Now the bitmap may be deleted +DeleteObject(hbm) + +; Also the device context related to the bitmap may be deleted +DeleteDC(hdc) + +; The graphics may now be deleted +Gdip_DeleteGraphics(G) +Return + +;####################################################################### + +GuiEscape: +Exit: +; gdi+ may now be shutdown on exiting the program +Gdip_Shutdown(pToken) +ExitApp +Return diff --git a/Task/Colour-bars-Display/BBC-BASIC/colour-bars-display.bbc b/Task/Colour-bars-Display/BBC-BASIC/colour-bars-display.bbc new file mode 100644 index 0000000000..41071ffd28 --- /dev/null +++ b/Task/Colour-bars-Display/BBC-BASIC/colour-bars-display.bbc @@ -0,0 +1,19 @@ + SW_MAXIMIZE = 3 + SYS "ShowWindow", @hwnd%, SW_MAXIMIZE + VDU 26 + + W% = @vdu%!208 / 4 + H% = @vdu%!212 * 2 + + COLOUR 1,9 + COLOUR 2,10 + COLOUR 3,12 + COLOUR 4,13 + COLOUR 5,14 + COLOUR 6,11 + COLOUR 7,15 + + FOR C% = 0 TO 7 + GCOL C% + RECTANGLE FILL C%*W%, 0, W%, H% + NEXT diff --git a/Task/Colour-bars-Display/C++/colour-bars-display-1.cpp b/Task/Colour-bars-Display/C++/colour-bars-display-1.cpp new file mode 100644 index 0000000000..73017aca15 --- /dev/null +++ b/Task/Colour-bars-Display/C++/colour-bars-display-1.cpp @@ -0,0 +1,18 @@ +#ifndef MYWIDGET_H +#define MYWIDGET_H +#include + +class QPaintEvent ; + +class MyWidget : public QWidget { +public : + MyWidget( ) ; + +protected : + void paintEvent( QPaintEvent * ) ; +private : + int width ; + int height ; + const int colornumber ; +} ; +#endif diff --git a/Task/Colour-bars-Display/C++/colour-bars-display-2.cpp b/Task/Colour-bars-Display/C++/colour-bars-display-2.cpp new file mode 100644 index 0000000000..184cbce048 --- /dev/null +++ b/Task/Colour-bars-Display/C++/colour-bars-display-2.cpp @@ -0,0 +1,27 @@ +#include +#include "colorbars.h" + +MyWidget::MyWidget( ) : + width( 640 ) , + height( 240 ) , + colornumber( 8 ) { + setGeometry( 0, 0 , width , height ) ; +} + +void MyWidget::paintEvent ( QPaintEvent * ) { + int rgbtriplets[ ] = { 0 , 0 , 0 , 255 , 0 , 0 , 0 , 255 , 0 , + 0 , 0 , 255 , 255 , 0 , 255 , 0 , 255 , 255 , 255 , 255 , 0 , + 255 , 255 , 255 } ; + QPainter myPaint( this ) ; + int rectwidth = width / colornumber ; //width of one rectangle + int xstart = 1 ; //x coordinate of the first rectangle + int offset = -1 ; //to allow for ++offset to define the red value even in the first run of the loop below + for ( int i = 0 ; i < colornumber ; i++ ) { + QColor rectColor ; + rectColor.setRed( rgbtriplets[ ++offset ] ) ; + rectColor.setGreen( rgbtriplets[ ++offset ] ) ; + rectColor.setBlue( rgbtriplets[ ++offset ] ) ; + myPaint.fillRect( xstart , 0 , rectwidth , height - 1 , rectColor ) ; + xstart += rectwidth + 1 ; + } +} diff --git a/Task/Colour-bars-Display/C++/colour-bars-display-3.cpp b/Task/Colour-bars-Display/C++/colour-bars-display-3.cpp new file mode 100644 index 0000000000..a96b1ce1c3 --- /dev/null +++ b/Task/Colour-bars-Display/C++/colour-bars-display-3.cpp @@ -0,0 +1,10 @@ +#include +#include "colorbars.h" + +int main( int argc, char * argv[ ] ) { + QApplication app( argc , argv ) ; + MyWidget window ; + window.setWindowTitle( QApplication::translate( "colorslides" , "color slides demonstration" ) ) ; + window.show( ) ; + return app.exec( ) ; +} diff --git a/Task/Colour-bars-Display/Java/colour-bars-display.java b/Task/Colour-bars-Display/Java/colour-bars-display.java new file mode 100644 index 0000000000..9b3cdc43a6 --- /dev/null +++ b/Task/Colour-bars-Display/Java/colour-bars-display.java @@ -0,0 +1,28 @@ +import java.awt.Color; +import java.awt.Graphics; + +import javax.swing.JFrame; + +public class ColorFrame extends JFrame { + public ColorFrame(int width, int height) { + this.setDefaultCloseOperation(EXIT_ON_CLOSE); + this.setSize(width, height); + this.setVisible(true); + } + + @Override + public void paint(Graphics g) { + Color[] colors = { Color.black, Color.red, Color.green, Color.blue, + Color.pink, Color.CYAN, Color.yellow, Color.white }; + + for (int i = 0; i < colors.length; i++) { + g.setColor(colors[i]); + g.fillRect(this.getWidth() / colors.length * i, 0, this.getWidth() + / colors.length, this.getHeight()); + } + } + + public static void main(String args[]) { + new ColorFrame(200, 200); + } +} diff --git a/Task/Colour-bars-Display/PHP/colour-bars-display.php b/Task/Colour-bars-Display/PHP/colour-bars-display.php new file mode 100644 index 0000000000..c21aa2e734 --- /dev/null +++ b/Task/Colour-bars-Display/PHP/colour-bars-display.php @@ -0,0 +1,25 @@ + $color) { + $color = imagecolorallocate($image, $color[0], $color[1], $color[2]); + imagefilledrectangle($image, $position * BARWIDTH, 0, + $position * BARWIDTH + BARWIDTH - 1, + HEIGHT - 1, $color); +} + +header('Content-type:image/png'); +imagepng($image); +imagedestroy($image); diff --git a/Task/Colour-bars-Display/Perl/colour-bars-display.pl b/Task/Colour-bars-Display/Perl/colour-bars-display.pl new file mode 100644 index 0000000000..bc04b39812 --- /dev/null +++ b/Task/Colour-bars-Display/Perl/colour-bars-display.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl -w +use strict ; +use GD ; + +my %colors = ( white => [ 255 , 255 , 255 ] , red => [255 , 0 , 0 ] , + green => [ 0 , 255 , 0 ] , blue => [ 0 , 0 , 255 ] , + magenta => [ 255 , 0 , 255 ] , yellow => [ 255 , 255 , 0 ] , + cyan => [ 0 , 255 , 255 ] , black => [ 0 , 0 , 0 ] ) ; +my $barwidth = 160 / 8 ; +my $image = new GD::Image( 160 , 100 ) ; +my $start = 0 ; +foreach my $rgb ( values %colors ) { + my $paintcolor = $image->colorAllocate( @$rgb ) ; + $image->filledRectangle( $start * $barwidth , 0 , $start * $barwidth + + $barwidth - 1 , 99 , $paintcolor ) ; + $start++ ; +} +open ( DISPLAY , ">" , "testprogram.png" ) || die ; +binmode DISPLAY ; +print DISPLAY $image->png ; +close DISPLAY ;#to be watched with testprogram.png diff --git a/Task/Colour-bars-Display/PicoLisp/colour-bars-display.l b/Task/Colour-bars-Display/PicoLisp/colour-bars-display.l new file mode 100644 index 0000000000..21014db548 --- /dev/null +++ b/Task/Colour-bars-Display/PicoLisp/colour-bars-display.l @@ -0,0 +1,10 @@ +(call 'clear) + +(let Width (in '(tput cols) (read)) + (do (in '(tput lines) (read)) + (for B (range 0 7) + (call 'tput 'setab B) + (space (/ Width 8)) ) + (prinl) ) ) + +(call 'tput 'sgr0) # reset diff --git a/Task/Colour-bars-Display/Python/colour-bars-display.py b/Task/Colour-bars-Display/Python/colour-bars-display.py new file mode 100644 index 0000000000..7b6c38440e --- /dev/null +++ b/Task/Colour-bars-Display/Python/colour-bars-display.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +#vertical coloured stripes in window in Python 2.7.1 + +from livewires import * + +horiz=640; vert=480 +begin_graphics(width=horiz,height=vert,title="v_stripes",background=Colour.black) +NameColors=["black","red","green","dark_blue","purple","blue","yellow","white"] +stepik=horiz/len(NameColors) + +for index,each in enumerate(NameColors): + ExcStrng="set_colour(Colour."+each+")" + exec ExcStrng + box(index*stepik,0,(index+1)*stepik,vert,filled=1) + +while keys_pressed() != ['x']: # press x key to terminate program + pass + +end_graphics() diff --git a/Task/Colour-bars-Display/R/colour-bars-display.r b/Task/Colour-bars-Display/R/colour-bars-display.r new file mode 100644 index 0000000000..eb20eb80a5 --- /dev/null +++ b/Task/Colour-bars-Display/R/colour-bars-display.r @@ -0,0 +1,3 @@ +pal <- c("black", "red", "green", "blue", "magenta", "cyan", "yellow", "white") +par(mar = rep(0, 4)) +image(matrix(1:8), col = pal, axes = FALSE) diff --git a/Task/Colour-bars-Display/Scala/colour-bars-display-1.scala b/Task/Colour-bars-Display/Scala/colour-bars-display-1.scala new file mode 100644 index 0000000000..74c432ea59 --- /dev/null +++ b/Task/Colour-bars-Display/Scala/colour-bars-display-1.scala @@ -0,0 +1,16 @@ +import java.awt.Color +import scala.swing._ + +class ColorBars extends Component { + override def paintComponent(g:Graphics2D)={ + val colors=List(Color.BLACK, Color.RED, Color.GREEN, Color.BLUE, Color.MAGENTA, Color.CYAN, Color.YELLOW, Color.WHITE) + val colCount=colors.size + val deltaX=size.width.toDouble/colCount + for(x <- 0 until colCount){ + val startX=(deltaX*x).toInt + val endX=(deltaX*(x+1)).toInt + g.setColor(colors(x)) + g.fillRect(startX, 0, endX-startX, size.height) + } + } +} diff --git a/Task/Colour-bars-Display/Scala/colour-bars-display-2.scala b/Task/Colour-bars-Display/Scala/colour-bars-display-2.scala new file mode 100644 index 0000000000..4f3e9f10c1 --- /dev/null +++ b/Task/Colour-bars-Display/Scala/colour-bars-display-2.scala @@ -0,0 +1,6 @@ +new MainFrame(){ + title="Color bars" + visible=true + preferredSize=new Dimension(640, 320) + contents=new ColorBars() +} diff --git a/Task/Colour-bars-Display/Tcl/colour-bars-display-1.tcl b/Task/Colour-bars-Display/Tcl/colour-bars-display-1.tcl new file mode 100644 index 0000000000..a97daa26d3 --- /dev/null +++ b/Task/Colour-bars-Display/Tcl/colour-bars-display-1.tcl @@ -0,0 +1,12 @@ +package require Tcl 8.5 +package require Tk 8.5 + +wm attributes . -fullscreen 1 +pack [canvas .c -highlightthick 0] -fill both -expand 1 +set colors {black red green blue magenta cyan yellow white} + +for {set x 0} {$x < [winfo screenwidth .c]} {incr x 8} { + .c create rectangle $x 0 [expr {$x+7}] [winfo screenheight .c] \ + -fill [lindex $colors 0] -outline {} + set colors [list {*}[lrange $colors 1 end] [lindex $colors 0]] +} diff --git a/Task/Colour-bars-Display/Tcl/colour-bars-display-2.tcl b/Task/Colour-bars-Display/Tcl/colour-bars-display-2.tcl new file mode 100644 index 0000000000..b3d1fd7a9c --- /dev/null +++ b/Task/Colour-bars-Display/Tcl/colour-bars-display-2.tcl @@ -0,0 +1,24 @@ +#!/bin/sh +clear +WIDTH=`tput cols` +HEIGHT=`tput lines` +NUMBARS=8 +BARWIDTH=`expr $WIDTH / $NUMBARS` + +l="1" # Set the line counter to 1 +while [ "$l" -lt $HEIGHT ]; do + b="0" # Bar counter + while [ "$b" -lt $NUMBARS ]; do + tput setab $b + s="0" + while [ "$s" -lt $BARWIDTH ]; do + echo -n " " + s=`expr $s + 1` + done + b=`expr $b + 1` + done + echo # newline + l=`expr $l + 1` +done + +tput sgr0 # reset diff --git a/Task/Colour-pinstripe-Display/0DESCRIPTION b/Task/Colour-pinstripe-Display/0DESCRIPTION new file mode 100644 index 0000000000..d0d69d6bf9 --- /dev/null +++ b/Task/Colour-pinstripe-Display/0DESCRIPTION @@ -0,0 +1,3 @@ +The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display. The pinstripes should either follow the system palette sequence or a sequence that includes Black, Red, Green, Blue, Magenta, Cyan, Yellow, White. + +After filling the top quarter of the display, we switch to a wider 2 pixel wide vertical pinstripe pattern. Halfway down the display we switch to 3 pixel wide vertical pinstripe and then finally to a 4 pixels wide vertical pinstripe for the last quarter of the display. diff --git a/Task/Colour-pinstripe-Display/1META.yaml b/Task/Colour-pinstripe-Display/1META.yaml new file mode 100644 index 0000000000..7268acefb9 --- /dev/null +++ b/Task/Colour-pinstripe-Display/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Test card diff --git a/Task/Colour-pinstripe-Display/AutoHotkey/colour-pinstripe-display.ahk b/Task/Colour-pinstripe-Display/AutoHotkey/colour-pinstripe-display.ahk new file mode 100644 index 0000000000..738412fede --- /dev/null +++ b/Task/Colour-pinstripe-Display/AutoHotkey/colour-pinstripe-display.ahk @@ -0,0 +1,43 @@ +h := A_ScreenHeight +w := A_ScreenWidth +pToken := gdip_Startup() +hdc := CreateCompatibleDC() +hbm := CreateDIBSection(w, h) +obm := SelectObject(hdc, hbm) +G := Gdip_GraphicsFromHDC(hdc) + +OnExit, Exit + +Gui -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop +Gui Show, NA +hwnd := WinExist() + +colors := [0xFF000000, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF + , 0xFFFF00FF, 0xFF00FFFF, 0xFFFFFF00, 0xFFFFFFFF] ; ARGB +pBrush := [] +Loop % colors.MaxIndex() + pBrush[A_Index] := Gdip_BrushCreateSolid(colors[A_Index]) +Loop 4 +{ + n := A_Index + Loop % w + Gdip_FillRectangle(G, pBrush[Mod(A_Index-1, colors.MaxIndex())+1] + , A_Index*n-n, (n-1)*h/4, n, h/4) +} + + +UpdateLayeredWindow(hwnd, hdc, 0, 0, W, H) + +Loop % colors.MaxIndex() + Gdip_DeleteBrush(pBrush[A_Index]) + +SelectObject(hdc, obm) +DeleteObject(hbm) +DeleteDC(hdc) +Gdip_DeleteGraphics(G) +Return + +Esc:: +Exit: +Gdip_Shutdown(pToken) +ExitApp diff --git a/Task/Colour-pinstripe-Display/BBC-BASIC/colour-pinstripe-display.bbc b/Task/Colour-pinstripe-Display/BBC-BASIC/colour-pinstripe-display.bbc new file mode 100644 index 0000000000..f864be3700 --- /dev/null +++ b/Task/Colour-pinstripe-Display/BBC-BASIC/colour-pinstripe-display.bbc @@ -0,0 +1,24 @@ + SW_MAXIMIZE = 3 + SYS "ShowWindow", @hwnd%, SW_MAXIMIZE + VDU 26 + + W% = @vdu%!208 * 2 + H% = @vdu%!212 / 2 + + COLOUR 1,9 + COLOUR 2,10 + COLOUR 3,12 + COLOUR 4,13 + COLOUR 5,14 + COLOUR 6,11 + COLOUR 7,15 + + Y% = H%*4 + FOR P% = 1 TO 4 + Y% -= H% + FOR X% = 0 TO W% STEP 4*P% + C% = (C% + 1) MOD 8 + GCOL C% + RECTANGLE FILL X%, Y%, 2*P%, H% + NEXT + NEXT P% diff --git a/Task/Colour-pinstripe-Display/Perl/colour-pinstripe-display.pl b/Task/Colour-pinstripe-Display/Perl/colour-pinstripe-display.pl new file mode 100644 index 0000000000..360d3dafff --- /dev/null +++ b/Task/Colour-pinstripe-Display/Perl/colour-pinstripe-display.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl -w +use strict ; +use GD ; + +my $image = new GD::Image( 320 , 240 ) ; +my %colors = ( "white" => [ 255 , 255 , 255 ] , "red" => [255 , 0 , 0 ] , + "green" => [ 0 , 255 , 0 ] , "blue" => [ 0 , 0 , 255 ] , + "magenta" => [ 255 , 0 , 255 ] , "yellow" => [ 255 , 255 , 0 ] , + "cyan" => [ 0 , 255 , 255 ] , "black" => [ 0 , 0 , 0 ] ) ; +my @paintcolors ; +foreach my $color ( keys %colors ) { + my $paintcolor = $image->colorAllocate( @{$colors{ $color }} ) ; + push @paintcolors, $paintcolor ; +} +my $startx = 0 ; +my $starty = 0 ; +my $run = 0 ; +my $barheight = 240 / 4 ; +my $colorindex = 0 ; +while ( $run < 4 ) { + my $barwidth = $run + 1 ; + while ( $startx + $barwidth < 320 ) { + $image->filledRectangle( $startx , $starty , $startx + $barwidth , + $starty + $barheight - 1 , $paintcolors[ $colorindex % 8 ] ) ; + $startx += $barwidth ; + $colorindex++ ; + } + $starty += $barheight ; + $startx = 0 ; + $colorindex = 0 ; + $run++ ; + } +open ( DISPLAY , ">" , "pinstripes.png" ) || die ; +binmode DISPLAY ; +print DISPLAY $image->png ; +close DISPLAY ; diff --git a/Task/Colour-pinstripe-Display/PicoLisp/colour-pinstripe-display.l b/Task/Colour-pinstripe-Display/PicoLisp/colour-pinstripe-display.l new file mode 100644 index 0000000000..dfc027cabb --- /dev/null +++ b/Task/Colour-pinstripe-Display/PicoLisp/colour-pinstripe-display.l @@ -0,0 +1,18 @@ +(de *Colors # Black Red Green Blue Magenta Cyan Yellow White + ((0 0 0) (255 0 0) (0 255 0) (0 0 255) + (255 0 255) (0 255 255) (255 255 0) (255 255 255) .) ) + +(let Ppm # Create PPM of 384 x 288 pixels + (make + (for N 4 + (let L + (make + (do (/ 384 N) + (let C (pop *Colors) + (do N (link C)) ) ) ) + (do 72 (link L)) ) ) ) + (out '(display) # Pipe to ImageMagick + (prinl "P6") # NetPBM format + (prinl (length (car Ppm)) " " (length Ppm)) + (prinl 255) + (for Y Ppm (for X Y (apply wr X))) ) ) diff --git a/Task/Colour-pinstripe-Display/Tcl/colour-pinstripe-display.tcl b/Task/Colour-pinstripe-Display/Tcl/colour-pinstripe-display.tcl new file mode 100644 index 0000000000..003b99606f --- /dev/null +++ b/Task/Colour-pinstripe-Display/Tcl/colour-pinstripe-display.tcl @@ -0,0 +1,17 @@ +package require Tcl 8.5 +package require Tk 8.5 + +wm attributes . -fullscreen 1 +pack [canvas .c -highlightthick 0] -fill both -expand 1 +set colors {black red green blue magenta cyan yellow white} + +set dy [expr {[winfo screenheight .c]/4}] +set y 0 +foreach dx {1 2 3 4} { + for {set x 0} {$x < [winfo screenwidth .c]} {incr x $dx} { + .c create rectangle $x $y [expr {$x+$dx}] [expr {$y+$dy}] \ + -fill [lindex $colors 0] -outline {} + set colors [list {*}[lrange $colors 1 end] [lindex $colors 0]] + } + incr y $dy +} diff --git a/Task/Colour-pinstripe-Printer/0DESCRIPTION b/Task/Colour-pinstripe-Printer/0DESCRIPTION new file mode 100644 index 0000000000..7749540aa3 --- /dev/null +++ b/Task/Colour-pinstripe-Printer/0DESCRIPTION @@ -0,0 +1,7 @@ +The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence woud be black, red, green, blue, magenta, cyan, yellow, white. + +After the first inch of printing, we switch to a wider 2 pixel wide vertical pinstripe pattern. and to 3 point wide vertical for the next inch, and then 4 point wide, etc. This trend continues for the entire length of the page (or for 12 inches of run length in the case of a printer using continuous roll stationery). After printing the test pattern the page is ejected (or the test pattern is rolled clear of the printer enclosure, in the case of continuous roll printers). + +Note that it is an acceptable solution to use the smallest marks that the language provides, rather than working at native printer resolution, where this is not achievable from within the language. + +Optionally, on systems where the printer resolution cannot be determined, it is permissible to prompt the user for printer resolution, and to calculate point size based on user input, enabling fractional point sizes to be used. diff --git a/Task/Colour-pinstripe-Printer/1META.yaml b/Task/Colour-pinstripe-Printer/1META.yaml new file mode 100644 index 0000000000..44ab78a9c6 --- /dev/null +++ b/Task/Colour-pinstripe-Printer/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Test card +- Printer diff --git a/Task/Colour-pinstripe-Printer/BBC-BASIC/colour-pinstripe-printer.bbc b/Task/Colour-pinstripe-Printer/BBC-BASIC/colour-pinstripe-printer.bbc new file mode 100644 index 0000000000..ff952bac43 --- /dev/null +++ b/Task/Colour-pinstripe-Printer/BBC-BASIC/colour-pinstripe-printer.bbc @@ -0,0 +1,43 @@ + PD_RETURNDC = 256 + _LOGPIXELSY = 90 + + DIM pd{lStructSize%, hwndOwner%, hDevMode%, hDevNames%, \ + \ hdc%, flags%, nFromPage{l&,h&}, nToPage{l&,h&}, \ + \ nMinPage{l&,h&}, nMaxPage{l&,h&}, nCopies{l&,h&}, \ + \ hInstance%, lCustData%, lpfnPrintHook%, lpfnSetupHook%, \ + \ lpPrintTemplateName%, lpSetupTemplateName%, \ + \ hPrintTemplate%, hSetupTemplate%} + pd.lStructSize% = DIM(pd{}) + pd.hwndOwner% = @hwnd% + pd.flags% = PD_RETURNDC + + SYS "PrintDlg", pd{} TO ok% + IF ok%=0 THEN QUIT + SYS "DeleteDC", @prthdc% + @prthdc% = pd.hdc% + *MARGINS 0,0,0,0 + + dx% = @vdu%!236-@vdu%!232 + dy% = @vdu%!244-@vdu%!240 + SYS "GetDeviceCaps", @prthdc%, _LOGPIXELSY TO dpi% + + DIM rc{l%,t%,r%,b%} + DIM colour%(7) + colour%() = &000000, &0000FF, &00FF00, &FF0000, \ + \ &FF00FF, &FFFF00, &00FFFF, &FFFFFF + + VDU 2,1,32,3 + pitch% = 1 + FOR y% = 0 TO dy% STEP dpi% + col% = 0 + FOR x% = 0 TO dx%-pitch% STEP pitch% + rc.l% = x% : rc.r% = x% + pitch% + rc.t% = y% : rc.b% = y% + dpi% + SYS "CreateSolidBrush", colour%(col% MOD 8) TO brush% + SYS "FillRect", @prthdc%, rc{}, brush% + SYS "DeleteObject", brush% + col% += 1 + NEXT + pitch% += 1 + NEXT y% + VDU 2,1,12,3 diff --git a/Task/Colour-pinstripe-Printer/PicoLisp/colour-pinstripe-printer.l b/Task/Colour-pinstripe-Printer/PicoLisp/colour-pinstripe-printer.l new file mode 100644 index 0000000000..7ed53fe31e --- /dev/null +++ b/Task/Colour-pinstripe-Printer/PicoLisp/colour-pinstripe-printer.l @@ -0,0 +1,25 @@ +(load "@lib/ps.l") + +# Using circular lists for an endless supply of colors +# (black red green blue magenta cyan yellow white) +(setq + Red (0 100 0 0 100 0 100 100 .) + Green (0 0 100 0 0 100 100 100 .) + Blue (0 0 0 100 100 100 0 100 .) ) + +(call 'lpr + (pdf "pinstripes" + (a4) # 595 x 842 dots + (let (I 0 Step 1) + (for X 595 + (color (car Red) (car Green) (car Blue) + (vline X 0 842) ) + (when (= Step (inc 'I)) + (zero I) + (pop 'Red) + (pop 'Green) + (pop 'Blue) ) + (when (=0 (% X 72)) # 1 inch + (zero I) + (inc 'Step) ) ) ) + (page) ) ) diff --git a/Task/Colour-pinstripe-Printer/Tcl/colour-pinstripe-printer.tcl b/Task/Colour-pinstripe-Printer/Tcl/colour-pinstripe-printer.tcl new file mode 100644 index 0000000000..8ec77c83b9 --- /dev/null +++ b/Task/Colour-pinstripe-Printer/Tcl/colour-pinstripe-printer.tcl @@ -0,0 +1,16 @@ +package require Tk +# Allocate a temporary drawing surface +canvas .c +# The cycle of colors we want to use +set colors {black red green blue magenta cyan yellow white} +# Draw the output we want +for {set y 0;set dx 1} {$y < 11*72} {incr y 72;incr dx} { + for {set x 0;set c 0} {$x < 8.5*72} {incr x $dx;incr c} { + .c create rectangle $x $y [expr {$x+$dx+1}] [expr {$y+73}] \ + -fill [lindex $colors [expr {$c%[llength $colors]}]] -outline {} + } +} +# Send postscript to default printer, scaled 1 pixel -> 1 point +exec lp - << [.c postscript -height $y -width $x -pageheight $y -pagewidth $x] +# Explicit exit; no GUI desired +exit diff --git a/Task/Combinations-with-repetitions/0DESCRIPTION b/Task/Combinations-with-repetitions/0DESCRIPTION new file mode 100644 index 0000000000..dac3339d8e --- /dev/null +++ b/Task/Combinations-with-repetitions/0DESCRIPTION @@ -0,0 +1,14 @@ +The set of combinations with repetitions is computed from a set, S (of cardinality n), and a size of resulting selection, k, by reporting the sets of cardinality k where each member of those sets is chosen from S. In the real world, it is about choosing sets where there is a “large” supply of each type of element and where the order of choice does not matter. For example: +:Q: How many ways can a person choose two doughnuts from a store selling three types of doughnut: iced, jam, and plain? (i.e., S is \{\mathrm{iced}, \mathrm{jam}, \mathrm{plain}\}, |S| = 3, and k = 2.) + +:A: 6: {iced, iced}; {iced, jam}; {iced, plain}; {jam, jam}; {jam, plain}; {plain, plain}. + +Note that both the order of items within a pair, and the order of the pairs given in the answer is not significant; the pairs represent multisets. +
Also note that ''doughnut'' can also be spelled ''donut''. + +'''Task description''' +* Write a function/program/routine/.. to generate all the combinations with repetitions of n types of things taken k at a time and use it to ''show'' an answer to the doughnut example above. +* For extra credit, use the function to compute and show ''just the number of ways'' of choosing three doughnuts from a choice of ten types of doughnut. Do not show the individual choices for this part. + +'''References:''' +* [[wp:Combination|k-combination with repetitions]] diff --git a/Task/Combinations-with-repetitions/1META.yaml b/Task/Combinations-with-repetitions/1META.yaml new file mode 100644 index 0000000000..9e130e8a7b --- /dev/null +++ b/Task/Combinations-with-repetitions/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Discrete math diff --git a/Task/Combinations-with-repetitions/Ada/combinations-with-repetitions.ada b/Task/Combinations-with-repetitions/Ada/combinations-with-repetitions.ada new file mode 100644 index 0000000000..92e0d1bdc4 --- /dev/null +++ b/Task/Combinations-with-repetitions/Ada/combinations-with-repetitions.ada @@ -0,0 +1,64 @@ +with Ada.Text_IO; +procedure Combinations is + + generic + type Set is (<>); + function Combinations + (Count : Positive; + Output : Boolean := False) + return Natural; + + function Combinations + (Count : Positive; + Output : Boolean := False) + return Natural + is + package Set_IO is new Ada.Text_IO.Enumeration_IO (Set); + type Set_Array is array (Positive range <>) of Set; + Empty_Array : Set_Array (1 .. 0); + function Recurse_Combinations + (Number : Positive; + First : Set; + Prefix : Set_Array) + return Natural + is + Combination_Count : Natural := 0; + begin + for Next in First .. Set'Last loop + if Number = 1 then + Combination_Count := Combination_Count + 1; + if Output then + for Element in Prefix'Range loop + Set_IO.Put (Prefix (Element)); + Ada.Text_IO.Put ('+'); + end loop; + Set_IO.Put (Next); + Ada.Text_IO.New_Line; + end if; + else + Combination_Count := Combination_Count + + Recurse_Combinations + (Number - 1, + Next, + Prefix & (1 => Next)); + end if; + end loop; + return Combination_Count; + end Recurse_Combinations; + begin + return Recurse_Combinations (Count, Set'First, Empty_Array); + end Combinations; + + type Donuts is (Iced, Jam, Plain); + function Donut_Combinations is new Combinations (Donuts); + + subtype Ten is Positive range 1 .. 10; + function Ten_Combinations is new Combinations (Ten); + + Donut_Count : constant Natural := + Donut_Combinations (Count => 2, Output => True); + Ten_Count : constant Natural := Ten_Combinations (Count => 3); +begin + Ada.Text_IO.Put_Line ("Total Donuts:" & Natural'Image (Donut_Count)); + Ada.Text_IO.Put_Line ("Total Tens:" & Natural'Image (Ten_Count)); +end Combinations; diff --git a/Task/Combinations-with-repetitions/BBC-BASIC/combinations-with-repetitions.bbc b/Task/Combinations-with-repetitions/BBC-BASIC/combinations-with-repetitions.bbc new file mode 100644 index 0000000000..0195092449 --- /dev/null +++ b/Task/Combinations-with-repetitions/BBC-BASIC/combinations-with-repetitions.bbc @@ -0,0 +1,27 @@ + DIM list$(2), chosen%(2) + list$() = "iced", "jam", "plain" + PRINT "Choices of 2 from 3:" + choices% = FNchoose(0, 2, 0, 3, chosen%(), list$()) + PRINT "Total choices = " ; choices% + + PRINT '"Choices of 3 from 10:" + choices% = FNchoose(0, 3, 0, 10, chosen%(), nul$()) + PRINT "Total choices = " ; choices% + END + + DEF FNchoose(n%, l%, p%, m%, g%(), RETURN n$()) + LOCAL i%, c% + IF n% = l% THEN + IF !^n$() THEN + FOR i% = 0 TO n%-1 + PRINT " " n$(g%(i%)) ; + NEXT + PRINT + ENDIF + = 1 + ENDIF + FOR i% = p% TO m%-1 + g%(n%) = i% + c% += FNchoose(n% + 1, l%, i%, m%, g%(), n$()) + NEXT + = c% diff --git a/Task/Combinations-with-repetitions/C/combinations-with-repetitions.c b/Task/Combinations-with-repetitions/C/combinations-with-repetitions.c new file mode 100644 index 0000000000..54ebeceba0 --- /dev/null +++ b/Task/Combinations-with-repetitions/C/combinations-with-repetitions.c @@ -0,0 +1,32 @@ +#include + +const char * donuts[] = { "iced", "jam", "plain", "something completely different" }; +long choose(int * got, int n_chosen, int len, int at, int max_types) +{ + int i; + long count = 0; + if (n_chosen == len) { + if (!got) return 1; + + for (i = 0; i < len; i++) + printf("%s\t", donuts[got[i]]); + printf("\n"); + return 1; + } + + for (i = at; i < max_types; i++) { + if (got) got[n_chosen] = i; + count += choose(got, n_chosen + 1, len, i, max_types); + } + return count; +} + +int main() +{ + int chosen[3]; + choose(chosen, 0, 2, 0, 3); + + printf("\nWere there ten donuts, we'd have had %ld choices of three\n", + choose(0, 0, 3, 0, 10)); + return 0; +} diff --git a/Task/Combinations-with-repetitions/Clojure/combinations-with-repetitions-1.clj b/Task/Combinations-with-repetitions/Clojure/combinations-with-repetitions-1.clj new file mode 100644 index 0000000000..34a0638d73 --- /dev/null +++ b/Task/Combinations-with-repetitions/Clojure/combinations-with-repetitions-1.clj @@ -0,0 +1,6 @@ +(defn combinations [coll k] + (when-let [[x & xs] coll] + (if (= k 1) + (map list coll) + (concat (map (partial cons x) (combinations coll (dec k))) + (combinations xs k))))) diff --git a/Task/Combinations-with-repetitions/Clojure/combinations-with-repetitions-2.clj b/Task/Combinations-with-repetitions/Clojure/combinations-with-repetitions-2.clj new file mode 100644 index 0000000000..d19b60dd2e --- /dev/null +++ b/Task/Combinations-with-repetitions/Clojure/combinations-with-repetitions-2.clj @@ -0,0 +1,2 @@ +user> (combinations '[iced jam plain] 2) +((iced iced) (iced jam) (iced plain) (jam jam) (jam plain) (plain plain)) diff --git a/Task/Combinations-with-repetitions/CoffeeScript/combinations-with-repetitions-1.coffee b/Task/Combinations-with-repetitions/CoffeeScript/combinations-with-repetitions-1.coffee new file mode 100644 index 0000000000..4ba3f5440a --- /dev/null +++ b/Task/Combinations-with-repetitions/CoffeeScript/combinations-with-repetitions-1.coffee @@ -0,0 +1,12 @@ +combos = (arr, k) -> + return [ [] ] if k == 0 + return [] if arr.length == 0 + + combos_with_head = ([arr[0]].concat combo for combo in combos arr, k-1) + combos_sans_head = combos arr[1...], k + combos_with_head.concat combos_sans_head + +arr = ['iced', 'jam', 'plain'] +console.log "valid pairs from #{arr.join ','}:" +console.log combos arr, 2 +console.log "#{combos([1..10], 3).length} ways to order 3 donuts given 10 types" diff --git a/Task/Combinations-with-repetitions/CoffeeScript/combinations-with-repetitions-2.coffee b/Task/Combinations-with-repetitions/CoffeeScript/combinations-with-repetitions-2.coffee new file mode 100644 index 0000000000..ef9701ffe7 --- /dev/null +++ b/Task/Combinations-with-repetitions/CoffeeScript/combinations-with-repetitions-2.coffee @@ -0,0 +1,8 @@ +jam,plain: +[ [ 'iced', 'iced' ], + [ 'iced', 'jam' ], + [ 'iced', 'plain' ], + [ 'jam', 'jam' ], + [ 'jam', 'plain' ], + [ 'plain', 'plain' ] ] +220 ways to order 3 donuts given 10 types diff --git a/Task/Combinations-with-repetitions/D/combinations-with-repetitions.d b/Task/Combinations-with-repetitions/D/combinations-with-repetitions.d new file mode 100644 index 0000000000..3583ca7429 --- /dev/null +++ b/Task/Combinations-with-repetitions/D/combinations-with-repetitions.d @@ -0,0 +1,86 @@ +import std.stdio, std.range; + +const struct CombRep { + immutable uint nt, nc; + private immutable ulong[] combVal; + + this(in uint numType, in uint numChoice) pure nothrow + in { + assert(0 < numType && numType + numChoice <= 64, + "Valid only for nt + nc <= 64 (ulong bit size)"); + } body { + nt = numType; + nc = numChoice; + if (nc == 0) + return; + ulong v = (1UL << (nt - 1)) - 1; + + // Init to smallest number that has nt-1 bit set + // a set bit is metaphored as a _type_ seperator. + immutable limit = v << nc; + + // Limit is the largest nt-1 bit set number that has nc + // zero-bit a zero-bit means a _choice_ between _type_ + // seperators. + while (v <= limit) { + combVal ~= v; + if (v == 0) + break; + // Get next nt-1 bit number. + immutable t = (v | (v - 1)) + 1; + v = t | ((((t & -t) / (v & -v)) >> 1) - 1); + } + } + + uint length() @property const pure nothrow { + return combVal.length; + } + + uint[] opIndex(in uint idx) const pure nothrow { + return val2set(combVal[idx]); + } + + int opApply(immutable int delegate(in ref uint[]) dg) { + foreach (immutable v; combVal) { + auto set = val2set(v); + if (dg(set)) + break; + } + return 1; + } + + private uint[] val2set(in ulong v) const pure nothrow { + // Convert bit pattern to selection set + immutable uint bitLimit = nt + nc - 1; + uint typeIdx = 0; + uint[] set; + foreach (immutable bitNum; 0 .. bitLimit) + if (v & (1 << (bitLimit - bitNum - 1))) + typeIdx++; + else + set ~= typeIdx; + return set; + } +} + +// For finite Random Access Range. +auto combRep(R)(R types, in uint numChoice) /*pure nothrow*/ +if (hasLength!R && isRandomAccessRange!R) { + ElementType!R[][] result; + + foreach (const s; CombRep(types.length, numChoice)) { + ElementType!R[] r; + foreach (immutable i; s) + r ~= types[i]; + result ~= r; + } + + return result; +} + +void main() { + foreach (const e; combRep(["iced", "jam", "plain"], 2)) + writefln("%-(%5s %)", e); + writeln("Ways to select 3 from 10 types is ", + CombRep(10, 3).length); +} diff --git a/Task/Combinations-with-repetitions/Erlang/combinations-with-repetitions-1.erl b/Task/Combinations-with-repetitions/Erlang/combinations-with-repetitions-1.erl new file mode 100644 index 0000000000..8a6ffeb70e --- /dev/null +++ b/Task/Combinations-with-repetitions/Erlang/combinations-with-repetitions-1.erl @@ -0,0 +1,9 @@ +-module(comb). +-compile(export_all). + +comb_rep(0,_) -> + [[]]; +comb_rep(_,[]) -> + []; +comb_rep(N,[H|T]=S) -> + [[H|L] || L <- comb_rep(N-1,S)]++comb_rep(N,T). diff --git a/Task/Combinations-with-repetitions/Erlang/combinations-with-repetitions-2.erl b/Task/Combinations-with-repetitions/Erlang/combinations-with-repetitions-2.erl new file mode 100644 index 0000000000..a6690ae775 --- /dev/null +++ b/Task/Combinations-with-repetitions/Erlang/combinations-with-repetitions-2.erl @@ -0,0 +1,9 @@ +94> comb:comb_rep(2,[iced,jam,plain]). +[[iced,iced], + [iced,jam], + [iced,plain], + [jam,jam], + [jam,plain], + [plain,plain]] +95> length(comb:comb_rep(3,lists:seq(1,10))). +220 diff --git a/Task/Combinations-with-repetitions/Fortran/combinations-with-repetitions.f b/Task/Combinations-with-repetitions/Fortran/combinations-with-repetitions.f new file mode 100644 index 0000000000..9ed18d1bd0 --- /dev/null +++ b/Task/Combinations-with-repetitions/Fortran/combinations-with-repetitions.f @@ -0,0 +1,53 @@ +program main + integer :: chosen(4) + integer :: ssize + + character(len=50) :: donuts(4) = [ "iced", "jam", "plain", "something completely different" ] + + ssize = choose( chosen, 2, 3 ) + write(*,*) "Total = ", ssize + + contains + + recursive function choose( got, len, maxTypes, nChosen, at ) result ( output ) + integer :: got(:) + integer :: len + integer :: maxTypes + integer :: output + integer, optional :: nChosen + integer, optional :: at + + integer :: effNChosen + integer :: effAt + + integer :: i + integer :: counter + + effNChosen = 1 + if( present(nChosen) ) effNChosen = nChosen + + effAt = 1 + if( present(at) ) effAt = at + + if ( effNChosen == len+1 ) then + do i=1,len + write(*,"(A10,5X)", advance='no') donuts( got(i)+1 ) + end do + + write(*,*) "" + + output = 1 + return + end if + + counter = 0 + do i=effAt,maxTypes + got(effNChosen) = i-1 + counter = counter + choose( got, len, maxTypes, effNChosen + 1, i ) + end do + + output = counter + return + end function choose + +end program main diff --git a/Task/Combinations-with-repetitions/Go/combinations-with-repetitions-1.go b/Task/Combinations-with-repetitions/Go/combinations-with-repetitions-1.go new file mode 100644 index 0000000000..0e4ee92da0 --- /dev/null +++ b/Task/Combinations-with-repetitions/Go/combinations-with-repetitions-1.go @@ -0,0 +1,23 @@ +package main + +import "fmt" + +func combrep(n int, lst []string) [][]string { + if n == 0 { + return [][]string{nil} + } + if len(lst) == 0 { + return nil + } + r := combrep(n, lst[1:]) + for _, x := range combrep(n-1, lst) { + r = append(r, append(x, lst[0])) + } + return r +} + +func main() { + fmt.Println(combrep(2, []string{"iced", "jam", "plain"})) + fmt.Println(len(combrep(3, + []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}))) +} diff --git a/Task/Combinations-with-repetitions/Go/combinations-with-repetitions-2.go b/Task/Combinations-with-repetitions/Go/combinations-with-repetitions-2.go new file mode 100644 index 0000000000..8f336467c2 --- /dev/null +++ b/Task/Combinations-with-repetitions/Go/combinations-with-repetitions-2.go @@ -0,0 +1,58 @@ +package main + +import "fmt" + +func picks(picked []int, pos, need int, c chan[]int, do_wait bool) { + if need == 0 { + if do_wait { + c <- picked + <-c + } else { // if we want only the count, there's no need to + // sync between coroutines; let it clobber the array + c <- []int {} + } + return + } + + if pos <= 0 { + if need == len(picked) { c <- nil } + return + } + + picked[len(picked) - need] = pos - 1 + picks(picked, pos, need - 1, c, do_wait) // choose the current donut + picks(picked, pos - 1, need, c, do_wait) // or don't +} + +func main() { + donuts := []string {"iced", "jam", "plain" } + + picked := make([]int, 2) + ch := make(chan []int) + + // true: tell the channel to wait for each sending, because + // otherwise the picked array may get clobbered before we can do + // anything to it + go picks(picked, len(donuts), len(picked), ch, true) + + var cc []int + for { + if cc = <-ch; cc == nil { break } + for _, i := range cc { + fmt.Printf("%s ", donuts[i]) + } + fmt.Println() + ch <- nil // sync + } + + picked = make([]int, 3) + // this time we only want the count, so tell goroutine to keep going + // and work the channel buffer + go picks(picked, 10, len(picked), ch, false) + count := 0 + for { + if cc = <-ch; cc == nil { break } + count++ + } + fmt.Printf("\npicking 3 of 10: %d\n", count) +} diff --git a/Task/Combinations-with-repetitions/Go/combinations-with-repetitions-3.go b/Task/Combinations-with-repetitions/Go/combinations-with-repetitions-3.go new file mode 100644 index 0000000000..18d243368a --- /dev/null +++ b/Task/Combinations-with-repetitions/Go/combinations-with-repetitions-3.go @@ -0,0 +1,102 @@ +package main + +import ( + "fmt" + "sort" + "strconv" +) + +// Go maps are an easy representation for sets as long as the element type +// of the set is valid as a key type for maps. Strings are easy. We follow +// the convention of always storing true for the value. +type set map[string]bool + +// Multisets of strings are easy in the same way. We store the multiplicity +// of the element as the value. +type multiset map[string]int + +// But multisets are not valid as a map key type so we must do something +// more involved to make a set of multisets, which is the desired return +// type for the combrep function required by the task. We can store the +// multiset as the value, but we derive a unique string to use as a key. +type msSet map[string]multiset + +// The key method returns this string. The string will simply be a text +// representation of the contents of the multiset. The standard +// printable representation of the multiset cannot be used however, because +// Go maps are not ordered. Instead, the contents are copied to a slice, +// which is sorted to produce something with a printable representation +// that will compare == for mathematically equal multisets. +// +// Of course there is overhead for this and if performance were important, +// a different representation would be used for multisets, one that didn’t +// require sorting to produce a key... +func (m multiset) key() string { + pl := make(pairList, len(m)) + i := 0 + for k, v := range m { + pl[i] = msPair{k, v} + i++ + } + sort.Sort(pl) + return fmt.Sprintf("%v", pl) +} + +// Types and methods needed for sorting inside of mulitset.key() +type msPair struct { + string + int +} +type pairList []msPair +func (p pairList) Len() int { return len(p) } +func (p pairList) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +func (p pairList) Less(i, j int) bool { return p[i].string < p[j].string } + +// Function required by task. +func combrep(n int, lst set) msSet { + if n == 0 { + var ms multiset + return msSet{ms.key(): ms} + } + if len(lst) == 0 { + return msSet{} + } + var car string + var cdr set + for ele := range lst { + if cdr == nil { + car = ele + cdr = make(set) + } else { + cdr[ele] = true + } + } + r := combrep(n, cdr) + + for _, x := range combrep(n-1, lst) { + c := multiset{car: 1} + for k, v := range x { + c[k] += v + } + r[c.key()] = c + } + return r +} + +// Driver for examples required by task. +func main() { + // Input is a set. + three := set{"iced": true, "jam": true, "plain": true} + // Output is a set of multisets. The set is a Go map: + // The key is a string representation that compares equal + // for equal multisets. We ignore this here. The value + // is the multiset. We print this. + for _, ms := range combrep(2, three) { + fmt.Println(ms) + } + ten := make(set) + for i := 1; i <= 10; i++ { + ten[strconv.Itoa(i)] = true + } + fmt.Println(len(combrep(3, ten))) +} diff --git a/Task/Combinations-with-repetitions/Haskell/combinations-with-repetitions-1.hs b/Task/Combinations-with-repetitions/Haskell/combinations-with-repetitions-1.hs new file mode 100644 index 0000000000..4890ff2cbb --- /dev/null +++ b/Task/Combinations-with-repetitions/Haskell/combinations-with-repetitions-1.hs @@ -0,0 +1,16 @@ +-- Return the combinations, with replacement, of k items from the +-- list. We ignore the case where k is greater than the length of +-- the list. +combsWithRep 0 _ = [[]] +combsWithRep _ [] = [] +combsWithRep k xxs@(x:xs) = map (x:) (combsWithRep (k-1) xxs) ++ combsWithRep k xs + +binomial n m = (f n) `div` (f (n - m)) `div` (f m) where + f n = if n == 0 then 1 else n * f (n - 1) + +countCombsWithRep k lst = binomial (k - 1 + length lst) k +-- countCombsWithRep k = length . combsWithRep k + +main = do + print $ combsWithRep 2 ["iced","jam","plain"] + print $ countCombsWithRep 3 [1..10] diff --git a/Task/Combinations-with-repetitions/Haskell/combinations-with-repetitions-2.hs b/Task/Combinations-with-repetitions/Haskell/combinations-with-repetitions-2.hs new file mode 100644 index 0000000000..2c15d205d9 --- /dev/null +++ b/Task/Combinations-with-repetitions/Haskell/combinations-with-repetitions-2.hs @@ -0,0 +1,2 @@ +[["iced","iced"],["iced","jam"],["iced","plain"],["jam","jam"],["jam","plain"],["plain","plain"]] +220 diff --git a/Task/Combinations-with-repetitions/Java/combinations-with-repetitions-1.java b/Task/Combinations-with-repetitions/Java/combinations-with-repetitions-1.java new file mode 100644 index 0000000000..160c55ada9 --- /dev/null +++ b/Task/Combinations-with-repetitions/Java/combinations-with-repetitions-1.java @@ -0,0 +1,26 @@ +import com.objectwave.utility.*; + +public class MultiCombinationsTester { + + public MultiCombinationsTester() throws CombinatoricException { + Object[] objects = {"iced", "jam", "plain"}; + //Object[] objects = {"abba", "baba", "ab"}; + //Object[] objects = {"aaa", "aa", "a"}; + //Object[] objects = {(Integer)1, (Integer)2, (Integer)3, (Integer)4}; + MultiCombinations mc = new MultiCombinations(objects, 2); + while (mc.hasMoreElements()) { + for (int i = 0; i < mc.nextElement().length; i++) { + System.out.print(mc.nextElement()[i].toString() + " "); + } + System.out.println(); + } + + // Extra credit: + System.out.println("----------"); + System.out.println("The ways to choose 3 items from 10 with replacement = " + MultiCombinations.c(10, 3)); + } // constructor + + public static void main(String[] args) throws CombinatoricException { + new MultiCombinationsTester(); + } +} // class diff --git a/Task/Combinations-with-repetitions/Java/combinations-with-repetitions-2.java b/Task/Combinations-with-repetitions/Java/combinations-with-repetitions-2.java new file mode 100644 index 0000000000..178e1a0757 --- /dev/null +++ b/Task/Combinations-with-repetitions/Java/combinations-with-repetitions-2.java @@ -0,0 +1,48 @@ +import com.objectwave.utility.*; +import java.util.*; + +public class MultiCombinations { + + private HashSet set = new HashSet(); + private Combinations comb = null; + private Object[] nextElem = null; + + public MultiCombinations(Object[] objects, int k) throws CombinatoricException { + k = Math.max(0, k); + Object[] myObjects = new Object[objects.length * k]; + for (int i = 0; i < objects.length; i++) { + for (int j = 0; j < k; j++) { + myObjects[i * k + j] = objects[i]; + } + } + comb = new Combinations(myObjects, k); + } // constructor + + boolean hasMoreElements() { + boolean ret = false; + nextElem = null; + int oldCount = set.size(); + while (comb.hasMoreElements()) { + Object[] elem = (Object[]) comb.nextElement(); + String str = ""; + for (int i = 0; i < elem.length; i++) { + str += ("%" + elem[i].toString() + "~"); + } + set.add(str); + if (set.size() > oldCount) { + nextElem = elem; + ret = true; + break; + } + } + return ret; + } // hasMoreElements() + + Object[] nextElement() { + return nextElem; + } + + static java.math.BigInteger c(int n, int k) throws CombinatoricException { + return Combinatoric.c(n + k - 1, k); + } +} // class diff --git a/Task/Combinations-with-repetitions/JavaScript/combinations-with-repetitions-1.js b/Task/Combinations-with-repetitions/JavaScript/combinations-with-repetitions-1.js new file mode 100644 index 0000000000..97d6e9602a --- /dev/null +++ b/Task/Combinations-with-repetitions/JavaScript/combinations-with-repetitions-1.js @@ -0,0 +1,24 @@ +Donuts +

diff --git a/Task/Combinations-with-repetitions/JavaScript/combinations-with-repetitions-2.js b/Task/Combinations-with-repetitions/JavaScript/combinations-with-repetitions-2.js
new file mode 100644
index 0000000000..2d19ae9378
--- /dev/null
+++ b/Task/Combinations-with-repetitions/JavaScript/combinations-with-repetitions-2.js
@@ -0,0 +1,8 @@
+iced iced
+iced jam
+iced plain
+jam jam
+jam plain
+plain plain
+6 combos
+pick 3 out of 10: 220 combos
diff --git a/Task/Combinations-with-repetitions/PHP/combinations-with-repetitions-1.php b/Task/Combinations-with-repetitions/PHP/combinations-with-repetitions-1.php
new file mode 100644
index 0000000000..c75762744b
--- /dev/null
+++ b/Task/Combinations-with-repetitions/PHP/combinations-with-repetitions-1.php
@@ -0,0 +1,32 @@
+";
+  }
+  $donuts = range(1, 10);
+  $num_donut_combos = count(combos($donuts, 3));
+  echo "$num_donut_combos ways to order 3 donuts given 10 types";
+?>
diff --git a/Task/Combinations-with-repetitions/PHP/combinations-with-repetitions-2.php b/Task/Combinations-with-repetitions/PHP/combinations-with-repetitions-2.php
new file mode 100644
index 0000000000..d8ef0c4d5c
--- /dev/null
+++ b/Task/Combinations-with-repetitions/PHP/combinations-with-repetitions-2.php
@@ -0,0 +1,7 @@
+iced iced
+iced jam
+iced plain
+jam jam
+jam plain
+plain plain
+220 ways to order 3 donuts given 10 types
diff --git a/Task/Combinations-with-repetitions/Perl/combinations-with-repetitions.pl b/Task/Combinations-with-repetitions/Perl/combinations-with-repetitions.pl
new file mode 100644
index 0000000000..9accee25cd
--- /dev/null
+++ b/Task/Combinations-with-repetitions/Perl/combinations-with-repetitions.pl
@@ -0,0 +1,9 @@
+sub p { $_[0] ? map p($_[0] - 1, [@{$_[1]}, $_[$_]], @_[$_ .. $#_]), 2 .. $#_ : $_[1] }
+sub f { $_[0] ? $_[0] * f($_[0] - 1) : 1 }
+sub pn{ f($_[0] + $_[1] - 1) / f($_[0]) / f($_[1] - 1) }
+
+for (p(2, [], qw(iced jam plain))) {
+        print "@$_\n";
+}
+
+printf "\nThere are %d ways to pick 7 out of 10\n", pn(7,10);
diff --git a/Task/Combinations-with-repetitions/PicoLisp/combinations-with-repetitions.l b/Task/Combinations-with-repetitions/PicoLisp/combinations-with-repetitions.l
new file mode 100644
index 0000000000..4743f8b953
--- /dev/null
+++ b/Task/Combinations-with-repetitions/PicoLisp/combinations-with-repetitions.l
@@ -0,0 +1,10 @@
+(de combrep (N Lst)
+   (cond
+      ((=0 N) '(NIL))
+      ((not Lst))
+      (T
+         (conc
+            (mapcar
+               '((X) (cons (car Lst) X))
+               (combrep (dec N) Lst) )
+            (combrep N (cdr Lst)) ) ) ) )
diff --git a/Task/Combinations-with-repetitions/Python/combinations-with-repetitions.py b/Task/Combinations-with-repetitions/Python/combinations-with-repetitions.py
new file mode 100644
index 0000000000..afd7cb494d
--- /dev/null
+++ b/Task/Combinations-with-repetitions/Python/combinations-with-repetitions.py
@@ -0,0 +1,8 @@
+>>> from itertools import combinations_with_replacement
+>>> n, k = 'iced jam plain'.split(), 2
+>>> list(combinations_with_replacement(n,k))
+[('iced', 'iced'), ('iced', 'jam'), ('iced', 'plain'), ('jam', 'jam'), ('jam', 'plain'), ('plain', 'plain')]
+>>> # Extra credit
+>>> len(list(combinations_with_replacement(range(10), 3)))
+220
+>>>
diff --git a/Task/Combinations-with-repetitions/REXX/combinations-with-repetitions.rexx b/Task/Combinations-with-repetitions/REXX/combinations-with-repetitions.rexx
new file mode 100644
index 0000000000..2d987cf675
--- /dev/null
+++ b/Task/Combinations-with-repetitions/REXX/combinations-with-repetitions.rexx
@@ -0,0 +1,30 @@
+/*REXX program shows combination sets for  X  things taken  Y  at a time*/
+parse arg x y symbols .;  if x=='' | x==',' then x=3
+                          if y=='' | y==',' then y=2
+if symbols=='' then symbols='iced jam plain'       /*symbol table words.*/
+
+say "────────────" abs(x) 'doughnut selection taken' y "at a time:"
+say "────────────" RcombN(x,y) 'combinations.';      if x\=='' then exit #
+say
+    x= -10          /*indicate that the combinations aren't to be shown.*/
+    y=   3
+say "────────────" abs(x) 'doughnut selection choose' y "at a time:"
+say "────────────" RcombN(x,y) 'combinations.'
+exit                                   /*stick a fork in it, we're done.*/
+/*─────────────────────────────────────RCOMBN subroutine────────────────*/
+RcombN: procedure expose # symbols; parse arg x 1 ox,y;  x=abs(x);  base=x
+!.=1
+           do #=1;  if ox>0 then do;  L=;     do d=1 for y while ox>0
+                                              L=L word(symbols,!.d)
+                                              end   /*d*/ ;          say L
+                                 end
+           !.y=!.y+1;    if !.y==base then if .RcombN(y-1) then leave
+           end    /*#*/
+return #
+/*─────────────────────────────────────.RCOMBN subroutine───────────────*/
+.RcombN: procedure expose !. y base;   parse arg d;  if d==0 then return 1
+p=!.d+1;   if p==base then return .RcombN(d-1)
+                do u=d to y
+                !.u=p
+                end     /*u*/
+return 0
diff --git a/Task/Combinations-with-repetitions/Ruby/combinations-with-repetitions.rb b/Task/Combinations-with-repetitions/Ruby/combinations-with-repetitions.rb
new file mode 100644
index 0000000000..beea310dd0
--- /dev/null
+++ b/Task/Combinations-with-repetitions/Ruby/combinations-with-repetitions.rb
@@ -0,0 +1,3 @@
+possible_doughnuts = ['iced', 'jam', 'plain'].repeated_combination(2)
+puts "There are #{possible_doughnuts.count} possible doughnuts:"
+possible_doughnuts.each{|doughnut_combi| puts doughnut_combi.join(' and ')}
diff --git a/Task/Combinations-with-repetitions/Scala/combinations-with-repetitions.scala b/Task/Combinations-with-repetitions/Scala/combinations-with-repetitions.scala
new file mode 100644
index 0000000000..971358ff96
--- /dev/null
+++ b/Task/Combinations-with-repetitions/Scala/combinations-with-repetitions.scala
@@ -0,0 +1,13 @@
+object CombinationsWithRepetition {
+
+  def multi[A](as: List[A], k: Int): List[List[A]] =
+    (List.fill(k)(as)).flatten.combinations(k).toList
+
+  def main(args: Array[String]): Unit = {
+    val doughnuts = multi(List("iced", "jam", "plain"), 2)
+    for (combo <- doughnuts) println(combo.mkString(","))
+
+    val bonus = multi(List(0,1,2,3,4,5,6,7,8,9), 3).size
+    println("There are "+bonus+" ways to choose 3 items from 10 choices")
+  }
+}
diff --git a/Task/Combinations-with-repetitions/Scheme/combinations-with-repetitions.ss b/Task/Combinations-with-repetitions/Scheme/combinations-with-repetitions.ss
new file mode 100644
index 0000000000..834d91c8fc
--- /dev/null
+++ b/Task/Combinations-with-repetitions/Scheme/combinations-with-repetitions.ss
@@ -0,0 +1,11 @@
+(define combinations
+  (lambda (lst k)
+    (cond ((= k 0) '(()))
+          ((null? lst) '())
+          (else
+           (append
+            (map
+             (lambda (x)
+               (cons (car lst) x))
+             (combinations lst (- k 1)))
+            (combinations (cdr lst) k))))))
diff --git a/Task/Combinations-with-repetitions/Tcl/combinations-with-repetitions.tcl b/Task/Combinations-with-repetitions/Tcl/combinations-with-repetitions.tcl
new file mode 100644
index 0000000000..223eaa25ba
--- /dev/null
+++ b/Task/Combinations-with-repetitions/Tcl/combinations-with-repetitions.tcl
@@ -0,0 +1,23 @@
+package require Tcl 8.5
+proc combrepl {set n {presorted no}} {
+    if {!$presorted} {
+        set set [lsort $set]
+    }
+    if {[incr n 0] < 1} {
+	return {}
+    } elseif {$n < 2} {
+	return $set
+    }
+    # Recursive call
+    set res [combrepl $set [incr n -1] yes]
+    set result {}
+    foreach item $set {
+	foreach inner $res {
+	    dict set result [lsort [list $item {*}$inner]] {}
+	}
+    }
+    return [dict keys $result]
+}
+
+puts [combrepl {iced jam plain} 2]
+puts [llength [combrepl {1 2 3 4 5 6 7 8 9 10} 3]]
diff --git a/Task/Combinations/0DESCRIPTION b/Task/Combinations/0DESCRIPTION
new file mode 100644
index 0000000000..32bf885ca0
--- /dev/null
+++ b/Task/Combinations/0DESCRIPTION
@@ -0,0 +1,14 @@
+Given non-negative integers m and n, generate all size m [http://mathworld.wolfram.com/Combination.html combinations] of the integers from 0 to n-1 in sorted order (each combination is sorted and the entire table is sorted).
+For example, 3 comb 5 is
+ 0 1 2
+ 0 1 3
+ 0 1 4
+ 0 2 3
+ 0 2 4
+ 0 3 4
+ 1 2 3
+ 1 2 4
+ 1 3 4
+ 2 3 4
+
+If it is more "natural" in your language to start counting from 1 instead of 0 the combinations can be of the integers from 1 to n.
diff --git a/Task/Combinations/1META.yaml b/Task/Combinations/1META.yaml
new file mode 100644
index 0000000000..9e130e8a7b
--- /dev/null
+++ b/Task/Combinations/1META.yaml
@@ -0,0 +1,2 @@
+---
+note: Discrete math
diff --git a/Task/Combinations/ALGOL-68/combinations.alg b/Task/Combinations/ALGOL-68/combinations.alg
new file mode 100644
index 0000000000..76fd3e2eba
--- /dev/null
+++ b/Task/Combinations/ALGOL-68/combinations.alg
@@ -0,0 +1,54 @@
+MODE DATA = INT;
+
+PRIO C = 7;
+
+# Calculate the number of combinations anticipated #
+OP C = (INT n, k)INT:
+  CASE k + 1 IN
+  # case 0: # 1,
+  # case 1: # n
+    OUT (n - 1) C (k - 1) * n OVER k
+  ESAC;
+
+PROC combinations = (INT m, []DATA list)[,]DATA: (
+  CASE m IN
+  # case 1: # ( # transpose list #
+    [UPB list,1]DATA out;
+    out[,1]:=list;
+    out
+  )
+  OUT
+    [UPB list C m, m]DATA out;
+    INT index out := 1;
+    FOR i TO UPB list DO
+      DATA x = list[i];
+      [,]DATA y = combinations(m - 1, list[i+1:]);
+      FOR suffix TO UPB y DO
+        out[index out,1 ] := x;
+        out[index out,2:] := y[suffix,];
+        index out +:= 1
+      OD
+    OD;
+    out
+  ESAC
+);
+
+PRIO COMB = 7;
+OP COMB = (INT n, k)[,]INT: (
+  [k]DATA list; # create a list to recombine #
+  FOR i TO UPB list DO list[i]:=i OD;
+  combinations(n,list)
+);
+
+INT m = 3;
+
+#IF formatted transput possible THEN#
+  FORMAT data repr = $d$;
+  FORMAT list repr = $"("n(m-1)(f(data repr)",")f(data repr)")"$;
+  printf ((list repr, 3 COMB 5, $l$));
+#ELSE#
+  [,]DATA result = 3 COMB 5;
+  FOR row TO UPB result DO
+    print ((result[row,], new line))
+  OD
+#FI#
diff --git a/Task/Combinations/AWK/combinations.awk b/Task/Combinations/AWK/combinations.awk
new file mode 100644
index 0000000000..2543bf999e
--- /dev/null
+++ b/Task/Combinations/AWK/combinations.awk
@@ -0,0 +1,37 @@
+BEGIN {
+	## Default values for r and n (Choose 3 from pool of 5).  Can
+	## alternatively be set on the command line:-
+	## awk -v r= -v n= -f 
+	if (length(r) == 0) r = 3
+	if (length(n) == 0) n = 5
+
+	for (i=1; i <= r; i++) { ## First combination of items:
+		A[i] = i
+		if (i < r ) printf i OFS
+		else print i}
+
+	## While 1st item is less than its maximum permitted value...
+	while (A[1] < n - r + 1) {
+		## loop backwards through all items in the previous
+		## combination of items until an item is found that is
+		## less than its maximum permitted value:
+		for (i = r; i >= 1; i--) {
+			## If the equivalently positioned item in the
+			## previous combination of items is less than its
+			## maximum permitted value...
+			if (A[i] < n - r + i) {
+				## increment the current item by 1:
+				A[i]++
+				## Save the current position-index for use
+				## outside this "for" loop:
+				p = i
+				break}}
+		## Put consecutive numbers in the remainder of the array,
+		## counting up from position-index p.
+		for (i = p + 1; i <= r; i++) A[i] = A[i - 1] + 1
+
+		## Print the current combination of items:
+		for (i=1; i <= r; i++) {
+			if (i < r) printf A[i] OFS
+			else print A[i]}}
+	exit}
diff --git a/Task/Combinations/Ada/combinations-1.ada b/Task/Combinations/Ada/combinations-1.ada
new file mode 100644
index 0000000000..beccb6b669
--- /dev/null
+++ b/Task/Combinations/Ada/combinations-1.ada
@@ -0,0 +1,56 @@
+with Ada.Text_IO;  use Ada.Text_IO;
+
+procedure Test_Combinations is
+   generic
+      type Integers is range <>;
+   package Combinations is
+      type Combination is array (Positive range <>) of Integers;
+      procedure First (X : in out Combination);
+      procedure Next (X : in out Combination);
+      procedure Put (X : Combination);
+   end Combinations;
+
+   package body Combinations is
+      procedure First (X : in out Combination) is
+      begin
+         X (1) := Integers'First;
+         for I in 2..X'Last loop
+            X (I) := X (I - 1) + 1;
+         end loop;
+      end First;
+      procedure Next (X : in out Combination) is
+      begin
+         for I in reverse X'Range loop
+            if X (I) < Integers'Val (Integers'Pos (Integers'Last) - X'Last + I) then
+               X (I) := X (I) + 1;
+               for J in I + 1..X'Last loop
+                  X (J) := X (J - 1) + 1;
+               end loop;
+               return;
+            end if;
+         end loop;
+         raise Constraint_Error;
+      end Next;
+      procedure Put (X : Combination) is
+      begin
+         for I in X'Range loop
+            Put (Integers'Image (X (I)));
+         end loop;
+      end Put;
+   end Combinations;
+
+   type Five is range 0..4;
+   package Fives is new Combinations (Five);
+   use Fives;
+
+   X : Combination (1..3);
+begin
+   First (X);
+   loop
+      Put (X); New_Line;
+      Next (X);
+   end loop;
+exception
+   when Constraint_Error =>
+      null;
+end Test_Combinations;
diff --git a/Task/Combinations/Ada/combinations-2.ada b/Task/Combinations/Ada/combinations-2.ada
new file mode 100644
index 0000000000..bb90efd0d9
--- /dev/null
+++ b/Task/Combinations/Ada/combinations-2.ada
@@ -0,0 +1 @@
+type Five is range 0..4;
diff --git a/Task/Combinations/AppleScript/combinations-1.applescript b/Task/Combinations/AppleScript/combinations-1.applescript
new file mode 100644
index 0000000000..2b69cea1bc
--- /dev/null
+++ b/Task/Combinations/AppleScript/combinations-1.applescript
@@ -0,0 +1,27 @@
+on comb(n, k)
+	set c to {}
+	repeat with i from 1 to k
+		set end of c to i's contents
+	end repeat
+	set r to {c's contents}
+	repeat while my next_comb(c, k, n)
+		set end of r to c's contents
+	end repeat
+	return r
+end comb
+
+on next_comb(c, k, n)
+	set i to k
+	set c's item i to (c's item i) + 1
+	repeat while (i > 1 and c's item i ≥ n - k + 1 + i)
+		set i to i - 1
+		set c's item i to (c's item i) + 1
+	end repeat
+	if (c's item 1 > n - k + 1) then return false	
+	repeat with i from i + 1 to k
+		set c's item i to (c's item (i - 1)) + 1
+	end repeat
+	return true
+end next_comb
+
+return comb(5, 3)
diff --git a/Task/Combinations/AppleScript/combinations-2.applescript b/Task/Combinations/AppleScript/combinations-2.applescript
new file mode 100644
index 0000000000..4c8e58a4fd
--- /dev/null
+++ b/Task/Combinations/AppleScript/combinations-2.applescript
@@ -0,0 +1 @@
+{{1, 2, 3}, {1, 2, 4}, {1, 2, 5}, {1, 3, 4}, {1, 3, 5}, {1, 4, 5}, {2, 3, 4}, {2, 3, 5}, {2, 4, 5}, {3, 4, 5}}
diff --git a/Task/Combinations/AutoHotkey/combinations.ahk b/Task/Combinations/AutoHotkey/combinations.ahk
new file mode 100644
index 0000000000..f097bd5196
--- /dev/null
+++ b/Task/Combinations/AutoHotkey/combinations.ahk
@@ -0,0 +1,26 @@
+MsgBox % Comb(1,1)
+MsgBox % Comb(3,3)
+MsgBox % Comb(3,2)
+MsgBox % Comb(2,3)
+MsgBox % Comb(5,3)
+
+Comb(n,t) { ; Generate all n choose t combinations of 1..n, lexicographically
+   IfLess n,%t%, Return
+   Loop %t%
+      c%A_Index% := A_Index
+   i := t+1, c%i% := n+1
+
+   Loop {
+      Loop %t%
+         i := t+1-A_Index, c .= c%i% " "
+      c .= "`n"     ; combinations in new lines
+      j := 1, i := 2
+      Loop
+         If (c%j%+1 = c%i%)
+             c%j% := j, ++j, ++i
+         Else Break
+      If (j > t)
+         Return c
+      c%j% += 1
+   }
+}
diff --git a/Task/Combinations/BBC-BASIC/combinations.bbc b/Task/Combinations/BBC-BASIC/combinations.bbc
new file mode 100644
index 0000000000..afbec89a93
--- /dev/null
+++ b/Task/Combinations/BBC-BASIC/combinations.bbc
@@ -0,0 +1,45 @@
+      INSTALL @lib$+"SORTLIB"
+      sort% = FN_sortinit(0,0)
+
+      M% = 3
+      N% = 5
+
+      C% = FNfact(N%)/(FNfact(M%)*FNfact(N%-M%))
+      DIM s$(C%)
+      PROCcomb(M%, N%, s$())
+
+      CALL sort%, s$(0)
+      FOR I% = 0 TO C%-1
+        PRINT s$(I%)
+      NEXT
+      END
+
+      DEF PROCcomb(C%, N%, s$())
+      LOCAL I%, U%
+      FOR U% = 0 TO 2^N%-1
+        IF FNbits(U%) = C% THEN
+          s$(I%) = FNlist(U%)
+          I% += 1
+        ENDIF
+      NEXT
+      ENDPROC
+
+      DEF FNbits(U%)
+      LOCAL N%
+      WHILE U%
+        N% += 1
+        U% = U% AND (U%-1)
+      ENDWHILE
+      = N%
+
+      DEF FNlist(U%)
+      LOCAL N%, s$
+      WHILE U%
+        IF U% AND 1 s$ += STR$(N%) + " "
+        N% += 1
+        U% = U% >> 1
+      ENDWHILE
+      = s$
+
+      DEF FNfact(N%)
+      IF N%<=1 THEN = 1 ELSE = N%*FNfact(N%-1)
diff --git a/Task/Combinations/Bracmat/combinations.bracmat b/Task/Combinations/Bracmat/combinations.bracmat
new file mode 100644
index 0000000000..d91d30ca6b
--- /dev/null
+++ b/Task/Combinations/Bracmat/combinations.bracmat
@@ -0,0 +1,24 @@
+(comb=
+  bvar combination combinations list m n pat pvar var
+.     !arg:(?m.?n)
+    & ( pat
+      =   ?
+        & !combinations (.!combination):?combinations
+        & ~
+      )
+    & :?list:?combination:?combinations
+    &   whl
+      ' ( !m+-1:~<0:?m
+        & chu$(utf$a+!m):?var
+        & glf$('(%@?.$var)):(=?pvar)
+        & '(? ()$pvar ()$pat):(=?pat)
+        & glf$('(!.$var)):(=?bvar)
+        & (   '$combination:(=)
+            & '$bvar:(=?combination)
+          | '($bvar ()$combination):(=?combination)
+          )
+        )
+    &   whl
+      ' (!n+-1:~<0:?n&!n !list:?list)
+    & !list:!pat
+  | !combinations);
diff --git a/Task/Combinations/C++/combinations.cpp b/Task/Combinations/C++/combinations.cpp
new file mode 100644
index 0000000000..ad0193fea2
--- /dev/null
+++ b/Task/Combinations/C++/combinations.cpp
@@ -0,0 +1,23 @@
+#include 
+#include 
+#include 
+
+void comb(int N, int K)
+{
+    std::string bitmask(K, 1); // K leading 1's
+    bitmask.resize(N, 0); // N-K trailing 0's
+
+    // print integers and permute bitmask
+    do {
+        for (int i = 0; i < N; ++i) // [0..N-1] integers
+        {
+            if (bitmask[i]) std::cout << " " << i;
+        }
+        std::cout << std::endl;
+    } while (std::prev_permutation(bitmask.begin(), bitmask.end()));
+}
+
+int main()
+{
+    comb(5, 3);
+}
diff --git a/Task/Combinations/C/combinations-1.c b/Task/Combinations/C/combinations-1.c
new file mode 100644
index 0000000000..a7024f6b01
--- /dev/null
+++ b/Task/Combinations/C/combinations-1.c
@@ -0,0 +1,29 @@
+#include 
+
+/* Type marker stick: using bits to indicate what's chosen.  The stick can't
+ * handle more than 32 items, but the idea is there; at worst, use array instead */
+typedef unsigned long marker;
+marker one = 1;
+
+void comb(int pool, int need, marker chosen, int at)
+{
+	if (pool < need + at) return; /* not enough bits left */
+
+	if (!need) {
+		/* got all we needed; print the thing.  if other actions are
+		 * desired, we could have passed in a callback function. */
+		for (at = 0; at < pool; at++)
+			if (chosen & (one << at)) printf("%d ", at);
+		printf("\n");
+		return;
+	}
+	/* if we choose the current item, "or" (|) the bit to mark it so. */
+	comb(pool, need - 1, chosen | (one << at), at + 1);
+	comb(pool, need, chosen, at + 1);  /* or don't choose it, go to next */
+}
+
+int main()
+{
+	comb(5, 3, 0, 0);
+	return 0;
+}
diff --git a/Task/Combinations/C/combinations-2.c b/Task/Combinations/C/combinations-2.c
new file mode 100644
index 0000000000..d61cbab4a5
--- /dev/null
+++ b/Task/Combinations/C/combinations-2.c
@@ -0,0 +1,26 @@
+#include 
+
+void comb(int m, int n, unsigned char *c)
+{
+	int i;
+	for (i = 0; i < n; i++) c[i] = n - i;
+
+	while (1) {
+		for (i = n; i--;)
+			printf("%d%c", c[i], i ? ' ': '\n');
+
+		/* this check is not strictly necessary, but if m is not close to n,
+		   it makes the whole thing quite a bit faster */
+		if (c[i]++ < m) continue;
+
+		for (i = 0; c[i] >= m - i;) if (++i >= n) return;
+		for (c[i]++; i; i--) c[i-1] = c[i] + 1;
+	}
+}
+
+int main()
+{
+	unsigned char buf[100];
+	comb(5, 3, buf);
+	return 0;
+}
diff --git a/Task/Combinations/Clojure/combinations.clj b/Task/Combinations/Clojure/combinations.clj
new file mode 100644
index 0000000000..9505d60da5
--- /dev/null
+++ b/Task/Combinations/Clojure/combinations.clj
@@ -0,0 +1,20 @@
+(defn combinations
+  "If m=1, generate a nested list of numbers [0,n)
+   If m>1, for each x in [0,n), and for each list in the recursion on [x+1,n), cons the two"
+  [m n]
+  (letfn [(comb-aux
+	   [m start]
+	   (if (= 1 m)
+	     (for [x (range start n)]
+	       (list x))
+	     (for [x (range start n)
+		   xs (comb-aux (dec m) (inc x))]
+	       (cons x xs))))]
+    (comb-aux m 0)))
+
+(defn print-combinations
+  [m n]
+  (doseq [line (combinations m n)]
+    (doseq [n line]
+      (printf "%s " n))
+    (printf "%n")))
diff --git a/Task/Combinations/CoffeeScript/combinations-1.coffee b/Task/Combinations/CoffeeScript/combinations-1.coffee
new file mode 100644
index 0000000000..93cacf3d1b
--- /dev/null
+++ b/Task/Combinations/CoffeeScript/combinations-1.coffee
@@ -0,0 +1,25 @@
+combinations = (n, p) ->
+  return [ [] ] if p == 0
+  i = 0
+  combos = []
+  combo = []
+  while combo.length < p
+    if i < n
+      combo.push i
+      i += 1
+    else
+      break if combo.length == 0
+      i = combo.pop() + 1
+
+    if combo.length == p
+      combos.push clone combo
+      i = combo.pop() + 1
+  combos
+
+clone = (arr) -> (n for n in arr)
+
+N = 5
+for i in [0..N]
+  console.log "------ #{N} #{i}"
+  for combo in combinations N, i
+    console.log combo
diff --git a/Task/Combinations/CoffeeScript/combinations-2.coffee b/Task/Combinations/CoffeeScript/combinations-2.coffee
new file mode 100644
index 0000000000..488d61813c
--- /dev/null
+++ b/Task/Combinations/CoffeeScript/combinations-2.coffee
@@ -0,0 +1,39 @@
+> coffee combo.coffee
+------ 5 0
+[]
+------ 5 1
+[ 0 ]
+[ 1 ]
+[ 2 ]
+[ 3 ]
+[ 4 ]
+------ 5 2
+[ 0, 1 ]
+[ 0, 2 ]
+[ 0, 3 ]
+[ 0, 4 ]
+[ 1, 2 ]
+[ 1, 3 ]
+[ 1, 4 ]
+[ 2, 3 ]
+[ 2, 4 ]
+[ 3, 4 ]
+------ 5 3
+[ 0, 1, 2 ]
+[ 0, 1, 3 ]
+[ 0, 1, 4 ]
+[ 0, 2, 3 ]
+[ 0, 2, 4 ]
+[ 0, 3, 4 ]
+[ 1, 2, 3 ]
+[ 1, 2, 4 ]
+[ 1, 3, 4 ]
+[ 2, 3, 4 ]
+------ 5 4
+[ 0, 1, 2, 3 ]
+[ 0, 1, 2, 4 ]
+[ 0, 1, 3, 4 ]
+[ 0, 2, 3, 4 ]
+[ 1, 2, 3, 4 ]
+------ 5 5
+[ 0, 1, 2, 3, 4 ]
diff --git a/Task/Combinations/Common-Lisp/combinations-1.lisp b/Task/Combinations/Common-Lisp/combinations-1.lisp
new file mode 100644
index 0000000000..9f12b0219a
--- /dev/null
+++ b/Task/Combinations/Common-Lisp/combinations-1.lisp
@@ -0,0 +1,18 @@
+(defun map-combinations (m n fn)
+  "Call fn with each m combination of the integers from 0 to n-1 as a list. The list may be destroyed after fn returns."
+  (let ((combination (make-list m)))
+    (labels ((up-from (low)
+               (let ((start (1- low)))
+                 (lambda () (incf start))))
+             (mc (curr left needed comb-tail)
+               (cond
+                ((zerop needed)
+                 (funcall fn combination))
+                ((= left needed)
+                 (map-into comb-tail (up-from curr))
+                 (funcall fn combination))
+                (t
+                 (setf (first comb-tail) curr)
+                 (mc (1+ curr) (1- left) (1- needed) (rest comb-tail))
+                 (mc (1+ curr) (1- left) needed comb)))))
+      (mc 0 n m combination))))
diff --git a/Task/Combinations/Common-Lisp/combinations-2.lisp b/Task/Combinations/Common-Lisp/combinations-2.lisp
new file mode 100644
index 0000000000..72b2328e55
--- /dev/null
+++ b/Task/Combinations/Common-Lisp/combinations-2.lisp
@@ -0,0 +1,9 @@
+(defun comb (m list fn)
+  (labels ((comb1 (l c m)
+		  (when (>= (length l) m)
+		    (if (zerop m) (return-from comb1 (funcall fn c)))
+		    (comb1 (cdr l) c m)
+		    (comb1 (cdr l) (cons (first l) c) (1- m)))))
+    (comb1 list nil m)))
+
+(comb 3 '(0 1 2 3 4 5) #'print)
diff --git a/Task/Combinations/D/combinations-1.d b/Task/Combinations/D/combinations-1.d
new file mode 100644
index 0000000000..c5e879768b
--- /dev/null
+++ b/Task/Combinations/D/combinations-1.d
@@ -0,0 +1,15 @@
+import std.stdio;
+
+T[][] comb(T)(in T[] arr, in int k) pure nothrow {
+    if (k == 0) return [[]];
+    typeof(return) result;
+    foreach (i, x; arr)
+        foreach (suffix; arr[i + 1 .. $].comb(k - 1))
+            result ~= x ~ suffix;
+    return result;
+}
+
+void main() {
+    //import std.stdio: writeln;
+    [0, 1, 2, 3].comb(2).writeln();
+}
diff --git a/Task/Combinations/D/combinations-2.d b/Task/Combinations/D/combinations-2.d
new file mode 100644
index 0000000000..cf1448d91e
--- /dev/null
+++ b/Task/Combinations/D/combinations-2.d
@@ -0,0 +1,13 @@
+import std.stdio, std.algorithm, std.range;
+
+T[][] comb(T)(in T[] s, in int m) /*pure nothrow*/ {
+  if (!m) return [[]];
+  if (s.empty) return [];
+  return s[1 .. $].comb(m - 1).map!(x => s[0] ~ x)().array() ~
+         s[1 .. $].comb(m);
+}
+
+void main() {
+    //import std.stdio: writeln;
+    iota(4).array().comb(2).writeln();
+}
diff --git a/Task/Combinations/D/combinations-3.d b/Task/Combinations/D/combinations-3.d
new file mode 100644
index 0000000000..c3ef2247cc
--- /dev/null
+++ b/Task/Combinations/D/combinations-3.d
@@ -0,0 +1,126 @@
+module combinations3;
+
+ulong binomial(long n, long k) pure nothrow
+in {
+    assert(n > 0, "binomial: n must be > 0.");
+} body {
+    if (k < 0 || k > n)
+        return 0;
+    if (k > (n / 2))
+        k = n - k;
+    ulong result = 1;
+    foreach (ulong d; 1 .. k + 1) {
+        result *= n;
+        n--;
+        result /= d;
+    }
+    return result;
+}
+
+
+struct Combinations(T, bool copy=true) {
+    // Algorithm by Knuth, Pre-fascicle 3A, draft of
+    // section 7.2.1.3: "Generating all partitions".
+    T[] items;
+    int k;
+    size_t len = -1; // computed lazily
+
+    this(in T[] items, in int k)
+    in {
+        assert(items.length, "combinations: items can't be empty.");
+    } body {
+        this.items = items.dup;
+        this.k = k;
+    }
+
+    @property size_t length() /*logic_const*/ {
+        if (len == -1) // set cache
+            len = cast(size_t)binomial(items.length, k);
+        return len;
+    }
+
+    int opApply(int delegate(ref T[]) dg) {
+        if (k == items.length)
+            return dg(items);         // yield items
+
+        auto outarr = new T[k];
+        if (k == 0)
+            return dg(outarr);        // yield []
+
+        if (k < 0 || k > items.length)
+            return 0;                 // yield nothing
+
+        int result, x;
+        immutable n = items.length;
+        auto c = new uint[k + 3]; // c[0] isn'k used
+
+        foreach (j; 1 .. k + 1)
+            c[j] = j - 1;
+        c[k + 1] = n;
+        c[k + 2] = 0;
+        int j = k;
+
+        while (true) {
+            // The following lines equal to:
+            //int pos;
+            //foreach (i; 1 .. k +1)
+            //    outarr[pos++] = items[c[i]];
+            auto outarr_ptr = outarr.ptr;
+            auto c_ptr = &(c[1]);
+            auto c_ptrkp1 = &(c[k + 1]);
+            while (c_ptr != c_ptrkp1)
+                *outarr_ptr++ = items[*c_ptr++];
+
+
+            static if (copy) {
+                auto outarr2 = outarr.dup;
+                result = dg(outarr2); // yield outarr2
+            } else {
+                result = dg(outarr); // yield outarr
+            }
+
+            if (j > 0) {
+                x = j;
+                c[j] = x;
+                j--;
+                continue;
+            }
+
+            if ((c[1] + 1) < c[2]) {
+                c[1]++;
+                continue;
+            } else
+                j = 2;
+
+            while (true) {
+                c[j - 1] = j - 2;
+                x = c[j] + 1;
+                if (x == c[j + 1])
+                    j++;
+                else
+                    break;
+            }
+
+            if (j > k)
+                return result; // End
+
+            c[j] = x;
+            j--;
+        }
+    }
+}
+
+Combinations!(T,copy) combinations(bool copy=true, T)
+                                  (in T[] items, in int k)
+in {
+    assert(items.length, "combinations: items can't be empty.");
+} body {
+    return Combinations!(T, copy)(items, k);
+}
+
+
+// compile with -version=combinations3_main to run main
+version(combinations3_main) void main() {
+    import std.stdio, std.array;
+    writeln(array(combinations([1, 2, 3, 4], 2)));
+}
diff --git a/Task/Combinations/D/combinations-4.d b/Task/Combinations/D/combinations-4.d
new file mode 100644
index 0000000000..d23c959921
--- /dev/null
+++ b/Task/Combinations/D/combinations-4.d
@@ -0,0 +1,100 @@
+module combinations4;
+import std.stdio, std.algorithm, std.conv;
+
+ulong choose(int n, int k) nothrow
+in {
+    assert(n >= 0 && k >= 0, "choose: no negative input.");
+} body {
+    static ulong[][] cache;
+
+    if (n < k)
+        return 0;
+    else if (n == k)
+        return 1;
+    while (n >= cache.length)
+        cache ~= [1UL]; // = choose(m, 0);
+    auto kmax  = min(k, n - k);
+    while(kmax >= cache[n].length) {
+        immutable h = cache[n].length;
+        cache[n] ~= choose(n - 1, h - 1) + choose(n - 1, h);
+    }
+
+    return cache[n][kmax];
+}
+
+int largestV(in int p, in int q, in long r) nothrow
+in {
+    assert(p > 0 && q >= 0 && r >= 0, "largestV: no negative input.");
+} body {
+    auto v = p - 1;
+    while (choose(v, q) > r)
+        v--;
+    return v;
+}
+
+struct Comb {
+    immutable int n, m;
+
+    @property size_t length() const /*nothrow*/ {
+        return to!size_t(choose(n, m));
+    }
+
+    int[] opIndex(in size_t idx) const {
+        if (m < 0 || n < 0)
+            return [];
+        if (idx >= length)
+            throw new Exception("Out of bound");
+        ulong x = choose(n, m) - 1 - idx;
+        int a = n, b = m;
+        auto res = new int[m];
+        foreach (i; 0 .. m) {
+            a = largestV(a, b, x);
+            x = x - choose(a, b);
+            b = b - 1;
+            res[i] = n - 1 - a;
+        }
+        return res;
+    }
+
+    int opApply(int delegate(ref int[]) dg) const {
+        int[] yield;
+
+        foreach (i; 0 .. length) {
+            yield = this[i];
+            if (dg(yield))
+                break;
+        }
+
+        return 0;
+    }
+
+    static auto On(T)(in T[] arr, in int m) {
+        auto comb = Comb(arr.length, m);
+
+        return new class {
+            @property size_t length() const /*nothrow*/ {
+                return comb.length;
+            }
+
+            int opApply(int delegate(ref T[]) dg) const {
+                auto yield = new T[m];
+
+                foreach (c; comb) {
+                    foreach (idx; 0 .. m)
+                        yield[idx] = arr[c[idx]];
+                    if (dg(yield))
+                        break;
+                }
+
+                return 0;
+            }
+        };
+    }
+}
+
+
+version(combinations4_main)
+    void main() {
+        foreach (c; Comb.On([1, 2, 3], 2))
+            writeln(c);
+    }
diff --git a/Task/Combinations/E/combinations.e b/Task/Combinations/E/combinations.e
new file mode 100644
index 0000000000..3a72ce70c4
--- /dev/null
+++ b/Task/Combinations/E/combinations.e
@@ -0,0 +1,13 @@
+def combinations(m, range) {
+  return if (m <=> 0) { [[]] } else {
+    def combGenerator {
+      to iterate(f) {
+        for i in range {
+          for suffix in combinations(m.previous(), range & (int > i)) {
+            f(null, [i] + suffix)
+          }
+        }
+      }
+    }
+  }
+}
diff --git a/Task/Combinations/Erlang/combinations.erl b/Task/Combinations/Erlang/combinations.erl
new file mode 100644
index 0000000000..b364cc8c1c
--- /dev/null
+++ b/Task/Combinations/Erlang/combinations.erl
@@ -0,0 +1,9 @@
+-module(comb).
+-compile(export_all).
+
+comb(0,_) ->
+    [[]];
+comb(_,[]) ->
+    [];
+comb(N,[H|T]) ->
+    [[H|L] || L <- comb(N-1,T)]++comb(N,T).
diff --git a/Task/Combinations/Fortran/combinations-1.f b/Task/Combinations/Fortran/combinations-1.f
new file mode 100644
index 0000000000..42839f8a28
--- /dev/null
+++ b/Task/Combinations/Fortran/combinations-1.f
@@ -0,0 +1,89 @@
+program Combinations
+  use iso_fortran_env
+  implicit none
+
+  type comb_result
+     integer, dimension(:), allocatable :: combs
+  end type comb_result
+
+  type(comb_result), dimension(:), pointer :: r
+  integer :: i, j
+
+  call comb(5, 3, r)
+  do i = 0, choose(5, 3) - 1
+     do j = 2, 0, -1
+        write(*, "(I4, ' ')", advance="no") r(i)%combs(j)
+     end do
+     deallocate(r(i)%combs)
+     write(*,*) ""
+  end do
+  deallocate(r)
+
+contains
+
+  function choose(n, k, err)
+    integer :: choose
+    integer, intent(in) :: n, k
+    integer, optional, intent(out) :: err
+
+    integer :: imax, i, imin, ie
+
+    ie = 0
+    if ( (n < 0 ) .or. (k < 0 ) ) then
+       write(ERROR_UNIT, *) "negative in choose"
+       choose = 0
+       ie = 1
+    else
+       if ( n < k ) then
+          choose = 0
+       else if ( n == k ) then
+          choose = 1
+       else
+          imax = max(k, n-k)
+          imin = min(k, n-k)
+          choose = 1
+          do i = imax+1, n
+             choose = choose * i
+          end do
+          do i = 2, imin
+             choose = choose / i
+          end do
+       end if
+    end if
+    if ( present(err) ) err = ie
+  end function choose
+
+  subroutine comb(n, k, co)
+    integer, intent(in) :: n, k
+    type(comb_result), dimension(:), pointer, intent(out) :: co
+
+    integer :: i, j, s, ix, kx, hm, t
+    integer :: err
+
+    hm = choose(n, k, err)
+    if ( err /= 0 ) then
+       nullify(co)
+       return
+    end if
+
+    allocate(co(0:hm-1))
+    do i = 0, hm-1
+       allocate(co(i)%combs(0:k-1))
+    end do
+    do i = 0, hm-1
+       ix = i; kx = k
+       do s = 0, n-1
+          if ( kx == 0 ) exit
+          t = choose(n-(s+1), kx-1)
+          if ( ix < t ) then
+             co(i)%combs(kx-1) = s
+             kx = kx - 1
+          else
+             ix = ix - t
+          end if
+       end do
+    end do
+
+  end subroutine comb
+
+end program Combinations
diff --git a/Task/Combinations/Fortran/combinations-2.f b/Task/Combinations/Fortran/combinations-2.f
new file mode 100644
index 0000000000..b85f12fe96
--- /dev/null
+++ b/Task/Combinations/Fortran/combinations-2.f
@@ -0,0 +1,32 @@
+program combinations
+
+  implicit none
+  integer, parameter :: m_max = 3
+  integer, parameter :: n_max = 5
+  integer, dimension (m_max) :: comb
+  character (*), parameter :: fmt = '(i0' // repeat (', 1x, i0', m_max - 1) // ')'
+
+  call gen (1)
+
+contains
+
+  recursive subroutine gen (m)
+
+    implicit none
+    integer, intent (in) :: m
+    integer :: n
+
+    if (m > m_max) then
+      write (*, fmt) comb
+    else
+      do n = 1, n_max
+        if ((m == 1) .or. (n > comb (m - 1))) then
+          comb (m) = n
+          call gen (m + 1)
+        end if
+      end do
+    end if
+
+  end subroutine gen
+
+end program combinations
diff --git a/Task/Combinations/Fortran/combinations-3.f b/Task/Combinations/Fortran/combinations-3.f
new file mode 100644
index 0000000000..4c8a46967c
--- /dev/null
+++ b/Task/Combinations/Fortran/combinations-3.f
@@ -0,0 +1,10 @@
+1 2 3
+1 2 4
+1 2 5
+1 3 4
+1 3 5
+1 4 5
+2 3 4
+2 3 5
+2 4 5
+3 4 5
diff --git a/Task/Combinations/Go/combinations.go b/Task/Combinations/Go/combinations.go
new file mode 100644
index 0000000000..bac5abc150
--- /dev/null
+++ b/Task/Combinations/Go/combinations.go
@@ -0,0 +1,29 @@
+package main
+
+import (
+    "fmt"
+)
+
+func main() {
+    comb(5, 3, func(c []int) {
+        fmt.Println(c)
+    })
+}
+
+func comb(n, m int, emit func([]int)) {
+    s := make([]int, m)
+    last := m - 1
+    var rc func(int, int)
+    rc = func(i, next int) {
+        for j := next; j < n; j++ {
+            s[i] = j
+            if i == last {
+                emit(s)
+            } else {
+                rc(i+1, j+1)
+            }
+        }
+        return
+    }
+    rc(0, 0)
+}
diff --git a/Task/Combinations/Haskell/combinations-1.hs b/Task/Combinations/Haskell/combinations-1.hs
new file mode 100644
index 0000000000..517245b476
--- /dev/null
+++ b/Task/Combinations/Haskell/combinations-1.hs
@@ -0,0 +1,4 @@
+comb :: Int -> [a] -> [[a]]
+comb 0 _      = [[]]
+comb _ []     = []
+comb m (x:xs) = map (x:) (comb (m-1) xs) ++ comb m xs
diff --git a/Task/Combinations/Haskell/combinations-2.hs b/Task/Combinations/Haskell/combinations-2.hs
new file mode 100644
index 0000000000..caf6ed0911
--- /dev/null
+++ b/Task/Combinations/Haskell/combinations-2.hs
@@ -0,0 +1,5 @@
+import Data.List (tails)
+
+comb :: Int -> [a] -> [[a]]
+comb 0 _      = [[]]
+comb m l = [x:ys | x:xs <- tails l, ys <- comb (m-1) xs]
diff --git a/Task/Combinations/Haskell/combinations-3.hs b/Task/Combinations/Haskell/combinations-3.hs
new file mode 100644
index 0000000000..f680e67af0
--- /dev/null
+++ b/Task/Combinations/Haskell/combinations-3.hs
@@ -0,0 +1 @@
+comb0 m n = comb m [0..n-1]
diff --git a/Task/Combinations/Haskell/combinations-4.hs b/Task/Combinations/Haskell/combinations-4.hs
new file mode 100644
index 0000000000..0ed5e8bf23
--- /dev/null
+++ b/Task/Combinations/Haskell/combinations-4.hs
@@ -0,0 +1 @@
+comb1 m n = comb m [1..n]
diff --git a/Task/Combinations/Haskell/combinations-5.hs b/Task/Combinations/Haskell/combinations-5.hs
new file mode 100644
index 0000000000..e6e1f68ddc
--- /dev/null
+++ b/Task/Combinations/Haskell/combinations-5.hs
@@ -0,0 +1,2 @@
+import Data.List (sort, subsequences)
+comb m n = sort . filter ((==m) . length) $ subsequences [0..n-1]
diff --git a/Task/Combinations/Haskell/combinations-6.hs b/Task/Combinations/Haskell/combinations-6.hs
new file mode 100644
index 0000000000..f297e3c86a
--- /dev/null
+++ b/Task/Combinations/Haskell/combinations-6.hs
@@ -0,0 +1 @@
+comb m n = filter ((==m . length) $ filterM (const [True, False]) [0..n-1]
diff --git a/Task/Combinations/Java/combinations.java b/Task/Combinations/Java/combinations.java
new file mode 100644
index 0000000000..92167c3ed2
--- /dev/null
+++ b/Task/Combinations/Java/combinations.java
@@ -0,0 +1,30 @@
+import java.util.Collections;
+import java.util.LinkedList;
+
+public class Comb{
+
+        public static void main(String[] args){
+                System.out.println(comb(3,5));
+        }
+
+        public static String bitprint(int u){
+                String s= "";
+                for(int n= 0;u > 0;++n, u>>= 1)
+                        if((u & 1) > 0) s+= n + " ";
+                return s;
+        }
+
+        public static int bitcount(int u){
+                int n;
+                for(n= 0;u > 0;++n, u&= (u - 1));//Turn the last set bit to a 0
+                return n;
+        }
+
+        public static LinkedList comb(int c, int n){
+                LinkedList s= new LinkedList();
+                for(int u= 0;u < 1 << n;u++)
+                        if(bitcount(u) == c) s.push(bitprint(u));
+                Collections.sort(s);
+                return s;
+        }
+}
diff --git a/Task/Combinations/JavaScript/combinations-1.js b/Task/Combinations/JavaScript/combinations-1.js
new file mode 100644
index 0000000000..271e1c8c0a
--- /dev/null
+++ b/Task/Combinations/JavaScript/combinations-1.js
@@ -0,0 +1,18 @@
+function bitprint(u) {
+  var s="";
+  for (var n=0; u; ++n, u>>=1)
+    if (u&1) s+=n+" ";
+  return s;
+}
+function bitcount(u) {
+  for (var n=0; u; ++n, u=u&(u-1));
+  return n;
+}
+function comb(c,n) {
+  var s=[];
+  for (var u=0; u<1< a and a or a+1 end end
+function combs(m, n)
+  if m * n == 0 then return {{}} end
+  local ret, old = {}, combs(m-1, n-1)
+  for i = 1, n do
+    for k, v in ipairs(old) do ret[#ret+1] = {i, map(incr(i), unpack(v))} end
+  end
+  return ret
+end
+
+for k, v in ipairs(combs(3, 5)) do print(unpack(v)) end
+
+-- Iterative version
+function icombs(a,b)
+    if a==0 then return end
+    local taken = {} local slots = {}
+    for i=1,a do slots[i]=0 end
+    for i=1,b do taken[i]=false end
+    local index = 1
+    while index > 0 do repeat
+        repeat slots[index] = slots[index] + 1
+        until slots[index] > b or not taken[slots[index]]
+        if slots[index] > b then
+            slots[index] = 0
+            index = index - 1
+            if index > 0 then
+                taken[slots[index]] = false
+            end
+            break
+        else
+            taken[slots[index]] = true
+        end
+        if index == a then
+            for i=1,a do io.write(slots[i]) io.write(" ") end
+            io.write("\n")
+            taken[slots[index]] = false
+            break
+        end
+        index = index + 1
+    until true end
+end
+
+icombs(3, 5)
diff --git a/Task/Combinations/MATLAB/combinations.m b/Task/Combinations/MATLAB/combinations.m
new file mode 100644
index 0000000000..49041c3bd5
--- /dev/null
+++ b/Task/Combinations/MATLAB/combinations.m
@@ -0,0 +1,14 @@
+>> nchoosek((0:4),3)
+
+ans =
+
+     0     1     2
+     0     1     3
+     0     1     4
+     0     2     3
+     0     2     4
+     0     3     4
+     1     2     3
+     1     2     4
+     1     3     4
+     2     3     4
diff --git a/Task/Combinations/Perl/combinations.pl b/Task/Combinations/Perl/combinations.pl
new file mode 100644
index 0000000000..1bbad0ffa8
--- /dev/null
+++ b/Task/Combinations/Perl/combinations.pl
@@ -0,0 +1,4 @@
+use Math::Combinatorics;
+
+@n = (0 .. 4);
+print join("\n", map { join(" ", @{$_}) } combine(3, @n)), "\n";
diff --git a/Task/Combinations/PicoLisp/combinations.l b/Task/Combinations/PicoLisp/combinations.l
new file mode 100644
index 0000000000..2548a0b02d
--- /dev/null
+++ b/Task/Combinations/PicoLisp/combinations.l
@@ -0,0 +1,12 @@
+(de comb (M Lst)
+   (cond
+      ((=0 M) '(NIL))
+      ((not Lst))
+      (T
+         (conc
+            (mapcar
+               '((Y) (cons (car Lst) Y))
+               (comb (dec M) (cdr Lst)) )
+            (comb M (cdr Lst)) ) ) ) )
+
+(comb 3 (1 2 3 4 5))
diff --git a/Task/Combinations/Prolog/combinations-1.pro b/Task/Combinations/Prolog/combinations-1.pro
new file mode 100644
index 0000000000..6ef2c33b80
--- /dev/null
+++ b/Task/Combinations/Prolog/combinations-1.pro
@@ -0,0 +1,7 @@
+:- use_module(library(clpfd)).
+
+comb_clpfd(L, M, N) :-
+    length(L, M),
+    L ins 1..N,
+    chain(L, #<),
+    label(L).
diff --git a/Task/Combinations/Prolog/combinations-2.pro b/Task/Combinations/Prolog/combinations-2.pro
new file mode 100644
index 0000000000..4ec7ae3ad2
--- /dev/null
+++ b/Task/Combinations/Prolog/combinations-2.pro
@@ -0,0 +1,12 @@
+ ?- comb_clpfd(L, 3, 5), writeln(L), fail.
+[1,2,3]
+[1,2,4]
+[1,2,5]
+[1,3,4]
+[1,3,5]
+[1,4,5]
+[2,3,4]
+[2,3,5]
+[2,4,5]
+[3,4,5]
+false.
diff --git a/Task/Combinations/Prolog/combinations-3.pro b/Task/Combinations/Prolog/combinations-3.pro
new file mode 100644
index 0000000000..97b95cfcc7
--- /dev/null
+++ b/Task/Combinations/Prolog/combinations-3.pro
@@ -0,0 +1,10 @@
+comb_Prolog(L, M, N) :-
+    length(L, M),
+    fill(L, 1, N).
+
+fill([], _, _).
+
+fill([H | T], Min, Max) :-
+    between(Min, Max, H),
+    H1 is H + 1,
+    fill(T, H1, Max).
diff --git a/Task/Combinations/Prolog/combinations-4.pro b/Task/Combinations/Prolog/combinations-4.pro
new file mode 100644
index 0000000000..dd41062347
--- /dev/null
+++ b/Task/Combinations/Prolog/combinations-4.pro
@@ -0,0 +1,3 @@
+:- use_module(library(clpfd)).
+comb_lstcomp(N, M, V) :-
+	V <- {L	& length(L, N), L ins 1..M & all_distinct(L), chain(L, #<), label(L)}.
diff --git a/Task/Combinations/Python/combinations-1.py b/Task/Combinations/Python/combinations-1.py
new file mode 100644
index 0000000000..4e07379adc
--- /dev/null
+++ b/Task/Combinations/Python/combinations-1.py
@@ -0,0 +1,3 @@
+>>> from itertools import combinations
+>>> list(combinations(range(5),3))
+[(0, 1, 2), (0, 1, 3), (0, 1, 4), (0, 2, 3), (0, 2, 4), (0, 3, 4), (1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4)]
diff --git a/Task/Combinations/Python/combinations-2.py b/Task/Combinations/Python/combinations-2.py
new file mode 100644
index 0000000000..0a723e39a5
--- /dev/null
+++ b/Task/Combinations/Python/combinations-2.py
@@ -0,0 +1,6 @@
+def comb(m, lst):
+    if m == 0:
+        return [[]]
+    else:
+        return [[x] + suffix for i, x in enumerate(lst)
+                for suffix in comb(m - 1, lst[i + 1:])]
diff --git a/Task/Combinations/Python/combinations-3.py b/Task/Combinations/Python/combinations-3.py
new file mode 100644
index 0000000000..c2448b5474
--- /dev/null
+++ b/Task/Combinations/Python/combinations-3.py
@@ -0,0 +1,2 @@
+>>> comb(3, range(5))
+[[0, 1, 2], [0, 1, 3], [0, 1, 4], [0, 2, 3], [0, 2, 4], [0, 3, 4], [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]
diff --git a/Task/Combinations/Python/combinations-4.py b/Task/Combinations/Python/combinations-4.py
new file mode 100644
index 0000000000..7851aa59cc
--- /dev/null
+++ b/Task/Combinations/Python/combinations-4.py
@@ -0,0 +1,6 @@
+def comb(m, s):
+    if m == 0: return [[]]
+    if s == []: return []
+    return [s[:1] + a for a in comb(m-1, s[1:])] + comb(m, s[1:])
+
+print comb(3, range(5))
diff --git a/Task/Combinations/R/combinations-1.r b/Task/Combinations/R/combinations-1.r
new file mode 100644
index 0000000000..b2b95365c2
--- /dev/null
+++ b/Task/Combinations/R/combinations-1.r
@@ -0,0 +1 @@
+print(combn(0:4, 3))
diff --git a/Task/Combinations/R/combinations-2.r b/Task/Combinations/R/combinations-2.r
new file mode 100644
index 0000000000..b1d62d1b63
--- /dev/null
+++ b/Task/Combinations/R/combinations-2.r
@@ -0,0 +1,2 @@
+r <- combn(0:4, 3)
+for(i in 1:choose(5,3)) print(r[,i])
diff --git a/Task/Combinations/REXX/combinations.rexx b/Task/Combinations/REXX/combinations.rexx
new file mode 100644
index 0000000000..95c66adb6d
--- /dev/null
+++ b/Task/Combinations/REXX/combinations.rexx
@@ -0,0 +1,27 @@
+/*REXX program shows combination sets for  X  things taken  Y  at a time*/
+@abc='abcdefghijklmnopqrstuvwxyz'; @abcU=@abc; upper @abcU; @digs=123456789
+parse arg x y symbols .;  if x=='' | x==',' then x=5
+                          if y=='' | y==',' then y=3
+if symbols=='' then symbols=@digs||@abc||@abcU    /*symbol table string.*/
+say "────────────" x 'things taken' y "at a time:"
+say "────────────" combN(x,y) 'combinations.'
+exit                                   /*stick a fork in it, we're done.*/
+/*──────────────────────────────────COMBN subroutine────────────────────*/
+combN: procedure expose symbols;  parse arg x,y;   base=x+1;  bbase=base-y
+!.=0;           do i=1 for y;    !.i=i
+                end   /*i*/
+
+          do j=1;  L=;           do d=1 for y
+                                 L=L   word(substr(symbols,!.d,1)   !.d,1)
+                                 end   /*d*/
+          say L
+          !.y=!.y+1;   if !.y==base   then   if .combUp(y-1)   then leave
+          end         /*j*/
+return j
+
+.combUp: procedure expose !. y bbase;  parse arg d;  if d==0 then return 1
+p=!.d;        do u=d to y;     !.u=p+1
+              if !.u==bbase+u then return .combUp(u-1)
+              p=!.u
+              end     /*u*/
+return 0
diff --git a/Task/Combinations/Ruby/combinations.rb b/Task/Combinations/Ruby/combinations.rb
new file mode 100644
index 0000000000..23c54c8fa4
--- /dev/null
+++ b/Task/Combinations/Ruby/combinations.rb
@@ -0,0 +1,5 @@
+def comb(m, n)
+  (0...n).to_a.combination(m).to_a
+end
+
+comb(3, 5)  # => [[0, 1, 2], [0, 1, 3], [0, 1, 4], [0, 2, 3], [0, 2, 4], [0, 3, 4], [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]
diff --git a/Task/Combinations/Scala/combinations.scala b/Task/Combinations/Scala/combinations.scala
new file mode 100644
index 0000000000..026a48997b
--- /dev/null
+++ b/Task/Combinations/Scala/combinations.scala
@@ -0,0 +1,8 @@
+implicit def toComb(m: Int) = new AnyRef {
+  def comb(n: Int) = recurse(m, List.range(0, n))
+  private def recurse(m: Int, l: List[Int]): List[List[Int]] = (m, l) match {
+    case (0, _)   => List(Nil)
+    case (_, Nil) => Nil
+    case _        => (recurse(m - 1, l.tail) map (l.head :: _)) ::: recurse(m, l.tail)
+  }
+}
diff --git a/Task/Combinations/Scheme/combinations.ss b/Task/Combinations/Scheme/combinations.ss
new file mode 100644
index 0000000000..d996ce2fa3
--- /dev/null
+++ b/Task/Combinations/Scheme/combinations.ss
@@ -0,0 +1,8 @@
+(define (comb m lst)
+  (cond ((= m 0) '(()))
+        ((null? lst) '())
+        (else (append (map (lambda (y) (cons (car lst) y))
+                           (comb (- m 1) (cdr lst)))
+                      (comb m (cdr lst))))))
+
+(comb 3 '(0 1 2 3 4))
diff --git a/Task/Combinations/Smalltalk/combinations.st b/Task/Combinations/Smalltalk/combinations.st
new file mode 100644
index 0000000000..90a781294a
--- /dev/null
+++ b/Task/Combinations/Smalltalk/combinations.st
@@ -0,0 +1,15 @@
+(0 to: 4)
+    combinations: 3 atATimeDo: [ :x |
+        ':-)' logCr: x ].
+
+"output on Transcript:
+#(0 1 2)
+#(0 1 3)
+#(0 1 4)
+#(0 2 3)
+#(0 2 4)
+#(0 3 4)
+#(1 2 3)
+#(1 2 4)
+#(1 3 4)
+#(2 3 4)"
diff --git a/Task/Combinations/Tcl/combinations.tcl b/Task/Combinations/Tcl/combinations.tcl
new file mode 100644
index 0000000000..71107a5f0c
--- /dev/null
+++ b/Task/Combinations/Tcl/combinations.tcl
@@ -0,0 +1,21 @@
+proc comb {m n} {
+    set set [list]
+    for {set i 0} {$i < $n} {incr i} {lappend set $i}
+    return [combinations $set $m]
+}
+proc combinations {list size} {
+    if {$size == 0} {
+        return [list [list]]
+    }
+    set retval {}
+    for {set i 0} {($i + $size) <= [llength $list]} {incr i} {
+        set firstElement [lindex $list $i]
+        set remainingElements [lrange $list [expr {$i + 1}] end]
+        foreach subset [combinations $remainingElements [expr {$size - 1}]] {
+            lappend retval [linsert $subset 0 $firstElement]
+        }
+    }
+    return $retval
+}
+
+comb 3 5 ;# ==> {0 1 2} {0 1 3} {0 1 4} {0 2 3} {0 2 4} {0 3 4} {1 2 3} {1 2 4} {1 3 4} {2 3 4}
diff --git a/Task/Command-line-arguments/0DESCRIPTION b/Task/Command-line-arguments/0DESCRIPTION
new file mode 100644
index 0000000000..9b66dd4c75
--- /dev/null
+++ b/Task/Command-line-arguments/0DESCRIPTION
@@ -0,0 +1,9 @@
+{{selection|Short Circuit|Console Program Basics}} [[Category:Basic language learning]][[Category:Programming environment operations]][[Category:Initialization]]Retrieve the list of command-line arguments given to the program. For programs that only print the arguments when run directly, see [[Scripted main]].
+
+See also [[Program name]].
+
+For parsing command line arguments intelligently, see [[Parsing command-line arguments]].
+
+Example command line:
+
+ myprogram -c "alpha beta" -h "gamma"
diff --git a/Task/Command-line-arguments/ALGOL-68/command-line-arguments.alg b/Task/Command-line-arguments/ALGOL-68/command-line-arguments.alg
new file mode 100644
index 0000000000..bd3df8a891
--- /dev/null
+++ b/Task/Command-line-arguments/ALGOL-68/command-line-arguments.alg
@@ -0,0 +1,5 @@
+main:(
+  FOR i TO argc DO
+    printf(($"the argument #"g(-0)" is "gl$, i, argv(i)))
+  OD
+)
diff --git a/Task/Command-line-arguments/AWK/command-line-arguments.awk b/Task/Command-line-arguments/AWK/command-line-arguments.awk
new file mode 100644
index 0000000000..4b1964d2d1
--- /dev/null
+++ b/Task/Command-line-arguments/AWK/command-line-arguments.awk
@@ -0,0 +1,8 @@
+#!/usr/bin/awk -f
+
+BEGIN {
+  print "There are " ARGC "command line parameters"
+  for(l=1; largs2 foo "bar baz" quux
+fn=d:\bin\args2.cmd
+p0=args2
+p*=foo "bar baz" quux
+p#=3
+p1=foo
+p2=bar baz
+p3=quux
diff --git a/Task/Command-line-arguments/Bracmat/command-line-arguments.bracmat b/Task/Command-line-arguments/Bracmat/command-line-arguments.bracmat
new file mode 100644
index 0000000000..411e62dc3d
--- /dev/null
+++ b/Task/Command-line-arguments/Bracmat/command-line-arguments.bracmat
@@ -0,0 +1 @@
+whl'(arg$:?a&out$(str$("next arg=" !a)))
diff --git a/Task/Command-line-arguments/C++/command-line-arguments.cpp b/Task/Command-line-arguments/C++/command-line-arguments.cpp
new file mode 100644
index 0000000000..1aa4114bf1
--- /dev/null
+++ b/Task/Command-line-arguments/C++/command-line-arguments.cpp
@@ -0,0 +1,11 @@
+#include 
+
+int main(int argc, char* argv[])
+{
+  std::cout << "This program is named " << argv[0] << std::endl;
+  std::cout << "There are " << argc-1 << " arguments given." << std::endl;
+  for (int i = 1; i < argc; ++i)
+    std::cout << "the argument #" << i << " is " << argv[i] << std::endl;
+
+  return 0;
+}
diff --git a/Task/Command-line-arguments/C/command-line-arguments.c b/Task/Command-line-arguments/C/command-line-arguments.c
new file mode 100644
index 0000000000..10c6f1aabd
--- /dev/null
+++ b/Task/Command-line-arguments/C/command-line-arguments.c
@@ -0,0 +1,11 @@
+#include 
+#include 
+
+int main(int argc, char* argv[])
+{
+  int i;
+  (void) printf("This program is named %s.\n", argv[0]);
+  for (i = 1; i < argc; ++i)
+    (void) printf("the argument #%d is %s\n", i, argv[i]);
+  return EXIT_SUCCESS;
+}
diff --git a/Task/Command-line-arguments/Clean/command-line-arguments.clean b/Task/Command-line-arguments/Clean/command-line-arguments.clean
new file mode 100644
index 0000000000..ed00aa2c48
--- /dev/null
+++ b/Task/Command-line-arguments/Clean/command-line-arguments.clean
@@ -0,0 +1,3 @@
+import ArgEnv
+
+Start = getCommandLine
diff --git a/Task/Command-line-arguments/Clojure/command-line-arguments.clj b/Task/Command-line-arguments/Clojure/command-line-arguments.clj
new file mode 100644
index 0000000000..51902be524
--- /dev/null
+++ b/Task/Command-line-arguments/Clojure/command-line-arguments.clj
@@ -0,0 +1 @@
+(dorun (map println *command-line-args*))
diff --git a/Task/Command-line-arguments/Common-Lisp/command-line-arguments.lisp b/Task/Command-line-arguments/Common-Lisp/command-line-arguments.lisp
new file mode 100644
index 0000000000..778f2c8e15
--- /dev/null
+++ b/Task/Command-line-arguments/Common-Lisp/command-line-arguments.lisp
@@ -0,0 +1,11 @@
+(defun argv ()
+  (or
+   #+clisp (ext:argv)
+   #+sbcl sb-ext:*posix-argv*
+   #+clozure (ccl::command-line-arguments)
+   #+gcl si:*command-args*
+   #+ecl (loop for i from 0 below (si:argc) collect (si:argv i))
+   #+cmu extensions:*command-line-strings*
+   #+allegro (sys:command-line-arguments)
+   #+lispworks sys:*line-arguments-list*
+   nil))
diff --git a/Task/Command-line-arguments/D/command-line-arguments-1.d b/Task/Command-line-arguments/D/command-line-arguments-1.d
new file mode 100644
index 0000000000..18aeaf3ebb
--- /dev/null
+++ b/Task/Command-line-arguments/D/command-line-arguments-1.d
@@ -0,0 +1,6 @@
+import std.stdio ;
+
+void main(string[] args) {
+  foreach(i, e ; args[1..$])
+    writefln("#%2d : %s", i + 1, e) ;
+}
diff --git a/Task/Command-line-arguments/D/command-line-arguments-2.d b/Task/Command-line-arguments/D/command-line-arguments-2.d
new file mode 100644
index 0000000000..ef885e8a8a
--- /dev/null
+++ b/Task/Command-line-arguments/D/command-line-arguments-2.d
@@ -0,0 +1,18 @@
+import tango.text.Arguments;
+import tango.io.Stdout;
+
+void main(char[][] realArgs)
+{
+    auto args = new Arguments;
+
+    args("hello").required.params(1).requires("world");
+    args("world").params(1).aliased('w');
+
+    if (! args.parse(realArgs)) {
+        Stdout ("bad arguments");
+
+    } else {
+        Stdout("argument for --hello ") (args("hello").assigned).newline;
+        Stdout("argument for --world ") (args("world").assigned).newline;
+    }
+}
diff --git a/Task/Command-line-arguments/Deja-Vu/command-line-arguments.djv b/Task/Command-line-arguments/Deja-Vu/command-line-arguments.djv
new file mode 100644
index 0000000000..3fe96bed43
--- /dev/null
+++ b/Task/Command-line-arguments/Deja-Vu/command-line-arguments.djv
@@ -0,0 +1,11 @@
+try:
+	set :i 1
+	while true:
+		drop dup # some stack manipulation to force
+		         # a stack-empty error before printing
+		         # the next line
+		print( "Argument #" i " is:" )
+		.
+		set :i ++ i
+catch stack-empty:
+	pass #end of argument list
diff --git a/Task/Command-line-arguments/Delphi/command-line-arguments.delphi b/Task/Command-line-arguments/Delphi/command-line-arguments.delphi
new file mode 100644
index 0000000000..7908376380
--- /dev/null
+++ b/Task/Command-line-arguments/Delphi/command-line-arguments.delphi
@@ -0,0 +1,13 @@
+// The program name and the directory it was called from are in
+// param[0] , so given the axample of myprogram -c "alpha beta" -h "gamma"
+
+  for x := 0 to paramcount do
+      writeln('param[',x,'] = ',param[x]);
+
+// will yield ( assuming windows and the c drive as the only drive) :
+
+//  param[0] = c:\myprogram
+//  param[1] = -c
+//  param[2] = alpha beta
+//  param[3] = -h
+//  param[4] = gamma
diff --git a/Task/Command-line-arguments/E/command-line-arguments.e b/Task/Command-line-arguments/E/command-line-arguments.e
new file mode 100644
index 0000000000..6ece0b604d
--- /dev/null
+++ b/Task/Command-line-arguments/E/command-line-arguments.e
@@ -0,0 +1 @@
+interp.getArgs()
diff --git a/Task/Command-line-arguments/Eiffel/command-line-arguments.e b/Task/Command-line-arguments/Eiffel/command-line-arguments.e
new file mode 100644
index 0000000000..eac54efa7b
--- /dev/null
+++ b/Task/Command-line-arguments/Eiffel/command-line-arguments.e
@@ -0,0 +1,17 @@
+class
+    APPLICATION
+inherit
+    ARGUMENTS
+create
+    make
+feature {NONE} -- Initialization
+    make
+            -- Print values for arguments with options 'c' and 'h'.
+        do
+            print ("Command line argument value for option 'c' is: ")
+            print (separate_character_option_value ('c') + "%N")
+            print ("Command line argument value for option 'h' is: ")
+            print (separate_character_option_value ('h') + "%N")
+            io.read_line    -- Keep console window open
+        end
+end
diff --git a/Task/Command-line-arguments/Emacs-Lisp/command-line-arguments.l b/Task/Command-line-arguments/Emacs-Lisp/command-line-arguments.l
new file mode 100644
index 0000000000..6b0a9c3e78
--- /dev/null
+++ b/Task/Command-line-arguments/Emacs-Lisp/command-line-arguments.l
@@ -0,0 +1,2 @@
+#!/usr/bin/env emacs --script
+(dolist (arg command-line-args-left) (message arg))
diff --git a/Task/Command-line-arguments/Erlang/command-line-arguments-1.erl b/Task/Command-line-arguments/Erlang/command-line-arguments-1.erl
new file mode 100644
index 0000000000..cabbe66994
--- /dev/null
+++ b/Task/Command-line-arguments/Erlang/command-line-arguments-1.erl
@@ -0,0 +1 @@
+3> init:get_arguments().
diff --git a/Task/Command-line-arguments/Erlang/command-line-arguments-2.erl b/Task/Command-line-arguments/Erlang/command-line-arguments-2.erl
new file mode 100644
index 0000000000..e9152df66e
--- /dev/null
+++ b/Task/Command-line-arguments/Erlang/command-line-arguments-2.erl
@@ -0,0 +1,5 @@
+[{root,["/usr/erlang/erl5.5"]},
+{progname,["erl"]},
+{home,["/home/me"]},
+{c,["alpha beta"]},
+{h,["gamma"]}]
diff --git a/Task/Command-line-arguments/Erlang/command-line-arguments-3.erl b/Task/Command-line-arguments/Erlang/command-line-arguments-3.erl
new file mode 100644
index 0000000000..8adf5d60a0
--- /dev/null
+++ b/Task/Command-line-arguments/Erlang/command-line-arguments-3.erl
@@ -0,0 +1,4 @@
+4> init:get_argument(h).
+{ok,[["gamma"]]}
+5> init:get_argument(c).
+{ok,[["alpha beta"]]}
diff --git a/Task/Command-line-arguments/Euphoria/command-line-arguments.euphoria b/Task/Command-line-arguments/Euphoria/command-line-arguments.euphoria
new file mode 100644
index 0000000000..6dab5e3b51
--- /dev/null
+++ b/Task/Command-line-arguments/Euphoria/command-line-arguments.euphoria
@@ -0,0 +1,9 @@
+constant cmd = command_line()
+printf(1,"Interpreter/executable name: %s\n",{cmd[1]})
+printf(1,"Program file name: %s\n",{cmd[2]})
+if length(cmd)>2 then
+  puts(1,"Command line arguments:\n")
+  for i = 3 to length(cmd) do
+    printf(1,"#%d : %s\n",{i,cmd[i]})
+  end for
+end if
diff --git a/Task/Command-line-arguments/Forth/command-line-arguments-1.fth b/Task/Command-line-arguments/Forth/command-line-arguments-1.fth
new file mode 100644
index 0000000000..f6e4419cdd
--- /dev/null
+++ b/Task/Command-line-arguments/Forth/command-line-arguments-1.fth
@@ -0,0 +1,5 @@
+\ args.f: print each command line argument on a separate line
+: main
+  argc @ 0 do i arg type cr loop ;
+
+main bye
diff --git a/Task/Command-line-arguments/Forth/command-line-arguments-2.fth b/Task/Command-line-arguments/Forth/command-line-arguments-2.fth
new file mode 100644
index 0000000000..0c09c58a0d
--- /dev/null
+++ b/Task/Command-line-arguments/Forth/command-line-arguments-2.fth
@@ -0,0 +1,7 @@
+$ gforth args.f alpha "beta gamma" delta
+gforth
+args.f
+alpha
+beta gamma
+delta
+$
diff --git a/Task/Command-line-arguments/Fortran/command-line-arguments-1.f b/Task/Command-line-arguments/Fortran/command-line-arguments-1.f
new file mode 100644
index 0000000000..93dc144f18
--- /dev/null
+++ b/Task/Command-line-arguments/Fortran/command-line-arguments-1.f
@@ -0,0 +1,16 @@
+program command_line_arguments
+
+  implicit none
+  integer, parameter :: len_max = 256
+  integer :: i , nargs
+  character (len_max) :: arg
+
+  nargs = command_argument_count()
+  !nargs = iargc()
+  do i = 0, nargs
+    call get_command_argument (i, arg)
+    !call getarg (i, arg)
+    write (*, '(a)') trim (arg)
+  end do
+
+end program command_line_arguments
diff --git a/Task/Command-line-arguments/Fortran/command-line-arguments-2.f b/Task/Command-line-arguments/Fortran/command-line-arguments-2.f
new file mode 100644
index 0000000000..3bedaef171
--- /dev/null
+++ b/Task/Command-line-arguments/Fortran/command-line-arguments-2.f
@@ -0,0 +1,6 @@
+> ./a.out -c "alpha beta" -h "gamma"
+./a.out
+-c
+alpha beta
+-h
+gamma
diff --git a/Task/Command-line-arguments/Go/command-line-arguments.go b/Task/Command-line-arguments/Go/command-line-arguments.go
new file mode 100644
index 0000000000..e2d9506e38
--- /dev/null
+++ b/Task/Command-line-arguments/Go/command-line-arguments.go
@@ -0,0 +1,15 @@
+package main
+import (
+  "fmt"
+  "os"
+)
+
+func main() {
+  for i, x := range os.Args {
+    if i == 0 {
+      fmt.Printf("This program is named %s.\n", x)
+    } else {
+      fmt.Printf("the argument #%d is %s\n", i, x)
+    }
+  }
+}
diff --git a/Task/Command-line-arguments/Haskell/command-line-arguments.hs b/Task/Command-line-arguments/Haskell/command-line-arguments.hs
new file mode 100644
index 0000000000..d549b5755c
--- /dev/null
+++ b/Task/Command-line-arguments/Haskell/command-line-arguments.hs
@@ -0,0 +1,2 @@
+import System
+main = getArgs >>= print
diff --git a/Task/Command-line-arguments/Java/command-line-arguments.java b/Task/Command-line-arguments/Java/command-line-arguments.java
new file mode 100644
index 0000000000..38c850460c
--- /dev/null
+++ b/Task/Command-line-arguments/Java/command-line-arguments.java
@@ -0,0 +1,7 @@
+public class Arguments {
+  public static void main(String[] args) {
+     System.out.println("There are " + args.length + " arguments given.");
+     for(int i = 0; i < args.length; i++)
+        System.out.println("The argument #" + (i+1) + " is " + args[i] + " and is at index " + i);
+  }
+}
diff --git a/Task/Command-line-arguments/JavaScript/command-line-arguments-1.js b/Task/Command-line-arguments/JavaScript/command-line-arguments-1.js
new file mode 100644
index 0000000000..e0e2318a6b
--- /dev/null
+++ b/Task/Command-line-arguments/JavaScript/command-line-arguments-1.js
@@ -0,0 +1,3 @@
+var objArgs = WScript.Arguments;
+for (var i = 0; i < objArgs.length; i++)
+   WScript.Echo(objArgs.Item(i));
diff --git a/Task/Command-line-arguments/JavaScript/command-line-arguments-2.js b/Task/Command-line-arguments/JavaScript/command-line-arguments-2.js
new file mode 100644
index 0000000000..41b7a9dead
--- /dev/null
+++ b/Task/Command-line-arguments/JavaScript/command-line-arguments-2.js
@@ -0,0 +1,4 @@
+import System;
+var argv:String[] = Environment.GetCommandLineArgs();
+for (var i in argv)
+  print(argv[i]);
diff --git a/Task/Command-line-arguments/JavaScript/command-line-arguments-3.js b/Task/Command-line-arguments/JavaScript/command-line-arguments-3.js
new file mode 100644
index 0000000000..7cc09fefe4
--- /dev/null
+++ b/Task/Command-line-arguments/JavaScript/command-line-arguments-3.js
@@ -0,0 +1,2 @@
+for (var i = 0; i < arguments.length; i++)
+    print(arguments[i]);
diff --git a/Task/Command-line-arguments/Lua/command-line-arguments.lua b/Task/Command-line-arguments/Lua/command-line-arguments.lua
new file mode 100644
index 0000000000..7c459808e3
--- /dev/null
+++ b/Task/Command-line-arguments/Lua/command-line-arguments.lua
@@ -0,0 +1,6 @@
+print( "Program name:", arg[0] )
+
+print "Arguments:"
+for i = 1, #arg do
+    print( i," ", arg[i] )
+end
diff --git a/Task/Command-line-arguments/PHP/command-line-arguments.php b/Task/Command-line-arguments/PHP/command-line-arguments.php
new file mode 100644
index 0000000000..1c2fbf66f7
--- /dev/null
+++ b/Task/Command-line-arguments/PHP/command-line-arguments.php
@@ -0,0 +1,4 @@
+
diff --git a/Task/Command-line-arguments/Perl/command-line-arguments-1.pl b/Task/Command-line-arguments/Perl/command-line-arguments-1.pl
new file mode 100644
index 0000000000..4089186960
--- /dev/null
+++ b/Task/Command-line-arguments/Perl/command-line-arguments-1.pl
@@ -0,0 +1,4 @@
+my @params = @ARGV;
+my $params_size = @ARGV;
+my $second = $ARGV[1];
+my $fifth = $ARGV[4];
diff --git a/Task/Command-line-arguments/Perl/command-line-arguments-2.pl b/Task/Command-line-arguments/Perl/command-line-arguments-2.pl
new file mode 100644
index 0000000000..be09bea6d2
--- /dev/null
+++ b/Task/Command-line-arguments/Perl/command-line-arguments-2.pl
@@ -0,0 +1,5 @@
+use Getopt::Long;
+GetOptions (
+    'help|h'     => \my $help,
+    'verbose|v'  => \my $verbose,
+);
diff --git a/Task/Command-line-arguments/PicoLisp/command-line-arguments.l b/Task/Command-line-arguments/PicoLisp/command-line-arguments.l
new file mode 100644
index 0000000000..8cd2f12923
--- /dev/null
+++ b/Task/Command-line-arguments/PicoLisp/command-line-arguments.l
@@ -0,0 +1,10 @@
+#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
+
+(de c ()
+   (prinl "Got 'c': " (opt)) )
+
+(de h ()
+   (prinl "Got 'h': " (opt)) )
+
+(load T)
+(bye)
diff --git a/Task/Command-line-arguments/Python/command-line-arguments.py b/Task/Command-line-arguments/Python/command-line-arguments.py
new file mode 100644
index 0000000000..27238345cf
--- /dev/null
+++ b/Task/Command-line-arguments/Python/command-line-arguments.py
@@ -0,0 +1,4 @@
+import sys
+program_name = sys.argv[0]
+arguments = sys.argv[1:]
+count = len(arguments)
diff --git a/Task/Command-line-arguments/R/command-line-arguments-1.r b/Task/Command-line-arguments/R/command-line-arguments-1.r
new file mode 100644
index 0000000000..86e74f33d8
--- /dev/null
+++ b/Task/Command-line-arguments/R/command-line-arguments-1.r
@@ -0,0 +1 @@
+R CMD BATCH --vanilla --slave '--args a=1 b=c(2,5,6)' test.r test.out
diff --git a/Task/Command-line-arguments/R/command-line-arguments-2.r b/Task/Command-line-arguments/R/command-line-arguments-2.r
new file mode 100644
index 0000000000..e6255ba5fa
--- /dev/null
+++ b/Task/Command-line-arguments/R/command-line-arguments-2.r
@@ -0,0 +1,18 @@
+# Read the commandline arguments
+args <- (commandArgs(TRUE))
+
+# args is now a list of character vectors
+# First check to see if any arguments were passed,
+# then evaluate each argument.
+if (length(args)==0) {
+    print("No arguments supplied.")
+    # Supply default values
+    a <- 1
+    b <- c(1,1,1)
+} else {
+    for (i in 1:length(args)) {
+         eval(parse(text=args[[i]]))
+    }
+}
+print(a*2)
+print(b*3)
diff --git a/Task/Command-line-arguments/REXX/command-line-arguments-1.rexx b/Task/Command-line-arguments/REXX/command-line-arguments-1.rexx
new file mode 100644
index 0000000000..2355afa823
--- /dev/null
+++ b/Task/Command-line-arguments/REXX/command-line-arguments-1.rexx
@@ -0,0 +1,2 @@
+say 'command arguments:'
+say arg(1)
diff --git a/Task/Command-line-arguments/REXX/command-line-arguments-2.rexx b/Task/Command-line-arguments/REXX/command-line-arguments-2.rexx
new file mode 100644
index 0000000000..bd43c95964
--- /dev/null
+++ b/Task/Command-line-arguments/REXX/command-line-arguments-2.rexx
@@ -0,0 +1,22 @@
+parse arg aaa                          /*get the arguments.        */
+                                       /*another version:          */
+                                       /*  aaa=arg(1)              */
+say 'command arguments:'
+say aaa
+
+opts=''                                /*placeholder for options.  */
+data=''                                /*placeholder for data.     */
+
+  do j=1 to words(aaa)
+  x=word(aaa,j)
+  if left(x,1)=='-' then opts=opts x   /*Option?  Then add to opts.*/
+                    else data=data x   /*Must be data. Add to data.*/
+  end
+
+        /*the above process adds a leading blank to  OPTS and  DATA*/
+
+opts=strip(opts,'L')                   /*strip leading blanks.     */
+data=strip(data,'l')                   /*strip leading blanks.     */
+say
+say 'options='opts
+say '   data='data
diff --git a/Task/Command-line-arguments/Racket/command-line-arguments-1.rkt b/Task/Command-line-arguments/Racket/command-line-arguments-1.rkt
new file mode 100644
index 0000000000..5c2f2ff648
--- /dev/null
+++ b/Task/Command-line-arguments/Racket/command-line-arguments-1.rkt
@@ -0,0 +1,2 @@
+#lang racket
+(current-command-line-arguments)
diff --git a/Task/Command-line-arguments/Racket/command-line-arguments-2.rkt b/Task/Command-line-arguments/Racket/command-line-arguments-2.rkt
new file mode 100644
index 0000000000..ddc2387297
--- /dev/null
+++ b/Task/Command-line-arguments/Racket/command-line-arguments-2.rkt
@@ -0,0 +1,3 @@
+#lang racket
+(for ([arg (current-command-line-arguments)])
+  (displayln arg))
diff --git a/Task/Command-line-arguments/Ruby/command-line-arguments.rb b/Task/Command-line-arguments/Ruby/command-line-arguments.rb
new file mode 100644
index 0000000000..b7c0bbc63d
--- /dev/null
+++ b/Task/Command-line-arguments/Ruby/command-line-arguments.rb
@@ -0,0 +1,2 @@
+#! /usr/bin/env ruby
+p ARGV
diff --git a/Task/Command-line-arguments/Sather/command-line-arguments.sa b/Task/Command-line-arguments/Sather/command-line-arguments.sa
new file mode 100644
index 0000000000..d2b3f08c75
--- /dev/null
+++ b/Task/Command-line-arguments/Sather/command-line-arguments.sa
@@ -0,0 +1,7 @@
+class MAIN is
+  main(args:ARRAY{STR}) is
+    loop
+      #OUT + args.elt! + "\n";
+    end;
+  end;
+end;
diff --git a/Task/Command-line-arguments/Scala/command-line-arguments-1.scala b/Task/Command-line-arguments/Scala/command-line-arguments-1.scala
new file mode 100644
index 0000000000..f92aab43c8
--- /dev/null
+++ b/Task/Command-line-arguments/Scala/command-line-arguments-1.scala
@@ -0,0 +1,5 @@
+object T {
+  def main(args: Array[String]) {
+    println("Received the following arguments": + args.mkString("", ", ", "."))
+  }
+}
diff --git a/Task/Command-line-arguments/Scala/command-line-arguments-2.scala b/Task/Command-line-arguments/Scala/command-line-arguments-2.scala
new file mode 100644
index 0000000000..e547819eec
--- /dev/null
+++ b/Task/Command-line-arguments/Scala/command-line-arguments-2.scala
@@ -0,0 +1 @@
+println("My arguments are: "+argv.mkString("", ", ", "."))
diff --git a/Task/Command-line-arguments/Scheme/command-line-arguments.ss b/Task/Command-line-arguments/Scheme/command-line-arguments.ss
new file mode 100644
index 0000000000..79c693e060
--- /dev/null
+++ b/Task/Command-line-arguments/Scheme/command-line-arguments.ss
@@ -0,0 +1,2 @@
+ (define (main args)
+  (for-each (lambda (arg) (display arg) (newline)) args))
diff --git a/Task/Command-line-arguments/Smalltalk/command-line-arguments-1.st b/Task/Command-line-arguments/Smalltalk/command-line-arguments-1.st
new file mode 100644
index 0000000000..8c8d2d8d26
--- /dev/null
+++ b/Task/Command-line-arguments/Smalltalk/command-line-arguments-1.st
@@ -0,0 +1,3 @@
+(1 to: Smalltalk getArgc) do: [ :i |
+  (Smalltalk getArgv: i) displayNl
+]
diff --git a/Task/Command-line-arguments/Smalltalk/command-line-arguments-2.st b/Task/Command-line-arguments/Smalltalk/command-line-arguments-2.st
new file mode 100644
index 0000000000..513ccc3afc
--- /dev/null
+++ b/Task/Command-line-arguments/Smalltalk/command-line-arguments-2.st
@@ -0,0 +1 @@
+Smalltalk commandLineArguments printCR
diff --git a/Task/Command-line-arguments/Tcl/command-line-arguments.tcl b/Task/Command-line-arguments/Tcl/command-line-arguments.tcl
new file mode 100644
index 0000000000..0827817f9e
--- /dev/null
+++ b/Task/Command-line-arguments/Tcl/command-line-arguments.tcl
@@ -0,0 +1,3 @@
+if { $argc > 1 } {
+    puts [lindex $argv 1]
+}
diff --git a/Task/Comments/C++/comments-1.cpp b/Task/Comments/C++/comments-1.cpp
new file mode 100644
index 0000000000..35915f268d
--- /dev/null
+++ b/Task/Comments/C++/comments-1.cpp
@@ -0,0 +1 @@
+// This is a comment
diff --git a/Task/Comments/C++/comments-2.cpp b/Task/Comments/C++/comments-2.cpp
new file mode 100644
index 0000000000..546894d1b7
--- /dev/null
+++ b/Task/Comments/C++/comments-2.cpp
@@ -0,0 +1 @@
+// This is a valid comment // with a "nested" comment
diff --git a/Task/Comments/C++/comments-3.cpp b/Task/Comments/C++/comments-3.cpp
new file mode 100644
index 0000000000..8fd52ef5e3
--- /dev/null
+++ b/Task/Comments/C++/comments-3.cpp
@@ -0,0 +1,3 @@
+#define FOO \
+  (macro text) // comment
+  (no more macro text)
diff --git a/Task/Comments/COBOL/comments.cobol b/Task/Comments/COBOL/comments.cobol
new file mode 100644
index 0000000000..e019391287
--- /dev/null
+++ b/Task/Comments/COBOL/comments.cobol
@@ -0,0 +1 @@
+      * an asterisk in 7th column comments the line out
diff --git a/Task/Comments/Chef/comments.chef b/Task/Comments/Chef/comments.chef
new file mode 100644
index 0000000000..7fac0cad2d
--- /dev/null
+++ b/Task/Comments/Chef/comments.chef
@@ -0,0 +1,16 @@
+Comment Stew.
+
+This is a comment.
+The other comment is a loop, but you can name it anything (single word only).
+You can also name ingredients as comments
+This is pseudocode.
+
+Ingredients.
+Ingredient list
+
+Method.
+Methods.
+SingleWordCommentOne the Ingredient.
+Methods.
+SingleWordCommentTwo until SingleWordCommentOned.
+Methods.
diff --git a/Task/Comments/Clean/comments-1.clean b/Task/Comments/Clean/comments-1.clean
new file mode 100644
index 0000000000..18acfe6c74
--- /dev/null
+++ b/Task/Comments/Clean/comments-1.clean
@@ -0,0 +1,2 @@
+Start = /* This is a multi-
+           line comment     */ 17 // This is a single-line comment
diff --git a/Task/Comments/Clean/comments-2.clean b/Task/Comments/Clean/comments-2.clean
new file mode 100644
index 0000000000..f0e2f1ec3e
--- /dev/null
+++ b/Task/Comments/Clean/comments-2.clean
@@ -0,0 +1 @@
+Start = /* This is a comment /* Nested comment */ still a comment */ 17
diff --git a/Task/Comments/ColdFusion/comments-1.cfm b/Task/Comments/ColdFusion/comments-1.cfm
new file mode 100644
index 0000000000..c9f8ffa4ab
--- /dev/null
+++ b/Task/Comments/ColdFusion/comments-1.cfm
@@ -0,0 +1,5 @@
+As ColdFusion's grammar is based around HTML syntax, commenting is similar to HTML.  Note that in the examples below, you will need to remove the space between the < and the !.
+< !--- This is a comment.  Nothing in this tag can be seen by the end user.
+       Note the three-or-greater dashes to open and close the tag. --->
+< !--  This is an HTML comment.  Any HTML between the opening and closing of the tag will be ignored, but any ColdFusion code will still run.
+       Note that in the popular FuseBox framework for ColdFusion, the circuit.xml files require that you use this style of comment. -->
diff --git a/Task/Comments/ColdFusion/comments-2.cfm b/Task/Comments/ColdFusion/comments-2.cfm
new file mode 100644
index 0000000000..1ec09949cd
--- /dev/null
+++ b/Task/Comments/ColdFusion/comments-2.cfm
@@ -0,0 +1,2 @@
+/* This is a comment */
+// This is also a comment
diff --git a/Task/Comments/Common-Lisp/comments-1.lisp b/Task/Comments/Common-Lisp/comments-1.lisp
new file mode 100644
index 0000000000..949e561cb4
--- /dev/null
+++ b/Task/Comments/Common-Lisp/comments-1.lisp
@@ -0,0 +1,12 @@
+;;;; This code implements the foo and bar functions
+
+;;; The foo function calls bar on the first argument and multiplies the result by the second.
+;;; The arguments are two integers
+(defun foo (a b)
+   ;; Call bar and multiply
+   (* (bar a) ; Calling bar
+      b))
+
+;;; The bar function simply adds 3 to the argument
+(defun bar (n)
+   (+ n 3))
diff --git a/Task/Comments/Common-Lisp/comments-2.lisp b/Task/Comments/Common-Lisp/comments-2.lisp
new file mode 100644
index 0000000000..d0e052790f
--- /dev/null
+++ b/Task/Comments/Common-Lisp/comments-2.lisp
@@ -0,0 +1,7 @@
+(defun bar (n)
+  "Add 3 to the argument."
+  (+ n 3))
+
+(defclass button (widget)
+  (label action)
+  (:documentation "This is a push-button widget."))
diff --git a/Task/Comments/D/comments-1.d b/Task/Comments/D/comments-1.d
new file mode 100644
index 0000000000..ab92f3d454
--- /dev/null
+++ b/Task/Comments/D/comments-1.d
@@ -0,0 +1,3 @@
+/* This is a simple
+C-style comment */
+// this also is
diff --git a/Task/Comments/D/comments-2.d b/Task/Comments/D/comments-2.d
new file mode 100644
index 0000000000..2ad750b7fc
--- /dev/null
+++ b/Task/Comments/D/comments-2.d
@@ -0,0 +1,5 @@
+/+ Nestable comment
+  /+ See?
+  +/
++/
+Yay! I'm code!
diff --git a/Task/Comments/D/comments-3.d b/Task/Comments/D/comments-3.d
new file mode 100644
index 0000000000..a97bb44829
--- /dev/null
+++ b/Task/Comments/D/comments-3.d
@@ -0,0 +1,5 @@
+/// I'm documentation!
+/** I'm multi-
+line documentation. */
+/++ And I
+  /++ can be nested +/ +/
diff --git a/Task/Comments/D/comments-4.d b/Task/Comments/D/comments-4.d
new file mode 100644
index 0000000000..3c660331cd
--- /dev/null
+++ b/Task/Comments/D/comments-4.d
@@ -0,0 +1,11 @@
+/*****************************************
+* This function solves world hunger.
+* Examples:
+* ----------------------------------------
+* feed_world (earth);
+* ----------------------------------------
+* Date: May 4, 2011
+* Bugs: Does not solve world thirst.
+* See_Also:
+*    SoylentGreen
+* Authors: J. Random Hacker. */
diff --git a/Task/Comments/DWScript/comments.dwscript b/Task/Comments/DWScript/comments.dwscript
new file mode 100644
index 0000000000..2532a3da3e
--- /dev/null
+++ b/Task/Comments/DWScript/comments.dwscript
@@ -0,0 +1,10 @@
+(* This is a comment.
+   It may extend across multiple lines. *)
+
+{ Alternatively curly braces
+  can be used. }
+
+/* C-style multi-line comments
+   are supported  */
+
+// and single-line C++ style comments too
diff --git a/Task/Comments/Delphi/comments.delphi b/Task/Comments/Delphi/comments.delphi
new file mode 100644
index 0000000000..1d7652b89c
--- /dev/null
+++ b/Task/Comments/Delphi/comments.delphi
@@ -0,0 +1 @@
+// single line comment
diff --git a/Task/Comments/Deluge/comments.deluge b/Task/Comments/Deluge/comments.deluge
new file mode 100644
index 0000000000..1d7652b89c
--- /dev/null
+++ b/Task/Comments/Deluge/comments.deluge
@@ -0,0 +1 @@
+// single line comment
diff --git a/Task/Comments/E/comments.e b/Task/Comments/E/comments.e
new file mode 100644
index 0000000000..4ddba7730f
--- /dev/null
+++ b/Task/Comments/E/comments.e
@@ -0,0 +1,6 @@
+# This is a regular comment.
+
+? "This is an Updoc comment, which
+> is an executable example or test case.".split(" ")
+# value: ["This", "is", "an", "Updoc", "comment,", "which
+#        is", "an", "executable", "example", "or", "test", "case."]
diff --git a/Task/Comments/Ela/comments.ela b/Task/Comments/Ela/comments.ela
new file mode 100644
index 0000000000..32cd4a06e6
--- /dev/null
+++ b/Task/Comments/Ela/comments.ela
@@ -0,0 +1,4 @@
+//single line comment
+
+/*multiple line
+comment*/
diff --git a/Task/Comments/Emacs-Lisp/comments-1.l b/Task/Comments/Emacs-Lisp/comments-1.l
new file mode 100644
index 0000000000..8b2be0f66b
--- /dev/null
+++ b/Task/Comments/Emacs-Lisp/comments-1.l
@@ -0,0 +1 @@
+; This is a comment
diff --git a/Task/Comments/Emacs-Lisp/comments-2.l b/Task/Comments/Emacs-Lisp/comments-2.l
new file mode 100644
index 0000000000..6dc43a2da3
--- /dev/null
+++ b/Task/Comments/Emacs-Lisp/comments-2.l
@@ -0,0 +1,2 @@
+"This is effectively a comment,
+if used at a place where the result is ignored"
diff --git a/Task/Comments/Emacs-Lisp/comments-3.l b/Task/Comments/Emacs-Lisp/comments-3.l
new file mode 100644
index 0000000000..92c36f681a
--- /dev/null
+++ b/Task/Comments/Emacs-Lisp/comments-3.l
@@ -0,0 +1,3 @@
+(defun subtract-second-from-first (x y)
+  "This function subtracts its second argument from its first argument."
+  (- y x))
diff --git a/Task/Comments/Euphoria/comments-1.euphoria b/Task/Comments/Euphoria/comments-1.euphoria
new file mode 100644
index 0000000000..5e7aa74e92
--- /dev/null
+++ b/Task/Comments/Euphoria/comments-1.euphoria
@@ -0,0 +1 @@
+-- This is a comment
diff --git a/Task/Comments/Euphoria/comments-2.euphoria b/Task/Comments/Euphoria/comments-2.euphoria
new file mode 100644
index 0000000000..3c91c2172c
--- /dev/null
+++ b/Task/Comments/Euphoria/comments-2.euphoria
@@ -0,0 +1,3 @@
+/*
+This is a comment
+*/
diff --git a/Task/Compare-sorting-algorithms-performance/0DESCRIPTION b/Task/Compare-sorting-algorithms-performance/0DESCRIPTION
new file mode 100644
index 0000000000..a87d499a30
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/0DESCRIPTION
@@ -0,0 +1,24 @@
+Measure a relative performance of sorting algorithms implementations.
+
+Plot '''execution time vs. input sequence length''' dependencies for various implementation of sorting algorithm and different input sequence types ([[#Figures: log2( time in microseconds ) vs. log2( sequence length )|example figures]]).
+
+Consider three type of input sequences:
+* ones: sequence of all ''1'''s. Example: {1, 1, 1, 1, 1}
+* range: ascending sequence, i.e. already sorted. Example: {1, 2, 3, 10, 15}
+* shuffled range: sequence with elements randomly distributed. Example: {5, 3, 9, 6, 8}
+
+Consider at least two different sorting functions (different algorithms or/and different implementation of the same algorithm).
+For example, consider [[Bubble Sort]], [[Insertion sort]], [[Quicksort]] or/and implementations of Quicksort with different pivot selection mechanisms. Where possible, use existing implementations.
+
+Preliminary subtask:
+* [[Bubble Sort]], [[Insertion sort]], [[Quicksort]], [[Radix sort]], [[Shell sort]]
+* [[Query Performance]]
+* [[Write float arrays to a text file]]
+* [[Plot x, y arrays]]
+* [[Polynomial Fitting]]
+
+General steps:
+# Define sorting routines to be considered.
+# Define appropriate sequence generators and write timings.
+# Plot timings.
+# What conclusions about relative performance of the sorting routines could be made based on the plots?
diff --git a/Task/Compare-sorting-algorithms-performance/1META.yaml b/Task/Compare-sorting-algorithms-performance/1META.yaml
new file mode 100644
index 0000000000..556e45905d
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/1META.yaml
@@ -0,0 +1,2 @@
+---
+note: Sorting
diff --git a/Task/Compare-sorting-algorithms-performance/AutoHotkey/compare-sorting-algorithms-performance.ahk b/Task/Compare-sorting-algorithms-performance/AutoHotkey/compare-sorting-algorithms-performance.ahk
new file mode 100644
index 0000000000..74104e2b8c
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/AutoHotkey/compare-sorting-algorithms-performance.ahk
@@ -0,0 +1,304 @@
+; BUGGY - FIX
+
+#Persistent
+#SingleInstance OFF
+SetBatchLines, -1
+SortMethods := "Bogo,Bubble,Cocktail,Counting,Gnome,Insertion,Merge,Permutation,Quick,Selection,Shell,BuiltIn"
+Gui, Add, Edit, vInput, numbers,separated,by,commas,without,spaces,afterwards
+Loop, PARSE, SortMethods, `,
+	Gui, Add, CheckBox, v%A_LoopField%, %A_LoopField% Sort
+Gui, Add, Button, gTest, Test!
+Gui, Show,, SortTest!
+Return
+Test:
+SplashTextOn,,, Test Commencing
+Sleep 2500
+SplashTextOff
+Gui, +OwnDialogs
+Gui, Submit, NoHide
+Loop, PARSE, SortMethods, `,
+{
+	If (%A_LoopField%)
+	{
+		DllCall("QueryPerformanceCounter", "Int64 *", %A_LoopField%Begin)
+		%A_LoopField%Out := %A_LoopField%Sort(Input)
+		DllCall("QueryPerformanceCounter", "Int64 *", %A_LoopField%Time)
+		%A_LoopField%End := %A_LoopField%Begin + %A_LoopField%Time
+		%A_LoopField%Time -= %A_LoopField%Begin
+	}
+}
+Time := ""
+Loop, PARSE, SortMethods, `,
+	If (%A_LoopField%)
+		Time .= A_LoopField . " Sort: " . %A_LoopField%Time . "`t`t" . %A_LoopField%Out . "`r`n"
+MsgBox,, Results!, %Time%
+Return
+
+
+
+; Sorting funtions (Bogo, Bubble, Cocktail, Counting, Gnome, Insertion, Merge, Permutation, Quick, Selection, Shell, BuiltIn):
+
+BogoSort(var)
+{
+	sorted := 1
+	Loop, Parse, var
+	{
+		current := A_LoopField
+		rest := SubStr(var, A_Index)
+		Loop, Parse, rest
+		{
+			If (current > A_LoopField)
+			sorted := 0
+		}
+	}
+	While !sorted {
+		sorted := 1
+		Loop, Parse, var, `,
+		{
+			current := A_LoopField
+			rest := SubStr(var, A_Index)
+			Loop, Parse, rest, `,
+			{
+				If (current > A_LoopField)
+				sorted := 0
+			}
+		}
+
+		Sort, var, D`, Random
+	}
+	Return var
+}
+
+BubbleSort(var)
+{
+	StringSplit, array, var, `,
+	hasChanged = 1
+	size := array0
+	While hasChanged
+	{
+		hasChanged = 0
+		Loop, % (size - 1)
+		{
+			i := array%A_Index%
+			aj := A_Index + 1
+			j := array%aj%
+			If (j < i)
+			{
+				temp := array%A_Index%
+				array%A_Index% := array%aj%
+				array%aj% := temp
+				hasChanged = 1
+			}
+		}
+	}
+	Loop, % size
+	sorted .= "," . array%A_Index%
+	Return substr(sorted,2)
+}
+
+CocktailSort(var)
+{
+	StringSplit array, var, `,
+	i0 := 1, i1 := array0
+	Loop
+	{
+		Changed =
+		Loop % i1-- -i0 {
+			j := i0+A_Index, i := j-1
+			If (array%j% < array%i%)
+				t := array%i%, array%i% := array%j%, array%j% := t
+				,Changed = 1
+		}
+		IfEqual Changed,, Break
+		Loop % i1-i0++
+		{
+			i := i1-A_Index, j := i+1
+			If (array%j% < array%i%)
+			t := array%i%, array%i% := array%j%, array%j% := t
+			,Changed = 1
+		}
+		IfEqual Changed,, Break
+	}
+	Loop % array0
+		sorted .= "," . array%A_Index%
+	Return SubStr(sorted,2)
+}
+
+CountingSort(var)
+{
+	max := min := substr(var, 1, instr(var, ","))
+	Loop, parse, var, `,
+	{
+		If (A_LoopField > max)
+			max := A_LoopField
+
+		Else If (A_LoopField < min)
+			min := A_LoopField
+	}
+	Loop % max-min+1
+		i := A_Index-1, a%i% := 0
+	Loop, Parse, var, `,
+		i := A_LoopField-min, a%i%++
+	Loop % max-min+1
+	{
+		i := A_Index-1, v := i+min
+		Loop % a%i%
+			t .= "," v
+	}
+	Return SubStr(t,2)
+}
+
+GnomeSort(var) {
+	StringSplit, a, var, `,
+	i := 2, j := 3
+	While i <= a0 {
+		u := i-1
+		If (a%u% < a%i%)
+			i := j, j := j+1
+		Else {
+			t := a%u%, a%u% := a%i%, a%i% := t
+			If (--i = 1)
+				i := j, j++
+		}
+	}
+	Loop % a0
+	sorted .= "," . a%A_Index%
+	Return SubStr(sorted,2)
+}
+
+InsertionSort(var) {
+	StringSplit, a, var, `,
+	Loop % a0-1 {
+		i := A_Index+1, v := a%i%, j := i-1
+		While j>0 and a%j%>v
+			u := j+1, a%u% := a%j%, j--
+		u := j+1, a%u% := v
+	}
+	Loop % a0
+	sorted .= "," . a%A_Index%
+	Return SubStr(sorted,2)
+}
+
+
+MergeSort(var) {
+	StringReplace, t, var, `,,, UseErrorLevel
+	L := ((t = "") ? 0 : ErrorLevel+1)
+	If (2 > L)
+		Return var
+	StringGetPos, p, var, `,, % "L" L//2
+	list0 := MergeSort(SubStr(var,1,p))
+	list1 := MergeSort(SubStr(var,p+2))
+	If (list0 = "")
+		Return list1
+	Else If (list1 = "")
+		Return list0
+	list := list0
+	i0 := (p0 := InStr(list,",",0,i:=p0+1)) ? SubStr(list,i,p0-i) : SubStr(list,i)
+	list := list1
+	i1 := (p1 := InStr(list,",",0,i:=p1+1)) ? SubStr(list,i,p1-i) : SubStr(list,i)
+	Loop  {
+		i := i0>i1
+		list .= "," i%i%
+		If (p%i%) {
+			list := list%i%
+			i%i% := (p%i% := InStr(list,",",0,i:=p%i%+1)) ? SubStr(list,i,p%i%-i) : SubStr(list,i)
+		}
+		Else {
+			i ^= 1
+			rtv := SubStr(list "," i%i% (p%i% ? "," SubStr(list%i%,p%i%+1) : ""), 2)
+		}
+	}
+	Return rtv
+}
+
+PermutationSort(var) {
+	static a:="a",v:="v"
+	StringSplit, a, var, `,
+	v0 := a0
+	Loop %v0%
+		v%A_Index% := A_Index
+	unsorted := 0
+	Loop % %a%0-1 {
+		i := %v%%A_Index%, j := A_Index+1, j := %v%%j%
+		If (%a%%i% > %a%%j%)
+			unSorted := 1
+	}
+	While unSorted {
+		i := %v%0, i1 := i-1
+		While %v%%i1% >= %v%%i% {
+			--i, --i1
+			IfLess i1,1, Return 1
+		}
+		j := %v%0
+		While %v%%j% <= %v%%i1%
+			--j
+		t := %v%%i1%, %v%%i1% := %v%%j%, %v%%j% := t,  j := %v%0
+		While i < j
+			t := %v%%i%, %v%%i% := %v%%j%, %v%%j% := t, ++i, --j
+		unsorted := 0
+		Loop % %a%0-1 {
+			i := %v%%A_Index%, j := A_Index+1, j := %v%%j%
+			If (%a%%i% > %a%%j%)
+				unSorted := 1
+		}
+	}
+	Loop % a0
+		i := v%A_Index%, sorted .= "," . a%i%
+	Return SubStr(sorted,2)
+}
+
+QuickSort(var)
+{
+	StringSplit, list, var, `,
+	If (list0 <= 1)
+		Return list
+	pivot := list1
+	Loop, Parse, var, `,
+	{
+		If (A_LoopField < pivot)
+			less .= "," . A_LoopField
+		Else If (A_LoopField > pivot)
+			more .= "," . A_LoopField
+		Else
+			pivotlist .= "," . A_LoopField
+	}
+	less := QuickSort(substr(less,2))
+	more := QuickSort(substr(more,2))
+	Return substr(less,2) . pivotList . more
+}
+
+SelectionSort(var) {
+	StringSplit, a, var, `,
+	Loop % a0-1 {
+		i := A_Index, mn := a%i%, j := m := i
+		Loop % a0-i {
+			j++
+			If (a%j% < mn)
+				mn := a%j%, m := j
+		}
+		t := a%i%, a%i% := a%m%, a%m% := t
+	}
+	Loop % a0
+		sorted .= "," . a%A_Index%
+	Return SubStr(sorted,2)
+}
+
+ShellSort(var) {
+	StringSplit, a, var, `,
+	inc := a0
+	While inc:=round(inc/2.2)
+		Loop % a0-inc {
+			i := A_Index+inc, t := a%i%, j := i, k := j-inc
+			While j > inc && a%k% > t
+				a%j% := a%k%, j := k, k -= inc
+			a%j% := t
+		}
+	Loop % a0
+		s .= "," . a%A_Index%
+	Return SubStr(s,2)
+}
+
+BuiltInSort(var) {
+	Sort, var, N D`,
+	Return var
+}
diff --git a/Task/Compare-sorting-algorithms-performance/BBC-BASIC/compare-sorting-algorithms-performance.bbc b/Task/Compare-sorting-algorithms-performance/BBC-BASIC/compare-sorting-algorithms-performance.bbc
new file mode 100644
index 0000000000..309b2b5604
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/BBC-BASIC/compare-sorting-algorithms-performance.bbc
@@ -0,0 +1,163 @@
+      HIMEM = PAGE + 2000000
+      INSTALL @lib$+"SORTLIB"
+      INSTALL @lib$+"TIMERLIB"
+      Sort% = FN_sortinit(0,0)
+      Timer% = FN_ontimer(1000, PROCtimer, 1)
+
+      PRINT "Array size:", 1000, 10000, 100000
+      @% = &2020A
+
+      FOR patt% = 1 TO 4
+        CASE patt% OF
+          WHEN 1: PRINT '"Data set to all ones:"
+          WHEN 2: PRINT '"Data ascending sequence:"
+          WHEN 3: PRINT '"Data randomly shuffled:"
+          WHEN 4: PRINT '"Data descending sequence:"
+        ENDCASE
+
+        FOR type% = 1 TO 6
+          CASE type% OF
+            WHEN 1: PRINT "Internal (lib)";
+            WHEN 2: PRINT "Quicksort   ";
+            WHEN 3: PRINT "Radix sort  ";
+            WHEN 4: PRINT "Shellsort   ";
+            WHEN 5: PRINT "Bubblesort  ";
+            WHEN 6: PRINT "Insertion sort";
+          ENDCASE
+
+          FOR power% = 3 TO 5
+            PROCsorttest(patt%, type%, 10^power%)
+          NEXT
+          PRINT
+
+        NEXT type%
+      NEXT patt%
+      END
+
+      DEF PROCsorttest(patt%, type%, size%)
+      LOCAL a%(), C%, I%
+      DIM a%(size%-1)
+
+      CASE patt% OF
+        WHEN 1: a%() = 1 : a%() = 1
+        WHEN 2: FOR I% = 0 TO size%-1 : a%(I%) = I% : NEXT
+        WHEN 3: FOR I% = 0 TO size%-1 : a%(I%) = I% : NEXT
+          C% = RND(-123456) : REM Seed
+          FOR I% = size% TO 2 STEP -1 : SWAP a%(I%-1),a%(RND(I%)-1) : NEXT
+        WHEN 4: FOR I% = 0 TO size%-1 : a%(I%) = size%-1-I% : NEXT
+      ENDCASE
+
+      Start% = TIME
+      ON ERROR LOCAL PRINT , "   >100.00" ; : ENDPROC
+      CASE type% OF
+        WHEN 1: C% = size% : CALL Sort%, a%(0)
+        WHEN 2: PROCquicksort(a%(), 0, size%)
+        WHEN 3: PROCradixsort(a%(), size%, 10)
+        WHEN 4: PROCshellsort(a%(), size%)
+        WHEN 5: PROCbubblesort(a%(), size%)
+        WHEN 6: PROCinsertionsort(a%(), size%)
+      ENDCASE
+      PRINT , (TIME - Start%)/100;
+
+      FOR I% = 0 TO size%-2
+        IF a%(I%) > a%(I%+1) ERROR 100, "Sort failed!"
+      NEXT
+      ENDPROC
+
+      DEF PROCtimer
+      Start% += 0
+      IF (TIME - Start%) > 10000 ERROR 111, ""
+      ENDPROC
+
+      DEF PROCbubblesort(a%(), n%)
+      LOCAL i%, l%
+      REPEAT
+        l% = 0
+        FOR i% = 1 TO n%-1
+          IF a%(i%-1) > a%(i%) THEN
+            SWAP a%(i%-1),a%(i%)
+            l% = i%
+          ENDIF
+        NEXT
+        n% = l%
+      UNTIL l% = 0
+      ENDPROC
+
+      DEF PROCinsertionsort(a%(), n%)
+      LOCAL i%, j%, t%
+      FOR i% = 1 TO n%-1
+        t% = a%(i%)
+        j% = i%
+        WHILE j%>0 AND t% p% r% -= 1 : ENDWHILE
+        IF l% <= r% THEN
+          SWAP a%(l%), a%(r%)
+          l% += 1
+          r% -= 1
+        ENDIF
+      UNTIL l% > r%
+      IF s% < r% PROCquicksort(a%(), s%, r% - s% + 1)
+      IF l% < t% PROCquicksort(a%(), l%, t% - l% + 1 )
+      ENDPROC
+
+      DEF PROCshellsort(a%(), n%)
+      LOCAL h%, i%, j%, k%
+      h% = n%
+      WHILE h%
+        IF h% = 2 h% = 1 ELSE h% DIV= 2.2
+        FOR i% = h% TO n% - 1
+          k% = a%(i%)
+          j% = i%
+          WHILE j% >= h% AND k% < a%(ABS(j% - h%))
+            a%(j%) = a%(j% - h%)
+            j% -= h%
+          ENDWHILE
+          a%(j%) = k%
+        NEXT
+      ENDWHILE
+      ENDPROC
+
+      DEF PROCradixsort(a%(), n%, r%)
+      LOCAL d%, e%, i%, l%, m%, b%(), bucket%()
+      DIM b%(DIM(a%(),1)), bucket%(r%-1)
+      FOR i% = 0 TO n%-1
+        IF a%(i%) < l% l% = a%(i%)
+        IF a%(i%) > m% m% = a%(i%)
+      NEXT
+      a%() -= l%
+      m% -= l%
+      e% = 1
+      WHILE m% DIV e%
+        bucket%() = 0
+        FOR i% = 0 TO n%-1
+          bucket%(a%(i%) DIV e% MOD r%) += 1
+        NEXT
+        FOR i% = 1 TO r%-1
+          bucket%(i%) += bucket%(i% - 1)
+        NEXT
+        FOR i% = n%-1 TO 0 STEP -1
+          d% = a%(i%) DIV e% MOD r%
+          bucket%(d%) -= 1
+          b%(bucket%(d%)) = a%(i%)
+        NEXT
+        a%() = b%()
+        e% *= r%
+      ENDWHILE
+      a%() += l%
+      ENDPROC
diff --git a/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-1.c b/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-1.c
new file mode 100644
index 0000000000..45df1bd443
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-1.c
@@ -0,0 +1,9 @@
+#ifndef _CSEQUENCE_H
+#define _CSEQUENCE_H
+#include 
+
+void setfillconst(double c);
+void fillwithconst(double *v, int n);
+void fillwithrrange(double *v, int n);
+void shuffledrange(double *v, int n);
+#endif
diff --git a/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-2.c b/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-2.c
new file mode 100644
index 0000000000..8fe2cb62fe
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-2.c
@@ -0,0 +1,31 @@
+#include "csequence.h"
+
+static double fill_constant;
+
+void setfillconst(double c)
+{
+  fill_constant = c;
+}
+
+void fillwithconst(double *v, int n)
+{
+  while( --n >= 0 ) v[n] = fill_constant;
+}
+
+void fillwithrrange(double *v, int n)
+{
+  int on = n;
+  while( --on >= 0 ) v[on] = n - on;
+}
+
+void shuffledrange(double *v, int n)
+{
+  int on = n;
+  fillwithrrange(v, n);
+  while( --n >= 0 ) {
+    int r = rand() % on;
+    double t = v[n];
+    v[n] = v[r];
+    v[r] = t;
+  }
+}
diff --git a/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-3.c b/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-3.c
new file mode 100644
index 0000000000..5868f6f099
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-3.c
@@ -0,0 +1,39 @@
+#ifndef _WRITETIMINGS_H
+#define _WRITETIMINGS_H
+#include "sorts.h"
+#include "csequence.h"
+#include "timeit.h"
+
+/* we repeat the same MEANREPEAT times, and get the mean; this *should*
+   give "better" results ... */
+#define MEANREPEAT 10.0
+#define BUFLEN 128
+#define MAKEACTION(ALGO) \
+  int action_ ## ALGO (int size) {				\
+    ALGO ## _sort(tobesorted, size);				\
+    return 0; }
+#define MAKEPIECE(N) { #N , action_ ## N }
+
+int action_bubble(int size);
+int action_shell(int size);
+int action_quick(int size);
+int action_insertion(int size);
+int action_merge(int size);
+int doublecompare( const void *a, const void *b );
+int action_qsort(int size);
+int get_the_longest(int *a);
+
+struct testpiece
+{
+  const char *name;
+  int (*action)(int);
+};
+typedef struct testpiece testpiece_t;
+
+struct seqdef
+{
+  const char *name;
+  void (*seqcreator)(double *, int);
+};
+typedef struct seqdef seqdef_t;
+#endif
diff --git a/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-4.c b/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-4.c
new file mode 100644
index 0000000000..140c85909d
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-4.c
@@ -0,0 +1,104 @@
+#include 
+#include 
+
+#include "writetimings.h"
+
+double *tobesorted = NULL;
+const char *bname = "data_";
+const char *filetempl = "%s%s_%s.dat";
+int datlengths[] = {100, 200, 300, 500, 1000, 5000, 10000, 50000, 100000};
+
+testpiece_t testpieces[] =
+{
+//  MAKEPIECE(bubble),
+  MAKEPIECE(shell),
+  MAKEPIECE(merge),
+  MAKEPIECE(insertion),
+  MAKEPIECE(quick),
+  MAKEPIECE(qsort),
+  { NULL, NULL }
+};
+
+seqdef_t seqdefs[] =
+{
+  { "c1", fillwithconst },
+  { "rr", fillwithrrange },
+  { "sr", shuffledrange },
+  { NULL, NULL }
+};
+
+
+MAKEACTION(bubble)
+MAKEACTION(insertion)
+MAKEACTION(quick)
+MAKEACTION(shell)
+
+int action_merge(int size)
+{
+  double *res = merge_sort(tobesorted, size);
+  free(res); /* unluckly this affects performance */
+  return 0;
+}
+
+int doublecompare( const void *a, const void *b )
+{
+  if ( *(double *)a == *(double *)b ) return 0;
+  if ( *(double *)a < *(double *)b ) return -1; else return 1;
+}
+int action_qsort(int size)
+{
+  qsort(tobesorted, size, sizeof(double), doublecompare);
+  return 0;
+}
+
+int get_the_longest(int *a)
+{
+  int r = *a;
+  while( *a > 0 ) {
+    if ( *a > r ) r = *a;
+    a++;
+  }
+  return r;
+}
+
+
+int main()
+{
+  int i, j, k, z, lenmax;
+  char buf[BUFLEN];
+  FILE *out;
+  double thetime;
+
+  lenmax = get_the_longest(datlengths);
+  printf("Bigger data set has %d elements\n", lenmax);
+  tobesorted = malloc(sizeof(double)*lenmax);
+  if ( tobesorted == NULL ) return 1;
+
+  setfillconst(1.0);
+
+  for(i=0; testpieces[i].name != NULL; i++) {
+    for(j=0; seqdefs[j].name != NULL; j++) {
+      snprintf(buf, BUFLEN, filetempl, bname, testpieces[i].name,
+	       seqdefs[j].name);
+      out = fopen(buf, "w");
+      if ( out == NULL ) goto severe;
+      printf("Producing data for sort '%s', created data type '%s'\n",
+	     testpieces[i].name, seqdefs[j].name);
+      for(k=0; datlengths[k] > 0; k++) {
+	printf("\tNumber of elements: %d\n", datlengths[k]);
+	thetime = 0.0;
+	seqdefs[j].seqcreator(tobesorted, datlengths[k]);
+	fprintf(out, "%d ", datlengths[k]);
+	for(z=0; z < MEANREPEAT; z++) {
+	  thetime += time_it(testpieces[i].action, datlengths[k]);
+	}
+	thetime /= MEANREPEAT;
+	fprintf(out, "%.8lf\n", thetime);
+      }
+      fclose(out);
+    }
+  }
+severe:
+  free(tobesorted);
+  return 0;
+}
diff --git a/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-5.c b/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-5.c
new file mode 100644
index 0000000000..1b640f0e39
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/C/compare-sorting-algorithms-performance-5.c
@@ -0,0 +1,30 @@
+#include 
+#include 
+#include 
+
+#include "polifitgsl.h"
+
+#define MAXNUMOFDATA 100
+
+double x[MAXNUMOFDATA], y[MAXNUMOFDATA];
+double cf[2];
+
+int main()
+{
+  int i, nod;
+  int r;
+
+  for(i=0; i < MAXNUMOFDATA; i++)
+  {
+    r = scanf("%lf %lf\n", &x[i], &y[i]);
+    if ( (r == EOF) || (r < 2) ) break;
+    x[i] = log10(x[i]);
+    y[i] = log10(y[i]);
+  }
+  nod = i;
+
+  polynomialfit(nod, 2, x, y, cf);
+  printf("C0 = %lf\nC1 = %lf\n", cf[0], cf[1]);
+
+  return 0;
+}
diff --git a/Task/Compare-sorting-algorithms-performance/D/compare-sorting-algorithms-performance.d b/Task/Compare-sorting-algorithms-performance/D/compare-sorting-algorithms-performance.d
new file mode 100644
index 0000000000..555b6934f8
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/D/compare-sorting-algorithms-performance.d
@@ -0,0 +1,148 @@
+import std.stdio, std.algorithm, std.container, std.datetime,
+       std.random, std.typetuple;
+
+immutable int[] allOnes, sortedData, randomData;
+
+static this() { // Initialize global Arrays.
+    immutable size_t arraySize = 10_000;
+
+    allOnes = new int[arraySize];
+    //allOnes[] = 1;
+    foreach (ref d; allOnes)
+        d = 1;
+
+    sortedData = new int[arraySize];
+    foreach (immutable i, ref d; sortedData)
+        d = i;
+
+    randomData = new int[arraySize];
+    foreach (ref d; randomData)
+        d = uniform(0, int.max);
+}
+
+// BubbleSort:
+
+void bubbleSort(T)(T[] list) {
+    for (int i = list.length - 1; i > 0; i--)
+        for (int j = i -1; j >= 0; j--)
+            if (list[i] < list[j])
+                swap(list[i], list[j]);
+}
+
+void allOnesBubble() {
+    auto data = allOnes.dup;
+    data.bubbleSort;
+    assert(data.isSorted);
+}
+
+void sortedBubble() {
+    auto data = sortedData.dup;
+    data.bubbleSort;
+    assert(data.isSorted);
+}
+
+void randomBubble() {
+    auto data = randomData.dup;
+    data.bubbleSort;
+    assert(data.isSorted);
+}
+
+// InsertionSort:
+
+void insertionSort(T)(T[] list) {
+    foreach (immutable i, currElem; list) {
+        size_t j = i;
+        for (; j > 0 && currElem < list[j - 1]; j--)
+            list[j] = list[j - 1];
+        list[j] = currElem;
+    }
+}
+
+void allOnesInsertion() {
+    auto data = allOnes.dup;
+    data.insertionSort;
+    assert(data.isSorted);
+}
+
+void sortedInsertion() {
+    auto data = sortedData.dup;
+    data.insertionSort;
+    assert(data.isSorted);
+}
+
+void randomInsertion() {
+    auto data = randomData.dup;
+    data.insertionSort;
+    assert(data.isSorted);
+}
+
+// HeapSort:
+
+void heapSort(T)(T[] data) {
+    auto h = data.heapify;
+    while (!h.empty)
+        h.removeFront;
+}
+
+void allOnesHeap() {
+    auto data = allOnes.dup;
+    data.heapSort;
+    assert(data.isSorted);
+}
+
+void sortedHeap() {
+    auto data = sortedData.dup;
+    data.heapSort;
+    assert(data.isSorted);
+}
+
+void randomHeap() {
+    auto data = randomData.dup;
+    data.heapSort;
+    assert(data.isSorted);
+}
+
+// Built-in sort:
+
+void allOnesBuiltIn() {
+    auto data = allOnes.dup;
+    data.sort!q{a < b};
+    assert(data.isSorted);
+}
+
+void sortedBuiltIn() {
+    auto data = sortedData.dup;
+    data.sort!q{a < b};
+    assert(data.isSorted);
+}
+
+void randomBuiltIn() {
+    auto data = randomData.dup;
+    data.sort!q{a < b};
+    assert(data.isSorted);
+}
+
+static void show(in TickDuration[4u] r) {
+    alias args = TypeTuple!("usecs", int);
+    writefln("    Bubble Sort:    %10d", r[0].to!args);
+    writefln("    Insertion Sort: %10d", r[1].to!args);
+    writefln("    Heap Sort:      %10d", r[3].to!args);
+    writefln("    Built-in Sort:  %10d", r[2].to!args);
+}
+
+void main() {
+    enum nRuns = 100;
+    writeln("Timings in microseconds:");
+
+    writeln("  Testing against all ones:");
+    nRuns.benchmark!(allOnesBubble, allOnesInsertion,
+                     allOnesHeap, allOnesBuiltIn).show;
+
+    writeln("\n  Testing against sorted data.");
+    nRuns.benchmark!(sortedBubble, sortedInsertion,
+                     sortedHeap, sortedBuiltIn).show;
+
+    writeln("\n  Testing against random data.");
+    nRuns.benchmark!(randomBubble, randomInsertion,
+                     randomHeap, randomBuiltIn).show;
+}
diff --git a/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-1.py b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-1.py
new file mode 100644
index 0000000000..ec5f03c81e
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-1.py
@@ -0,0 +1,19 @@
+def builtinsort(x):
+    x.sort()
+
+def partition(seq, pivot):
+   low, middle, up = [], [], []
+   for x in seq:
+       if x < pivot:
+           low.append(x)
+       elif x == pivot:
+           middle.append(x)
+       else:
+           up.append(x)
+   return low, middle, up
+import random
+def qsortranpart(seq):
+   size = len(seq)
+   if size < 2: return seq
+   low, middle, up = partition(seq, random.choice(seq))
+   return qsortranpart(low) + middle + qsortranpart(up)
diff --git a/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-2.py b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-2.py
new file mode 100644
index 0000000000..416cd36944
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-2.py
@@ -0,0 +1,10 @@
+def ones(n):
+    return [1]*n
+
+def reversedrange(n):
+    return reversed(range(n))
+
+def shuffledrange(n):
+    x = range(n)
+    random.shuffle(x)
+    return x
diff --git a/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-3.py b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-3.py
new file mode 100644
index 0000000000..ba966fac0a
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-3.py
@@ -0,0 +1,7 @@
+def write_timings(npoints=10, maxN=10**4, sort_functions=(builtinsort,insertion_sort, qsort),
+                  sequence_creators = (ones, range, shuffledrange)):
+   Ns = range(2, maxN, maxN//npoints)
+   for sort in sort_functions:
+       for make_seq in sequence_creators:
+           Ts = [usec(sort, (make_seq(n),)) for n in Ns]
+           writedat('%s-%s-%d-%d.xy' % (sort.__name__,  make_seq.__name__, len(Ns), max(Ns)), Ns, Ts)
diff --git a/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-4.py b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-4.py
new file mode 100644
index 0000000000..cd0af13197
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-4.py
@@ -0,0 +1,23 @@
+import operator
+import numpy, pylab
+def plotdd(dictplotdict):
+   """See ``plot_timings()`` below."""
+   symbols = ('o', '^', 'v', '<', '>', 's', '+', 'x', 'D', 'd',
+              '1', '2', '3', '4', 'h', 'H', 'p', '|', '_')
+   colors = list('bgrcmyk') # split string on distinct characters
+   for npoints, plotdict in dictplotdict.iteritems():
+       for ttle, lst in plotdict.iteritems():
+           pylab.hold(False)
+           for i, (label, polynom, x, y) in enumerate(sorted(lst,key=operator.itemgetter(0))):
+               pylab.plot(x, y, colors[i % len(colors)] + symbols[i % len(symbols)], label='%s %s' % (polynom, label))
+               pylab.hold(True)
+               y = numpy.polyval(polynom, x)
+               pylab.plot(x, y, colors[i % len(colors)], label= '_nolegend_')
+           pylab.legend(loc='upper left')
+           pylab.xlabel(polynom.variable)
+           pylab.ylabel('log2( time in microseconds )')
+           pylab.title(ttle, verticalalignment='bottom')
+           figname = '_%(npoints)03d%(ttle)s' % vars()
+           pylab.savefig(figname+'.png')
+           pylab.savefig(figname+'.pdf')
+           print figname
diff --git a/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-5.py b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-5.py
new file mode 100644
index 0000000000..b47c82ee86
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-5.py
@@ -0,0 +1,30 @@
+import collections, itertools, glob, re
+import numpy
+def plot_timings():
+   makedict = lambda: collections.defaultdict(lambda: collections.defaultdict(list))
+   df = makedict()
+   ds = makedict()
+   # populate plot dictionaries
+   for filename in glob.glob('*.xy'):
+       m = re.match(r'([^-]+)-([^-]+)-(\d+)-(\d+)\.xy', filename)
+       print filename
+       assert m, filename
+       funcname, seqname, npoints, maxN = m.groups()
+       npoints, maxN = int(npoints), int(maxN)
+       a = numpy.fromiter(itertools.imap(float, open(filename).read().split()), dtype='f')
+       Ns = a[::2]  # sequences lengths
+       Ts = a[1::2] # corresponding times
+       assert len(Ns) == len(Ts) == npoints
+       assert max(Ns) <= maxN
+       #
+       logsafe = numpy.logical_and(Ns>0, Ts>0)
+       Ts = numpy.log2(Ts[logsafe])
+       Ns = numpy.log2(Ns[logsafe])
+       coeffs = numpy.polyfit(Ns, Ts, deg=1)
+       poly = numpy.poly1d(coeffs, variable='log2(N)')
+       #
+       df[npoints][funcname].append((seqname, poly, Ns, Ts))
+       ds[npoints][seqname].append((funcname, poly, Ns, Ts))
+   # actual plotting
+   plotdd(df)
+   plotdd(ds) # see ``plotdd()`` above
diff --git a/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-6.py b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-6.py
new file mode 100644
index 0000000000..35f24e9330
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/Python/compare-sorting-algorithms-performance-6.py
@@ -0,0 +1,18 @@
+sort_functions = [
+    builtinsort,         # see implementation above
+    insertion_sort,      # see [[Insertion sort]]
+    insertion_sort_lowb, # ''insertion_sort'', where sequential search is replaced
+                         #     by lower_bound() function
+    qsort,               # see [[Quicksort]]
+    qsortranlc,          # ''qsort'' with randomly choosen ''pivot''
+                         #     and the filtering via list comprehension
+    qsortranpart,        # ''qsortranlc'' with filtering via ''partition'' function
+    qsortranpartis,      # ''qsortranpart'', where for a small input sequence lengths
+    ]                    #     ''insertion_sort'' is called
+if __name__=="__main__":
+   import sys
+   sys.setrecursionlimit(10000)
+   write_timings(npoints=100, maxN=1024, # 1 <= N <= 2**10 an input sequence length
+                 sort_functions=sort_functions,
+                 sequence_creators = (ones, range, shuffledrange))
+   plot_timings()
diff --git a/Task/Compare-sorting-algorithms-performance/Tcl/compare-sorting-algorithms-performance.tcl b/Task/Compare-sorting-algorithms-performance/Tcl/compare-sorting-algorithms-performance.tcl
new file mode 100644
index 0000000000..608daf9c34
--- /dev/null
+++ b/Task/Compare-sorting-algorithms-performance/Tcl/compare-sorting-algorithms-performance.tcl
@@ -0,0 +1,222 @@
+###############################################################################
+# measure and plot times
+package require Tk
+package require struct::list
+namespace path ::tcl::mathfunc
+
+proc create_log10_plot {title xlabel ylabel xs ys labels shapes colours} {
+    set w [toplevel .[clock clicks]]
+    wm title $w $title
+    pack [canvas $w.c -background white]
+    pack [canvas $w.legend -background white]
+    update
+    plot_log10 $w.c $w.legend $title $xlabel $ylabel $xs $ys $labels $shapes $colours
+    $w.c config -scrollregion [$w.c bbox all]
+    update
+}
+
+proc plot_log10 {canvas legend title xlabel ylabel xs ys labels shapes colours} {
+    global xfac yfac
+    set log10_xs [map {_ {log10 $_}} $xs]
+    foreach series $ys {
+        lappend log10_ys [map {_ {log10 $_}} $series]
+    }
+    set maxx [max {*}$log10_xs]
+    set yvalues [lsort -real [struct::list flatten $log10_ys]]
+    set firstInf [lsearch $yvalues Inf]
+    set maxy [lindex $yvalues [expr {$firstInf == -1 ? [llength $yvalues] - 1 : $firstInf - 1}]]
+
+    set xfac [expr {[winfo width $canvas] * 0.8/$maxx}]
+    set yfac [expr {[winfo height $canvas] * 0.8/$maxy}]
+
+    scale $canvas x 0 $maxx $xfac "log10($xlabel)"
+    scale $canvas y 0 $maxy $yfac "log10($ylabel)" $maxx $xfac
+
+    $legend create text 30 0 -text $title -anchor nw
+    set count 1
+    foreach series $log10_ys shape $shapes colour $colours label $labels {
+        plotxy $canvas $log10_xs $series $shape $colour
+        legenditem $legend [incr count] $shape $colour $label
+    }
+}
+
+proc map {lambda list} {
+    set res [list]
+    foreach item $list {lappend res [apply $lambda $item]}
+    return $res
+}
+
+proc legenditem {legend pos shape colour label} {
+    set y [expr {$pos * 15}]
+    $shape $legend 20 $y -fill $colour
+    $legend create text 30 $y -text $label -anchor w
+}
+
+# The actual plotting engine
+proc plotxy {canvas _xs _ys shape colour} {
+    global xfac yfac
+    foreach x $_xs y $_ys {
+        if {$y < Inf} {
+            lappend xs $x
+            lappend ys $y
+        }
+    }
+    set coords [list]
+    foreach x $xs y $ys {
+        set coord_x [expr {$x*$xfac}]
+        set coord_y [expr {-$y*$yfac}]
+        $shape $canvas $coord_x $coord_y -fill $colour
+        lappend coords $coord_x $coord_y
+    }
+    $canvas create line $coords -smooth true
+}
+# Rescales the contents of the given canvas
+proc scale {canvas direction from to fac label {other_to 0} {other_fac 0}} {
+    set f [expr {$from*$fac}]
+    set t [expr {$to*$fac}]
+    switch -- $direction {
+        x {
+            set f [expr {$from * $fac}]
+            set t [expr {$to * $fac}]
+            # create x-axis
+            $canvas create line $f 0 $t 0
+            $canvas create text $f 0 -anchor nw -text $from
+            $canvas create text $t 0 -anchor n -text [format "%.1f" $to]
+            $canvas create text [expr {($f+$t)/2}] 0 -anchor n -text $label
+
+        }
+        y {
+            set f [expr {$from * -$fac}]
+            set t [expr {$to * -$fac}]
+            # create y-axis
+            $canvas create line 0 $f 0 $t
+            $canvas create text 0 $f -anchor se -text $from
+            $canvas create text 0 $t -anchor e -text [format "%.1f" $to]
+            $canvas create text 0 [expr {($f+$t)/2}] -anchor e -text $label
+            # create gridlines
+            set xmax [expr {$other_to * $other_fac}]
+            for {set i 1} {$i < $to} {incr i} {
+                set y [expr {$i * -$fac}]
+                $canvas create line 0 $y $xmax $y -dash .
+            }
+        }
+    }
+}
+# Helper to make points, which are otherwise not a native item type
+proc dot {canvas x y args} {
+    set id [$canvas create oval [expr {$x-3}] [expr {$y-3}] \
+                [expr {$x+3}] [expr {$y+3}]]
+    $canvas itemconfigure $id {*}$args
+}
+proc square {canvas x y args} {
+    set id [$canvas create rectangle [expr {$x-3}] [expr {$y-3}] \
+                [expr {$x+3}] [expr {$y+3}]]
+    $canvas itemconfigure $id {*}$args
+}
+proc cross {canvas x y args} {
+    set l1 [$canvas create line [expr {$x-3}] $y [expr {$x+3}] $y]
+    set l2 [$canvas create line $x [expr {$y-3}] $x [expr {$y+3}]]
+    $canvas itemconfigure $l1 {*}$args
+    $canvas itemconfigure $l2 {*}$args
+}
+proc x {canvas x y args} {
+    set l1 [$canvas create line [expr {$x-3}] [expr {$y-3}] [expr {$x+3}] [expr {$y+3}]]
+    set l2 [$canvas create line [expr {$x+3}] [expr {$y-3}] [expr {$x-3}] [expr {$y+3}]]
+    $canvas itemconfigure $l1 {*}$args
+    $canvas itemconfigure $l2 {*}$args
+}
+proc triangleup {canvas x y args} {
+    set id [$canvas create polygon $x [expr {$y-4}] \
+                [expr {$x+4}] [expr {$y+4}] \
+                [expr {$x-4}] [expr {$y+4}]]
+    $canvas itemconfigure $id {*}$args
+}
+proc triangledown {canvas x y args} {
+    set id [$canvas create polygon $x [expr {$y+4}] \
+                [expr {$x+4}] [expr {$y-4}] \
+                [expr {$x-4}] [expr {$y-4}]]
+    $canvas itemconfigure $id {*}$args
+}
+
+wm withdraw .
+
+#####################################################################
+# list creation procedures
+proc ones n {
+    lrepeat $n 1
+}
+proc reversed n {
+    while {[incr n -1] >= 0} {
+        lappend result $n
+    }
+    return $result
+}
+proc random n {
+    for {set i 0} {$i < $n} {incr i} {
+        lappend result [expr {int($n * rand())}]
+    }
+    return $result
+}
+
+set algorithms {lsort quicksort shellsort insertionsort bubblesort mergesort}
+set sizes {1 10 100 1000 10000 100000}
+set types {ones reversed random}
+set shapes {dot square cross triangleup triangledown x}
+set colours {red blue black brown yellow black}
+
+# create some lists to be used by all sorting algorithms
+array set lists {}
+foreach size $sizes {
+    foreach type $types {
+        set lists($type,$size) [$type $size]
+    }
+}
+
+set runs 10
+
+# header
+fconfigure stdout -buffering none
+puts -nonewline [format "%-16s" "list length:"]
+foreach size $sizes {
+    puts -nonewline [format " %10d" $size]
+}
+puts ""
+
+# perform the sort timings and output results
+foreach type $types {
+    puts "\nlist type: $type"
+    set times [list]
+    foreach algo $algorithms {
+        set errs [list]
+        set thesetimes [list]
+        $algo {} ;# call it once to ensure it's compiled
+
+        puts -nonewline [format "   %-13s" $algo]
+        foreach size $sizes {
+            # some implementations are just too slow
+            if {$type ne "ones" && (
+                ($algo eq "insertionsort" && $size > 10000) ||
+                ($algo eq "bubblesort" && $size > 1000))
+            } {
+                set time Inf
+            } else {
+                # OK, do it
+                if {[catch {time [list $algo $lists($type,$size)] $runs} result] != 0} {
+                    set time Inf
+                    lappend errs $result
+                } else {
+                    set time [lindex [split $result] 0]
+                }
+            }
+            lappend thesetimes $time
+            puts -nonewline [format " %10s" $time]
+        }
+        puts ""
+        if {[llength $errs] > 0} {
+            puts [format "      %s" [join $errs "\n      "]]
+        }
+        lappend times $thesetimes
+    }
+    create_log10_plot "Sorting a '$type' list" size time $sizes $times $algorithms $shapes $colours
+}
+puts "\ntimes in microseconds, average of $runs runs"
diff --git a/Task/Compile-time-calculation/0DESCRIPTION b/Task/Compile-time-calculation/0DESCRIPTION
new file mode 100644
index 0000000000..d3a6b46585
--- /dev/null
+++ b/Task/Compile-time-calculation/0DESCRIPTION
@@ -0,0 +1,3 @@
+Some programming languages allow calculation of values at compile time. For this task, calculate 10! at compile time. Print the result when the program is run.
+
+Discuss what limitations apply to compile-time calculations in your language.
diff --git a/Task/Compile-time-calculation/Ada/compile-time-calculation-1.ada b/Task/Compile-time-calculation/Ada/compile-time-calculation-1.ada
new file mode 100644
index 0000000000..598e0b5e5f
--- /dev/null
+++ b/Task/Compile-time-calculation/Ada/compile-time-calculation-1.ada
@@ -0,0 +1,7 @@
+with Ada.Text_Io;
+procedure CompileTimeCalculation is
+   Factorial : constant Integer := 10*9*8*7*6*5*4*3*2*1;
+
+begin
+   Ada.Text_Io.Put(Integer'Image(Factorial));
+end CompileTimeCalculation;
diff --git a/Task/Compile-time-calculation/Ada/compile-time-calculation-2.ada b/Task/Compile-time-calculation/Ada/compile-time-calculation-2.ada
new file mode 100644
index 0000000000..00ced038db
--- /dev/null
+++ b/Task/Compile-time-calculation/Ada/compile-time-calculation-2.ada
@@ -0,0 +1,16 @@
+with Ada.Text_Io;
+procedure CompileTimeCalculation is
+
+   function Factorial (Int : in Integer) return Integer is
+   begin
+      if Int > 1 then
+         return Int * Factorial(Int-1);
+      else
+         return 1;
+      end if;
+   end;
+
+     Fact10 : Integer := Factorial(10);
+begin
+   Ada.Text_Io.Put(Integer'Image(Fact10));
+end CompileTimeCalculation;
diff --git a/Task/Compile-time-calculation/Ada/compile-time-calculation-3.ada b/Task/Compile-time-calculation/Ada/compile-time-calculation-3.ada
new file mode 100644
index 0000000000..b1ca7360d1
--- /dev/null
+++ b/Task/Compile-time-calculation/Ada/compile-time-calculation-3.ada
@@ -0,0 +1,12 @@
+with Ada.Text_IO;
+
+procedure Unbounded_Compile_Time_Calculation is
+   F_10 : constant Integer := 10*9*8*7*6*5*4*3*2*1;
+   A_11_15 : constant Integer := 15*14*13*12*11;
+   A_16_20 : constant Integer := 20*19*18*17*16;
+begin
+   Ada.Text_IO.Put_Line -- prints out
+     ("20 choose 10 =" & Integer'Image((A_11_15 * A_16_20 * F_10) / (F_10 * F_10)));
+--   Ada.Text_IO.Put_Line -- would not compile
+--     ("Factorial(20) =" & Integer'Image(A_11_15 * A_16_20 * F_10));
+end Unbounded_Compile_Time_Calculation;
diff --git a/Task/Compile-time-calculation/Ada/compile-time-calculation-4.ada b/Task/Compile-time-calculation/Ada/compile-time-calculation-4.ada
new file mode 100644
index 0000000000..26a6a488fc
--- /dev/null
+++ b/Task/Compile-time-calculation/Ada/compile-time-calculation-4.ada
@@ -0,0 +1,2 @@
+   Ada.Text_IO.Put_Line -- would not compile
+      ("Factorial(20) =" & Integer'Image(A_11_15 * A_16_20 * F_10));
diff --git a/Task/Compile-time-calculation/BASIC/compile-time-calculation-1.bas b/Task/Compile-time-calculation/BASIC/compile-time-calculation-1.bas
new file mode 100644
index 0000000000..32e4763688
--- /dev/null
+++ b/Task/Compile-time-calculation/BASIC/compile-time-calculation-1.bas
@@ -0,0 +1 @@
+CONST factorial10 = 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10
diff --git a/Task/Compile-time-calculation/BASIC/compile-time-calculation-2.bas b/Task/Compile-time-calculation/BASIC/compile-time-calculation-2.bas
new file mode 100644
index 0000000000..a9a2bdd687
--- /dev/null
+++ b/Task/Compile-time-calculation/BASIC/compile-time-calculation-2.bas
@@ -0,0 +1,2 @@
+DIM factorial10 AS LONG
+factorial10 = 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10
diff --git a/Task/Compile-time-calculation/C++/compile-time-calculation-1.cpp b/Task/Compile-time-calculation/C++/compile-time-calculation-1.cpp
new file mode 100644
index 0000000000..f6a977675e
--- /dev/null
+++ b/Task/Compile-time-calculation/C++/compile-time-calculation-1.cpp
@@ -0,0 +1,18 @@
+#include 
+
+template struct Fac
+{
+    static const int result = i * Fac::result;
+};
+
+template<> struct Fac<1>
+{
+    static const int result = 1;
+};
+
+
+int main()
+{
+    std::cout << "10! = " << Fac<10>::result << "\n";
+    return 0;
+}
diff --git a/Task/Compile-time-calculation/C++/compile-time-calculation-2.cpp b/Task/Compile-time-calculation/C++/compile-time-calculation-2.cpp
new file mode 100644
index 0000000000..602e684476
--- /dev/null
+++ b/Task/Compile-time-calculation/C++/compile-time-calculation-2.cpp
@@ -0,0 +1,12 @@
+#include 
+
+constexpr int factorial(int n) {
+    return n ? (n * factorial(n - 1)) : 1;
+}
+
+constexpr int f10 = factorial(10);
+
+int main() {
+    printf("%d\n", f10);
+    return 0;
+}
diff --git a/Task/Compile-time-calculation/C++/compile-time-calculation-3.cpp b/Task/Compile-time-calculation/C++/compile-time-calculation-3.cpp
new file mode 100644
index 0000000000..a6f3a29075
--- /dev/null
+++ b/Task/Compile-time-calculation/C++/compile-time-calculation-3.cpp
@@ -0,0 +1,12 @@
+_main:
+	pushl	%ebp
+	movl	%esp, %ebp
+	andl	$-16, %esp
+	subl	$16, %esp
+	call	___main
+	movl	$3628800, 4(%esp)
+	movl	$LC0, (%esp)
+	call	_printf
+	movl	$0, %eax
+	leave
+	ret
diff --git a/Task/Compile-time-calculation/C/compile-time-calculation.c b/Task/Compile-time-calculation/C/compile-time-calculation.c
new file mode 100644
index 0000000000..8619e0be12
--- /dev/null
+++ b/Task/Compile-time-calculation/C/compile-time-calculation.c
@@ -0,0 +1,10 @@
+#include 
+#include 
+
+#define ORDER_PP_DEF_8fac ORDER_PP_FN( \
+8fn(8X, 8seq_fold(8times, 1, 8seq_iota(1, 8inc(8X)))) )
+
+int main(void) {
+	printf("10! = %d\n", ORDER_PP( 8to_lit( 8fac(10) ) ) );
+	return 0;
+}
diff --git a/Task/Compile-time-calculation/Clojure/compile-time-calculation.clj b/Task/Compile-time-calculation/Clojure/compile-time-calculation.clj
new file mode 100644
index 0000000000..f50e85a229
--- /dev/null
+++ b/Task/Compile-time-calculation/Clojure/compile-time-calculation.clj
@@ -0,0 +1,2 @@
+(defn fac [n] (apply * (range 1 (inc n))))
+(defmacro ct-factorial [n] (fac n))
diff --git a/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-1.lisp b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-1.lisp
new file mode 100644
index 0000000000..148be5b087
--- /dev/null
+++ b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-1.lisp
@@ -0,0 +1,2 @@
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defun factorial ...))
diff --git a/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-2.lisp b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-2.lisp
new file mode 100644
index 0000000000..ac36d55fe9
--- /dev/null
+++ b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-2.lisp
@@ -0,0 +1,6 @@
+(defmacro ct-factorial (n)
+  (factorial n))
+
+...
+
+(print (ct-factorial 10))
diff --git a/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-3.lisp b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-3.lisp
new file mode 100644
index 0000000000..b20bbe6da9
--- /dev/null
+++ b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-3.lisp
@@ -0,0 +1,6 @@
+(defmacro ct-factorial (n)
+  `(quote ,(factorial n)))
+
+; or, equivalently,
+(defmacro ct-factorial (n)
+  `',(factorial n))
diff --git a/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-4.lisp b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-4.lisp
new file mode 100644
index 0000000000..7ecf1f160e
--- /dev/null
+++ b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-4.lisp
@@ -0,0 +1 @@
+(print (load-time-value (factorial 10)))
diff --git a/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-5.lisp b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-5.lisp
new file mode 100644
index 0000000000..93e50b9a53
--- /dev/null
+++ b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-5.lisp
@@ -0,0 +1 @@
+(print (#. (factorial 10)))
diff --git a/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-6.lisp b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-6.lisp
new file mode 100644
index 0000000000..38a460a6fb
--- /dev/null
+++ b/Task/Compile-time-calculation/Common-Lisp/compile-time-calculation-6.lisp
@@ -0,0 +1,4 @@
+(define-compiler-macro factorial (&whole form arg)
+  (if (constantp arg)
+    (factorial arg)
+    form))
diff --git a/Task/Compile-time-calculation/D/compile-time-calculation-1.d b/Task/Compile-time-calculation/D/compile-time-calculation-1.d
new file mode 100644
index 0000000000..3dfc2e4640
--- /dev/null
+++ b/Task/Compile-time-calculation/D/compile-time-calculation-1.d
@@ -0,0 +1,15 @@
+import core.stdc.stdio;
+
+long fact(long x) {
+    long result = 1;
+    foreach (i; 2 .. x + 1)
+        result *= i;
+    return result;
+}
+
+void main() {
+    // enum means "compile-time constant", it forces CTFE.
+    enum fact10 = fact(10);
+
+    printf("%ld\n", fact10);
+}
diff --git a/Task/Compile-time-calculation/D/compile-time-calculation-2.d b/Task/Compile-time-calculation/D/compile-time-calculation-2.d
new file mode 100644
index 0000000000..f000806a41
--- /dev/null
+++ b/Task/Compile-time-calculation/D/compile-time-calculation-2.d
@@ -0,0 +1,11 @@
+__Dmain
+    push EAX
+    mov  EAX,offset FLAT:_DATA
+    push 0
+    push 0375F00h
+    push EAX
+    call near ptr _printf
+    add  ESP,0Ch
+    xor  EAX,EAX
+    pop  ECX
+    ret
diff --git a/Task/Compile-time-calculation/DWScript/compile-time-calculation.dwscript b/Task/Compile-time-calculation/DWScript/compile-time-calculation.dwscript
new file mode 100644
index 0000000000..310d3b3b60
--- /dev/null
+++ b/Task/Compile-time-calculation/DWScript/compile-time-calculation.dwscript
@@ -0,0 +1 @@
+const fact10 = Factorial(10);
diff --git a/Task/Compile-time-calculation/Forth/compile-time-calculation-1.fth b/Task/Compile-time-calculation/Forth/compile-time-calculation-1.fth
new file mode 100644
index 0000000000..7e7b2a1144
--- /dev/null
+++ b/Task/Compile-time-calculation/Forth/compile-time-calculation-1.fth
@@ -0,0 +1,7 @@
+: fac ( n -- n! ) 1 swap 1+ 2 max 2 ?do i * loop ;
+
+: main  ." 10! = " [ 10 fac ] literal . ;
+
+see main
+: main
+  .\" 10! = " 3628800 . ; ok
diff --git a/Task/Compile-time-calculation/Forth/compile-time-calculation-2.fth b/Task/Compile-time-calculation/Forth/compile-time-calculation-2.fth
new file mode 100644
index 0000000000..0bbbf98a6a
--- /dev/null
+++ b/Task/Compile-time-calculation/Forth/compile-time-calculation-2.fth
@@ -0,0 +1,9 @@
+: more  ( "digits" -- )  \ store "1234" as 1 c, 2 c, 3 c, 4 c,
+  parse-word bounds ?do
+    i c@ [char] 0 - c,
+  loop ;
+
+create bignum
+more 73167176531330624919225119674426574742355349194934
+more 96983520312774506326239578318016984801869478851843
+...
diff --git a/Task/Compile-time-calculation/Fortran/compile-time-calculation.f b/Task/Compile-time-calculation/Fortran/compile-time-calculation.f
new file mode 100644
index 0000000000..86bf133fba
--- /dev/null
+++ b/Task/Compile-time-calculation/Fortran/compile-time-calculation.f
@@ -0,0 +1,8 @@
+ program test
+
+   implicit none
+   integer,parameter :: t = 10*9*8*7*6*5*4*3*2  !computed at compile time
+
+   write(*,*) t  !write the value the console.
+
+ end program test
diff --git a/Task/Compile-time-calculation/Go/compile-time-calculation.go b/Task/Compile-time-calculation/Go/compile-time-calculation.go
new file mode 100644
index 0000000000..95e6e4ced0
--- /dev/null
+++ b/Task/Compile-time-calculation/Go/compile-time-calculation.go
@@ -0,0 +1,7 @@
+package main
+
+import "fmt"
+
+func main() {
+    fmt.Println(2*3*4*5*6*7*8*9*10)
+}
diff --git a/Task/Compile-time-calculation/Haskell/compile-time-calculation.hs b/Task/Compile-time-calculation/Haskell/compile-time-calculation.hs
new file mode 100644
index 0000000000..527ffd3984
--- /dev/null
+++ b/Task/Compile-time-calculation/Haskell/compile-time-calculation.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE QuasiQuotes, TemplateHaskell #-}
+
+fact n = product [1..n]
+
+main = print $([|fact 10|])
diff --git a/Task/Compile-time-calculation/Perl/compile-time-calculation-1.pl b/Task/Compile-time-calculation/Perl/compile-time-calculation-1.pl
new file mode 100644
index 0000000000..5b242ea95c
--- /dev/null
+++ b/Task/Compile-time-calculation/Perl/compile-time-calculation-1.pl
@@ -0,0 +1,6 @@
+my $tenfactorial;
+print "$tenfactorial\n";
+
+BEGIN
+   {$tenfactorial = 1;
+    $tenfactorial *= $_ foreach 1 .. 10;}
diff --git a/Task/Compile-time-calculation/Perl/compile-time-calculation-2.pl b/Task/Compile-time-calculation/Perl/compile-time-calculation-2.pl
new file mode 100644
index 0000000000..786b44245f
--- /dev/null
+++ b/Task/Compile-time-calculation/Perl/compile-time-calculation-2.pl
@@ -0,0 +1 @@
+my $tenfactorial = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2;
diff --git a/Task/Compile-time-calculation/PicoLisp/compile-time-calculation.l b/Task/Compile-time-calculation/PicoLisp/compile-time-calculation.l
new file mode 100644
index 0000000000..a065a941ee
--- /dev/null
+++ b/Task/Compile-time-calculation/PicoLisp/compile-time-calculation.l
@@ -0,0 +1,5 @@
+(de fact (N)
+   (apply * (range 1 N)) )
+
+(de foo ()
+   (prinl "The value of fact(10) is " `(fact 10)) )
diff --git a/Task/Compile-time-calculation/REXX/compile-time-calculation.rexx b/Task/Compile-time-calculation/REXX/compile-time-calculation.rexx
new file mode 100644
index 0000000000..3056ded832
--- /dev/null
+++ b/Task/Compile-time-calculation/REXX/compile-time-calculation.rexx
@@ -0,0 +1,3 @@
+/*REXX program to compute 10!*/  say '10! =' !(10); exit
+
+!: procedure;  !=1;  do j=2 to arg(1);  !=!*j;  end;  return !
diff --git a/Task/Compile-time-calculation/Racket/compile-time-calculation.rkt b/Task/Compile-time-calculation/Racket/compile-time-calculation.rkt
new file mode 100644
index 0000000000..997b0b593c
--- /dev/null
+++ b/Task/Compile-time-calculation/Racket/compile-time-calculation.rkt
@@ -0,0 +1,21 @@
+#lang racket
+
+;; Import the math library for compile-time
+;; Note: included in Racket v5.3.2
+(require (for-syntax math))
+
+;; In versions older than v5.3.2, just define the function
+;; for compile-time
+;;
+;; (begin-for-syntax
+;;   (define (factorial n)
+;;     (if (zero? n)
+;;         1
+;;         (factorial (- n 1)))))
+
+;; define a macro that calls factorial at compile-time
+(define-syntax (fact10 stx)
+  #`#,(factorial 10))
+
+;; use the macro defined above
+(fact10)
diff --git a/Task/Compile-time-calculation/Tcl/compile-time-calculation-1.tcl b/Task/Compile-time-calculation/Tcl/compile-time-calculation-1.tcl
new file mode 100644
index 0000000000..eb1a7929f8
--- /dev/null
+++ b/Task/Compile-time-calculation/Tcl/compile-time-calculation-1.tcl
@@ -0,0 +1,8 @@
+proc makeFacExpr n {
+    set exp 1
+    for {set i 2} {$i <= $n} {incr i} {
+        append exp " * $i"
+    }
+    return "expr \{$exp\}"
+}
+eval [makeFacExpr 10]
diff --git a/Task/Compile-time-calculation/Tcl/compile-time-calculation-2.tcl b/Task/Compile-time-calculation/Tcl/compile-time-calculation-2.tcl
new file mode 100644
index 0000000000..57b37d5764
--- /dev/null
+++ b/Task/Compile-time-calculation/Tcl/compile-time-calculation-2.tcl
@@ -0,0 +1,9 @@
+% tcl::unsupported::disassemble script [makeFacExpr 10]
+ByteCode 0x0x4de10, refCt 1, epoch 3, interp 0x0x31c10 (epoch 3)
+  Source "expr {1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10}"
+  Cmds 1, src 45, inst 3, litObjs 1, aux 0, stkDepth 1, code/src 0.00
+  Commands 1:
+      1: pc 0-1, src 0-44
+  Command 1: "expr {1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10}"
+    (0) push1 0 	# "3628800"
+    (2) done
diff --git a/Task/Compound-data-type/0DESCRIPTION b/Task/Compound-data-type/0DESCRIPTION
new file mode 100644
index 0000000000..8f6abd977f
--- /dev/null
+++ b/Task/Compound-data-type/0DESCRIPTION
@@ -0,0 +1,4 @@
+{{Data structure}}
+Create a compound data type Point(x,y).
+
+A compound data type is one that holds multiple independent values.  See also [[Enumeration]].
diff --git a/Task/Compound-data-type/1META.yaml b/Task/Compound-data-type/1META.yaml
new file mode 100644
index 0000000000..659c8686af
--- /dev/null
+++ b/Task/Compound-data-type/1META.yaml
@@ -0,0 +1,2 @@
+---
+note: Basic language learning
diff --git a/Task/Compound-data-type/ACL2/compound-data-type.acl2 b/Task/Compound-data-type/ACL2/compound-data-type.acl2
new file mode 100644
index 0000000000..bb1bff278a
--- /dev/null
+++ b/Task/Compound-data-type/ACL2/compound-data-type.acl2
@@ -0,0 +1,9 @@
+(defstructure point
+   (x (:assert (rationalp x)))
+   (y (:assert (rationalp y))))
+
+(assign p1 (make-point :x 1 :y 2))
+(point-x (@ p1)) ; Access the x value of the point
+(assign p1 (update-point (@ p1) :x 3)) ; Update the x value
+(point-x (@ p1))
+(point-p (@ p1)) ; Recognizer for points
diff --git a/Task/Compound-data-type/ALGOL-68/compound-data-type-1.alg b/Task/Compound-data-type/ALGOL-68/compound-data-type-1.alg
new file mode 100644
index 0000000000..337710d2b9
--- /dev/null
+++ b/Task/Compound-data-type/ALGOL-68/compound-data-type-1.alg
@@ -0,0 +1,8 @@
+MODE UNIONX = UNION(
+   STRUCT(REAL r, INT i),
+   INT,
+   REAL,
+   STRUCT(INT ii),
+   STRUCT(REAL rr),
+   STRUCT([]REAL r)
+);
diff --git a/Task/Compound-data-type/ALGOL-68/compound-data-type-2.alg b/Task/Compound-data-type/ALGOL-68/compound-data-type-2.alg
new file mode 100644
index 0000000000..7e171ba391
--- /dev/null
+++ b/Task/Compound-data-type/ALGOL-68/compound-data-type-2.alg
@@ -0,0 +1,9 @@
+UNIONX data := 6.6;
+CASE data IN
+   (INT i): printf(($"r: "gl$,i)),
+   (REAL r): printf(($"r: "gl$,r)),
+   (STRUCT(REAL r, INT i) s): printf(($"r&i: "2(g)l$,s)),
+   (STRUCT([]REAL r) s): printf(($"r: "n(UPB r OF s)(g)l$,s))
+OUT
+  printf($"Other cases"l$)
+ESAC;
diff --git a/Task/Compound-data-type/ALGOL-68/compound-data-type-3.alg b/Task/Compound-data-type/ALGOL-68/compound-data-type-3.alg
new file mode 100644
index 0000000000..6ec7554a66
--- /dev/null
+++ b/Task/Compound-data-type/ALGOL-68/compound-data-type-3.alg
@@ -0,0 +1,4 @@
+MODE POINT = STRUCT(
+   INT x,
+   INT y
+);
diff --git a/Task/Compound-data-type/ALGOL-68/compound-data-type-4.alg b/Task/Compound-data-type/ALGOL-68/compound-data-type-4.alg
new file mode 100644
index 0000000000..83ed9f5e92
--- /dev/null
+++ b/Task/Compound-data-type/ALGOL-68/compound-data-type-4.alg
@@ -0,0 +1,9 @@
+MODE PERSON = STRUCT(
+   STRING name,
+   REAL age,
+   REAL weight,
+   UNION (
+      STRUCT (REAL beard length),
+      VOID
+   ) gender details
+);
diff --git a/Task/Compound-data-type/AWK/compound-data-type.awk b/Task/Compound-data-type/AWK/compound-data-type.awk
new file mode 100644
index 0000000000..eb884beef8
--- /dev/null
+++ b/Task/Compound-data-type/AWK/compound-data-type.awk
@@ -0,0 +1,2 @@
+p["x"]=10
+p["y"]=42
diff --git a/Task/Compound-data-type/ActionScript/compound-data-type.as b/Task/Compound-data-type/ActionScript/compound-data-type.as
new file mode 100644
index 0000000000..a1406917c6
--- /dev/null
+++ b/Task/Compound-data-type/ActionScript/compound-data-type.as
@@ -0,0 +1,14 @@
+package
+{
+    public class Point
+    {
+        public var x:Number;
+        public var y:Number;
+
+        public function Point(x:Number, y:Number)
+        {
+            this.x = x;
+            this.y = y;
+        }
+    }
+}
diff --git a/Task/Compound-data-type/Ada/compound-data-type-1.ada b/Task/Compound-data-type/Ada/compound-data-type-1.ada
new file mode 100644
index 0000000000..db3bf141a0
--- /dev/null
+++ b/Task/Compound-data-type/Ada/compound-data-type-1.ada
@@ -0,0 +1,4 @@
+type Point is tagged record
+   X : Integer := 0;
+   Y : Integer := 0;
+end record;
diff --git a/Task/Compound-data-type/Ada/compound-data-type-2.ada b/Task/Compound-data-type/Ada/compound-data-type-2.ada
new file mode 100644
index 0000000000..c435b4ef48
--- /dev/null
+++ b/Task/Compound-data-type/Ada/compound-data-type-2.ada
@@ -0,0 +1,4 @@
+type Point is record
+   X : Integer := 0;
+   Y : Integer := 0;
+end record;
diff --git a/Task/Compound-data-type/Ada/compound-data-type-3.ada b/Task/Compound-data-type/Ada/compound-data-type-3.ada
new file mode 100644
index 0000000000..1ede5f843a
--- /dev/null
+++ b/Task/Compound-data-type/Ada/compound-data-type-3.ada
@@ -0,0 +1,11 @@
+type Person (Gender : Gender_Type) is record
+   Name   : Name_String;
+   Age    : Natural;
+   Weight : Float;
+   Case Gender is
+      when Male =>
+         Beard_Length : Float;
+      when Female =>
+         null;
+   end case;
+end record;
diff --git a/Task/Compound-data-type/AmigaE/compound-data-type.amiga b/Task/Compound-data-type/AmigaE/compound-data-type.amiga
new file mode 100644
index 0000000000..b29e16d846
--- /dev/null
+++ b/Task/Compound-data-type/AmigaE/compound-data-type.amiga
@@ -0,0 +1,12 @@
+OBJECT point
+  x, y
+ENDOBJECT
+
+PROC main()
+  DEF pt:PTR TO point,
+
+  NEW pt
+  pt.x := 10.4
+  pt.y := 3.14
+  END pt
+ENDPROC
diff --git a/Task/Compound-data-type/AutoHotkey/compound-data-type.ahk b/Task/Compound-data-type/AutoHotkey/compound-data-type.ahk
new file mode 100644
index 0000000000..bb424a7f95
--- /dev/null
+++ b/Task/Compound-data-type/AutoHotkey/compound-data-type.ahk
@@ -0,0 +1,3 @@
+point := Object()
+point.x := 1
+point.y := 0
diff --git a/Task/Compound-data-type/BASIC/compound-data-type.bas b/Task/Compound-data-type/BASIC/compound-data-type.bas
new file mode 100644
index 0000000000..6c5ad925ff
--- /dev/null
+++ b/Task/Compound-data-type/BASIC/compound-data-type.bas
@@ -0,0 +1,4 @@
+TYPE Point
+   x AS INTEGER
+   y AS INTEGER
+ END TYPE
diff --git a/Task/Compound-data-type/BBC-BASIC/compound-data-type.bbc b/Task/Compound-data-type/BBC-BASIC/compound-data-type.bbc
new file mode 100644
index 0000000000..1d0b3a11c6
--- /dev/null
+++ b/Task/Compound-data-type/BBC-BASIC/compound-data-type.bbc
@@ -0,0 +1 @@
+      DIM Point{x%, y%}
diff --git a/Task/Compound-data-type/Bracmat/compound-data-type.bracmat b/Task/Compound-data-type/Bracmat/compound-data-type.bracmat
new file mode 100644
index 0000000000..cab653a0eb
--- /dev/null
+++ b/Task/Compound-data-type/Bracmat/compound-data-type.bracmat
@@ -0,0 +1,11 @@
+( ( Point
+  =   (x=)
+      (y=)
+      (new=.!arg:(?(its.x).?(its.y)))
+  )
+& new$(Point,(3.4)):?pt
+& out$(!(pt..x) !(pt..y))
+  { Show independcy by changing x, but not y }
+& 7:?(pt..x)
+& out$(!(pt..x) !(pt..y))
+);
diff --git a/Task/Compound-data-type/C++/compound-data-type-1.cpp b/Task/Compound-data-type/C++/compound-data-type-1.cpp
new file mode 100644
index 0000000000..72a08ddad3
--- /dev/null
+++ b/Task/Compound-data-type/C++/compound-data-type-1.cpp
@@ -0,0 +1,5 @@
+struct Point
+{
+  int x;
+  int y;
+};
diff --git a/Task/Compound-data-type/C++/compound-data-type-2.cpp b/Task/Compound-data-type/C++/compound-data-type-2.cpp
new file mode 100644
index 0000000000..b20d34d3f2
--- /dev/null
+++ b/Task/Compound-data-type/C++/compound-data-type-2.cpp
@@ -0,0 +1,6 @@
+struct Point
+{
+  int x;
+  int y;
+  Point(int ax, int ay): x(ax), y(ax) {}
+};
diff --git a/Task/Compound-data-type/C++/compound-data-type-3.cpp b/Task/Compound-data-type/C++/compound-data-type-3.cpp
new file mode 100644
index 0000000000..da6d61c8fc
--- /dev/null
+++ b/Task/Compound-data-type/C++/compound-data-type-3.cpp
@@ -0,0 +1,10 @@
+template struct point
+{
+  Coordinate x, y;
+};
+
+// A point with integer coordinates
+Point point1 = { 3, 5 };
+
+// a point with floating point coordinates
+Point point2 = { 1.7, 3.6 };
diff --git a/Task/Compound-data-type/C/compound-data-type.c b/Task/Compound-data-type/C/compound-data-type.c
new file mode 100644
index 0000000000..a9cdfa9640
--- /dev/null
+++ b/Task/Compound-data-type/C/compound-data-type.c
@@ -0,0 +1,5 @@
+typedef struct Point
+{
+  int x;
+  int y;
+} Point;
diff --git a/Task/Compound-data-type/Clean/compound-data-type-1.clean b/Task/Compound-data-type/Clean/compound-data-type-1.clean
new file mode 100644
index 0000000000..3ed077659a
--- /dev/null
+++ b/Task/Compound-data-type/Clean/compound-data-type-1.clean
@@ -0,0 +1 @@
+:: Point = { x :: Int, y :: Int }
diff --git a/Task/Compound-data-type/Clean/compound-data-type-2.clean b/Task/Compound-data-type/Clean/compound-data-type-2.clean
new file mode 100644
index 0000000000..e906f98024
--- /dev/null
+++ b/Task/Compound-data-type/Clean/compound-data-type-2.clean
@@ -0,0 +1 @@
+:: Point a = Point a a  // usage: (Point Int)
diff --git a/Task/Compound-data-type/Clean/compound-data-type-3.clean b/Task/Compound-data-type/Clean/compound-data-type-3.clean
new file mode 100644
index 0000000000..342ade94c6
--- /dev/null
+++ b/Task/Compound-data-type/Clean/compound-data-type-3.clean
@@ -0,0 +1 @@
+:: Point :== (Int, Int)
diff --git a/Task/Compound-data-type/Clojure/compound-data-type-1.clj b/Task/Compound-data-type/Clojure/compound-data-type-1.clj
new file mode 100644
index 0000000000..533c5ce011
--- /dev/null
+++ b/Task/Compound-data-type/Clojure/compound-data-type-1.clj
@@ -0,0 +1 @@
+(defrecord Point [x y])
diff --git a/Task/Compound-data-type/Clojure/compound-data-type-2.clj b/Task/Compound-data-type/Clojure/compound-data-type-2.clj
new file mode 100644
index 0000000000..01496ae573
--- /dev/null
+++ b/Task/Compound-data-type/Clojure/compound-data-type-2.clj
@@ -0,0 +1,3 @@
+(def p (Point. 0 1))
+(assert (= 0 (:x p)))
+(assert (= 1 (:y p)))
diff --git a/Task/Compound-data-type/CoffeeScript/compound-data-type.coffee b/Task/Compound-data-type/CoffeeScript/compound-data-type.coffee
new file mode 100644
index 0000000000..f1bb228a16
--- /dev/null
+++ b/Task/Compound-data-type/CoffeeScript/compound-data-type.coffee
@@ -0,0 +1,20 @@
+# Lightweight JS objects (with CS sugar).
+point =
+  x: 5
+  y: 3
+
+console.log point.x, point.y # 5 3
+
+# Heavier OO style
+class Point
+  constructor: (@x, @y) ->
+  distance_from: (p2) ->
+    dx = p2.x - @x
+    dy = p2.y - @y
+    Math.sqrt dx*dx + dy*dy
+
+p1 = new Point(1, 6)
+p2 = new Point(6, 18)
+console.log p1 # { x: 1, y: 6 }
+console.log p1.distance_from # [Function]
+console.log p1.distance_from p2 # 13
diff --git a/Task/Compound-data-type/Common-Lisp/compound-data-type-1.lisp b/Task/Compound-data-type/Common-Lisp/compound-data-type-1.lisp
new file mode 100644
index 0000000000..a4c67bb138
--- /dev/null
+++ b/Task/Compound-data-type/Common-Lisp/compound-data-type-1.lisp
@@ -0,0 +1,2 @@
+CL-USER> (defstruct point (x 0) (y 0))  ;If not provided, x or y default to 0
+POINT
diff --git a/Task/Compound-data-type/Common-Lisp/compound-data-type-2.lisp b/Task/Compound-data-type/Common-Lisp/compound-data-type-2.lisp
new file mode 100644
index 0000000000..f290869e46
--- /dev/null
+++ b/Task/Compound-data-type/Common-Lisp/compound-data-type-2.lisp
@@ -0,0 +1,12 @@
+CL-USER> (setf a (make-point))          ;The default constructor using the default values for x and y
+#S(POINT :X 0 :Y 0)
+CL-USER> (setf b (make-point :x 5.5 :y #C(0 1)))  ;Dynamic datatypes are the default
+#S(POINT :X 5.5 :Y #C(0 1))                       ;y has been set to the imaginary number i (using the Common Lisp complex number data type)
+CL-USER> (point-x b)                    ;The default name for the accessor functions is structname-slotname
+5.5
+CL-USER> (point-y b)
+#C(0 1)
+CL-USER> (setf (point-y b) 3)           ;The accessor is setfable
+3
+CL-USER> (point-y b)
+3
diff --git a/Task/Compound-data-type/D/compound-data-type.d b/Task/Compound-data-type/D/compound-data-type.d
new file mode 100644
index 0000000000..24fa2745e3
--- /dev/null
+++ b/Task/Compound-data-type/D/compound-data-type.d
@@ -0,0 +1,47 @@
+void main() {
+    // A normal POD struct
+    // (if it's nested and it's not static then it has a hidden
+    // field that points to the enclosing function):
+    static struct Point {
+        int x, y;
+    }
+
+    auto p1 = Point(10, 20);
+
+    // It can also be parametrized on the coordinate type:
+    static struct Pair(T) {
+        T x, y;
+    }
+
+    // A pair with integer coordinates:
+    auto p2 = Pair!int(3, 5);
+
+    // A pair with floating point coordinates:
+    auto p3 = Pair!double(3, 5);
+
+    // Classes (static inner):
+    static class PointClass {
+        int x, y;
+        this(int x_, int y_) {
+            this.x = x_;
+            this.y = y_;
+        }
+    }
+
+    auto p4 = new PointClass(1, 2);
+
+    // There are also library-defined tuples:
+    import std.typecons;
+
+    alias Tuple!(int,"x", int,"y") PointXY;
+
+    auto p5 = PointXY(3, 5);
+
+    // And even built-in "type tuples":
+    import std.typetuple;
+
+    alias TypeTuple!(int, 5) p6;
+
+    static assert(is(p6[0] == int));
+    static assert(p6[1] == 5);
+}
diff --git a/Task/Compound-data-type/Delphi/compound-data-type.delphi b/Task/Compound-data-type/Delphi/compound-data-type.delphi
new file mode 100644
index 0000000000..8249d8c64e
--- /dev/null
+++ b/Task/Compound-data-type/Delphi/compound-data-type.delphi
@@ -0,0 +1,4 @@
+  TPoint = record
+    X: Longint;
+    Y: Longint;
+  end;
diff --git a/Task/Compound-data-type/E/compound-data-type.e b/Task/Compound-data-type/E/compound-data-type.e
new file mode 100644
index 0000000000..c602574a1e
--- /dev/null
+++ b/Task/Compound-data-type/E/compound-data-type.e
@@ -0,0 +1,7 @@
+def makePoint(x, y) {
+    def point {
+        to getX() { return x }
+        to getY() { return y }
+    }
+    return point
+}
diff --git a/Task/Compound-data-type/Ela/compound-data-type-1.ela b/Task/Compound-data-type/Ela/compound-data-type-1.ela
new file mode 100644
index 0000000000..9b55deb1f4
--- /dev/null
+++ b/Task/Compound-data-type/Ela/compound-data-type-1.ela
@@ -0,0 +1 @@
+type Maybe = None | Some a
diff --git a/Task/Compound-data-type/Ela/compound-data-type-2.ela b/Task/Compound-data-type/Ela/compound-data-type-2.ela
new file mode 100644
index 0000000000..525a48795e
--- /dev/null
+++ b/Task/Compound-data-type/Ela/compound-data-type-2.ela
@@ -0,0 +1,4 @@
+opentype Several = One | Two | Three
+
+//Add new constructor to an existing type
+data Several = Four
diff --git a/Task/Compound-data-type/Erlang/compound-data-type.erl b/Task/Compound-data-type/Erlang/compound-data-type.erl
new file mode 100644
index 0000000000..0f6bde522e
--- /dev/null
+++ b/Task/Compound-data-type/Erlang/compound-data-type.erl
@@ -0,0 +1,10 @@
+-module(records_test).
+-compile(export_all).
+
+-record(point,{x,y}).
+
+test() ->
+    P1 = #point{x=1.0,y=2.0}, % creates a new point record
+    io:fwrite("X: ~f, Y: ~f~n",[P1#point.x,P1#point.y]),
+    P2 = P1#point{x=3.0}, % creates a new point record with x set to 3.0, y is copied from P1
+    io:fwrite("X: ~f, Y: ~f~n",[P2#point.x,P2#point.y]).
diff --git a/Task/Compound-data-type/Forth/compound-data-type-1.fth b/Task/Compound-data-type/Forth/compound-data-type-1.fth
new file mode 100644
index 0000000000..5030415c56
--- /dev/null
+++ b/Task/Compound-data-type/Forth/compound-data-type-1.fth
@@ -0,0 +1,7 @@
+: pt>x ( point -- x ) ;
+: pt>y ( point -- y ) CELL+ ;
+: .pt ( point -- ) dup pt>x @ . pt>y @ . ;    \ or for this simple structure, 2@ . .
+
+create point 6 , 0 ,
+7 point pt>y !
+.pt    \ 6 7
diff --git a/Task/Compound-data-type/Forth/compound-data-type-2.fth b/Task/Compound-data-type/Forth/compound-data-type-2.fth
new file mode 100644
index 0000000000..15950b85c2
--- /dev/null
+++ b/Task/Compound-data-type/Forth/compound-data-type-2.fth
@@ -0,0 +1,4 @@
+struct
+  cell% field pt>x
+  cell% field pt>y
+end-struct point%
diff --git a/Task/Compound-data-type/Fortran/compound-data-type.f b/Task/Compound-data-type/Fortran/compound-data-type.f
new file mode 100644
index 0000000000..6b57e23560
--- /dev/null
+++ b/Task/Compound-data-type/Fortran/compound-data-type.f
@@ -0,0 +1,22 @@
+program typedemo
+    type rational                                           ! Type declaration
+        integer :: numerator
+        integer :: denominator
+    end type rational
+
+    type( rational ), parameter :: zero = rational( 0, 1 )  ! Variables initialized
+    type( rational ), parameter :: one  = rational( 1, 1 )  ! by constructor syntax
+    type( rational ), parameter :: half = rational( 1, 2 )
+    integer :: n, halfd, halfn
+    type( rational ) :: &
+        one_over_n(20) = (/ (rational( 1, n ), n = 1, 20) /) ! Array initialized with
+                                                             ! constructor inside
+                                                             ! implied-do array initializer
+    integer :: oon_denoms(20)
+
+    halfd = half%denominator                       ! field access with "%" delimiter
+    halfn = half%numerator
+
+    oon_denoms = one_over_n%denominator            ! Access denominator field in every
+                                                   ! rational array element & store
+end program typedemo                               ! as integer array
diff --git a/Task/Compound-data-type/Go/compound-data-type.go b/Task/Compound-data-type/Go/compound-data-type.go
new file mode 100644
index 0000000000..8d999f8ea6
--- /dev/null
+++ b/Task/Compound-data-type/Go/compound-data-type.go
@@ -0,0 +1,11 @@
+package main
+
+import "fmt"
+
+type point struct {
+    x, y float64
+}
+
+func main() {
+    fmt.Println(point{3, 4})
+}
diff --git a/Task/Compound-data-type/Haskell/compound-data-type.hs b/Task/Compound-data-type/Haskell/compound-data-type.hs
new file mode 100644
index 0000000000..e08398a71a
--- /dev/null
+++ b/Task/Compound-data-type/Haskell/compound-data-type.hs
@@ -0,0 +1 @@
+p = (2,3)
diff --git a/Task/Compound-data-type/Java/compound-data-type.java b/Task/Compound-data-type/Java/compound-data-type.java
new file mode 100644
index 0000000000..d1d8941dd1
--- /dev/null
+++ b/Task/Compound-data-type/Java/compound-data-type.java
@@ -0,0 +1,14 @@
+public class Point
+{
+  public int x, y;
+  public Point() { this(0); }
+  public Point(int x0) { this(x0,0); }
+  public Point(int x0, int y0) { x = x0; y = y0; }
+
+  public static void main(String args[])
+  {
+    Point point = new Point(1,2);
+    System.out.println("x = " + point.x );
+    System.out.println("y = " + point.y );
+  }
+}
diff --git a/Task/Compound-data-type/JavaScript/compound-data-type.js b/Task/Compound-data-type/JavaScript/compound-data-type.js
new file mode 100644
index 0000000000..b5fe6df70a
--- /dev/null
+++ b/Task/Compound-data-type/JavaScript/compound-data-type.js
@@ -0,0 +1 @@
+var point = {x : 1, y : 2};
diff --git a/Task/Compound-data-type/Lua/compound-data-type-1.lua b/Task/Compound-data-type/Lua/compound-data-type-1.lua
new file mode 100644
index 0000000000..596afed81c
--- /dev/null
+++ b/Task/Compound-data-type/Lua/compound-data-type-1.lua
@@ -0,0 +1,8 @@
+a = {x = 1; y = 2}
+b = {x = 3; y = 4}
+c = {
+    x = a.x + b.x;
+    y = a.y + b.y
+}
+print(a.x, a.y)  --> 1 2
+print(c.x, c.y)  --> 4 6
diff --git a/Task/Compound-data-type/Lua/compound-data-type-2.lua b/Task/Compound-data-type/Lua/compound-data-type-2.lua
new file mode 100644
index 0000000000..68c3809f30
--- /dev/null
+++ b/Task/Compound-data-type/Lua/compound-data-type-2.lua
@@ -0,0 +1,9 @@
+cPoint = {}                                           -- metatable (behaviour table)
+function newPoint(x, y)                               -- constructor
+    local pointPrototype = {}                         -- prototype declaration
+    function pointPrototype:getX() return x end       -- public method
+    function pointPrototype:getY() return y end       -- public method
+    function pointPrototype:getXY() return x, y end   -- public method
+    function pointPrototype:type() return "point" end -- public method
+    return setmetatable(pointPrototype, cPoint)       -- set behaviour and return the pointPrototype
+end--newPoint
diff --git a/Task/Compound-data-type/Lua/compound-data-type-3.lua b/Task/Compound-data-type/Lua/compound-data-type-3.lua
new file mode 100644
index 0000000000..cfe510be66
--- /dev/null
+++ b/Task/Compound-data-type/Lua/compound-data-type-3.lua
@@ -0,0 +1,9 @@
+local oldtype = type;                   -- store original type function
+function type(v)
+    local vType = oldtype(v)
+    if (vType=="table" and v.type) then
+        return v:type()                 -- bypass original type function if possible
+    else
+        return vType
+    end--if vType=="table"
+end--type
diff --git a/Task/Compound-data-type/Lua/compound-data-type-4.lua b/Task/Compound-data-type/Lua/compound-data-type-4.lua
new file mode 100644
index 0000000000..cf38e4d7ba
--- /dev/null
+++ b/Task/Compound-data-type/Lua/compound-data-type-4.lua
@@ -0,0 +1,14 @@
+function cPoint.__add(op1, op2)  -- add the x and y components
+    if type(op1)=="point" and type(op2)=="point" then
+        return newPoint(
+            op1:getX()+op2:getX(),
+            op1:getY()+op2:getY())
+    end--if type(op1)
+end--cPoint.__add
+function cPoint.__sub(op1, op2)  -- subtract the x and y components
+    if (type(op1)=="point" and type(op2)=="point") then
+        return newPoint(
+            op1:getX()-op2:getX(),
+            op1:getY()-op2:getY())
+    end--if type(op1)
+end--cPoint.__sub
diff --git a/Task/Compound-data-type/Lua/compound-data-type-5.lua b/Task/Compound-data-type/Lua/compound-data-type-5.lua
new file mode 100644
index 0000000000..d99400c334
--- /dev/null
+++ b/Task/Compound-data-type/Lua/compound-data-type-5.lua
@@ -0,0 +1,7 @@
+a = newPoint(1, 2)
+b = newPoint(3, 4)
+c = a + b             -- using __add behaviour
+print(a:getXY())      --> 1 2
+print(type(a))        --> point
+print(c:getXY())      --> 4 6
+print((a-b):getXY())  --> -2 -2  -- using __sub behaviour
diff --git a/Task/Compound-data-type/PHP/compound-data-type-1.php b/Task/Compound-data-type/PHP/compound-data-type-1.php
new file mode 100644
index 0000000000..b697049661
--- /dev/null
+++ b/Task/Compound-data-type/PHP/compound-data-type-1.php
@@ -0,0 +1,10 @@
+# Using pack/unpack
+$point = pack("ii", 1, 2);
+
+$u = unpack("ix/iy", $point);
+echo $x;
+echo $y;
+
+list($x,$y) = unpack("ii", $point);
+echo $x;
+echo $y;
diff --git a/Task/Compound-data-type/PHP/compound-data-type-2.php b/Task/Compound-data-type/PHP/compound-data-type-2.php
new file mode 100644
index 0000000000..1720569116
--- /dev/null
+++ b/Task/Compound-data-type/PHP/compound-data-type-2.php
@@ -0,0 +1,8 @@
+# Using array
+$point = array('x' => 1, 'y' => 2);
+
+list($x, $y) = $point;
+echo $x, ' ', $y, "\n";
+
+# or simply:
+echo $point['x'], ' ', $point['y'], "\n";
diff --git a/Task/Compound-data-type/PHP/compound-data-type-3.php b/Task/Compound-data-type/PHP/compound-data-type-3.php
new file mode 100644
index 0000000000..87afadd40f
--- /dev/null
+++ b/Task/Compound-data-type/PHP/compound-data-type-3.php
@@ -0,0 +1,7 @@
+# Using class
+class Point {
+  function __construct($x, $y) { $this->x = $x; $this->y = $y; }
+  function __tostring() { return $this->x . ' ' . $this->y . "\n"; }
+}
+$point = new Point(1, 2);
+echo $point; # will call __tostring() in later releases of PHP 5.2; before that, it won't work so good.
diff --git a/Task/Compound-data-type/Perl/compound-data-type-1.pl b/Task/Compound-data-type/Perl/compound-data-type-1.pl
new file mode 100644
index 0000000000..8073a94be3
--- /dev/null
+++ b/Task/Compound-data-type/Perl/compound-data-type-1.pl
@@ -0,0 +1 @@
+my @point = (3, 8);
diff --git a/Task/Compound-data-type/Perl/compound-data-type-2.pl b/Task/Compound-data-type/Perl/compound-data-type-2.pl
new file mode 100644
index 0000000000..45b1111b70
--- /dev/null
+++ b/Task/Compound-data-type/Perl/compound-data-type-2.pl
@@ -0,0 +1,4 @@
+my %point = (
+   x => 3,
+   y => 8
+);
diff --git a/Task/Compound-data-type/Perl/compound-data-type-3.pl b/Task/Compound-data-type/Perl/compound-data-type-3.pl
new file mode 100644
index 0000000000..38449942a7
--- /dev/null
+++ b/Task/Compound-data-type/Perl/compound-data-type-3.pl
@@ -0,0 +1,9 @@
+package Point;
+
+use strict;
+use base 'Class::Struct'
+    x => '$',
+    y => '$',
+;
+
+my $point = Point->new(x => 3, y => 8);
diff --git a/Task/Compound-data-type/PicoLisp/compound-data-type.l b/Task/Compound-data-type/PicoLisp/compound-data-type.l
new file mode 100644
index 0000000000..da7e7bae1e
--- /dev/null
+++ b/Task/Compound-data-type/PicoLisp/compound-data-type.l
@@ -0,0 +1,9 @@
+(class +Point)
+
+(dm T (X Y)
+   (=: x X)
+   (=: y Y) )
+
+(setq P (new '(+Point) 3 4))
+
+(show P)
diff --git a/Task/Compound-data-type/Python/compound-data-type-1.py b/Task/Compound-data-type/Python/compound-data-type-1.py
new file mode 100644
index 0000000000..0cf808f9de
--- /dev/null
+++ b/Task/Compound-data-type/Python/compound-data-type-1.py
@@ -0,0 +1,5 @@
+X, Y = 0, 1
+p = (3, 4)
+p = [3, 4]
+
+print p[X]
diff --git a/Task/Compound-data-type/Python/compound-data-type-2.py b/Task/Compound-data-type/Python/compound-data-type-2.py
new file mode 100644
index 0000000000..5c01436aa6
--- /dev/null
+++ b/Task/Compound-data-type/Python/compound-data-type-2.py
@@ -0,0 +1,7 @@
+class Point:
+    def __init__(self, x=0, y=0):
+        self.x = x
+        self.y = y
+
+p = Point()
+print p.x
diff --git a/Task/Compound-data-type/Python/compound-data-type-3.py b/Task/Compound-data-type/Python/compound-data-type-3.py
new file mode 100644
index 0000000000..27444c4fea
--- /dev/null
+++ b/Task/Compound-data-type/Python/compound-data-type-3.py
@@ -0,0 +1,5 @@
+class MyObject(object): pass
+point = MyObject()
+point.x, point.y = 0, 1
+# objects directly instantiated from "object()"  cannot be "monkey patched"
+# however this can generally be done to it's subclasses
diff --git a/Task/Compound-data-type/Python/compound-data-type-4.py b/Task/Compound-data-type/Python/compound-data-type-4.py
new file mode 100644
index 0000000000..aec9631f30
--- /dev/null
+++ b/Task/Compound-data-type/Python/compound-data-type-4.py
@@ -0,0 +1,27 @@
+>>> from collections import namedtuple
+>>> help(namedtuple)
+Help on function namedtuple in module collections:
+
+namedtuple(typename, field_names, verbose=False)
+    Returns a new subclass of tuple with named fields.
+
+    >>> Point = namedtuple('Point', 'x y')
+    >>> Point.__doc__                   # docstring for the new class
+    'Point(x, y)'
+    >>> p = Point(11, y=22)             # instantiate with positional args or keywords
+    >>> p[0] + p[1]                     # indexable like a plain tuple
+    33
+    >>> x, y = p                        # unpack like a regular tuple
+    >>> x, y
+    (11, 22)
+    >>> p.x + p.y                       # fields also accessable by name
+    33
+    >>> d = p._asdict()                 # convert to a dictionary
+    >>> d['x']
+    11
+    >>> Point(**d)                      # convert from a dictionary
+    Point(x=11, y=22)
+    >>> p._replace(x=100)               # _replace() is like str.replace() but targets named fields
+    Point(x=100, y=22)
+
+>>>
diff --git a/Task/Compound-data-type/R/compound-data-type.r b/Task/Compound-data-type/R/compound-data-type.r
new file mode 100644
index 0000000000..41b84471b4
--- /dev/null
+++ b/Task/Compound-data-type/R/compound-data-type.r
@@ -0,0 +1,20 @@
+mypoint <- list(x=3.4, y=6.7)
+# $x
+# [1] 3.4
+# $y
+# [1] 6.7
+mypoint$x    # 3.4
+
+list(a=1:10, b="abc", c=runif(10), d=list(e=1L, f=TRUE))
+# $a
+# [1]  1  2  3  4  5  6  7  8  9 10
+# $b
+# [1] "abc"
+# $c
+#  [1] 0.64862897 0.73669435 0.11138945 0.10408015 0.46843836 0.32351247
+#  [7] 0.20528914 0.78512472 0.06139691 0.76937113
+# $d
+# $d$e
+# [1] 1
+# $d$f
+# [1] TRUE
diff --git a/Task/Compound-data-type/REXX/compound-data-type-1.rexx b/Task/Compound-data-type/REXX/compound-data-type-1.rexx
new file mode 100644
index 0000000000..d8541d556b
--- /dev/null
+++ b/Task/Compound-data-type/REXX/compound-data-type-1.rexx
@@ -0,0 +1,4 @@
+x= -4.9
+y=  1.7
+
+point=x y
diff --git a/Task/Compound-data-type/REXX/compound-data-type-2.rexx b/Task/Compound-data-type/REXX/compound-data-type-2.rexx
new file mode 100644
index 0000000000..628b298df3
--- /dev/null
+++ b/Task/Compound-data-type/REXX/compound-data-type-2.rexx
@@ -0,0 +1,8 @@
+x= -4.1
+y=  1/4e21
+
+point=x y
+
+bpoint=point
+
+gpoint=5.6  7.3e-12
diff --git a/Task/Compound-data-type/Racket/compound-data-type-1.rkt b/Task/Compound-data-type/Racket/compound-data-type-1.rkt
new file mode 100644
index 0000000000..355e567fe7
--- /dev/null
+++ b/Task/Compound-data-type/Racket/compound-data-type-1.rkt
@@ -0,0 +1,2 @@
+#lang racket
+(struct point (x y))
diff --git a/Task/Compound-data-type/Racket/compound-data-type-2.rkt b/Task/Compound-data-type/Racket/compound-data-type-2.rkt
new file mode 100644
index 0000000000..aaf8b840d3
--- /dev/null
+++ b/Task/Compound-data-type/Racket/compound-data-type-2.rkt
@@ -0,0 +1,5 @@
+#lang racket
+(define point% ; classes are suffixed with % by convention
+  (class object%
+    (super-new)
+    (init-field x y)))
diff --git a/Task/Compound-data-type/Ruby/compound-data-type.rb b/Task/Compound-data-type/Ruby/compound-data-type.rb
new file mode 100644
index 0000000000..37e33cf286
--- /dev/null
+++ b/Task/Compound-data-type/Ruby/compound-data-type.rb
@@ -0,0 +1,5 @@
+Point = Struct.new(:x,:y)
+p = Point.new(6,7)
+p.y=3
+puts p
+=> #
diff --git a/Task/Compound-data-type/Scala/compound-data-type.scala b/Task/Compound-data-type/Scala/compound-data-type.scala
new file mode 100644
index 0000000000..7642545827
--- /dev/null
+++ b/Task/Compound-data-type/Scala/compound-data-type.scala
@@ -0,0 +1,4 @@
+case class Point(x:Int=0, y:Int=0)
+
+val p=Point(1,2)
+println(p.y)   //=> 2
diff --git a/Task/Compound-data-type/Scheme/compound-data-type.ss b/Task/Compound-data-type/Scheme/compound-data-type.ss
new file mode 100644
index 0000000000..35fd811c2a
--- /dev/null
+++ b/Task/Compound-data-type/Scheme/compound-data-type.ss
@@ -0,0 +1,5 @@
+(define-record-type point
+    (make-point x y)
+    point?
+    (x point-x)
+    (y point-y))
diff --git a/Task/Compound-data-type/Tcl/compound-data-type-1.tcl b/Task/Compound-data-type/Tcl/compound-data-type-1.tcl
new file mode 100644
index 0000000000..fce21dae51
--- /dev/null
+++ b/Task/Compound-data-type/Tcl/compound-data-type-1.tcl
@@ -0,0 +1,4 @@
+array set point {x 4 y 5}
+set point(y) 7
+puts "Point is {$point(x),$point(y)}"
+# => Point is {4,7}
diff --git a/Task/Compound-data-type/Tcl/compound-data-type-2.tcl b/Task/Compound-data-type/Tcl/compound-data-type-2.tcl
new file mode 100644
index 0000000000..393c534ab9
--- /dev/null
+++ b/Task/Compound-data-type/Tcl/compound-data-type-2.tcl
@@ -0,0 +1,3 @@
+set point [dict create x 4 y 5]
+dict set point y 7
+puts "Point is {[dict get $point x],[dict get $point y]}"
diff --git a/Task/Compound-data-type/Tcl/compound-data-type-3.tcl b/Task/Compound-data-type/Tcl/compound-data-type-3.tcl
new file mode 100644
index 0000000000..37533cd8f7
--- /dev/null
+++ b/Task/Compound-data-type/Tcl/compound-data-type-3.tcl
@@ -0,0 +1,10 @@
+oo::class create Point {
+    variable x y
+    constructor {X Y} {set x $X;set y $Y}
+    method x {args} {set x {*}$args}
+    method y {args} {set y {*}$args}
+    method show {} {return "{$x,$y}"}
+}
+Point create point 4 5
+point y 7
+puts "Point is [point show]"
diff --git a/Task/Concurrent-computing/0DESCRIPTION b/Task/Concurrent-computing/0DESCRIPTION
new file mode 100644
index 0000000000..fe26cd2fcf
--- /dev/null
+++ b/Task/Concurrent-computing/0DESCRIPTION
@@ -0,0 +1 @@
+Using either native language concurrency syntax or freely available libraries write a program to display the strings "Enjoy" "Rosetta" "Code", one string per line, in random order. Concurrency syntax must use [[thread|threads]], tasks, co-routines, or whatever concurrency is called in your language.
diff --git a/Task/Concurrent-computing/1META.yaml b/Task/Concurrent-computing/1META.yaml
new file mode 100644
index 0000000000..e6c1282cd4
--- /dev/null
+++ b/Task/Concurrent-computing/1META.yaml
@@ -0,0 +1,4 @@
+---
+category:
+- Basic language learning
+note: Concurrency
diff --git a/Task/Concurrent-computing/ALGOL-68/concurrent-computing.alg b/Task/Concurrent-computing/ALGOL-68/concurrent-computing.alg
new file mode 100644
index 0000000000..e927ec2dcc
--- /dev/null
+++ b/Task/Concurrent-computing/ALGOL-68/concurrent-computing.alg
@@ -0,0 +1,9 @@
+main:(
+  PROC echo = (STRING string)VOID:
+      printf(($gl$,string));
+  PAR(
+    echo("Enjoy"),
+    echo("Rosetta"),
+    echo("Code")
+  )
+)
diff --git a/Task/Concurrent-computing/Ada/concurrent-computing.ada b/Task/Concurrent-computing/Ada/concurrent-computing.ada
new file mode 100644
index 0000000000..5a5ed89e86
--- /dev/null
+++ b/Task/Concurrent-computing/Ada/concurrent-computing.ada
@@ -0,0 +1,17 @@
+with Ada.Text_IO, Ada.Numerics.Float_Random;
+
+procedure Concurrent_Hello is
+   type Messages is (Enjoy, Rosetta, Code);
+   task type Writer (Message : Messages);
+   task body Writer is
+      Seed : Ada.Numerics.Float_Random.Generator;
+   begin
+      Ada.Numerics.Float_Random.Reset (Seed); -- time-dependent, see ARM A.5.2
+      delay Duration (Ada.Numerics.Float_Random.Random (Seed));
+      Ada.Text_IO.Put_Line (Messages'Image(Message));
+   end Writer;
+   Taks: array(Messages) of access Writer -- 3 Writer tasks will immediately run
+     := (new Writer(Enjoy), new Writer(Rosetta), new Writer(Code));
+begin
+   null; -- the "environment task" doesn't need to do anything
+end Concurrent_Hello;
diff --git a/Task/Concurrent-computing/BBC-BASIC/concurrent-computing.bbc b/Task/Concurrent-computing/BBC-BASIC/concurrent-computing.bbc
new file mode 100644
index 0000000000..ad0f03a7ca
--- /dev/null
+++ b/Task/Concurrent-computing/BBC-BASIC/concurrent-computing.bbc
@@ -0,0 +1,31 @@
+      INSTALL @lib$+"TIMERLIB"
+
+      tID1% = FN_ontimer(100, PROCtask1, 1)
+      tID2% = FN_ontimer(100, PROCtask2, 1)
+      tID3% = FN_ontimer(100, PROCtask3, 1)
+
+      ON ERROR PRINT REPORT$ : PROCcleanup : END
+      ON CLOSE PROCcleanup : QUIT
+
+      REPEAT
+        WAIT 0
+      UNTIL FALSE
+      END
+
+      DEF PROCtask1
+      PRINT "Enjoy"
+      ENDPROC
+
+      DEF PROCtask2
+      PRINT "Rosetta"
+      ENDPROC
+
+      DEF PROCtask3
+      PRINT "Code"
+      ENDPROC
+
+      DEF PROCcleanup
+      PROC_killtimer(tID1%)
+      PROC_killtimer(tID2%)
+      PROC_killtimer(tID3%)
+      ENDPROC
diff --git a/Task/Concurrent-computing/C++/concurrent-computing.cpp b/Task/Concurrent-computing/C++/concurrent-computing.cpp
new file mode 100644
index 0000000000..dad8ecbf6a
--- /dev/null
+++ b/Task/Concurrent-computing/C++/concurrent-computing.cpp
@@ -0,0 +1,20 @@
+#include 
+#include  // MSVC++
+
+void a(void) { std::cout << "Eat\n";   }
+void b(void) { std::cout << "At\n";    }
+void c(void) { std::cout << "Joe's\n"; }
+
+int main()
+{
+    // function pointers
+    Concurrency::parallel_invoke(&a, &b, &c);
+
+    // C++11 lambda functions
+    Concurrency::parallel_invoke(
+        []{ std::cout << "Enjoy\n";   },
+        []{ std::cout << "Rosetta\n"; },
+        []{ std::cout << "Code\n";    }
+    );
+    return 0;
+}
diff --git a/Task/Concurrent-computing/C/concurrent-computing-1.c b/Task/Concurrent-computing/C/concurrent-computing-1.c
new file mode 100644
index 0000000000..0e597e9423
--- /dev/null
+++ b/Task/Concurrent-computing/C/concurrent-computing-1.c
@@ -0,0 +1,56 @@
+#include 
+#include 
+#include 
+
+pthread_mutex_t condm = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+int bang = 0;
+
+#define WAITBANG() do { \
+   pthread_mutex_lock(&condm); \
+   while( bang == 0 ) \
+   { \
+      pthread_cond_wait(&cond, &condm); \
+   } \
+   pthread_mutex_unlock(&condm); } while(0);\
+
+void *t_enjoy(void *p)
+{
+  WAITBANG();
+  printf("Enjoy\n");
+  pthread_exit(0);
+}
+
+void *t_rosetta(void *p)
+{
+  WAITBANG();
+  printf("Rosetta\n");
+  pthread_exit(0);
+}
+
+void *t_code(void *p)
+{
+  WAITBANG();
+  printf("Code\n");
+  pthread_exit(0);
+}
+
+typedef void *(*threadfunc)(void *);
+int main()
+{
+   int i;
+   pthread_t a[3];
+   threadfunc p[3] = {t_enjoy, t_rosetta, t_code};
+
+   for(i=0;i<3;i++)
+   {
+     pthread_create(&a[i], NULL, p[i], NULL);
+   }
+   sleep(1);
+   bang = 1;
+   pthread_cond_broadcast(&cond);
+   for(i=0;i<3;i++)
+   {
+     pthread_join(a[i], NULL);
+   }
+}
diff --git a/Task/Concurrent-computing/C/concurrent-computing-2.c b/Task/Concurrent-computing/C/concurrent-computing-2.c
new file mode 100644
index 0000000000..d965da14a3
--- /dev/null
+++ b/Task/Concurrent-computing/C/concurrent-computing-2.c
@@ -0,0 +1,11 @@
+#include 
+#include 
+
+int main()
+{
+	const char *str[] = { "Enjoy", "Rosetta", "Code" };
+	#pragma omp parallel for num_threads(3)
+	for (int i = 0; i < 3; i++)
+		printf("%s\n", str[i]);
+	return 0;
+}
diff --git a/Task/Concurrent-computing/Clojure/concurrent-computing.clj b/Task/Concurrent-computing/Clojure/concurrent-computing.clj
new file mode 100644
index 0000000000..3258076963
--- /dev/null
+++ b/Task/Concurrent-computing/Clojure/concurrent-computing.clj
@@ -0,0 +1,2 @@
+(doseq [text ["Enjoy" "Rosetta" "Code"]]
+  (future (println text)))
diff --git a/Task/Concurrent-computing/CoffeeScript/concurrent-computing.coffee b/Task/Concurrent-computing/CoffeeScript/concurrent-computing.coffee
new file mode 100644
index 0000000000..b893a9ffd3
--- /dev/null
+++ b/Task/Concurrent-computing/CoffeeScript/concurrent-computing.coffee
@@ -0,0 +1,5 @@
+exec = require('child_process').exec
+
+for word in ["Enjoy", "Rosetta", "Code"]
+    exec "echo #{word}", (err, stdout) ->
+        console.log stdout
diff --git a/Task/Concurrent-computing/Common-Lisp/concurrent-computing.lisp b/Task/Concurrent-computing/Common-Lisp/concurrent-computing.lisp
new file mode 100644
index 0000000000..49bc8fc1d1
--- /dev/null
+++ b/Task/Concurrent-computing/Common-Lisp/concurrent-computing.lisp
@@ -0,0 +1,10 @@
+(defun concurrency-example (&optional (out *standard-output*))
+  (let ((lock (bordeaux-threads:make-lock)))
+    (flet ((writer (string)
+             #'(lambda ()
+                 (bordeaux-threads:acquire-lock lock t)
+                 (write-line string out)
+                 (bordeaux-threads:release-lock lock))))
+      (bordeaux-threads:make-thread (writer "Enjoy"))
+      (bordeaux-threads:make-thread (writer "Rosetta"))
+      (bordeaux-threads:make-thread (writer "Code")))))
diff --git a/Task/Concurrent-computing/D/concurrent-computing-1.d b/Task/Concurrent-computing/D/concurrent-computing-1.d
new file mode 100644
index 0000000000..a90f25d3ae
--- /dev/null
+++ b/Task/Concurrent-computing/D/concurrent-computing-1.d
@@ -0,0 +1,8 @@
+import std.stdio, std.random, std.parallelism, core.thread, core.time;
+
+void main() {
+    foreach (s; ["Enjoy", "Rosetta", "Code"].parallel(1)) {
+        Thread.sleep(uniform(0, 1000).dur!"msecs");
+        s.writeln;
+    }
+}
diff --git a/Task/Concurrent-computing/D/concurrent-computing-2.d b/Task/Concurrent-computing/D/concurrent-computing-2.d
new file mode 100644
index 0000000000..0062eb70c8
--- /dev/null
+++ b/Task/Concurrent-computing/D/concurrent-computing-2.d
@@ -0,0 +1,9 @@
+import tango.core.Thread;
+import tango.io.Console;
+import tango.math.Random;
+
+void main() {
+    (new Thread( { Thread.sleep(Random.shared.next(1000) / 1000.0); Cout("Enjoy").newline; } )).start;
+    (new Thread( { Thread.sleep(Random.shared.next(1000) / 1000.0); Cout("Rosetta").newline; } )).start;
+    (new Thread( { Thread.sleep(Random.shared.next(1000) / 1000.0); Cout("Code").newline; } )).start;
+}
diff --git a/Task/Concurrent-computing/Delphi/concurrent-computing.delphi b/Task/Concurrent-computing/Delphi/concurrent-computing.delphi
new file mode 100644
index 0000000000..37eb02514e
--- /dev/null
+++ b/Task/Concurrent-computing/Delphi/concurrent-computing.delphi
@@ -0,0 +1,39 @@
+program ConcurrentComputing;
+
+{$APPTYPE CONSOLE}
+
+uses SysUtils, Classes, Windows;
+
+type
+  TRandomThread = class(TThread)
+  private
+    FString: string;
+  protected
+    procedure Execute; override;
+  public
+    constructor Create(const aString: string); overload;
+  end;
+
+constructor TRandomThread.Create(const aString: string);
+begin
+  inherited Create(False);
+  FreeOnTerminate := True;
+  FString := aString;
+end;
+
+procedure TRandomThread.Execute;
+begin
+  Sleep(Random(5) * 100);
+  Writeln(FString);
+end;
+
+var
+  lThreadArray: Array[0..2] of THandle;
+begin
+  Randomize;
+  lThreadArray[0] := TRandomThread.Create('Enjoy').Handle;
+  lThreadArray[1] := TRandomThread.Create('Rosetta').Handle;
+  lThreadArray[2] := TRandomThread.Create('Stone').Handle;
+
+  WaitForMultipleObjects(Length(lThreadArray), @lThreadArray, True, INFINITE);
+end.
diff --git a/Task/Concurrent-computing/E/concurrent-computing-1.e b/Task/Concurrent-computing/E/concurrent-computing-1.e
new file mode 100644
index 0000000000..2fdc785384
--- /dev/null
+++ b/Task/Concurrent-computing/E/concurrent-computing-1.e
@@ -0,0 +1,4 @@
+def base := timer.now()
+for string in ["Enjoy", "Rosetta", "Code"] {
+    timer <- whenPast(base + entropy.nextInt(1000), fn { println(string) })
+}
diff --git a/Task/Concurrent-computing/E/concurrent-computing-2.e b/Task/Concurrent-computing/E/concurrent-computing-2.e
new file mode 100644
index 0000000000..0a95aee94e
--- /dev/null
+++ b/Task/Concurrent-computing/E/concurrent-computing-2.e
@@ -0,0 +1,9 @@
+def seedVat := ()
+for string in ["Enjoy", "Rosetta", "Code"] {
+   seedVat <- (`
+       fn string {
+           println(string)
+           currentVat <- orderlyShutdown("done")
+       }
+   `) <- get(0) <- (string)
+}
diff --git a/Task/Concurrent-computing/Erlang/concurrent-computing-1.erl b/Task/Concurrent-computing/Erlang/concurrent-computing-1.erl
new file mode 100644
index 0000000000..8f2431091a
--- /dev/null
+++ b/Task/Concurrent-computing/Erlang/concurrent-computing-1.erl
@@ -0,0 +1,19 @@
+-module(hw).
+-export([start/0]).
+
+start() ->
+   [ spawn(fun() ->  say(self(), X) end) || X <- ['Enjoy', 'Rosetta', 'Code'] ],
+   wait(2),
+   ok.
+
+say(Pid,Str) ->
+   io:fwrite("~s~n",[Str]),
+   Pid ! done.
+
+wait(N) ->
+   receive
+       done -> case N of
+           0 -> 0;
+           _N -> wait(N-1)
+       end
+   end.
diff --git a/Task/Concurrent-computing/Erlang/concurrent-computing-2.erl b/Task/Concurrent-computing/Erlang/concurrent-computing-2.erl
new file mode 100644
index 0000000000..05b819f0e5
--- /dev/null
+++ b/Task/Concurrent-computing/Erlang/concurrent-computing-2.erl
@@ -0,0 +1,2 @@
+|erlc hw.erl
+|erl -run hw start -run init stop -noshell
diff --git a/Task/Concurrent-computing/Euphoria/concurrent-computing.euphoria b/Task/Concurrent-computing/Euphoria/concurrent-computing.euphoria
new file mode 100644
index 0000000000..9ae9a66367
--- /dev/null
+++ b/Task/Concurrent-computing/Euphoria/concurrent-computing.euphoria
@@ -0,0 +1,17 @@
+procedure echo(sequence s)
+    puts(1,s)
+    puts(1,'\n')
+end procedure
+
+atom task1,task2,task3
+
+task1 = task_create(routine_id("echo"),{"Enjoy"})
+task_schedule(task1,1)
+
+task2 = task_create(routine_id("echo"),{"Rosetta"})
+task_schedule(task2,1)
+
+task3 = task_create(routine_id("echo"),{"Code"})
+task_schedule(task3,1)
+
+task_yield()
diff --git a/Task/Concurrent-computing/Forth/concurrent-computing.fth b/Task/Concurrent-computing/Forth/concurrent-computing.fth
new file mode 100644
index 0000000000..7a8976f358
--- /dev/null
+++ b/Task/Concurrent-computing/Forth/concurrent-computing.fth
@@ -0,0 +1,17 @@
+require tasker.fs
+require random.fs
+
+: task ( str len -- )
+  64 NewTask 2 swap pass
+  ( str len -- )
+  10 0 do
+    100 random ms
+    pause 2dup cr type
+  loop 2drop ;
+
+: main
+  s" Enjoy"   task
+  s" Rosetta" task
+  s" Code"    task
+  begin pause single-tasking? until ;
+main
diff --git a/Task/Concurrent-computing/Fortran/concurrent-computing.f b/Task/Concurrent-computing/Fortran/concurrent-computing.f
new file mode 100644
index 0000000000..226e7bbdea
--- /dev/null
+++ b/Task/Concurrent-computing/Fortran/concurrent-computing.f
@@ -0,0 +1,44 @@
+program concurrency
+  implicit none
+  character(len=*), parameter :: str1 = 'Enjoy'
+  character(len=*), parameter :: str2 = 'Rosetta'
+  character(len=*), parameter :: str3 = 'Code'
+  integer                     :: i
+  real                        :: h
+  real, parameter             :: one_third = 1.0e0/3
+  real, parameter             :: two_thirds = 2.0e0/3
+
+  interface
+     integer function omp_get_thread_num
+     end function omp_get_thread_num
+  end interface
+  interface
+     integer function omp_get_num_threads
+     end function omp_get_num_threads
+  end interface
+
+  ! Use OpenMP to create a team of threads
+  !$omp parallel do private(i,h)
+  do i=1,20
+     ! First time through the master thread output the number of threads
+     ! in the team
+     if (omp_get_thread_num() == 0 .and. i == 1) then
+        write(*,'(a,i0,a)') 'Using ',omp_get_num_threads(),' threads'
+     end if
+
+     ! Randomize the order
+     call random_number(h)
+
+     !$omp critical
+     if (h < one_third) then
+        write(*,'(a)') str1
+     else if (h < two_thirds) then
+        write(*,'(a)') str2
+     else
+        write(*,'(a)') str3
+     end if
+     !$omp end critical
+  end do
+  !$omp end parallel do
+
+end program concurrency
diff --git a/Task/Concurrent-computing/Go/concurrent-computing-1.go b/Task/Concurrent-computing/Go/concurrent-computing-1.go
new file mode 100644
index 0000000000..ee69c491a5
--- /dev/null
+++ b/Task/Concurrent-computing/Go/concurrent-computing-1.go
@@ -0,0 +1,22 @@
+package main
+
+import (
+    "fmt"
+    "math/rand"
+    "time"
+)
+
+func main() {
+    words := []string{"Enjoy", "Rosetta", "Code"}
+    rand.Seed(time.Now().UnixNano())
+    q := make(chan string)
+    for _, w := range words {
+        go func(w string) {
+            time.Sleep(time.Duration(rand.Int63n(1e9)))
+            q <- w
+        }(w)
+    }
+    for i := 0; i < len(words); i++ {
+        fmt.Println(<-q)
+    }
+}
diff --git a/Task/Concurrent-computing/Go/concurrent-computing-2.go b/Task/Concurrent-computing/Go/concurrent-computing-2.go
new file mode 100644
index 0000000000..175c716488
--- /dev/null
+++ b/Task/Concurrent-computing/Go/concurrent-computing-2.go
@@ -0,0 +1,25 @@
+package main
+
+import (
+    "log"
+    "math/rand"
+    "os"
+    "sync"
+    "time"
+)
+
+func main() {
+    words := []string{"Enjoy", "Rosetta", "Code"}
+    rand.Seed(time.Now().UnixNano())
+    l := log.New(os.Stdout, "", 0)
+    var q sync.WaitGroup
+    q.Add(len(words))
+    for _, w := range words {
+        w := w
+        time.AfterFunc(time.Duration(rand.Int63n(1e9)), func() {
+            l.Println(w)
+            q.Done()
+        })
+    }
+    q.Wait()
+}
diff --git a/Task/Concurrent-computing/Go/concurrent-computing-3.go b/Task/Concurrent-computing/Go/concurrent-computing-3.go
new file mode 100644
index 0000000000..31d18f1044
--- /dev/null
+++ b/Task/Concurrent-computing/Go/concurrent-computing-3.go
@@ -0,0 +1,25 @@
+package main
+
+import "fmt"
+
+func main() {
+    w1 := make(chan bool, 1)
+    w2 := make(chan bool, 1)
+    w3 := make(chan bool, 1)
+    for i := 0; i < 3; i++ {
+        w1 <- true
+        w2 <- true
+        w3 <- true
+        fmt.Println()
+        for i := 0; i < 3; i++ {
+            select {
+            case <-w1:
+                fmt.Println("Enjoy")
+            case <-w2:
+                fmt.Println("Rosetta")
+            case <-w3:
+                fmt.Println("Code")
+            }
+        }
+    }
+}
diff --git a/Task/Concurrent-computing/Haskell/concurrent-computing-1.hs b/Task/Concurrent-computing/Haskell/concurrent-computing-1.hs
new file mode 100644
index 0000000000..f1a84059df
--- /dev/null
+++ b/Task/Concurrent-computing/Haskell/concurrent-computing-1.hs
@@ -0,0 +1,6 @@
+import Control.Concurrent
+
+main = mapM_ forkIO [process1, process2, process3] where
+  process1 = putStrLn "Enjoy"
+  process2 = putStrLn "Rosetta"
+  process3 = putStrLn "Code"
diff --git a/Task/Concurrent-computing/Haskell/concurrent-computing-2.hs b/Task/Concurrent-computing/Haskell/concurrent-computing-2.hs
new file mode 100644
index 0000000000..b851762f2c
--- /dev/null
+++ b/Task/Concurrent-computing/Haskell/concurrent-computing-2.hs
@@ -0,0 +1,19 @@
+import Control.Concurrent
+import System.Random
+
+concurrent :: IO ()
+concurrent = do
+    var <- newMVar [] -- use an MVar to collect the results of each thread
+    mapM_ (forkIO . task var) ["Enjoy", "Rosetta", "Code"] -- run 3 threads
+    putStrLn "Press Return to show the results." -- while we wait for the user,
+    -- the threads run
+    _ <- getLine
+    takeMVar var >>= mapM_ putStrLn -- read the results and show them on screen
+    where
+        -- "task" is a thread
+        task v s = do
+            randomRIO (1,10) >>= \r -> threadDelay (r * 100000) -- wait a while
+            val <- takeMVar v -- read the MVar and block other threads from reading it
+            -- until we write another value to it
+            putMVar v (s : val) -- append a text string to the MVar and block other
+            -- threads from writing to it unless it is read first
diff --git a/Task/Concurrent-computing/Haskell/concurrent-computing-3.hs b/Task/Concurrent-computing/Haskell/concurrent-computing-3.hs
new file mode 100644
index 0000000000..59bac8a155
--- /dev/null
+++ b/Task/Concurrent-computing/Haskell/concurrent-computing-3.hs
@@ -0,0 +1,4 @@
+procedure main()
+   L:=[ thread write("Enjoy"), thread write("Rosetta"), thread write("Code") ]
+   every wait(!L)
+end
diff --git a/Task/Concurrent-computing/Java/concurrent-computing.java b/Task/Concurrent-computing/Java/concurrent-computing.java
new file mode 100644
index 0000000000..701a542462
--- /dev/null
+++ b/Task/Concurrent-computing/Java/concurrent-computing.java
@@ -0,0 +1,33 @@
+import java.util.concurrent.CyclicBarrier;
+
+public class Threads
+{
+  public static class DelayedMessagePrinter implements Runnable
+  {
+    private CyclicBarrier barrier;
+    private String msg;
+
+    public DelayedMessagePrinter(CyclicBarrier barrier, String msg)
+    {
+      this.barrier = barrier;
+      this.msg = msg;
+    }
+
+    public void run()
+    {
+      try
+      {  barrier.await();  }
+      catch (Exception e)
+      {  }
+      System.out.println(msg);
+    }
+  }
+
+  public static void main(String[] args)
+  {
+    CyclicBarrier barrier = new CyclicBarrier(3);
+    new Thread(new DelayedMessagePrinter(barrier, "Enjoy")).start();
+    new Thread(new DelayedMessagePrinter(barrier, "Rosetta")).start();
+    new Thread(new DelayedMessagePrinter(barrier, "Code")).start();
+  }
+}
diff --git a/Task/Concurrent-computing/JavaScript/concurrent-computing-1.js b/Task/Concurrent-computing/JavaScript/concurrent-computing-1.js
new file mode 100644
index 0000000000..2b6657033b
--- /dev/null
+++ b/Task/Concurrent-computing/JavaScript/concurrent-computing-1.js
@@ -0,0 +1,4 @@
+self.addEventListener('message', function (event) {
+  self.postMessage(event.data);
+  self.close();
+}, false);
diff --git a/Task/Concurrent-computing/JavaScript/concurrent-computing-2.js b/Task/Concurrent-computing/JavaScript/concurrent-computing-2.js
new file mode 100644
index 0000000000..b7d64ec263
--- /dev/null
+++ b/Task/Concurrent-computing/JavaScript/concurrent-computing-2.js
@@ -0,0 +1,10 @@
+var words = ["Enjoy", "Rosetta", "Code"];
+var workers = [];
+
+for (var i = 0; i < words.length; i++) {
+  workers[i] = new Worker("concurrent_worker.js");
+  workers[i].addEventListener('message', function (event) {
+    console.log(event.data);
+  }, false);
+  workers[i].postMessage(words[i]);
+}
diff --git a/Task/Concurrent-computing/Lua/concurrent-computing.lua b/Task/Concurrent-computing/Lua/concurrent-computing.lua
new file mode 100644
index 0000000000..33b22490f1
--- /dev/null
+++ b/Task/Concurrent-computing/Lua/concurrent-computing.lua
@@ -0,0 +1,16 @@
+co = {}
+co[1] = coroutine.create( function() print "Enjoy" end )
+co[2] = coroutine.create( function() print "Rosetta" end )
+co[3] = coroutine.create( function() print "Code" end )
+
+math.randomseed( os.time() )
+h = {}
+i = 0
+repeat
+    j = math.random(3)
+    if h[j] == nil then
+       coroutine.resume( co[j] )
+       h[j] = true
+       i = i + 1
+    end
+until i == 3
diff --git a/Task/Concurrent-computing/Perl/concurrent-computing-1.pl b/Task/Concurrent-computing/Perl/concurrent-computing-1.pl
new file mode 100644
index 0000000000..8ae9ad5812
--- /dev/null
+++ b/Task/Concurrent-computing/Perl/concurrent-computing-1.pl
@@ -0,0 +1,9 @@
+use threads;
+use Time::HiRes qw(sleep);
+
+$_->join for map {
+    threads->create(sub {
+        sleep rand;
+        print shift, "\n";
+    }, $_)
+} qw(Enjoy Rosetta Code);
diff --git a/Task/Concurrent-computing/Perl/concurrent-computing-2.pl b/Task/Concurrent-computing/Perl/concurrent-computing-2.pl
new file mode 100644
index 0000000000..fddb763cbb
--- /dev/null
+++ b/Task/Concurrent-computing/Perl/concurrent-computing-2.pl
@@ -0,0 +1,10 @@
+use feature qw( say );
+use Coro;
+use Coro::Timer qw( sleep );
+
+$_->join for map {
+    async {
+        sleep rand;
+        say @_;
+    } $_
+} qw( Enjoy Rosetta Code );
diff --git a/Task/Concurrent-computing/PicoLisp/concurrent-computing-1.l b/Task/Concurrent-computing/PicoLisp/concurrent-computing-1.l
new file mode 100644
index 0000000000..0779dad7e1
--- /dev/null
+++ b/Task/Concurrent-computing/PicoLisp/concurrent-computing-1.l
@@ -0,0 +1,5 @@
+(for (N . Str) '("Enjoy" "Rosetta" "Code")
+   (task (- N) (rand 1000 4000)              # Random start time 1 .. 4 sec
+      Str Str                                # Closure with string value
+      (println Str)                          # Task body: Print the string
+      (task @) ) )                           # and stop the task
diff --git a/Task/Concurrent-computing/PicoLisp/concurrent-computing-2.l b/Task/Concurrent-computing/PicoLisp/concurrent-computing-2.l
new file mode 100644
index 0000000000..c12a1117d1
--- /dev/null
+++ b/Task/Concurrent-computing/PicoLisp/concurrent-computing-2.l
@@ -0,0 +1,6 @@
+(for Str '("Enjoy" "Rosetta" "Code")
+   (let N (rand 1000 4000)                   # Randomize
+      (unless (fork)                         # Create child process
+         (wait N)                            # Wait 1 .. 4 sec
+         (println Str)                       # Print string
+         (bye) ) ) )                         # Terminate child process
diff --git a/Task/Concurrent-computing/Python/concurrent-computing-1.py b/Task/Concurrent-computing/Python/concurrent-computing-1.py
new file mode 100644
index 0000000000..d2651242db
--- /dev/null
+++ b/Task/Concurrent-computing/Python/concurrent-computing-1.py
@@ -0,0 +1,10 @@
+Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win 32
+Type "help", "copyright", "credits" or "license" for more information.
+>>> from concurrent import futures
+>>> with futures.ProcessPoolExecutor() as executor:
+...   _ = list(executor.map(print, 'Enjoy Rosetta Code'.split()))
+...
+Enjoy
+Rosetta
+Code
+>>>
diff --git a/Task/Concurrent-computing/Python/concurrent-computing-2.py b/Task/Concurrent-computing/Python/concurrent-computing-2.py
new file mode 100644
index 0000000000..76da5f5e94
--- /dev/null
+++ b/Task/Concurrent-computing/Python/concurrent-computing-2.py
@@ -0,0 +1,9 @@
+import threading
+import random
+
+def echo(text):
+    print(text)
+
+threading.Timer(random.random(), echo, ("Enjoy",)).start()
+threading.Timer(random.random(), echo, ("Rosetta",)).start()
+threading.Timer(random.random(), echo, ("Code",)).start()
diff --git a/Task/Concurrent-computing/Python/concurrent-computing-3.py b/Task/Concurrent-computing/Python/concurrent-computing-3.py
new file mode 100644
index 0000000000..3b50b0c815
--- /dev/null
+++ b/Task/Concurrent-computing/Python/concurrent-computing-3.py
@@ -0,0 +1,8 @@
+import threading
+import random
+
+def echo(text):
+    print(text)
+
+for text in ["Enjoy", "Rosetta", "Code"]:
+    threading.Timer(random.random(), echo, (text,)).start()
diff --git a/Task/Concurrent-computing/Python/concurrent-computing-4.py b/Task/Concurrent-computing/Python/concurrent-computing-4.py
new file mode 100644
index 0000000000..4b93f65dba
--- /dev/null
+++ b/Task/Concurrent-computing/Python/concurrent-computing-4.py
@@ -0,0 +1,14 @@
+import random, sys, time
+import threading
+
+lock = threading.Lock()
+
+def echo(s):
+    time.sleep(1e-2*random.random())
+    # use `.write()` with lock due to `print` prints empty lines occasionally
+    with lock:
+        sys.stdout.write(s)
+        sys.stdout.write('\n')
+
+for line in 'Enjoy Rosetta Code'.split():
+    threading.Thread(target=echo, args=(line,)).start()
diff --git a/Task/Concurrent-computing/Python/concurrent-computing-5.py b/Task/Concurrent-computing/Python/concurrent-computing-5.py
new file mode 100644
index 0000000000..019c91dee5
--- /dev/null
+++ b/Task/Concurrent-computing/Python/concurrent-computing-5.py
@@ -0,0 +1,9 @@
+from __future__ import print_function
+from multiprocessing import Pool
+
+def main():
+    p = Pool()
+    p.map(print, 'Enjoy Rosetta Code'.split())
+
+if __name__=="__main__":
+    main()
diff --git a/Task/Concurrent-computing/Python/concurrent-computing-6.py b/Task/Concurrent-computing/Python/concurrent-computing-6.py
new file mode 100644
index 0000000000..da9ce71fa8
--- /dev/null
+++ b/Task/Concurrent-computing/Python/concurrent-computing-6.py
@@ -0,0 +1,9 @@
+import random
+from twisted.internet    import reactor, task, defer
+from twisted.python.util import println
+
+delay = lambda: 1e-4*random.random()
+d = defer.DeferredList([task.deferLater(reactor, delay(), println, line)
+                        for line in 'Enjoy Rosetta Code'.split()])
+d.addBoth(lambda _: reactor.stop())
+reactor.run()
diff --git a/Task/Concurrent-computing/Python/concurrent-computing-7.py b/Task/Concurrent-computing/Python/concurrent-computing-7.py
new file mode 100644
index 0000000000..64d78fbfcc
--- /dev/null
+++ b/Task/Concurrent-computing/Python/concurrent-computing-7.py
@@ -0,0 +1,7 @@
+from __future__ import print_function
+import random
+import gevent
+
+delay = lambda: 1e-4*random.random()
+gevent.joinall([gevent.spawn_later(delay(), print, line)
+               for line in 'Enjoy Rosetta Code'.split()])
diff --git a/Task/Concurrent-computing/Racket/concurrent-computing.rkt b/Task/Concurrent-computing/Racket/concurrent-computing.rkt
new file mode 100644
index 0000000000..ea337494d5
--- /dev/null
+++ b/Task/Concurrent-computing/Racket/concurrent-computing.rkt
@@ -0,0 +1,4 @@
+#lang racket
+
+(for ([str '("Enjoy" "Rosetta" "Code")])
+  (thread (λ () (displayln str))))
diff --git a/Task/Concurrent-computing/Ruby/concurrent-computing.rb b/Task/Concurrent-computing/Ruby/concurrent-computing.rb
new file mode 100644
index 0000000000..885e8f0b4b
--- /dev/null
+++ b/Task/Concurrent-computing/Ruby/concurrent-computing.rb
@@ -0,0 +1,8 @@
+%w{Enjoy Rosetta Code}.map do |x|
+    Thread.new do
+        sleep rand
+        puts x
+    end
+end.each do |t|
+  t.join
+end
diff --git a/Task/Concurrent-computing/Scala/concurrent-computing.scala b/Task/Concurrent-computing/Scala/concurrent-computing.scala
new file mode 100644
index 0000000000..ec95cc21f6
--- /dev/null
+++ b/Task/Concurrent-computing/Scala/concurrent-computing.scala
@@ -0,0 +1,7 @@
+import scala.actors.Futures
+List("Enjoy", "Rosetta", "Code").map { x =>
+    Futures.future {
+      Thread.sleep((Math.random * 1000).toInt)
+       println(x)
+    }
+}.foreach(_())
diff --git a/Task/Concurrent-computing/Scheme/concurrent-computing.ss b/Task/Concurrent-computing/Scheme/concurrent-computing.ss
new file mode 100644
index 0000000000..ccdbfd1249
--- /dev/null
+++ b/Task/Concurrent-computing/Scheme/concurrent-computing.ss
@@ -0,0 +1,3 @@
+(parallel-execute (lambda () (print "Enjoy"))
+                  (lambda () (print "Rosetta"))
+                  (lambda () (print "Code")))
diff --git a/Task/Concurrent-computing/Tcl/concurrent-computing-1.tcl b/Task/Concurrent-computing/Tcl/concurrent-computing-1.tcl
new file mode 100644
index 0000000000..38db6eb625
--- /dev/null
+++ b/Task/Concurrent-computing/Tcl/concurrent-computing-1.tcl
@@ -0,0 +1,3 @@
+after [expr int(1000*rand())] {puts "Enjoy"}
+after [expr int(1000*rand())] {puts "Rosetta"}
+after [expr int(1000*rand())] {puts "Code"}
diff --git a/Task/Concurrent-computing/Tcl/concurrent-computing-2.tcl b/Task/Concurrent-computing/Tcl/concurrent-computing-2.tcl
new file mode 100644
index 0000000000..2fce7b25da
--- /dev/null
+++ b/Task/Concurrent-computing/Tcl/concurrent-computing-2.tcl
@@ -0,0 +1,3 @@
+after idle {puts "Enjoy"}
+after idle {puts "Rosetta"}
+after idle {puts "Code"}
diff --git a/Task/Concurrent-computing/Tcl/concurrent-computing-3.tcl b/Task/Concurrent-computing/Tcl/concurrent-computing-3.tcl
new file mode 100644
index 0000000000..62b1dc7aa6
--- /dev/null
+++ b/Task/Concurrent-computing/Tcl/concurrent-computing-3.tcl
@@ -0,0 +1,13 @@
+package require Thread
+set pool [tpool::create -initcmd {
+    proc delayPrint msg {
+        after [expr int(1000*rand())]
+        puts $msg
+    }
+}]
+tpool::post -detached $pool [list delayPrint "Enjoy"]
+tpool::post -detached $pool [list delayPrint "Rosetta"]
+tpool::post -detached $pool [list delayPrint "Code"]
+tpool::release $pool
+after 1200 ;# Give threads time to do their work
+exit
diff --git a/Task/Conditional-structures/0DESCRIPTION b/Task/Conditional-structures/0DESCRIPTION
new file mode 100644
index 0000000000..c8481e1e63
--- /dev/null
+++ b/Task/Conditional-structures/0DESCRIPTION
@@ -0,0 +1 @@
+{{Control Structures}}This page lists the conditional structures offered by different programming languages. Common conditional structures are '''if-then-else''' and '''switch'''.
diff --git a/Task/Conditional-structures/1META.yaml b/Task/Conditional-structures/1META.yaml
new file mode 100644
index 0000000000..8af673b2be
--- /dev/null
+++ b/Task/Conditional-structures/1META.yaml
@@ -0,0 +1,2 @@
+---
+note: Control Structures
diff --git a/Task/Conditional-structures/6502-Assembly/conditional-structures-1.6502 b/Task/Conditional-structures/6502-Assembly/conditional-structures-1.6502
new file mode 100644
index 0000000000..877bf5f72a
--- /dev/null
+++ b/Task/Conditional-structures/6502-Assembly/conditional-structures-1.6502
@@ -0,0 +1,2 @@
+		LDA #10
+		CMP #11
diff --git a/Task/Conditional-structures/6502-Assembly/conditional-structures-2.6502 b/Task/Conditional-structures/6502-Assembly/conditional-structures-2.6502
new file mode 100644
index 0000000000..01062a6c17
--- /dev/null
+++ b/Task/Conditional-structures/6502-Assembly/conditional-structures-2.6502
@@ -0,0 +1,20 @@
+		BNE 		;Branch on Not Equal - branch when the zero flag is set
+		BEQ 		;Branch on EQual - branch when the zero flag is set.
+				;The zero flag is set when the result of an operation is zero
+
+		BMI 		;Branch on MInus
+		BPL 		;Branch on PLus - branch when the sign flag is cleared/set.
+				;The sign flag is set when the result of an instruction is a negative number
+				;and cleared when the result is a positive number
+
+		BVS 		;Branch on oVerflow Set
+		BVC 		;Branch on oVerflow Cleared - branch when the overflow flag is cleared/set.
+				;The overflow flag is set when the result of an addition/subtraction would
+				;result in a number larger than 127 or smaller than -128
+
+		BCS		;Branch on Carry Set
+		BCC		;Branch on Carry Clear - branch when the carry flag is cleared/set.
+				;The carry flag is set when an addition produced a carry and when
+				;a subtraction produced a borrow and cleared if an addition/subtraction
+				;does not produce a carry/borrow.  The carry flag also holds bits
+				;after shifts and rotates.
diff --git a/Task/Conditional-structures/6502-Assembly/conditional-structures-3.6502 b/Task/Conditional-structures/6502-Assembly/conditional-structures-3.6502
new file mode 100644
index 0000000000..912ce4f0cd
--- /dev/null
+++ b/Task/Conditional-structures/6502-Assembly/conditional-structures-3.6502
@@ -0,0 +1,6 @@
+		LDA #200
+		CMP Variable
+		BEQ #3			;if equal, skip ahead 3 bytes...
+		CLC			;if unequal, continue executing instructions
+		ADC #1
+		STA OtherVariable	;				...to here.
diff --git a/Task/Conditional-structures/6502-Assembly/conditional-structures-4.6502 b/Task/Conditional-structures/6502-Assembly/conditional-structures-4.6502
new file mode 100644
index 0000000000..e92f03398c
--- /dev/null
+++ b/Task/Conditional-structures/6502-Assembly/conditional-structures-4.6502
@@ -0,0 +1,4 @@
+		LDX #100
+Loop:		...do something
+		DEX
+		BNE Loop
diff --git a/Task/Conditional-structures/AWK/conditional-structures-1.awk b/Task/Conditional-structures/AWK/conditional-structures-1.awk
new file mode 100644
index 0000000000..c1fe28f65b
--- /dev/null
+++ b/Task/Conditional-structures/AWK/conditional-structures-1.awk
@@ -0,0 +1 @@
+if(i<0) i=0; else i=42
diff --git a/Task/Conditional-structures/AWK/conditional-structures-2.awk b/Task/Conditional-structures/AWK/conditional-structures-2.awk
new file mode 100644
index 0000000000..c2a697b232
--- /dev/null
+++ b/Task/Conditional-structures/AWK/conditional-structures-2.awk
@@ -0,0 +1 @@
+i=(i<0? 0: 42)
diff --git a/Task/Conditional-structures/Ada/conditional-structures-1.ada b/Task/Conditional-structures/Ada/conditional-structures-1.ada
new file mode 100644
index 0000000000..67ae23e4c7
--- /dev/null
+++ b/Task/Conditional-structures/Ada/conditional-structures-1.ada
@@ -0,0 +1,10 @@
+type Restricted is range 1..10;
+My_Var : Restricted;
+
+if My_Var = 5 then
+  -- do something
+elsif My_Var > 5 then
+  -- do something
+else
+  -- do something
+end if;
diff --git a/Task/Conditional-structures/Ada/conditional-structures-2.ada b/Task/Conditional-structures/Ada/conditional-structures-2.ada
new file mode 100644
index 0000000000..c21c5a56c3
--- /dev/null
+++ b/Task/Conditional-structures/Ada/conditional-structures-2.ada
@@ -0,0 +1,13 @@
+type Days is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
+Today : Days;
+
+case Today is
+  when Saturday | Sunday =>
+     null;
+  when Monday =>
+     Compute_Starting_Balance;
+  when Friday =>
+     Compute_Ending_Balance;
+  when others =>
+     Accumulate_Sales;
+end case;
diff --git a/Task/Conditional-structures/Ada/conditional-structures-3.ada b/Task/Conditional-structures/Ada/conditional-structures-3.ada
new file mode 100644
index 0000000000..86cd396be0
--- /dev/null
+++ b/Task/Conditional-structures/Ada/conditional-structures-3.ada
@@ -0,0 +1,9 @@
+case Today is
+  when Monday =>
+     Compute_Starting_Balance;
+  when Friday =>
+     Compute_Ending_Balance;
+  when Tuesday .. Thursday =>
+     Accumulate_Sales;
+  -- ignore Saturday and Sunday
+end case;
diff --git a/Task/Conditional-structures/Ada/conditional-structures-4.ada b/Task/Conditional-structures/Ada/conditional-structures-4.ada
new file mode 100644
index 0000000000..aa33204a12
--- /dev/null
+++ b/Task/Conditional-structures/Ada/conditional-structures-4.ada
@@ -0,0 +1,10 @@
+case Today is
+  when Saturday | Sunday =>
+     null; -- don't do anything, if Today is Saturday or Sunday
+  when Monday =>
+     Compute_Starting_Balance;
+  when Friday =>
+     Compute_Ending_Balance;
+  when Tuesday .. Thursday =>
+     Accumulate_Sales;
+end case;
diff --git a/Task/Conditional-structures/Ada/conditional-structures-5.ada b/Task/Conditional-structures/Ada/conditional-structures-5.ada
new file mode 100644
index 0000000000..a438527473
--- /dev/null
+++ b/Task/Conditional-structures/Ada/conditional-structures-5.ada
@@ -0,0 +1,7 @@
+select
+   accept first_entry;
+   -- do something
+   or accept second_entry;
+   -- do something
+   or terminate;
+end select;
diff --git a/Task/Conditional-structures/Ada/conditional-structures-6.ada b/Task/Conditional-structures/Ada/conditional-structures-6.ada
new file mode 100644
index 0000000000..6844b781bd
--- /dev/null
+++ b/Task/Conditional-structures/Ada/conditional-structures-6.ada
@@ -0,0 +1,5 @@
+select
+  My_Task.Start;
+or
+  delay Timeout_Period;
+end select;
diff --git a/Task/Conditional-structures/Aikido/conditional-structures-1.aikido b/Task/Conditional-structures/Aikido/conditional-structures-1.aikido
new file mode 100644
index 0000000000..a8d9b58da0
--- /dev/null
+++ b/Task/Conditional-structures/Aikido/conditional-structures-1.aikido
@@ -0,0 +1 @@
+var x = loggedin ? sessionid : -1
diff --git a/Task/Conditional-structures/Aikido/conditional-structures-2.aikido b/Task/Conditional-structures/Aikido/conditional-structures-2.aikido
new file mode 100644
index 0000000000..b63ea040a8
--- /dev/null
+++ b/Task/Conditional-structures/Aikido/conditional-structures-2.aikido
@@ -0,0 +1,7 @@
+if (value > 40) {
+    println ("OK")
+} elif (value < 20) {
+    println ("FAILED")
+} else {
+    println ("RETRY")
+}
diff --git a/Task/Conditional-structures/Aikido/conditional-structures-3.aikido b/Task/Conditional-structures/Aikido/conditional-structures-3.aikido
new file mode 100644
index 0000000000..bec9cfe072
--- /dev/null
+++ b/Task/Conditional-structures/Aikido/conditional-structures-3.aikido
@@ -0,0 +1,25 @@
+switch (arg) {
+case "-d":
+case "--debug":
+    debug = true
+    break
+case "-f":
+    force = true
+    break
+default:
+    throw "Unknown option " + arg
+}
+
+switch (value) {
+case > 40:
+    println ("OK")
+    break
+case < 20:
+    println ("FAILED")
+    break
+case in 50..59:
+   println ("WIERD")
+   // fall through
+default:
+    println ("RETRY")
+}
diff --git a/Task/Conditional-structures/Aime/conditional-structures.aime b/Task/Conditional-structures/Aime/conditional-structures.aime
new file mode 100644
index 0000000000..614d36a415
--- /dev/null
+++ b/Task/Conditional-structures/Aime/conditional-structures.aime
@@ -0,0 +1,9 @@
+if (c1) {
+  // first condition is true...
+} elif (c2) {
+  // second condition is true...
+} elif (c3) {
+  // third condition is true...
+} else {
+  // none was true...
+}
diff --git a/Task/Conditional-structures/AmbientTalk/conditional-structures-1.ambient b/Task/Conditional-structures/AmbientTalk/conditional-structures-1.ambient
new file mode 100644
index 0000000000..3366874101
--- /dev/null
+++ b/Task/Conditional-structures/AmbientTalk/conditional-structures-1.ambient
@@ -0,0 +1,5 @@
+if: condition then: {
+  // condition is true...
+} else: {
+  // condition is false...
+}
diff --git a/Task/Conditional-structures/AmbientTalk/conditional-structures-2.ambient b/Task/Conditional-structures/AmbientTalk/conditional-structures-2.ambient
new file mode 100644
index 0000000000..14c3c064bc
--- /dev/null
+++ b/Task/Conditional-structures/AmbientTalk/conditional-structures-2.ambient
@@ -0,0 +1 @@
+condition.ifTrue: { /* condition is true... */ } ifFalse: { /* condition is false... */ }
diff --git a/Task/Conditional-structures/AmigaE/conditional-structures-1.amiga b/Task/Conditional-structures/AmigaE/conditional-structures-1.amiga
new file mode 100644
index 0000000000..db740cb6b1
--- /dev/null
+++ b/Task/Conditional-structures/AmigaE/conditional-structures-1.amiga
@@ -0,0 +1,7 @@
+IF condition
+  -> if condition is true...
+ELSEIF condition2
+  -> else if condition2 is true...
+ELSE
+  -> if all other conditions are not true...
+ENDIF
diff --git a/Task/Conditional-structures/AmigaE/conditional-structures-2.amiga b/Task/Conditional-structures/AmigaE/conditional-structures-2.amiga
new file mode 100644
index 0000000000..44201fb7fd
--- /dev/null
+++ b/Task/Conditional-structures/AmigaE/conditional-structures-2.amiga
@@ -0,0 +1 @@
+IF condition THEN statement
diff --git a/Task/Conditional-structures/AmigaE/conditional-structures-3.amiga b/Task/Conditional-structures/AmigaE/conditional-structures-3.amiga
new file mode 100644
index 0000000000..4c21c787d5
--- /dev/null
+++ b/Task/Conditional-structures/AmigaE/conditional-structures-3.amiga
@@ -0,0 +1,2 @@
+DEF c
+c := IF condition THEN 78 ELSE 19
diff --git a/Task/Conditional-structures/AmigaE/conditional-structures-4.amiga b/Task/Conditional-structures/AmigaE/conditional-structures-4.amiga
new file mode 100644
index 0000000000..ed8e0c882f
--- /dev/null
+++ b/Task/Conditional-structures/AmigaE/conditional-structures-4.amiga
@@ -0,0 +1,8 @@
+SELECT var
+  CASE n1
+    -> code
+  CASE n2
+    -> code
+  DEFAULT
+    -> no one of the previous case...
+ENDSELECT
diff --git a/Task/Conditional-structures/AmigaE/conditional-structures-5.amiga b/Task/Conditional-structures/AmigaE/conditional-structures-5.amiga
new file mode 100644
index 0000000000..4ab1237376
--- /dev/null
+++ b/Task/Conditional-structures/AmigaE/conditional-structures-5.amiga
@@ -0,0 +1,10 @@
+SELECT max_possible_value OF var
+  CASE n1
+    -> code
+  CASE n2 TO n3, n4
+    -> more
+  CASE n5 TO n6, n7 TO n8
+    -> more...
+  DEFAULT
+    -> none of previous ones
+ENDSELECT
diff --git a/Task/Conditional-structures/AppleScript/conditional-structures.applescript b/Task/Conditional-structures/AppleScript/conditional-structures.applescript
new file mode 100644
index 0000000000..f04454c0d1
--- /dev/null
+++ b/Task/Conditional-structures/AppleScript/conditional-structures.applescript
@@ -0,0 +1,10 @@
+if myVar is "ok" then return true
+
+set i to 0
+if i is 0 then
+       return "zero"
+else if i mod 2 is 0 then
+       return "even"
+else
+       return "odd"
+end if
diff --git a/Task/Conditional-structures/AutoHotkey/conditional-structures.ahk b/Task/Conditional-structures/AutoHotkey/conditional-structures.ahk
new file mode 100644
index 0000000000..774a878c74
--- /dev/null
+++ b/Task/Conditional-structures/AutoHotkey/conditional-structures.ahk
@@ -0,0 +1,19 @@
+; if
+x = 1
+If x
+  MsgBox, x is %x%
+Else If x > 1
+  MsgBox, x is %x%
+Else
+  MsgBox, x is %x%
+
+; ternary if
+x = 2
+y = 1
+var := x > y ? 2 : 3
+MsgBox, % var
+
+; while
+While (A_Index < 3) {
+  MsgBox, %A_Index% is less than 3
+}
diff --git a/Task/Conditional-structures/BASIC/conditional-structures-1.bas b/Task/Conditional-structures/BASIC/conditional-structures-1.bas
new file mode 100644
index 0000000000..c9cb0ffc20
--- /dev/null
+++ b/Task/Conditional-structures/BASIC/conditional-structures-1.bas
@@ -0,0 +1,7 @@
+10 LET A%=1: REM A HAS A VALUE OF TRUE
+20 IF A% THEN PRINT "A IS TRUE"
+30 WE CAN OF COURSE USE EXPRESSIONS
+40 IF A%<>0 THEN PRINT "A IS TRUE"
+50 IF NOT(A%) THEN PRINT "A IS FALSE"
+60 REM SOME VERSIONS OF BASIC PROVIDE AN ELSE KEYWORD
+70 IF A% THEN PRINT "A IS TRUE" ELSE PRINT "A IS FALSE"
diff --git a/Task/Conditional-structures/BASIC/conditional-structures-2.bas b/Task/Conditional-structures/BASIC/conditional-structures-2.bas
new file mode 100644
index 0000000000..ba08a0a3a7
--- /dev/null
+++ b/Task/Conditional-structures/BASIC/conditional-structures-2.bas
@@ -0,0 +1,2 @@
+IF x = 0 THEN doSomething
+IF x < 0 THEN doSomething ELSE doOtherThing
diff --git a/Task/Conditional-structures/BASIC/conditional-structures-3.bas b/Task/Conditional-structures/BASIC/conditional-structures-3.bas
new file mode 100644
index 0000000000..952fdd5edd
--- /dev/null
+++ b/Task/Conditional-structures/BASIC/conditional-structures-3.bas
@@ -0,0 +1,7 @@
+IF x > 0 AND x < 10 THEN
+   'do stuff
+ELSE IF x = 0 THEN
+   'do other stuff
+ELSE
+   'do more stuff
+END IF
diff --git a/Task/Conditional-structures/BASIC/conditional-structures-4.bas b/Task/Conditional-structures/BASIC/conditional-structures-4.bas
new file mode 100644
index 0000000000..8696495497
--- /dev/null
+++ b/Task/Conditional-structures/BASIC/conditional-structures-4.bas
@@ -0,0 +1,5 @@
+IF aNumber THEN
+   'the number is not 0
+ELSE
+   'the number is 0
+END IF
diff --git a/Task/Conditional-structures/BASIC/conditional-structures-5.bas b/Task/Conditional-structures/BASIC/conditional-structures-5.bas
new file mode 100644
index 0000000000..7b3329f775
--- /dev/null
+++ b/Task/Conditional-structures/BASIC/conditional-structures-5.bas
@@ -0,0 +1,12 @@
+SELECT CASE expression
+CASE 1
+   'do stuff
+CASE 2, 3
+   'do other stuff
+CASE 3.1 TO 9.9
+   'do this
+CASE IS >= 10
+   'do that
+CASE ELSE
+   'default case
+END SELECT
diff --git a/Task/Conditional-structures/BASIC/conditional-structures-6.bas b/Task/Conditional-structures/BASIC/conditional-structures-6.bas
new file mode 100644
index 0000000000..a222fc3af0
--- /dev/null
+++ b/Task/Conditional-structures/BASIC/conditional-structures-6.bas
@@ -0,0 +1,9 @@
+10 INPUT "Enter 1,2 or 3: ";v
+20 GOTO v * 100
+99 STOP
+100 PRINT "Apple"
+110 STOP
+200 PRINT "Banana"
+210 STOP
+300 PRINT "Cherry"
+310 STOP
diff --git a/Task/Conditional-structures/BASIC/conditional-structures-7.bas b/Task/Conditional-structures/BASIC/conditional-structures-7.bas
new file mode 100644
index 0000000000..e489d0a20d
--- /dev/null
+++ b/Task/Conditional-structures/BASIC/conditional-structures-7.bas
@@ -0,0 +1,12 @@
+10 REM while loop
+20 L=0
+30 WHILE L<5
+40 PRINT L
+50 L=L+1
+60 WEND
+70 REM repeat loop
+80 L=1
+90 REPEAT
+100 PRINT L
+110 L=L+1
+120 UNTIL L>5
diff --git a/Task/Conditional-structures/BBC-BASIC/conditional-structures.bbc b/Task/Conditional-structures/BBC-BASIC/conditional-structures.bbc
new file mode 100644
index 0000000000..9cdf13e164
--- /dev/null
+++ b/Task/Conditional-structures/BBC-BASIC/conditional-structures.bbc
@@ -0,0 +1,26 @@
+      REM Single-line IF ... THEN ... ELSE (ELSE clause is optional):
+      IF condition% THEN statements ELSE statements
+
+      REM Multi-line IF ... ENDIF (ELSE clause is optional):
+      IF condition% THEN
+        statements
+      ELSE
+        statements
+      ENDIF
+
+      REM CASE ... ENDCASE (OTHERWISE clause is optional):
+      CASE expression OF
+        WHEN value1: statements
+        WHEN value2: statements
+          ...
+        OTHERWISE: statements
+      ENDCASE
+
+      REM ON ... GOTO (ELSE clause is optional):
+      ON expression% GOTO dest1, dest2 ... ELSE statements
+
+      REM ON ...GOSUB (ELSE clause is optional):
+      ON expression% GOSUB dest1, dest2 ... ELSE statements
+
+      REM ON ... PROC (ELSE clause is optional):
+      ON expression% PROCone, PROCtwo ... ELSE statements
diff --git a/Task/Conditional-structures/Befunge/conditional-structures-1.bf b/Task/Conditional-structures/Befunge/conditional-structures-1.bf
new file mode 100644
index 0000000000..1f265c8440
--- /dev/null
+++ b/Task/Conditional-structures/Befunge/conditional-structures-1.bf
@@ -0,0 +1,3 @@
+v   > "X",@ non-zero
+> & |
+    > "0",@ zero
diff --git a/Task/Conditional-structures/Befunge/conditional-structures-2.bf b/Task/Conditional-structures/Befunge/conditional-structures-2.bf
new file mode 100644
index 0000000000..7d8ed9f79a
--- /dev/null
+++ b/Task/Conditional-structures/Befunge/conditional-structures-2.bf
@@ -0,0 +1,2 @@
+& #v_ "0",@ zero
+   >  "X",@ non-zero
diff --git a/Task/Conditional-structures/Bori/conditional-structures.bori b/Task/Conditional-structures/Bori/conditional-structures.bori
new file mode 100644
index 0000000000..3382566832
--- /dev/null
+++ b/Task/Conditional-structures/Bori/conditional-structures.bori
@@ -0,0 +1,6 @@
+if (i == 0)
+    return "zero";
+elif (i % 2)
+    return "odd";
+else
+    return "even";
diff --git a/Task/Conditional-structures/Bracmat/conditional-structures-1.bracmat b/Task/Conditional-structures/Bracmat/conditional-structures-1.bracmat
new file mode 100644
index 0000000000..4281843944
--- /dev/null
+++ b/Task/Conditional-structures/Bracmat/conditional-structures-1.bracmat
@@ -0,0 +1,5 @@
+    2+2:5
+  & put$"Strange, must check that Bracmat interpreter."
+  & 0
+|   put$"That's what I thought."
+  & Right
diff --git a/Task/Conditional-structures/Bracmat/conditional-structures-2.bracmat b/Task/Conditional-structures/Bracmat/conditional-structures-2.bracmat
new file mode 100644
index 0000000000..7d68d21e1c
--- /dev/null
+++ b/Task/Conditional-structures/Bracmat/conditional-structures-2.bracmat
@@ -0,0 +1,8 @@
+  2+2
+: (   (<3|>5)
+    & put$"Not quite, must check that Bracmat interpreter."
+  |   (3|5)
+    & put$"Not far off, but must check that Bracmat interpreter some day."
+  |   ?
+    & put$"That's what I thought."
+  )
diff --git a/Task/Conditional-structures/Brainf---/conditional-structures-1.bf b/Task/Conditional-structures/Brainf---/conditional-structures-1.bf
new file mode 100644
index 0000000000..64c1592ab2
--- /dev/null
+++ b/Task/Conditional-structures/Brainf---/conditional-structures-1.bf
@@ -0,0 +1 @@
+[.]
diff --git a/Task/Conditional-structures/Brainf---/conditional-structures-2.bf b/Task/Conditional-structures/Brainf---/conditional-structures-2.bf
new file mode 100644
index 0000000000..c0f99b5528
--- /dev/null
+++ b/Task/Conditional-structures/Brainf---/conditional-structures-2.bf
@@ -0,0 +1 @@
++[.]
diff --git a/Task/Conditional-structures/Brainf---/conditional-structures-3.bf b/Task/Conditional-structures/Brainf---/conditional-structures-3.bf
new file mode 100644
index 0000000000..a5806d02a9
--- /dev/null
+++ b/Task/Conditional-structures/Brainf---/conditional-structures-3.bf
@@ -0,0 +1 @@
++[.-]
diff --git a/Task/Conditional-structures/Burlesque/conditional-structures-1.blq b/Task/Conditional-structures/Burlesque/conditional-structures-1.blq
new file mode 100644
index 0000000000..0998ad35e0
--- /dev/null
+++ b/Task/Conditional-structures/Burlesque/conditional-structures-1.blq
@@ -0,0 +1,2 @@
+blsq ) 9 2.%{"Odd""Even"}ch
+"Odd"
diff --git a/Task/Conditional-structures/Burlesque/conditional-structures-2.blq b/Task/Conditional-structures/Burlesque/conditional-structures-2.blq
new file mode 100644
index 0000000000..bae1624e76
--- /dev/null
+++ b/Task/Conditional-structures/Burlesque/conditional-structures-2.blq
@@ -0,0 +1,4 @@
+blsq ) 9^^2.%{+.}if
+10
+blsq ) 10^^2.%{+.}if
+10
diff --git a/Task/Conditional-structures/Burlesque/conditional-structures-3.blq b/Task/Conditional-structures/Burlesque/conditional-structures-3.blq
new file mode 100644
index 0000000000..3bf8e37c1f
--- /dev/null
+++ b/Task/Conditional-structures/Burlesque/conditional-structures-3.blq
@@ -0,0 +1,4 @@
+blsq ) 10^^2.%{-.}\/{+.}\/ie
+11
+blsq ) 9^^2.%{-.}\/{+.}\/ie
+8
diff --git a/Task/Conditional-structures/Burlesque/conditional-structures-4.blq b/Task/Conditional-structures/Burlesque/conditional-structures-4.blq
new file mode 100644
index 0000000000..1ae46534f6
--- /dev/null
+++ b/Task/Conditional-structures/Burlesque/conditional-structures-4.blq
@@ -0,0 +1,4 @@
+blsq ) {"Hate tomatos" "Like Bananas" "Hate Apples"}{"Tomato" "Banana" "Apple"}"Banana"Fi!!
+"Like Bananas"
+blsq ) {"Hate tomatos" "Like Bananas" "Hate Apples"}{"Tomato" "Banana" "Apple"}"Apple"Fi!!
+"Hate Apples"
diff --git a/Task/Conditional-structures/C++/conditional-structures.cpp b/Task/Conditional-structures/C++/conditional-structures.cpp
new file mode 100644
index 0000000000..2eb4b553c7
--- /dev/null
+++ b/Task/Conditional-structures/C++/conditional-structures.cpp
@@ -0,0 +1,17 @@
+template struct ifthenelse;
+
+template struct ifthenelse
+{
+  typedef ThenType type;
+};
+
+template struct ifthenelse
+{
+  typedef ElseType type;
+};
+
+// example usage: select type based on size
+ifthenelse              // otherwise an int will do
+  ::type myvar;              // define variable myvar with that type
diff --git a/Task/Conditional-structures/CMake/conditional-structures.cmake b/Task/Conditional-structures/CMake/conditional-structures.cmake
new file mode 100644
index 0000000000..51d6aa04ec
--- /dev/null
+++ b/Task/Conditional-structures/CMake/conditional-structures.cmake
@@ -0,0 +1,10 @@
+set(num 5)
+
+if(num GREATER 100)
+  message("${num} is very large!")
+elseif(num GREATER 10)
+  message("${num} is large.")
+else()
+  message("${num} is small.")
+  message("We might want a bigger number.")
+endif()
diff --git a/Task/Conditional-structures/COBOL/conditional-structures-1.cobol b/Task/Conditional-structures/COBOL/conditional-structures-1.cobol
new file mode 100644
index 0000000000..538b1c0b93
--- /dev/null
+++ b/Task/Conditional-structures/COBOL/conditional-structures-1.cobol
@@ -0,0 +1,19 @@
+if condition-1
+    imperative-statement-1
+else
+    imperative-statement-2
+end-if
+
+if condition-1
+    if condition-a
+        imperative-statement-1a
+    else
+        imperative-statement-1
+    end-if
+else
+    if condition-a
+        imperative-statement-2a
+    else
+        imperative-statement-2
+    end-if
+end-if
diff --git a/Task/Conditional-structures/COBOL/conditional-structures-2.cobol b/Task/Conditional-structures/COBOL/conditional-structures-2.cobol
new file mode 100644
index 0000000000..1c62d4c6ab
--- /dev/null
+++ b/Task/Conditional-structures/COBOL/conditional-structures-2.cobol
@@ -0,0 +1,33 @@
+evaluate identifier-1
+when 'good'
+    good-imperative-statement
+when 'bad'
+    bad-imperative-statement
+when 'ugly'
+when 'awful'
+    ugly-or-awful-imperative-statement
+when other
+    default-imperative-statement
+end-evaluate
+
+evaluate true
+when condition-1
+    condition-1-imperative-statement
+when condition-2
+    condition-2-imperative-statement
+when condition-3
+    condition-3-imperative-statement
+when other
+    default-condition-imperative-statement
+end-evaluate
+
+evaluate identifier-1 also identifier-2
+when 10 also 20
+   one-is-10-and-two-is-20-imperative-statement
+when 11 also 30
+   one-is-11-and-two-is-30-imperative-statement
+when 20 also any
+   one-is-20-and-two-is-anything-imperative-statement
+when other
+   default-imperative-statement
+end-evaluate
diff --git a/Task/Conditional-structures/Clean/conditional-structures-1.clean b/Task/Conditional-structures/Clean/conditional-structures-1.clean
new file mode 100644
index 0000000000..ccd60ccf5d
--- /dev/null
+++ b/Task/Conditional-structures/Clean/conditional-structures-1.clean
@@ -0,0 +1 @@
+bool2int b = if b 1 0
diff --git a/Task/Conditional-structures/Clean/conditional-structures-2.clean b/Task/Conditional-structures/Clean/conditional-structures-2.clean
new file mode 100644
index 0000000000..c8bc6afd76
--- /dev/null
+++ b/Task/Conditional-structures/Clean/conditional-structures-2.clean
@@ -0,0 +1,3 @@
+case 6 * 7 of
+    42 -> "Correct"
+    _  -> "Wrong" // default, matches anything
diff --git a/Task/Conditional-structures/Clean/conditional-structures-3.clean b/Task/Conditional-structures/Clean/conditional-structures-3.clean
new file mode 100644
index 0000000000..7ff2d043cc
--- /dev/null
+++ b/Task/Conditional-structures/Clean/conditional-structures-3.clean
@@ -0,0 +1,2 @@
+answer 42 = True
+answer _ = False
diff --git a/Task/Conditional-structures/Clean/conditional-structures-4.clean b/Task/Conditional-structures/Clean/conditional-structures-4.clean
new file mode 100644
index 0000000000..c110e62cc2
--- /dev/null
+++ b/Task/Conditional-structures/Clean/conditional-structures-4.clean
@@ -0,0 +1,8 @@
+answer x
+    | x == 42   = True
+    | otherwise = False
+
+case 6 * 7 of
+    n | n < 0 -> "Not even close"
+    42        -> "Correct"
+    // no default, could result in a run-time error
diff --git a/Task/Conditional-structures/Clojure/conditional-structures-1.clj b/Task/Conditional-structures/Clojure/conditional-structures-1.clj
new file mode 100644
index 0000000000..ea81b7455d
--- /dev/null
+++ b/Task/Conditional-structures/Clojure/conditional-structures-1.clj
@@ -0,0 +1,5 @@
+(if (= 1 1) :yes :no) ; returns :yes
+
+(if (= 1 2) :yes :no) ; returns :no
+
+(if (= 1 2) :yes) ; returns nil
diff --git a/Task/Conditional-structures/Clojure/conditional-structures-2.clj b/Task/Conditional-structures/Clojure/conditional-structures-2.clj
new file mode 100644
index 0000000000..b58ab33b84
--- /dev/null
+++ b/Task/Conditional-structures/Clojure/conditional-structures-2.clj
@@ -0,0 +1,4 @@
+(when x
+  (print "hello")
+  (println " world")
+  5) ; when x is logical true, prints "hello world" and returns 5; otherwise does nothing, returns nil
diff --git a/Task/Conditional-structures/Clojure/conditional-structures-3.clj b/Task/Conditional-structures/Clojure/conditional-structures-3.clj
new file mode 100644
index 0000000000..2b613f105d
--- /dev/null
+++ b/Task/Conditional-structures/Clojure/conditional-structures-3.clj
@@ -0,0 +1,6 @@
+(cond
+  (= 1 2) :no) ; returns nil
+
+(cond
+  (= 1 2) :no
+  (= 1 1) :yes) ; returns :yes
diff --git a/Task/Conditional-structures/Clojure/conditional-structures-4.clj b/Task/Conditional-structures/Clojure/conditional-structures-4.clj
new file mode 100644
index 0000000000..0347f96e2f
--- /dev/null
+++ b/Task/Conditional-structures/Clojure/conditional-structures-4.clj
@@ -0,0 +1,3 @@
+(cond
+  (= 1 2) :no
+  :else :yes) ; returns :yes
diff --git a/Task/Conditional-structures/Clojure/conditional-structures-5.clj b/Task/Conditional-structures/Clojure/conditional-structures-5.clj
new file mode 100644
index 0000000000..d463720bb1
--- /dev/null
+++ b/Task/Conditional-structures/Clojure/conditional-structures-5.clj
@@ -0,0 +1,5 @@
+(condp < 3
+  4 :a  ; cond equivalent would be (< 4 3) :a
+  3 :b
+  2 :c
+  1 :d) ; returns :c
diff --git a/Task/Conditional-structures/Clojure/conditional-structures-6.clj b/Task/Conditional-structures/Clojure/conditional-structures-6.clj
new file mode 100644
index 0000000000..e15b7f3b19
--- /dev/null
+++ b/Task/Conditional-structures/Clojure/conditional-structures-6.clj
@@ -0,0 +1,4 @@
+(condp < 3
+  4 :a
+  3 :b
+  :no-match) ; returns :no-match
diff --git a/Task/Conditional-structures/Clojure/conditional-structures-7.clj b/Task/Conditional-structures/Clojure/conditional-structures-7.clj
new file mode 100644
index 0000000000..64eb99f597
--- /dev/null
+++ b/Task/Conditional-structures/Clojure/conditional-structures-7.clj
@@ -0,0 +1,4 @@
+(case 2
+  0 (println "0")
+  1 (println "1")
+  2 (println "2")) ; prints 2.
diff --git a/Task/Conditional-structures/CoffeeScript/conditional-structures-1.coffee b/Task/Conditional-structures/CoffeeScript/conditional-structures-1.coffee
new file mode 100644
index 0000000000..f61f09748d
--- /dev/null
+++ b/Task/Conditional-structures/CoffeeScript/conditional-structures-1.coffee
@@ -0,0 +1,6 @@
+if n == 1
+  console.log "one"
+else if n == 2
+  console.log "two"
+else
+  console.log "other"
diff --git a/Task/Conditional-structures/CoffeeScript/conditional-structures-2.coffee b/Task/Conditional-structures/CoffeeScript/conditional-structures-2.coffee
new file mode 100644
index 0000000000..0fea1dd996
--- /dev/null
+++ b/Task/Conditional-structures/CoffeeScript/conditional-structures-2.coffee
@@ -0,0 +1,9 @@
+n = 1
+
+switch n
+  when 1
+    console.log "one"
+  when 2, 3
+    console.log "two or three"
+  else
+    console.log "other"
diff --git a/Task/Conditional-structures/CoffeeScript/conditional-structures-3.coffee b/Task/Conditional-structures/CoffeeScript/conditional-structures-3.coffee
new file mode 100644
index 0000000000..bf0de632f1
--- /dev/null
+++ b/Task/Conditional-structures/CoffeeScript/conditional-structures-3.coffee
@@ -0,0 +1,7 @@
+s = if condition then "yup" else "nope"
+
+# alternate form
+s = \
+  if condition
+  then "yup"
+  else "nope"
diff --git a/Task/Conditional-structures/ColdFusion/conditional-structures-1.cfm b/Task/Conditional-structures/ColdFusion/conditional-structures-1.cfm
new file mode 100644
index 0000000000..af91207146
--- /dev/null
+++ b/Task/Conditional-structures/ColdFusion/conditional-structures-1.cfm
@@ -0,0 +1,7 @@
+
+ do something
+
+ do something else
+
+ do something else
+
diff --git a/Task/Conditional-structures/ColdFusion/conditional-structures-2.cfm b/Task/Conditional-structures/ColdFusion/conditional-structures-2.cfm
new file mode 100644
index 0000000000..b8c69c7760
--- /dev/null
+++ b/Task/Conditional-structures/ColdFusion/conditional-structures-2.cfm
@@ -0,0 +1,11 @@
+
+ 
+  do something
+ 
+ 
+  do something
+ 
+ 
+  do something
+ 
+
diff --git a/Task/Conditional-structures/Common-Lisp/conditional-structures-1.lisp b/Task/Conditional-structures/Common-Lisp/conditional-structures-1.lisp
new file mode 100644
index 0000000000..c448a5c7f4
--- /dev/null
+++ b/Task/Conditional-structures/Common-Lisp/conditional-structures-1.lisp
@@ -0,0 +1,3 @@
+(if (= val 42)
+    "That is the answer to life, the universe and everything"
+    "Try again") ; the else clause here is optional
diff --git a/Task/Conditional-structures/Common-Lisp/conditional-structures-2.lisp b/Task/Conditional-structures/Common-Lisp/conditional-structures-2.lisp
new file mode 100644
index 0000000000..fdeafb0f35
--- /dev/null
+++ b/Task/Conditional-structures/Common-Lisp/conditional-structures-2.lisp
@@ -0,0 +1,4 @@
+(cond ((= val 1)                 (print "no"))
+      ((and (> val 3) (< val 6)) (print "yes"))
+      ((> val 99)                (print "too far"))
+      (T                         (print "no way, man!")))
diff --git a/Task/Conditional-structures/Crack/conditional-structures-1.crack b/Task/Conditional-structures/Crack/conditional-structures-1.crack
new file mode 100644
index 0000000000..3a5367e355
--- /dev/null
+++ b/Task/Conditional-structures/Crack/conditional-structures-1.crack
@@ -0,0 +1,17 @@
+if (condition)
+{
+   // Some Task
+}
+
+if (condition)
+{
+  // Some Task
+}
+else if (condition2)
+{
+  // Some Task
+}
+else
+{
+  // Some Task
+}
diff --git a/Task/Conditional-structures/Crack/conditional-structures-2.crack b/Task/Conditional-structures/Crack/conditional-structures-2.crack
new file mode 100644
index 0000000000..bca71a2f8a
--- /dev/null
+++ b/Task/Conditional-structures/Crack/conditional-structures-2.crack
@@ -0,0 +1,2 @@
+// if condition is true var will be set to 1, else false.
+int var = condition ? 1 : 2;
diff --git a/Task/Conditional-structures/D/conditional-structures-1.d b/Task/Conditional-structures/D/conditional-structures-1.d
new file mode 100644
index 0000000000..6cb58f4212
--- /dev/null
+++ b/Task/Conditional-structures/D/conditional-structures-1.d
@@ -0,0 +1 @@
+const i = 5; static if (i == 7) { ... } else { ... }
diff --git a/Task/Conditional-structures/D/conditional-structures-2.d b/Task/Conditional-structures/D/conditional-structures-2.d
new file mode 100644
index 0000000000..87486a535d
--- /dev/null
+++ b/Task/Conditional-structures/D/conditional-structures-2.d
@@ -0,0 +1,9 @@
+ auto i = 5;
+// is(T: U) tests if T is implicitly castable to U.
+// typeof(var) is the type of the variable.
+// also: is(T==U) checks if T is U.
+static if (is(typeof(i) : int)) {
+  ...
+} else {
+  ...
+}
diff --git a/Task/Conditional-structures/Dao/conditional-structures-1.dao b/Task/Conditional-structures/Dao/conditional-structures-1.dao
new file mode 100644
index 0000000000..949f73cc61
--- /dev/null
+++ b/Task/Conditional-structures/Dao/conditional-structures-1.dao
@@ -0,0 +1,8 @@
+a = 3
+if( a == 1 ){
+    io.writeln( 'a == 1' )
+}elif( a== 3 ){
+    io.writeln( 'a == 3' )
+}else{
+    io.writeln( 'a is neither 1 nor 3' )
+}
diff --git a/Task/Conditional-structures/Dao/conditional-structures-2.dao b/Task/Conditional-structures/Dao/conditional-structures-2.dao
new file mode 100644
index 0000000000..1874434903
--- /dev/null
+++ b/Task/Conditional-structures/Dao/conditional-structures-2.dao
@@ -0,0 +1,7 @@
+a = 3
+switch( a ){
+case 0: io.writeln( 'case 0' )
+case 1, 2: io.writeln( 'case 1,2' )
+case 3 ... 5: io.writeln( 'case 3...5' )
+default: io.writeln( 'default' )
+}
diff --git a/Task/Conditional-structures/Deja-Vu/conditional-structures.djv b/Task/Conditional-structures/Deja-Vu/conditional-structures.djv
new file mode 100644
index 0000000000..3c009eb055
--- /dev/null
+++ b/Task/Conditional-structures/Deja-Vu/conditional-structures.djv
@@ -0,0 +1,6 @@
+if a:
+    pass
+elseif b:
+    pass
+else: # c, maybe?
+    pass
diff --git a/Task/Conditional-structures/Deluge/conditional-structures.deluge b/Task/Conditional-structures/Deluge/conditional-structures.deluge
new file mode 100644
index 0000000000..33101ec2a0
--- /dev/null
+++ b/Task/Conditional-structures/Deluge/conditional-structures.deluge
@@ -0,0 +1,7 @@
+if (input.Field == "Hello World") {
+    sVar = "good";
+} else if (input.Field == "Bye World") {
+    sVar = "bad";
+} else {
+    sVar = "neutral";
+}
diff --git a/Task/Conditional-structures/E/conditional-structures-1.e b/Task/Conditional-structures/E/conditional-structures-1.e
new file mode 100644
index 0000000000..d8ee9742b1
--- /dev/null
+++ b/Task/Conditional-structures/E/conditional-structures-1.e
@@ -0,0 +1,7 @@
+if (okay) {
+    println("okay")
+} else if (!okay) {
+    println("not okay")
+} else {
+    println("not my day")
+}
diff --git a/Task/Conditional-structures/E/conditional-structures-2.e b/Task/Conditional-structures/E/conditional-structures-2.e
new file mode 100644
index 0000000000..538aaa3804
--- /dev/null
+++ b/Task/Conditional-structures/E/conditional-structures-2.e
@@ -0,0 +1 @@
+println(okay.pick("okay", "not okay"))
diff --git a/Task/Conditional-structures/E/conditional-structures-3.e b/Task/Conditional-structures/E/conditional-structures-3.e
new file mode 100644
index 0000000000..68681c1d29
--- /dev/null
+++ b/Task/Conditional-structures/E/conditional-structures-3.e
@@ -0,0 +1,5 @@
+okay.pick(fn {
+    println("okay")
+}, fn {
+    println("not okay")
+})()
diff --git a/Task/Conditional-structures/E/conditional-structures-4.e b/Task/Conditional-structures/E/conditional-structures-4.e
new file mode 100644
index 0000000000..5001b1a7d7
--- /dev/null
+++ b/Task/Conditional-structures/E/conditional-structures-4.e
@@ -0,0 +1,7 @@
+def expression := ["+", [1, 2]]
+
+def value := switch (expression) {
+    match [`+`, [a, b]] { a + b }
+    match [`*`, [a, b]] { a * b }
+    match [op, _] { throw(`unknown operator: $op`) }
+}
diff --git a/Task/Conditional-structures/Efene/conditional-structures.efene b/Task/Conditional-structures/Efene/conditional-structures.efene
new file mode 100644
index 0000000000..2ebd5fd432
--- /dev/null
+++ b/Task/Conditional-structures/Efene/conditional-structures.efene
@@ -0,0 +1,60 @@
+show_if_with_parenthesis = fn (Num) {
+    if (Num == 1) {
+        io.format("is one~n")
+    }
+    else if (Num === 2) {
+        io.format("is two~n")
+    }
+    else {
+        io.format("not one not two~n")
+    }
+}
+
+show_if_without_parenthesis = fn (Num) {
+    if Num == 1 {
+        io.format("is one~n")
+    }
+    else if Num === 2 {
+        io.format("is two~n")
+    }
+    else {
+        io.format("not one not two~n")
+    }
+}
+
+show_switch_with_parenthesis = fn (Num) {
+    switch (Num) {
+        case (1) {
+            io.format("one!~n")
+        }
+        case (2) {
+            io.format("two!~n")
+        }
+        else {
+            io.format("else~n")
+        }
+    }
+}
+
+show_switch_without_parenthesis = fn (Num) {
+    switch (Num) {
+        case 1 {
+            io.format("one!~n")
+        }
+        case 2 {
+            io.format("two!~n")
+        }
+        else {
+            io.format("else~n")
+        }
+    }
+}
+
+@public
+run = fn () {
+    show_if_with_parenthesis(random.uniform(3))
+    show_if_without_parenthesis(random.uniform(3))
+
+    show_switch_with_parenthesis(random.uniform(3))
+    show_switch_without_parenthesis(random.uniform(3))
+}
diff --git a/Task/Conditional-structures/Ela/conditional-structures-1.ela b/Task/Conditional-structures/Ela/conditional-structures-1.ela
new file mode 100644
index 0000000000..10f7d67ecc
--- /dev/null
+++ b/Task/Conditional-structures/Ela/conditional-structures-1.ela
@@ -0,0 +1 @@
+if x < 0 then 0 else x
diff --git a/Task/Conditional-structures/Ela/conditional-structures-2.ela b/Task/Conditional-structures/Ela/conditional-structures-2.ela
new file mode 100644
index 0000000000..1831c29fb5
--- /dev/null
+++ b/Task/Conditional-structures/Ela/conditional-structures-2.ela
@@ -0,0 +1,2 @@
+getX x | x < 0 = 0
+       | else  = x
diff --git a/Task/Conditional-structures/Ela/conditional-structures-3.ela b/Task/Conditional-structures/Ela/conditional-structures-3.ela
new file mode 100644
index 0000000000..6757f4e101
--- /dev/null
+++ b/Task/Conditional-structures/Ela/conditional-structures-3.ela
@@ -0,0 +1,2 @@
+force (x::xs) = x :: force xs
+force [] = []
diff --git a/Task/Conditional-structures/Ela/conditional-structures-4.ela b/Task/Conditional-structures/Ela/conditional-structures-4.ela
new file mode 100644
index 0000000000..d68b109dd3
--- /dev/null
+++ b/Task/Conditional-structures/Ela/conditional-structures-4.ela
@@ -0,0 +1,3 @@
+force lst = match lst with
+                  x::xs = x :: force xs
+                  [] = []
diff --git a/Task/Conditional-structures/Erlang/conditional-structures-1.erl b/Task/Conditional-structures/Erlang/conditional-structures-1.erl
new file mode 100644
index 0000000000..c197e0e43e
--- /dev/null
+++ b/Task/Conditional-structures/Erlang/conditional-structures-1.erl
@@ -0,0 +1,5 @@
+case X of
+  {N,M} when N > M -> M;
+  {N,M} when N < M -> N;
+  _ -> equal
+end.
diff --git a/Task/Conditional-structures/Erlang/conditional-structures-2.erl b/Task/Conditional-structures/Erlang/conditional-structures-2.erl
new file mode 100644
index 0000000000..ad731dbeee
--- /dev/null
+++ b/Task/Conditional-structures/Erlang/conditional-structures-2.erl
@@ -0,0 +1,6 @@
+{N,M} = X,
+if
+  N > M -> M;
+  N < M -> N;
+  true -> equal
+end.
diff --git a/Task/Conditional-structures/Erlang/conditional-structures-3.erl b/Task/Conditional-structures/Erlang/conditional-structures-3.erl
new file mode 100644
index 0000000000..57269a25c1
--- /dev/null
+++ b/Task/Conditional-structures/Erlang/conditional-structures-3.erl
@@ -0,0 +1,3 @@
+test({N,M}) when N > M -> M;
+test({N,M}) when N < M -> N;
+test(_) -> equal.
diff --git a/Task/Conditional-structures/Forth/conditional-structures-1.fth b/Task/Conditional-structures/Forth/conditional-structures-1.fth
new file mode 100644
index 0000000000..4cf6ee19ec
--- /dev/null
+++ b/Task/Conditional-structures/Forth/conditional-structures-1.fth
@@ -0,0 +1,2 @@
+( condition ) IF ( true statements ) THEN
+( condition ) IF ( true statements ) ELSE ( false statements ) THEN
diff --git a/Task/Conditional-structures/Forth/conditional-structures-2.fth b/Task/Conditional-structures/Forth/conditional-structures-2.fth
new file mode 100644
index 0000000000..7a2d3e1d80
--- /dev/null
+++ b/Task/Conditional-structures/Forth/conditional-structures-2.fth
@@ -0,0 +1 @@
+10 < IF ." Less than 10" ELSE ." Greater than or equal to 10" THEN
diff --git a/Task/Conditional-structures/Forth/conditional-structures-3.fth b/Task/Conditional-structures/Forth/conditional-structures-3.fth
new file mode 100644
index 0000000000..29a91cd7ba
--- /dev/null
+++ b/Task/Conditional-structures/Forth/conditional-structures-3.fth
@@ -0,0 +1,5 @@
+( n -- ) CASE
+( integer ) OF ( statements ) ENDOF
+( integer ) OF ( statements ) ENDOF
+( default instructions )
+ENDCASE
diff --git a/Task/Conditional-structures/Forth/conditional-structures-4.fth b/Task/Conditional-structures/Forth/conditional-structures-4.fth
new file mode 100644
index 0000000000..6b4c242236
--- /dev/null
+++ b/Task/Conditional-structures/Forth/conditional-structures-4.fth
@@ -0,0 +1,6 @@
+: test-case ( n -- )
+   CASE
+     0 OF ." Zero!" ENDOF
+     1 OF ." One!"  ENDOF
+     ." Some other number!"
+   ENDCASE ;
diff --git a/Task/Conditional-structures/Forth/conditional-structures-5.fth b/Task/Conditional-structures/Forth/conditional-structures-5.fth
new file mode 100644
index 0000000000..17d98c1190
--- /dev/null
+++ b/Task/Conditional-structures/Forth/conditional-structures-5.fth
@@ -0,0 +1,19 @@
+: switch
+  CREATE ( default-xt [count-xts] count -- ) DUP , 0 DO , LOOP ,
+  DOES> ( u -- ) TUCK @ MIN 1+ CELLS + @ EXECUTE ;
+
+  :NONAME ." Out of range!" ;
+  :NONAME ." nine" ;
+  :NONAME ." eight" ;
+  :NONAME ." seven" ;
+  :NONAME ." six" ;
+  :NONAME ." five" ;
+  :NONAME ." four" ;
+  :NONAME ." three" ;
+  :NONAME ." two" ;
+  :NONAME ." one" ;
+  :NONAME ." zero" ;
+10 switch digit
+
+ 8 digit   \ eight
+34 digit   \ Out of range!
diff --git a/Task/Conditional-structures/Fortran/conditional-structures-1.f b/Task/Conditional-structures/Fortran/conditional-structures-1.f
new file mode 100644
index 0000000000..cc5995ffce
--- /dev/null
+++ b/Task/Conditional-structures/Fortran/conditional-structures-1.f
@@ -0,0 +1,7 @@
+if ( a .gt. 20.0 ) then
+   q = q + a**2
+else if ( a .ge. 0.0 ) then
+   q = q + 2*a**3
+else
+   q = q - a
+end if
diff --git a/Task/Conditional-structures/Fortran/conditional-structures-2.f b/Task/Conditional-structures/Fortran/conditional-structures-2.f
new file mode 100644
index 0000000000..ca73a855d8
--- /dev/null
+++ b/Task/Conditional-structures/Fortran/conditional-structures-2.f
@@ -0,0 +1,8 @@
+select case (i)
+   case (21:)      ! matches all integers greater than 20
+      q = q + i**2
+   case (0:20)     ! matches all integers between 0 and 20 (inclusive)
+      q = q + 2*i**3
+   case default    ! matches all other integers (negative in this particular case)
+      q = q - I
+end select
diff --git a/Task/Conditional-structures/Fortran/conditional-structures-3.f b/Task/Conditional-structures/Fortran/conditional-structures-3.f
new file mode 100644
index 0000000000..50300d1ed2
--- /dev/null
+++ b/Task/Conditional-structures/Fortran/conditional-structures-3.f
@@ -0,0 +1,31 @@
+! diffusion grid time step
+where     (edge_type(1:n,1:m) == center)
+   anew(1:n,1:m) = (a(1:n,1:m) + a(0:n-1,1:m) + a(2:n+1,1:m) + a(1:n,0:m-1) + a(1:n,2:m+1)) / 5
+
+elsewhere (edge_type(1:n,1:m) == left)
+   anew(1:n,1:m) = (a(1:n,1:m) + 2*a(2:n+1,1:m) + a(1:n,0:m-1) + a(1:n,2:m+1)) / 5
+
+elsewhere (edge_type(1:n,1:m) == right)
+   anew(1:n,1:m) = (a(1:n,1:m) + 2*a(0:n-1,1:m) + a(1:n,0:m-1) + a(1:n,2:m+1)) / 5
+
+elsewhere (edge_type(1:n,1:m) == top)
+   anew(1:n,1:m) = (a(1:n,1:m) + a(0:n-1,1:m) + a(2:n+1,1:m) + 2*a(1:n,2:m+1)) / 5
+
+elsewhere (edge_type(1:n,1:m) == bottom)
+   anew(1:n,1:m) = (a(1:n,1:m) + a(0:n-1,1:m) + a(2:n+1,1:m) + 2*a(1:n,0:m-1)) / 5
+
+elsewhere (edge_type(1:n,1:m) == left_top)
+   anew(1:n,1:m) = (a(1:n,1:m) + 2*a(2:n+1,1:m) + 2*a(1:n,2:m+1)) / 5
+
+elsewhere (edge_type(1:n,1:m) == right_top)
+   anew(1:n,1:m) = (a(1:n,1:m) + 2*a(0:n-1,1:m) + 2*a(1:n,2:m+1)) / 5
+
+elsewhere (edge_type(1:n,1:m) == left_bottom)
+   anew(1:n,1:m) = (a(1:n,1:m) + 2*a(2:n+1,1:m) + 2*a(1:n,0:m-1)) / 5
+
+elsewhere (edge_type(1:n,1:m) == right_bottom)
+   anew(1:n,1:m) = (a(1:n,1:m) + 2*a(0:n-1,1:m) + 2*a(1:n,0:m-1)) / 5
+
+elsewhere      ! sink/source, does not change
+   anew(1:n,1:m) = a(1:n,1:m)
+end where
diff --git a/Task/Conditional-structures/Go/conditional-structures-1.go b/Task/Conditional-structures/Go/conditional-structures-1.go
new file mode 100644
index 0000000000..278d66e613
--- /dev/null
+++ b/Task/Conditional-structures/Go/conditional-structures-1.go
@@ -0,0 +1,3 @@
+if booleanExpression {
+    statements
+}
diff --git a/Task/Conditional-structures/Go/conditional-structures-10.go b/Task/Conditional-structures/Go/conditional-structures-10.go
new file mode 100644
index 0000000000..8c66caf040
--- /dev/null
+++ b/Task/Conditional-structures/Go/conditional-structures-10.go
@@ -0,0 +1,7 @@
+treadmill: for {
+    switch {
+    case true:
+        break treadmill
+    }
+}
+fmt.Println("I'm off!")
diff --git a/Task/Conditional-structures/Go/conditional-structures-2.go b/Task/Conditional-structures/Go/conditional-structures-2.go
new file mode 100644
index 0000000000..6b6a1b444b
--- /dev/null
+++ b/Task/Conditional-structures/Go/conditional-structures-2.go
@@ -0,0 +1,6 @@
+if booleanExpression {
+    statements
+} else {
+    other
+    statements
+}
diff --git a/Task/Conditional-structures/Go/conditional-structures-3.go b/Task/Conditional-structures/Go/conditional-structures-3.go
new file mode 100644
index 0000000000..861bf69081
--- /dev/null
+++ b/Task/Conditional-structures/Go/conditional-structures-3.go
@@ -0,0 +1,5 @@
+if booleanExpression1 {
+    statements
+} else if booleanExpression2 {
+    otherStatements
+}
diff --git a/Task/Conditional-structures/Go/conditional-structures-4.go b/Task/Conditional-structures/Go/conditional-structures-4.go
new file mode 100644
index 0000000000..2d3076b9cf
--- /dev/null
+++ b/Task/Conditional-structures/Go/conditional-structures-4.go
@@ -0,0 +1,5 @@
+if x := fetchSomething(); if x > 0 {
+    DoPos(x)
+} else {
+    DoNeg(x)
+}
diff --git a/Task/Conditional-structures/Go/conditional-structures-5.go b/Task/Conditional-structures/Go/conditional-structures-5.go
new file mode 100644
index 0000000000..921d7552df
--- /dev/null
+++ b/Task/Conditional-structures/Go/conditional-structures-5.go
@@ -0,0 +1,11 @@
+switch {
+case booleanExpression1:
+    statements
+case booleanExpression2:
+    other
+    statements
+default:
+    last
+    resort
+    statements
+}
diff --git a/Task/Conditional-structures/Go/conditional-structures-6.go b/Task/Conditional-structures/Go/conditional-structures-6.go
new file mode 100644
index 0000000000..8592ae21d3
--- /dev/null
+++ b/Task/Conditional-structures/Go/conditional-structures-6.go
@@ -0,0 +1,7 @@
+switch expressionOfAnyType {
+case value1:
+    statements
+case value2, value3, value4:
+    other
+    statements
+}
diff --git a/Task/Conditional-structures/Go/conditional-structures-7.go b/Task/Conditional-structures/Go/conditional-structures-7.go
new file mode 100644
index 0000000000..e59b874d84
--- /dev/null
+++ b/Task/Conditional-structures/Go/conditional-structures-7.go
@@ -0,0 +1,7 @@
+switch x := fetch(); {
+case x == "cheese":
+    statements
+case otherBooleanExpression:
+    other
+    statements
+}
diff --git a/Task/Conditional-structures/Go/conditional-structures-8.go b/Task/Conditional-structures/Go/conditional-structures-8.go
new file mode 100644
index 0000000000..f65c119509
--- /dev/null
+++ b/Task/Conditional-structures/Go/conditional-structures-8.go
@@ -0,0 +1,10 @@
+switch {
+case booleanExpression1:
+default:
+    statements
+    preliminaryToOtherStatements
+    fallthrough
+case booleanExpression2:
+    other
+    statements
+}
diff --git a/Task/Conditional-structures/Go/conditional-structures-9.go b/Task/Conditional-structures/Go/conditional-structures-9.go
new file mode 100644
index 0000000000..c586493f23
--- /dev/null
+++ b/Task/Conditional-structures/Go/conditional-structures-9.go
@@ -0,0 +1,7 @@
+for {
+    switch {
+    case true:
+        break
+    }
+    fmt.Println("I want out!")
+}
diff --git a/Task/Conditional-structures/Haskell/conditional-structures-1.hs b/Task/Conditional-structures/Haskell/conditional-structures-1.hs
new file mode 100644
index 0000000000..2e97f97740
--- /dev/null
+++ b/Task/Conditional-structures/Haskell/conditional-structures-1.hs
@@ -0,0 +1,3 @@
+fac x = if x==0 then
+           1
+           else x * fac (x - 1)
diff --git a/Task/Conditional-structures/Haskell/conditional-structures-2.hs b/Task/Conditional-structures/Haskell/conditional-structures-2.hs
new file mode 100644
index 0000000000..16d078c321
--- /dev/null
+++ b/Task/Conditional-structures/Haskell/conditional-structures-2.hs
@@ -0,0 +1,2 @@
+fac x | x==0 = 1
+      | x>0 = x * fac (x-1)
diff --git a/Task/Conditional-structures/Haskell/conditional-structures-3.hs b/Task/Conditional-structures/Haskell/conditional-structures-3.hs
new file mode 100644
index 0000000000..5c61c5a48e
--- /dev/null
+++ b/Task/Conditional-structures/Haskell/conditional-structures-3.hs
@@ -0,0 +1,2 @@
+fac 0 = 1
+fac x = x * fac (x-1)
diff --git a/Task/Conditional-structures/Haskell/conditional-structures-4.hs b/Task/Conditional-structures/Haskell/conditional-structures-4.hs
new file mode 100644
index 0000000000..ae799ba321
--- /dev/null
+++ b/Task/Conditional-structures/Haskell/conditional-structures-4.hs
@@ -0,0 +1,2 @@
+fac x = case x of 0 -> 1
+                  _ -> x * fac (x-1)
diff --git a/Task/Conditional-structures/Java/conditional-structures-1.java b/Task/Conditional-structures/Java/conditional-structures-1.java
new file mode 100644
index 0000000000..1dd9b2a216
--- /dev/null
+++ b/Task/Conditional-structures/Java/conditional-structures-1.java
@@ -0,0 +1,10 @@
+if(s.equals("Hello World"))
+{
+    foo();
+}
+else if(s.equals("Bye World"))
+    bar();//{}'s optional for one-liners
+else
+{
+    deusEx();
+}
diff --git a/Task/Conditional-structures/Java/conditional-structures-2.java b/Task/Conditional-structures/Java/conditional-structures-2.java
new file mode 100644
index 0000000000..8a64149e62
--- /dev/null
+++ b/Task/Conditional-structures/Java/conditional-structures-2.java
@@ -0,0 +1,3 @@
+if(obj != null && obj.foo()){
+   aMethod();
+}
diff --git a/Task/Conditional-structures/Java/conditional-structures-3.java b/Task/Conditional-structures/Java/conditional-structures-3.java
new file mode 100644
index 0000000000..5d62f3db30
--- /dev/null
+++ b/Task/Conditional-structures/Java/conditional-structures-3.java
@@ -0,0 +1,3 @@
+if(obj != null & obj.foo()){
+   aMethod();
+}
diff --git a/Task/Conditional-structures/Java/conditional-structures-4.java b/Task/Conditional-structures/Java/conditional-structures-4.java
new file mode 100644
index 0000000000..9303f704c3
--- /dev/null
+++ b/Task/Conditional-structures/Java/conditional-structures-4.java
@@ -0,0 +1 @@
+s.equals("Hello World") ? foo() : bar();
diff --git a/Task/Conditional-structures/Java/conditional-structures-5.java b/Task/Conditional-structures/Java/conditional-structures-5.java
new file mode 100644
index 0000000000..4e2893a979
--- /dev/null
+++ b/Task/Conditional-structures/Java/conditional-structures-5.java
@@ -0,0 +1,9 @@
+switch(c) {
+case 'a':
+   foo();
+   break;
+case 'b':
+   bar();
+default:
+   foobar();
+}
diff --git a/Task/Conditional-structures/Java/conditional-structures-6.java b/Task/Conditional-structures/Java/conditional-structures-6.java
new file mode 100644
index 0000000000..1eed067928
--- /dev/null
+++ b/Task/Conditional-structures/Java/conditional-structures-6.java
@@ -0,0 +1,8 @@
+if(c == 'a'){
+   foo();
+}else if(c == 'b'){
+   bar();
+   foobar();
+}else{
+   foobar();
+}
diff --git a/Task/Conditional-structures/JavaScript/conditional-structures-1.js b/Task/Conditional-structures/JavaScript/conditional-structures-1.js
new file mode 100644
index 0000000000..a4f2199bc1
--- /dev/null
+++ b/Task/Conditional-structures/JavaScript/conditional-structures-1.js
@@ -0,0 +1,7 @@
+if( s == "Hello World" ) {
+    foo();
+} else if( s == "Bye World" ) {
+    bar();
+} else {
+    deusEx();
+}
diff --git a/Task/Conditional-structures/JavaScript/conditional-structures-2.js b/Task/Conditional-structures/JavaScript/conditional-structures-2.js
new file mode 100644
index 0000000000..bba9acb54b
--- /dev/null
+++ b/Task/Conditional-structures/JavaScript/conditional-structures-2.js
@@ -0,0 +1,15 @@
+switch(object) {
+    case 1:
+        one();
+        break;
+    case 2:
+    case 3:
+    case 4:
+        twoThreeOrFour();
+        break;
+    case 5:
+        five();
+        break;
+    default:
+        everythingElse();
+}
diff --git a/Task/Conditional-structures/JavaScript/conditional-structures-3.js b/Task/Conditional-structures/JavaScript/conditional-structures-3.js
new file mode 100644
index 0000000000..9a22238c99
--- /dev/null
+++ b/Task/Conditional-structures/JavaScript/conditional-structures-3.js
@@ -0,0 +1 @@
+var num = window.obj ? obj.getNumber() : null;
diff --git a/Task/Conditional-structures/Lua/conditional-structures.lua b/Task/Conditional-structures/Lua/conditional-structures.lua
new file mode 100644
index 0000000000..57cd142d90
--- /dev/null
+++ b/Task/Conditional-structures/Lua/conditional-structures.lua
@@ -0,0 +1,32 @@
+--if-then-elseif-then-else
+if a then
+  b()
+elseif c then
+  d()
+else
+  e()
+end
+
+for var = start, _end, step do --note: end is a reserved word
+  something()
+end
+
+for var, var2, etc in iteratorfunction do
+  something()
+end
+
+while somethingistrue() do
+  something()
+end
+
+repeat
+  something()
+until somethingistrue()
+
+cases = {
+key1 = dothis,
+key2 = dothat,
+key3 = dotheother
+}
+
+cases[key]() --equivalent to dothis(), dothat(), or dotheother() respectively
diff --git a/Task/Conditional-structures/MATLAB/conditional-structures-1.m b/Task/Conditional-structures/MATLAB/conditional-structures-1.m
new file mode 100644
index 0000000000..4ce55ac94c
--- /dev/null
+++ b/Task/Conditional-structures/MATLAB/conditional-structures-1.m
@@ -0,0 +1,7 @@
+if x == 1
+    disp 'x==1';
+elseif x > 1
+    disp 'x>1';
+else
+    disp 'x<1';
+end
diff --git a/Task/Conditional-structures/MATLAB/conditional-structures-2.m b/Task/Conditional-structures/MATLAB/conditional-structures-2.m
new file mode 100644
index 0000000000..d3489f617e
--- /dev/null
+++ b/Task/Conditional-structures/MATLAB/conditional-structures-2.m
@@ -0,0 +1,8 @@
+switch x
+    case 1
+        disp 'Hello';
+    case 2
+        disp 'World';
+    otherwise
+        disp 'Skynet Active';
+end
diff --git a/Task/Conditional-structures/PHP/conditional-structures-1.php b/Task/Conditional-structures/PHP/conditional-structures-1.php
new file mode 100644
index 0000000000..7332933df9
--- /dev/null
+++ b/Task/Conditional-structures/PHP/conditional-structures-1.php
@@ -0,0 +1,22 @@
+
diff --git a/Task/Conditional-structures/PHP/conditional-structures-2.php b/Task/Conditional-structures/PHP/conditional-structures-2.php
new file mode 100644
index 0000000000..de5abc7900
--- /dev/null
+++ b/Task/Conditional-structures/PHP/conditional-structures-2.php
@@ -0,0 +1,18 @@
+
diff --git a/Task/Conditional-structures/Perl/conditional-structures.pl b/Task/Conditional-structures/Perl/conditional-structures.pl
new file mode 100644
index 0000000000..6037d6bc48
--- /dev/null
+++ b/Task/Conditional-structures/Perl/conditional-structures.pl
@@ -0,0 +1,8 @@
+use feature "switch";
+given ($input) {
+    when (0)          { print 'input == 0'; }
+    when ('coffee')   { print 'input equal coffee'; }
+    when ([1..9])     { print 'input between 1 and 9'; }
+    when (/rats/)     { print 'input matches rats'; }
+    default           { do_fallback; }
+}
diff --git a/Task/Conditional-structures/PicoLisp/conditional-structures-1.l b/Task/Conditional-structures/PicoLisp/conditional-structures-1.l
new file mode 100644
index 0000000000..2dac424657
--- /dev/null
+++ b/Task/Conditional-structures/PicoLisp/conditional-structures-1.l
@@ -0,0 +1,9 @@
+(if (condition)                  # If the condition evaluates to non-NIL
+   (then-do-this)                # Then execute the following expression
+   (else-do-that)                # Else execute all other expressions
+   (and-more) )
+
+(ifn (condition)                 # If the condition evaluates to NIL
+   (then-do-this)                # Then execute the following expression
+   (else-do-that)                # Else execute all other expressions
+   (and-more) )
diff --git a/Task/Conditional-structures/PicoLisp/conditional-structures-2.l b/Task/Conditional-structures/PicoLisp/conditional-structures-2.l
new file mode 100644
index 0000000000..884bdfc60e
--- /dev/null
+++ b/Task/Conditional-structures/PicoLisp/conditional-structures-2.l
@@ -0,0 +1,7 @@
+(when (condition)                # If the condition evaluates to non-NIL
+   (then-do-this)                # Then execute tall following expressions
+   (and-more) )
+
+(unless (condition)              # If the condition evaluates to NIL
+   (then-do-this)                # Then execute all following expressions
+   (and-more) )
diff --git a/Task/Conditional-structures/PicoLisp/conditional-structures-3.l b/Task/Conditional-structures/PicoLisp/conditional-structures-3.l
new file mode 100644
index 0000000000..f45013257c
--- /dev/null
+++ b/Task/Conditional-structures/PicoLisp/conditional-structures-3.l
@@ -0,0 +1,6 @@
+(if2 (condition1) (condition2)   # If both conditions evaluate to non-NIL
+   (expression-both)             # Then execute this expression
+   (expression-first)            # Otherwise this for the first
+   (expression-second)           # or this the second condition.
+   (expression-none)             # If both are NIL, all following expressions
+   (and-more) )
diff --git a/Task/Conditional-structures/PicoLisp/conditional-structures-4.l b/Task/Conditional-structures/PicoLisp/conditional-structures-4.l
new file mode 100644
index 0000000000..e091645187
--- /dev/null
+++ b/Task/Conditional-structures/PicoLisp/conditional-structures-4.l
@@ -0,0 +1,21 @@
+(cond
+   ((condition1)                 # If this condition evaluates to non-NIL
+      (expression 1)             # Execute these expression(s)
+      (more 1) )
+   ((condition2)                 # Otherwise, if this evaluates to non-NIL
+      (expression 2)             # Execute these expression(s)
+      (more 2) )
+   (T                            # If none evaluated to non-NIL
+      (expression 1)             # Execute these expression(s)
+      (more 1) )
+
+(nond
+   ((condition1)                 # If this condition evaluates to NIL
+      (expression 1)             # Execute these expression(s)
+      (more 1) )
+   ((condition2)                 # Otherwise, if this evaluates to NIL
+      (expression 2)             # Execute these expression(s)
+      (more 2) )
+   (NIL                          # If none evaluated to NIL
+      (expression 1)             # Execute these expression(s)
+      (more 1) )
diff --git a/Task/Conditional-structures/PicoLisp/conditional-structures-5.l b/Task/Conditional-structures/PicoLisp/conditional-structures-5.l
new file mode 100644
index 0000000000..704bc09163
--- /dev/null
+++ b/Task/Conditional-structures/PicoLisp/conditional-structures-5.l
@@ -0,0 +1,9 @@
+(case (expression)               # Evaluate the expression
+   (value1                       # If it is equal to, or member of, 'value1'
+      (do-this1)                 # Execute these expression(s)
+      (do-that1) )
+   (value2                       # Else if it is equal to, or member of, 'value2
+      (do-this2)                 # Execute these expression(s)
+      (do-that2) )
+   (T                            # Else execute final expression(s)
+      (do-something-else) ) )
diff --git a/Task/Conditional-structures/Python/conditional-structures-1.py b/Task/Conditional-structures/Python/conditional-structures-1.py
new file mode 100644
index 0000000000..96dfebb81a
--- /dev/null
+++ b/Task/Conditional-structures/Python/conditional-structures-1.py
@@ -0,0 +1,8 @@
+if x == 0:
+    foo()
+elif x == 1:
+    bar()
+elif x == 2:
+    baz()
+else:
+    boz()
diff --git a/Task/Conditional-structures/Python/conditional-structures-2.py b/Task/Conditional-structures/Python/conditional-structures-2.py
new file mode 100644
index 0000000000..3a3deaba3d
--- /dev/null
+++ b/Task/Conditional-structures/Python/conditional-structures-2.py
@@ -0,0 +1 @@
+true_value if condition else false_value
diff --git a/Task/Conditional-structures/Python/conditional-structures-3.py b/Task/Conditional-structures/Python/conditional-structures-3.py
new file mode 100644
index 0000000000..1a814d524c
--- /dev/null
+++ b/Task/Conditional-structures/Python/conditional-structures-3.py
@@ -0,0 +1,3 @@
+>>> secret='foo'
+>>> print 'got it' if secret=='foo' else 'try again'
+'got it'
diff --git a/Task/Conditional-structures/Python/conditional-structures-4.py b/Task/Conditional-structures/Python/conditional-structures-4.py
new file mode 100644
index 0000000000..893859e72a
--- /dev/null
+++ b/Task/Conditional-structures/Python/conditional-structures-4.py
@@ -0,0 +1,4 @@
+>>> secret = 'foo'
+>>> result = 'got it' if secret=='foo' else 'try again'
+>>> print result
+'got it'
diff --git a/Task/Conditional-structures/Python/conditional-structures-5.py b/Task/Conditional-structures/Python/conditional-structures-5.py
new file mode 100644
index 0000000000..8c65e6ca18
--- /dev/null
+++ b/Task/Conditional-structures/Python/conditional-structures-5.py
@@ -0,0 +1,10 @@
+dispatcher = dict()
+dispatcher[0]=foo  # Not foo(): we bind the dictionary entry to the function's object,
+                   # NOT to the results returned by an invocation of the function
+dispatcher[1]=bar
+dispatcher[2]=baz  # foo,bar, baz, and boz are defined functions.
+# Then later
+results = dispatcher.get(x, boz)()  # binding results to a name is optional
+# or with no "default" case:
+if x in dispatcher:
+    results=dispatcher[x]()
diff --git a/Task/Conditional-structures/R/conditional-structures-1.r b/Task/Conditional-structures/R/conditional-structures-1.r
new file mode 100644
index 0000000000..bef67ea1af
--- /dev/null
+++ b/Task/Conditional-structures/R/conditional-structures-1.r
@@ -0,0 +1,13 @@
+#Single line example
+ #x is assumed to be scalar
+ if(x < 3) message("x is less than 3") else if(x < 5) message("x is greater than or equal to 3 but less than 5") else message("x is greater than or equal to 5")
+#Block example
+ if(x < 3)
+ {
+    x <- 3
+    warning("x has been increased to 3")
+ } else
+ {
+    y <- x^2
+ }
+#It is important that the else keyword appears on the same line as the closing '}' of the if block.
diff --git a/Task/Conditional-structures/R/conditional-structures-2.r b/Task/Conditional-structures/R/conditional-structures-2.r
new file mode 100644
index 0000000000..4ad35586b6
--- /dev/null
+++ b/Task/Conditional-structures/R/conditional-structures-2.r
@@ -0,0 +1,3 @@
+#ifelse is a vectorised version of the if/else flow controllers, similar to the C-style ternary operator.
+ x <- sample(1:10, 10)
+ ifelse(x > 5, x^2, 0)
diff --git a/Task/Conditional-structures/R/conditional-structures-3.r b/Task/Conditional-structures/R/conditional-structures-3.r
new file mode 100644
index 0000000000..348713d55d
--- /dev/null
+++ b/Task/Conditional-structures/R/conditional-structures-3.r
@@ -0,0 +1,12 @@
+# Character input
+ calories <- function(food) switch(food, apple=47, pizza=1500, stop("food not known"))
+ calories("apple")  # 47
+ calories("banana") # throws an error
+# Numeric input
+ alphabet <- function(number) switch(number, "a", "ab", "abc")
+ alphabet(0) # null response
+ alphabet(1) # "a"
+ alphabet(2) # "ab"
+ alphabet(3) # "abc"
+ alphabet(4) # null response
+# Note that no 'otherwise' option is allowed when the input is numeric.
diff --git a/Task/Conditional-structures/REXX/conditional-structures-1.rexx b/Task/Conditional-structures/REXX/conditional-structures-1.rexx
new file mode 100644
index 0000000000..5a1d105c5c
--- /dev/null
+++ b/Task/Conditional-structures/REXX/conditional-structures-1.rexx
@@ -0,0 +1,22 @@
+if  y  then x=6                        /* Y must be either   0   or   1 */
+
+
+if t**2>u then x= y
+          else x=-y
+
+
+if t**2>u then do j=1 to 10; say prime(j); end
+          else x=-y
+
+
+if z>w+4 then do
+              z=abs(z)
+              say 'z='z
+              end
+         else do;  z=0;  say 'failed.';  end
+
+
+if x>y & c*d0       then do
+                      y=sqrt(z)
+                      z=u**2
+                      end
+
+                /*if control reaches this point  and  none of the WHENs */
+                /*were satisfied,  a SYNTAX condition is raised (error).*/
+  end   /*select*/
diff --git a/Task/Conditional-structures/REXX/conditional-structures-3.rexx b/Task/Conditional-structures/REXX/conditional-structures-3.rexx
new file mode 100644
index 0000000000..94df904106
--- /dev/null
+++ b/Task/Conditional-structures/REXX/conditional-structures-3.rexx
@@ -0,0 +1,14 @@
+     select
+     when g=='angel'              then many='host'
+     when g=='ass' | g=='donkey'  then many='pace'
+     when g=='crocodile'          then many='bask'
+     when g=='crow'               then many='murder'
+     when g=='lark'               then many='ascension'
+     when g=='quail'              then many='bevy'
+     when g=='wolf'               then many='pack'
+     otherwise  say
+                say '*** error! ***'
+                say g "isn't one of the known thingys."
+                say
+                exit 13
+     end   /*select*/
diff --git a/Task/Conditional-structures/SNUSP/conditional-structures.snusp b/Task/Conditional-structures/SNUSP/conditional-structures.snusp
new file mode 100644
index 0000000000..8a05a5b7ff
--- /dev/null
+++ b/Task/Conditional-structures/SNUSP/conditional-structures.snusp
@@ -0,0 +1,2 @@
+$==?\==zero=====!/==#
+    \==non zero==/
diff --git a/Task/Conditional-structures/Sather/conditional-structures-1.sa b/Task/Conditional-structures/Sather/conditional-structures-1.sa
new file mode 100644
index 0000000000..0e7532301d
--- /dev/null
+++ b/Task/Conditional-structures/Sather/conditional-structures-1.sa
@@ -0,0 +1,7 @@
+    if EXPR then
+      -- CODE
+    elsif EXPR then
+      -- CODE
+    else
+      -- CODE
+    end;
diff --git a/Task/Conditional-structures/Sather/conditional-structures-2.sa b/Task/Conditional-structures/Sather/conditional-structures-2.sa
new file mode 100644
index 0000000000..60d9b0dfb3
--- /dev/null
+++ b/Task/Conditional-structures/Sather/conditional-structures-2.sa
@@ -0,0 +1,8 @@
+    case EXPR
+      when EXPRL then
+         -- CODE
+      when EXPRL then
+         -- CODE
+      else
+         -- CODE
+    end;
diff --git a/Task/Conditional-structures/Scheme/conditional-structures-1.ss b/Task/Conditional-structures/Scheme/conditional-structures-1.ss
new file mode 100644
index 0000000000..d9cfa37414
--- /dev/null
+++ b/Task/Conditional-structures/Scheme/conditional-structures-1.ss
@@ -0,0 +1 @@
+(if   )
diff --git a/Task/Conditional-structures/Scheme/conditional-structures-10.ss b/Task/Conditional-structures/Scheme/conditional-structures-10.ss
new file mode 100644
index 0000000000..dff3aefd79
--- /dev/null
+++ b/Task/Conditional-structures/Scheme/conditional-structures-10.ss
@@ -0,0 +1,2 @@
+composite
+consonant
diff --git a/Task/Conditional-structures/Scheme/conditional-structures-2.ss b/Task/Conditional-structures/Scheme/conditional-structures-2.ss
new file mode 100644
index 0000000000..16fac090a1
--- /dev/null
+++ b/Task/Conditional-structures/Scheme/conditional-structures-2.ss
@@ -0,0 +1 @@
+(if  )
diff --git a/Task/Conditional-structures/Scheme/conditional-structures-3.ss b/Task/Conditional-structures/Scheme/conditional-structures-3.ss
new file mode 100644
index 0000000000..163ffa25e5
--- /dev/null
+++ b/Task/Conditional-structures/Scheme/conditional-structures-3.ss
@@ -0,0 +1,9 @@
+(display
+  (if (> 1 2)
+      "yes"
+      "no"))
+(newline)
+(display
+  (if (> 1 2)
+      (- 1 2)))
+(newline)
diff --git a/Task/Conditional-structures/Scheme/conditional-structures-4.ss b/Task/Conditional-structures/Scheme/conditional-structures-4.ss
new file mode 100644
index 0000000000..586ef2350a
--- /dev/null
+++ b/Task/Conditional-structures/Scheme/conditional-structures-4.ss
@@ -0,0 +1,2 @@
+no
+#
diff --git a/Task/Conditional-structures/Scheme/conditional-structures-5.ss b/Task/Conditional-structures/Scheme/conditional-structures-5.ss
new file mode 100644
index 0000000000..fe5913139b
--- /dev/null
+++ b/Task/Conditional-structures/Scheme/conditional-structures-5.ss
@@ -0,0 +1 @@
+(cond   ...)
diff --git a/Task/Conditional-structures/Scheme/conditional-structures-6.ss b/Task/Conditional-structures/Scheme/conditional-structures-6.ss
new file mode 100644
index 0000000000..dcc72e04dd
--- /dev/null
+++ b/Task/Conditional-structures/Scheme/conditional-structures-6.ss
@@ -0,0 +1,9 @@
+(display
+  (cond ((> 1 2) "greater")
+        ((< 1 2) "less")))
+(newline)
+(display
+  (cond ((> 1 1) "greater")
+        ((< 1 1) "less")
+        (else "equal")))
+(newline)
diff --git a/Task/Conditional-structures/Scheme/conditional-structures-7.ss b/Task/Conditional-structures/Scheme/conditional-structures-7.ss
new file mode 100644
index 0000000000..a5b3cc688c
--- /dev/null
+++ b/Task/Conditional-structures/Scheme/conditional-structures-7.ss
@@ -0,0 +1,2 @@
+less
+equal
diff --git a/Task/Conditional-structures/Scheme/conditional-structures-8.ss b/Task/Conditional-structures/Scheme/conditional-structures-8.ss
new file mode 100644
index 0000000000..ae39fe7209
--- /dev/null
+++ b/Task/Conditional-structures/Scheme/conditional-structures-8.ss
@@ -0,0 +1 @@
+(case    ...)
diff --git a/Task/Conditional-structures/Scheme/conditional-structures-9.ss b/Task/Conditional-structures/Scheme/conditional-structures-9.ss
new file mode 100644
index 0000000000..affbd16181
--- /dev/null
+++ b/Task/Conditional-structures/Scheme/conditional-structures-9.ss
@@ -0,0 +1,11 @@
+(display
+  (case (* 2 3)
+    ((2 3 5 7) "prime")
+    ((1 4 6 8 9) "composite")))
+(newline)
+(display
+  (case (car (list c d))
+    ((a e i o u) "vowel")
+    ((w y) "semivowel")
+    (else "consonant")))
+(newline)
diff --git a/Task/Conditional-structures/Smalltalk/conditional-structures-1.st b/Task/Conditional-structures/Smalltalk/conditional-structures-1.st
new file mode 100644
index 0000000000..88004c5250
--- /dev/null
+++ b/Task/Conditional-structures/Smalltalk/conditional-structures-1.st
@@ -0,0 +1,4 @@
+"Conditionals in Smalltalk are really messages sent to Boolean objects"
+ balance > 0
+     ifTrue: [Transcript cr; show: 'still sitting pretty!'.]
+     ifFalse: [Transcript cr; show: 'No money till payday!'.].
diff --git a/Task/Conditional-structures/Smalltalk/conditional-structures-2.st b/Task/Conditional-structures/Smalltalk/conditional-structures-2.st
new file mode 100644
index 0000000000..5e56ef0cbd
--- /dev/null
+++ b/Task/Conditional-structures/Smalltalk/conditional-structures-2.st
@@ -0,0 +1 @@
+abs := x > 0 ifTrue: [ x ] ifFalse: [ x negated ]
diff --git a/Task/Conditional-structures/Tcl/conditional-structures-1.tcl b/Task/Conditional-structures/Tcl/conditional-structures-1.tcl
new file mode 100644
index 0000000000..a44513a5b4
--- /dev/null
+++ b/Task/Conditional-structures/Tcl/conditional-structures-1.tcl
@@ -0,0 +1,7 @@
+if {$foo == 3} {
+    puts "foo is three"
+} elseif {$foo == 4} {
+    puts "foo is four"
+} else {
+    puts "foo is neither three nor four"
+}
diff --git a/Task/Conditional-structures/Tcl/conditional-structures-2.tcl b/Task/Conditional-structures/Tcl/conditional-structures-2.tcl
new file mode 100644
index 0000000000..09a893c5ea
--- /dev/null
+++ b/Task/Conditional-structures/Tcl/conditional-structures-2.tcl
@@ -0,0 +1 @@
+set result [expr { $foo == 3 ? "three" : "not three" }]
diff --git a/Task/Conditional-structures/Tcl/conditional-structures-3.tcl b/Task/Conditional-structures/Tcl/conditional-structures-3.tcl
new file mode 100644
index 0000000000..21f16835ab
--- /dev/null
+++ b/Task/Conditional-structures/Tcl/conditional-structures-3.tcl
@@ -0,0 +1,5 @@
+switch -- $foo {
+    3 {puts "foo is three"}
+    4 {puts "foo is four"}
+    default {puts "foo is something else"}
+}
diff --git a/Task/Constrained-genericity/0DESCRIPTION b/Task/Constrained-genericity/0DESCRIPTION
new file mode 100644
index 0000000000..95d1118000
--- /dev/null
+++ b/Task/Constrained-genericity/0DESCRIPTION
@@ -0,0 +1,4 @@
+{{omit from|BBC BASIC}}
+'''Constrained genericity''' or '''bounded quantification''' means that a parametrized type or function (see [[parametric polymorphism]]) can only be instantiated on types fulfilling some conditions, even if those conditions are not used in that function.
+
+Say a type is called "eatable" if you can call the function eat on it. Write a generic type FoodBox which contains a collection of objects of a type given as parameter, but can only be instantiated on eatable types. The FoodBox shall not use the function eat in any way (i.e. without the explicit restriction, it could be instantiated on any type). The specification of a type being eatable should be as generic as possible in your language (i.e. the restrictions on the implementation of eatable types should be as minimal as possible). Also explain the restrictions, if any, on the implementation of eatable types, and show at least one example of an eatable type.
diff --git a/Task/Constrained-genericity/1META.yaml b/Task/Constrained-genericity/1META.yaml
new file mode 100644
index 0000000000..0535d6f9ea
--- /dev/null
+++ b/Task/Constrained-genericity/1META.yaml
@@ -0,0 +1,4 @@
+---
+category:
+- Type System
+note: Object oriented
diff --git a/Task/Constrained-genericity/Ada/constrained-genericity-1.ada b/Task/Constrained-genericity/Ada/constrained-genericity-1.ada
new file mode 100644
index 0000000000..cb6067c059
--- /dev/null
+++ b/Task/Constrained-genericity/Ada/constrained-genericity-1.ada
@@ -0,0 +1,24 @@
+with Ada.Containers.Indefinite_Vectors;
+
+package Nutrition is
+   type Food is interface;
+   procedure Eat (Object : in out Food) is abstract;
+
+end Nutrition;
+
+with Ada.Containers;
+with Nutrition;
+
+generic
+   type New_Food is new Nutrition.Food;
+package Food_Boxes is
+
+  package Food_Vectors is
+      new Ada.Containers.Indefinite_Vectors
+          (  Index_Type   => Positive,
+             Element_Type => New_Food
+          );
+
+   subtype Food_Box is Food_Vectors.Vector;
+
+end Food_Boxes;
diff --git a/Task/Constrained-genericity/Ada/constrained-genericity-2.ada b/Task/Constrained-genericity/Ada/constrained-genericity-2.ada
new file mode 100644
index 0000000000..5657c969ab
--- /dev/null
+++ b/Task/Constrained-genericity/Ada/constrained-genericity-2.ada
@@ -0,0 +1,8 @@
+type Banana is new Food with null record;
+overriding procedure Eat (Object : in out Banana) is null;
+package Banana_Box is new Food_Boxes (Banana);
+
+type Tomato is new Food with null record;
+overriding procedure Eat (Object : in out Tomato) is null;
+package Tomato_Box is new Food_Boxes (Tomato);
+-- We have declared Banana and Tomato as a Food.
diff --git a/Task/Constrained-genericity/Common-Lisp/constrained-genericity.lisp b/Task/Constrained-genericity/Common-Lisp/constrained-genericity.lisp
new file mode 100644
index 0000000000..223ea350ca
--- /dev/null
+++ b/Task/Constrained-genericity/Common-Lisp/constrained-genericity.lisp
@@ -0,0 +1,34 @@
+(defclass food () ())
+
+(defclass inedible-food (food) ())
+
+(defclass edible-food (food) ())
+
+(defgeneric eat (foodstuff)
+  (:documentation "Eat the foodstuff."))
+
+(defmethod eat ((foodstuff edible-food))
+  "A specialized method for eating edible-food."
+  (format nil "Eating ~w." foodstuff))
+
+(defun eatable-p (thing)
+  "Returns true if there are eat methods defined for thing."
+  (not (endp (compute-applicable-methods #'eat (list thing)))))
+
+(deftype eatable ()
+  "Eatable objects are those satisfying eatable-p."
+  '(satisfies eatable-p))
+
+(defun make-food-box (extra-type &rest array-args)
+  "Returns an array whose element-type is (and extra-type food).
+array-args should be suitable for MAKE-ARRAY, and any provided
+element-type keyword argument is ignored."
+  (destructuring-bind (dimensions &rest array-args) array-args
+    (apply 'make-array dimensions
+           :element-type `(and ,extra-type food)
+           array-args)))
+
+(defun make-eatable-food-box (&rest array-args)
+  "Return an array whose elements are declared to be of type (and
+eatable food)."
+  (apply 'make-food-box 'eatable array-args))
diff --git a/Task/Constrained-genericity/D/constrained-genericity-1.d b/Task/Constrained-genericity/D/constrained-genericity-1.d
new file mode 100644
index 0000000000..e5d1270b74
--- /dev/null
+++ b/Task/Constrained-genericity/D/constrained-genericity-1.d
@@ -0,0 +1,21 @@
+template IsEdible(T) {
+    enum IsEdible = is(typeof(T.eat()));
+}
+
+struct FoodBox(T) if (IsEdible!T) {
+    T[] food;
+    alias food this;
+}
+
+struct Carrot {
+    void eat() {}
+}
+
+static struct Car {}
+
+void main() {
+    FoodBox!Carrot carrotsBox; // OK
+    carrotsBox ~= Carrot();    // Adds a carrot
+
+    //FoodBox!Car carsBox;     // Not allowed
+}
diff --git a/Task/Constrained-genericity/D/constrained-genericity-2.d b/Task/Constrained-genericity/D/constrained-genericity-2.d
new file mode 100644
index 0000000000..9accbda904
--- /dev/null
+++ b/Task/Constrained-genericity/D/constrained-genericity-2.d
@@ -0,0 +1,17 @@
+interface IEdible { void eat(); }
+
+struct FoodBox(T : IEdible) {
+    T[] food;
+    alias food this;
+}
+
+class Carrot : IEdible {
+    void eat() {}
+}
+
+class Car {}
+
+void main() {
+    FoodBox!Carrot carrotBox; // OK
+    //FoodBox!Car carBox;     // Not allowed
+}
diff --git a/Task/Constrained-genericity/E/constrained-genericity.e b/Task/Constrained-genericity/E/constrained-genericity.e
new file mode 100644
index 0000000000..d245f55976
--- /dev/null
+++ b/Task/Constrained-genericity/E/constrained-genericity.e
@@ -0,0 +1,14 @@
+/** Guard accepting only objects with an 'eat' method */
+def Eatable {
+    to coerce(specimen, ejector) {
+        if (Ref.isNear(specimen) && specimen.__respondsTo("eat", 0)) {
+            return specimen
+        } else {
+            throw.eject(ejector, `inedible: $specimen`)
+        }
+    }
+}
+
+def makeFoodBox() {
+    return [].diverge(Eatable) # A guard-constrained list
+}
diff --git a/Task/Constrained-genericity/Eiffel/constrained-genericity-1.e b/Task/Constrained-genericity/Eiffel/constrained-genericity-1.e
new file mode 100644
index 0000000000..863d0654a4
--- /dev/null
+++ b/Task/Constrained-genericity/Eiffel/constrained-genericity-1.e
@@ -0,0 +1,10 @@
+deferred class
+    EATABLE
+
+feature -- Basic operations
+
+    eat
+            -- Eat this eatable substance
+        deferred
+        end
+end
diff --git a/Task/Constrained-genericity/Eiffel/constrained-genericity-2.e b/Task/Constrained-genericity/Eiffel/constrained-genericity-2.e
new file mode 100644
index 0000000000..4b42f4ea5f
--- /dev/null
+++ b/Task/Constrained-genericity/Eiffel/constrained-genericity-2.e
@@ -0,0 +1,14 @@
+class
+    APPLE
+
+inherit
+    EATABLE
+
+feature -- Basic operations
+
+    eat
+            -- Consume
+        do
+            print ("One apple eaten%N")
+        end
+end
diff --git a/Task/Constrained-genericity/Eiffel/constrained-genericity-3.e b/Task/Constrained-genericity/Eiffel/constrained-genericity-3.e
new file mode 100644
index 0000000000..45c3612444
--- /dev/null
+++ b/Task/Constrained-genericity/Eiffel/constrained-genericity-3.e
@@ -0,0 +1,14 @@
+class
+    PEAR
+
+inherit
+    EATABLE
+
+feature -- Basic operations
+
+    eat
+            -- Consume
+        do
+            print ("One pear eaten%N")
+        end
+end
diff --git a/Task/Constrained-genericity/Eiffel/constrained-genericity-4.e b/Task/Constrained-genericity/Eiffel/constrained-genericity-4.e
new file mode 100644
index 0000000000..69f359f832
--- /dev/null
+++ b/Task/Constrained-genericity/Eiffel/constrained-genericity-4.e
@@ -0,0 +1,10 @@
+class
+    FOOD_BOX [G -> EATABLE]
+
+inherit
+    ARRAYED_LIST [G]
+
+create
+    make
+
+end
diff --git a/Task/Constrained-genericity/Eiffel/constrained-genericity-5.e b/Task/Constrained-genericity/Eiffel/constrained-genericity-5.e
new file mode 100644
index 0000000000..ea6bdefc7a
--- /dev/null
+++ b/Task/Constrained-genericity/Eiffel/constrained-genericity-5.e
@@ -0,0 +1 @@
+    my_apple_box: FOOD_BOX [APPLE]
diff --git a/Task/Constrained-genericity/Eiffel/constrained-genericity-6.e b/Task/Constrained-genericity/Eiffel/constrained-genericity-6.e
new file mode 100644
index 0000000000..6306f65085
--- /dev/null
+++ b/Task/Constrained-genericity/Eiffel/constrained-genericity-6.e
@@ -0,0 +1 @@
+    my_refrigerator: FOOD_BOX [EATABLE]
diff --git a/Task/Constrained-genericity/Eiffel/constrained-genericity-7.e b/Task/Constrained-genericity/Eiffel/constrained-genericity-7.e
new file mode 100644
index 0000000000..15c75cf73f
--- /dev/null
+++ b/Task/Constrained-genericity/Eiffel/constrained-genericity-7.e
@@ -0,0 +1,34 @@
+class
+    APPLICATION
+
+create
+    make
+
+feature {NONE} -- Initialization
+
+    make
+            -- Run application.
+        do
+            create my_apple_box.make (10)
+            create one_apple
+            create one_pear
+            my_apple_box.extend (one_apple)
+--          my_apple_box.extend (one_pear)
+            across
+                my_apple_box as ic
+            loop
+                ic.item.eat
+            end
+        end
+
+feature -- Access
+
+    my_apple_box: FOOD_BOX [APPLE]
+            -- My apple box
+
+    one_apple: APPLE
+            -- An apple
+
+    one_pear: PEAR
+            -- A pear
+end
diff --git a/Task/Constrained-genericity/Eiffel/constrained-genericity-8.e b/Task/Constrained-genericity/Eiffel/constrained-genericity-8.e
new file mode 100644
index 0000000000..e0f541213b
--- /dev/null
+++ b/Task/Constrained-genericity/Eiffel/constrained-genericity-8.e
@@ -0,0 +1 @@
+--              my_apple_box.extend (one_pear)
diff --git a/Task/Constrained-genericity/Go/constrained-genericity-1.go b/Task/Constrained-genericity/Go/constrained-genericity-1.go
new file mode 100644
index 0000000000..8682ec1031
--- /dev/null
+++ b/Task/Constrained-genericity/Go/constrained-genericity-1.go
@@ -0,0 +1,3 @@
+type eatable interface {
+    eat()
+}
diff --git a/Task/Constrained-genericity/Go/constrained-genericity-2.go b/Task/Constrained-genericity/Go/constrained-genericity-2.go
new file mode 100644
index 0000000000..85dc1fe783
--- /dev/null
+++ b/Task/Constrained-genericity/Go/constrained-genericity-2.go
@@ -0,0 +1 @@
+type foodbox []eatable
diff --git a/Task/Constrained-genericity/Go/constrained-genericity-3.go b/Task/Constrained-genericity/Go/constrained-genericity-3.go
new file mode 100644
index 0000000000..30eb23f8ed
--- /dev/null
+++ b/Task/Constrained-genericity/Go/constrained-genericity-3.go
@@ -0,0 +1,6 @@
+type peelfirst string
+
+func (f peelfirst) eat() {
+    // peel code goes here
+    fmt.Println("mm, that", f, "was good!")
+}
diff --git a/Task/Constrained-genericity/Go/constrained-genericity-4.go b/Task/Constrained-genericity/Go/constrained-genericity-4.go
new file mode 100644
index 0000000000..af759b0895
--- /dev/null
+++ b/Task/Constrained-genericity/Go/constrained-genericity-4.go
@@ -0,0 +1,22 @@
+package main
+
+import "fmt"
+
+type eatable interface {
+    eat()
+}
+
+type foodbox []eatable
+
+type peelfirst string
+
+func (f peelfirst) eat() {
+    // peel code goes here
+    fmt.Println("mm, that", f, "was good!")
+}
+
+func main() {
+    fb := foodbox{peelfirst("banana"), peelfirst("mango")}
+    f0 := fb[0]
+    f0.eat()
+}
diff --git a/Task/Constrained-genericity/Haskell/constrained-genericity-1.hs b/Task/Constrained-genericity/Haskell/constrained-genericity-1.hs
new file mode 100644
index 0000000000..0885ded1b4
--- /dev/null
+++ b/Task/Constrained-genericity/Haskell/constrained-genericity-1.hs
@@ -0,0 +1,2 @@
+class Eatable a where
+  eat :: a -> String
diff --git a/Task/Constrained-genericity/Haskell/constrained-genericity-2.hs b/Task/Constrained-genericity/Haskell/constrained-genericity-2.hs
new file mode 100644
index 0000000000..9445d574a3
--- /dev/null
+++ b/Task/Constrained-genericity/Haskell/constrained-genericity-2.hs
@@ -0,0 +1 @@
+data (Eatable a) => FoodBox a = F [a]
diff --git a/Task/Constrained-genericity/Haskell/constrained-genericity-3.hs b/Task/Constrained-genericity/Haskell/constrained-genericity-3.hs
new file mode 100644
index 0000000000..3720989fb7
--- /dev/null
+++ b/Task/Constrained-genericity/Haskell/constrained-genericity-3.hs
@@ -0,0 +1,3 @@
+data Banana = Foo -- the implementation doesn't really matter in this case
+instance Eatable Banana where
+  eat _ = "I'm eating a banana"
diff --git a/Task/Constrained-genericity/Haskell/constrained-genericity-4.hs b/Task/Constrained-genericity/Haskell/constrained-genericity-4.hs
new file mode 100644
index 0000000000..3fe4926e7d
--- /dev/null
+++ b/Task/Constrained-genericity/Haskell/constrained-genericity-4.hs
@@ -0,0 +1,2 @@
+instance Eatable Double where
+  eat d = "I'm eating " ++ show d
diff --git a/Task/Constrained-genericity/Haskell/constrained-genericity-5.hs b/Task/Constrained-genericity/Haskell/constrained-genericity-5.hs
new file mode 100644
index 0000000000..257b350352
--- /dev/null
+++ b/Task/Constrained-genericity/Haskell/constrained-genericity-5.hs
@@ -0,0 +1,2 @@
+class Food a where
+  munch :: a -> String
diff --git a/Task/Constrained-genericity/Haskell/constrained-genericity-6.hs b/Task/Constrained-genericity/Haskell/constrained-genericity-6.hs
new file mode 100644
index 0000000000..e21a648aca
--- /dev/null
+++ b/Task/Constrained-genericity/Haskell/constrained-genericity-6.hs
@@ -0,0 +1,2 @@
+instance (Food a) => Eatable a where
+  eat x = munch x
diff --git a/Task/Constrained-genericity/Java/constrained-genericity-1.java b/Task/Constrained-genericity/Java/constrained-genericity-1.java
new file mode 100644
index 0000000000..192535ad35
--- /dev/null
+++ b/Task/Constrained-genericity/Java/constrained-genericity-1.java
@@ -0,0 +1,4 @@
+interface Eatable
+{
+    void eat();
+}
diff --git a/Task/Constrained-genericity/Java/constrained-genericity-2.java b/Task/Constrained-genericity/Java/constrained-genericity-2.java
new file mode 100644
index 0000000000..57a4b314e4
--- /dev/null
+++ b/Task/Constrained-genericity/Java/constrained-genericity-2.java
@@ -0,0 +1,6 @@
+import java.util.List;
+
+class FoodBox
+{
+    public List food;
+}
diff --git a/Task/Constrained-genericity/Java/constrained-genericity-3.java b/Task/Constrained-genericity/Java/constrained-genericity-3.java
new file mode 100644
index 0000000000..1d325e4856
--- /dev/null
+++ b/Task/Constrained-genericity/Java/constrained-genericity-3.java
@@ -0,0 +1,2 @@
+public  void foo(T x) { }
+// although in this case this is no more useful than just "public void foo(Eatable x)"
diff --git a/Task/Constrained-genericity/Java/constrained-genericity-4.java b/Task/Constrained-genericity/Java/constrained-genericity-4.java
new file mode 100644
index 0000000000..4986299fb4
--- /dev/null
+++ b/Task/Constrained-genericity/Java/constrained-genericity-4.java
@@ -0,0 +1,3 @@
+public class Test{
+   public  void bar(){ }
+}
diff --git a/Task/Constrained-genericity/Java/constrained-genericity-5.java b/Task/Constrained-genericity/Java/constrained-genericity-5.java
new file mode 100644
index 0000000000..004353a720
--- /dev/null
+++ b/Task/Constrained-genericity/Java/constrained-genericity-5.java
@@ -0,0 +1 @@
+test.bar();
diff --git a/Task/Constrained-genericity/PicoLisp/constrained-genericity.l b/Task/Constrained-genericity/PicoLisp/constrained-genericity.l
new file mode 100644
index 0000000000..9deaaa1924
--- /dev/null
+++ b/Task/Constrained-genericity/PicoLisp/constrained-genericity.l
@@ -0,0 +1,18 @@
+(class +Eatable)
+
+(dm eat> ()
+   (prinl "I'm eatable") )
+
+
+(class +FoodBox)
+# obj
+
+(dm set> (Obj)
+   (unless (method 'eat> Obj)                # Check if the object is eatable
+      (quit "Object is not eatable" Obj) )
+   (=: obj Obj) )                            # If so, set the object
+
+
+(let (Box (new '(+FoodBox))  Eat (new '(+Eatable))  NoEat (new '(+Bla)))
+   (set> Box Eat)       # Works
+   (set> Box NoEat) )   # Gives an error
diff --git a/Task/Constrained-genericity/Sather/constrained-genericity.sa b/Task/Constrained-genericity/Sather/constrained-genericity.sa
new file mode 100644
index 0000000000..171e82dbec
--- /dev/null
+++ b/Task/Constrained-genericity/Sather/constrained-genericity.sa
@@ -0,0 +1,51 @@
+abstract class $EDIBLE is
+  eat;
+end;
+
+class FOOD < $EDIBLE is
+  readonly attr name:STR;
+  eat is
+    #OUT + "eating " + self.name + "\n";
+  end;
+  create(name:STR):SAME is
+    res ::= new;
+    res.name := name;
+    return res;
+  end;
+end;
+
+class CAR is
+  readonly attr name:STR;
+  create(name:STR):SAME is
+    res ::= new;
+    res.name := name;
+    return res;
+  end;
+end;
+
+class FOODBOX{T < $EDIBLE} is
+  private attr list:LLIST{T};
+  create:SAME is
+    res ::= new;
+    res.list := #;
+    return res;
+  end;
+  add(c :T) is
+    self.list.insert_back(c);
+  end;
+  elt!:T is loop yield self.list.elt!; end; end;
+end;
+
+class MAIN is
+  main is
+    box  ::= #FOODBOX{FOOD}; -- ok
+    box.add(#FOOD("Banana"));
+    box.add(#FOOD("Amanita Muscaria"));
+
+    box2 ::= #FOODBOX{CAR};  -- not ok
+    box2.add(#CAR("Punto")); -- but compiler let it pass!
+
+    -- eat everything
+    loop box.elt!.eat; end;
+  end;
+end;
diff --git a/Task/Constrained-genericity/Scala/constrained-genericity.scala b/Task/Constrained-genericity/Scala/constrained-genericity.scala
new file mode 100644
index 0000000000..52780da6a8
--- /dev/null
+++ b/Task/Constrained-genericity/Scala/constrained-genericity.scala
@@ -0,0 +1,11 @@
+type Eatable = { def eat: Unit }
+
+class FoodBox(coll: List[Eatable])
+
+case class Fish(name: String) {
+  def eat {
+    println("Eating "+name)
+  }
+}
+
+val foodBox = new FoodBox(List(new Fish("salmon")))
diff --git a/Task/Constrained-random-points-on-a-circle/0DESCRIPTION b/Task/Constrained-random-points-on-a-circle/0DESCRIPTION
new file mode 100644
index 0000000000..7ab39b9e3c
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/0DESCRIPTION
@@ -0,0 +1,8 @@
+Generate 100  coordinate pairs such that x and y are integers sampled from the uniform distribution with the condition that 10 \leq \sqrt{ x^2 + y^2 } \leq 15 . Then display/plot them. The outcome should be a "fuzzy" circle. The actual number of points plotted may be less than 100, given that some pairs may be generated more than once.
+
+There are several possible approaches to accomplish this. Here are two possible algorithms.
+
+1) Generate random pairs of integers and filter out those that don't satisfy this condition:
+:10 \leq \sqrt{ x^2 + y^2 } \leq 15 .
+
+2) Precalculate the set of all possible points (there are 404 of them) and select randomly from this set.
diff --git a/Task/Constrained-random-points-on-a-circle/1META.yaml b/Task/Constrained-random-points-on-a-circle/1META.yaml
new file mode 100644
index 0000000000..29aeacfd2a
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/1META.yaml
@@ -0,0 +1,2 @@
+---
+note: Probability and statistics
diff --git a/Task/Constrained-random-points-on-a-circle/ALGOL-68/constrained-random-points-on-a-circle.alg b/Task/Constrained-random-points-on-a-circle/ALGOL-68/constrained-random-points-on-a-circle.alg
new file mode 100644
index 0000000000..1c2b87a086
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/ALGOL-68/constrained-random-points-on-a-circle.alg
@@ -0,0 +1,72 @@
+PROC clrscr = VOID:
+        printf(($g"[2J"$,REPR 27)); # ansi.sys #
+
+PROC gotoxy = (INT x,y)VOID:
+        printf(($g"["g(0)";"g(0)"H"$,REPR 27, y,x)); # ansi.sys #
+
+MODE POINT = STRUCT(
+    INT x,y
+);
+
+INT radius = 15;
+INT inside radius = 10;
+
+POINT center = (radius+1, radius+1);
+
+FLEX[0]POINT set;
+
+PROC swap with last set = (INT position,INT where last set)VOID:
+(
+        INT temp := x OF set[position];
+        x OF set[position]:=x OF set[where last set];
+        x OF set[where last set] := temp;
+
+        temp := y OF set[position];
+        y OF set[position]:=y OF set[where last set];
+        y OF set[where last set] := temp
+);
+
+PROC create set = VOID:
+(
+        set := HEAP[(2*radius+1)**2]POINT;
+        INT x,y,i:=LWB set;
+
+        FOR x FROM -radius TO radius DO
+                FOR y FROM -radius TO radius DO
+                        IF sqrt(x*x+y*y)>=inside radius AND sqrt(x*x+y*y)<=radius THEN
+                                x OF set[i] := x;
+                                y OF set[i] := y;
+                                i+:=1
+                        FI
+                OD
+        OD;
+
+        set:=set[:i-1]
+);
+
+PROC plot fuzzy set = (CHAR ch)VOID:
+(
+        INT pos,i;
+
+        TO UPB set DO
+                pos := ENTIER(random * UPB set) + 1;
+
+                gotoxy(x OF center + x OF set[pos],y OF center + y OF set[pos]);
+
+                print(ch);
+
+                swap with last set(pos,UPB set)
+
+        OD
+);
+
+main:
+(
+        # srand((INT)time(NIL)); #
+
+        clrscr;
+        create set;
+        plot fuzzy set("*");
+        gotoxy(2*radius+1, 2*radius+1);
+        newline(stand in)
+)
diff --git a/Task/Constrained-random-points-on-a-circle/Ada/constrained-random-points-on-a-circle.ada b/Task/Constrained-random-points-on-a-circle/Ada/constrained-random-points-on-a-circle.ada
new file mode 100644
index 0000000000..60e2a1dbd5
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Ada/constrained-random-points-on-a-circle.ada
@@ -0,0 +1,94 @@
+with Ada.Text_IO;
+with Ada.Numerics.Discrete_Random;
+procedure Circle is
+   -- extreme coordinate values are -15:0, 15:0, 0:-15, 0:15
+   subtype Coordinate is Integer range -15 .. 15;
+   type Point is record
+      X, Y : Coordinate;
+   end record;
+   type Point_List is array (Positive range <>) of Point;
+
+   function Acceptable (Position : Point) return Boolean is
+      Squared_Sum : Natural := Position.X ** 2 + Position.Y ** 2;
+   begin
+      return 10 ** 2 <= Squared_Sum and Squared_Sum <= 15 ** 2;
+   end Acceptable;
+
+   -- first algorithm
+   function Generate_Random_Points
+     (Count : Positive := 100)
+      return  Point_List
+   is
+      package RNG is new Ada.Numerics.Discrete_Random (Coordinate);
+      Generator  : RNG.Generator;
+      Next_Point : Point;
+      Result     : Point_List (1 .. Count);
+   begin
+      RNG.Reset (Generator);
+      for N in Result'Range loop
+         loop
+            Next_Point.X := RNG.Random (Generator);
+            Next_Point.Y := RNG.Random (Generator);
+            exit when Acceptable (Next_Point);
+         end loop;
+         Result (N) := Next_Point;
+      end loop;
+      return Result;
+   end Generate_Random_Points;
+
+   -- second algorithm
+   function Choose_Precalculated
+     (Count : Positive := 100)
+      return  Point_List
+   is
+      subtype Possible_Points is Positive range 1 .. 404;
+      package RNG is new Ada.Numerics.Discrete_Random (Possible_Points);
+      Generator  : RNG.Generator;
+      Point_Pool : Point_List (Possible_Points);
+      Next_Point : Point;
+      Next_Index : Possible_Points := 1;
+      Result     : Point_List (1 .. Count);
+   begin
+      -- precalculate
+      Precalculate : for X in Coordinate'Range loop
+         Next_Point.X := X;
+         for Y in Coordinate'Range loop
+            Next_Point.Y := Y;
+            if Acceptable (Next_Point) then
+               Point_Pool (Next_Index) := Next_Point;
+               exit Precalculate when Next_Index = Possible_Points'Last;
+               Next_Index := Next_Index + 1;
+            end if;
+         end loop;
+      end loop Precalculate;
+      -- choose
+      RNG.Reset (Generator);
+      for N in Result'Range loop
+         Result (N) := Point_Pool (RNG.Random (Generator));
+      end loop;
+      return Result;
+   end Choose_Precalculated;
+
+   procedure Print_Points (Points : Point_List) is
+      Output_String : array (Coordinate, Coordinate) of Character :=
+        (others => (others => ' '));
+   begin
+      for N in Points'Range loop
+         Output_String (Points (N).X, Points (N).Y) := '*';
+      end loop;
+      for Line in Output_String'Range (2) loop
+         for Column in Output_String'Range (1) loop
+            Ada.Text_IO.Put (Output_String (Column, Line));
+         end loop;
+         Ada.Text_IO.New_Line;
+      end loop;
+   end Print_Points;
+
+   My_Circle_Randomly      : Point_List := Generate_Random_Points;
+   My_Circle_Precalculated : Point_List := Choose_Precalculated;
+begin
+   Ada.Text_IO.Put_Line ("Randomly generated:");
+   Print_Points (My_Circle_Randomly);
+   Ada.Text_IO.Put_Line ("Chosen from precalculated:");
+   Print_Points (My_Circle_Precalculated);
+end Circle;
diff --git a/Task/Constrained-random-points-on-a-circle/AutoHotkey/constrained-random-points-on-a-circle.ahk b/Task/Constrained-random-points-on-a-circle/AutoHotkey/constrained-random-points-on-a-circle.ahk
new file mode 100644
index 0000000000..c995bef641
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/AutoHotkey/constrained-random-points-on-a-circle.ahk
@@ -0,0 +1,18 @@
+z=100 ; x = x-coord; y = y-coord; z = count; pBitmap = a pointer to the image; f = filename
+
+pToken	:= Gdip_Startup()
+pBitmap := Gdip_CreateBitmap(31, 32)
+
+While z
+{
+	Random, x, -20, 20
+	Random, y, -20,20
+	If ( t := sqrt(x**2 + y**2) ) >= 10 && t <= 15
+		Gdip_SetPixel(pBitmap, x+15, y+16, 255<<24), z--
+}
+
+Gdip_SaveBitmapToFile(pBitmap, f := A_ScriptDir "\ahk_fuzzycircle.png")
+run % f
+
+Gdip_DisposeImage(pBitmap)
+Gdip_Shutdown(pToken)
diff --git a/Task/Constrained-random-points-on-a-circle/BBC-BASIC/constrained-random-points-on-a-circle.bbc b/Task/Constrained-random-points-on-a-circle/BBC-BASIC/constrained-random-points-on-a-circle.bbc
new file mode 100644
index 0000000000..9196a187a8
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/BBC-BASIC/constrained-random-points-on-a-circle.bbc
@@ -0,0 +1,8 @@
+      MODE 8
+      ORIGIN 640, 512
+      FOR i% = 1 TO 1000
+        x% = RND(31)-16
+        y% = RND(31)-16
+        r = SQR(x%^2 + y%^2)
+        IF r >= 10 IF r <= 15 PLOT x%*2, y%*2
+      NEXT
diff --git a/Task/Constrained-random-points-on-a-circle/C/constrained-random-points-on-a-circle-1.c b/Task/Constrained-random-points-on-a-circle/C/constrained-random-points-on-a-circle-1.c
new file mode 100644
index 0000000000..33816f27aa
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/C/constrained-random-points-on-a-circle-1.c
@@ -0,0 +1,35 @@
+#include 
+#include 
+
+inline
+int randn(int m)
+{
+	int rand_max = RAND_MAX - (RAND_MAX % m);
+	int r;
+	while ((r = rand()) > rand_max);
+	return r / (rand_max / m);
+}
+
+int main()
+{
+	int i, x, y, r2;
+	unsigned long buf[31] = {0}; /* could just use 2d array */
+
+	for (i = 0; i < 100; ) {
+		x = randn(31) - 15;
+		y = randn(31) - 15;
+		r2 = x * x + y * y;
+		if (r2 >= 100 && r2 <= 225) {
+			buf[15 + y] |= 1 << (x + 15);
+			i++;
+		}
+	}
+
+	for (y = 0; y < 31; y++) {
+		for (x = 0; x < 31; x++)
+			printf((buf[y] & 1 << x) ? ". " : "  ");
+		printf("\n");
+	}
+
+	return 0;
+}
diff --git a/Task/Constrained-random-points-on-a-circle/C/constrained-random-points-on-a-circle-2.c b/Task/Constrained-random-points-on-a-circle/C/constrained-random-points-on-a-circle-2.c
new file mode 100644
index 0000000000..1ef6c2a777
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/C/constrained-random-points-on-a-circle-2.c
@@ -0,0 +1,30 @@
+                            .   .     . .
+                    .           .         .
+                  .           .           . .
+                              .             .     .
+                    .       .       .     . .
+          .                                 .       .
+          .       .                               .
+          .                                     .
+                                                . .
+                                                  .   .
+      . .
+        . .                                       . .
+  .       .                                               .
+
+                                                    .
+  .
+
+      . .                                                 .
+    .                                                 . .
+      .   . .
+      .   .                                   .         .
+        .                                       . . .   .
+          .       .
+      . .     .                                 .
+          .   .     .   .   .         .           .
+                    .       . .         .
+              . . .   . . .       .
+                  . .     .               .
+                                        .
+                              .
diff --git a/Task/Constrained-random-points-on-a-circle/Clojure/constrained-random-points-on-a-circle.clj b/Task/Constrained-random-points-on-a-circle/Clojure/constrained-random-points-on-a-circle.clj
new file mode 100644
index 0000000000..8145624ccf
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Clojure/constrained-random-points-on-a-circle.clj
@@ -0,0 +1,19 @@
+(import '[java.awt Color Graphics Dimension]
+	'[javax.swing JFrame JPanel])
+
+(let [points (->> (for [x (range -15 16)
+			y (range -15 16)
+			:when (<= 10 (Math/sqrt (+ (* x x) (* y y))) 15)]
+		    [(+ x 15) (+ y 15)])
+		  shuffle
+		  (take 100 ,))]
+  (doto (JFrame.)
+    (.add (doto (proxy [JPanel] []
+		  (paint [^Graphics g]
+			 (doseq [[x y] points]
+			   (.fillRect g (* 10 x) (* 10 y) 10 10))))
+	    (.setPreferredSize (Dimension. 310 310))))
+    (.setResizable false)
+    (.setDefaultCloseOperation JFrame/DISPOSE_ON_CLOSE)
+    .pack
+    .show))
diff --git a/Task/Constrained-random-points-on-a-circle/CoffeeScript/constrained-random-points-on-a-circle-1.coffee b/Task/Constrained-random-points-on-a-circle/CoffeeScript/constrained-random-points-on-a-circle-1.coffee
new file mode 100644
index 0000000000..36be3cbb85
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/CoffeeScript/constrained-random-points-on-a-circle-1.coffee
@@ -0,0 +1,27 @@
+NUM_POINTS = 100
+MIN_R = 10
+MAX_R = 15
+
+random_circle_points = ->
+  rand_point = ->
+    Math.floor (Math.random() * (MAX_R * 2 + 1) - MAX_R)
+
+  points = {}
+  cnt = 0
+  while cnt < 100
+    x = rand_point()
+    y = rand_point()
+    continue unless MIN_R * MIN_R <= x*x + y*y <= MAX_R * MAX_R
+    points["#{x},#{y}"] = true
+    cnt += 1
+  points
+
+plot = (points) ->
+  range = [-1 * MAX_R .. MAX_R]
+  for y in range
+    s = ''
+    for x in range
+      s += if points["#{x},#{y}"] then '*' else ' '
+    console.log s
+
+plot random_circle_points()
diff --git a/Task/Constrained-random-points-on-a-circle/CoffeeScript/constrained-random-points-on-a-circle-2.coffee b/Task/Constrained-random-points-on-a-circle/CoffeeScript/constrained-random-points-on-a-circle-2.coffee
new file mode 100644
index 0000000000..d136ae9cc9
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/CoffeeScript/constrained-random-points-on-a-circle-2.coffee
@@ -0,0 +1,30 @@
+> coffee foo.coffee
+
+          **    *
+         * ** *     *
+          *  * *      *
+     *     **           *
+      *  *      *       *
+    *               *
+                      *
+    *                    *
+  ***
+     **                 **** *
+  * *
+     *                      *
+  **
+                          *
+
+    *                     **
+ *  *                    *
+   **
+   *                      * **
+     *                     *
+  *                         *
+                       *    *
+     *  *
+                       ***
+      *** * *     *     * *
+     ***           *
+      * *       * *  *
+               * *   *
diff --git a/Task/Constrained-random-points-on-a-circle/Common-Lisp/constrained-random-points-on-a-circle.lisp b/Task/Constrained-random-points-on-a-circle/Common-Lisp/constrained-random-points-on-a-circle.lisp
new file mode 100644
index 0000000000..dce971193a
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Common-Lisp/constrained-random-points-on-a-circle.lisp
@@ -0,0 +1,9 @@
+(flet ((good-p (x y) (<= 100 (+ (* x x) (* y y)) 255)))
+  (loop with x with y with cnt = 0
+	with scr = (loop repeat 31 collect (loop repeat 31 collect "  "))
+	while (< cnt 100)
+	do (when (good-p (- (setf x (random 31)) 15)
+			 (- (setf y (random 31)) 15))
+	     (setf (elt (elt scr y) x) "@ ")
+	     (incf cnt))
+	finally (mapc #'(lambda (row) (format t "~{~a~^~}~%" row)) scr)))
diff --git a/Task/Constrained-random-points-on-a-circle/D/constrained-random-points-on-a-circle.d b/Task/Constrained-random-points-on-a-circle/D/constrained-random-points-on-a-circle.d
new file mode 100644
index 0000000000..50040edc9a
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/D/constrained-random-points-on-a-circle.d
@@ -0,0 +1,16 @@
+import std.stdio, std.random, std.math, std.complex;
+
+void main() {
+    char[31][31] table = ' ';
+
+    foreach (i; 0 .. 100) {
+        int x, y;
+        do {
+            x = uniform(-15, 16);
+            y = uniform(-15, 16);
+        } while(abs(12.5 - complex(x, y).abs()) > 2.5);
+        table[x + 15][y + 15] = '*';
+    }
+
+    writefln("%-(%s\n%)", table);
+}
diff --git a/Task/Constrained-random-points-on-a-circle/Euphoria/constrained-random-points-on-a-circle-1.euphoria b/Task/Constrained-random-points-on-a-circle/Euphoria/constrained-random-points-on-a-circle-1.euphoria
new file mode 100644
index 0000000000..f1c9686f74
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Euphoria/constrained-random-points-on-a-circle-1.euphoria
@@ -0,0 +1,65 @@
+include std/console.e
+
+sequence validpoints = {}
+sequence discardedpoints = {}
+sequence rand100points = {}
+atom coordresult
+integer randindex
+
+--scan for all possible values. store discarded ones in another sequence, for extra reference.
+for y = -15 to 15 do
+    for x = -15 to 15 do
+
+        coordresult = sqrt( x * x + y * y )
+
+        if coordresult >= 10 and coordresult <= 15 then --if it would fall in the ring area
+            validpoints &= {{x, y, coordresult}} --concatenate (add to the end) the coordinate pair x, y and the
+            -- result into a subsequence of sequence validpoints
+            else
+                discardedpoints &= {{x, y, coordresult}} --else put it in the discarded sequence
+        end if
+
+    end for
+end for
+
+for i = 1 to 100 label "oneofhundred" do --make 100 random coordinate pairs
+    randindex = rand(length(validpoints) ) --random value from 1 to the number of 3 value subsequences in validpoints (the data)
+
+    if length(rand100points) = 0 then --if rand100points sequence is empty, add the first subsequence to it.
+        rand100points &= {validpoints[randindex]}
+
+        else --if it isn't empty, then..
+            for j = 1 to length(rand100points) do --loop through each "data chunk" in rand100points
+
+                if equal(validpoints[randindex], rand100points[j]) = 1 then --if any are the same as the randomly chosen chunk in
+                    retry "oneofhundred" -- validpoints, then retry from one line below the "oneofhundred" loop without incrementing i.
+                end if --the continue keyword would increment i instead.
+
+            end for
+
+            rand100points &= {validpoints[randindex]} --length of rand100points isnt 0 and no data chunks match ones that the program
+            --already picked before, so add this subsequence chunk to rand100points.
+    end if
+
+end for
+
+for i = 1 to 32 do --32 lines
+    printf(1,"\n")
+    for j = 1 to 32 label "xscan" do --32 characters on each line
+
+        for k = 1 to length(rand100points) do --for every subsequence in this
+            if rand100points[k][1]+16 = j and rand100points[k][2]+16 = i then --if the x and y coordinates in the picked points
+                printf(1, 178) --(adjusted to minimum of 1,1) are at the same place as in the console output grid
+                continue "xscan" --print a funny character and continue to the next "xscan"
+            end if
+        end for
+
+        printf(1, 176) --if no picked points were there, print another funny character to represent a blank space
+
+    end for
+end for
+
+printf(1, "\nNumber of valid coordinate pairs %d :", length(validpoints) )
+printf(1, "\nNumber of discarded coordinate pairs : %d", length(discardedpoints) )
+printf(1, "\nNumber of randomly picked coordinate pairs : %d\n", length(rand100points) )
+any_key()
diff --git a/Task/Constrained-random-points-on-a-circle/Euphoria/constrained-random-points-on-a-circle-2.euphoria b/Task/Constrained-random-points-on-a-circle/Euphoria/constrained-random-points-on-a-circle-2.euphoria
new file mode 100644
index 0000000000..3ca9068588
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Euphoria/constrained-random-points-on-a-circle-2.euphoria
@@ -0,0 +1,19 @@
+for i = 1 to length(validpoints) do --simple each pixel output to screen surface
+    dummy=pixelColor(surface,validpoints[i][1]+18,validpoints[i][2]+18,#AA0202FF) --i is index number of each subsequence 'chunk'.
+    --index 1 is x, index 2 is y, inside that chunk.
+end for
+
+for i = 1 to length(discardedpoints) do
+    dummy=pixelColor(surface,discardedpoints[i][1]+18,discardedpoints[i][2]+52,#0202AAFF)
+end for
+
+for i = 1 to length(rand100points) do
+    dummy=pixelColor(surface,rand100points[i][1]+55,rand100points[i][2]+52,#02AA02FF)
+end for
+
+dummy=boxColor(surface,0,71,395,111,#232323FF) --background box
+dummy=stringColor(surface,0,73,sprintf("Number of valid coordinate pairs %d :", length(validpoints) ),#AA0202FF)
+
+dummy=stringColor(surface,0,83,sprintf("Number of discarded coordinate pairs : %d", length(discardedpoints) ),#0202AAFF)
+
+dummy=stringColor(surface,0,93,sprintf("Number of randomly picked coordinate pairs : %d", length(rand100points) ),#02AA02FF)
diff --git a/Task/Constrained-random-points-on-a-circle/Fortran/constrained-random-points-on-a-circle.f b/Task/Constrained-random-points-on-a-circle/Fortran/constrained-random-points-on-a-circle.f
new file mode 100644
index 0000000000..51302521b8
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Fortran/constrained-random-points-on-a-circle.f
@@ -0,0 +1,76 @@
+program Constrained_Points
+  implicit none
+
+  integer, parameter :: samples = 100
+  integer :: i, j, n, randpoint
+  real :: r
+
+  type points
+    integer :: x, y
+  end type
+
+  type(points) :: set(500), temp
+
+! Create set of valid points
+  n = 0
+  do i = -15, 15
+    do j = -15, 15
+      if(sqrt(real(i*i + j*j)) >= 10.0 .and. sqrt(real(i*i + j*j)) <= 15.0) then
+        n = n + 1
+        set(n)%x = i
+        set(n)%y = j
+      end if
+    end do
+  end do
+
+! create 100 random points
+! Choose a random number between 1 and n inclusive and swap point at this index with point at index 1
+! Choose a random number between 2 and n inclusive and swap point at this index with point at index 2
+! Continue in this fashion until 100 points have been selected
+  call random_seed
+  do i = 1, samples
+    call random_number(r)
+    randpoint = r * (n + 1 - i) + i
+    temp = set(i)
+    set(i) = set(randpoint)
+    set(randpoint) = temp
+  end do
+
+! In order to facilitate printing sort random points into ascending order
+! sort x in ascending order
+  do i = 2, samples
+     j = i - 1
+     temp = set(i)
+        do while (j>=1 .and. set(j)%x > temp%x)
+           set(j+1) = set(j)
+           j = j - 1
+        end do
+     set(j+1) = temp
+  end do
+
+! sort y in ascending order for same x
+  do i = 2, samples
+     j = i - 1
+     temp = set(i)
+        do while (j>=1 .and. set(j)%x == temp%x .and. set(j)%y > temp%y)
+           set(j+1) = set(j)
+           j = j - 1
+        end do
+     set(j+1) = temp
+  end do
+
+! print circle
+  write(*,"(a,a)", advance="no") repeat(" ", set(1)%y+15), "*"
+  do i = 2, samples
+    if(set(i)%x == set(i-1)%x) then
+      write(*,"(a,a)", advance="no") repeat(" ", set(i)%y - set(i-1)%y-1), "*"
+    else
+      n = set(i)%x - set(i-1)%x
+      do j = 1, n
+        write(*,*)
+      end do
+      write(*,"(a,a)", advance="no") repeat(" ", set(i)%y+15), "*"
+    end if
+  end do
+
+end program
diff --git a/Task/Constrained-random-points-on-a-circle/Go/constrained-random-points-on-a-circle-1.go b/Task/Constrained-random-points-on-a-circle/Go/constrained-random-points-on-a-circle-1.go
new file mode 100644
index 0000000000..594a401fae
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Go/constrained-random-points-on-a-circle-1.go
@@ -0,0 +1,34 @@
+package main
+
+import (
+    "bytes"
+    "fmt"
+    "math/rand"
+    "time"
+)
+
+type pt struct {
+    x, y int
+}
+
+func main() {
+    rand.Seed(time.Now().UnixNano())
+    // generate random points, accumulate 100 distinct points meeting condition
+    m := make(map[int]pt) // key is buffer index
+    for len(m) < 100 {
+        p := pt{rand.Intn(31) - 15, rand.Intn(31) - 15}
+        rs := p.x*p.x + p.y*p.y
+        if 100 <= rs && rs <= 225 {
+            m[(p.x+15)*2+(p.y+15)*31*2] = p
+        }
+    }
+    // plot to buffer
+    b := bytes.Repeat([]byte{' '}, 31*31*2)
+    for i := range m {
+        b[i] = '*'
+    }
+    // print buffer to screen
+    for i := 0; i < 31; i++ {
+        fmt.Println(string(b[i*31*2 : (i+1)*31*2]))
+    }
+}
diff --git a/Task/Constrained-random-points-on-a-circle/Go/constrained-random-points-on-a-circle-2.go b/Task/Constrained-random-points-on-a-circle/Go/constrained-random-points-on-a-circle-2.go
new file mode 100644
index 0000000000..cb7d7fd66d
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Go/constrained-random-points-on-a-circle-2.go
@@ -0,0 +1,39 @@
+package main
+
+import (
+    "bytes"
+    "fmt"
+    "math/rand"
+)
+
+type pt struct {
+    x, y int
+}
+
+func main() {
+    // generate possible points
+    all := make([]pt, 0, 404)
+    for x := -15; x <= 15; x++ {
+        for y := -15; y <= 15; y++ {
+            rs := x*x + y*y
+            if 100 <= rs && rs <= 225 {
+                all = append(all, pt{x, y})
+            }
+        }
+    }
+    if len(all) != 404 {
+        panic(len(all))
+    }
+    // randomly order
+    rp := rand.Perm(404)
+    // plot 100 of them to a buffer
+    b := bytes.Repeat([]byte{' '}, 31*31*2)
+    for i := 0; i < 100; i++ {
+        p := all[rp[i]]
+        b[(p.x+15)*2+(p.y+15)*31*2] = '*'
+    }
+    // print buffer to screen
+    for i := 0; i < 31; i++ {
+        fmt.Println(string(b[i*31*2 : (i+1)*31*2]))
+    }
+}
diff --git a/Task/Constrained-random-points-on-a-circle/Haskell/constrained-random-points-on-a-circle.hs b/Task/Constrained-random-points-on-a-circle/Haskell/constrained-random-points-on-a-circle.hs
new file mode 100644
index 0000000000..2142f58318
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Haskell/constrained-random-points-on-a-circle.hs
@@ -0,0 +1,15 @@
+import Data.List
+import Control.Monad
+import Control.Arrow
+import Rosetta.Knuthshuffle
+
+task = do
+  let blanco = replicate (31*31) "  "
+      cs = sequence [[-15,-14..15],[-15,-14..15]] :: [[Int]]
+      constraint = uncurry(&&).((<= 15*15) &&& (10*10 <=)). sum. map (join (*))
+-- select and randomize all circle points
+  pts <- knuthShuffle $ filter constraint cs
+-- 'paint' first 100 randomized circle points on canvas
+  let canvas = foldl (\cs [x,y] -> replaceAt (31*(x+15)+y+15) "/ " cs ) blanco (take 100 pts)
+-- show canvas
+  mapM_ (putStrLn.concat). takeWhile(not.null). unfoldr (Just . splitAt 31) $ canvas
diff --git a/Task/Constrained-random-points-on-a-circle/Java/constrained-random-points-on-a-circle.java b/Task/Constrained-random-points-on-a-circle/Java/constrained-random-points-on-a-circle.java
new file mode 100644
index 0000000000..3109c74bb5
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Java/constrained-random-points-on-a-circle.java
@@ -0,0 +1,29 @@
+import java.util.Random;
+
+public class FuzzyCircle {
+	static final Random rnd = new Random();
+	public static void main(String[] args){
+		char[][] field = new char[31][31];
+		for(int i = 0; i < field.length; i++){
+			for(int j = 0; j < field[i].length; j++){
+				field[i][j] = ' ';
+			}
+		}
+		int pointsInDisc = 0;
+		while(pointsInDisc < 100){
+			int x = rnd.nextInt(31) - 15;
+			int y = rnd.nextInt(31) - 15;
+			double dist = Math.hypot(x, y);
+			if(dist >= 10 && dist <= 15 && field[x + 15][y + 15] == ' '){
+				field[x + 15][y + 15] = 'X';
+				pointsInDisc++;
+			}
+		}
+		for(char[] row:field){
+			for(char space:row){
+				System.out.print(space);
+			}
+			System.out.println();
+		}
+	}
+}
diff --git a/Task/Constrained-random-points-on-a-circle/JavaScript/constrained-random-points-on-a-circle.js b/Task/Constrained-random-points-on-a-circle/JavaScript/constrained-random-points-on-a-circle.js
new file mode 100644
index 0000000000..16df0ba9f8
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/JavaScript/constrained-random-points-on-a-circle.js
@@ -0,0 +1,46 @@
+Circle
+
+
+
diff --git a/Task/Constrained-random-points-on-a-circle/MATLAB/constrained-random-points-on-a-circle-1.m b/Task/Constrained-random-points-on-a-circle/MATLAB/constrained-random-points-on-a-circle-1.m
new file mode 100644
index 0000000000..13d1701a02
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/MATLAB/constrained-random-points-on-a-circle-1.m
@@ -0,0 +1,31 @@
+function [xCoordinates,yCoordinates] = randomDisc(numPoints)
+
+    xCoordinates = [];
+    yCoordinates = [];
+
+    %Helper function that samples a random integer from the uniform
+    %distribution between -15 and 15.
+    function nums = randInt(n)
+        nums = round((31*rand(n,1))-15.5);
+    end
+
+    n = numPoints;
+
+    while n > 0
+
+        x = randInt(n);
+        y = randInt(n);
+
+        norms = sqrt((x.^2) + (y.^2));
+        inBounds = find((10 <= norms) & (norms <= 15));
+
+        xCoordinates = [xCoordinates; x(inBounds)];
+        yCoordinates = [yCoordinates; y(inBounds)];
+
+        n = numPoints - numel(xCoordinates);
+    end
+
+    xCoordinates(numPoints+1:end) = [];
+    yCoordinates(numPoints+1:end) = [];
+
+end
diff --git a/Task/Constrained-random-points-on-a-circle/MATLAB/constrained-random-points-on-a-circle-2.m b/Task/Constrained-random-points-on-a-circle/MATLAB/constrained-random-points-on-a-circle-2.m
new file mode 100644
index 0000000000..0a9f234d5d
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/MATLAB/constrained-random-points-on-a-circle-2.m
@@ -0,0 +1,2 @@
+>> [x,y] = randomDisc(100);
+>> plot(x,y,'.')
diff --git a/Task/Constrained-random-points-on-a-circle/Perl/constrained-random-points-on-a-circle.pl b/Task/Constrained-random-points-on-a-circle/Perl/constrained-random-points-on-a-circle.pl
new file mode 100644
index 0000000000..582a32d38a
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Perl/constrained-random-points-on-a-circle.pl
@@ -0,0 +1,22 @@
+my @points;
+while (@points < 100) {
+        my ($x, $y) = (int(rand(31))-15, int(rand(31)) - 15);
+        my $r2 = $x*$x + $y*$y;
+        next if $r2 < 100 || $r2 > 225;
+        push @points, [$x, $y];
+}
+
+print << 'HEAD';
+%!PS-Adobe-3.0 EPSF-3.0
+%%BoundingBox 0 0 400 400
+200 200 translate 10 10 scale
+0 setlinewidth
+1 0 0 setrgbcolor
+0 0 10 0 360 arc stroke
+0 0 15 360 0 arcn stroke
+0 setgray
+/pt { .1 0 360 arc fill } def
+HEAD
+
+print "@$_ pt\n" for @points;
+print "%%EOF";
diff --git a/Task/Constrained-random-points-on-a-circle/PicoLisp/constrained-random-points-on-a-circle.l b/Task/Constrained-random-points-on-a-circle/PicoLisp/constrained-random-points-on-a-circle.l
new file mode 100644
index 0000000000..6751e749a9
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/PicoLisp/constrained-random-points-on-a-circle.l
@@ -0,0 +1,13 @@
+(let Area (make (do 31 (link (need 31 " "))))
+   (use (X Y)
+      (do 100
+         (until
+            (>=
+               15
+               (sqrt
+                  (+
+                     (* (setq X (rand -15 15)) X)
+                     (* (setq Y (rand -15 15)) Y) ) )
+               10 ) )
+         (set (nth Area (+ 16 X) (+ 16 Y)) "#") ) )
+   (mapc prinl Area) )
diff --git a/Task/Constrained-random-points-on-a-circle/Prolog/constrained-random-points-on-a-circle.pro b/Task/Constrained-random-points-on-a-circle/Prolog/constrained-random-points-on-a-circle.pro
new file mode 100644
index 0000000000..f75b7f522b
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Prolog/constrained-random-points-on-a-circle.pro
@@ -0,0 +1,36 @@
+:- use_module(library(clpfd)).
+
+circle :-
+	bagof([X,Y], init(X,Y), BL),
+	length(BL, N),
+	length(L, 100),
+	maplist(choose(BL, N), L),
+	draw_circle(L).
+
+
+% point selection
+choose(BL, N, V) :-
+	I is random(N),
+	nth0(I, BL, V).
+
+% to find all couples of numbers verifying
+% 100 <= x^2 + y^2 <= 225
+init(X1, Y1) :-
+	X in -15..15,
+	Y in -15..15,
+	X*X + Y*Y #>= 100,
+	X*X + Y*Y #=< 225,
+	label([X,Y]),
+	X1 is 10 * X + 200,
+	Y1 is 10 * Y + 200.
+
+
+draw_circle(L) :-
+	new(D, window('Circle')),
+	send(D, size,size(400,400)),
+	forall(member([X,Y], L),
+	       (   new(C, circle(4)),
+		   send(C, fill_pattern, colour(@default, 0, 0, 0)),
+		   send(C, center(point(X,Y))),
+		   send(D, display, C))),
+	send(D, open).
diff --git a/Task/Constrained-random-points-on-a-circle/Python/constrained-random-points-on-a-circle-1.py b/Task/Constrained-random-points-on-a-circle/Python/constrained-random-points-on-a-circle-1.py
new file mode 100644
index 0000000000..453f59f5e6
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Python/constrained-random-points-on-a-circle-1.py
@@ -0,0 +1,44 @@
+>>> from collections import defaultdict
+>>> from random import choice
+>>> world = defaultdict(int)
+>>> possiblepoints = [(x,y) for x in range(-15,16)
+		  for y in range(-15,16)
+		  if 10 <= abs(x+y*1j) <= 15]
+>>> for i in range(100): world[choice(possiblepoints)] += 1
+
+>>> for x in range(-15,16):
+	print(''.join(str(min([9, world[(x,y)]])) if world[(x,y)] else ' '
+			  for y in range(-15,16)))
+
+	
+
+             1     1
+          1 1
+      11 1     1  1     1
+     111  1     1211
+      1   2    1 1    11
+      1  11         21
+     1   1            11  1
+   1  2                1 1
+
+ 1  2
+   1 1                      1
+   1 1
+   2                      11
+  1                         1
+                         1
+
+
+  1                          1
+                         1
+                         2
+                            1
+     1                  1 1
+      1                2   1
+   1   3            11  2
+    11   1    1      1   2
+            1   1    2
+        1  1
+         1      1     1
+          2 2   1
+               1
diff --git a/Task/Constrained-random-points-on-a-circle/Python/constrained-random-points-on-a-circle-2.py b/Task/Constrained-random-points-on-a-circle/Python/constrained-random-points-on-a-circle-2.py
new file mode 100644
index 0000000000..73ae447e67
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Python/constrained-random-points-on-a-circle-2.py
@@ -0,0 +1,38 @@
+>>> for i in range(1000): world[choice(possiblepoints)] += 1
+
+>>> for x in range(-15,16):
+	print(''.join(str(min([9, world[(x,y)]])) if world[(x,y)] else ' '
+			  for y in range(-15,16)))
+
+	
+               2
+          41341421333
+        5133333131253 1
+      5231514 14214721 24
+     326 21222143234122322
+    54235153132123344125 22
+   32331432         2422 33
+   5453135           4144344
+  132595               323123
+  4 6353               432224
+ 5 4323                 3 5313
+ 23214                   41433
+ 42454                   33342
+ 332 4                   34314
+ 142 1                   35 53
+124211                   53131
+ 22221                   152 4
+ 22213                   34562
+ 654 4                   4 212
+ 24354                   52232
+ 544222                 283323
+  411123               453325
+  251321               124332
+   2124134           2443226
+   2 113315         64324334
+    2412452 324 32121132363
+      4222434324635 5433
+      3113333123432112633
+        2131181233  424
+          47414232164
+               4
diff --git a/Task/Constrained-random-points-on-a-circle/R/constrained-random-points-on-a-circle.r b/Task/Constrained-random-points-on-a-circle/R/constrained-random-points-on-a-circle.r
new file mode 100644
index 0000000000..7b0b2d00a4
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/R/constrained-random-points-on-a-circle.r
@@ -0,0 +1,18 @@
+RMin <- 10
+RMax <- 15
+NPts <- 100
+
+# instead of a for loop, we generate what should be enough points
+# also take care to have enough range to avoid rounding inaccuracies
+nBlock <- NPts * ((RMax/RMin) ^ 2)
+nValid <- 0
+while (nValid < NPts) {
+	X <- round(runif(nBlock, -RMax - 1, RMax + 1))
+	Y <- round(runif(nBlock, -RMax - 1, RMax + 1))
+	R <-  sqrt(X^2 + Y^2)
+	Valid <- ( (R >= RMin) & (R <= RMax) )
+	nValid <- sum(Valid)
+	nBlock <- 2 * nBlock
+}
+plot(X[Valid][1:NPts],Y[Valid][1:NPts], pch=19, cex=0.25, col="blue",
+	xlab="x",ylab="y",main="Fuzzy circle", xlim=c(-RMax,RMax), ylim=c(-RMax,RMax) )
diff --git a/Task/Constrained-random-points-on-a-circle/REXX/constrained-random-points-on-a-circle-1.rexx b/Task/Constrained-random-points-on-a-circle/REXX/constrained-random-points-on-a-circle-1.rexx
new file mode 100644
index 0000000000..55d127d94d
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/REXX/constrained-random-points-on-a-circle-1.rexx
@@ -0,0 +1,25 @@
+/*REXX program gens 100 random points in an annulus: 10 ≤ √(x²≤y²) ≤ 15 */
+arg points low high .; $=              /*allow args from command line.  */
+if points=='' then points=100
+if    low=='' then    low=10;      low2= low**2
+if   high=='' then   high=15;     high2=high**2
+
+   do x=-high;      x2=x*x             /*gen all possible annulus points*/
+   if x<0 & x2>high2 then iterate
+   if x>0 & x2>high2 then leave
+         do y=-high;    y2=y*y;    s=x2+y2
+         if (y<0 & s>high2) | s0 & s>high2           then leave
+         $=$ x','y
+         end   /*y*/
+   end         /*x*/
+
+field.=;    plotChar='O';    minY=high2;    maxY=-minY;    ap=words($)
+
+   do j=1 for points                   /*"draw" the x,y points [char O].*/
+   parse value word($,random(1,ap)) with x ',' y    /*pick random point.*/
+   field.y=overlay(plotChar, field.y, x+high+1)     /*"draw: the point. */
+   minY=min(minY,y);    maxY=max(maxY,y)            /*plot restricting. */
+   end   /*j*/
+
+ do y=minY to maxY; if field.y=='' then iterate; say field.y; end /*plot*/
diff --git a/Task/Constrained-random-points-on-a-circle/REXX/constrained-random-points-on-a-circle-2.rexx b/Task/Constrained-random-points-on-a-circle/REXX/constrained-random-points-on-a-circle-2.rexx
new file mode 100644
index 0000000000..55d127d94d
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/REXX/constrained-random-points-on-a-circle-2.rexx
@@ -0,0 +1,25 @@
+/*REXX program gens 100 random points in an annulus: 10 ≤ √(x²≤y²) ≤ 15 */
+arg points low high .; $=              /*allow args from command line.  */
+if points=='' then points=100
+if    low=='' then    low=10;      low2= low**2
+if   high=='' then   high=15;     high2=high**2
+
+   do x=-high;      x2=x*x             /*gen all possible annulus points*/
+   if x<0 & x2>high2 then iterate
+   if x>0 & x2>high2 then leave
+         do y=-high;    y2=y*y;    s=x2+y2
+         if (y<0 & s>high2) | s0 & s>high2           then leave
+         $=$ x','y
+         end   /*y*/
+   end         /*x*/
+
+field.=;    plotChar='O';    minY=high2;    maxY=-minY;    ap=words($)
+
+   do j=1 for points                   /*"draw" the x,y points [char O].*/
+   parse value word($,random(1,ap)) with x ',' y    /*pick random point.*/
+   field.y=overlay(plotChar, field.y, x+high+1)     /*"draw: the point. */
+   minY=min(minY,y);    maxY=max(maxY,y)            /*plot restricting. */
+   end   /*j*/
+
+ do y=minY to maxY; if field.y=='' then iterate; say field.y; end /*plot*/
diff --git a/Task/Constrained-random-points-on-a-circle/Ruby/constrained-random-points-on-a-circle.rb b/Task/Constrained-random-points-on-a-circle/Ruby/constrained-random-points-on-a-circle.rb
new file mode 100644
index 0000000000..b418a9b773
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Ruby/constrained-random-points-on-a-circle.rb
@@ -0,0 +1,21 @@
+points = (1...100).map {
+    # choose a random radius and angle
+    angle = rand * 2.0 * Math::PI
+    rad   = rand * 5.0 + 10.0
+    # convert back from polar to cartesian coordinates
+    [rad * Math::cos(angle), rad * Math::sin(angle)].map(&:round)
+  }
+
+(-15..15).each do |row|
+  puts((-15..15).map { |col| points.include?([row, col]) ? "X" : " " }.join)
+end
+
+load 'raster_graphics.rb'
+
+pixmap = Pixmap.new(321,321)
+pixmap.draw_circle(Pixel.new(160,160),90,RGBColour::BLACK)
+pixmap.draw_circle(Pixel.new(160,160),160,RGBColour::BLACK)
+points.each {|(x,y)| pixmap[10*(x+16),10*(y+16)] = RGBColour::BLACK}
+pngfile = __FILE__
+pngfile[/\.rb/] = ".png"
+pixmap.save_as_png(pngfile)
diff --git a/Task/Constrained-random-points-on-a-circle/Tcl/constrained-random-points-on-a-circle.tcl b/Task/Constrained-random-points-on-a-circle/Tcl/constrained-random-points-on-a-circle.tcl
new file mode 100644
index 0000000000..3ceb88b839
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/Tcl/constrained-random-points-on-a-circle.tcl
@@ -0,0 +1,34 @@
+package require Tcl 8.5
+
+# Generate random point at specified distance from the centre
+proc getPoint {range from to} {
+    set r2 [expr {$range / 2}]
+    set f2 [expr {$from ** 2}]
+    set t2 [expr {$to ** 2}]
+    while 1 {
+	set x [expr {int($range * rand())}]
+	set y [expr {int($range * rand())}]
+	set d2 [expr {($x-$r2)**2 + ($y-$r2)**2}]
+	if {$d2 >= $f2 && $d2 <= $t2} {
+	    return [list $y $x]
+	}
+    }
+}
+
+# Make somewhere to store the counters
+set ary [lrepeat 31 [lrepeat 31 0]]
+
+# Generate 100 random points
+for {set i 0} {$i < 100} {incr i} {
+    set location [getPoint 31 10 15]
+    # Increment the counter for the point
+    lset ary $location [expr {1 + [lindex $ary $location]}]
+}
+
+# Simple renderer
+foreach line $ary {
+    foreach c $line {
+	puts -nonewline [expr {$c == 0 ? " " : $c > 9 ? "X" : $c}]
+    }
+    puts ""
+}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/0DESCRIPTION b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/0DESCRIPTION
new file mode 100644
index 0000000000..283c548e33
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/0DESCRIPTION
@@ -0,0 +1,34 @@
+To understand this task in context please see [[Continued fraction arithmetic]]
+
+The purpose of this task is to write a function \mathit{r2cf}(\mathrm{int} N_1, \mathrm{int} N_2), or \mathit{r2cf}(\mathrm{Fraction} N), which will output a continued fraction assuming:
+:N_1 is the numerator
+:N_2 is the denominator
+
+The function should output its results one digit at a time each time it is called, in a manner sometimes described as lazy evaluation.
+
+To achieve this it must determine: the integer part; and remainder part, of N_1 divided by N_2. It then sets N_1 to N_2 and N_2 to the determined remainder part. It then outputs the determined integer part. It does this until \mathrm{abs}(N_2) is zero.
+
+Demonstrate the function by outputing the continued fraction for:
+: 1/2
+: 3
+: 23/8
+: 13/11
+: 22/7
+: -151/77
+\sqrt 2 should approach [1; 2, 2, 2, 2, \ldots] try ever closer rational approximations until bordom gets the better of you:
+: 14142,10000
+: 141421,100000
+: 1414214,1000000
+: 14142136,10000000
+
+Try :
+: 31,10
+: 314,100
+: 3142,1000
+: 31428,10000
+: 314285,100000
+: 3142857,1000000
+: 31428571,10000000
+: 314285714,100000000
+
+Observe how this rational number behaves differently to \sqrt 2 and convince yourself that, in the same way as 3.7 may be represented as 3.70 when an extra decimal place is required, [3;7] may be represented as [3;7,\infty] when an extra term is required.
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-1.cpp b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-1.cpp
new file mode 100644
index 0000000000..3a849b0678
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-1.cpp
@@ -0,0 +1,32 @@
+#include 
+/* Interface for all Continued Fractions
+   Nigel Galloway, February 9th., 2013.
+*/
+class ContinuedFraction {
+	public:
+	virtual const int nextTerm(){};
+	virtual const bool moreTerms(){};
+};
+/* Create a continued fraction from a rational number
+   Nigel Galloway, February 9th., 2013.
+*/
+class r2cf : public ContinuedFraction {
+	private: int n1, n2;
+	public:
+	r2cf(const int numerator, const int denominator): n1(numerator), n2(denominator){}
+	const int nextTerm() {
+		const int thisTerm = n1/n2;
+		const int t2 = n2; n2 = n1 - thisTerm * n2; n1 = t2;
+		return thisTerm;
+	}
+	const bool moreTerms() {return fabs(n2) > 0;}
+};
+/* Generate a continued fraction for sqrt of 2
+   Nigel Galloway, February 9th., 2013.
+*/
+class SQRT2 : public ContinuedFraction {
+	private: bool first=true;
+	public:
+	const int nextTerm() {if (first) {first = false; return 1;} else return 2;}
+	const bool moreTerms() {return true;}
+};
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-2.cpp b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-2.cpp
new file mode 100644
index 0000000000..2e539d9dbf
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-2.cpp
@@ -0,0 +1,15 @@
+int main() {
+	for(r2cf n(1,2); n.moreTerms(); std::cout << n.nextTerm() << " ");
+	std::cout << std::endl;
+	for(r2cf n(3,1); n.moreTerms(); std::cout << n.nextTerm() << " ");
+	std::cout << std::endl;
+	for(r2cf n(23,8); n.moreTerms(); std::cout << n.nextTerm() << " ");
+	std::cout << std::endl;
+	for(r2cf n(13,11); n.moreTerms(); std::cout << n.nextTerm() << " ");
+	std::cout << std::endl;
+	for(r2cf n(22,7); n.moreTerms(); std::cout << n.nextTerm() << " ");
+	std::cout << std::endl;
+	for(r2cf cf(-151,77); cf.moreTerms(); std::cout << cf.nextTerm() << " ");
+	std::cout << std::endl;
+	return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-3.cpp b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-3.cpp
new file mode 100644
index 0000000000..f0a516a0ce
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-3.cpp
@@ -0,0 +1,10 @@
+int main() {
+	int i = 0;
+	for(SQRT2 n; i++ < 20; std::cout << n.nextTerm() << " ");
+	std::cout << std::endl;
+	for(r2cf n(14142,10000); n.moreTerms(); std::cout << n.nextTerm() << " ");
+	std::cout << std::endl;
+	for(r2cf n(14142136,10000000); n.moreTerms(); std::cout << n.nextTerm() << " ");
+	std::cout << std::endl;
+	return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-4.cpp b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-4.cpp
new file mode 100644
index 0000000000..64a1df68f2
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/C++/continued-fraction-arithmetic-construct-from-rational-number-4.cpp
@@ -0,0 +1,19 @@
+int main() {
+  for(r2cf n(31,10); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf n(314,100); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf n(3142,1000); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf n(31428,10000); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf n(314285,100000); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf n(3142857,1000000); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf n(31428571,10000000); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf n(314285714,100000000); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Haskell/continued-fraction-arithmetic-construct-from-rational-number.hs b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Haskell/continued-fraction-arithmetic-construct-from-rational-number.hs
new file mode 100644
index 0000000000..0a0dfb82d1
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Haskell/continued-fraction-arithmetic-construct-from-rational-number.hs
@@ -0,0 +1,11 @@
+import Data.Ratio ((%))
+
+real2cf :: (RealFrac a, Integral b) => a -> [b]
+real2cf x =
+  i : if f == 0 then [] else real2cf (1/f)
+  where (i, f) = properFraction x
+
+main :: IO ()
+main = do
+  print $ real2cf (13 % 11) -- => [1,5,2]
+  print $ take 20 $ real2cf (sqrt 2) -- => [1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Python/continued-fraction-arithmetic-construct-from-rational-number-1.py b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Python/continued-fraction-arithmetic-construct-from-rational-number-1.py
new file mode 100644
index 0000000000..0c1abc993f
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Python/continued-fraction-arithmetic-construct-from-rational-number-1.py
@@ -0,0 +1,14 @@
+def r2cf(n1,n2):
+  while n2:
+    n1, (t1, n2) = n2, divmod(n1, n2)
+    yield t1
+
+print(list(r2cf(1,2)))    # => [0, 2]
+print(list(r2cf(3,1)))    # => [3]
+print(list(r2cf(23,8)))    # => [2, 1, 7]
+print(list(r2cf(13,11)))    # => [1, 5, 2]
+print(list(r2cf(22,7)))    # => [3, 7]
+print(list(r2cf(14142,10000)))    # => [1, 2, 2, 2, 2, 2, 1, 1, 29]
+print(list(r2cf(141421,100000)))    # => [1, 2, 2, 2, 2, 2, 2, 3, 1, 1, 3, 1, 7, 2]
+print(list(r2cf(1414214,1000000)))    # => [1, 2, 2, 2, 2, 2, 2, 2, 3, 6, 1, 2, 1, 12]
+print(list(r2cf(14142136,10000000)))    # => [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 1, 2, 4, 1, 1, 2]
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Python/continued-fraction-arithmetic-construct-from-rational-number-2.py b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Python/continued-fraction-arithmetic-construct-from-rational-number-2.py
new file mode 100644
index 0000000000..f08e86be2f
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Python/continued-fraction-arithmetic-construct-from-rational-number-2.py
@@ -0,0 +1,13 @@
+def real2cf(x):
+    while True:
+        t1, f = divmod(x, 1)
+        yield int(t1)
+        if not f:
+            break
+        x = 1/f
+
+from fractions import Fraction
+from itertools import islice
+
+print(list(real2cf(Fraction(13, 11))))    # => [1, 5, 2]
+print(list(islice(real2cf(2 ** 0.5), 20)))    # => [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/REXX/continued-fraction-arithmetic-construct-from-rational-number.rexx b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/REXX/continued-fraction-arithmetic-construct-from-rational-number.rexx
new file mode 100644
index 0000000000..7840e9810e
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/REXX/continued-fraction-arithmetic-construct-from-rational-number.rexx
@@ -0,0 +1,62 @@
+/*REXX pgm converts decimal or rational fraction to a continued fraction*/
+numeric digits 230                     /*this determines how many terms */
+                                       /*can be generated for dec fracts*/
+say '              1/2  ──► CF: '   r2cf( '1/2'   )
+say '               3   ──► CF: '   r2cf(   3     )
+say '             23/8  ──► CF: '   r2cf( '23/8'  )
+say '             13/11 ──► CF: '   r2cf( '13/11' )
+say '             22/7  ──► CF: '   r2cf( '22/7 ' )
+say
+say '───────── attempts at √2.'
+say '14142/1e4          ──► CF: '   r2cf( '14142/1e4 ' )
+say '141421/1e5         ──► CF: '   r2cf( '141421/1e5 ' )
+say '1414214/1e6        ──► CF: '   r2cf( '1414214/1e6 ' )
+say '14142136/1e7       ──► CF: '   r2cf( '14142136/1e7 ' )
+say '141421356/1e8      ──► CF: '   r2cf( '141421356/1e8 ' )
+say '1414213562/1e9     ──► CF: '   r2cf( '1414213562/1e9 ' )
+say '14142135624/1e10   ──► CF: '   r2cf( '14142135624/1e10 ' )
+say '141421356237/1e11  ──► CF: '   r2cf( '141421356237/1e11 ' )
+say '1414213562373/1e12 ──► CF: '   r2cf( '1414213562373/1e12 ' )
+say '√2                 ──► CF: '   r2cf(  sqrt(2)  )
+say
+say '───────── an attempt at π'
+say 'π                  ──► CF: '   r2cf(  pi()  )
+exit                                   /*stick a fork in it, we're done.*/
+/*────────────────────────────────R2CF subroutine───────────────────────*/
+r2cf: procedure; parse arg g 1 s 2;  $=;   if s=='-'  then g = substr(g,2)
+                                                      else s =
+if pos('.',g)\==0 then do
+                       if \datatype(g,'N') then call serr 'not numeric:' g
+                       g = $maxfact(g)
+                       end
+if pos('/',g)==0  then g = g"/"1
+parse var g n '/' d
+if \datatype(n,'W')  then call serr   "a numerator isn't an integer:"  n
+if \datatype(d,'W')  then call serr "a denominator isn't an integer:"  d
+n = abs(n)                             /*ensure numerator is positive.  */
+if d=0               then call serr 'a denominator is zero'
+
+                 do  while  d\==0      /*where the rubber meets the road*/
+                 $ = $    s || (n%d)   /*append another number to list. */
+                 _ = d
+                 d = n // d            /* %  is int div,  // is modulus.*/
+                 n = _
+                 end   /*while*/
+return strip($)
+/*─────────────────────────────PI subroutine────────────────────────────*/
+pi: return,                            /*a bit of overkill,  but hey !! */             /* ··· should  ≥  NUMERIC DIGITS */
+3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271
+/*─────────────────────────────SERR subroutine──────────────────────────*/
+serr:  say;    say '***error!***';    say;    say arg(1);     say;    exit
+/*─────────────────────────────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 call sqrtErr;   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
+/*─────────────────────────────MAXFACT subroutine───────────────────────*/
+$maxFact: procedure;  parse arg x 1 _x,y;   y=10**(digits()-1);  b=0;  h=1
+a=1; g=0;    do while a<=y & g<=y; n=trunc(_x);  _=a;  a=n*a+b;  b=_;  _=g
+g=n*g+h; h=_;  if n=_x | a/g=x  then do;  if a>y | g>y  then iterate;  b=a
+h=g;  leave;  end;      _x=1/(_x-n); end;                    return  b'/'h
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-1.rb b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-1.rb
new file mode 100644
index 0000000000..94ad700364
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-1.rb
@@ -0,0 +1,10 @@
+=begin
+  Generate a continued fraction from a rational number
+
+  Nigel Galloway, February 4th., 2013
+=end
+def r2cf(n1,n2)
+  while n2 > 0
+    t1 = n1/n2; t2 = n2; n2 = n1 - t1 * n2; n1 = t2; yield t1
+  end
+end
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-10.rb b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-10.rb
new file mode 100644
index 0000000000..d8ee9cf7c5
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-10.rb
@@ -0,0 +1 @@
+r2cf(14142136,10000000) {|n| print "#{n} "}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-2.rb b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-2.rb
new file mode 100644
index 0000000000..206ab53e4a
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-2.rb
@@ -0,0 +1 @@
+r2cf(1,2) {|n| print "#{n} "}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-3.rb b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-3.rb
new file mode 100644
index 0000000000..e9bec76074
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-3.rb
@@ -0,0 +1 @@
+r2cf(3,1) {|n| print "#{n} "}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-4.rb b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-4.rb
new file mode 100644
index 0000000000..ca6021e58b
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-4.rb
@@ -0,0 +1 @@
+r2cf(23,8) {|n| print "#{n} "}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-5.rb b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-5.rb
new file mode 100644
index 0000000000..9ad87f479f
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-5.rb
@@ -0,0 +1 @@
+r2cf(13,11) {|n| print "#{n} "}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-6.rb b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-6.rb
new file mode 100644
index 0000000000..de78f13b5a
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-6.rb
@@ -0,0 +1 @@
+r2cf(22,7) {|n| print "#{n} "}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-7.rb b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-7.rb
new file mode 100644
index 0000000000..a24cf2f2de
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-7.rb
@@ -0,0 +1 @@
+r2cf(14142,10000) {|n| print "#{n} "}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-8.rb b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-8.rb
new file mode 100644
index 0000000000..540b71adad
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-8.rb
@@ -0,0 +1 @@
+r2cf(141421,100000) {|n| print "#{n} "}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-9.rb b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-9.rb
new file mode 100644
index 0000000000..0354322540
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Ruby/continued-fraction-arithmetic-construct-from-rational-number-9.rb
@@ -0,0 +1 @@
+r2cf(1414214,1000000) {|n| print "#{n} "}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-1.tcl b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-1.tcl
new file mode 100644
index 0000000000..2bdfab1136
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-1.tcl
@@ -0,0 +1,19 @@
+package require Tcl 8.6
+
+proc r2cf {n1 {n2 1}} {
+    # Convert a decimal fraction (e.g., 1.23) into a form we can handle
+    if {$n1 != int($n1) && [regexp {\.(\d+)} $n1 -> suffix]} {
+	set pow [string length $suffix]
+	set n1 [expr {int($n1 * 10**$pow)}]
+	set n2 [expr {$n2 * 10**$pow}]
+    }
+    # Construct the continued fraction as a coroutine that yields the digits in sequence
+    coroutine cf\#[incr ::cfcounter] apply {{n1 n2} {
+	yield [info coroutine]
+	while {$n2 > 0} {
+	    yield [expr {$n1 / $n2}]
+	    set n2 [expr {$n1 % [set n1 $n2]}]
+	}
+	return -code break
+    }} $n1 $n2
+}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-2.tcl b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-2.tcl
new file mode 100644
index 0000000000..b2beb9dec8
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-2.tcl
@@ -0,0 +1,31 @@
+proc printcf {name cf} {
+    puts -nonewline "$name -> "
+    while 1 {
+	puts -nonewline "[$cf],"
+    }
+    puts "\b "
+}
+
+foreach {n1 n2} {
+    1 2
+    3 1
+    23 8
+    13 11
+    22 7
+    -151 77
+    14142 10000
+    141421 100000
+    1414214 1000000
+    14142136 10000000
+    31 10
+    314 100
+    3142 1000
+    31428 10000
+    314285 100000
+    3142857 1000000
+    31428571 10000000
+    314285714 100000000
+    3141592653589793 1000000000000000
+} {
+    printcf "\[$n1;$n2\]" [r2cf $n1 $n2]
+}
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-3.tcl b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-3.tcl
new file mode 100644
index 0000000000..b372e1a8f2
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Tcl/continued-fraction-arithmetic-construct-from-rational-number-3.tcl
@@ -0,0 +1,109 @@
+package require Tcl 8.6
+
+# General generator class based on coroutines
+oo::class create Generator {
+    constructor {} {
+	coroutine [namespace current]::coro my Apply
+    }
+    destructor {
+	catch {rename [namespace current]::coro {}}
+    }
+    method Apply {} {
+	yield
+        # Call the method (defined in subclasses) that actually produces values
+	my Produce
+	my destroy
+	return -code break
+    }
+    forward generate coro
+    method unknown args {
+	if {![llength $args]} {
+	    tailcall coro
+	}
+	next {*}$args
+    }
+
+    # Various ways to get the sequence from the generator
+    method collect {} {
+	set result {}
+	while 1 {
+	    lappend result [my generate]
+	}
+	return $result
+    }
+    method take {n {suffix ""}} {
+	set result {}
+	for {set i 0} {$i < $n} {incr i} {
+	    lappend result [my generate]
+	}
+	while {$suffix ne ""} {
+	    my generate
+	    lappend result $suffix
+	    break
+	}
+	return $result
+    }
+}
+
+oo::class create R2CF {
+    superclass Generator
+    variable a b
+    # The constructor converts other kinds of fraction (e.g., 1.23, 22/7) into a
+    # form we can handle.
+    constructor {n1 {n2 1}} {
+	next;  # Delegate to superclass for coroutine management
+	if {[regexp {(.*)/(.*)} $n1 -> a b]} {
+	    # Nothing more to do; assume we can ignore second argument here
+	} elseif {$n1 != int($n1) && [regexp {\.(\d+)} $n1 -> suffix]} {
+	    set pow [string length $suffix]
+	    set a [expr {int($n1 * 10**$pow)}]
+	    set b [expr {$n2 * 10**$pow}]
+	} else {
+	    set a $n1
+	    set b $n2
+	}
+    }
+    # How to actually produce the values of the sequence
+    method Produce {} {
+	while {$b > 0} {
+	    yield [expr {$a / $b}]
+	    set b [expr {$a % [set a $b]}]
+	}
+    }
+}
+
+proc printcf {name cf {take ""}} {
+    if {$take ne ""} {
+	set terms [$cf take $take \u2026]
+    } else {
+	set terms [$cf collect]
+    }
+    puts [format "%-15s-> %s" $name [join $terms ,]]
+}
+
+foreach {n1 n2} {
+    1 2
+    3 1
+    23 8
+    13 11
+    22 7
+    -151 77
+    14142 10000
+    141421 100000
+    1414214 1000000
+    14142136 10000000
+    31 10
+    314 100
+    3142 1000
+    31428 10000
+    314285 100000
+    3142857 1000000
+    31428571 10000000
+    314285714 100000000
+    3141592653589793 1000000000000000
+} {
+    printcf "\[$n1;$n2\]" [R2CF new $n1 $n2]
+}
+# Demonstrate parsing of input in forms other than a direct pair of decimals
+printcf "1.5" [R2CF new 1.5]
+printcf "23/7" [R2CF new 23/7]
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/0DESCRIPTION b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/0DESCRIPTION
new file mode 100644
index 0000000000..b340488f7a
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/0DESCRIPTION
@@ -0,0 +1,41 @@
+This task investigates mathmatical operations that can be performed on a single continued fraction. This requires only a baby version of NG:
+: \begin{bmatrix}
+  a_1 & a \\
+  b_1 & b
+\end{bmatrix}
+I may perform perform the following operations:
+:Input the next term of N1
+:Output a term of the continued fraction resulting from the operation.
+
+I output a term if the integer parts of \frac{a}{b} and \frac{a_1}{b_1} are equal. Otherwise I input a term from N. If I need a term from N but N has no more terms I inject \infty.
+
+When I input a term t my internal state: \begin{bmatrix}
+  a_1 & a \\
+  b_1 & b
+\end{bmatrix} is transposed thus \begin{bmatrix} a + a_1 * t & a_1  \\
+  b + b_1 * t & b_1
+\end{bmatrix}
+
+When I output a term t my internal state: \begin{bmatrix}
+  a_1 & a \\
+  b_1 & b
+\end{bmatrix} is transposed thus \begin{bmatrix} b_1 & b  \\
+  a_1 - b_1 * t & a - b * t
+\end{bmatrix}
+
+When I need a term t but there are no more my internal state: \begin{bmatrix}
+  a_1 & a \\
+  b_1 & b
+\end{bmatrix} is transposed thus \begin{bmatrix} a_1 & a_1 \\
+  b_1 & b_1
+\end{bmatrix}
+
+I am done when b1 and b are zero.
+
+Demonstrate your solution by calculating:
+:[1;5,2] + 1/2
+:[3;7] + 1/2
+:[3;7] divided by 4
+Using a generator for \sqrt{2} (e.g., from [[Continued fraction]]) calculate \frac{1}{\sqrt{2}}. You are now at the starting line for using Continued Fractions to implement [[Arithmetic-geometric mean]] without ulps and epsilons.
+
+The first step in implementing [[Arithmetic-geometric mean]] is to calculate \frac{1 + \frac{1}{\sqrt{2}}}{2} do this now to cross the starting line and begin the race.
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.cpp
new file mode 100644
index 0000000000..959b0d4a00
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.cpp
@@ -0,0 +1,48 @@
+/* Interface for all matrixNG classes
+   Nigel Galloway, February 10th., 2013.
+*/
+class matrixNG {
+  private:
+  virtual void consumeTerm(){}
+  virtual void consumeTerm(int n){}
+  virtual const bool needTerm(){}
+  protected: int cfn = 0, thisTerm;
+             bool haveTerm = false;
+  friend class NG;
+};
+/* Implement the babyNG matrix
+   Nigel Galloway, February 10th., 2013.
+*/
+class NG_4 : public matrixNG {
+  private: int a1, a, b1, b, t;
+  const bool needTerm() {
+    if (b1==0 and b==0) return false;
+    if (b1==0 or b==0) return true; else thisTerm = a/b;
+    if (thisTerm==(int)(a1/b1)){
+      t=a; a=b; b=t-b*thisTerm; t=a1; a1=b1; b1=t-b1*thisTerm;
+      haveTerm=true; return false;
+    }
+    return true;
+  }
+  void consumeTerm(){a=a1; b=b1;}
+  void consumeTerm(int n){t=a; a=a1; a1=t+a1*n; t=b; b=b1; b1=t+b1*n;}
+  public:
+  NG_4(int a1, int a, int b1, int b): a1(a1), a(a), b1(b1), b(b){}
+};
+/* Implement a Continued Fraction which returns the result of an arithmetic operation on
+   1 or more Continued Fractions (Currently 1 or 2).
+   Nigel Galloway, February 10th., 2013.
+*/
+class NG : public ContinuedFraction {
+  private:
+   matrixNG* ng;
+   ContinuedFraction* n[2];
+  public:
+  NG(NG_4* ng, ContinuedFraction* n1): ng(ng){n[0] = n1;}
+  NG(NG_8* ng, ContinuedFraction* n1, ContinuedFraction* n2): ng(ng){n[0] = n1; n[1] = n2;}
+  const int nextTerm() {ng->haveTerm = false; return ng->thisTerm;}
+  const bool moreTerms(){
+    while(ng->needTerm()) if(n[ng->cfn]->moreTerms()) ng->consumeTerm(n[ng->cfn]->nextTerm()); else ng->consumeTerm();
+    return ng->haveTerm;
+  }
+};
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.cpp
new file mode 100644
index 0000000000..92efe9aad1
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.cpp
@@ -0,0 +1,7 @@
+int main() {
+  NG_4 a1(2,1,0,2);
+  r2cf n1(13,11);
+  for(NG n(&a1, &n1); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-3.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-3.cpp
new file mode 100644
index 0000000000..a61cbb03ee
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-3.cpp
@@ -0,0 +1,7 @@
+int main() {
+  NG_4 a2(7,0,0,22);
+  r2cf n2(22,7);
+  for(NG n(&a2, &n2); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-4.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-4.cpp
new file mode 100644
index 0000000000..7fdd5c4895
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-4.cpp
@@ -0,0 +1,7 @@
+int main() {
+  NG_4 a3(2,1,0,2);
+  r2cf n3(22,7);
+  for(NG n(&a3, &n3); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-5.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-5.cpp
new file mode 100644
index 0000000000..2bbf9f7773
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-5.cpp
@@ -0,0 +1,7 @@
+int main() {
+  NG_4 a4(1,0,0,4);
+  r2cf n4(22,7);
+  for(NG n(&a4, &n4); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-6.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-6.cpp
new file mode 100644
index 0000000000..5db15ac3c3
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-6.cpp
@@ -0,0 +1,10 @@
+int main() {
+  NG_4 a5(0,1,1,0);
+  SQRT2 n5;
+  int i = 0;
+  for(NG n(&a5, &n5); n.moreTerms() and i++ < 20; std::cout << n.nextTerm() << " ");
+  std::cout << "..." << std::endl;
+  for(r2cf cf(10000000, 14142136); cf.moreTerms(); std::cout << cf.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-7.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-7.cpp
new file mode 100644
index 0000000000..142d7f771d
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-7.cpp
@@ -0,0 +1,10 @@
+int main() {
+  int i = 0;
+  NG_4 a6(1,1,0,2);
+  SQRT2 n6;
+  for(NG n(&a6, &n6); n.moreTerms() and i++ < 20; std::cout << n.nextTerm() << " ");
+  std::cout << "..." << std::endl;
+  for(r2cf cf(24142136, 20000000); cf.moreTerms(); std::cout << cf.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.rb b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.rb
new file mode 100644
index 0000000000..eb2389dc7c
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.rb
@@ -0,0 +1,29 @@
+=begin
+  I define a class to implement baby NG
+  Nigel Galloway February 6th., 2013
+=end
+class NG
+  def initialize(a1, a, b1, b)
+    @a1 = a1; @a = a; @b1 = b1; @b = b;
+  end
+  def ingress(n)
+    t=@a; @a=@a1; @a1=t + @a1 * n; t=@b; @b=@b1; @b1=t + @b1 * n;
+  end
+  def needterm?
+    return true if @b1 == 0 or @b == 0
+    return true unless @a/@b == @a1/@b1
+    return false
+  end
+  def egress
+    n = @a/@b
+    t=@a; @a=@b; @b=t - @b * n; t=@a1; @a1=@b1; @b1=t - @b1 * n;
+    return n
+  end
+  def egress_done
+    if needterm? then @a=@a1; @b=@b1 end
+    return egress
+  end
+  def done?
+    if @b1 == 0 and @b == 0 then return true else return false end
+  end
+end
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.rb b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.rb
new file mode 100644
index 0000000000..6c93599a81
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.rb
@@ -0,0 +1,3 @@
+op = NG.new(2,1,0,2)
+r2cf(13,11) {|n| if op.needterm? then op.ingress(n) else print "#{op.egress} "; op.ingress(n) end}
+while not op.done? do print "#{op.egress_done} " end
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-3.rb b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-3.rb
new file mode 100644
index 0000000000..24ac7eb6c5
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-3.rb
@@ -0,0 +1,3 @@
+op = NG.new(2,1,0,2)
+r2cf(22,7) {|n| if op.needterm? then op.ingress(n) else print "#{op.egress} "; op.ingress(n) end}
+while not op.done? do print "#{op.egress_done} " end
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-4.rb b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-4.rb
new file mode 100644
index 0000000000..c6556761ea
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Ruby/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-4.rb
@@ -0,0 +1,3 @@
+op = NG.new(1,0,0,4)
+r2cf(22,7) {|n| if op.needterm? then op.ingress(n) else print "#{op.egress} "; op.ingress(n) end}
+while not op.done? do print "#{op.egress_done} " end
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.tcl b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.tcl
new file mode 100644
index 0000000000..472d3b0ded
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-1.tcl
@@ -0,0 +1,50 @@
+# The single-operand version of the NG operator, using our little generator framework
+oo::class create NG1 {
+    superclass Generator
+
+    variable a1 a b1 b cf
+    constructor args {
+	next
+	lassign $args a1 a b1 b
+    }
+    method Ingress n {
+	lassign [list [expr {$a + $a1*$n}] $a1 [expr {$b + $b1*$n}] $b1] \
+	    a1 a b1 b
+    }
+    method NeedTerm? {} {
+	expr {$b1 == 0 || $b == 0 || $a/$b != $a1/$b1}
+    }
+    method Egress {} {
+	set n [expr {$a/$b}]
+	lassign [list $b1 $b [expr {$a1 - $b1*$n}] [expr {$a - $b*$n}]] \
+	    a1 a b1 b
+	return $n
+    }
+    method EgressDone {} {
+	if {[my NeedTerm?]} {
+	    set a $a1
+	    set b $b1
+	}
+	tailcall my Egress
+    }
+    method Done? {} {
+	expr {$b1 == 0 && $b == 0}
+    }
+
+    method operand {N} {
+	set cf $N
+	return [self]
+    }
+    method Produce {} {
+	while 1 {
+	    set n [$cf]
+	    if {![my NeedTerm?]} {
+		yield [my Egress]
+	    }
+	    my Ingress $n
+	}
+	while {![my Done?]} {
+	    yield [my EgressDone]
+	}
+    }
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.tcl b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.tcl
new file mode 100644
index 0000000000..966e9d0ec7
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n)-2.tcl
@@ -0,0 +1,29 @@
+# The square root of 2 as a continued fraction in the framework
+oo::class create Root2 {
+    superclass Generator
+    method apply {} {
+	yield 1
+	while {[self] ne ""} {
+	    yield 2
+	}
+    }
+}
+
+set op [[NG1 new 2 1 0 2] operand [R2CF new 13/11]]
+printcf "\[1;5,2\] + 1/2" $op
+
+set op [[NG1 new 7 0 0 22] operand [R2CF new 22/7]]
+printcf "\[3;7\] * 7/22" $op
+
+set op [[NG1 new 2 1 0 2] operand [R2CF new 22/7]]
+printcf "\[3;7\] + 1/2" $op
+
+set op [[NG1 new 1 0 0 4] operand [R2CF new 22/7]]
+printcf "\[3;7\] / 4" $op
+
+set op [[NG1 new 0 1 1 0] operand [Root2 new]]
+printcf "1/\u221a2" $op 20
+
+set op [[NG1 new 1 1 0 2] operand [Root2 new]]
+printcf "(1+\u221a2)/2" $op 20
+printcf "approx val" [R2CF new 24142136 20000000]
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/0DESCRIPTION b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/0DESCRIPTION
new file mode 100644
index 0000000000..6901180101
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/0DESCRIPTION
@@ -0,0 +1,59 @@
+This task performs the basic mathematical functions on 2 continued fractions. This requires the full version of matrix NG:
+: \begin{bmatrix}
+  a_{12} & a_1 & a_2 & a \\
+  b_{12} & b_1 & b_2 & b
+\end{bmatrix}
+I may perform perform the following operations:
+:Input the next term of continued fraction N1
+:Input the next term of continued fraction N2
+:Output a term of the continued fraction resulting from the operation.
+
+I output a term if the integer parts of \frac{a}{b} and \frac{a_1}{b_1} and \frac{a_2}{b_2} and \frac{a_{12}}{b_{12}} are equal. Otherwise I input a term from continued fraction N1 or continued fraction N2. If I need a term from N but N has no more terms I inject \infty.
+
+When I input a term t from continued fraction N1 I change my internal state:
+: \begin{bmatrix}
+  a_{12} & a_1 & a_2 & a \\
+  b_{12} & b_1 & b_2 & b \end{bmatrix} is transposed thus \begin{bmatrix}   a_2+a_{12}*t & a+a_1*t & a_{12} & a_1 \\
+  b_2+b_{12}*t & b+b_1*t & b_{12} & b_1
+\end{bmatrix}
+
+When I need a term from exhausted continued fraction N1 I change my internal state:
+: \begin{bmatrix}
+  a_{12} & a_1 & a_2 & a \\
+  b_{12} & b_1 & b_2 & b \end{bmatrix} is transposed thus \begin{bmatrix}
+  a_{12} & a_1 & a_{12} & a_1 \\
+  b_{12} & b_1 & b_{12} & b_1
+\end{bmatrix}
+
+When I input a term t from continued fraction N2 I change my internal state:
+: \begin{bmatrix}
+  a_{12} & a_1 & a_2 & a \\
+  b_{12} & b_1 & b_2 & b \end{bmatrix} is transposed thus \begin{bmatrix}
+  a_1+a_{12}*t & a_{12} & a+a_2*t & a_2 \\
+  b_1+b_{12}*t & b_{12} & b+b_2*t & b_2
+\end{bmatrix}
+
+When I need a term from exhausted continued fraction N2 I change my internal state:
+: \begin{bmatrix}
+  a_{12} & a_1 & a_2 & a \\
+  b_{12} & b_1 & b_2 & b \end{bmatrix} is transposed thus \begin{bmatrix}
+  a_{12} & a_{12} & a_2 & a_2 \\
+  b_{12} & b_{12} & b_2 & b_2
+\end{bmatrix}
+
+When I output a term t I change my internal state:
+: \begin{bmatrix}
+  a_{12} & a_1 & a_2 & a \\
+  b_{12} & b_1 & b_2 & b \end{bmatrix} is transposed thus \begin{bmatrix}
+  b_{12} & b_1 & b_2 & b \\
+  a_{12}-b_{12}*t & a_1-b_1*t & a_2-b_2*t & a-b*t
+\end{bmatrix}
+
+When I need to choose to input from N1 or N2 I act:
+: if b and b2 are zero I choose N1
+: if b is zero I choose N2
+: if b2 is zero I choose N2
+: if abs(\frac{a_1}{b_1}-\frac{a}{b}) is greater than abs(\frac{a_2}{b_2}-\frac{a}{b}) I choose N1
+: otherwise I choose N2
+
+When performing arithmetic operation on two potentially infinite continued fractions it is possible to generate a rational number. eg \sqrt{2} * \sqrt{2} should produce 2. This will require either that I determine that my internal state is approaching infinity, or limiting the number of terms I am willing to input without producing any output.
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/1META.yaml b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/1META.yaml
new file mode 100644
index 0000000000..1e81690bbc
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/1META.yaml
@@ -0,0 +1,2 @@
+---
+note: Matrices
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-1.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-1.cpp
new file mode 100644
index 0000000000..af0c45b771
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-1.cpp
@@ -0,0 +1,29 @@
+/* Implement matrix NG
+   Nigel Galloway, February 12., 2013
+*/
+class NG_8 : public matrixNG {
+  private: int a12, a1, a2, a, b12, b1, b2, b, t;
+           double ab, a1b1, a2b2, a12b12;
+  const int chooseCFN(){return fabs(a1b1-ab) > fabs(a2b2-ab)? 0 : 1;}
+  const bool needTerm() {
+    if (b1==0 and b==0 and b2==0 and b12==0) return false;
+    if (b==0){cfn = b2==0? 0:1; return true;} else ab = ((double)a)/b;
+    if (b2==0){cfn = 1; return true;} else a2b2 = ((double)a2)/b2;
+    if (b1==0){cfn = 0; return true;} else a1b1 = ((double)a1)/b1;
+    if (b12==0){cfn = chooseCFN(); return true;} else a12b12 = ((double)a12)/b12;
+    thisTerm = (int)ab;
+    if (thisTerm==(int)a1b1 and thisTerm==(int)a2b2 and thisTerm==(int)a12b12){
+      t=a; a=b; b=t-b*thisTerm; t=a1; a1=b1; b1=t-b1*thisTerm; t=a2; a2=b2; b2=t-b2*thisTerm; t=a12; a12=b12; b12=t-b12*thisTerm;
+      haveTerm = true; return false;
+    }
+    cfn = chooseCFN();
+    return true;
+  }
+  void consumeTerm(){if(cfn==0){a=a1; a2=a12; b=b1; b2=b12;} else{a=a2; a1=a12; b=b2; b1=b12;}}
+  void consumeTerm(int n){
+    if(cfn==0){t=a; a=a1; a1=t+a1*n; t=a2; a2=a12; a12=t+a12*n; t=b; b=b1; b1=t+b1*n; t=b2; b2=b12; b12=t+b12*n;}
+    else{t=a; a=a2; a2=t+a2*n; t=a1; a1=a12; a12=t+a12*n; t=b; b=b2; b2=t+b2*n; t=b1; b1=b12; b12=t+b12*n;}
+  }
+  public:
+  NG_8(int a12, int a1, int a2, int a, int b12, int b1, int b2, int b): a12(a12), a1(a1), a2(a2), a(a), b12(b12), b1(b1), b2(b2), b(b){
+}};
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-2.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-2.cpp
new file mode 100644
index 0000000000..81a4368335
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-2.cpp
@@ -0,0 +1,13 @@
+int main() {
+  NG_8 a(0,1,1,0,0,0,0,1);
+  r2cf n2(22,7);
+  r2cf n1(1,2);
+  for(NG n(&a, &n1, &n2); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+
+  NG_4 a3(2,1,0,2);
+  r2cf n3(22,7);
+  for(NG n(&a3, &n3); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-3.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-3.cpp
new file mode 100644
index 0000000000..d5415ded47
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-3.cpp
@@ -0,0 +1,12 @@
+int main() {
+  NG_8 b(1,0,0,0,0,0,0,1);
+  r2cf b1(13,11);
+  r2cf b2(22,7);
+  for(NG n(&b, &b1, &b2); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  for(NG n(&a, &b2, &b1); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf cf(286,77); cf.moreTerms(); std::cout << cf.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-4.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-4.cpp
new file mode 100644
index 0000000000..a17b50ed3f
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-4.cpp
@@ -0,0 +1,10 @@
+int main() {
+  NG_8 c(0,1,-1,0,0,0,0,1);
+  r2cf c1(13,11);
+  r2cf c2(22,7);
+  for(NG n(&c, &c1, &c2); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf cf(-151,77); cf.moreTerms(); std::cout << cf.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-5.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-5.cpp
new file mode 100644
index 0000000000..88f73675f3
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-5.cpp
@@ -0,0 +1,8 @@
+int main() {
+  NG_8 d(0,1,0,0,0,0,1,0);
+  r2cf d1(22*22,7*7);
+  r2cf d2(22,7);
+  for(NG n(&d, &d1, &d2); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-6.cpp b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-6.cpp
new file mode 100644
index 0000000000..53cc109416
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/C++/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-6.cpp
@@ -0,0 +1,20 @@
+int main() {
+  r2cf a1(2,7);
+  r2cf a2(13,11);
+  NG_8 na(0,1,1,0,0,0,0,1);
+  NG A(&na, &a1, &a2); //[0;3,2] + [1;5,2]
+  r2cf b1(2,7);
+  r2cf b2(13,11);
+  NG_8 nb(0,1,-1,0,0,0,0,1);
+  NG B(&nb, &b1, &b2); //[0;3,2] - [1;5,2]
+  NG_8 nc(1,0,0,0,0,0,0,1); //A*B
+  for(NG n(&nc, &A, &B); n.moreTerms(); std::cout << n.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf cf(2,7); cf.moreTerms(); std::cout << cf.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf cf(13,11); cf.moreTerms(); std::cout << cf.nextTerm() << " ");
+  std::cout << std::endl;
+  for(r2cf cf(-7797,5929); cf.moreTerms(); std::cout << cf.nextTerm() << " ");
+  std::cout << std::endl;
+  return 0;
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-1.tcl b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-1.tcl
new file mode 100644
index 0000000000..cb40e68678
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-1.tcl
@@ -0,0 +1,101 @@
+oo::class create NG2 {
+    variable a b a1 b1 a2 b2 a12 b12 cf1 cf2
+    superclass Generator
+    constructor {args} {
+	lassign $args a12 a1 a2 a b12 b1 b2 b
+	next
+    }
+    method operands {N1 N2} {
+	set cf1 $N1
+	set cf2 $N2
+	return [self]
+    }
+
+    method Ingress1 t {
+	lassign [list [expr {$a2+$a12*$t}] [expr {$a+$a1*$t}] $a12 $a1 \
+		      [expr {$b2+$b12*$t}] [expr {$b+$b1*$t}] $b12 $b1] \
+	    a12 a1 a2 a b12 b1 b2 b
+    }
+    method Exhaust1 {} {
+	lassign [list $a12 $a1 $a12 $a1 $b12 $b1 $b12 $b1] \
+	    a12 a1 a2 a b12 b1 b2 b
+    }
+    method Ingress2 t {
+	lassign [list [expr {$a1+$a12*$t}] $a12 [expr {$a+$a2*$t}] $a2 \
+		      [expr {$b1+$b12*$t}] $b12 [expr {$b+$b2*$t}] $b2] \
+	    a12 a1 a2 a b12 b1 b2 b
+    }
+    method Exhaust2 {} {
+	lassign [list $a12 $a12 $a2 $a2 $b12 $b12 $b2 $b2] \
+	    a12 a1 a2 a b12 b1 b2 b
+    }
+    method Egress {} {
+	set t [expr {$a/$b}]
+	lassign [list $b12 $b1 $b2 $b \
+		    [expr {$a12 - $b12*$t}] [expr {$a1 - $b1*$t}] \
+		    [expr {$a2 - $b2*$t}] [expr {$a - $b*$t}]] \
+	    a12 a1 a2 a b12 b1 b2 b
+	return $t
+    }
+
+    method DoIngress1 {} {
+	try {tailcall my Ingress1 [$cf1]} on break {} {}
+	oo::objdefine [self] forward DoIngress1 my Exhaust1
+	set cf1 ""
+	tailcall my Exhaust1
+    }
+    method DoIngress2 {} {
+	try {tailcall my Ingress2 [$cf2]} on break {} {}
+	oo::objdefine [self] forward DoIngress2 my Exhaust2
+	set cf2 ""
+	tailcall my Exhaust2
+    }
+    method Ingress {} {
+	if {$b==0} {
+	    if {$b2 == 0} {
+		tailcall my DoIngress1
+	    } else {
+		tailcall my DoIngress2
+	    }
+	}
+	if {!$b2} {
+	    tailcall my DoIngress2
+	}
+	if {!$b1} {
+	    tailcall my DoIngress1
+	}
+	if {[my FirstSource?]} {
+	    tailcall my DoIngress1
+	} else {
+	    tailcall my DoIngress2
+	}
+    }
+
+    method FirstSource? {} {
+	expr {abs($a1*$b*$b2 - $a*$b1*$b2) > abs($a2*$b*$b1 - $a*$b1*$b2)}
+    }
+    method NeedTerm? {} {
+	expr {
+	    ($b*$b1*$b2*$b12==0) ||
+	    !($a/$b == $a1/$b1 && $a/$b == $a2/$b2 && $a/$b == $a12/$b12)
+	}
+    }
+    method Done? {} {
+	expr {$b==0 && $b1==0 && $b2==0 && $b12==0}
+    }
+
+    method Produce {} {
+	# Until we've drained both continued fractions...
+	while {$cf1 ne "" || $cf2 ne ""} {
+	    if {[my NeedTerm?]} {
+		my Ingress
+	    } else {
+		yield [my Egress]
+	    }
+	}
+	# Drain our internal state
+	while {![my Done?]} {
+	    yield [my Egress]
+	}
+    }
+}
diff --git a/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-2.tcl b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-2.tcl
new file mode 100644
index 0000000000..1638d7b354
--- /dev/null
+++ b/Task/Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2)/Tcl/continued-fraction-arithmetic-g(matrix-ng,-contined-fraction-n1,-contined-fraction-n2)-2.tcl
@@ -0,0 +1,16 @@
+set op [[NG2 new 0 1 1 0 0 0 0 1] operands [R2CF new 1/2] [R2CF new 22/7]]
+printcf "\[3;7\] + \[0;2\]" $op
+
+set op [[NG2 new 1 0 0 0 0 0 0 1] operands [R2CF new 13/11] [R2CF new 22/7]]
+printcf "\[1:5,2\] * \[3;7\]" $op
+
+set op [[NG2 new 0 1 -1 0 0 0 0 1] operands [R2CF new 13/11] [R2CF new 22/7]]
+printcf "\[1:5,2\] - \[3;7\]" $op
+
+set op [[NG2 new 0 1 0 0 0 0 1 0] operands [R2CF new 484/49] [R2CF new 22/7]]
+printcf "div test" $op
+
+set op1 [[NG2 new 0 1 1 0 0 0 0 1] operands [R2CF new 2/7] [R2CF new 13/11]]
+set op2 [[NG2 new 0 1 -1 0 0 0 0 1] operands [R2CF new 2/7] [R2CF new 13/11]]
+set op3 [[NG2 new 1 0 0 0 0 0 0 1] operands $op1 $op2]
+printcf "layered test" $op3
diff --git a/Task/Continued-fraction/0DESCRIPTION b/Task/Continued-fraction/0DESCRIPTION
new file mode 100644
index 0000000000..8fe12309b2
--- /dev/null
+++ b/Task/Continued-fraction/0DESCRIPTION
@@ -0,0 +1,20 @@
+A number may be represented as a [[wp:Continued fraction|continued fraction]] (see [http://mathworld.wolfram.com/ContinuedFraction.html Mathworld] for more information) as follows:
+
+:a_0 + \cfrac{b_1}{a_1 + \cfrac{b_2}{a_2 + \cfrac{b_3}{a_3 + \ddots}}}
+
+The task is to write a program which generates such a number and prints a real representation of it. The code should be tested by calculating and printing the square root of 2, Napier's Constant, and Pi, using the following coefficients:
+
+For the square root of 2, use a_0 = 1 then a_N = 2. b_N is always 1.
+
+:\sqrt{2} = 1 + \cfrac{1}{2 + \cfrac{1}{2 + \cfrac{1}{2 + \ddots}}}
+
+For Napier's Constant, use a_0 = 2, then a_N = N. b_1 = 1 then b_N = N-1.
+
+:e = 2 + \cfrac{1}{1 + \cfrac{1}{2 + \cfrac{2}{3 + \cfrac{3}{4 + \ddots}}}}
+
+For Pi, use a_0 = 3 then a_N = 6. b_N = (2N-1)^2.
+
+:\pi = 3 + \cfrac{1}{6 + \cfrac{9}{6 + \cfrac{25}{6 + \ddots}}}
+
+;See also:
+* [[Continued fraction/Arithmetic]] for tasks that do arithmetic over continued fractions.
diff --git a/Task/Continued-fraction/ATS/continued-fraction.ats b/Task/Continued-fraction/ATS/continued-fraction.ats
new file mode 100644
index 0000000000..47914d457d
--- /dev/null
+++ b/Task/Continued-fraction/ATS/continued-fraction.ats
@@ -0,0 +1,37 @@
+(* a coefficient function creates double values from in paramters *)
+typedef coeff_f = int -> double
+
+(* a continued fraction is described by a record of two coefficent functions a and b *)
+typedef frac = @{a= coeff_f, b= coeff_f}
+
+(* recursive definition of the approximation *)
+fun calc_rec(f: frac, n: int, r: double): double =
+  if n = 0 then
+    f.a(0) + r // base case
+  else let // recursive case
+    val a: double = f.a(n) // record access
+    val b: double = f.b(n)
+    val s: double = b / (a + r)
+    //val () = printf("r%d = %f, a = %f, b = %f, r%d = %f\n", @(n, r, a, b, (n-1), s))
+  in calc_rec(f, n - 1, s) end
+
+fun calc(f: frac, n: int): double =
+  calc_rec(f, n, 0.0)
+
+(* anonymous coefficient functions created with lam (short for lambda) *)
+val sqrt2 = @{ a= lam (n: int): double => if n = 0 then 1.0 else 2.0,
+               b= lam (n: int): double => 1.0 }
+
+val napier = @{ a= lam (n: int): double => if n = 0 then 2.0 else 1.0 * (n),
+                b= lam (n: int): double => if n = 1 then 1.0 else n - 1.0 }
+
+fun square(x: double): double = x * x
+
+val pi = @{ a= lam (n: int): double => if n = 0 then 3.0 else 6.0,
+            b= lam (n: int): double => square (2.0 * n - 1) }
+
+implement main () = begin
+  printf ("sqrt2  = %f\n", @(calc(sqrt2,  100)));
+  printf ("napier = %f\n", @(calc(napier, 100)));
+  printf ("  pi   = %f\n", @(calc(  pi  , 100)));
+end
diff --git a/Task/Continued-fraction/Ada/continued-fraction-1.ada b/Task/Continued-fraction/Ada/continued-fraction-1.ada
new file mode 100644
index 0000000000..988ba8a48b
--- /dev/null
+++ b/Task/Continued-fraction/Ada/continued-fraction-1.ada
@@ -0,0 +1,6 @@
+generic
+   type Scalar is digits <>;
+
+   with function A (N : in Natural)  return Natural;
+   with function B (N : in Positive) return Natural;
+function Continued_Fraction (Steps : in Natural) return Scalar;
diff --git a/Task/Continued-fraction/Ada/continued-fraction-2.ada b/Task/Continued-fraction/Ada/continued-fraction-2.ada
new file mode 100644
index 0000000000..d109c9b8b5
--- /dev/null
+++ b/Task/Continued-fraction/Ada/continued-fraction-2.ada
@@ -0,0 +1,11 @@
+function Continued_Fraction (Steps : in Natural) return Scalar is
+   function A (N : in Natural)  return Scalar is (Scalar (Natural'(A (N))));
+   function B (N : in Positive) return Scalar is (Scalar (Natural'(B (N))));
+
+   Fraction : Scalar := 0.0;
+begin
+   for N in reverse Natural range 1 .. Steps loop
+      Fraction := B (N) / (A (N) + Fraction);
+   end loop;
+   return A (0) + Fraction;
+end Continued_Fraction;
diff --git a/Task/Continued-fraction/Ada/continued-fraction-3.ada b/Task/Continued-fraction/Ada/continued-fraction-3.ada
new file mode 100644
index 0000000000..060a5408d6
--- /dev/null
+++ b/Task/Continued-fraction/Ada/continued-fraction-3.ada
@@ -0,0 +1,35 @@
+with Ada.Text_IO;
+
+with Continued_Fraction;
+
+procedure Test_Continued_Fractions is
+   type Scalar is digits 15;
+
+   package Square_Root_Of_2 is
+      function A (N : in Natural)  return Natural is (if N = 0 then 1 else 2);
+      function B (N : in Positive) return Natural is (1);
+
+      function Estimate is new Continued_Fraction (Scalar, A, B);
+   end Square_Root_Of_2;
+
+   package Napiers_Constant is
+      function A (N : in Natural)  return Natural is (if N = 0 then 2 else N);
+      function B (N : in Positive) return Natural is (if N = 1 then 1 else N-1);
+
+      function Estimate is new Continued_Fraction (Scalar, A, B);
+   end Napiers_Constant;
+
+   package Pi is
+      function A (N : in Natural)  return Natural is  (if N = 0 then 3 else 6);
+      function B (N : in Positive) return Natural is ((2 * N - 1) ** 2);
+
+      function Estimate is new Continued_Fraction (Scalar, A, B);
+   end Pi;
+
+   package Scalar_Text_IO is new Ada.Text_IO.Float_IO (Scalar);
+   use Ada.Text_IO, Scalar_Text_IO;
+begin
+   Put (Square_Root_Of_2.Estimate (200), Exp => 0); New_Line;
+   Put (Napiers_Constant.Estimate (200), Exp => 0); New_Line;
+   Put (Pi.Estimate (10000),             Exp => 0); New_Line;
+end Test_Continued_Fractions;
diff --git a/Task/Continued-fraction/Ada/continued-fraction-4.ada b/Task/Continued-fraction/Ada/continued-fraction-4.ada
new file mode 100644
index 0000000000..dbb2bdb4c3
--- /dev/null
+++ b/Task/Continued-fraction/Ada/continued-fraction-4.ada
@@ -0,0 +1,6 @@
+generic
+   type Scalar is digits <>;
+
+   with function A (N : in Natural)  return Natural;
+   with function B (N : in Positive) return Natural;
+function Continued_Fraction_Ada95 (Steps : in Natural) return Scalar;
diff --git a/Task/Continued-fraction/Ada/continued-fraction-5.ada b/Task/Continued-fraction/Ada/continued-fraction-5.ada
new file mode 100644
index 0000000000..8aa038981b
--- /dev/null
+++ b/Task/Continued-fraction/Ada/continued-fraction-5.ada
@@ -0,0 +1,18 @@
+function Continued_Fraction_Ada95 (Steps : in Natural) return Scalar is
+   function A (N : in Natural)  return Scalar is
+   begin
+      return Scalar (Natural'(A (N)));
+   end A;
+
+   function B (N : in Positive) return Scalar is
+   begin
+      return Scalar (Natural'(B (N)));
+   end B;
+
+   Fraction : Scalar := 0.0;
+begin
+   for N in reverse Natural range 1 .. Steps loop
+      Fraction := B (N) / (A (N) + Fraction);
+   end loop;
+   return A (0) + Fraction;
+end Continued_Fraction_Ada95;
diff --git a/Task/Continued-fraction/Ada/continued-fraction-6.ada b/Task/Continued-fraction/Ada/continued-fraction-6.ada
new file mode 100644
index 0000000000..e13f026a7b
--- /dev/null
+++ b/Task/Continued-fraction/Ada/continued-fraction-6.ada
@@ -0,0 +1,87 @@
+with Ada.Text_IO;
+
+with Continued_Fraction_Ada95;
+
+procedure Test_Continued_Fractions_Ada95 is
+   type Scalar is digits 15;
+
+   package Square_Root_Of_2 is
+      function A (N : in Natural)  return Natural;
+      function B (N : in Positive) return Natural;
+
+      function Estimate is new Continued_Fraction_Ada95 (Scalar, A, B);
+   end Square_Root_Of_2;
+
+   package body Square_Root_Of_2 is
+      function A (N : in Natural) return Natural is
+      begin
+         if N = 0 then
+            return 1;
+         else
+            return 2;
+         end if;
+      end A;
+
+      function B (N : in Positive) return Natural is
+      begin
+         return 1;
+      end B;
+   end Square_Root_Of_2;
+
+   package Napiers_Constant is
+      function A (N : in Natural)  return Natural;
+      function B (N : in Positive) return Natural;
+
+      function Estimate is new Continued_Fraction_Ada95 (Scalar, A, B);
+   end Napiers_Constant;
+
+   package body Napiers_Constant is
+      function A (N : in Natural) return Natural is
+      begin
+         if N = 0 then
+            return 2;
+         else
+            return N;
+         end if;
+      end A;
+
+      function B (N : in Positive) return Natural is
+      begin
+          if N = 1 then
+             return 1;
+          else
+             return N - 1;
+          end if;
+      end B;
+   end Napiers_Constant;
+
+   package Pi is
+      function A (N : in Natural)  return Natural;
+      function B (N : in Positive) return Natural;
+
+      function Estimate is new Continued_Fraction_Ada95 (Scalar, A, B);
+   end Pi;
+
+   package body Pi is
+      function A (N : in Natural) return Natural is
+      begin
+         if N = 0 then
+            return 3;
+         else
+            return 6;
+         end if;
+      end A;
+
+      function B (N : in Positive) return Natural is
+      begin
+         return (2 * N - 1) ** 2;
+      end B;
+   end Pi;
+
+   package Scalar_Text_IO is new Ada.Text_IO.Float_IO (Scalar);
+   use Ada.Text_IO, Scalar_Text_IO;
+begin
+   Put (Square_Root_Of_2.Estimate (200), Exp => 0); New_Line;
+   Put (Napiers_Constant.Estimate (200), Exp => 0); New_Line;
+   Put (Pi.Estimate (10000),             Exp => 0); New_Line;
+end Test_Continued_Fractions_Ada95;
diff --git a/Task/Continued-fraction/Axiom/continued-fraction-1.axiom b/Task/Continued-fraction/Axiom/continued-fraction-1.axiom
new file mode 100644
index 0000000000..cf9a9ab3cd
--- /dev/null
+++ b/Task/Continued-fraction/Axiom/continued-fraction-1.axiom
@@ -0,0 +1,4 @@
+get(obj) == convergents(obj).1000 -- utility to extract the 1000th value
+get continuedFraction(1, repeating [1], repeating [2]) :: Float
+get continuedFraction(2, cons(1,[i for i in 1..]), [i for i in 1..]) :: Float
+get continuedFraction(3, [i^2 for i in 1.. by 2], repeating [6]) :: Float
diff --git a/Task/Continued-fraction/Axiom/continued-fraction-2.axiom b/Task/Continued-fraction/Axiom/continued-fraction-2.axiom
new file mode 100644
index 0000000000..b6b00401f3
--- /dev/null
+++ b/Task/Continued-fraction/Axiom/continued-fraction-2.axiom
@@ -0,0 +1,8 @@
+   (1)  1.4142135623 730950488
+                                                                  Type: Float
+
+   (2)  2.7182818284 590452354
+                                                                  Type: Float
+
+   (3)  3.1415926538 39792926
+                                                                  Type: Float
diff --git a/Task/Continued-fraction/Axiom/continued-fraction-3.axiom b/Task/Continued-fraction/Axiom/continued-fraction-3.axiom
new file mode 100644
index 0000000000..8d9e9f41ea
--- /dev/null
+++ b/Task/Continued-fraction/Axiom/continued-fraction-3.axiom
@@ -0,0 +1,9 @@
+cf(initial, a, b, n) ==
+  n=1 => initial
+  temp := 0
+  for i in (n-1)..1 by -1 repeat
+    temp := a.i/(b.i+temp)
+  initial+temp
+cf(1, repeating [1], repeating [2], 1000) :: Float
+cf(2, cons(1,[i for i in 1..]), [i for i in 1..], 1000) :: Float
+cf(3, [i^2 for i in 1.. by 2], repeating [6], 1000) :: Float
diff --git a/Task/Continued-fraction/BBC-BASIC/continued-fraction.bbc b/Task/Continued-fraction/BBC-BASIC/continued-fraction.bbc
new file mode 100644
index 0000000000..28649bf9a2
--- /dev/null
+++ b/Task/Continued-fraction/BBC-BASIC/continued-fraction.bbc
@@ -0,0 +1,16 @@
+      *FLOAT64
+      @% = &1001010
+
+      PRINT "SQR(2) = " ; FNcontfrac(1, 1, "2", "1")
+      PRINT "     e = " ; FNcontfrac(2, 1, "N", "N")
+      PRINT "    PI = " ; FNcontfrac(3, 1, "6", "(2*N+1)^2")
+      END
+
+      REM a$ and b$ are functions of N
+      DEF FNcontfrac(a0, b1, a$, b$)
+      LOCAL N, expr$
+      REPEAT
+        N += 1
+        expr$ += STR$(EVAL(a$)) + "+" + STR$(EVAL(b$)) + "/("
+      UNTIL LEN(expr$) > (65500 - N)
+      = a0 + b1 / EVAL (expr$ + "1" + STRING$(N, ")"))
diff --git a/Task/Continued-fraction/C++/continued-fraction.cpp b/Task/Continued-fraction/C++/continued-fraction.cpp
new file mode 100644
index 0000000000..bcf7e242dd
--- /dev/null
+++ b/Task/Continued-fraction/C++/continued-fraction.cpp
@@ -0,0 +1,42 @@
+#include 
+#include 
+#include 
+
+typedef std::tuple coeff_t; // coefficients type
+typedef coeff_t (*func_t)(int); // callback function type
+
+double calc(func_t func, int n)
+{
+    double a, b, temp = 0;
+    for (; n > 0; --n) {
+        std::tie(a, b) = func(n);
+        temp = b / (a + temp);
+    }
+    std::tie(a, b) = func(0);
+    return a + temp;
+}
+
+coeff_t sqrt2(int n)
+{
+    return coeff_t(n > 0 ? 2 : 1, 1);
+}
+
+coeff_t napier(int n)
+{
+    return coeff_t(n > 0 ? n : 2, n > 1 ? n - 1 : 1);
+}
+
+coeff_t pi(int n)
+{
+    return coeff_t(n > 0 ? 6 : 3, (2 * n - 1) * (2 * n - 1));
+}
+
+int main()
+{
+    std::streamsize old_prec = std::cout.precision(15); // set output digits
+    std::cout
+        << calc(sqrt2, 20) << '\n'
+        << calc(napier, 15) << '\n'
+        << calc(pi, 10000) << '\n'
+        << std::setprecision(old_prec); // reset precision
+}
diff --git a/Task/Continued-fraction/C/continued-fraction.c b/Task/Continued-fraction/C/continued-fraction.c
new file mode 100644
index 0000000000..3bb64d15ee
--- /dev/null
+++ b/Task/Continued-fraction/C/continued-fraction.c
@@ -0,0 +1,71 @@
+/* calculate approximations for continued fractions */
+#include 
+
+/* kind of function that returns a series of coefficients */
+typedef double (*coeff_func)(unsigned n);
+
+/* calculates the specified number of expansions of the continued fraction
+ * described by the coefficient series f_a and f_b */
+double calc(coeff_func f_a, coeff_func f_b, unsigned expansions)
+{
+	double a, b, r;
+	a = b = r = 0.0;
+
+	unsigned i;
+	for (i = expansions; i > 0; i--) {
+		a = f_a(i);
+		b = f_b(i);
+		r = b / (a + r);
+	}
+	a = f_a(0);
+
+	return a + r;
+}
+
+/* series for sqrt(2) */
+double sqrt2_a(unsigned n)
+{
+	return n ? 2.0 : 1.0;
+}
+
+double sqrt2_b(unsigned n)
+{
+	return 1.0;
+}
+
+/* series for the napier constant */
+double napier_a(unsigned n)
+{
+	return n ? n : 2.0;
+}
+
+double napier_b(unsigned n)
+{
+	return n > 1.0 ? n - 1.0 : 1.0;
+}
+
+/* series for pi */
+double pi_a(unsigned n)
+{
+	return n ? 6.0 : 3.0;
+}
+
+double pi_b(unsigned n)
+{
+	double c = 2.0 * n - 1.0;
+
+	return c * c;
+}
+
+int main(void)
+{
+	double sqrt2, napier, pi;
+
+	sqrt2  = calc(sqrt2_a,  sqrt2_b,  1000);
+	napier = calc(napier_a, napier_b, 1000);
+	pi     = calc(pi_a,     pi_b,     1000);
+
+	printf("%12.10g\n%12.10g\n%12.10g\n", sqrt2, napier, pi);
+
+	return 0;
+}
diff --git a/Task/Continued-fraction/CoffeeScript/continued-fraction.coffee b/Task/Continued-fraction/CoffeeScript/continued-fraction.coffee
new file mode 100644
index 0000000000..6a6dc10f31
--- /dev/null
+++ b/Task/Continued-fraction/CoffeeScript/continued-fraction.coffee
@@ -0,0 +1,35 @@
+# Compute a continuous fraction of the form
+# a0 + b1 / (a1 + b2 / (a2 + b3 / ...
+continuous_fraction = (f) ->
+  a = f.a
+  b = f.b
+  c = 1
+  for n in [100000..1]
+    c = b(n) / (a(n) + c)
+  a(0) + c
+
+# A little helper.
+p = (a, b) ->
+  console.log a
+  console.log b
+  console.log "---"
+
+do ->
+  fsqrt2 =
+    a: (n) -> if n is 0 then 1 else 2
+    b: (n) -> 1
+  p Math.sqrt(2), continuous_fraction(fsqrt2)
+
+  fnapier =
+    a: (n) -> if n is 0 then 2 else n
+    b: (n) -> if n is 1 then 1 else n - 1
+  p Math.E, continuous_fraction(fnapier)
+
+  fpi =
+    a: (n) ->
+      return 3 if n is 0
+      6
+    b: (n) ->
+      x = 2*n - 1
+      x * x
+  p Math.PI, continuous_fraction(fpi)
diff --git a/Task/Continued-fraction/Common-Lisp/continued-fraction.lisp b/Task/Continued-fraction/Common-Lisp/continued-fraction.lisp
new file mode 100644
index 0000000000..922c2dd492
--- /dev/null
+++ b/Task/Continued-fraction/Common-Lisp/continued-fraction.lisp
@@ -0,0 +1,24 @@
+(defun estimate-continued-fraction (generator n)
+  (let ((temp 0))
+    (loop for n1 from n downto 1
+       do (multiple-value-bind (a b)
+	      (funcall generator n1)
+	    (setf temp (/ b (+ a temp)))))
+    (+ (funcall generator 0) temp)))
+
+(format t "sqrt(2) = ~a~%" (coerce (estimate-continued-fraction
+				    (lambda (n)
+				      (values (if (> n 0) 2 1) 1)) 20)
+				   'double-float))
+(format t "napier's = ~a~%" (coerce (estimate-continued-fraction
+				     (lambda (n)
+				       (values (if (> n 0) n 2)
+					       (if (> n 1) (1- n) 1))) 15)
+				    'double-float))
+
+(format t "pi = ~a~%" (coerce (estimate-continued-fraction
+			       (lambda (n)
+				 (values (if (> n 0) 6 3)
+					 (* (1- (* 2 n))
+					    (1- (* 2 n))))) 10000)
+			      'double-float))
diff --git a/Task/Continued-fraction/D/continued-fraction.d b/Task/Continued-fraction/D/continued-fraction.d
new file mode 100644
index 0000000000..8eaf1b8275
--- /dev/null
+++ b/Task/Continued-fraction/D/continued-fraction.d
@@ -0,0 +1,37 @@
+import std.typecons;
+
+alias Tuple!(int,"a", int,"b") Pair;
+
+FP calc(FP, F)(in F fun, in int n) pure nothrow {
+    FP temp = 0;
+
+    foreach_reverse (ni; 1 .. n+1) {
+        immutable p = fun(ni);
+        temp = cast(FP)p.b / (cast(FP)p.a + temp);
+    }
+    return cast(FP)fun(0).a + temp;
+}
+
+// int[2] fsqrt2(in int n) pure nothrow {
+Pair fsqrt2(in int n) pure nothrow {
+    return Pair(n > 0 ? 2 : 1,
+                1);
+}
+
+Pair fnapier(in int n) pure nothrow {
+    return Pair(n > 0 ? n : 2,
+                n > 1 ? (n - 1) : 1);
+}
+
+Pair fpi(in int n) pure nothrow {
+    return Pair(n > 0 ? 6 : 3,
+                (2 * n - 1) ^^ 2);
+}
+
+void main() {
+    import std.stdio;
+
+    writefln("%.19f", calc!real(&fsqrt2, 200));
+    writefln("%.19f", calc!real(&fnapier, 200));
+    writefln("%.19f", calc!real(&fpi, 200));
+}
diff --git a/Task/Continued-fraction/Forth/continued-fraction.fth b/Task/Continued-fraction/Forth/continued-fraction.fth
new file mode 100644
index 0000000000..cbd0a94434
--- /dev/null
+++ b/Task/Continued-fraction/Forth/continued-fraction.fth
@@ -0,0 +1,9 @@
+: fsqrt2 1 s>f 0> if 2 s>f else fdup then ;
+: fnapier dup dup 1 > if 1- else drop 1 then s>f dup 1 < if drop 2 then s>f ;
+: fpi dup 2* 1- dup * s>f 0> if 6 else 3 then s>f ;
+                                       ( n -- f1 f2)
+: cont.fraction                        ( xt n -- f)
+  1 swap 1+ 0 s>f                      \ calculate for 1 .. n
+  do i over execute frot f+ f/ -1 +loop
+  0 swap execute fnip f+               \ calcucate for 0
+;
diff --git a/Task/Continued-fraction/Go/continued-fraction.go b/Task/Continued-fraction/Go/continued-fraction.go
new file mode 100644
index 0000000000..320c47f3db
--- /dev/null
+++ b/Task/Continued-fraction/Go/continued-fraction.go
@@ -0,0 +1,53 @@
+package main
+
+import "fmt"
+
+type cfTerm struct {
+    a, b int
+}
+
+// follows subscript convention of mathworld and WP where there is no b(0).
+// cf[0].b is unused in this representation.
+type cf []cfTerm
+
+func cfSqrt2(nTerms int) cf {
+    f := make(cf, nTerms)
+    for n := range f {
+        f[n] = cfTerm{2, 1}
+    }
+    f[0].a = 1
+    return f
+}
+
+func cfNap(nTerms int) cf {
+    f := make(cf, nTerms)
+    for n := range f {
+        f[n] = cfTerm{n, n - 1}
+    }
+    f[0].a = 2
+    f[1].b = 1
+    return f
+}
+
+func cfPi(nTerms int) cf {
+    f := make(cf, nTerms)
+    for n := range f {
+        g := 2*n - 1
+        f[n] = cfTerm{6, g * g}
+    }
+    f[0].a = 3
+    return f
+}
+
+func (f cf) real() (r float64) {
+    for n := len(f) - 1; n > 0; n-- {
+        r = float64(f[n].b) / (float64(f[n].a) + r)
+    }
+    return r + float64(f[0].a)
+}
+
+func main() {
+    fmt.Println("sqrt2:", cfSqrt2(20).real())
+    fmt.Println("nap:  ", cfNap(20).real())
+    fmt.Println("pi:   ", cfPi(20).real())
+}
diff --git a/Task/Continued-fraction/Haskell/continued-fraction-1.hs b/Task/Continued-fraction/Haskell/continued-fraction-1.hs
new file mode 100644
index 0000000000..ef1eaed630
--- /dev/null
+++ b/Task/Continued-fraction/Haskell/continued-fraction-1.hs
@@ -0,0 +1,24 @@
+import Data.List (unfoldr)
+import Data.Char (intToDigit)
+
+-- continued fraction represented as a (possibly infinite) list of pairs
+sqrt2, napier, myPi :: [(Integer, Integer)]
+sqrt2 = zip (1 : [2,2..]) [1,1..]
+napier = zip (2 : [1..]) (1 : [1..])
+myPi = zip (3 : [6,6..]) (map (^2) [1,3..])
+
+-- approximate a continued fraction after certain number of iterations
+approxCF :: (Integral a, Fractional b) => Int -> [(a, a)] -> b
+approxCF t =
+  foldr (\(a,b) z -> fromIntegral a + fromIntegral b / z) 1 . take t
+
+-- infinite decimal representation of a real number
+decString :: RealFrac a => a -> String
+decString frac = show i ++ '.' : decString' f where
+  (i,f) = properFraction frac
+  decString' = map intToDigit . unfoldr (Just . properFraction . (10*))
+
+main :: IO ()
+main = mapM_ (putStrLn . take 200 . decString .
+              (approxCF 950 :: [(Integer, Integer)] -> Rational))
+             [sqrt2, napier, myPi]
diff --git a/Task/Continued-fraction/Haskell/continued-fraction-2.hs b/Task/Continued-fraction/Haskell/continued-fraction-2.hs
new file mode 100644
index 0000000000..0924b0ee0b
--- /dev/null
+++ b/Task/Continued-fraction/Haskell/continued-fraction-2.hs
@@ -0,0 +1,30 @@
+import Data.Ratio
+
+-- ignoring the task-given pi sequence: sucky convergence
+-- pie = zip (3:repeat 6) (map (^2) [1,3..])
+
+pie    = zip (0:[1,3..]) (4:map (^2) [1..])
+sqrt2  = zip (1:repeat 2) (repeat 1)
+napier = zip (2:[1..]) (1:[1..])
+
+-- truncate after n terms
+cf2rat n = foldr (\(a,b) f -> (a%1) + ((b%1) / f)) (1%1) . take n
+
+-- truncate after error is at most 1/p
+cf2rat_p p s = f $ map (\i -> (cf2rat i s, cf2rat (1+i) s)) $ map (2^) [0..]
+	where f ((x,y):ys) = if abs (x-y) < (1/fromIntegral p) then x else f ys
+
+-- returns a decimal string of n digits after the dot; all digits should
+-- be correct (doesn't mean it's the best approximation! the decimal
+-- string is simply truncated to given digits: pi=3.141 instead of 3.142)
+cf2dec n = (ratstr n) . cf2rat_p (10^n) where
+	ratstr l a = (show t) ++ '.':fracstr l n d where
+		d = denominator a
+		(t, n) = quotRem (numerator a) d
+		fracstr 0 _ _ = []
+		fracstr l n d = (show t)++ fracstr (l-1) n1 d where (t,n1) = quotRem (10 * n) d
+
+main = do
+	putStrLn $ cf2dec 200 sqrt2
+	putStrLn $ cf2dec 200 napier
+	putStrLn $ cf2dec 200 pie
diff --git a/Task/Continued-fraction/Perl/continued-fraction.pl b/Task/Continued-fraction/Perl/continued-fraction.pl
new file mode 100644
index 0000000000..8d0f8d52ab
--- /dev/null
+++ b/Task/Continued-fraction/Perl/continued-fraction.pl
@@ -0,0 +1,10 @@
+sub continued_fraction {
+    my ($a, $b, $n) = (@_[0,1], $_[2] // 100);
+
+    $a->() + ($n && $b->() / continued_fraction($a, $b, $n-1));
+}
+
+printf "√2  ≈ %.9f\n", continued_fraction do { my $n; sub { $n++ ? 2 : 1 } }, sub { 1 };
+printf "e   ≈ %.9f\n", continued_fraction do { my $n; sub { $n++ || 2 } }, do { my $n; sub { $n++ || 1 } };
+printf "π   ≈ %.9f\n", continued_fraction do { my $n; sub { $n++ ? 6 : 3 } }, do { my $n; sub { (2*$n++ + 1)**2 } }, 1_000;
+printf "π/2 ≈ %.9f\n", continued_fraction do { my $n; sub { 1/($n++ || 1) } }, sub { 1 }, 1_000;
diff --git a/Task/Continued-fraction/Prolog/continued-fraction.pro b/Task/Continued-fraction/Prolog/continued-fraction.pro
new file mode 100644
index 0000000000..00f22ad602
--- /dev/null
+++ b/Task/Continued-fraction/Prolog/continued-fraction.pro
@@ -0,0 +1,43 @@
+continued_fraction :-
+	% square root 2
+	continued_fraction(200, sqrt_2_ab, V1),
+	format('sqrt(2) = ~w~n', [V1]),
+
+	% napier
+	continued_fraction(200, napier_ab, V2),
+	format('e       = ~w~n', [V2]),
+
+	% pi
+	continued_fraction(200, pi_ab, V3),
+	format('pi      = ~w~n', [V3]).
+
+
+% code for continued fractions
+continued_fraction(N, Compute_ab, V) :-
+	continued_fraction(N,  Compute_ab, 0, V).
+
+continued_fraction(0,  Compute_ab, Temp, V) :-
+	call(Compute_ab, 0, A, _),
+	V is A + Temp.
+
+continued_fraction(N, Compute_ab, Tmp, V) :-
+	call(Compute_ab, N, A, B),
+	Tmp1 is B / (A + Tmp),
+	N1 is N - 1,
+	continued_fraction(N1, Compute_ab, Tmp1, V).
+
+% specific codes for examples
+% definitions for square root of 2
+sqrt_2_ab(0, 1, 1).
+sqrt_2_ab(_, 2, 1).
+
+% definitions for napier
+napier_ab(0, 2, _).
+napier_ab(1, 1, 1).
+napier_ab(N, N, V) :-
+	V is N - 1.
+
+% definitions for pi
+pi_ab(0, 3, _).
+pi_ab(N, 6, V) :-
+	V is (2 * N - 1)*(2 * N - 1).
diff --git a/Task/Continued-fraction/Python/continued-fraction-1.py b/Task/Continued-fraction/Python/continued-fraction-1.py
new file mode 100644
index 0000000000..c0f627c0e4
--- /dev/null
+++ b/Task/Continued-fraction/Python/continued-fraction-1.py
@@ -0,0 +1,67 @@
+from fractions import Fraction
+import itertools
+try: zip = itertools.izip
+except: pass
+
+# The Continued Fraction
+def CF(a, b, t):
+  terms = list(itertools.islice(zip(a, b), t))
+  z = Fraction(1,1)
+  for a, b in reversed(terms):
+    z = a + b / z
+  return z
+
+# Approximates a fraction to a string
+def pRes(x, d):
+  q, x = divmod(x, 1)
+  res = str(q)
+  res += "."
+  for i in range(d):
+    x *= 10
+    q, x = divmod(x, 1)
+    res += str(q)
+  return res
+
+# Test the Continued Fraction for sqrt2
+def sqrt2_a():
+  yield 1
+  for x in itertools.repeat(2):
+    yield x
+
+def sqrt2_b():
+  for x in itertools.repeat(1):
+    yield x
+
+cf = CF(sqrt2_a(), sqrt2_b(), 950)
+print(pRes(cf, 200))
+#1.41421356237309504880168872420969807856967187537694807317667973799073247846210703885038753432764157273501384623091229702492483605585073721264412149709993583141322266592750559275579995050115278206057147
+
+
+# Test the Continued Fraction for Napier's Constant
+def Napier_a():
+  yield 2
+  for x in itertools.count(1):
+    yield x
+
+def Napier_b():
+  yield 1
+  for x in itertools.count(1):
+    yield x
+
+cf = CF(Napier_a(), Napier_b(), 950)
+print(pRes(cf, 200))
+#2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746639193200305992181741359662904357290033429526059563073813232862794349076323382988075319525101901
+
+# Test the Continued Fraction for Pi
+def Pi_a():
+  yield 3
+  for x in itertools.repeat(6):
+    yield x
+
+def Pi_b():
+  for x in itertools.count(1,2):
+    yield x*x
+
+cf = CF(Pi_a(), Pi_b(), 950)
+print(pRes(cf, 10))
+#3.1415926532
diff --git a/Task/Continued-fraction/Python/continued-fraction-2.py b/Task/Continued-fraction/Python/continued-fraction-2.py
new file mode 100644
index 0000000000..fa8e766636
--- /dev/null
+++ b/Task/Continued-fraction/Python/continued-fraction-2.py
@@ -0,0 +1,24 @@
+from decimal import Decimal, getcontext
+
+def calc(fun, n):
+    temp = Decimal("0.0")
+
+    for ni in xrange(n+1, 0, -1):
+        (a, b) = fun(ni)
+        temp = Decimal(b) / (a + temp)
+
+    return fun(0)[0] + temp
+
+def fsqrt2(n):
+    return (2 if n > 0 else 1, 1)
+
+def fnapier(n):
+    return (n if n > 0 else 2, (n - 1) if n > 1 else 1)
+
+def fpi(n):
+    return (6 if n > 0 else 3, (2 * n - 1) ** 2)
+
+getcontext().prec = 50
+print calc(fsqrt2, 200)
+print calc(fnapier, 200)
+print calc(fpi, 200)
diff --git a/Task/Continued-fraction/REXX/continued-fraction-1.rexx b/Task/Continued-fraction/REXX/continued-fraction-1.rexx
new file mode 100644
index 0000000000..688b4ef34f
--- /dev/null
+++ b/Task/Continued-fraction/REXX/continued-fraction-1.rexx
@@ -0,0 +1,80 @@
+/*REXX program calculates and displays values of some specific continued*/
+/*───────────── fractions   (along with their   α   and   ß   terms).   */
+/*───────────── Continued fractions: also known as anthyphairetic ratio.*/
+T=500                                  /*use 500 terms for calculations.*/
+showDig=100; numeric digits 2*showDig  /*use 100 digits for the display.*/
+a=;  @=;  b=                           /*omitted ß terms are assumed = 1*/
+/*══════════════════════════════════════════════════════════════════════*/
+a=1 rep(2);                                             call tell '√2'
+/*══════════════════════════════════════════════════════════════════════*/
+a=1 rep(1 2);                                           call tell '√3'        /*also:  2∙sin(π/3)    */
+/*══════════════════════════════════════   ___  ════════════════════════*/
+                           /*generalized  √ N   */
+      do N=2 to 11;        a=1 rep(2); b=rep(N-1);      call tell 'gen √'N;   end
+N=1/2;                     a=1 rep(2); b=rep(N-1);      call tell 'gen √½'
+/*══════════════════════════════════════════════════════════════════════*/
+      do j=1 for T;        a=a j; end;   b=1 a; a=2 a;  call tell 'e'
+/*══════════════════════════════════════════════════════════════════════*/
+      do j=1 for T by 2;   a=a j;        b=b j+1; end;  call tell '1÷[√e-1]'
+/*══════════════════════════════════════════════════════════════════════*/
+      do j=1 for T;        a=a j;     end; b=a; a=0 a;  call tell '1÷[e-1]'
+/*══════════════════════════════════════════════════════════════════════*/
+a=1 rep(1);                                             call tell 'φ, phi'
+/*══════════════════════════════════════════════════════════════════════*/
+a=1;  do j=1 for T by 2;   a=a j 1;   end;              call tell 'tan(1)'
+/*══════════════════════════════════════════════════════════════════════*/
+a=1;  do j=1 for T;        a=a 2*j+1; end;              call tell 'coth(1)'
+/*══════════════════════════════════════════════════════════════════════*/
+a=2;  do j=1 for T;        a=a 4*j+2; end;              call tell 'coth(½)'   /*also:  [e+1] ÷ [e-1] */
+/*══════════════════════════════════════════════════════════════════════*/
+T=10000
+a=1 rep(2)
+      do j=1 for T by 2;   b=b j**2;  end;              call tell '4÷π'
+/*══════════════════════════════════════════════════════════════════════*/
+T=10000
+a=1;  do j=1 for T;        a=a 1/j; @=@ '1/'j; end;     call tell '½π, ½pi'
+/*══════════════════════════════════════════════════════════════════════*/
+T=10000
+a=0 1 rep(2)
+      do j=1 for T by 2;   b=b j**2;     end;   b=4 b;  call tell 'π, pi'
+/*══════════════════════════════════════════════════════════════════════*/
+T=10000
+a=0;  do j=1 for T; a=a j*2-1; b=b j**2; end;   b=4 b;  call tell 'π, pi'
+/*══════════════════════════════════════════════════════════════════════*/
+T=100000
+a=3 rep(6)
+      do j=1 for T by 2;       b=b j**2; end;           call tell 'π, pi'
+exit                                   /*stick a fork in it, we're done.*/
+
+/*────────────────────────────────CF subroutine─────────────────────────*/
+cf: procedure;  parse arg C x,y;      !=0;      numeric digits  digits()+5
+           do k=words(x) to 1 by -1;   a=word(x,k);  b=word(word(y,k) 1,1)
+           d=a+!;  if d=0 then call divZero  /*in case divisor is bogus.*/
+           !=b/d                             /*here's a binary mosh pit.*/
+           end   /*k*/
+return !+C
+/*────────────────────────────────DIVZERO subroutine────────────────────*/
+divZero: say;  say '***error!***';  say 'division by zero.';  say; exit 13
+/*────────────────────────────────GETT subroutine───────────────────────*/
+getT: parse arg stuff,width,ma,mb,_
+                do m=1; mm=m+ma; mn=max(1,m-mb);   w=word(stuff,m)
+                w=right(w,max(length(word(As,mm)),length(word(Bs,mn)),length(w)))
+                if length(_ w)>width  then leave   /*stop getting terms?*/
+                _=_ w                              /*whole, don't chop. */
+                end   /*m*/                        /*done building terms*/
+return strip(_)                                    /*strip leading blank*/
+/*────────────────────────────────REP subroutine────────────────────────*/
+rep:     parse arg rep;        return  space(copies(' 'rep, T%words(rep)))
+/*────────────────────────────────RF subroutine─────────────────────────*/
+rf: parse arg xxx,z
+         do m=1 for T; w=word(xxx,m)    ;  if w=='1/1' | w=1  then w=1
+         if w=='1/2' | w=1/2  then w='½';  if w=-.5           then w='-½'
+         if w=='1/4' | w=1/4  then w='¼';  if w=-.25          then w='-¼'
+         z=z w
+         end
+return z                                           /*done re-formatting.*/
+/*────────────────────────────────TELL subroutine───────────────────────*/
+tell: parse arg ?; v=cf(a,b); numeric digits showdig; As=rf(@ a); Bs=rf(b)
+      say right(?,8)   '='   left(v/1,showdig)   '  α terms= '   getT(As,72  ,0,1)
+      if b\=='' then say right('',8+2+showdig+1) '  ß terms=   ' getT(Bs,72-2,1,0)
+      a=;  @=;  b=;   return
diff --git a/Task/Continued-fraction/REXX/continued-fraction-2.rexx b/Task/Continued-fraction/REXX/continued-fraction-2.rexx
new file mode 100644
index 0000000000..f85721f91a
--- /dev/null
+++ b/Task/Continued-fraction/REXX/continued-fraction-2.rexx
@@ -0,0 +1,44 @@
+/* REXX **************************************************************
+* Derived from PL/I with a little "massage"
+* SQRT2=     1.41421356237309505              <- PL/I Result
+*            1.41421356237309504880168872421  <- REXX Result 30 digits
+* NAPIER=    2.71828182845904524
+*            2.71828182845904523536028747135
+* PI=        3.14159262280484695
+*            3.14159262280484694855146925223
+* 06.09.2012 Walter Pachl
+**********************************************************************/
+  Numeric Digits 30
+  Parse Value '1 2 3 0 0' with Sqrt2 napier pi a b
+  Say left('SQRT2=' ,10) calc(sqrt2,  200)
+  Say left('NAPIER=',10) calc(napier, 200)
+  Say left('PI='    ,10) calc(pi,     200)
+  Exit
+
+Get_Coeffs: procedure Expose a b Sqrt2 napier pi
+  Parse Arg form, n
+  select
+    when form=Sqrt2 Then do
+      if n > 0 then a = 2; else a = 1
+      b = 1
+      end
+    when form=Napier Then do
+      if n > 0 then a = n; else a = 2
+      if n > 1 then b = n - 1; else b = 1
+      end
+    when form=pi Then do
+      if n > 0 then a = 6; else a = 3
+      b = (2*n - 1)**2
+      end
+    end
+  Return
+
+Calc: procedure Expose a b Sqrt2 napier pi
+  Parse Arg form,n
+  Temp=0
+  do ni = n to 1 by -1
+    Call Get_Coeffs form, ni
+    Temp = B/(A + Temp)
+    end
+  call Get_Coeffs  form, 0
+  return (A + Temp)
diff --git a/Task/Continued-fraction/REXX/continued-fraction-3.rexx b/Task/Continued-fraction/REXX/continued-fraction-3.rexx
new file mode 100644
index 0000000000..a2ebb2cccc
--- /dev/null
+++ b/Task/Continued-fraction/REXX/continued-fraction-3.rexx
@@ -0,0 +1,72 @@
+/* REXX *************************************************************
+* The task description specifies a continued fraction for pi
+* that gives a reasonable approximation.
+* Literature shows a better CF that yields pi with a precision of
+* 200 digits.
+* http://de.wikipedia.org/wiki/Kreiszahl
+*                    1
+* pi = 3 + ------------------------
+*                      1
+*          7 + --------------------
+*                         1
+*              15 + ---------------
+*                            1
+*                   1 + -----------
+*
+*                       292 + ...
+*
+* This program uses that CF and shows the first 50 digits
+* PI =3.1415926535897932384626433832795028841971693993751...
+* PIX=3.1415926535897932384626433832795028841971693993751...
+* 201 correct digits
+* 18.09.2012 Walter Pachl
+**********************************************************************/
+  pi='3.1415926535897932384626433832795028841971'||,
+     '693993751058209749445923078164062862089986280348'||,
+     '253421170679821480865132823066470938446095505822'||,
+     '317253594081284811174502841027019385211055596446'||,
+     '229489549303819644288109756659334461284756482337'||,
+     '867831652712019091456485669234603486104543266482'||,
+     '133936072602491412737245870066063155881748815209'||,
+     '209628292540917153643678925903600113305305488204'||,
+     '665213841469519415116094330572703657595919530921'||,
+     '861173819326117931051185480744623799627495673518'||,
+     '857527248912279381830119491298336733624'
+  Numeric Digits 1000
+  al='7 15 1 292 1 1 1 2 1 3 1 14 2 1 1 2 2 2 2 1 84 2',
+     '1 1 15 3 13 1 4 2 6 6 99 1 2 2 6 3 5 1 1 6 8 1 7 1 2',
+     '3 7 1 2 1 1 12 1 1 1 3 1 1 8 1 1 2 1 6 1 1 5 2 2 3 1',
+     '2 4 4 16 1 161 45 1 22 1 2 2 1 4 1 2 24 1 2 1 3 1 2',
+     '1 1 10 2 5 4 1 2 2 8 1 5 2 2 26 1 4 1 1 8 2 42 2 1 7',
+     '3 3 1 1 7 2 4 9 7 2 3 1 57 1 18 1 9 19 1 2 18 1 3 7',
+     '30 1 1 1 3 3 3 1 2 8 1 1 2 1 15 1 2 13 1 2 1 4 1 12',
+     '1 1 3 3 28 1 10 3 2 20 1 1 1 1 4 1 1 1 5 3 2 1 6 1 4'
+  a.=3
+  Do i=1 By 1 while al<>''
+    Parse Var al a.i al
+    End
+  pix=calc(194)
+  Do e=1 To length(pi)
+    If substr(pix,e,1)<>substr(pi,e,1) Then Leave
+    End
+  Numeric Digits 50
+  Say 'PI ='||(pi+0)||'...'
+  Say 'PIX='||(pix+0)||'...'
+  Say (e-1) 'correct digits'
+  Exit
+
+Get_Coeffs: procedure Expose a b a.
+  Parse Arg n
+  a=a.n
+  b=1
+  Return
+
+Calc: procedure Expose a b a.
+  Parse Arg n
+  Temp=0
+  do ni = n to 1 by -1
+    Call Get_Coeffs ni
+    Temp = B/(A + Temp)
+    end
+  call Get_Coeffs 0
+  return (A + Temp)
diff --git a/Task/Continued-fraction/Ruby/continued-fraction.rb b/Task/Continued-fraction/Ruby/continued-fraction.rb
new file mode 100644
index 0000000000..593eac58ec
--- /dev/null
+++ b/Task/Continued-fraction/Ruby/continued-fraction.rb
@@ -0,0 +1,47 @@
+require 'bigdecimal'
+
+# square root of 2
+sqrt2 = Object.new
+def sqrt2.a(n); n == 1 ? 1 : 2; end
+def sqrt2.b(n); 1; end
+
+# Napier's constant
+napier = Object.new
+def napier.a(n); n == 1 ? 2 : n - 1; end
+def napier.b(n); n == 1 ? 1 : n - 1; end
+
+pi = Object.new
+def pi.a(n); n == 1 ? 3 : 6; end
+def pi.b(n); (2*n - 1)**2; end
+
+# Estimates the value of a continued fraction _cfrac_, to _prec_
+# decimal digits of precision. Returns a BigDecimal. _cfrac_ must
+# respond to _cfrac.a(n)_ and _cfrac.b(n)_ for integer _n_ >= 1.
+def estimate(cfrac, prec)
+  last_result = nil
+  terms = prec
+
+  loop do
+    # Estimate continued fraction for _n_ from 1 to _terms_.
+    result = cfrac.a(terms)
+    (terms - 1).downto(1) do |n|
+      a = BigDecimal cfrac.a(n)
+      b = BigDecimal cfrac.b(n)
+      digits = [b.div(result, 1).exponent + prec, 1].max
+      result = a + b.div(result, digits)
+    end
+    result = result.round(prec)
+
+    if result == last_result
+      return result
+    else
+      # Double _terms_ and try again.
+      last_result = result
+      terms *= 2
+    end
+  end
+end
+
+puts estimate(sqrt2, 50).to_s('F')
+puts estimate(napier, 50).to_s('F')
+puts estimate(pi, 10).to_s('F')
diff --git a/Task/Continued-fraction/Scala/continued-fraction-1.scala b/Task/Continued-fraction/Scala/continued-fraction-1.scala
new file mode 100644
index 0000000000..e62d761efa
--- /dev/null
+++ b/Task/Continued-fraction/Scala/continued-fraction-1.scala
@@ -0,0 +1,31 @@
+object CF extends App {
+  import Stream._
+  val sqrt2 = 1 #:: from(2,0) zip from(1,0)
+  val napier = 2 #:: from(1) zip (1 #:: from(1))
+  val pi = 3 #:: from(6,0) zip (from(1,2) map {x=>x*x})
+
+  // reference values, source: wikipedia
+  val refPi     = "3.14159265358979323846264338327950288419716939937510"
+  val refNapier = "2.71828182845904523536028747135266249775724709369995"
+  val refSQRT2  = "1.41421356237309504880168872420969807856967187537694"
+
+  def calc(cf: Stream[(Int, Int)], numberOfIters: Int=200): BigDecimal = {
+    (cf take numberOfIters toList).foldRight[BigDecimal](1)((a, z) => a._1+a._2/z)
+  }
+
+  def approx(cfV: BigDecimal, cfRefV: String): String = {
+    val p: Pair[Char,Char] => Boolean = pair =>(pair._1==pair._2)
+    ((cfV.toString+" "*34).substring(0,34) zip cfRefV.toString.substring(0,34))
+      .takeWhile(p).foldRight[String]("")((a:Pair[Char,Char],z)=>a._1+z)
+  }
+
+  List(("sqrt2",sqrt2,50,refSQRT2),("napier",napier,50,refNapier),("pi",pi,3000,refPi)) foreach {t=>
+    val (name,cf,iters,refV) = t
+    val cfV = calc(cf,iters)
+    println(name+":")
+    println("ref value: "+refV.substring(0,34))
+    println("cf value:  "+(cfV.toString+" "*34).substring(0,34))
+    println("precision: "+approx(cfV,refV))
+    println()
+  }
+}
diff --git a/Task/Continued-fraction/Scala/continued-fraction-2.scala b/Task/Continued-fraction/Scala/continued-fraction-2.scala
new file mode 100644
index 0000000000..cee312192d
--- /dev/null
+++ b/Task/Continued-fraction/Scala/continued-fraction-2.scala
@@ -0,0 +1,35 @@
+object CFI extends App {
+  import Stream._
+  val sqrt2 = 1 #:: from(2,0) zip from(1,0)
+  val napier = 2 #:: from(1) zip (1 #:: from(1))
+  val pi = 3 #:: from(6,0) zip (from(1,2) map {x=>x*x})
+
+  // reference values, source: wikipedia
+  val refPi     = "3.14159265358979323846264338327950288419716939937510"
+  val refNapier = "2.71828182845904523536028747135266249775724709369995"
+  val refSQRT2  = "1.41421356237309504880168872420969807856967187537694"
+
+  def calc_i(cf: Stream[(Int, Int)], numberOfIters: Int=50): BigDecimal = {
+    val cfl = cf take numberOfIters toList
+    var z: BigDecimal = 1.0
+    for (i <- 0 to cfl.size-1 reverse)
+      z=cfl(i)._1+cfl(i)._2/z
+    z
+  }
+
+  def approx(cfV: BigDecimal, cfRefV: String): String = {
+    val p: Pair[Char,Char] => Boolean = pair =>(pair._1==pair._2)
+    ((cfV.toString+" "*34).substring(0,34) zip cfRefV.toString.substring(0,34))
+      .takeWhile(p).foldRight[String]("")((a:Pair[Char,Char],z)=>a._1+z)
+  }
+
+  List(("sqrt2",sqrt2,50,refSQRT2),("napier",napier,50,refNapier),("pi",pi,50000,refPi)) foreach {t=>
+    val (name,cf,iters,refV) = t
+    val cfV = calc_i(cf,iters)
+    println(name+":")
+    println("ref value: "+refV.substring(0,34))
+    println("cf value:  "+(cfV.toString+" "*34).substring(0,34))
+    println("precision: "+approx(cfV,refV))
+    println()
+  }
+}
diff --git a/Task/Continued-fraction/Tcl/continued-fraction.tcl b/Task/Continued-fraction/Tcl/continued-fraction.tcl
new file mode 100644
index 0000000000..7aaefaec7d
--- /dev/null
+++ b/Task/Continued-fraction/Tcl/continued-fraction.tcl
@@ -0,0 +1,41 @@
+package require Tcl 8.6
+
+# Term generators; yield list of pairs
+proc r2 {} {
+    yield {1 1}
+    while 1 {yield {2 1}}
+}
+proc e {} {
+    yield {2 1}
+    while 1 {yield [list [incr n] $n]}
+}
+proc pi {} {
+    set n 0; set a 3
+    while 1 {
+	yield [list $a [expr {(2*[incr n]-1)**2}]]
+	set a 6
+    }
+}
+
+# Continued fraction calculator
+proc cf {generator {termCount 50}} {
+    # Get the chunk of terms we want to work with
+    set terms [list [coroutine cf.c $generator]]
+    while {[llength $terms] < $termCount} {
+	lappend terms [cf.c]
+    }
+    rename cf.c {}
+
+    # Merge the terms to compute the result
+    set val 0.0
+    foreach pair [lreverse $terms] {
+	lassign $pair a b
+	set val [expr {$a + $b/$val}]
+    }
+    return $val
+}
+
+# Demonstration
+puts [cf r2]
+puts [cf e]
+puts [cf pi 250]; # Converges more slowly
diff --git a/Task/Conways-Game-of-Life/0DESCRIPTION b/Task/Conways-Game-of-Life/0DESCRIPTION
new file mode 100644
index 0000000000..57aff5c64b
--- /dev/null
+++ b/Task/Conways-Game-of-Life/0DESCRIPTION
@@ -0,0 +1,17 @@
+The '''Game of Life''' is a [[wp:cellular automaton|cellular automaton]] devised by the British mathematician [[wp:John Horton Conway|John Horton Conway]] in 1970. It is the best-known example of a cellular automaton.
+
+Conway's game of life is described [[wp:Conway%27s_Game_of_Life|here]]:
+
+A cell '''C''' is represented by a 1 when alive or 0 when dead, in an m-by-m square array of cells. We calculate '''N''' - the sum of live cells in C's [[wp:Moore neighborhood|eight-location neighbourhood]], then cell C is alive or dead in the next generation based on the following table:
+    '''C   N                 new C'''
+    1   0,1             ->  0  # Lonely
+    1   4,5,6,7,8       ->  0  # Overcrowded
+    1   2,3             ->  1  # Lives
+    0   3               ->  1  # It takes three to give birth!
+    0   0,1,2,4,5,6,7,8 ->  0  # Barren
+
+Assume cells beyond the boundary are always dead.
+
+The "game" is actually a zero-player game, meaning that its evolution is determined by its initial state, needing no input from human players. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.
+
+Although you should test your implementation on more complex examples such as the [[wp:Conway%27s_Game_of_Life#Examples_of_patterns|glider]] in a larger universe, show the action of the blinker (three adjoining cells in a row all alive), over three generations, in a 3 by 3 grid.
diff --git a/Task/Conways-Game-of-Life/1META.yaml b/Task/Conways-Game-of-Life/1META.yaml
new file mode 100644
index 0000000000..fe8c0bdcea
--- /dev/null
+++ b/Task/Conways-Game-of-Life/1META.yaml
@@ -0,0 +1,4 @@
+---
+category:
+- Cellular automata
+note: Games
diff --git a/Task/Conways-Game-of-Life/6502-Assembly/conways-game-of-life.6502 b/Task/Conways-Game-of-Life/6502-Assembly/conways-game-of-life.6502
new file mode 100644
index 0000000000..3b10dbe4bd
--- /dev/null
+++ b/Task/Conways-Game-of-Life/6502-Assembly/conways-game-of-life.6502
@@ -0,0 +1,123 @@
+randfill:   stx $01          ;$200 for indirect
+            ldx #$02         ;addressing
+            stx $02
+randloop:   lda $fe          ;generate random
+            and #$01         ;pixels on the
+            sta ($01),Y      ;screen
+            jsr inc0103
+            cmp #$00
+            bne randloop
+            lda $02
+            cmp #$06
+            bne randloop
+
+
+clearmem:   lda #$df         ;set $07df-$0a20
+            sta $01          ;to $#00
+            lda #$07
+            sta $02
+clearbyte:  lda #$00
+            sta ($01),Y
+            jsr inc0103
+            cmp #$20
+            bne clearbyte
+            lda $02
+            cmp #$0a
+            bne clearbyte
+
+
+starttick:
+copyscreen: lda #$00         ;set up source
+            sta $01          ;pointer at
+            sta $03          ;$01/$02 and
+            lda #$02         ;dest pointer
+            sta $02          ;at $03/$04
+            lda #$08
+            sta $04
+            ldy #$00
+copybyte:   lda ($01),Y      ;copy pixel to
+            sta ($03),Y      ;back buffer
+            jsr inc0103      ;increment pointers
+            cmp #$00         ;check to see
+            bne copybyte     ;if we're at $600
+            lda $02          ;if so, we've
+            cmp #$06         ;copied the
+            bne copybyte     ;entire screen
+
+
+conway:     lda #$df         ;apply conway rules
+            sta $01          ;reset the pointer
+            sta $03          ;to $#01df/$#07df
+            lda #$01         ;($200 - $21)
+            sta $02          ;($800 - $21)
+            lda #$07
+            sta $04
+onecell:    lda #$00         ;process one cell
+            ldy #$01         ;upper cell
+            clc
+            adc ($03),Y
+            ldy #$41         ;lower cell
+            clc
+            adc ($03),Y
+chkleft:    tax              ;check to see
+            lda $01          ;if we're at the
+            and #$1f         ;left edge
+            tay
+            txa
+            cpy #$1f
+            beq rightcells
+leftcells:  ldy #$00         ;upper-left cell
+            clc
+            adc ($03),Y
+            ldy #$20         ;left cell
+            clc
+            adc ($03),Y
+            ldy #$40         ;lower-left cell
+            clc
+            adc ($03),Y
+chkright:   tax              ;check to see
+            lda $01          ;if we're at the
+            and #$1f         ;right edge
+            tay
+            txa
+            cpy #$1e
+            beq evaluate
+rightcells: ldy #$02         ;upper-right cell
+            clc
+            adc ($03),Y
+            ldy #$22         ;right cell
+            clc
+            adc ($03),Y
+            ldy #$42         ;lower-right cell
+            clc
+            adc ($03),Y
+evaluate:   ldx #$01         ;evaluate total
+            ldy #$21         ;for current cell
+            cmp #$03         ;3 = alive
+            beq storex
+            ldx #$00
+            cmp #$02         ;2 = alive if
+            bne storex       ;c = alive
+            lda ($03),Y
+            and #$01
+            tax
+storex:     txa              ;store to screen
+            sta ($01),Y
+            jsr inc0103      ;move to next cell
+conwayloop: cmp #$e0         ;if not last cell,
+            bne onecell      ;process next cell
+            lda $02
+            cmp #$05
+            bne onecell
+            jmp starttick    ;run next tick
+
+
+inc0103:    lda $01          ;increment $01
+            cmp #$ff         ;and $03 as 16-bit
+            bne onlyinc01    ;pointers
+            inc $02
+            inc $04
+onlyinc01:  inc $01
+            lda $01
+            sta $03
+            rts
diff --git a/Task/Conways-Game-of-Life/ACL2/conways-game-of-life.acl2 b/Task/Conways-Game-of-Life/ACL2/conways-game-of-life.acl2
new file mode 100644
index 0000000000..050ac29efb
--- /dev/null
+++ b/Task/Conways-Game-of-Life/ACL2/conways-game-of-life.acl2
@@ -0,0 +1,105 @@
+(defun print-row (row)
+   (if (endp row)
+       nil
+       (prog2$ (if (first row)
+                   (cw "[]")
+                   (cw "  "))
+               (print-row (rest row)))))
+
+(defun print-grid-r (grid)
+   (if (endp grid)
+       nil
+       (progn$ (cw "|")
+               (print-row (first grid))
+               (cw "|~%")
+               (print-grid-r (rest grid)))))
+
+(defun print-line (l)
+   (if (zp l)
+       nil
+       (prog2$ (cw "-")
+               (print-line (1- l)))))
+
+(defun print-grid (grid)
+   (progn$ (cw "+")
+           (print-line (* 2 (len (first grid))))
+           (cw "+~%")
+           (print-grid-r grid)
+           (cw "+")
+           (print-line (* 2 (len (first grid))))
+           (cw "+~%")))
+
+(defun neighbors-row-r (row)
+   (if (endp (rest (rest row)))
+       (list (if (first row) 1 0))
+       (cons (+ (if (first row) 1 0)
+                (if (third row) 1 0))
+             (neighbors-row-r (rest row)))))
+
+(defun neighbors-row (row)
+   (cons (if (second row) 1 0)
+         (neighbors-row-r row)))
+
+(defun zip+ (xs ys)
+   (if (or (endp xs) (endp ys))
+       (append xs ys)
+       (cons (+ (first xs) (first ys))
+             (zip+ (rest xs) (rest ys)))))
+
+(defun counts-row (row)
+   (if (endp row)
+       nil
+       (cons (if (first row) 1 0)
+             (counts-row (rest row)))))
+
+(defun neighbors-r (grid prev-counts curr-counts next-counts
+                         prev-neighbors curr-neighbors
+                         next-neighbors)
+   (if (endp (rest grid))
+       (list (zip+ (zip+ prev-counts
+                         prev-neighbors)
+                   (neighbors-row (first grid))))
+       (cons (zip+ (zip+ (zip+ prev-counts next-counts)
+                         (zip+ prev-neighbors next-neighbors))
+                   curr-neighbors)
+             (neighbors-r (rest grid)
+                          curr-counts
+                          next-counts
+                          (counts-row (third grid))
+                          curr-neighbors
+                          next-neighbors
+                          (neighbors-row (third grid))))))
+
+(defun neighbors (grid)
+   (neighbors-r grid
+                nil
+                (counts-row (first grid))
+                (counts-row (second grid))
+                nil
+                (neighbors-row (first grid))
+                (neighbors-row (second grid))))
+
+(defun life-rules-row (life neighbors)
+   (if (or (endp life) (endp neighbors))
+       nil
+       (cons (or (and (first life)
+                      (or (= (first neighbors) 2)
+                          (= (first neighbors) 3)))
+                 (and (not (first life))
+                      (= (first neighbors) 3)))
+             (life-rules-row (rest life) (rest neighbors)))))
+
+(defun life-rules-r (grid neighbors)
+   (if (or (endp grid) (endp neighbors))
+       nil
+       (cons (life-rules-row (first grid) (first neighbors))
+             (life-rules-r (rest grid) (rest neighbors)))))
+
+(defun conway-step (grid)
+   (life-rules-r grid (neighbors grid)))
+
+(defun conway (grid steps)
+   (if (zp steps)
+       nil
+       (progn$ (print-grid grid)
+               (conway (conway-step grid) (1- steps)))))
diff --git a/Task/Conways-Game-of-Life/AWK/conways-game-of-life.awk b/Task/Conways-Game-of-Life/AWK/conways-game-of-life.awk
new file mode 100644
index 0000000000..c1ba9e9f08
--- /dev/null
+++ b/Task/Conways-Game-of-Life/AWK/conways-game-of-life.awk
@@ -0,0 +1,21 @@
+BEGIN { c=220; d=619; i=10000; printf("\033[2J");
+ while(i--) m[i]=0;
+ while(d--) m[int(rand()*1000)]=1;
+ while(c--){
+  for(i=52; i<=949; i++){
+   d=m[i-1]+m[i+1]+m[i-51]+m[i-50]+m[i-49]+m[i+49]+m[i+50]+m[i+51];
+   n[i]=m[i];
+   if(m[i]==0 && d==3) n[i]=1;
+   else if(m[i]==1 && d<2) n[i]=0;
+        else if(m[i]==1 && d>3) n[i]=0;
+  }
+  printf("\033[1;1H");
+  for(i=1;i<=1000;i++)
+  {
+   if(n[i]) printf("O"); else printf(".");
+   m[i]=n[i];
+   if(!(i%50)) printf("\n");
+  }
+  printf("%3d\n",c); x=30000; while(x--) ;
+ }
+}
diff --git a/Task/Conways-Game-of-Life/Ada/conways-game-of-life.ada b/Task/Conways-Game-of-Life/Ada/conways-game-of-life.ada
new file mode 100644
index 0000000000..2e0bedd92f
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Ada/conways-game-of-life.ada
@@ -0,0 +1,90 @@
+with Ada.Text_IO;  use Ada.Text_IO;
+
+procedure Life is
+   type Cell is (O, X); -- Two states of a cell
+      -- Computation of neighborhood
+   function "+" (L, R : Cell) return Integer is
+   begin
+      case L is
+         when O =>
+            case R is
+               when O => return 0;
+               when X => return 1;
+            end case;
+         when X =>
+            case R is
+               when O => return 1;
+               when X => return 2;
+            end case;
+      end case;
+   end "+";
+   function "+" (L : Integer; R : Cell) return Integer is
+   begin
+      case R is
+         when O => return L;
+         when X => return L + 1;
+      end case;
+   end "+";
+      -- A colony of cells. The borders are dire and unhabited
+   type Petri_Dish is array (Positive range <>, Positive range <>) of Cell;
+
+   procedure Step (Culture : in out Petri_Dish) is
+      Above : array (Culture'Range (2)) of Cell := (others => O);
+      Left  : Cell;
+      This  : Cell;
+   begin
+      for I in Culture'First (1) + 1 .. Culture'Last (1) - 1 loop
+         Left := O;
+         for J in Culture'First (2) + 1 .. Culture'Last (2) - 1 loop
+            case Above        (J-1) + Above        (J) + Above        (J+1) +
+                 Left                                  + Culture (I,   J+1) +
+                 Culture (I+1, J-1) + Culture (I+1, J) + Culture (I+1, J+1) is
+               when 2 =>     -- Survives if alive
+                  This := Culture (I, J);
+               when 3 =>     -- Survives or else multiplies
+                  This := X;
+               when others => -- Dies
+                  This := O;
+            end case;
+            Above (J-1) := Left;
+            Left        := Culture (I, J);
+            Culture (I, J) := This;
+         end loop;
+         Above (Above'Last - 1) := Left;
+      end loop;
+   end Step;
+
+   procedure Put (Culture : Petri_Dish) is
+   begin
+      for I in Culture'Range loop
+         for J in Culture'Range loop
+            case Culture (I, J) is
+               when O => Put (' ');
+               when X => Put ('#');
+            end case;
+         end loop;
+         New_Line;
+      end loop;
+   end Put;
+
+   Blinker : Petri_Dish := (2..4 =>(O,O,X,O,O), 1|5 =>(O,O,O,O,O));
+   Glider  : Petri_Dish :=
+             (  (O,O,O,O,O,O,O,O,O,O,O),
+                (O,O,X,O,O,O,O,O,O,O,O),
+                (O,O,O,X,O,O,O,O,O,O,O),
+                (O,X,X,X,O,O,O,O,O,O,O),
+                (O,O,O,O,O,O,O,O,O,O,O),
+                (O,O,O,O,O,O,O,O,O,O,O)
+             );
+begin
+   for Generation in 1..3 loop
+      Put_Line ("Blinker" & Integer'Image (Generation));
+      Put (Blinker);
+      Step (Blinker);
+   end loop;
+   for Generation in 1..5 loop
+      Put_Line ("Glider" & Integer'Image (Generation));
+      Put (Glider);
+      Step (Glider);
+   end loop;
+end Life;
diff --git a/Task/Conways-Game-of-Life/AutoHotkey/conways-game-of-life.ahk b/Task/Conways-Game-of-Life/AutoHotkey/conways-game-of-life.ahk
new file mode 100644
index 0000000000..86689fc97a
--- /dev/null
+++ b/Task/Conways-Game-of-Life/AutoHotkey/conways-game-of-life.ahk
@@ -0,0 +1,40 @@
+rows := cols := 10                               ; set grid dimensions
+i = -1,0,1, -1,1, -1,0,1                         ; neighbors' x-offsets
+j = -1,-1,-1, 0,0, 1,1,1                         ; neighbors' y-offsets
+StringSplit i, i, `,                             ; make arrays
+StringSplit j, j, `,
+
+Loop % rows {                                    ; setup grid of checkboxes
+   r := A_Index, y := r*17-8                     ; looks good in VISTA
+   Loop % cols {
+      c := A_Index, x := c*17-5
+      Gui Add, CheckBox, x%x% y%y% w17 h17 vv%c%_%r% gCheck
+   }
+}
+Gui Add, Button, % "x12 w" x+2, step             ; button to step to next generation
+Gui Show
+Return
+
+Check:
+   GuiControlGet %A_GuiControl%                  ; manual set of cells
+Return
+
+ButtonStep:                                      ; move to next generation
+   Loop % rows {
+      r := A_Index
+      Loop % cols {
+         c := A_Index, n := 0
+         Loop 8                                  ; w[x,y] <- new states
+            x := c+i%A_Index%, y := r+j%A_Index%, n += 1=v%x%_%y%
+         GuiControl,,v%c%_%r%,% w%c%_%r% := v%c%_%r% ? n=2 || n=3 : n=3
+      }
+   }
+   Loop % rows {                                 ; update v[x,y] = states
+      r := A_Index
+      Loop % cols
+         v%A_Index%_%r% := w%A_Index%_%r%
+   }
+Return
+
+GuiClose:                                        ; exit when GUI is closed
+ExitApp
diff --git a/Task/Conways-Game-of-Life/BASIC256/conways-game-of-life.basic256 b/Task/Conways-Game-of-Life/BASIC256/conways-game-of-life.basic256
new file mode 100644
index 0000000000..fb58ef6e31
--- /dev/null
+++ b/Task/Conways-Game-of-Life/BASIC256/conways-game-of-life.basic256
@@ -0,0 +1,69 @@
+X = 59 : Y = 35 : H = 4
+
+fastgraphics
+graphsize X*H,Y*H
+
+dim c(X,Y) : dim cn(X,Y) : dim cl(X,Y)
+c[X/2-1,Y/3+1] = 1 : c[X/2,Y/3+1] = 1 : c[X/2+1,Y/3+1] = 1	# Thunderbird methuselah
+c[X/2,Y/3+3] = 1 : c[X/2,Y/3+4] = 1 : c[X/2,Y/3+5] = 1
+
+s = 0
+do
+	color black
+	rect 0,0,graphwidth,graphheight
+	alive = 0 : stable = 1
+	s = s + 1
+	for y = 0 to Y-1
+		for x = 0 to X-1
+			xm1 = (x-1+X)%X : xp1 = (x+1+X)%X
+			ym1 = (y-1+Y)%Y : yp1 = (y+1+Y)%Y
+			cn[x,y] = c[xm1,y] + c[xp1,y]
+			cn[x,y] = c[xm1,ym1] + c[x,ym1] + c[xp1,ym1] + cn[x,y]
+			cn[x,y] = c[xm1,yp1] + c[x,yp1] + c[xp1,yp1] + cn[x,y]
+			if c[x,y] = 1 then
+				if cn[x,y] < 2 or cn[x,y] > 3 then
+					cn[x,y] = 0
+				else
+					cn[x,y] = 1
+					alive = alive + 1
+				end if
+			else
+				if cn[x,y] = 3 then
+					cn[x,y] = 1
+					alive = alive + 1
+				else
+					cn[x,y] = 0
+				end if
+			end if
+			if c[x,y] then
+				if cn[x,y] then
+					if cl[x,y] then color purple		# adult
+					if not cl[x,y] then color green	        # newborn
+				else
+					if cl[x,y] then color red		# old
+					if not cl[x,y] then color yellow	# shortlived
+				end if
+				rect x*H,y*H,H,H
+			end if
+		next x
+	next y
+	refresh
+	pause 0.06
+	# Copy arrays
+	for i = 0 to X-1
+		for j = 0 to Y-1
+			if cl[i,j]<>cn[i,j] then stable = 0
+			cl[i,j] = c[i,j]
+			c[i,j] = cn[i,j]
+		next j
+	next i	
+until not alive or stable
+
+if not alive then
+	print "Died in "+s+" iterations"
+	color black
+	rect 0,0,graphwidth,graphheight
+	refresh
+else
+	print "Stabilized in "+(s-2)+" iterations"	
+end if
diff --git a/Task/Conways-Game-of-Life/BBC-BASIC/conways-game-of-life.bbc b/Task/Conways-Game-of-Life/BBC-BASIC/conways-game-of-life.bbc
new file mode 100644
index 0000000000..9e2ac60ef1
--- /dev/null
+++ b/Task/Conways-Game-of-Life/BBC-BASIC/conways-game-of-life.bbc
@@ -0,0 +1,35 @@
+      dx% = 64
+      dy% = 64
+      DIM old&(dx%+1,dy%+1), new&(dx%+1,dy%+1)
+      VDU 23,22,dx%*4;dy%*4;16,16,16,0
+      OFF
+
+      REM Set blinker:
+      old&(50,50) = 1 : old&(50,51) = 1 : old&(50,52) = 1
+      REM Set glider:
+      old&(5,7) = 1 : old&(6,7) = 1 : old&(7,7) = 1 : old&(7,6) = 1 : old&(6,5) = 1
+
+      REM Draw initial grid:
+      FOR X% = 1 TO dx%
+        FOR Y% = 1 TO dy%
+          IF old&(X%,Y%) GCOL 11 ELSE GCOL 4
+          PLOT 69, X%*8-6, Y%*8-4
+        NEXT
+      NEXT X%
+
+      REM Run:
+      GCOL 4,0
+      REPEAT
+        FOR X% = 1 TO dx%
+          FOR Y% = 1 TO dy%
+            S% = old&(X%-1,Y%) + old&(X%,Y%-1) + old&(X%-1,Y%-1) + old&(X%+1,Y%-1) + \
+            \    old&(X%+1,Y%) + old&(X%,Y%+1) + old&(X%-1,Y%+1) + old&(X%+1,Y%+1)
+            O% = old&(X%,Y%)
+            N% = -(S%=3 OR (O%=1 AND S%=2))
+            new&(X%,Y%) = N%
+            IF N%<>O% PLOT X%*8-6, Y%*8-4
+          NEXT
+        NEXT X%
+        SWAP old&(), new&()
+        WAIT 30
+      UNTIL FALSE
diff --git a/Task/Conways-Game-of-Life/C++/conways-game-of-life.cpp b/Task/Conways-Game-of-Life/C++/conways-game-of-life.cpp
new file mode 100644
index 0000000000..f57130d334
--- /dev/null
+++ b/Task/Conways-Game-of-Life/C++/conways-game-of-life.cpp
@@ -0,0 +1,204 @@
+#include 
+#define HEIGHT 4
+#define WIDTH 4
+
+struct Shape {
+public:
+    char xCoord;
+    char yCoord;
+    char height;
+    char width;
+    char **figure;
+};
+
+struct Glider : public Shape {
+    static const char GLIDER_SIZE = 3;
+    Glider( char x , char y );
+    ~Glider();
+};
+
+struct Blinker : public Shape {
+    static const char BLINKER_HEIGHT = 3;
+    static const char BLINKER_WIDTH = 1;
+    Blinker( char x , char y );
+    ~Blinker();
+};
+
+class GameOfLife {
+public:
+    GameOfLife( Shape sh );
+    void print();
+    void update();
+    char getState( char state , char xCoord , char yCoord , bool toggle);
+    void iterate(unsigned int iterations);
+private:
+    char world[HEIGHT][WIDTH];
+    char otherWorld[HEIGHT][WIDTH];
+    bool toggle;
+    Shape shape;
+};
+
+GameOfLife::GameOfLife( Shape sh ) :
+    shape(sh) ,
+    toggle(true)
+{
+    for ( char i = 0; i < HEIGHT; i++ ) {
+        for ( char j = 0; j < WIDTH; j++ ) {
+            world[i][j] = '.';
+        }
+    }
+    for ( char i = shape.yCoord; i - shape.yCoord < shape.height; i++ ) {
+        for ( char j = shape.xCoord; j - shape.xCoord < shape.width; j++ ) {
+            if ( i < HEIGHT && j < WIDTH ) {
+                world[i][j] =
+                    shape.figure[ i - shape.yCoord ][j - shape.xCoord ];
+            }
+        }
+    }
+}
+
+void GameOfLife::print() {
+    if ( toggle ) {
+        for ( char i = 0; i < HEIGHT; i++ ) {
+            for ( char j = 0; j < WIDTH; j++ ) {
+                std::cout << world[i][j];
+            }
+            std::cout << std::endl;
+        }
+    } else {
+        for ( char i = 0; i < HEIGHT; i++ ) {
+            for ( char j = 0; j < WIDTH; j++ ) {
+                std::cout << otherWorld[i][j];
+            }
+            std::cout << std::endl;
+        }
+    }
+    for ( char i = 0; i < WIDTH; i++ ) {
+        std::cout << '=';
+    }
+    std::cout << std::endl;
+}
+
+void GameOfLife::update() {
+    if (toggle) {
+        for ( char i = 0; i < HEIGHT; i++ ) {
+            for ( char j = 0; j < WIDTH; j++ ) {
+                otherWorld[i][j] =
+                    GameOfLife::getState(world[i][j] , i , j , toggle);
+            }
+        }
+        toggle = !toggle;
+    } else {
+        for ( char i = 0; i < HEIGHT; i++ ) {
+            for ( char j = 0; j < WIDTH; j++ ) {
+                world[i][j] =
+                    GameOfLife::getState(otherWorld[i][j] , i , j , toggle);
+            }
+        }
+        toggle = !toggle;
+    }
+}
+
+char GameOfLife::getState( char state, char yCoord, char xCoord, bool toggle ) {
+    char neighbors = 0;
+    if ( toggle ) {
+        for ( char i = yCoord - 1; i <= yCoord + 1; i++ ) {
+            for ( char j = xCoord - 1; j <= xCoord + 1; j++ ) {
+                if ( i == yCoord && j == xCoord ) {
+                    continue;
+                }
+                if ( i > -1 && i < HEIGHT && j > -1 && j < WIDTH ) {
+                    if ( world[i][j] == 'X' ) {
+                        neighbors++;
+                    }
+                }
+            }
+        }
+    } else {
+        for ( char i = yCoord - 1; i <= yCoord + 1; i++ ) {
+            for ( char j = xCoord - 1; j <= xCoord + 1; j++ ) {
+                if ( i == yCoord && j == xCoord ) {
+                    continue;
+                }
+                if ( i > -1 && i < HEIGHT && j > -1 && j < WIDTH ) {
+                    if ( otherWorld[i][j] == 'X' ) {
+                        neighbors++;
+                    }
+                }
+            }
+        }
+    }
+    if (state == 'X') {
+        return ( neighbors > 1 && neighbors < 4 ) ? 'X' : '.';
+    }
+    else {
+        return ( neighbors == 3 ) ? 'X' : '.';
+    }
+}
+
+void GameOfLife::iterate( unsigned int iterations ) {
+    for ( int i = 0; i < iterations; i++ ) {
+        print();
+        update();
+    }
+}
+
+Glider::Glider( char x , char y ) {
+    xCoord = x;
+    yCoord = y;
+    height = GLIDER_SIZE;
+    width = GLIDER_SIZE;
+    figure = new char*[GLIDER_SIZE];
+    for ( char i = 0; i < GLIDER_SIZE; i++ ) {
+        figure[i] = new char[GLIDER_SIZE];
+    }
+    for ( char i = 0; i < GLIDER_SIZE; i++ ) {
+        for ( char j = 0; j < GLIDER_SIZE; j++ ) {
+            figure[i][j] = '.';
+        }
+    }
+    figure[0][1] = 'X';
+    figure[1][2] = 'X';
+    figure[2][0] = 'X';
+    figure[2][1] = 'X';
+    figure[2][2] = 'X';
+}
+
+Glider::~Glider() {
+    for ( char i = 0; i < GLIDER_SIZE; i++ ) {
+        delete[] figure[i];
+    }
+    delete[] figure;
+}
+
+Blinker::Blinker( char x , char y ) {
+    xCoord = x;
+    yCoord = y;
+    height = BLINKER_HEIGHT;
+    width = BLINKER_WIDTH;
+    figure = new char*[BLINKER_HEIGHT];
+    for ( char i = 0; i < BLINKER_HEIGHT; i++ ) {
+        figure[i] = new char[BLINKER_WIDTH];
+    }
+    for ( char i = 0; i < BLINKER_HEIGHT; i++ ) {
+        for ( char j = 0; j < BLINKER_WIDTH; j++ ) {
+            figure[i][j] = 'X';
+        }
+    }
+}
+
+Blinker::~Blinker() {
+    for ( char i = 0; i < BLINKER_HEIGHT; i++ ) {
+        delete[] figure[i];
+    }
+    delete[] figure;
+}
+
+int main() {
+    Glider glider(0,0);
+    GameOfLife gol(glider);
+    gol.iterate(5);
+    Blinker blinker(1,0);
+    GameOfLife gol2(blinker);
+    gol2.iterate(4);
+}
diff --git a/Task/Conways-Game-of-Life/C-sharp/conways-game-of-life.cs b/Task/Conways-Game-of-Life/C-sharp/conways-game-of-life.cs
new file mode 100644
index 0000000000..8cb5d5ef46
--- /dev/null
+++ b/Task/Conways-Game-of-Life/C-sharp/conways-game-of-life.cs
@@ -0,0 +1,240 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+
+namespace Game_of_Life
+{
+    internal static class Program
+    {
+        private static void Main()
+        {
+            var blinker = new Blinker();
+
+            for (int i = 0; i < 3; i++)
+            {
+                blinker.Print(new Cell(-1, -2), new Cell(4, 4));
+                blinker.Step();
+            }
+
+            var glider = new Glider();
+
+            for (int i = 0; i < 3; i++)
+            {
+                var top = glider.Top;
+                var left = glider.Left;
+                var bottom = glider.Bottom;
+                var right = glider.Right;
+
+                glider.Print(new Cell(left - 1, top - 1), new Cell(right - left + 2, bottom - top + 2));
+                glider.Step();
+            }
+        }
+
+        private static void Print(this CellCollection state, Cell topLeft, Cell size)
+        {
+            const char alive = '#';
+            const char dead = ' ';
+
+            Console.WriteLine("Generation {0} [({1}, {2}), ({3}, {4})] ({5} live cells)",
+                              state.Generation,
+                              topLeft.X, topLeft.Y,
+                              topLeft.X + size.X, topLeft.Y + size.Y,
+                              state.Count);
+
+            for (int i = topLeft.Y; i <= topLeft.Y + size.Y; i++)
+            {
+                for (int o = topLeft.X; o <= topLeft.X + size.X; o++)
+                {
+                    Console.Write(state.Contains(o, i) ? alive : dead);
+                }
+                Console.WriteLine();
+            }
+
+            Console.WriteLine("Generated in {0} ms.", state.MillisecondsToGenerate);
+        }
+
+        private class Blinker : CellCollection
+        {
+            public Blinker()
+            {
+                Add(0, 0);
+                Add(1, 0);
+                Add(2, 0);
+            }
+        }
+
+        private class Glider : CellCollection
+        {
+            public Glider()
+            {
+                Add(1, 0);
+                Add(2, 1);
+                Add(0, 2);
+                Add(1, 2);
+                Add(2, 2);
+            }
+        }
+
+        private class CellCollection : List
+        {
+            public CellCollection(IEnumerable cells)
+                : this()
+            {
+                foreach (var cell in cells)
+                    Add(cell);
+            }
+
+            public CellCollection()
+            {
+                Generation = 0;
+                _stopwatch = new Stopwatch();
+            }
+
+            // Returns the amount of neighboring cells that are alive.
+            private byte GetAliveNeighborsCount(int x, int y)
+            {
+                byte neighbors = 0;
+                for (int i = -1; i <= 1; i++)
+                {
+                    for (int o = -1; o <= 1; o++)
+                    {
+                        if (i == 0 && o == 0)
+                            continue;
+                        if (Contains(x + i, y + o))
+                            neighbors++;
+                    }
+                }
+                return neighbors;
+            }
+
+            // Returns all neighboring cells.
+            private IEnumerable GetNeighbors(int x, int y)
+            {
+                for (int i = -1; i <= 1; i++)
+                {
+                    for (int o = -1; o <= 1; o++)
+                    {
+                        if (i == 0 && o == 0)
+                            continue;
+
+                        yield return new Cell(x + o, y + i);
+                    }
+                }
+            }
+
+            // Steps forward the specified amount of generations.
+            public void Step(uint steps = 1)
+            {
+                _stopwatch.Restart();
+
+                for (uint step = 0; step < steps; step++)
+                {
+                    Generation++;
+
+                    // Variable to act as a snapshot of the current state while we make changes.
+                    var oldState = new CellCollection(this);
+
+                    // Variable to hold the cells that we will check.
+                    var checkCells = new List(oldState);
+
+                    // Adds all dead cells neighboring alive cells to the cells that we will check.
+                    checkCells.AddRange(
+                        from cell in oldState
+                        from neighbor in GetNeighbors(cell.X, cell.Y)
+                        where !checkCells.Contains(neighbor)
+                        select neighbor);
+
+                    foreach (var cell in checkCells)
+                    {
+                        byte neighbors = oldState.GetAliveNeighborsCount(cell.X, cell.Y);
+
+                        /*
+                         * Checks if the current cell is alive or not.
+                         *
+                         * If so, if the cell has less than 2, or more than 3 alive neighbors,
+                         * the cell will be killed.
+                         *
+                         * If not, if the cell has 3 alive neighbors, the cell will be brought to life.
+                         */
+                        if (oldState.Contains(cell.X, cell.Y))
+                        {
+                            if (neighbors < 2 || neighbors > 3)
+                                Remove(cell);
+                        }
+                        else
+                        {
+                            if (neighbors == 3)
+                                Add(cell);
+                        }
+                    }
+                }
+
+                _stopwatch.Stop();
+            }
+
+            public void Add(int x, int y)
+            {
+                Add(new Cell(x, y));
+            }
+
+            public bool Contains(int x, int y)
+            {
+                return Contains(new Cell(x, y));
+            }
+
+            public int Top
+            {
+                get { return (from cell in this orderby cell.Y ascending select cell.Y).First(); }
+            }
+
+            public int Bottom
+            {
+                get { return (from cell in this orderby cell.Y descending select cell.Y).First(); }
+            }
+
+            public int Left
+            {
+                get { return (from cell in this orderby cell.X ascending select cell.X).First(); }
+            }
+
+            public int Right
+            {
+                get { return (from cell in this orderby cell.X descending select cell.X).First(); }
+            }
+
+            public uint Generation { get; private set; }
+            public long MillisecondsToGenerate { get { return _stopwatch.ElapsedMilliseconds; } }
+
+            private readonly Stopwatch _stopwatch;
+        }
+
+        private struct Cell : IEquatable
+        {
+            public Cell(int x, int y)
+            {
+                _x = x;
+                _y = y;
+            }
+
+            private readonly int _x;
+
+            public int X
+            {
+                get { return _x; }
+            }
+
+            private readonly int _y;
+
+            public int Y
+            {
+                get { return _y; }
+            }
+
+            public bool Equals(Cell other)
+            {
+                return (X == other.X && Y == other.Y);
+            }
+        }
+    }
+}
diff --git a/Task/Conways-Game-of-Life/C/conways-game-of-life.c b/Task/Conways-Game-of-Life/C/conways-game-of-life.c
new file mode 100644
index 0000000000..8767b8526c
--- /dev/null
+++ b/Task/Conways-Game-of-Life/C/conways-game-of-life.c
@@ -0,0 +1,56 @@
+#include 
+#include 
+#include 
+
+#define for_x for (int x = 0; x < w; x++)
+#define for_y for (int y = 0; y < h; y++)
+#define for_xy for_x for_y
+void show(void *u, int w, int h)
+{
+	int (*univ)[w] = u;
+	printf("\033[H");
+	for_y {
+		for_x printf(univ[y][x] ? "\033[07m  \033[m" : "  ");
+		printf("\033[E");
+	}
+	fflush(stdout);
+}
+
+void evolve(void *u, int w, int h)
+{
+	unsigned (*univ)[w] = u;
+	unsigned new[h][w];
+
+	for_y for_x {
+		int n = 0;
+		for (int y1 = y - 1; y1 <= y + 1; y1++)
+			for (int x1 = x - 1; x1 <= x + 1; x1++)
+				if (univ[(y1 + h) % h][(x1 + w) % w])
+					n++;
+
+		if (univ[y][x]) n--;
+		new[y][x] = (n == 3 || (n == 2 && univ[y][x]));
+	}
+	for_y for_x univ[y][x] = new[y][x];
+}
+
+void game(int w, int h)
+{
+	unsigned univ[h][w];
+	for_xy univ[y][x] = rand() < RAND_MAX / 10 ? 1 : 0;
+	while (1) {
+		show(univ, w, h);
+		evolve(univ, w, h);
+		usleep(200000);
+	}
+}
+
+int main(int c, char **v)
+{
+	int w = 0, h = 0;
+	if (c > 1) w = atoi(v[1]);
+	if (c > 2) h = atoi(v[2]);
+	if (w <= 0) w = 30;
+	if (h <= 0) h = 30;
+	game(w, h);
+}
diff --git a/Task/Conways-Game-of-Life/Clojure/conways-game-of-life.clj b/Task/Conways-Game-of-Life/Clojure/conways-game-of-life.clj
new file mode 100644
index 0000000000..91564c8023
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Clojure/conways-game-of-life.clj
@@ -0,0 +1,27 @@
+(defn moore-neighborhood [[x y]]
+  (for [dx [-1 0 1]
+        dy [-1 0 1]
+        :when (not (= [dx dy] [0 0]))]
+    [(+ x dx) (+ y dy)]))
+
+(defn step [set-of-cells]
+  (set (for [[cell count] (frequencies (mapcat moore-neighborhood set-of-cells))
+             :when (or (= 3 count)
+                       (and (= 2 count) (contains? set-of-cells cell)))]
+         cell)))
+
+(defn print-world
+  ([set-of-cells] (print-world set-of-cells 10))
+  ([set-of-cells world-size]
+     (let [r (range 0 (+ 1 world-size))]
+       (pprint (for [y r] (apply str (for [x r] (if (set-of-cells [x y]) \# \.))))))))
+
+(defn run-life [world-size num-steps set-of-cells]
+  (loop [s num-steps
+         cells set-of-cells]
+    (print-world cells world-size)
+    (when (< 0 s)
+      (recur (- s 1) (step cells)))))
+
+(def *blinker* #{[1 2] [2 2] [3 2]})
+(def *glider* #{[1 0] [2 1] [0 2] [1 2] [2 2]})
diff --git a/Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-1.lisp b/Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-1.lisp
new file mode 100644
index 0000000000..f43b9ed88e
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-1.lisp
@@ -0,0 +1,42 @@
+(defun next-life (array &optional results)
+  (let* ((dimensions (array-dimensions array))
+         (results (or results (make-array dimensions :element-type 'bit))))
+    (destructuring-bind (rows columns) dimensions
+      (labels ((entry (row col)
+                 "Return array(row,col) for valid (row,col) else 0."
+                 (if (or (not (< -1 row rows))
+                         (not (< -1 col columns)))
+                   0
+                   (aref array row col)))
+               (neighbor-count (row col &aux (count 0))
+                 "Return the sum of the neighbors of (row,col)."
+                 (dolist (r (list (1- row) row (1+ row)) count)
+                   (dolist (c (list (1- col) col (1+ col)))
+                     (unless (and (eql r row) (eql c col))
+                       (incf count (entry r c))))))
+               (live-or-die? (current-state neighbor-count)
+                 (if (or (and (eql current-state 1)
+                              (<=  2 neighbor-count 3))
+                         (and (eql current-state 0)
+                              (eql neighbor-count 3)))
+                   1
+                   0)))
+        (dotimes (row rows results)
+          (dotimes (column columns)
+            (setf (aref results row column)
+                  (live-or-die? (aref array row column)
+                                (neighbor-count row column)))))))))
+
+(defun print-grid (grid &optional (out *standard-output*))
+  (destructuring-bind (rows columns) (array-dimensions grid)
+    (dotimes (r rows grid)
+      (dotimes (c columns (terpri out))
+        (write-char (if (zerop (aref grid r c)) #\+ #\#) out)))))
+
+(defun run-life (&optional world (iterations 10) (out *standard-output*))
+  (let* ((world (or world (make-array '(10 10) :element-type 'bit)))
+         (result (make-array (array-dimensions world) :element-type 'bit)))
+    (do ((i 0 (1+ i))) ((eql i iterations) world)
+      (terpri out) (print-grid world out)
+      (psetq world (next-life world result)
+             result world))))
diff --git a/Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-2.lisp b/Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-2.lisp
new file mode 100644
index 0000000000..74aff8d8b5
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-2.lisp
@@ -0,0 +1,6 @@
+(run-life (make-array '(3 3)
+                      :element-type 'bit
+                      :initial-contents '((0 0 0)
+                                          (1 1 1)
+                                          (0 0 0)))
+          3)
diff --git a/Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-3.lisp b/Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-3.lisp
new file mode 100644
index 0000000000..08ff514305
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Common-Lisp/conways-game-of-life-3.lisp
@@ -0,0 +1,42 @@
+(defun moore-neighborhood (cell)
+  (let ((r '(-1 0 1)))
+    (mapcan
+	 (lambda (delta-x)
+	   (loop for delta-y in r
+	      unless (and (= delta-x 0) (= delta-y 0))
+	      collect (cons (+ (car cell) delta-x) (+ (cdr cell) delta-y))))
+	 r)))
+
+(defun frequencies (cells)
+  (let ((h (make-hash-table :test #'equal)))
+    (loop for c in cells
+       if (gethash c h)
+         do (incf (gethash c h))
+       else
+       do (setf (gethash c h) 1))
+    h))
+
+(defun life-step (cells)
+  (let ((f (frequencies (mapcan #'moore-neighborhood cells))))
+    (loop for k being the hash-keys in f
+       when (or
+	     (= (gethash k f) 3)
+	     (and (= (gethash k f) 2) (member k cells :test #'equal)))
+	 collect k)))
+
+(defun print-world (live-cells &optional (world-size 10))
+  (dotimes (y world-size)
+    (dotimes (x world-size)
+      (if (member (cons x y) live-cells :test #'equal)
+	  (format t "X")
+	  (format t ".")))
+    (format t "~%")))
+
+(defun run-life (world-size steps cells)
+  (print-world cells world-size)
+  (format t "~%")
+  (when (< 0 steps)
+    (run-life world-size (- steps 1) (life-step cells))))
+
+(defparameter *blinker* '((1 . 2) (2 . 2) (3 . 2)))
+(defparameter *glider* '((1 . 0) (2 . 1) (0 . 2) (1 . 2) (2 . 2)))
diff --git a/Task/Conways-Game-of-Life/D/conways-game-of-life-1.d b/Task/Conways-Game-of-Life/D/conways-game-of-life-1.d
new file mode 100644
index 0000000000..bdcb1c3ea0
--- /dev/null
+++ b/Task/Conways-Game-of-Life/D/conways-game-of-life-1.d
@@ -0,0 +1,66 @@
+import std.stdio,std.string,std.algorithm,std.typetuple,std.array;
+
+struct GameOfLife {
+  enum Cell : char { dead = ' ', alive = '#' }
+  Cell[][] grid, newGrid;
+
+  this(in int x, in int y) pure nothrow {
+    grid = new typeof(grid)(y + 2, x + 2);
+    newGrid = new typeof(grid)(y + 2, x + 2);
+  }
+
+  void opIndexAssign(in string[] v, in size_t y, in size_t x)
+  pure nothrow {
+    foreach (nr, row; v)
+      foreach (nc, state; row) {
+        //grid[y + nr][x + nc] = to!Cell(state);
+        assert(state == Cell.dead || state == Cell.alive);
+        grid[y + nr][x + nc] = cast(Cell)state;
+      }
+  }
+
+  void iteration() pure nothrow {
+    newGrid[0][] = Cell.dead;
+    newGrid[$ - 1][] = Cell.dead;
+    foreach (row; newGrid)
+      row[0] = row[$ - 1] = Cell.dead;
+
+    foreach (r; 1 .. grid.length - 1)
+      foreach (c; 1 .. grid[0].length - 1) {
+        int count = 0;
+        foreach (i; -1 .. 2)
+          foreach (j; -1 .. 2)
+            if (i != 0 || j != 0)
+              count += grid[r + i][c + j] == Cell.alive;
+        auto a = count == 3 ||
+                 (count == 2 && grid[r][c] == Cell.alive);
+        newGrid[r][c] = a ? Cell.alive : Cell.dead;
+      }
+
+    swap(grid, newGrid);
+  }
+
+  string toString() const pure nothrow {
+    string ret = "-".replicate(grid[0].length - 1) ~ "\n";
+    foreach (row; grid[1 .. $ - 1])
+      ret ~= "|" ~ cast(char[])row[1 .. $-1] ~ "|\n";
+    return ret ~ "-".replicate(grid[0].length - 1);
+  }
+}
+void main() {
+  immutable glider1 = ["  #", "# #", " ##"];
+  immutable glider2 = ["#  ", "# #", "## "];
+
+  auto uni = GameOfLife(60, 20);
+  uni[3,  2] = glider1;
+  uni[3, 15] = glider2;
+  uni[3, 19] = glider1;
+  uni[3, 32] = glider2;
+  uni[5, 50] = [" #  #", "#  ", "#   #", "#### "];
+  writeln(uni);
+
+  foreach (i; 0 .. 20) {
+    uni.iteration();
+    writeln(uni);
+  }
+}
diff --git a/Task/Conways-Game-of-Life/D/conways-game-of-life-2.d b/Task/Conways-Game-of-Life/D/conways-game-of-life-2.d
new file mode 100644
index 0000000000..fffa9574b2
--- /dev/null
+++ b/Task/Conways-Game-of-Life/D/conways-game-of-life-2.d
@@ -0,0 +1,83 @@
+import std.stdio,std.string,std.algorithm,std.typetuple,std.array;
+
+template Iota(int start, int stop) {
+    static if (stop <= start)
+        alias TypeTuple!() Iota;
+    else
+        alias TypeTuple!(Iota!(start, stop-1), stop-1) Iota;
+}
+
+struct GameOfLife {
+  enum Cell : char { dead = ' ', alive = '#' }
+  Cell[] grid, newGrid;
+  immutable size_t nCols;
+
+  this(int nx, int ny) pure nothrow {
+    nCols = nx + 2;
+    grid = new typeof(grid)(nCols * (ny + 2));
+    newGrid = new typeof(grid)(grid.length);
+  }
+
+  void opIndexAssign(in string[] v, in size_t y, in size_t x)
+  pure nothrow {
+    foreach (nr, row; v)
+      foreach (nc, state; row) {
+        //grid[(y + nr) * nCols + x + nc] = to!Cell(state);
+        assert(state == Cell.dead || state == Cell.alive);
+        grid[(y + nr) * nCols + x + nc] = cast(Cell)state;
+      }
+  }
+
+  void iteration() {
+    newGrid[0 .. nCols] = Cell.dead;
+    newGrid[$ - nCols .. $] = Cell.dead;
+    foreach (nr; 1 .. (newGrid.length / nCols) - 1) {
+      newGrid[nr * nCols + 0] = Cell.dead;
+      newGrid[nr * nCols + nCols - 1] = Cell.dead;
+    }
+
+    foreach (nr; 1 .. (grid.length / nCols) - 1) {
+      size_t nr_nCols = nr * nCols;
+      foreach (nc; 1 .. nCols - 1) {
+        uint count = 0;
+        /*static*/ foreach (i; Iota!(-1, 2))
+          /*static*/ foreach (j; Iota!(-1, 2))
+            static if (i != 0 || j != 0)
+              count +=
+                (grid[nr_nCols + i * nCols + nc + j] == Cell.alive);
+        const a = count == 3 ||
+                  (count == 2 && grid[nr_nCols + nc] == Cell.alive);
+        newGrid[nr_nCols + nc] = a ? Cell.alive : Cell.dead;
+      }
+    }
+
+    swap(grid, newGrid);
+  }
+
+  string toString() const pure nothrow {
+    string ret = "-".replicate(nCols - 1) ~ "\n";
+    foreach (nr; 1 .. (grid.length / nCols) - 1)
+      ret ~= "|" ~
+             cast(char[])grid[nr * nCols + 1 .. nr * nCols + nCols - 1]
+             ~ "|\n";
+    return ret ~ "-".replicate(nCols - 1);
+  }
+}
+
+void main() {
+  immutable glider1 = ["  #", "# #", " ##"];
+  immutable glider2 = ["#  ", "# #", "## "];
+
+  auto uni = GameOfLife(60, 20);
+  uni[3,  2] = glider1;
+  uni[3, 15] = glider2;
+  uni[3, 19] = glider1;
+  uni[3, 32] = glider2;
+  uni[5, 50] = [" #  #", "#  ", "#   #", "#### "];
+  writeln(uni);
+
+  foreach (i; 0 .. 20) {
+    uni.iteration();
+    writeln(uni);
+  }
+}
diff --git a/Task/Conways-Game-of-Life/Dart/conways-game-of-life-1.dart b/Task/Conways-Game-of-Life/Dart/conways-game-of-life-1.dart
new file mode 100644
index 0000000000..20eed56c4b
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Dart/conways-game-of-life-1.dart
@@ -0,0 +1,157 @@
+/**
+* States of a cell. A cell is either [ALIVE] or [DEAD].
+* The state contains its [symbol] for printing.
+*/
+class State {
+  const State(this.symbol);
+
+  static final ALIVE = const State('#');
+  static final DEAD = const State(' ');
+
+  final String symbol;
+}
+
+/**
+* The "business rule" of the game. Depending on the count of neighbours,
+* the [cellState] changes.
+*/
+class Rule {
+  Rule(this.cellState);
+
+  reactToNeighbours(int neighbours) {
+    if (neighbours == 3) {
+      cellState = State.ALIVE;
+    } else if (neighbours != 2) {
+      cellState = State.DEAD;
+    }
+  }
+
+  var cellState;
+}
+
+/**
+* A coordinate on the [Grid].
+*/
+class Point {
+  const Point(this.x, this.y);
+
+  operator +(other) => new Point(x + other.x, y + other.y);
+
+  final int x;
+  final int y;
+}
+
+/**
+* List of the relative indices of the 8 cells around a cell.
+*/
+class Neighbourhood {
+  List points() {
+    return [
+      new Point(LEFT, UP), new Point(MIDDLE, UP), new Point(RIGHT, UP),
+      new Point(LEFT, SAME), new Point(RIGHT, SAME),
+      new Point(LEFT, DOWN), new Point(MIDDLE, DOWN), new Point(RIGHT, DOWN)
+    ];
+  }
+
+  static final LEFT = -1;
+  static final MIDDLE = 0;
+  static final RIGHT = 1;
+  static final UP = -1;
+  static final SAME = 0;
+  static final DOWN = 1;
+}
+
+/**
+* The grid is an endless, two-dimensional [field] of cell [State]s.
+*/
+class Grid {
+  Grid(this.xCount, this.yCount) {
+    _field = new Map();
+    _neighbours = new Neighbourhood().points();
+  }
+
+  set(point, state) {
+    _field[_pos(point)] = state;
+  }
+
+  State get(point) {
+    var state = _field[_pos(point)];
+    return state != null ? state : State.DEAD;
+  }
+
+  int countLiveNeighbours(point) =>
+    _neighbours.filter((offset) => get(point + offset) == State.ALIVE).length;
+
+  _pos(point) => '${(point.x + xCount) % xCount}:${(point.y + yCount) % yCount}';
+
+  print() {
+    var sb = new StringBuffer();
+    iterate((point) { sb.add(get(point).symbol); }, (x) { sb.add("\n"); });
+    return sb.toString();
+  }
+
+  iterate(eachCell, [finishedRow]) {
+    for (var x = 0; x < xCount; x++) {
+      for (var y = 0; y < yCount; y++) {
+         eachCell(new Point(x, y));
+      }
+      if(finishedRow != null) {
+        finishedRow(x);
+      }
+    }
+  }
+
+  final xCount, yCount;
+  List _neighbours;
+  Map _field;
+}
+
+/**
+* The game updates the [grid] in each step using the [Rule].
+*/
+class Game {
+  Game(this.grid);
+
+  tick() {
+    var newGrid = createNewGrid();
+
+    grid.iterate((point) {
+      var rule = new Rule(grid.get(point));
+      rule.reactToNeighbours(grid.countLiveNeighbours(point));
+      newGrid.set(point, rule.cellState);
+    });
+
+    grid = newGrid;
+  }
+
+  createNewGrid() => new Grid(grid.xCount, grid.yCount);
+
+  printGrid() => print(grid.print());
+
+  Grid grid;
+}
+
+main() {
+  // Run the GoL with a blinker.
+  runBlinker();
+}
+
+runBlinker() {
+  var game = new Game(createBlinkerGrid());
+
+  for(int i = 0; i < 3; i++) {
+    game.printGrid();
+    game.tick();
+  }
+  game.printGrid();
+}
+
+createBlinkerGrid() {
+  var grid = new Grid(4, 4);
+  loadBlinker(grid);
+  return grid;
+}
+
+loadBlinker(grid) => blinkerPoints().forEach((point) => grid.set(point, State.ALIVE));
+
+blinkerPoints() => [new Point(0, 1), new Point(1, 1), new Point(2, 1)];
diff --git a/Task/Conways-Game-of-Life/Dart/conways-game-of-life-2.dart b/Task/Conways-Game-of-Life/Dart/conways-game-of-life-2.dart
new file mode 100644
index 0000000000..ea098326fa
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Dart/conways-game-of-life-2.dart
@@ -0,0 +1,98 @@
+#import('/lib/unittest/unittest.dart');
+
+main() {
+  group('rules', () {
+    test('should let living but lonely cell die', () {
+      var rule = new Rule(State.ALIVE);
+      rule.reactToNeighbours(1);
+      expect(rule.cellState, State.DEAD);
+    });
+    test('should let proper cell live on', () {
+      var rule = new Rule(State.ALIVE);
+      rule.reactToNeighbours(2);
+      expect(rule.cellState, State.ALIVE);
+    });
+    test('should let dead cell with three neighbours be reborn', () {
+      var rule = new Rule(State.DEAD);
+      rule.reactToNeighbours(3);
+      expect(rule.cellState, State.ALIVE);
+    });
+    test('should let living cell with too many neighbours die', () {
+      var rule = new Rule(State.ALIVE);
+      rule.reactToNeighbours(4);
+      expect(rule.cellState, State.DEAD);
+    });
+  });
+
+  group('grid', () {
+    var origin = new Point(0, 0);
+    test('should have state', () {
+      var grid = new Grid(1, 1);
+      expect(grid.get(origin), State.DEAD);
+      grid.set(origin, State.ALIVE);
+      expect(grid.get(origin), State.ALIVE);
+    });
+    test('should have dimension', () {
+      var grid = new Grid(2, 3);
+      expect(grid.get(origin), State.DEAD);
+      grid.set(origin, State.ALIVE);
+      expect(grid.get(origin), State.ALIVE);
+      expect(grid.get(new Point(1, 2)), State.DEAD);
+      grid.set(new Point(1, 2), State.ALIVE);
+      expect(grid.get(new Point(1, 2)), State.ALIVE);
+    });
+    test('should be endless', () {
+      var grid = new Grid(2, 4);
+      grid.set(new Point(2, 4), State.ALIVE);
+      expect(grid.get(origin), State.ALIVE);
+      grid.set(new Point(-1, -1), State.ALIVE);
+      expect(grid.get(new Point(1, 3)), State.ALIVE);
+    });
+    test('should print itself', () {
+      var grid = new Grid(1, 2);
+      grid.set(new Point(0, 1), State.ALIVE);
+      expect(grid.print(), " #\n");
+    });
+  });
+
+  group('game', () {
+    test('should exists', () {
+     var game = new Game(null);
+     expect(game, isNotNull);
+    });
+    test('should create a new grid when ticked', () {
+      var grid = new Grid(1, 1);
+      var game = new Game(grid);
+      game.tick();
+      expect(game.grid !== grid);
+    });
+    test('should have a grid with the same dimension after tick', (){
+      var game = new Game(new Grid(2, 3));
+      game.tick();
+      expect(game.grid.xCount, 2);
+      expect(game.grid.yCount, 3);
+    });
+    test('should apply rules to middle cell', (){
+      var grid = new Grid(3, 3);
+      grid.set(new Point(1, 1), State.ALIVE);
+      var game = new Game(grid);
+      game.tick();
+      expect(game.grid.get(new Point(1, 1)), State.DEAD);
+
+      grid.set(new Point(0, 0), State.ALIVE);
+      grid.set(new Point(1, 0), State.ALIVE);
+      game = new Game(grid);
+      game.tick();
+      expect(game.grid.get(new Point(1, 1)), State.ALIVE);
+    });
+    test('should apply rules to all cells', (){
+      var grid = new Grid(3, 3);
+      grid.set(new Point(0, 1), State.ALIVE);
+      grid.set(new Point(1, 0), State.ALIVE);
+      grid.set(new Point(1, 1), State.ALIVE);
+      var game = new Game(grid);
+      game.tick();
+      expect(game.grid.get(new Point(0, 0)), State.ALIVE);
+    });
+  });
+}
diff --git a/Task/Conways-Game-of-Life/E/conways-game-of-life.e b/Task/Conways-Game-of-Life/E/conways-game-of-life.e
new file mode 100644
index 0000000000..80e79439d4
--- /dev/null
+++ b/Task/Conways-Game-of-Life/E/conways-game-of-life.e
@@ -0,0 +1,61 @@
+def gridWidth := 3
+def gridHeight := 3
+def X := 0..!gridWidth
+def Y := 0..!gridHeight
+
+def makeFlexList := 
+def makeGrid() {
+  def storage := makeFlexList.fromType(, gridWidth * gridHeight)
+  storage.setSize(gridWidth * gridHeight)
+
+  def grid {
+    to __printOn(out) {
+      for y in Y {
+        out.print("[")
+        for x in X {
+          out.print(grid[x, y].pick("#", " "))
+        }
+        out.println("]")
+      }
+    }
+    to get(xb :int, yb :int) {
+      return if (xb =~ x :X && yb =~ y :Y) {
+        storage[y * gridWidth + x]
+      } else {
+        false
+      }
+    }
+    to put(x :X, y :Y, c :boolean) {
+      storage[y * gridWidth + x] := c
+    }
+  }
+  return grid
+}
+
+def mooreNeighborhood := [[-1,-1],[0,-1],[1,-1],[-1,0],[1,0],[-1,1],[0,1],[1,1]]
+def computeNextLife(prevGrid, nextGrid) {
+  for y in Y {
+    for x in X {
+      var neighbors := 0
+      for [nx, ny] ? (prevGrid[x+nx, y+ny]) in mooreNeighborhood {
+        neighbors += 1
+      }
+      def self := prevGrid[x, y]
+      nextGrid[x, y] := (self && neighbors == 2 || neighbors == 3)
+    }
+  }
+}
+
+var currentFrame := makeGrid()
+var nextFrame := makeGrid()
+currentFrame[1, 0] := true
+currentFrame[1, 1] := true
+currentFrame[1, 2] := true
+
+for _ in 1..3 {
+  def frame := nextFrame
+  computeNextLife(currentFrame, frame)
+  nextFrame := currentFrame
+  currentFrame := frame
+  println(currentFrame)
+}
diff --git a/Task/Conways-Game-of-Life/Erlang/conways-game-of-life.erl b/Task/Conways-Game-of-Life/Erlang/conways-game-of-life.erl
new file mode 100644
index 0000000000..605fa95ce8
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Erlang/conways-game-of-life.erl
@@ -0,0 +1,206 @@
+-module(life).
+
+-export([bang/1]).
+
+
+-define(CHAR_DEAD,   32).  % " "
+-define(CHAR_ALIVE, 111).  % "o"
+-define(CHAR_BAR,    45).  % "-"
+
+-define(GEN_INTERVAL, 100).
+
+
+-record(state, {x            :: non_neg_integer()
+               ,y            :: non_neg_integer()
+               ,n            :: pos_integer()
+               ,bar          :: nonempty_string()
+               ,board        :: array()
+               ,gen_count    :: pos_integer()
+               ,gen_duration :: non_neg_integer()
+               ,print_time   :: non_neg_integer()
+               }).
+
+
+%% ============================================================================
+%% API
+%% ============================================================================
+
+bang(Args) ->
+    [X, Y] = [atom_to_integer(A) || A <- Args],
+    {Time, Board} = timer:tc(fun() -> init_board(X, Y) end),
+    State = #state{x            = X
+                  ,y            = Y
+                  ,n            = X * Y
+                  ,bar          = [?CHAR_BAR || _ <- lists:seq(1, X)]
+                  ,board        = Board
+                  ,gen_count    = 1  % Consider inital state to be generation 1
+                  ,gen_duration = Time
+                  ,print_time   = 0  % There was no print time yet
+    },
+    life_loop(State).
+
+
+%% ============================================================================
+%% Internal
+%% ============================================================================
+
+life_loop(
+    #state{x            = X
+          ,y            = Y
+          ,n            = N
+          ,bar          = Bar
+          ,board        = Board
+          ,gen_count    = GenCount
+          ,gen_duration = Time
+          ,print_time   = LastPrintTime
+    }=State) ->
+
+    {PrintTime, ok} = timer:tc(
+        fun() ->
+            do_print_screen(Board, Bar, X, Y, N, GenCount, Time, LastPrintTime)
+        end
+    ),
+
+    {NewTime, NewBoard} = timer:tc(
+        fun() ->
+            next_generation(X, Y, Board)
+        end
+    ),
+
+    NewState = State#state{board        = NewBoard
+                          ,gen_count    = GenCount + 1
+                          ,gen_duration = NewTime
+                          ,print_time   = PrintTime
+    },
+
+    NewTimeMil = NewTime / 1000,
+    NextGenDelay = at_least_zero(round(?GEN_INTERVAL - NewTimeMil)),
+    timer:sleep(NextGenDelay),
+
+    life_loop(NewState).
+
+
+at_least_zero(Integer) when Integer >= 0 -> Integer;
+at_least_zero(_) -> 0.
+
+
+do_print_screen(Board, Bar, X, Y, N, GenCount, Time, PrintTime) ->
+    ok = do_print_status(Bar, X, Y, N, GenCount, Time, PrintTime),
+    ok = do_print_board(Board).
+
+
+do_print_status(Bar, X, Y, N, GenCount, TimeMic, PrintTimeMic) ->
+    TimeSec = TimeMic / 1000000,
+    PrintTimeSec = PrintTimeMic / 1000000,
+    ok = io:format("~s~n", [Bar]),
+    ok = io:format(
+        "X: ~b Y: ~b CELLS: ~b GENERATION: ~b DURATION: ~f PRINT TIME: ~f~n",
+        [X, Y, N, GenCount, TimeSec, PrintTimeSec]
+    ),
+    ok = io:format("~s~n", [Bar]).
+
+
+do_print_board(Board) ->
+    % It seems that just doing a fold should be faster than map + to_list
+    % combo, but, after measuring several times, map + to_list has been
+    % consistently (nearly twice) faster than either foldl or foldr.
+    RowStrings = array:to_list(
+        array:map(
+            fun(_, Row) ->
+                array:to_list(
+                    array:map(
+                        fun(_, State) ->
+                            state_to_char(State)
+                        end,
+                        Row
+                    )
+                )
+            end,
+            Board
+        )
+    ),
+
+    ok = lists:foreach(
+        fun(RowString) ->
+            ok = io:format("~s~n", [RowString])
+        end,
+        RowStrings
+    ).
+
+
+state_to_char(0) -> ?CHAR_DEAD;
+state_to_char(1) -> ?CHAR_ALIVE.
+
+
+next_generation(W, H, Board) ->
+    array:map(
+        fun(Y, Row) ->
+            array:map(
+                fun(X, State) ->
+                    Neighbors = filter_offsides(H, W, neighbors(X, Y)),
+                    States = neighbor_states(Board, Neighbors),
+                    LiveNeighbors = lists:sum(States),
+                    new_state(State, LiveNeighbors)
+                end,
+                Row
+            )
+        end,
+        Board
+    ).
+
+
+new_state(1, LiveNeighbors) when LiveNeighbors  <  2 -> 0;
+new_state(1, LiveNeighbors) when LiveNeighbors  <  4 -> 1;
+new_state(1, LiveNeighbors) when LiveNeighbors  >  3 -> 0;
+new_state(0, LiveNeighbors) when LiveNeighbors =:= 3 -> 1;
+new_state(State, _LiveNeighbors) -> State.
+
+
+neighbor_states(Board, Neighbors) ->
+    [array:get(X, array:get(Y, Board)) || {X, Y} <- Neighbors].
+
+
+filter_offsides(H, W, Coordinates) ->
+    [{X, Y} || {X, Y} <- Coordinates, is_onside(X, Y, H, W)].
+
+
+is_onside(X, Y, H, W) when (X >= 0) and (Y >= 0) and (X < W) and (Y < H) -> true;
+is_onside(_, _, _, _) -> false.
+
+
+neighbors(X, Y) ->
+    [{X + OffX, Y + OffY} || {OffX, OffY} <- offsets()].
+
+
+offsets() ->
+    [offset(D) || D <- directions()].
+
+
+offset('N')  -> { 0, -1};
+offset('NE') -> { 1, -1};
+offset('E')  -> { 1,  0};
+offset('SE') -> { 1,  1};
+offset('S')  -> { 0,  1};
+offset('SW') -> {-1,  1};
+offset('W')  -> {-1,  0};
+offset('NW') -> {-1, -1}.
+
+
+directions() ->
+    ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'].
+
+
+init_board(X, Y) ->
+    array:map(fun(_, _) -> init_row(X) end, array:new(Y)).
+
+
+init_row(X) ->
+    array:map(fun(_, _) -> init_cell_state() end, array:new(X)).
+
+
+init_cell_state() ->
+    crypto:rand_uniform(0, 2).
+
+
+atom_to_integer(Atom) ->
+    list_to_integer(atom_to_list(Atom)).
diff --git a/Task/Conways-Game-of-Life/Forth/conways-game-of-life.fth b/Task/Conways-Game-of-Life/Forth/conways-game-of-life.fth
new file mode 100644
index 0000000000..336512c5d3
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Forth/conways-game-of-life.fth
@@ -0,0 +1,79 @@
+ \ The fast wrapping requires dimensions that are powers of 2.
+ 1 6 lshift constant w \ 64
+ 1 4 lshift constant h \ 16
+
+ : rows    w * 2* ;
+ 1 rows constant row
+ h rows constant size
+
+ create world size allot
+ world   value old
+ old w + value new
+
+ variable gens
+ : clear  world size erase     0 gens ! ;
+ : age  new old to new to old  1 gens +! ;
+
+ : col+  1+ ;
+ : col-  1- dup w and + ; \ avoid borrow into row
+ : row+  row + ;
+ : row-  row - ;
+ : wrap ( i -- i ) [ size w - 1- ] literal and ;
+ : w@ ( i -- 0/1 ) wrap old + c@ ;
+ : w! ( 0/1 i -- ) wrap old + c! ;
+
+ : foreachrow ( xt -- )
+   size 0 do  I over execute  row +loop drop ;
+
+ : showrow ( i -- ) cr
+   old + w over + swap do I c@ if [char] * else bl then emit loop ;
+ : show  ['] showrow foreachrow  cr ." Generation " gens @ . ;
+
+ : sum-neighbors ( i -- i n )
+   dup  col- row- w@
+   over      row- w@ +
+   over col+ row- w@ +
+   over col-      w@ +
+   over col+      w@ +
+   over col- row+ w@ +
+   over      row+ w@ +
+   over col+ row+ w@ + ;
+ : gencell ( i -- )
+   sum-neighbors  over old + c@
+   or 3 = 1 and   swap new + c! ;
+ : genrow ( i -- )
+   w over + swap do I gencell loop ;
+ : gen  ['] genrow foreachrow  age ;
+
+ : life  begin gen 0 0 at-xy show key? until ;
+
+ \ patterns
+ char | constant '|'
+ : pat ( i addr len -- )
+   rot dup 2swap  over + swap do
+     I c@ '|' = if drop row+ dup else
+     I c@ bl  = 1+ over w!  col+ then
+   loop 2drop ;
+
+ : blinker s" ***" pat ;
+ : toad s" ***| ***" pat ;
+ : pentomino s" **| **| *" pat ;
+ : pi s" **| **|**" pat ;
+ : glider s"  *|  *|***" pat ;
+ : pulsar s" *****|*   *" pat ;
+ : ship s"  ****|*   *|    *|   *" pat ;
+ : pentadecathalon s" **********" pat ;
+ : clock s"  *|  **|**|  *" pat ;
+
+ clear  0 glider show
+  *
+   *
+ ***
+
+ Generation 0  ok
+ gen show
+
+ * *
+  **
+  *
+ Generation 1  ok
diff --git a/Task/Conways-Game-of-Life/Fortran/conways-game-of-life.f b/Task/Conways-Game-of-Life/Fortran/conways-game-of-life.f
new file mode 100644
index 0000000000..7880dcaace
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Fortran/conways-game-of-life.f
@@ -0,0 +1,74 @@
+ PROGRAM LIFE_2D
+   IMPLICIT NONE
+
+   INTEGER, PARAMETER :: gridsize = 10
+   LOGICAL :: cells(0:gridsize+1,0:gridsize+1) = .FALSE.
+   INTEGER :: i, j, generation=0
+   REAL :: rnums(gridsize,gridsize)
+
+ !  Start patterns
+ !  **************
+ !  cells(2,1:3) = .TRUE.                                                  ! Blinker
+ !  cells(3,4:6) = .TRUE. ; cells(4,3:5) = .TRUE.                          ! Toad
+ !  cells(1,2) = .TRUE. ; cells(2,3) = .TRUE. ; cells(3,1:3) = .TRUE.      ! Glider
+    cells(3:5,3:5) = .TRUE. ; cells(6:8,6:8) = .TRUE.                      ! Figure of Eight
+ !  CALL RANDOM_SEED
+ !  CALL RANDOM_NUMBER(rnums)
+ !  WHERE (rnums>0.6) cells(1:gridsize,1:gridsize) = .TRUE.                ! Random universe
+
+   CALL Drawgen(cells(1:gridsize, 1:gridsize), generation)
+   DO generation = 1, 8
+      CALL Nextgen(cells)
+      CALL Drawgen(cells(1:gridsize, 1:gridsize), generation)
+   END DO
+
+ CONTAINS
+
+   SUBROUTINE Drawgen(cells, gen)
+     LOGICAL, INTENT(IN OUT) :: cells(:,:)
+     INTEGER, INTENT(IN) :: gen
+
+     WRITE(*, "(A,I0)") "Generation ", gen
+     DO i = 1, SIZE(cells,1)
+        DO j = 1, SIZE(cells,2)
+           IF (cells(i,j)) THEN
+              WRITE(*, "(A)", ADVANCE = "NO") "#"
+           ELSE
+              WRITE(*, "(A)", ADVANCE = "NO") " "
+           END IF
+        END DO
+        WRITE(*,*)
+     END DO
+     WRITE(*,*)
+   END SUBROUTINE Drawgen
+
+  SUBROUTINE Nextgen(cells)
+     LOGICAL, INTENT(IN OUT) :: cells(0:,0:)
+     LOGICAL :: buffer(0:SIZE(cells, 1)-1, 0:SIZE(cells, 2)-1)
+     INTEGER :: neighbours, i, j
+
+     buffer = cells   ! Store current status
+     DO i = 1, SIZE(cells, 1)-2
+        DO j = 1, SIZE(cells, 2)-2
+          if(buffer(i, j)) then
+            neighbours = sum(count(buffer(i-1:i+1, j-1:j+1), 1)) - 1
+          else
+            neighbours = sum(count(buffer(i-1:i+1, j-1:j+1), 1))
+          end if
+
+          SELECT CASE(neighbours)
+            CASE (0:1, 4:8)
+               cells(i,j) = .FALSE.
+
+            CASE (2)
+               ! No change
+
+            CASE (3)
+               cells(i,j) = .TRUE.
+          END SELECT
+
+        END DO
+     END DO
+  END SUBROUTINE Nextgen
+
+ END PROGRAM LIFE_2D
diff --git a/Task/Conways-Game-of-Life/Go/conways-game-of-life.go b/Task/Conways-Game-of-Life/Go/conways-game-of-life.go
new file mode 100644
index 0000000000..cb1b7d2bfa
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Go/conways-game-of-life.go
@@ -0,0 +1,83 @@
+package main
+
+import "fmt"
+
+const (
+    rows  = 3
+    cols  = 3
+    empty = '·' // middle dot
+    alive = '*'
+    start = "···***···"
+    sz    = (rows + 2) * (cols + 2)
+)
+
+var (
+    cs = make([]rune, sz)
+    ns = make([]int, sz)
+    nb [8]int
+)
+
+func main() {
+    // initialize empty (really we just need the border)
+    for i := range cs {
+        cs[i] = empty
+    }
+    // initialize start
+    si := []rune(start)
+    for row := 1; row <= rows; row++ {
+        for col := 1; col <= cols; col++ {
+            cs[row*(cols+2)+col] = si[(row-1)*cols+col-1]
+        }
+    }
+    // initialize neighbor offsets
+    for i := 0; i < 3; i++ {
+        nb[i] = i - cols - 3
+        nb[i+3] = i + cols + 1
+    }
+    nb[6] = -1
+    nb[7] = 1
+    // run
+    printU()
+    for g := 0; g < 3; g++ {
+        genU()
+        printU()
+    }
+}
+
+func genU() {
+    // compute n
+    for row := 1; row <= rows; row++ {
+        for col := 1; col <= cols; col++ {
+            cx := row*(cols+2) + col
+            n := 0
+            for _, d := range nb {
+                if cs[cx+d] == '*' {
+                    n++
+                }
+            }
+            ns[cx] = n
+        }
+    }
+    // update c
+    for row := 1; row <= rows; row++ {
+        for col := 1; col <= cols; col++ {
+            cx := row*(cols+2) + col
+            if cs[cx] == '*' {
+                switch ns[cx] {
+                case 0, 1, 4, 5, 6, 7, 8:
+                    cs[cx] = '·'
+                }
+            } else if ns[cx] == 3 {
+                cs[cx] = '*'
+            }
+        }
+    }
+}
+
+func printU() {
+    fmt.Println("")
+    for row := 1; row <= rows; row++ {
+        cx := row*(cols+2) + 1
+        fmt.Println(string(cs[cx : cx+cols]))
+    }
+}
diff --git a/Task/Conways-Game-of-Life/Haskell/conways-game-of-life-1.hs b/Task/Conways-Game-of-Life/Haskell/conways-game-of-life-1.hs
new file mode 100644
index 0000000000..2dac608f20
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Haskell/conways-game-of-life-1.hs
@@ -0,0 +1,22 @@
+import Data.Array.Unboxed
+
+type Grid = UArray (Int,Int) Bool
+ -- The grid is indexed by (y, x).
+
+life :: Int -> Int -> Grid -> Grid
+{- Returns the given Grid advanced by one generation. -}
+life w h old =
+    listArray b (map f (range b))
+  where b@((y1,x1),(y2,x2)) = bounds old
+        f (y, x) = ( c && (n == 2 || n == 3) ) || ( not c && n == 3 )
+          where c = get x y
+                n = count [get (x + x') (y + y') |
+                    x' <- [-1, 0, 1], y' <- [-1, 0, 1],
+                    not (x' == 0 && y' == 0)]
+
+        get x y | x < x1 || x > x2 = False
+                | y < y1 || y > y2 = False
+                | otherwise       = old ! (y, x)
+
+count :: [Bool] -> Int
+count = length . filter id
diff --git a/Task/Conways-Game-of-Life/Haskell/conways-game-of-life-2.hs b/Task/Conways-Game-of-Life/Haskell/conways-game-of-life-2.hs
new file mode 100644
index 0000000000..e3013c86ff
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Haskell/conways-game-of-life-2.hs
@@ -0,0 +1,40 @@
+import Data.List (unfoldr)
+
+grid :: [String] -> (Int, Int, Grid)
+grid l = (width, height, a)
+  where (width, height) = (length $ head l, length l)
+        a = listArray ((1, 1), (height, width)) $ concatMap f l
+        f = map g
+        g '.' = False
+        g _   = True
+
+printGrid :: Int -> Grid -> IO ()
+printGrid width = mapM_ f . split width . elems
+  where f = putStrLn . map g
+        g False = '.'
+        g _     = '#'
+
+split :: Int -> [a] -> [[a]]
+split n = takeWhile (not . null) . unfoldr (Just . splitAt n)
+
+blinker = grid
+   [".#.",
+    ".#.",
+    ".#."]
+
+glider = grid
+   ["............",
+    "............",
+    "............",
+    ".......###..",
+    ".......#....",
+    "........#...",
+    "............"]
+
+printLife :: Int -> (Int, Int, Grid) -> IO ()
+printLife n (w, h, g) = mapM_ f $ take n $ iterate (life w h) g
+  where f g = do
+            putStrLn "------------------------------"
+            printGrid w g
+
+main = printLife 10 glider
diff --git a/Task/Conways-Game-of-Life/Haskell/conways-game-of-life-3.hs b/Task/Conways-Game-of-Life/Haskell/conways-game-of-life-3.hs
new file mode 100644
index 0000000000..28e5224093
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Haskell/conways-game-of-life-3.hs
@@ -0,0 +1,43 @@
+module Main where
+import Data.List
+
+lifeStep :: [(Int, Int)] -> [(Int, Int)]
+lifeStep cells = [head g | g <- grouped cells, viable g]
+  where grouped = group . sort . concatMap neighbors
+        neighbors (x, y) = [(x+dx, y+dy) | dx <- [-1..1], dy <- [-1..1], (dx,dy) /= (0,0)]
+        viable [_,_,_] = True
+        viable [c,_] = c `elem` cells
+        viable _ = False
+
+
+showWorld :: [(Int, Int)] -> IO ()
+showWorld cells = mapM_ putStrLn $ worldToGrid cells
+  where worldToGrid cells = [[cellChar (x, y) | x <- [least..greatest]] | y <- [least..greatest]]
+        cellChar cell = if cell `elem` cells then '#' else '.'
+        (least, greatest) = worldBounds cells
+
+worldBounds cells = (least, greatest)
+  where least = min x y
+        greatest = max x' y'
+        (x, y) = head cells
+        (x', y') = last cells
+
+runLife :: Int -> [(Int, Int)] -> IO ()
+runLife steps cells = rec (steps - 1) cells
+  where rec 0 cells = showWorld cells
+        rec s cells = do showWorld cells
+                         putStrLn ""
+                         rec (s - 1) $ lifeStep cells
+
+glider = [(1, 0), (2, 1), (0, 2), (1, 2), (2, 2)]
+blinker = [(1, 0), (1, 1), (1, 2)]
+
+main :: IO ()
+main = do
+  putStrLn "Glider >> 10"
+  putStrLn "------------"
+  runLife 10 glider
+  putStrLn ""
+  putStrLn "Blinker >> 3"
+  putStrLn "------------"
+  runLife 3 blinker
diff --git a/Task/Conways-Game-of-Life/Java/conways-game-of-life.java b/Task/Conways-Game-of-Life/Java/conways-game-of-life.java
new file mode 100644
index 0000000000..e5c820c75f
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Java/conways-game-of-life.java
@@ -0,0 +1,91 @@
+public class GameOfLife{
+	public static void main(String[] args){
+		String[] dish= {
+				"_#_",
+				"_#_",
+				"_#_",};
+		int gens= 3;
+		for(int i= 0;i < gens;i++){
+			System.out.println("Generation " + i + ":");
+			print(dish);
+			dish= life(dish);
+		}
+	}
+
+	public static String[] life(String[] dish){
+		String[] newGen= new String[dish.length];
+		for(int row= 0;row < dish.length;row++){//each row
+			newGen[row]= "";
+			for(int i= 0;i < dish[row].length();i++){//each char in the row
+				String above= "";//neighbors above
+				String same= "";//neighbors in the same row
+				String below= "";//neighbors below
+				if(i == 0){//all the way on the left
+					//no one above if on the top row
+					//otherwise grab the neighbors from above
+					above= (row == 0) ? null : dish[row - 1].substring(i,
+									i + 2);
+					same= dish[row].substring(i + 1, i + 2);
+					//no one below if on the bottom row
+					//otherwise grab the neighbors from below
+					below= (row == dish.length - 1) ? null : dish[row + 1]
+									.substring(i, i + 2);
+				}else if(i == dish[row].length() - 1){//right
+					//no one above if on the top row
+					//otherwise grab the neighbors from above
+					above= (row == 0) ? null : dish[row - 1].substring(i - 1,
+									i + 1);
+					same= dish[row].substring(i - 1, i);
+					//no one below if on the bottom row
+					//otherwise grab the neighbors from below
+					below= (row == dish.length - 1) ? null : dish[row + 1]
+									.substring(i - 1, i + 1);
+				}else{//anywhere else
+					//no one above if on the top row
+					//otherwise grab the neighbors from above
+					above= (row == 0) ? null : dish[row - 1].substring(i - 1,
+									i + 2);
+					same= dish[row].substring(i - 1, i)
+									+ dish[row].substring(i + 1, i + 2);
+					//no one below if on the bottom row
+					//otherwise grab the neighbors from below
+					below= (row == dish.length - 1) ? null : dish[row + 1]
+									.substring(i - 1, i + 2);
+				}
+				int neighbors= getNeighbors(above, same, below);
+				if(neighbors < 2 || neighbors > 3){
+					newGen[row]+= "_";//<2 or >3 neighbors -> die
+				}else if(neighbors == 3){
+					newGen[row]+= "#";//3 neighbors -> spawn/live
+				}else{
+					newGen[row]+= dish[row].charAt(i);//2 neighbors -> stay
+				}
+			}
+		}
+		return newGen;
+	}
+
+	public static int getNeighbors(String above, String same, String below){
+		int ans= 0;
+		if(above != null){//no one above
+			for(char x: above.toCharArray()){//each neighbor from above
+				if(x == '#') ans++;//count it if someone is here
+			}
+		}
+		for(char x: same.toCharArray()){//two on either side
+			if(x == '#') ans++;//count it if someone is here
+		}
+		if(below != null){//no one below
+			for(char x: below.toCharArray()){//each neighbor below
+				if(x == '#') ans++;//count it if someone is here
+			}
+		}
+		return ans;
+	}
+
+	public static void print(String[] dish){
+		for(String s: dish){
+			System.out.println(s);
+		}
+	}
+}
diff --git a/Task/Conways-Game-of-Life/JavaScript/conways-game-of-life-1.js b/Task/Conways-Game-of-Life/JavaScript/conways-game-of-life-1.js
new file mode 100644
index 0000000000..d7ee1ae3ce
--- /dev/null
+++ b/Task/Conways-Game-of-Life/JavaScript/conways-game-of-life-1.js
@@ -0,0 +1,99 @@
+function GameOfLife () {
+
+	this.init = function (turns,width,height) {
+		this.board = new Array(height);
+		for (var x = 0; x < height; x++) {
+			this.board[x] = new Array(width);
+			for (var y = 0; y < width; y++) {
+				this.board[x][y] = Math.round(Math.random());
+			}
+		}
+		this.turns = turns;
+	}
+
+	this.nextGen = function() {
+		this.boardNext = new Array(this.board.length);
+		for (var i = 0; i < this.board.length; i++) {
+			this.boardNext[i] = new Array(this.board[i].length);
+		}
+		for (var x = 0; x < this.board.length; x++) {
+			for (var y = 0; y < this.board[x].length; y++) {
+				var n = 0;
+				for (var dx = -1; dx <= 1; dx++) {
+					for (var dy = -1; dy <= 1; dy++) {
+						if ( dx == 0 && dy == 0){}
+						else if (typeof this.board[x+dx] !== 'undefined'
+								&& typeof this.board[x+dx][y+dy] !== 'undefined'
+								&& this.board[x+dx][y+dy]) {
+							n++;
+						}
+					}	
+				}
+				var c = this.board[x][y];
+				switch (n) {
+					case 0:
+					case 1:
+						c = 0;
+						break;
+					case 2:
+						break;
+					case 3:
+						c = 1;
+						break;
+					default:
+						c = 0;
+				}
+				this.boardNext[x][y] = c;
+			}
+		}
+		this.board = this.boardNext.slice();
+	}
+
+	this.print = function() {
+		for (var x = 0; x < this.board.length; x++) {
+			var l = "";
+			for (var y = 0; y < this.board[x].length; y++) {
+				if (this.board[x][y])
+					l += "X";
+				else
+					l += " ";
+			}
+			print(l);
+		}
+	}
+
+	this.start = function() {
+		for (var t = 0; t < this.turns; t++) {
+			print("---\nTurn "+(t+1));
+			this.print();
+			this.nextGen()
+		}
+	}
+
+}
+
+
+var game = new GameOfLife();
+
+print("---\n3x3 Blinker over three turns.");
+game.init(3);
+game.board = [
+	[0,0,0],
+	[1,1,1],
+	[0,0,0]];
+game.start();
+
+print("---\n10x6 Glider over five turns.");
+game.init(5);
+game.board = [
+	[0,0,0,0,0,0,0,0,0,0],
+	[0,0,1,0,0,0,0,0,0,0],
+	[0,0,0,1,0,0,0,0,0,0],
+	[0,1,1,1,0,0,0,0,0,0],
+	[0,0,0,0,0,0,0,0,0,0],
+	[0,0,0,0,0,0,0,0,0,0]];
+game.start();
+
+print("---\nRandom 5x10");
+game.init(5,5,10);
+game.start();
diff --git a/Task/Conways-Game-of-Life/JavaScript/conways-game-of-life-2.js b/Task/Conways-Game-of-Life/JavaScript/conways-game-of-life-2.js
new file mode 100644
index 0000000000..88f5ebd35e
--- /dev/null
+++ b/Task/Conways-Game-of-Life/JavaScript/conways-game-of-life-2.js
@@ -0,0 +1,151 @@
+
+	
+		
+		
+	
+	
+		3x3 Blinker
+ + No canvas support found! +

+ 6x6 Glider
+ + No canvas support found! +

+ 8x8 Random
+ + No canvas support found! +
+ + diff --git a/Task/Conways-Game-of-Life/Lua/conways-game-of-life.lua b/Task/Conways-Game-of-Life/Lua/conways-game-of-life.lua new file mode 100644 index 0000000000..3c90d5fb99 --- /dev/null +++ b/Task/Conways-Game-of-Life/Lua/conways-game-of-life.lua @@ -0,0 +1,51 @@ +function Evolve( cell ) + local m = #cell + local cell2 = {} + for i = 1, m do + cell2[i] = {} + for j = 1, m do + cell2[i][j] = cell[i][j] + end + end + + for i = 1, m do + for j = 1, m do + local count + if cell2[i][j] == 0 then count = 0 else count = -1 end + for x = -1, 1 do + for y = -1, 1 do + if i+x >= 1 and i+x <= m and j+y >= 1 and j+y <= m and cell2[i+x][j+y] == 1 then count = count + 1 end + end + end + if count < 2 or count > 3 then cell[i][j] = 0 end + if count == 3 then cell[i][j] = 1 end + end + end + + return cell +end + + +m = 3 -- number rows / colums +num_iterations = 10 + +cell = {} +for i = 1, m do + cell[i] = {} + for j = 1, m do + cell[i][j] = 0 + end +end + +cell[2][2], cell[2][1], cell[2][3] = 1, 1, 1 + +for l = 1, num_iterations do + for i = 1, m do + for j = 1, m do + if cell[i][j] == 1 then io.write( "#" ) else io.write( " " ) end + end + io.write( "\n" ) + end + + cell = Evolve( cell ) +end diff --git a/Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-1.m b/Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-1.m new file mode 100644 index 0000000000..4b10a05285 --- /dev/null +++ b/Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-1.m @@ -0,0 +1 @@ +life diff --git a/Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-2.m b/Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-2.m new file mode 100644 index 0000000000..a80c72c83b --- /dev/null +++ b/Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-2.m @@ -0,0 +1 @@ +open(fullfile(matlabroot, 'toolbox', 'matlab', 'demos', 'life.m')) diff --git a/Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-3.m b/Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-3.m new file mode 100644 index 0000000000..378494836b --- /dev/null +++ b/Task/Conways-Game-of-Life/MATLAB/conways-game-of-life-3.m @@ -0,0 +1,10 @@ +function GoL(S, N) % + colormap copper; whitebg('black'); + G= round(rand(S)); + A = [S 1:S-1]; B = [2:S 1]; + for k=1:N + Sum = G(A,:)+G(B,:)+G(:,B)+G(:,A)+G(A,B)+G(A,A)+G(B,B)+G(B,A); + G = double((G & (Sum == 2)) | (Sum == 3)); + surf(G); view([0 90]); pause(0.001) + end +end diff --git a/Task/Conways-Game-of-Life/Perl/conways-game-of-life-1.pl b/Task/Conways-Game-of-Life/Perl/conways-game-of-life-1.pl new file mode 100644 index 0000000000..635d213469 --- /dev/null +++ b/Task/Conways-Game-of-Life/Perl/conways-game-of-life-1.pl @@ -0,0 +1,59 @@ +my ($width, $height, $generations) = @ARGV; + +my $printed; + +sub generate { + (map + {[ (map { rand () < 0.5 } 1 .. $width), 0 ]} + 1 .. $height), + [(0) x ($width + 1)]; +} + +sub nexgen { + my @prev = map {[@$_]} @_; + my @new = map {[ (0) x ($width + 1) ]} 0 .. $height; + foreach my $row ( 0 .. $height - 1 ) { + foreach my $col ( 0 .. $width - 1 ) { + my $val = + $prev[ $row - 1 ][ $col - 1 ] + + $prev[ $row - 1 ][ $col ] + + $prev[ $row - 1 ][ $col + 1 ] + + $prev[ $row ][ $col - 1 ] + + $prev[ $row ][ $col + 1 ] + + $prev[ $row + 1 ][ $col - 1 ] + + $prev[ $row + 1 ][ $col ] + + $prev[ $row + 1 ][ $col + 1 ]; + $new[$row][$col] = + ( $prev[$row][$col] && $val == 2 || $val == 3 ); + } + } + return @new; +} + +sub printlife { + my @life = @_; + if ($printed) { + # Move the cursor up to print over prior generation. + print "\e[1A" x $height; + } + $printed = 1; + foreach my $row ( 0 .. $height - 1 ) { + foreach my $col ( 0 .. $width - 1 ) { + print($life[$row][$col] + ? "\e[33;45;1m \e[0m" + : "\e[1;34;1m \e[0m"); + } + print "\n"; + } +} + +my @life = generate; +print "Start\n"; +printlife @life; +foreach my $stage ( 1 .. $generations ) { + sleep 1; + print "Generation $stage\n\e[1A"; + @life = nexgen @life; + printlife @life; +} +print "\n"; diff --git a/Task/Conways-Game-of-Life/Perl/conways-game-of-life-2.pl b/Task/Conways-Game-of-Life/Perl/conways-game-of-life-2.pl new file mode 100644 index 0000000000..cbcae01f28 --- /dev/null +++ b/Task/Conways-Game-of-Life/Perl/conways-game-of-life-2.pl @@ -0,0 +1,32 @@ +my $w = `tput cols` - 1; +my $h = `tput lines` - 1; +my $r = "\033[H"; + +my @universe = map([ map(rand(1) < .1, 1 .. $w) ], 1 .. $h); +sub iterate { + my @new = map([ map(0, 1 .. $w) ], 1 .. $h); + for my $i (0 .. $h - 1) { + for my $j (0 .. $w - 1) { + my $neighbor = 0; + for ( [-1, -1], [-1, 0], [-1, 1], + [ 0, -1], [ 0, 1], + [ 1, -1], [ 1, 0], [ 1, 1] ) + { + my $y = $_->[0] + $i; + my $x = $_->[1] + $j; + $neighbor += $universe[$y % $h][$x % $w]; + last if $neighbor > 3; + } + + $new[$i][$j] = $universe[$i][$j] + ? ($neighbor == 2 or $neighbor == 3) + : $neighbor == 3; + }} + @universe = @new; +} + +while(1) { + print $r; + print map((map($_ ? "#" : " ", @$_), "\n"), @universe); + iterate; +} diff --git a/Task/Conways-Game-of-Life/PicoLisp/conways-game-of-life.l b/Task/Conways-Game-of-Life/PicoLisp/conways-game-of-life.l new file mode 100644 index 0000000000..77fe652a22 --- /dev/null +++ b/Task/Conways-Game-of-Life/PicoLisp/conways-game-of-life.l @@ -0,0 +1,30 @@ +(load "@lib/simul.l") + +(de life (DX DY . Init) + (let Grid (grid DX DY) + (for This Init + (=: life T) ) + (loop + (disp Grid NIL + '((This) (if (: life) "X " " ")) ) + (wait 1000) + (for Col Grid + (for This Col + (let N # Count neighbors + (cnt + '((Dir) (get (Dir This) 'life)) + (quote + west east south north + ((X) (south (west X))) + ((X) (north (west X))) + ((X) (south (east X))) + ((X) (north (east X))) ) ) + (=: next # Next generation + (if (: life) + (>= 3 N 2) + (= N 3) ) ) ) ) ) + (for Col Grid # Update + (for This Col + (=: life (: next)) ) ) ) ) ) + +(life 5 5 b3 c3 d3) diff --git a/Task/Conways-Game-of-Life/Prolog/conways-game-of-life.pro b/Task/Conways-Game-of-Life/Prolog/conways-game-of-life.pro new file mode 100644 index 0000000000..cfb891aff0 --- /dev/null +++ b/Task/Conways-Game-of-Life/Prolog/conways-game-of-life.pro @@ -0,0 +1,179 @@ +%----------------------------------------------------------------------% +% GAME OF LIFE % +% % +% Adapt the prediacte grid_size according to the grid size of the % +% start pic. % +% Modify the number of generations. % +% Run PROLOG and type '[gol].' to compile the source file. % +% Create a subfolder where your gol.pl resides and place % +% your initial PBM '0.0000.pbm' inside . % +% You need to adjust the number of zeros after . The % +% sequence of zeros after '0.' must be as long as the number of % +% generations. This is important to obtain a propper animation. % +% (Maybe someone knows a better solution for this) % +% Start PROLOG and run % +% % +% cellular('.//'). % +% % +% Inside run the following shell command % +% % +% convert -delay 25 -loop 0 * .gif % +% % +%----------------------------------------------------------------------% + +%----------------------------------------------------------------------% +% Special thanks to René Thiemann improving the runtime performance. % +%----------------------------------------------------------------------% + +% Size of the 2D grid +grid_size(300). +% Number of generations +generations(1000). + +%----------------------------------------------------------------------% +% Main procedure: generate n generations of life and store each file. % +% cellular( +File path ) % +%----------------------------------------------------------------------% +cellular(I) :- + grid_size(GS), + string_concat(I,'0.0000.pbm',I1), + read_pbm(I1,GS,M), + cellular_(I,M,GS,1), !. + +cellular_(I,M,GS,N) :- + N1 is N+1, + format(atom(N0),'~4d',N), + string_concat(I,N0,I1), + string_concat(I1,'.pbm',I2), + step(M,M1), + write_pbm(M1,GS,I2), !, + cellular_(I,M1,GS,N1). +cellular_(_,_,_,GE) :- + generations(GE),!. + +%----------------------------------------------------------------------% +% Apply the Game Of Life rule set to every cell. % +% step( +OldMatrix, +NewMatrix ) % +% % +% ss | s | ... | s ss ... step_ss % +% ----+---+-----+--- s ... step_s % +% ii | i | ... | i ii ... step_ii % +% ----+---+-----+--- i ... step_i % +% : | : | : | : ee ... step_ee % +% ----+---+-----+--- e ... step_e % +% ii | i | ... | i % +% ----+---+-----+--- % +% ee | e | ... | e % +% % +%----------------------------------------------------------------------% +step([R1,R2|M],[H|T]) :- + step_ss(R1,R2,H), !, + step_([R1,R2|M],T). + +step_([R1,R2,R3|M],[H|T]) :- + step_ii(R1,R2,R3,H), + step_([R2,R3|M],T), !. +step_([R1,R2],[H]) :- + step_ee(R1,R2,H). + +% Start case +step_ss([A1,A2|R1],[B1,B2|R2],[H|T]) :- + rule([0,0,0],[0,A1,A2],[0,B1,B2],H), + step_s([A1,A2|R1],[B1,B2|R2],T). +step_s([A1,A2,A3|R1],[B1,B2,B3|R2],[H|T]) :- + rule([0,0,0],[A1,A2,A3],[B1,B2,B3],H), + step_s([A2,A3|R1],[B2,B3|R2],T). +step_s([A1,A2],[B1,B2],[H]) :- + rule([0,0,0],[A1,A2,0],[B1,B2,0],H). + +% Immediate case +step_ii([A1,A2|R1],[B1,B2|R2],[C1,C2|R3],[H|T]) :- + rule([0,A1,A2],[0,B1,B2],[0,C1,C2],H), + step_i([A1,A2|R1],[B1,B2|R2],[C1,C2|R3],T). +step_i([A1,A2,A3|R1],[B1,B2,B3|R2],[C1,C2,C3|R3],[H|T]) :- + rule([A1,A2,A3],[B1,B2,B3],[C1,C2,C3],H), + step_i([A2,A3|R1],[B2,B3|R2],[C2,C3|R3],T). +step_i([A1,A2],[B1,B2],[C1,C2],[H]) :- + rule([A1,A2,0],[B1,B2,0],[C1,C2,0],H). + +% End case +step_ee([A1,A2|R1],[B1,B2|R2],[H|T]) :- + rule([0,A1,A2],[0,B1,B2],[0,0,0],H), + step_e([A1,A2|R1],[B1,B2|R2],T). +step_e([A1,A2,A3|R1],[B1,B2,B3|R2],[H|T]) :- + rule([A1,A2,A3],[B1,B2,B3],[0,0,0],H), + step_e([A2,A3|R1],[B2,B3|R2],T). +step_e([A1,A2],[B1,B2],[H]) :- + rule([A1,A2,0],[B1,B2,0],[0,0,0],H). + +%----------------------------------------------------------------------% +% o Any dead cell with exactly three live neighbours becomes a live % +% cell, as if by reproduction. % +% o Any other dead cell remains dead. % +% o Any live cell with fewer than two live neighbours dies, as if % +% caused by under-population. % +% o Any live cell with two or three live neighbours lives on to the % +% next generation. % +% o Any live cell with more than three live neighbours dies, as if by % +% overcrowding. % +% % +% [Source: Wikipedia] % +%----------------------------------------------------------------------% +rule([A,B,C],[D,0,F],[G,H,I],1) :- A+B+C+D+F+G+H+I =:= 3. +rule([_,_,_],[_,0,_],[_,_,_],0). +rule([A,B,C],[D,1,F],[G,H,I],0) :- A+B+C+D+F+G+H+I < 2. +rule([A,B,C],[D,1,F],[G,H,I],1) :- A+B+C+D+F+G+H+I =:= 2. +rule([A,B,C],[D,1,F],[G,H,I],1) :- A+B+C+D+F+G+H+I =:= 3. +rule([A,B,C],[D,1,F],[G,H,I],0) :- A+B+C+D+F+G+H+I > 3. + +%----------------------------------------------------------------------% +% Read a 2bit Protable Bitmap into a GS x GS 2-dimensional list. % +% read_pbm( +File path, +Grid size, -List 2D ) % +%----------------------------------------------------------------------% +read_pbm(F,GS,M) :- + open(F,read,S), + skip(S,10), + skip(S,10), + get(S,C), + read_file(S,C,L), + nest(L,GS,M), + close(S). + +read_file(S,C,[CHR|T]) :- + CHR is C-48, + get(S,NC), + read_file(S,NC,T). +read_file(_,-1,[]) :- !. + +%----------------------------------------------------------------------% +% Morph simple list into a 2-dimensional one with size GS x GS % +% nest( ?List simple, ?Grid size, ?2D list ) % +%----------------------------------------------------------------------% +nest(L,GS,[H|T]) :- + length(H,GS), + append(H,S,L), + nest(S,GS,T). +nest(L,GS,[L]) :- + length(L,S), + S =< GS, !. + +%----------------------------------------------------------------------% +% Write a GS x GS 2-dimensional list into a 2bit Protable Bitmap. % +% write_pbm( +List 2D, +Grid size, +File path ) % +%----------------------------------------------------------------------% +write_pbm(L,GS,F) :- + open(F,write,S), + write(S,'P1'), nl(S), + write(S,GS), put(S,' '), write(S,GS), nl(S), + write_file(S,L), + close(S). + +write_file(S,[H|T]) :- + write_line(S,H), nl(S), + write_file(S,T). +write_file(_,[]) :- !. + +write_line(S,[H|T]) :- + write(S,H), put(S,' '), + write_line(S,T). +write_line(_,[]) :- !. diff --git a/Task/Conways-Game-of-Life/Python/conways-game-of-life-1.py b/Task/Conways-Game-of-Life/Python/conways-game-of-life-1.py new file mode 100644 index 0000000000..22927c3aeb --- /dev/null +++ b/Task/Conways-Game-of-Life/Python/conways-game-of-life-1.py @@ -0,0 +1,55 @@ +import random +from collections import defaultdict + +printdead, printlive = '-#' +maxgenerations = 3 +cellcount = 3,3 +celltable = defaultdict(int, { + (1, 2): 1, + (1, 3): 1, + (0, 3): 1, + } ) # Only need to populate with the keys leading to life + +## +## Start States +## +# blinker +u = universe = defaultdict(int) +u[(1,0)], u[(1,1)], u[(1,2)] = 1,1,1 + +## toad +#u = universe = defaultdict(int) +#u[(5,5)], u[(5,6)], u[(5,7)] = 1,1,1 +#u[(6,6)], u[(6,7)], u[(6,8)] = 1,1,1 + +## glider +#u = universe = defaultdict(int) +#maxgenerations = 16 +#u[(5,5)], u[(5,6)], u[(5,7)] = 1,1,1 +#u[(6,5)] = 1 +#u[(7,6)] = 1 + +## random start +#universe = defaultdict(int, +# # array of random start values +# ( ((row, col), random.choice((0,1))) +# for col in range(cellcount[0]) +# for row in range(cellcount[1]) +# ) ) # returns 0 for out of bounds + +for i in range(maxgenerations): + print "\nGeneration %3i:" % ( i, ) + for row in range(cellcount[1]): + print " ", ''.join(str(universe[(row,col)]) + for col in range(cellcount[0])).replace( + '0', printdead).replace('1', printlive) + nextgeneration = defaultdict(int) + for row in range(cellcount[1]): + for col in range(cellcount[0]): + nextgeneration[(row,col)] = celltable[ + ( universe[(row,col)], + -universe[(row,col)] + sum(universe[(r,c)] + for r in range(row-1,row+2) + for c in range(col-1, col+2) ) + ) ] + universe = nextgeneration diff --git a/Task/Conways-Game-of-Life/Python/conways-game-of-life-2.py b/Task/Conways-Game-of-Life/Python/conways-game-of-life-2.py new file mode 100644 index 0000000000..0686a22a16 --- /dev/null +++ b/Task/Conways-Game-of-Life/Python/conways-game-of-life-2.py @@ -0,0 +1,29 @@ +from collections import defaultdict + +glider = [(1, 0), (2, 1), (0, 2), (1, 2), (2, 2)] +blinker = [(1, 0), (1, 1), (1, 2)] + +def neighbors(cell): + x,y = cell + r = range(-1,2) + return [(x+dx, y+dy) for dx in r for dy in r if not (dx, dy) == (0, 0)] + +def frequencies(cells): + res = defaultdict(int) + for cell in cells: + res[cell] += 1 + return res + +def lifeStep(cells): + freqs = frequencies(n for c in cells for n in neighbors(c)) + return [k for k in freqs if freqs[k]==3 or (freqs[k]==2 and k in cells)] + +def printWorld(cells, worldSize=10): + for y in range(0, worldSize): + print ["#" if (x, y) in cells else "." for x in range(0, worldSize)] + +def runLife(worldSize, steps, cells): + printWorld(cells, worldSize) + print "" + if 0 < steps: + runLife(worldSize, steps-1, lifeStep(cells)) diff --git a/Task/Conways-Game-of-Life/R/conways-game-of-life.r b/Task/Conways-Game-of-Life/R/conways-game-of-life.r new file mode 100644 index 0000000000..ef10a58737 --- /dev/null +++ b/Task/Conways-Game-of-Life/R/conways-game-of-life.r @@ -0,0 +1,82 @@ +# Generates a new board - either a random one, sample blinker or gliders, or user specified. +gen.board <- function(type="random", nrow=3, ncol=3, seeds=NULL) +{ + if(type=="random") + { + return(matrix(runif(nrow*ncol) > 0.5, nrow=nrow, ncol=ncol)) + } else if(type=="blinker") + { + seeds <- list(c(2,1),c(2,2),c(2,3)) + } else if(type=="glider") + { + seeds <- list(c(1,2),c(2,3),c(3,1), c(3,2), c(3,3)) + } + board <- matrix(FALSE, nrow=nrow, ncol=ncol) + for(k in seq_along(seeds)) + { + board[seeds[[k]][1],seeds[[k]][2]] <- TRUE + } + board +} + +# Returns the number of living neighbours to a location +count.neighbours <- function(x,i,j) +{ + sum(x[max(1,i-1):min(nrow(x),i+1),max(1,j-1):min(ncol(x),j+1)]) - x[i,j] +} + +# Implements the rulebase +determine.new.state <- function(board, i, j) +{ + N <- count.neighbours(board,i,j) + (N == 3 || (N ==2 && board[i,j])) +} + +# Generates the next interation of the board from the existing one +evolve <- function(board) +{ + newboard <- board + for(i in seq_len(nrow(board))) + { + for(j in seq_len(ncol(board))) + { + newboard[i,j] <- determine.new.state(board,i,j) + } + } + newboard +} + +# Plays the game. By default, the board is shown in a plot window, though output to the console if possible. +game.of.life <- function(board, nsteps=50, timebetweensteps=0.25, graphicaloutput=TRUE) +{ + if(!require(lattice)) stop("lattice package could not be loaded") + nr <- nrow(board) + + for(i in seq_len(nsteps)) + { + if(graphicaloutput) + { + print(levelplot(t(board[nr:1,]), colorkey=FALSE)) + } else print(board) + + Sys.sleep(timebetweensteps) + + newboard <- evolve(board) + + if(all(newboard==board)) + { + message("board is static") + break + } else if(sum(newboard) < 1) + { + message("everything is dead") + break + } else board <- newboard + } + invisible(board) +} + +# Example usage +game.of.life(gen.board("blinker")) +game.of.life(gen.board("glider", 18, 20)) +game.of.life(gen.board(, 50, 50)) diff --git a/Task/Conways-Game-of-Life/REXX/conways-game-of-life.rexx b/Task/Conways-Game-of-Life/REXX/conways-game-of-life.rexx new file mode 100644 index 0000000000..92930e832a --- /dev/null +++ b/Task/Conways-Game-of-Life/REXX/conways-game-of-life.rexx @@ -0,0 +1,70 @@ +/*REXX program displays Conway's game of life. + ┌───────────────────────────elided version─────────────────────────┐ + ├─── full version has many more options and enhanced displays. ────┤ + └──────────────────────────────────────────────────────────────────┘ */ +signal on syntax; signal on novalue /*handle REXX program errors. */ +signal on halt /*handle cell growth interruptus.*/ +parse arg peeps '(' generations rows cols bare! life! clearscreen every repeats +@abc='abcdefghijklmnopqrstuvwxyz'; @abcU=@abc; upper @abcU + blank = 'BLANK' +generations = p(generations 100) + rows = p(rows 3) + cols = p(cols 3) + bare! = pickchar(bare! blank) +clearscreen = p(clearscreen 0) + every = p(every 999999999) + life! = pickchar(life! '☼') + repeats = p(repeats 2) +fents=max(79,cols) /*fence width shown after display*/ +#repeats=0; $.=bare! /*the universe is new, and barren*/ +gens=abs(generations) /*use this for convenience. */ +x=space(peeps) /*remove superfluous spaces. */ +if x=='' then x='2,1 2,2 2,3' + + do while x \=='' + parse var x p x; parse var p r ',' c .; $.r=overlay(life!,$.r,c+1) + end +life=0; !.=0; call showCells /*show initial state of the cells*/ +/*─────────────────────────────────────watch cell colony grow/live/die. */ + do life=1 for gens + do r=1 for rows; rank=bare! + do c=2 for cols; ?=substr($.r,c,1); ??=?; n=neighbors() + select /*select da quickest choice first*/ + when ?==bare! then if n==3 then ??=life! + otherwise if n<2 | n>3 then ??=bare! + end /*select*/ + rank=rank || ?? + end /*c*/ + @.r=rank + end /*c*/ + + do r=1 for rows; $.r=@.r; end /*assign alternate cells ──► real*/ + if life//every==0 | generations>0 | life==gens then call showCells + end /*life*/ +/*─────────────────────────────────────stop watching the universe (life)*/ +halt: cycles=life-1; if cycles\==gens then say 'REXX program interrupted.' +exit /*stick a fork in it, we're done.*/ +/*───────────────────────────────SHOWCELLS subroutine─-─────────────────*/ +showCells: if clearscreen then 'CLS' /* ◄─── change this for your OS.*/ +_=; do r=rows by -1 for rows /*show the forest in proper order*/ + z=strip(substr($.r,2),'T') /*pick off the meat of the row. */ + say z; _=_ || z /*be neat about trailing blanks. */ + end /*r*/ +say right(copies('═',fents)life,fents) /*show&tell for a stand of trees.*/ +if _=='' then exit /*if no life, then stop the run. */ +if !._ then #repeats=#repeats+1 /*we detected a repeated pattern.*/ +!._=1 /*assign a state & compare later.*/ +if repeats\==0 & #repeats<=repeats then return /*so far, so good. */ +say '"Life" repeated itself' repeats "times, program is stopping." +exit /*stick a fork in it, we're done.*/ +/*───────────────────────────────NEIGHBORS subroutine───────────────────*/ +neighbors: rp=r+1; cp=c+1; rm=r-1; cm=c-1 /*count 8 neighbors of a cell*/ +return (substr($.rm,cm,1)==life!) + (substr($.rm,c ,1)==life!) + , + (substr($.rm,cp,1)==life!) + (substr($.r ,cm,1)==life!) + , + (substr($.r ,cp,1)==life!) + (substr($.rp,cm,1)==life!) + , + (substr($.rp,c ,1)==life!) + (substr($.rp,cp,1)==life!) +/*───────────────────────────────1-liner subroutines────────────────────*/ +err: say;say;say center(' error! ',max(40,linesize()%2),"*");say;do j=1 for arg();say arg(j);say;end;say;exit 13 +novalue: syntax: call err 'REXX program' condition('C') "error",condition('D'),'REXX source statement (line' sigl"):",sourceline(sigl) +pickchar: _=p(arg(1));if translate(_)==blank then _=' ';if length(_) ==3 then _=d2c(_);if length(_) ==2 then _=x2c(_);return _ +p: return word(arg(1),1) diff --git a/Task/Conways-Game-of-Life/Racket/conways-game-of-life.rkt b/Task/Conways-Game-of-Life/Racket/conways-game-of-life.rkt new file mode 100644 index 0000000000..72df08f970 --- /dev/null +++ b/Task/Conways-Game-of-Life/Racket/conways-game-of-life.rkt @@ -0,0 +1,132 @@ +#lang racket +(require 2htdp/image + 2htdp/universe) + +;;; +;;; Grid object +;;; + +(define (make-empty-grid m n) + (build-vector m (lambda (y) (make-vector n 0)))) + +(define rows vector-length) + +(define (cols grid) + (vector-length (vector-ref grid 0))) + +(define (make-grid m n living-cells) + (let loop ((grid (make-empty-grid m n)) + (cells living-cells)) + (if (empty? cells) + grid + (loop (2d-set! grid (caar cells) (cadar cells) 1) (cdr cells))))) + +(define (2d-ref grid i j) + (cond ((< i 0) 0) + ((< j 0) 0) + ((>= i (rows grid)) 0) + ((>= j (cols grid)) 0) + ((vector-ref (vector-ref grid i) j)))) + +(define (2d-refs grid indices) + (map (lambda (ind) (2d-ref grid (car ind) (cadr ind))) indices)) + +(define (2d-set! grid i j val) + (begin + (vector-set! (vector-ref grid i) j val) + grid)) + +;;; cartesian product of 2 lists +(define (cart l1 l2) + (if (empty? l1) + '() + (append (let loop ((n (car l1)) (l l2)) + (if (empty? l) '() (cons (list n (car l)) (loop n (cdr l))))) + (cart (cdr l1) l2)))) + +;;; Count living cells in the neighbourhood +(define (n-count grid i j) + (- (apply + (2d-refs grid (cart (list (- i 1) i (+ i 1)) + (list (- j 1) j (+ j 1))))) + (2d-ref grid i j))) + +;;; +;;; Rules and updates of the grid +;;; + +;;; rules are stored in a 2d array: r_i,j = new state of a cell +;;; in state i with j neighboors +(define conway-rules + (list->vector (list (list->vector '(0 0 0 1 0 0 0 0 0)) + (list->vector '(0 0 1 1 0 0 0 0 0))))) + + +(define (next-state rules grid i j) + (let ((current (2d-ref grid i j)) + (N (n-count grid i j))) + (2d-ref rules current N))) + +(define (next-grid rules grid) + (let ((new-grid (make-empty-grid (rows grid) (cols grid)))) + (let loop ((i 0) + (j 0)) + (if (>= i (rows grid)) + new-grid + (if (>= j (cols grid)) + (loop (+ i 1) 0) + (begin (2d-set! new-grid i j (next-state rules grid i j)) + (loop i (+ j 1)))))))) + +(define (next-grid! rules grid) + (let ((new-grid (next-grid rules grid))) + (let loop ((i 0)) + (if (< i (rows grid)) + (begin (vector-set! grid i (vector-ref new-grid i)) + (loop (+ i 1))) + grid)))) + +;;; +;;; Image / Animation +;;; + +(define (grid->image grid) + (let ((m (rows grid)) + (n (cols grid)) + (size 5)) + (let loop ((img (rectangle (* m size) (* n size) "solid" "white")) + (i 0) + (j 0)) + (if (>= i (rows grid)) + img + (if (>= j (cols grid)) + (loop img (+ i 1) 0) + (if (= (2d-ref grid i j) 1) + (loop (underlay/xy img (* i (+ 1 size)) (* j (+ 1 size)) (square (- size 2) "solid" "black")) i (+ j 1)) + (loop img i (+ j 1)))))))) + + + +(define (game-of-life grid refresh_time) + (animate (lambda (n) (if (= (modulo n refresh_time) 0) + (grid->image (next-grid! conway-rules grid)) + (grid->image grid))))) + +;;; +;;; Examples +;;; + +(define (blinker) (make-grid 3 3 '((0 1) (1 1) (2 1)))) + +(define (thunder) (make-grid 70 50 '((30 19) (30 20) (30 21) (29 17) (30 17) (31 17)))) + +(define (cross) + (let loop ((i 0) + (l '())) + (if (>= i 80) + (make-grid 80 80 l) + (loop (+ i 1) (cons (list i i) (cons (list (- 79 i) i) l)))))) + +;;; To run examples: +;;; (game-of-life (blinker) 30) +;;; (game-of-life (thunder) 2) +;;; (game-of-life (cross) 2) diff --git a/Task/Conways-Game-of-Life/Ruby/conways-game-of-life-1.rb b/Task/Conways-Game-of-Life/Ruby/conways-game-of-life-1.rb new file mode 100644 index 0000000000..091d33881b --- /dev/null +++ b/Task/Conways-Game-of-Life/Ruby/conways-game-of-life-1.rb @@ -0,0 +1,66 @@ +def game_of_life(name, size, generations, initial_life=nil) + board = new_board size + seed board, size, initial_life + print_board board, 0, name + reason = generations.times do |gen| + new = evolve board, size + print_board new, gen+1, name + break :all_dead if barren? new, size + break :static if board == new + board = new + end + if reason == :all_dead then puts "no more life." + elsif reason == :static then puts "no movement" + else puts "specified lifetime ended" + end +end + +def new_board(n) + Array.new(n) {Array.new(n, 0)} +end + +def seed(board, n, points=nil) + if points.nil? + # randomly seed board + srand + indices = [] + n.times {|x| n.times {|y| indices << [x,y] }} + indices.shuffle[0,10].each {|x,y| board[y][x] = 1} + else + points.each {|x, y| board[y][x] = 1} + end +end + +def evolve(board, n) + new = new_board n + n.times {|i| n.times {|j| new[i][j] = fate board, i, j, n}} + new +end + +def fate(board, i, j, n) + i1 = [0, i-1].max; i2 = [i+1, n-1].min + j1 = [0, j-1].max; j2 = [j+1, n-1].min + sum = 0 + for ii in (i1..i2) + for jj in (j1..j2) + sum += board[ii][jj] if not (ii == i and jj == j) + end + end + (sum == 3 or (sum == 2 and board[i][j] == 1)) ? 1 : 0 +end + +def barren?(board, n) + n.times {|i| n.times {|j| return false if board[i][j] == 1}} + true +end + +def print_board(m, generation, name) + puts "#{name}: generation #{generation}" + m.each {|row| row.each {|val| print "#{val == 1 ? '#' : '.'} "}; puts} + puts +end + + +game_of_life "blinker", 3, 2, [[1,0],[1,1],[1,2]] +#game_of_life "glider", 4, 4, [[1,0],[2,1],[0,2],[1,2],[2,2]] +#game_of_life "random", 5, 10 diff --git a/Task/Conways-Game-of-Life/Ruby/conways-game-of-life-2.rb b/Task/Conways-Game-of-Life/Ruby/conways-game-of-life-2.rb new file mode 100644 index 0000000000..74ed9fabcf --- /dev/null +++ b/Task/Conways-Game-of-Life/Ruby/conways-game-of-life-2.rb @@ -0,0 +1,148 @@ +class Game + def initialize(name, size, generations, initial_life=nil) + @board = GameBoard.new size, initial_life + @board.display 0, name + + reason = generations.times do |gen| + new_board = evolve + new_board.display gen+1, name + break :all_dead if new_board.barren? + break :static if @board == new_board + @board = new_board + end + + if reason == :all_dead then puts "No more life." + elsif reason == :static then puts "No movement." + else puts "Specified lifetime ended." + end + end + + def evolve + new_board = GameBoard.new @board.size, @board.life + @board.size.times do |i| + @board.size.times do |j| + if cell_fate i, j + new_board[i,j].live + else + new_board[i,j].die + end + end + end + new_board + end + + def cell_fate(i, j) + left = [0, i-1].max; right = [i+1, @board.size-1].min + top = [0, j-1].max; bottom = [j+1, @board.size-1].min + sum = 0 + for x in (left..right) + for y in (top..bottom) + sum += @board[x,y].value if (x != i or y != j) + end + end + (sum == 3 or (sum == 2 and @board[i,j].alive?)) + end +end + +class GameBoard + attr_reader :size + + def initialize(size, initial_life=nil) + @size = size + @board = Array.new(size) {Array.new(size) {Cell.new false}} + self.seed_board initial_life + end + + def seed_board(life) + if life.nil? + # randomly seed board + srand # seed the random number generator + indices = [] + @size.times {|x| @size.times {|y| indices << [x,y] }} + indices.shuffle[0,10].each {|x,y| @board[y][x].live} + else + life.each {|x, y| @board[y][x].live} + end + end + + def [](x, y) + @board[y][x] + end + + def ==(board) + self.life == board.life + end + + def barren? + @size.times do |i| + @size.times do |j| + return false if @board[i][j].alive? + end + end + true + end + + def life + indices = [] + @size.times do |x| + @size.times do |y| + if @board[y][x].alive? + indices << [x,y] + end + end + end + indices + end + + def display(generation, name) + puts "#{name}: generation #{generation}" + @board.each do |row| + row.each do |cell| + print "#{cell.alive? ? '#' : '.'} " + end + puts + end + puts + end + + def apocalypse + # utility function to entirely clear the game board + @board.each do |row| + row.each do |cell| + if cell.alive? + cell.die + end + end + end + end +end + +class Cell + def initialize is_alive + @is_alive = is_alive + end + + def alive? + @is_alive + end + + def value + if self.alive? + return 1 + else + return 0 + end + end + + def live + @is_alive = true + end + + def die + @is_alive = false + end +end + +game_of_life = Game.new "blinker", 3, 2, [[1,0],[1,1],[1,2]] +game_of_life = Game.new "glider", 4, 4, [[1,0],[2,1],[0,2],[1,2],[2,2]] +game_of_life = Game.new "random", 5, 10 diff --git a/Task/Conways-Game-of-Life/Scheme/conways-game-of-life.ss b/Task/Conways-Game-of-Life/Scheme/conways-game-of-life.ss new file mode 100644 index 0000000000..81c4614591 --- /dev/null +++ b/Task/Conways-Game-of-Life/Scheme/conways-game-of-life.ss @@ -0,0 +1,89 @@ +;;An R6RS Scheme implementation of Conway's Game of Life --- assumes +;;all cells outside the defined grid are dead + +;if n is outside bounds of list, return 0 else value at n +(define (nth n lst) + (cond ((> n (length lst)) 0) + ((< n 1) 0) + ((= n 1) (car lst)) + (else (nth (- n 1) (cdr lst))))) + +;return the next state of the supplied universe +(define (next-universe universe) + ;value at (x, y) + (define (cell x y) + (if (list? (nth y universe)) + (nth x (nth y universe)) + 0)) + ;sum of the values of the cells surrounding (x, y) + (define (neighbor-sum x y) + (+ (cell (- x 1) (- y 1)) + (cell (- x 1) y) + (cell (- x 1) (+ y 1)) + (cell x (- y 1)) + (cell x (+ y 1)) + (cell (+ x 1) (- y 1)) + (cell (+ x 1) y) + (cell (+ x 1) (+ y 1)))) + ;next state of the cell at (x, y) + (define (next-cell x y) + (let ((cur (cell x y)) + (ns (neighbor-sum x y))) + (cond ((and (= cur 1) + (or (< ns 2) (> ns 3))) + 0) + ((and (= cur 0) (= ns 3)) + 1) + (else cur)))) + ;next state of row n + (define (row n out) + (let ((w (length (car universe)))) + (if (= (length out) w) + out + (row n + (cons (next-cell (- w (length out)) n) + out))))) + ;a range of ints from bot to top + (define (int-range bot top) + (if (> bot top) '() + (cons bot (int-range (+ bot 1) top)))) + (map (lambda (n) + (row n '())) + (int-range 1 (length universe)))) + +;represent the universe as a string +(define (universe->string universe) + (define (prettify row) + (apply string-append + (map (lambda (b) + (if (= b 1) "#" "-")) + row))) + (if (null? universe) + "" + (string-append (prettify (car universe)) + "\n" + (universe->string (cdr universe))))) + +;starting with seed, show reps states of the universe +(define (conway seed reps) + (when (> reps 0) + (display (universe->string seed)) + (newline) + (conway (next-universe seed) (- reps 1)))) + +;; --- Example Universes --- ;; + +;blinker in a 3x3 universe +(conway '((0 1 0) + (0 1 0) + (0 1 0)) 5) + +;glider in an 8x8 universe +(conway '((0 0 1 0 0 0 0 0) + (0 0 0 1 0 0 0 0) + (0 1 1 1 0 0 0 0) + (0 0 0 0 0 0 0 0) + (0 0 0 0 0 0 0 0) + (0 0 0 0 0 0 0 0) + (0 0 0 0 0 0 0 0) + (0 0 0 0 0 0 0 0)) 30) diff --git a/Task/Conways-Game-of-Life/Tcl/conways-game-of-life.tcl b/Task/Conways-Game-of-Life/Tcl/conways-game-of-life.tcl new file mode 100644 index 0000000000..efcfd0f5dd --- /dev/null +++ b/Task/Conways-Game-of-Life/Tcl/conways-game-of-life.tcl @@ -0,0 +1,79 @@ +package require Tcl 8.5 + +proc main {} { + evolve 3 blinker [initialize_tableau {3 3} {{0 1} {1 1} {2 1}}] + evolve 5 glider [initialize_tableau {4 4} {{0 1} {1 2} {2 0} {2 1} {2 2}}] +} + +proc evolve {generations name tableau} { + for {set gen 1} {$gen <= $generations} {incr gen} { + puts "$name generation $gen:" + print $tableau + set tableau [next_generation $tableau] + } + puts "" +} + +proc initialize_tableau {size initial_life} { + lassign $size ::max_x ::max_y + set tableau [blank_tableau] + foreach point $initial_life { + lset tableau {*}$point 1 + } + return $tableau +} + +proc blank_tableau {} { + return [lrepeat $::max_x [lrepeat $::max_y 0]] +} + +proc print {tableau} { + foreach row $tableau {puts [string map {0 . 1 #} [join $row]]} +} + +proc next_generation {tableau} { + set new [blank_tableau] + for {set x 0} {$x < $::max_x} {incr x} { + for {set y 0} {$y < $::max_y} {incr y} { + lset new $x $y [fate [list $x $y] $tableau] + } + } + return $new +} + +proc fate {point tableau} { + set current [value $point $tableau] + set neighbours [sum_neighbours $point $tableau] + return [expr {($neighbours == 3) || ($neighbours == 2 && $current == 1)}] +} + +proc value {point tableau} { + return [lindex $tableau {*}$point] +} + +proc sum_neighbours {point tableau} { + set sum 0 + foreach neighbour [get_neighbours $point] { + incr sum [value $neighbour $tableau] + } + return $sum +} + +proc get_neighbours {point} { + lassign $point x y + set results [list] + foreach x_off {-1 0 1} { + foreach y_off {-1 0 1} { + if { ! ($x_off == 0 && $y_off == 0)} { + set i [expr {$x + $x_off}] + set j [expr {$y + $y_off}] + if {(0 <= $i && $i < $::max_x) && (0 <= $j && $j < $::max_y)} { + lappend results [list $i $j] + } + } + } + } + return $results +} + +main diff --git a/Task/Count-in-factors/0DESCRIPTION b/Task/Count-in-factors/0DESCRIPTION new file mode 100644 index 0000000000..4711b24a51 --- /dev/null +++ b/Task/Count-in-factors/0DESCRIPTION @@ -0,0 +1,7 @@ +Write a program which counts up from 1, displaying each number as the multiplication of its prime factors. For the purpose of this task, 1 may be shown as itself. + +For examle, 2 is prime, so it would be shown as itself. 6 is not prime; it would be shown as 2\times3. Likewise, 2144 is not prime; it would be shown as 2\times2\times2\times2\times2\times67. + +c.f. [[Prime decomposition]] + +[[:Category:Prime_Numbers]] diff --git a/Task/Count-in-factors/Ada/count-in-factors.ada b/Task/Count-in-factors/Ada/count-in-factors.ada new file mode 100644 index 0000000000..560a84c10e --- /dev/null +++ b/Task/Count-in-factors/Ada/count-in-factors.ada @@ -0,0 +1,61 @@ +with Ada.Command_Line; +with Ada.Text_IO; + +procedure Count is + type Number_List is array (Positive range <>) of Positive; + + function Decompose (N : Natural) return Number_List is + Size : Natural := 0; + M : Natural := N; + K : Natural := 2; + begin + if N = 1 then + return (1 => 1); + end if; + -- Estimation of the result length from above + while M >= 2 loop + M := (M + 1) / 2; + Size := Size + 1; + end loop; + M := N; + -- Filling the result with prime numbers + declare + Result : Number_List (1 .. Size); + Index : Positive := 1; + begin + while N >= K loop -- Divisors loop + while 0 = (M mod K) loop -- While divides + Result (Index) := K; + Index := Index + 1; + M := M / K; + end loop; + K := K + 1; + end loop; + return Result (1 .. Index - 1); + end; + end Decompose; + + procedure Put (List : Number_List) is + begin + for Index in List'Range loop + Ada.Text_IO.Put (Integer'Image (List (Index))); + if Index /= List'Last then + Ada.Text_IO.Put (" x"); + end if; + end loop; + end Put; + + N : Natural := 1; + Max_N : Natural := 15; +begin + if Ada.Command_Line.Argument_Count = 1 then + Max_N := Integer'Value (Ada.Command_Line.Argument (1)); + end if; + loop + Ada.Text_IO.Put (Integer'Image (N) & ": "); + Put (Decompose (N)); + Ada.Text_IO.New_Line; + N := N + 1; + exit when N > Max_N; + end loop; +end Count; diff --git a/Task/Count-in-factors/AutoHotkey/count-in-factors.ahk b/Task/Count-in-factors/AutoHotkey/count-in-factors.ahk new file mode 100644 index 0000000000..84ede11f52 --- /dev/null +++ b/Task/Count-in-factors/AutoHotkey/count-in-factors.ahk @@ -0,0 +1,17 @@ +factorize(n){ + if n = 1 + return 1 + if n < 1 + return false + result := 0, m := n, k := 2 + While n >= k{ + while !Mod(m, k){ + result .= " * " . k, m /= k + } + k++ + } + return SubStr(result, 5) +} +Loop 22 + out .= A_Index ": " factorize(A_index) "`n" +MsgBox % out diff --git a/Task/Count-in-factors/BBC-BASIC/count-in-factors.bbc b/Task/Count-in-factors/BBC-BASIC/count-in-factors.bbc new file mode 100644 index 0000000000..466b72f19b --- /dev/null +++ b/Task/Count-in-factors/BBC-BASIC/count-in-factors.bbc @@ -0,0 +1,18 @@ + FOR i% = 1 TO 20 + PRINT i% " = " FNfactors(i%) + NEXT + END + + DEF FNfactors(N%) + LOCAL P%, f$ + IF N% = 1 THEN = "1" + P% = 2 + WHILE P% <= N% + IF (N% MOD P%) = 0 THEN + f$ += STR$(P%) + " x " + N% DIV= P% + ELSE + P% += 1 + ENDIF + ENDWHILE + = LEFT$(f$, LEN(f$) - 3) diff --git a/Task/Count-in-factors/C/count-in-factors.c b/Task/Count-in-factors/C/count-in-factors.c new file mode 100644 index 0000000000..7015bb1271 --- /dev/null +++ b/Task/Count-in-factors/C/count-in-factors.c @@ -0,0 +1,64 @@ +#include +#include + +typedef unsigned long long ULONG; + +ULONG get_prime(int idx) +{ + static long n_primes = 0, alloc = 0; + static ULONG *primes = 0; + ULONG last, p; + int i; + + if (idx >= n_primes) { + if (n_primes >= alloc) { + alloc += 16; /* be conservative */ + primes = realloc(primes, sizeof(ULONG) * alloc); + } + if (!n_primes) { + primes[0] = 2; + primes[1] = 3; + n_primes = 2; + } + + last = primes[n_primes-1]; + while (idx >= n_primes) { + last += 2; + for (i = 0; i < n_primes; i++) { + p = primes[i]; + if (p * p > last) { + primes[n_primes++] = last; + break; + } + if (last % p == 0) break; + } + } + } + return primes[idx]; +} + +int main() +{ + ULONG n, x, p; + int i, first; + + for (x = 1; ; x++) { + printf("%lld = ", n = x); + + for (i = 0, first = 1; ; i++) { + p = get_prime(i); + while (n % p == 0) { + n /= p; + if (!first) printf(" x "); + first = 0; + printf("%lld", p); + } + if (n <= p * p) break; + } + + if (first) printf("%lld\n", n); + else if (n > 1) printf(" x %lld\n", n); + else printf("\n"); + } + return 0; +} diff --git a/Task/Count-in-factors/CoffeeScript/count-in-factors.coffee b/Task/Count-in-factors/CoffeeScript/count-in-factors.coffee new file mode 100644 index 0000000000..2f0e5832e6 --- /dev/null +++ b/Task/Count-in-factors/CoffeeScript/count-in-factors.coffee @@ -0,0 +1,40 @@ +count_primes = (max) -> + # Count through the natural numbers and give their prime + # factorization. This algorithm uses no division. + # Instead, each prime number starts a rolling odometer + # to help subsequent factorizations. The algorithm works similar + # to the Sieve of Eratosthenes, as we note when each prime number's + # odometer rolls a digit. (As it turns out, as long as your computer + # is not horribly slow at division, you're better off just doing simple + # prime factorizations on each new n vs. using this algorithm.) + console.log "1 = 1" + primes = [] + n = 2 + while n <= max + factors = [] + for prime_odometer in primes + # digits are an array w/least significant digit in + # position 0; for example, [3, [0]] will roll as + # follows: + # [0] -> [1] -> [2] -> [0, 1] + [base, digits] = prime_odometer + i = 0 + while true + digits[i] += 1 + break if digits[i] < base + digits[i] = 0 + factors.push base + i += 1 + if i >= digits.length + digits.push 0 + + if factors.length == 0 + primes.push [n, [0, 1]] + factors.push n + console.log "#{n} = #{factors.join('*')}" + n += 1 + + primes.length + +num_primes = count_primes 10000 +console.log num_primes diff --git a/Task/Count-in-factors/Common-Lisp/count-in-factors-1.lisp b/Task/Count-in-factors/Common-Lisp/count-in-factors-1.lisp new file mode 100644 index 0000000000..d240d63b3a --- /dev/null +++ b/Task/Count-in-factors/Common-Lisp/count-in-factors-1.lisp @@ -0,0 +1,27 @@ +(defparameter *primes* + (make-array 10 :adjustable t :fill-pointer 0 :element-type 'integer)) + +(mapc #'(lambda (x) (vector-push x *primes*)) '(2 3 5 7)) + +(defun extend-primes (n) + (let ((p (+ 2 (elt *primes* (1- (length *primes*)))))) + (loop for i = p then (+ 2 i) + while (<= (* i i) n) do + (if (primep i t) (vector-push-extend i *primes*))))) + +(defun primep (n &optional skip) + (if (not skip) (extend-primes n)) + (if (= n 1) nil + (loop for p across *primes* while (<= (* p p) n) + never (zerop (mod n p))))) + +(defun factors (n) + (extend-primes n) + (loop with res for x across *primes* while (> n (* x x)) do + (loop while (zerop (rem n x)) do + (setf n (/ n x)) + (push x res)) + finally (return (if (> n 1) (cons n res) res)))) + +(loop for n from 1 do + (format t "~a: ~{~a~^ × ~}~%" n (reverse (factors n)))) diff --git a/Task/Count-in-factors/Common-Lisp/count-in-factors-2.lisp b/Task/Count-in-factors/Common-Lisp/count-in-factors-2.lisp new file mode 100644 index 0000000000..ce9927e8a2 --- /dev/null +++ b/Task/Count-in-factors/Common-Lisp/count-in-factors-2.lisp @@ -0,0 +1,9 @@ +(defun factors (n) + (loop with res for x from 2 to (isqrt n) do + (loop while (zerop (rem n x)) do + (setf n (/ n x)) + (push x res)) + finally (return (if (> n 1) (cons n res) res)))) + +(loop for n from 1 do + (format t "~a: ~{~a~^ × ~}~%" n (reverse (factors n)))) diff --git a/Task/Count-in-factors/D/count-in-factors-1.d b/Task/Count-in-factors/D/count-in-factors-1.d new file mode 100644 index 0000000000..0ecaa88265 --- /dev/null +++ b/Task/Count-in-factors/D/count-in-factors-1.d @@ -0,0 +1,22 @@ +int[] factorize(in int n) pure nothrow +in { + assert(n > 0); +} body { + if (n == 1) return [1]; + int[] result; + int m = n, k = 2; + while (n >= k) { + while (m % k == 0) { + result ~= k; + m /= k; + } + k++; + } + return result; +} + +void main() { + import std.stdio; + foreach (i; 1 .. 22) + writefln("%d: %(%d × %)", i, i.factorize()); +} diff --git a/Task/Count-in-factors/D/count-in-factors-2.d b/Task/Count-in-factors/D/count-in-factors-2.d new file mode 100644 index 0000000000..ab7f2f626d --- /dev/null +++ b/Task/Count-in-factors/D/count-in-factors-2.d @@ -0,0 +1,32 @@ +import std.stdio, std.math, std.conv, std.algorithm, + std.array, std.string, import xt.uiprimes; + +pragma(lib, "uiprimes.lib"); + +// function _factorize_ included in uiprimes.lib +ulong[] factorize(ulong n) { + if (n == 0) return []; + if (n == 1) return [1]; + ulong[] res; + uint limit = cast(uint)(1 + sqrt(n)); + foreach (p; Primes(limit)) { + if (n == 1) break; + if (0UL == (n % p)) + while((n > 1) && (0UL == (n % p ))) { + res ~= p; + n /= p; + } + } + if (n > 1) + res ~= [n]; + return res; +} + +string productStr(T)(in T[] nums) { + return nums.map!text().join(" x "); +} + +void main() { + foreach (i; 1 .. 21) + writefln("%2d = %s", i, productStr(factorize(i))); +} diff --git a/Task/Count-in-factors/DWScript/count-in-factors.dwscript b/Task/Count-in-factors/DWScript/count-in-factors.dwscript new file mode 100644 index 0000000000..a0aca4c7a9 --- /dev/null +++ b/Task/Count-in-factors/DWScript/count-in-factors.dwscript @@ -0,0 +1,18 @@ +function Factorize(n : Integer) : String; +begin + if n <= 1 then + Exit('1'); + var k := 2; + while n >= k do begin + while (n mod k) = 0 do begin + Result += ' * '+IntToStr(k); + n := n div k; + end; + Inc(k); + end; + Result:=SubStr(Result, 4); +end; + +var i : Integer; +for i := 1 to 22 do + PrintLn(IntToStr(i) + ': ' + Factorize(i)); diff --git a/Task/Count-in-factors/Euphoria/count-in-factors.euphoria b/Task/Count-in-factors/Euphoria/count-in-factors.euphoria new file mode 100644 index 0000000000..a2f83d9e8f --- /dev/null +++ b/Task/Count-in-factors/Euphoria/count-in-factors.euphoria @@ -0,0 +1,28 @@ +function factorize(integer n) + sequence result + integer k + if n = 1 then + return {1} + else + k = 2 + result = {} + while n > 1 do + while remainder(n, k) = 0 do + result &= k + n /= k + end while + k += 1 + end while + return result + end if +end function + +sequence factors +for i = 1 to 22 do + printf(1, "%d: ", i) + factors = factorize(i) + for j = 1 to length(factors)-1 do + printf(1, "%d * ", factors[j]) + end for + printf(1, "%d\n", factors[$]) +end for diff --git a/Task/Count-in-factors/Forth/count-in-factors.fth b/Task/Count-in-factors/Forth/count-in-factors.fth new file mode 100644 index 0000000000..514389c9b9 --- /dev/null +++ b/Task/Count-in-factors/Forth/count-in-factors.fth @@ -0,0 +1,15 @@ +: .factors ( n -- ) + 2 + begin 2dup dup * >= + while 2dup /mod swap + if drop 1+ 1 or \ next odd number + else -rot nip dup . ." x " + then + repeat + drop . ; + +: main ( n -- ) + ." 1 : 1" cr + 1+ 2 ?do i . ." : " i .factors cr loop ; + +15 main bye diff --git a/Task/Count-in-factors/Go/count-in-factors.go b/Task/Count-in-factors/Go/count-in-factors.go new file mode 100644 index 0000000000..e0930c56bb --- /dev/null +++ b/Task/Count-in-factors/Go/count-in-factors.go @@ -0,0 +1,19 @@ +package main + +import "fmt" + +func main() { + fmt.Println("1: 1") + for i := 2; ; i++ { + fmt.Printf("%d: ", i) + var x string + for n, f := i, 2; n != 1; f++ { + for m := n % f; m == 0; m = n % f { + fmt.Print(x, f) + x = "×" + n /= f + } + } + fmt.Println() + } +} diff --git a/Task/Count-in-factors/Haskell/count-in-factors-1.hs b/Task/Count-in-factors/Haskell/count-in-factors-1.hs new file mode 100644 index 0000000000..d6a19296ef --- /dev/null +++ b/Task/Count-in-factors/Haskell/count-in-factors-1.hs @@ -0,0 +1,3 @@ +import Data.List (intercalate) + +showFactors n = show n ++ " = " ++ (intercalate " * " . map show . factorize) n diff --git a/Task/Count-in-factors/Haskell/count-in-factors-2.hs b/Task/Count-in-factors/Haskell/count-in-factors-2.hs new file mode 100644 index 0000000000..76aaa022b8 --- /dev/null +++ b/Task/Count-in-factors/Haskell/count-in-factors-2.hs @@ -0,0 +1,42 @@ +Main> print 1 >> mapM_ (putStrLn . showFactors) [2..] +1 +2 = 2 +3 = 3 +4 = 2 * 2 +5 = 5 +6 = 2 * 3 +7 = 7 +8 = 2 * 2 * 2 +9 = 3 * 3 +10 = 2 * 5 +11 = 11 +12 = 2 * 2 * 3 +. . . + +Main> mapM_ (putStrLn . showFactors) [2144..] +2144 = 2 * 2 * 2 * 2 * 2 * 67 +2145 = 3 * 5 * 11 * 13 +2146 = 2 * 29 * 37 +2147 = 19 * 113 +2148 = 2 * 2 * 3 * 179 +2149 = 7 * 307 +2150 = 2 * 5 * 5 * 43 +2151 = 3 * 3 * 239 +2152 = 2 * 2 * 2 * 269 +2153 = 2153 +2154 = 2 * 3 * 359 +. . . + +Main> mapM_ (putStrLn . showFactors) [121231231232155..] +121231231232155 = 5 * 11 * 419 * 5260630559 +121231231232156 = 2 * 2 * 97 * 1061 * 294487867 +121231231232157 = 3 * 3 * 3 * 131 * 34275157261 +121231231232158 = 2 * 19 * 67 * 1231 * 38681033 +121231231232159 = 121231231232159 +121231231232160 = 2 * 2 * 2 * 2 * 2 * 3 * 5 * 7 * 7 * 5154389083 +121231231232161 = 121231231232161 +121231231232162 = 2 * 60615615616081 +121231231232163 = 3 * 13 * 83 * 191089 * 195991 +121231231232164 = 2 * 2 * 253811 * 119410931 +121231231232165 = 5 * 137 * 176979899609 +. . . diff --git a/Task/Count-in-factors/Java/count-in-factors.java b/Task/Count-in-factors/Java/count-in-factors.java new file mode 100644 index 0000000000..d07ef9de79 --- /dev/null +++ b/Task/Count-in-factors/Java/count-in-factors.java @@ -0,0 +1,41 @@ +public class CountingInFactors{ + public static void main(String[] args){ + for(int i = 1; i<= 10; i++){ + System.out.println(i + " = "+ countInFactors(i)); + } + + for(int i = 9991; i <= 10000; i++){ + System.out.println(i + " = "+ countInFactors(i)); + } + } + + private static String countInFactors(int n){ + if(n == 1) return "1"; + + StringBuilder sb = new StringBuilder(); + + n = checkFactor(2, n, sb); + if(n == 1) return sb.toString(); + + n = checkFactor(3, n, sb); + if(n == 1) return sb.toString(); + + for(int i = 5; i <= n; i+= 2){ + if(i % 3 == 0)continue; + + n = checkFactor(i, n, sb); + if(n == 1)break; + } + + return sb.toString(); + } + + private static int checkFactor(int mult, int n, StringBuilder sb){ + while(n % mult == 0 ){ + if(sb.length() > 0) sb.append(" x "); + sb.append(mult); + n /= mult; + } + return n; + } +} diff --git a/Task/Count-in-factors/JavaScript/count-in-factors.js b/Task/Count-in-factors/JavaScript/count-in-factors.js new file mode 100644 index 0000000000..6c6905720d --- /dev/null +++ b/Task/Count-in-factors/JavaScript/count-in-factors.js @@ -0,0 +1,15 @@ +for(i = 1; i <= 10; i++) + console.log(i + " : " + factor(i).join(" x ")); + +function factor(n) { + var factors = []; + if (n == 1) return [1]; + for(p = 2; p <= n; ) { + if((n % p) == 0) { + factors[factors.length] = p; + n /= p; + } + else p++; + } + return factors; +} diff --git a/Task/Count-in-factors/Lua/count-in-factors.lua b/Task/Count-in-factors/Lua/count-in-factors.lua new file mode 100644 index 0000000000..5929e63573 --- /dev/null +++ b/Task/Count-in-factors/Lua/count-in-factors.lua @@ -0,0 +1,24 @@ +function factorize( n ) + if n == 1 then return {1} end + + local k = 2 + res = {} + while n > 1 do + while n % k == 0 do + res[#res+1] = k + n = n / k + end + k = k + 1 + end + return res +end + +for i = 1, 22 do + io.write( i, ": " ) + fac = factorize( i ) + io.write( fac[1] ) + for j = 2, #fac do + io.write( " * ", fac[j] ) + end + print "" +end diff --git a/Task/Count-in-factors/Perl/count-in-factors.pl b/Task/Count-in-factors/Perl/count-in-factors.pl new file mode 100644 index 0000000000..4a16f3863b --- /dev/null +++ b/Task/Count-in-factors/Perl/count-in-factors.pl @@ -0,0 +1,26 @@ +use utf8; +sub factors { + my $n = shift; + my $p = 2; + my @out; + + while ($n >= $p * $p) { + while ($n % $p == 0) { + push @out, $p; + $n /= $p; + } + $p = next_prime($p); + } + push @out, $n if $n > 1 || !@out; + @out; +} + +sub next_prime { + my $p = shift; + do { $p = $p == 2 ? 3 : $p + 2 } until is_prime($p); + $p; +} + +sub is_prime { factors(shift) == 1 } + +print "$_ = ", join(" × ", factors($_)), "\n" for (1 .. 1000); diff --git a/Task/Count-in-factors/PicoLisp/count-in-factors.l b/Task/Count-in-factors/PicoLisp/count-in-factors.l new file mode 100644 index 0000000000..eeb27c1779 --- /dev/null +++ b/Task/Count-in-factors/PicoLisp/count-in-factors.l @@ -0,0 +1,11 @@ +(de factor (N) + (make + (let (D 2 L (1 2 2 . (4 2 4 2 4 6 2 6 .)) M (sqrt N)) + (while (>= M D) + (if (=0 (% N D)) + (setq M (sqrt (setq N (/ N (link D))))) + (inc 'D (pop 'L)) ) ) + (link N) ) ) ) + +(for N 20 + (prinl N ": " (glue " * " (factor N))) ) diff --git a/Task/Count-in-factors/Python/count-in-factors.py b/Task/Count-in-factors/Python/count-in-factors.py new file mode 100644 index 0000000000..568d3015e8 --- /dev/null +++ b/Task/Count-in-factors/Python/count-in-factors.py @@ -0,0 +1,35 @@ +from functools import lru_cache + +primes = [2, 3, 5, 7, 11, 13, 17] # Will be extended + +@lru_cache(maxsize=2000) +def pfactor(n): + if n == 1: + return [1] + n2 = n // 2 + 1 + for p in primes: + if p <= n2: + d, m = divmod(n, p) + if m == 0: + if d > 1: + return [p] + pfactor(d) + else: + return [p] + else: + if n > primes[-1]: + primes.append(n) + return [n] + +if __name__ == '__main__': + mx = 5000 + for n in range(1, mx + 1): + factors = pfactor(n) + if n <= 10 or n >= mx - 20: + print( '%4i %5s %s' % (n, + '' if factors != [n] else 'prime', + 'x'.join(str(i) for i in factors)) ) + if n == 11: + print('...') + + print('\nNumber of primes gathered up to', n, 'is', len(primes)) + print(pfactor.cache_info()) diff --git a/Task/Count-in-factors/REXX/count-in-factors.rexx b/Task/Count-in-factors/REXX/count-in-factors.rexx new file mode 100644 index 0000000000..4ca266e0cc --- /dev/null +++ b/Task/Count-in-factors/REXX/count-in-factors.rexx @@ -0,0 +1,35 @@ +/*REXX program finds and lists the prime factors of positive integer(s).*/ +numeric digits 12 /*bump precision of the numbers. */ +parse arg low high . /*get the argument(s) from the CL*/ +if high=='' then high=low /*No HIGH? Then make one up. */ +w=length(high) /*get max width for pretty tell. */ +blanks=1 /*allow spaces around the "x". */ + do n=low to high /*process single number | a range*/ + say right(n,w) '=' space(factr(n),blanks) /*display N & factors*/ + end /*n*/ /*if BLANKS=0, no spaces around X*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────FACTR subroutine────────────────────*/ +factr: procedure; parse arg x 1 z /*defines X and Z from the arg.*/ +if x <1 then return '' /*Invalid number? Return null. */ +if x==1 then return 1 /*handle special case for unity. */ +Xtimes= '∙' /*use round bullet for "times". */ +Xtimes= 'x' /*character used for "times" (x).*/ +list= /*nullify the list (to empty). */ + + do j=2 to 5; if j\==4 then call .buildF; end /*fast builds for list.*/ + j=5 /*start were we left off (five).*/ + do y=0 by 2; j=j+2+y//4 /*insure it's not divisible by 3.*/ + if right(j,1)==5 then iterate /*fast check for divisible by 5.*/ + if j>z then leave /*number reduced to a small 'un? */ + if j*j>x then leave /*are we higher than the √ of X ?*/ + call .buildF /*add a prime factor to list (J).*/ + end /*y*/ + +if z==1 then z= /*if residual is = 1, nullify it.*/ +return strip(strip(list Xtimes z),,Xtimes) /*elide any leading "x". */ +/*──────────────────────────────────.BUILDF subroutine──────────────────*/ +.buildF: do while z//j==0 /*keep dividing until it hurts. */ + list=list Xtimes j /*add number to the list (J). */ + z=z%j /*do an integer divide. */ + end /*while*/ +return diff --git a/Task/Count-in-factors/Racket/count-in-factors.rkt b/Task/Count-in-factors/Racket/count-in-factors.rkt new file mode 100644 index 0000000000..1f529bdd2e --- /dev/null +++ b/Task/Count-in-factors/Racket/count-in-factors.rkt @@ -0,0 +1,15 @@ +#lang racket +(require math) + +(define (~ f) + (match f + [(list p 1) (~a p)] + [(list p n) (~a p "^" n)])) + +(define (factors fs) + (add-between (map ~ fs) " * ")) + +(for ([x (in-range 2 20)]) + (display (~a x " = ")) + (map display (factors (factorize x))) + (newline)) diff --git a/Task/Count-in-factors/Ruby/count-in-factors.rb b/Task/Count-in-factors/Ruby/count-in-factors.rb new file mode 100644 index 0000000000..20d8c2d610 --- /dev/null +++ b/Task/Count-in-factors/Ruby/count-in-factors.rb @@ -0,0 +1,23 @@ +require 'optparse' +require 'prime' + +maximum = 10 +OptionParser.new do |o| + o.banner = "Usage: #{File.basename $0} [-m MAXIMUM]" + o.on("-m MAXIMUM", Integer, + "Count up to MAXIMUM [#{maximum}]") { |m| maximum = m } + o.parse! rescue ($stderr.puts $!, o; exit 1) + ($stderr.puts o; exit 1) unless ARGV.size == 0 +end + +# 1 has no prime factors +puts "1 is 1" unless maximum < 1 + +2.upto(maximum) do |i| + # i is 504 => i.prime_division is [[2, 3], [3, 2], [7, 1]] + f = i.prime_division.map! do |factor, exponent| + # convert [2, 3] to "2 x 2 x 2" + ([factor] * exponent).join " x " + end.join " x " + puts "#{i} is #{f}" +end diff --git a/Task/Count-in-factors/Scheme/count-in-factors.ss b/Task/Count-in-factors/Scheme/count-in-factors.ss new file mode 100644 index 0000000000..c16e18dfa1 --- /dev/null +++ b/Task/Count-in-factors/Scheme/count-in-factors.ss @@ -0,0 +1,20 @@ +(define (factors n) + (let facs ((l '()) (d 2) (x n)) + (cond ((= x 1) (if (null? l) '(1) l)) + ((< x (* d d)) (cons x l)) + (else (if (= 0 (modulo x d)) + (facs (cons d l) d (/ x d)) + (facs l (+ 1 d) x)))))) + +(define (show l) + (display (car l)) + (if (not (null? (cdr l))) + (begin + (display " × ") + (show (cdr l))) + (display "\n"))) + +(do ((i 1 (+ i 1))) (#f) + (display i) + (display " = ") + (show (reverse (factors i)))) diff --git a/Task/Count-in-factors/Tcl/count-in-factors-1.tcl b/Task/Count-in-factors/Tcl/count-in-factors-1.tcl new file mode 100644 index 0000000000..e0b550ed16 --- /dev/null +++ b/Task/Count-in-factors/Tcl/count-in-factors-1.tcl @@ -0,0 +1,62 @@ +package require Tcl 8.5 + +namespace eval prime { + variable primes [list 2 3 5 7 11] + proc restart {} { + variable index -1 + variable primes + variable current [lindex $primes end] + } + + proc get_next_prime {} { + variable primes + variable index + if {$index < [llength $primes]-1} { + return [lindex $primes [incr index]] + } + variable current + while 1 { + incr current 2 + set p 1 + foreach prime $primes { + if {$current % $prime} {} else { + set p 0 + break + } + } + if {$p} { + return [lindex [lappend primes $current] [incr index]] + } + } + } + + proc factors {num} { + restart + set factors [dict create] + for {set i [get_next_prime]} {$i <= $num} {} { + if {$num % $i == 0} { + dict incr factors $i + set num [expr {$num / $i}] + continue + } elseif {$i*$i > $num} { + dict incr factors $num + break + } else { + set i [get_next_prime] + } + } + return $factors + } + + # Produce the factors in rendered form + proc factors.rendered {num} { + set factorDict [factors $num] + if {[dict size $factorDict] == 0} { + return 1 + } + dict for {factor times} $factorDict { + lappend v {*}[lrepeat $times $factor] + } + return [join $v "*"] + } +} diff --git a/Task/Count-in-factors/Tcl/count-in-factors-2.tcl b/Task/Count-in-factors/Tcl/count-in-factors-2.tcl new file mode 100644 index 0000000000..ce9aff0fb7 --- /dev/null +++ b/Task/Count-in-factors/Tcl/count-in-factors-2.tcl @@ -0,0 +1,4 @@ +set max 20 +for {set i 1} {$i <= $max} {incr i} { + puts [format "%*d = %s" [string length $max] $i [prime::factors.rendered $i]] +} diff --git a/Task/Count-in-octal/0815/count-in-octal.0815 b/Task/Count-in-octal/0815/count-in-octal.0815 new file mode 100644 index 0000000000..d6b7ce1224 --- /dev/null +++ b/Task/Count-in-octal/0815/count-in-octal.0815 @@ -0,0 +1,17 @@ +}:l:> Start loop, enqueue Z (initially 0). + }:o: Treat the queue as a stack and + <:8:= accumulate the octal digits + /=>&~ of the current number. + ^:o: + + <:0:- Get a sentinel negative 1. + &>@ Enqueue it between the digits and the current number. + { Dequeue the first octal digit. + + }:p: + ~%={+ Rotate each octal digit into place and print it. + ^:p: + + <:a:~$ Output a newline. + <:1:x{+ Dequeue the current number and increment it. +^:l: diff --git a/Task/Count-in-octal/0DESCRIPTION b/Task/Count-in-octal/0DESCRIPTION new file mode 100644 index 0000000000..c1e8dd8654 --- /dev/null +++ b/Task/Count-in-octal/0DESCRIPTION @@ -0,0 +1,3 @@ +The task is to produce a sequential count in octal, starting at zero, and using an increment of a one for each consecutive number. Each number should appear on a single line, and the program should count until terminated, or until the maximum value of the numeric type in use is reached. + +* [[Integer sequence]] is a similar task without the use of octal numbers. diff --git a/Task/Count-in-octal/ALGOL-68/count-in-octal.alg b/Task/Count-in-octal/ALGOL-68/count-in-octal.alg new file mode 100644 index 0000000000..eeeb0936a3 --- /dev/null +++ b/Task/Count-in-octal/ALGOL-68/count-in-octal.alg @@ -0,0 +1,9 @@ +#!/usr/local/bin/a68g --script # + +INT oct width = (bits width-1) OVER 3 + 1; +main: +( + FOR i TO 17 # max int # DO + printf(($"8r"8r n(oct width)dl$, BIN i)) + OD +) diff --git a/Task/Count-in-octal/AWK/count-in-octal.awk b/Task/Count-in-octal/AWK/count-in-octal.awk new file mode 100644 index 0000000000..2ccacc5a52 --- /dev/null +++ b/Task/Count-in-octal/AWK/count-in-octal.awk @@ -0,0 +1,5 @@ +BEGIN { + for (l = 0; l <= 2147483647; l++) { + printf("%o\n", l); + } +} diff --git a/Task/Count-in-octal/Ada/count-in-octal.ada b/Task/Count-in-octal/Ada/count-in-octal.ada new file mode 100644 index 0000000000..614daf64dc --- /dev/null +++ b/Task/Count-in-octal/Ada/count-in-octal.ada @@ -0,0 +1,10 @@ +with Ada.Text_IO; + +procedure Octal is + package IIO is new Ada.Text_IO.Integer_IO(Integer); +begin + for I in 0 .. Integer'Last loop + IIO.Put(I, Base => 8); + Ada.Text_IO.New_Line; + end loop; +end Octal; diff --git a/Task/Count-in-octal/AutoHotkey/count-in-octal.ahk b/Task/Count-in-octal/AutoHotkey/count-in-octal.ahk new file mode 100644 index 0000000000..4fb732dd7d --- /dev/null +++ b/Task/Count-in-octal/AutoHotkey/count-in-octal.ahk @@ -0,0 +1,11 @@ +DllCall("AllocConsole") +Octal(int){ + While int + out := Mod(int, 8) . out, int := int//8 + return out +} +Loop +{ + FileAppend, % Octal(A_Index) "`n", CONOUT$ + Sleep 200 +} diff --git a/Task/Count-in-octal/BASIC/count-in-octal-1.bas b/Task/Count-in-octal/BASIC/count-in-octal-1.bas new file mode 100644 index 0000000000..09499c90f9 --- /dev/null +++ b/Task/Count-in-octal/BASIC/count-in-octal-1.bas @@ -0,0 +1,4 @@ +DIM n AS LONG +FOR n = 0 TO &h7FFFFFFF + PRINT OCT$(n) +NEXT diff --git a/Task/Count-in-octal/BASIC/count-in-octal-2.bas b/Task/Count-in-octal/BASIC/count-in-octal-2.bas new file mode 100644 index 0000000000..3558a9b0a6 --- /dev/null +++ b/Task/Count-in-octal/BASIC/count-in-octal-2.bas @@ -0,0 +1,15 @@ +WHILE ("" = INKEY$) + PRINT Octal$(n) + n = n + 1 +WEND +END +FUNCTION Octal$(what) + outp$ = "" + w = what + WHILE ABS(w) > 0 + o = w AND 7 + w = INT(w / 8) + outp$ = STR$(o) + outp$ + WEND + Octal$ = outp$ +END FUNCTION diff --git a/Task/Count-in-octal/BBC-BASIC/count-in-octal.bbc b/Task/Count-in-octal/BBC-BASIC/count-in-octal.bbc new file mode 100644 index 0000000000..ab8c11c881 --- /dev/null +++ b/Task/Count-in-octal/BBC-BASIC/count-in-octal.bbc @@ -0,0 +1,18 @@ + N% = 0 + REPEAT + PRINT FN_tobase(N%, 8, 0) + N% += 1 + UNTIL FALSE + END + + REM Convert N% to string in base B% with minimum M% digits: + DEF FN_tobase(N%, B%, M%) + LOCAL D%, A$ + REPEAT + D% = N% MOD B% + N% DIV= B% + IF D%<0 D% += B% : N% -= 1 + A$ = CHR$(48 + D% - 7*(D%>9)) + A$ + M% -= 1 + UNTIL (N%=FALSE OR N%=TRUE) AND M%<=0 + =A$ diff --git a/Task/Count-in-octal/Bracmat/count-in-octal.bracmat b/Task/Count-in-octal/Bracmat/count-in-octal.bracmat new file mode 100644 index 0000000000..0e0be6367c --- /dev/null +++ b/Task/Count-in-octal/Bracmat/count-in-octal.bracmat @@ -0,0 +1,8 @@ + ( oct + = + . !arg:<8 + & (!arg:~<0|ERROR) + | str$(oct$(div$(!arg.8)) mod$(!arg.8)) + ) +& -1:?n +& whl'(1+!n:?n&out$(!n oct$!n)); diff --git a/Task/Count-in-octal/Brainf---/count-in-octal.bf b/Task/Count-in-octal/Brainf---/count-in-octal.bf new file mode 100644 index 0000000000..99ee24b080 --- /dev/null +++ b/Task/Count-in-octal/Brainf---/count-in-octal.bf @@ -0,0 +1,17 @@ ++[ Start with n=1 to kick off the loop +[>>++++++++<< Set up {n 0 8} for divmod magic +[->+>- Then +[>+>>]> do +[+[-<+>]>+>>] the +<<<<<<] magic +>>>+ Increment n % 8 so that 0s don't break things +>] Move into n / 8 and divmod that unless it's 0 +-< Set up sentinel ‑1 then move into the first octal digit +[++++++++ ++++++++ ++++++++ Add 47 to get it to ASCII + ++++++++ ++++++++ +++++++. and print it +[<]<] Get to a 0; the cell to the left is the next octal digit +>>[<+>-] Tape is {0 n}; make it {n 0} +>[>+] Get to the ‑1 +<[[-]<] Zero the tape for the next iteration +++++++++++. Print a newline +[-]<+] Zero it then increment n and go again diff --git a/Task/Count-in-octal/C++/count-in-octal.cpp b/Task/Count-in-octal/C++/count-in-octal.cpp new file mode 100644 index 0000000000..901ac5a6fd --- /dev/null +++ b/Task/Count-in-octal/C++/count-in-octal.cpp @@ -0,0 +1,12 @@ +#include + +int main() +{ + unsigned i = 0; + do + { + std::cout << std::oct << i << std::endl; + ++i; + } while(i != 0); + return 0; +} diff --git a/Task/Count-in-octal/C/count-in-octal.c b/Task/Count-in-octal/C/count-in-octal.c new file mode 100644 index 0000000000..bf4f425982 --- /dev/null +++ b/Task/Count-in-octal/C/count-in-octal.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + unsigned int i = 0; + do { printf("%o\n", i++); } while(i); + return 0; +} diff --git a/Task/Count-in-octal/Clojure/count-in-octal.clj b/Task/Count-in-octal/Clojure/count-in-octal.clj new file mode 100644 index 0000000000..17dce42dda --- /dev/null +++ b/Task/Count-in-octal/Clojure/count-in-octal.clj @@ -0,0 +1 @@ +(doseq [i (range)] (println (format "%o" i))) diff --git a/Task/Count-in-octal/CoffeeScript/count-in-octal.coffee b/Task/Count-in-octal/CoffeeScript/count-in-octal.coffee new file mode 100644 index 0000000000..832b5f61bd --- /dev/null +++ b/Task/Count-in-octal/CoffeeScript/count-in-octal.coffee @@ -0,0 +1,5 @@ +n = 0 + +while true + console.log n.toString(8) + n += 1 diff --git a/Task/Count-in-octal/Common-Lisp/count-in-octal.lisp b/Task/Count-in-octal/Common-Lisp/count-in-octal.lisp new file mode 100644 index 0000000000..a3602c787d --- /dev/null +++ b/Task/Count-in-octal/Common-Lisp/count-in-octal.lisp @@ -0,0 +1 @@ +(loop for i from 0 do (format t "~o~%" i)) diff --git a/Task/Count-in-octal/D/count-in-octal.d b/Task/Count-in-octal/D/count-in-octal.d new file mode 100644 index 0000000000..64d8328190 --- /dev/null +++ b/Task/Count-in-octal/D/count-in-octal.d @@ -0,0 +1,7 @@ +import std.stdio; + +void main() { + ubyte i; + do writefln("%o", i++); + while(i); +} diff --git a/Task/Count-in-octal/Dc/count-in-octal.dc b/Task/Count-in-octal/Dc/count-in-octal.dc new file mode 100644 index 0000000000..62f497c782 --- /dev/null +++ b/Task/Count-in-octal/Dc/count-in-octal.dc @@ -0,0 +1 @@ +8o0[p1+lpx]dspx diff --git a/Task/Count-in-octal/Delphi/count-in-octal.delphi b/Task/Count-in-octal/Delphi/count-in-octal.delphi new file mode 100644 index 0000000000..53b93adeaa --- /dev/null +++ b/Task/Count-in-octal/Delphi/count-in-octal.delphi @@ -0,0 +1,24 @@ +program CountingInOctal; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +function DecToOct(aValue: Integer): string; +var + lRemainder: Integer; +begin + Result := ''; + repeat + lRemainder := aValue mod 8; + Result := IntToStr(lRemainder) + Result; + aValue := aValue div 8; + until aValue = 0; +end; + +var + i: Integer; +begin + for i := 0 to 20 do + WriteLn(DecToOct(i)); +end. diff --git a/Task/Count-in-octal/Emacs-Lisp/count-in-octal.l b/Task/Count-in-octal/Emacs-Lisp/count-in-octal.l new file mode 100644 index 0000000000..f6dfcac92d --- /dev/null +++ b/Task/Count-in-octal/Emacs-Lisp/count-in-octal.l @@ -0,0 +1,2 @@ +(dotimes (i most-positive-fixnum) ;; starting from 0 + (message "%o" i)) diff --git a/Task/Count-in-octal/Euphoria/count-in-octal.euphoria b/Task/Count-in-octal/Euphoria/count-in-octal.euphoria new file mode 100644 index 0000000000..871cba5486 --- /dev/null +++ b/Task/Count-in-octal/Euphoria/count-in-octal.euphoria @@ -0,0 +1,6 @@ +integer i +i = 0 +while 1 do + printf(1,"%o\n",i) + i += 1 +end while diff --git a/Task/Count-in-octal/Forth/count-in-octal.fth b/Task/Count-in-octal/Forth/count-in-octal.fth new file mode 100644 index 0000000000..73375fd56a --- /dev/null +++ b/Task/Count-in-octal/Forth/count-in-octal.fth @@ -0,0 +1,3 @@ +: octal ( -- ) 8 base ! ; \ where unavailable + +octal ints diff --git a/Task/Count-in-octal/Fortran/count-in-octal.f b/Task/Count-in-octal/Fortran/count-in-octal.f new file mode 100644 index 0000000000..e2d9b08c5c --- /dev/null +++ b/Task/Count-in-octal/Fortran/count-in-octal.f @@ -0,0 +1,13 @@ +program Octal + implicit none + + integer, parameter :: i64 = selected_int_kind(18) + integer(i64) :: n = 0 + +! Will stop when n overflows from +! 9223372036854775807 to -92233720368547758078 (1000000000000000000000 octal) + do while(n >= 0) + write(*, "(o0)") n + n = n + 1 + end do +end program diff --git a/Task/Count-in-octal/Go/count-in-octal-1.go b/Task/Count-in-octal/Go/count-in-octal-1.go new file mode 100644 index 0000000000..9f936d73d0 --- /dev/null +++ b/Task/Count-in-octal/Go/count-in-octal-1.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "math" +) + +func main() { + for i := int8(0); ; i++ { + fmt.Printf("%o\n", i) + if i == math.MaxInt8 { + break + } + } +} diff --git a/Task/Count-in-octal/Go/count-in-octal-2.go b/Task/Count-in-octal/Go/count-in-octal-2.go new file mode 100644 index 0000000000..196a2b9f2c --- /dev/null +++ b/Task/Count-in-octal/Go/count-in-octal-2.go @@ -0,0 +1,8 @@ +func main() { + for i := uint16(0); ; i++ { // type specified here + fmt.Printf("%o\n", i) + if i == math.MaxUint16 { // maximum value for type specified here + break + } + } +} diff --git a/Task/Count-in-octal/Go/count-in-octal-3.go b/Task/Count-in-octal/Go/count-in-octal-3.go new file mode 100644 index 0000000000..936882f79c --- /dev/null +++ b/Task/Count-in-octal/Go/count-in-octal-3.go @@ -0,0 +1,17 @@ +import "fmt" + +func main() { + for i := 0.; ; { + fmt.Printf("%o\n", int64(i)) + /* uncomment to produce example output + if i == 3 { + i = float64(1<<53 - 4) // skip to near the end + fmt.Println("...") + } */ + next := i + 1 + if next == i { + break + } + i = next + } +} diff --git a/Task/Count-in-octal/Go/count-in-octal-4.go b/Task/Count-in-octal/Go/count-in-octal-4.go new file mode 100644 index 0000000000..6f7d6a6ce6 --- /dev/null +++ b/Task/Count-in-octal/Go/count-in-octal-4.go @@ -0,0 +1,14 @@ +import ( + "big" + "fmt" +) + +func main() { + defer func() { + recover() + }() + one := big.NewInt(1) + for i := big.NewInt(0); ; i.Add(i, one) { + fmt.Printf("%o\n", i) + } +} diff --git a/Task/Count-in-octal/Haskell/count-in-octal.hs b/Task/Count-in-octal/Haskell/count-in-octal.hs new file mode 100644 index 0000000000..76476193a7 --- /dev/null +++ b/Task/Count-in-octal/Haskell/count-in-octal.hs @@ -0,0 +1,3 @@ +import Numeric + +main = mapM_ (putStrLn . flip showOct "") [1..] diff --git a/Task/Count-in-octal/Java/count-in-octal.java b/Task/Count-in-octal/Java/count-in-octal.java new file mode 100644 index 0000000000..1ab8f77d89 --- /dev/null +++ b/Task/Count-in-octal/Java/count-in-octal.java @@ -0,0 +1,7 @@ +public class Count{ + public static void main(String[] args){ + for(int i = 0;i >= 0;i++){ + System.out.println(Integer.toOctalString(i)); //optionally use "Integer.toString(i, 8)" + } + } +} diff --git a/Task/Count-in-octal/JavaScript/count-in-octal.js b/Task/Count-in-octal/JavaScript/count-in-octal.js new file mode 100644 index 0000000000..685c62cb21 --- /dev/null +++ b/Task/Count-in-octal/JavaScript/count-in-octal.js @@ -0,0 +1,3 @@ +for (var n = 0; n < 1e14; n++) { // arbitrary limit that's not too big + document.writeln(n.toString(8)); // not sure what's the best way to output it in JavaScript +} diff --git a/Task/Count-in-octal/Lua/count-in-octal.lua b/Task/Count-in-octal/Lua/count-in-octal.lua new file mode 100644 index 0000000000..6a2077f69e --- /dev/null +++ b/Task/Count-in-octal/Lua/count-in-octal.lua @@ -0,0 +1,3 @@ +for l=1,2147483647 do + print(string.format("%o",l)) +end diff --git a/Task/Count-in-octal/MATLAB/count-in-octal-1.m b/Task/Count-in-octal/MATLAB/count-in-octal-1.m new file mode 100644 index 0000000000..ac5e7b62d2 --- /dev/null +++ b/Task/Count-in-octal/MATLAB/count-in-octal-1.m @@ -0,0 +1,5 @@ + n = 0; + while (1) + dec2base(n,8) + n = n+1; + end; diff --git a/Task/Count-in-octal/MATLAB/count-in-octal-2.m b/Task/Count-in-octal/MATLAB/count-in-octal-2.m new file mode 100644 index 0000000000..ff68cdfbc6 --- /dev/null +++ b/Task/Count-in-octal/MATLAB/count-in-octal-2.m @@ -0,0 +1,5 @@ + n = 0; + while (1) + printf('%o\n',n); + n = n+1; + end; diff --git a/Task/Count-in-octal/MATLAB/count-in-octal-3.m b/Task/Count-in-octal/MATLAB/count-in-octal-3.m new file mode 100644 index 0000000000..db313ece87 --- /dev/null +++ b/Task/Count-in-octal/MATLAB/count-in-octal-3.m @@ -0,0 +1,2 @@ + seq = 1:100; + dec2base(seq,8) diff --git a/Task/Count-in-octal/MATLAB/count-in-octal-4.m b/Task/Count-in-octal/MATLAB/count-in-octal-4.m new file mode 100644 index 0000000000..37e155b3c8 --- /dev/null +++ b/Task/Count-in-octal/MATLAB/count-in-octal-4.m @@ -0,0 +1 @@ + printf('%o\n',seq); diff --git a/Task/Count-in-octal/PHP/count-in-octal.php b/Task/Count-in-octal/PHP/count-in-octal.php new file mode 100644 index 0000000000..bf1c557e1d --- /dev/null +++ b/Task/Count-in-octal/PHP/count-in-octal.php @@ -0,0 +1,5 @@ + diff --git a/Task/Count-in-octal/Perl/count-in-octal-1.pl b/Task/Count-in-octal/Perl/count-in-octal-1.pl new file mode 100644 index 0000000000..e1627e3ab1 --- /dev/null +++ b/Task/Count-in-octal/Perl/count-in-octal-1.pl @@ -0,0 +1,2 @@ +use POSIX; +printf "%o\n", $_ for (0 .. POSIX::UINT_MAX); diff --git a/Task/Count-in-octal/Perl/count-in-octal-2.pl b/Task/Count-in-octal/Perl/count-in-octal-2.pl new file mode 100644 index 0000000000..237ffe4a63 --- /dev/null +++ b/Task/Count-in-octal/Perl/count-in-octal-2.pl @@ -0,0 +1,3 @@ +use bigint; +my $i = 0; +printf "%o\n", $i++ while 1 diff --git a/Task/Count-in-octal/PicoLisp/count-in-octal.l b/Task/Count-in-octal/PicoLisp/count-in-octal.l new file mode 100644 index 0000000000..bb8ffa546d --- /dev/null +++ b/Task/Count-in-octal/PicoLisp/count-in-octal.l @@ -0,0 +1,2 @@ +(for (N 0 T (inc N)) + (prinl (oct N)) ) diff --git a/Task/Count-in-octal/Python/count-in-octal.py b/Task/Count-in-octal/Python/count-in-octal.py new file mode 100644 index 0000000000..4378823016 --- /dev/null +++ b/Task/Count-in-octal/Python/count-in-octal.py @@ -0,0 +1,3 @@ +import sys +for n in xrange(sys.maxint): + print oct(n) diff --git a/Task/Count-in-octal/REXX/count-in-octal.rexx b/Task/Count-in-octal/REXX/count-in-octal.rexx new file mode 100644 index 0000000000..41db76f767 --- /dev/null +++ b/Task/Count-in-octal/REXX/count-in-octal.rexx @@ -0,0 +1,33 @@ +/*REXX program counts in octal until the number exceeds #pgm statements.*/ + +/*┌────────────────────────────────────────────────────────────────────┐ + │ Count all the protons (and electrons!) in the universe. │ + │ │ + │ According to Sir Author Eddington in 1938 at his Tamer Lecture at │ + │ Trinity Collecge (Cambridge), he postulated that there are exactly │ + │ │ + │ 136 ∙ 2^245 │ + │ │ + │ protons in the universe, and the same number of electrons, which │ + │ is equal to around 1.57477e+79. │ + │ │ + │ [Although, a modern estimate is around 10^80.] │ + └────────────────────────────────────────────────────────────────────┘*/ + +numeric digits 100000 /*handle almost all big numbers. */ +numIn=right('number in', 20) /*used for indentation of output.*/ +w=length(sourceline()) /*used for formatting width of #s*/ + + do #=0 to 136 * (2**256) /*Sir Eddington, here we come ! */ + !=x2b( d2x(#) ) + _=right(!, 3 * (length(_) % 3 + 1), 0) + o= + do k=1 to length(_) by 3 + o=o'0'substr(_,k,3) + end /*k*/ + + say numIn 'base ten = ' right(#,w) numIn "octal = " right(b2x(o)+0,w+w) + + if #>sourceline() then leave /*stop if #protons > program statements.*/ + end /*#*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Count-in-octal/Racket/count-in-octal.rkt b/Task/Count-in-octal/Racket/count-in-octal.rkt new file mode 100644 index 0000000000..b0836456c9 --- /dev/null +++ b/Task/Count-in-octal/Racket/count-in-octal.rkt @@ -0,0 +1,3 @@ +#lang racket +(for ([i (in-naturals)]) + (displayln (number->string i 8))) diff --git a/Task/Count-in-octal/Ruby/count-in-octal.rb b/Task/Count-in-octal/Ruby/count-in-octal.rb new file mode 100644 index 0000000000..e3a4c76b99 --- /dev/null +++ b/Task/Count-in-octal/Ruby/count-in-octal.rb @@ -0,0 +1,5 @@ +n = 0 +loop do + puts "%o" % n + n += 1 +end diff --git a/Task/Count-in-octal/Scala/count-in-octal.scala b/Task/Count-in-octal/Scala/count-in-octal.scala new file mode 100644 index 0000000000..c9c28f4dfa --- /dev/null +++ b/Task/Count-in-octal/Scala/count-in-octal.scala @@ -0,0 +1 @@ +0 until Int.MaxValue foreach(i=> println(i toOctalString)) diff --git a/Task/Count-in-octal/Scheme/count-in-octal.ss b/Task/Count-in-octal/Scheme/count-in-octal.ss new file mode 100644 index 0000000000..6b25364ef3 --- /dev/null +++ b/Task/Count-in-octal/Scheme/count-in-octal.ss @@ -0,0 +1 @@ +(do ((i 0 (+ i 1))) (#f) (display (number->string i 8)) (newline)) diff --git a/Task/Count-in-octal/Tcl/count-in-octal.tcl b/Task/Count-in-octal/Tcl/count-in-octal.tcl new file mode 100644 index 0000000000..d1a98cd384 --- /dev/null +++ b/Task/Count-in-octal/Tcl/count-in-octal.tcl @@ -0,0 +1,4 @@ +package require Tcl 8.5; # arbitrary precision integers; we can count until we run out of memory! +while 1 { + puts [format "%llo" [incr counter]] +} diff --git a/Task/Count-occurrences-of-a-substring/0DESCRIPTION b/Task/Count-occurrences-of-a-substring/0DESCRIPTION new file mode 100644 index 0000000000..e51d7b5483 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/0DESCRIPTION @@ -0,0 +1,10 @@ +The task is to either create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string. The function should take two arguments: the first argument being the string to search and the second a substring to be search for. It should return an integer count. + +print countSubstring("the three truths","th") +3 + +// do not count substrings that overlap with previously-counted substrings: +print countSubstring("ababababab","abab") +2 + +The matching should yield the highest number of non-overlapping matches. In general, this essentially means matching from left-to-right or right-to-left (see proof on talk page). diff --git a/Task/Count-occurrences-of-a-substring/1META.yaml b/Task/Count-occurrences-of-a-substring/1META.yaml new file mode 100644 index 0000000000..ae625822b7 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/1META.yaml @@ -0,0 +1,2 @@ +--- +note: String manipulation diff --git a/Task/Count-occurrences-of-a-substring/ALGOL-68/count-occurrences-of-a-substring.alg b/Task/Count-occurrences-of-a-substring/ALGOL-68/count-occurrences-of-a-substring.alg new file mode 100644 index 0000000000..b78cae0a28 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/ALGOL-68/count-occurrences-of-a-substring.alg @@ -0,0 +1,17 @@ +#!/usr/local/bin/a68g --script # + +PROC count string in string = (STRING needle, haystack)INT: ( + INT start:=LWB haystack, next, out:=0; + FOR count WHILE string in string(needle, next, haystack[start:]) DO + start+:=next+UPB needle-LWB needle; + out:=count + OD; + out +); + +printf(($d" "$, + count string in string("th", "the three truths"), # expect 3 # + count string in string("abab", "ababababab"), # expect 2 # + count string in string("a*b", "abaabba*bbaba*bbab"), # expect 2 # + $l$ +)) diff --git a/Task/Count-occurrences-of-a-substring/AWK/count-occurrences-of-a-substring.awk b/Task/Count-occurrences-of-a-substring/AWK/count-occurrences-of-a-substring.awk new file mode 100644 index 0000000000..b3b766e08e --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/AWK/count-occurrences-of-a-substring.awk @@ -0,0 +1,16 @@ +#!/usr/local/bin/awk -f + function countsubstring (str,pat) + { + n=0; + while (match(str,pat)) { + n++; + str = substr(str,RSTART+RLENGTH); + } + return n; + } + + BEGIN { + print countsubstring("the three truths","th"); + print countsubstring("ababababab","abab"); + print countsubstring(ARGV[1],ARGV[2]); + } diff --git a/Task/Count-occurrences-of-a-substring/Ada/count-occurrences-of-a-substring.ada b/Task/Count-occurrences-of-a-substring/Ada/count-occurrences-of-a-substring.ada new file mode 100644 index 0000000000..66bbbb29a1 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Ada/count-occurrences-of-a-substring.ada @@ -0,0 +1,18 @@ +with Ada.Strings.Fixed, Ada.Text_IO; + +procedure Count_Substrings is + + function Substrings(Main: String; Sub: String) return Natural is + Idx: Natural := Ada.Strings.Fixed.Index(Source => Main, Pattern => Sub); + begin + if Idx = 0 then + return 0; + else + return 1 + Substrings(Main(Idx+Sub'Length .. Main'Last), Sub); + end if; + end Substrings; + +begin + Ada.Text_IO.Put(Integer'Image(Substrings("the three truths", "th"))); + Ada.Text_IO.Put(Integer'Image(Substrings("ababababab", "abab"))); +end Count_Substrings; diff --git a/Task/Count-occurrences-of-a-substring/AutoHotkey/count-occurrences-of-a-substring.ahk b/Task/Count-occurrences-of-a-substring/AutoHotkey/count-occurrences-of-a-substring.ahk new file mode 100644 index 0000000000..1eb8d91dc3 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/AutoHotkey/count-occurrences-of-a-substring.ahk @@ -0,0 +1,7 @@ +MsgBox % countSubstring("the three truths","th") ; 3 +MsgBox % countSubstring("ababababab","abab") ; 2 + +CountSubstring(fullstring, substring){ + StringReplace, junk, fullstring, %substring%, , UseErrorLevel + return errorlevel +} diff --git a/Task/Count-occurrences-of-a-substring/BASIC/count-occurrences-of-a-substring.bas b/Task/Count-occurrences-of-a-substring/BASIC/count-occurrences-of-a-substring.bas new file mode 100644 index 0000000000..81bdba3216 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/BASIC/count-occurrences-of-a-substring.bas @@ -0,0 +1,15 @@ +DECLARE FUNCTION countSubstring& (where AS STRING, what AS STRING) + +PRINT "the three truths, th:", countSubstring&("the three truths", "th") +PRINT "ababababab, abab:", countSubstring&("ababababab", "abab") + +FUNCTION countSubstring& (where AS STRING, what AS STRING) + DIM c AS LONG, s AS LONG + s = 1 - LEN(what) + DO + s = INSTR(s + LEN(what), where, what) + IF 0 = s THEN EXIT DO + c = c + 1 + LOOP + countSubstring = c +END FUNCTION diff --git a/Task/Count-occurrences-of-a-substring/BBC-BASIC/count-occurrences-of-a-substring.bbc b/Task/Count-occurrences-of-a-substring/BBC-BASIC/count-occurrences-of-a-substring.bbc new file mode 100644 index 0000000000..aaaf81b24e --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/BBC-BASIC/count-occurrences-of-a-substring.bbc @@ -0,0 +1,16 @@ + tst$ = "the three truths" + sub$ = "th" + PRINT ; FNcountSubstring(tst$, sub$) " """ sub$ """ in """ tst$ """" + tst$ = "ababababab" + sub$ = "abab" + PRINT ; FNcountSubstring(tst$, sub$) " """ sub$ """ in """ tst$ """" + END + + DEF FNcountSubstring(A$, B$) + LOCAL I%, N% + I% = 1 : N% = 0 + REPEAT + I% = INSTR(A$, B$, I%) + IF I% THEN N% += 1 : I% += LEN(B$) + UNTIL I% = 0 + = N% diff --git a/Task/Count-occurrences-of-a-substring/Bracmat/count-occurrences-of-a-substring.bracmat b/Task/Count-occurrences-of-a-substring/Bracmat/count-occurrences-of-a-substring.bracmat new file mode 100644 index 0000000000..a77a902c32 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Bracmat/count-occurrences-of-a-substring.bracmat @@ -0,0 +1,16 @@ + ( count-substring + = n S s p + . 0:?n:?p + & !arg:(?S.?s) + & @( !S + : ? + ( [!p ? !s [?p ? + & !n+1:?n + & ~ + ) + ) + | !n + ) +& out$(count-substring$("the three truths".th)) +& out$(count-substring$(ababababab.abab)) +& ; diff --git a/Task/Count-occurrences-of-a-substring/C++/count-occurrences-of-a-substring.cpp b/Task/Count-occurrences-of-a-substring/C++/count-occurrences-of-a-substring.cpp new file mode 100644 index 0000000000..d2ee74c179 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/C++/count-occurrences-of-a-substring.cpp @@ -0,0 +1,24 @@ +#include +#include + +// returns count of non-overlapping occurrences of 'sub' in 'str' +int countSubstring(const std::string& str, const std::string& sub) +{ + if (sub.length() == 0) return 0; + int count = 0; + for (size_t offset = str.find(sub); offset != std::string::npos; + offset = str.find(sub, offset + sub.length())) + { + ++count; + } + return count; +} + +int main() +{ + std::cout << countSubstring("the three truths", "th") << '\n'; + std::cout << countSubstring("ababababab", "abab") << '\n'; + std::cout << countSubstring("abaabba*bbaba*bbab", "a*b") << '\n'; + + return 0; +} diff --git a/Task/Count-occurrences-of-a-substring/C-sharp/count-occurrences-of-a-substring.cs b/Task/Count-occurrences-of-a-substring/C-sharp/count-occurrences-of-a-substring.cs new file mode 100644 index 0000000000..50b8b1be67 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/C-sharp/count-occurrences-of-a-substring.cs @@ -0,0 +1,26 @@ +using System; + +class SubStringTestClass +{ + public static int CountSubStrings(this string testString, string testSubstring) + { + int count = 0; + + if (testString.Contains(testSubstring)) + { + for (int i = 0; i < testString.Length; i++) + { + if (testString.Substring(i).Length >= testSubstring.Length) + { + bool equals = testString.Substring(i, testSubstring.Length).Equals(testSubstring); + if (equals) + { + count++; + i += testSubstring.Length - 1; // Fix: Don't count overlapping matches + } + } + } + } + return count; + } +} diff --git a/Task/Count-occurrences-of-a-substring/C/count-occurrences-of-a-substring-1.c b/Task/Count-occurrences-of-a-substring/C/count-occurrences-of-a-substring-1.c new file mode 100644 index 0000000000..3338a69b2b --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/C/count-occurrences-of-a-substring-1.c @@ -0,0 +1,22 @@ +#include +#include + +int match(const char *s, const char *p, int overlap) +{ + int c = 0, l = strlen(p); + + while (*s != '\0') { + if (strncmp(s++, p, l)) continue; + if (!overlap) s += l - 1; + c++; + } + return c; +} + +int main() +{ + printf("%d\n", match("the three truths", "th", 0)); + printf("overlap:%d\n", match("abababababa", "aba", 1)); + printf("not: %d\n", match("abababababa", "aba", 0)); + return 0; +} diff --git a/Task/Count-occurrences-of-a-substring/C/count-occurrences-of-a-substring-2.c b/Task/Count-occurrences-of-a-substring/C/count-occurrences-of-a-substring-2.c new file mode 100644 index 0000000000..18e42fa2fb --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/C/count-occurrences-of-a-substring-2.c @@ -0,0 +1,22 @@ +#include +#include + +// returns count of non-overlapping occurrences of 'sub' in 'str' +int countSubstring(const char *str, const char *sub) +{ + int length = strlen(sub); + if (length == 0) return 0; + int count = 0; + for (str = strstr(str, sub); str; str = strstr(str + length, sub)) + ++count; + return count; +} + +int main() +{ + printf("%d\n", countSubstring("the three truths", "th")); + printf("%d\n", countSubstring("ababababab", "abab")); + printf("%d\n", countSubstring("abaabba*bbaba*bbab", "a*b")); + + return 0; +} diff --git a/Task/Count-occurrences-of-a-substring/CoffeeScript/count-occurrences-of-a-substring.coffee b/Task/Count-occurrences-of-a-substring/CoffeeScript/count-occurrences-of-a-substring.coffee new file mode 100644 index 0000000000..5f25d5d74f --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/CoffeeScript/count-occurrences-of-a-substring.coffee @@ -0,0 +1,10 @@ +countSubstring = (str, substr) -> + n = 0 + i = 0 + while (pos = str.indexOf(substr, i)) != -1 + n += 1 + i = pos + substr.length + n + +console.log countSubstring "the three truths", "th" +console.log countSubstring "ababababab", "abab" diff --git a/Task/Count-occurrences-of-a-substring/Common-Lisp/count-occurrences-of-a-substring.lisp b/Task/Count-occurrences-of-a-substring/Common-Lisp/count-occurrences-of-a-substring.lisp new file mode 100644 index 0000000000..f5ca1e3765 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Common-Lisp/count-occurrences-of-a-substring.lisp @@ -0,0 +1,8 @@ +(defun count-sub (str pat) + (loop with z = 0 with s = 0 while s do + (when (setf s (search pat str :start2 s)) + (incf z) (incf s (length pat))) + finally (return z))) + +(count-sub "ababa" "ab") ; 2 +(count-sub "ababa" "aba") ; 1 diff --git a/Task/Count-occurrences-of-a-substring/D/count-occurrences-of-a-substring.d b/Task/Count-occurrences-of-a-substring/D/count-occurrences-of-a-substring.d new file mode 100644 index 0000000000..19a7848b98 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/D/count-occurrences-of-a-substring.d @@ -0,0 +1,6 @@ +import std.stdio, std.algorithm; + +void main() { + writeln("the three truths".count("th")); + writeln("ababababab".count("abab")); +} diff --git a/Task/Count-occurrences-of-a-substring/Delphi/count-occurrences-of-a-substring.delphi b/Task/Count-occurrences-of-a-substring/Delphi/count-occurrences-of-a-substring.delphi new file mode 100644 index 0000000000..65928c18e4 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Delphi/count-occurrences-of-a-substring.delphi @@ -0,0 +1,23 @@ +program OccurrencesOfASubstring; + +{$APPTYPE CONSOLE} + +uses StrUtils; + +function CountSubstring(const aString, aSubstring: string): Integer; +var + lPosition: Integer; +begin + Result := 0; + lPosition := PosEx(aSubstring, aString); + while lPosition <> 0 do + begin + Inc(Result); + lPosition := PosEx(aSubstring, aString, lPosition + Length(aSubstring)); + end; +end; + +begin + Writeln(CountSubstring('the three truths', 'th')); + Writeln(CountSubstring('ababababab', 'abab')); +end. diff --git a/Task/Count-occurrences-of-a-substring/EGL/count-occurrences-of-a-substring.egl b/Task/Count-occurrences-of-a-substring/EGL/count-occurrences-of-a-substring.egl new file mode 100644 index 0000000000..58d3e3aa73 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/EGL/count-occurrences-of-a-substring.egl @@ -0,0 +1,51 @@ +program CountStrings + + function main() + SysLib.writeStdout("Remove and Count:"); + SysLib.writeStdout(countSubstring("th", "the three truths")); + SysLib.writeStdout(countSubstring("abab", "ababababab")); + SysLib.writeStdout(countSubstring("a*b", "abaabba*bbaba*bbab")); + SysLib.writeStdout(countSubstring("a", "abaabba*bbaba*bbab")); + SysLib.writeStdout(countSubstring(" ", "abaabba*bbaba*bbab")); + SysLib.writeStdout(countSubstring("", "abaabba*bbaba*bbab")); + SysLib.writeStdout(countSubstring("a", "")); + SysLib.writeStdout(countSubstring("", "")); + + SysLib.writeStdout("Manual Loop:"); + SysLib.writeStdout(countSubstringWithLoop("th", "the three truths")); + SysLib.writeStdout(countSubstringWithLoop("abab", "ababababab")); + SysLib.writeStdout(countSubstringWithLoop("a*b", "abaabba*bbaba*bbab")); + SysLib.writeStdout(countSubstringWithLoop("a", "abaabba*bbaba*bbab")); + SysLib.writeStdout(countSubstringWithLoop(" ", "abaabba*bbaba*bbab")); + SysLib.writeStdout(countSubstringWithLoop("", "abaabba*bbaba*bbab")); + SysLib.writeStdout(countSubstringWithLoop("a", "")); + SysLib.writeStdout(countSubstringWithLoop("", "")); + end + + function countSubstring(substr string in, str string in) returns(int) + if(str.length() > 0 and substr.length() > 0) + return (str.length() - str.replaceStr(subStr, "").length()) / subStr.length(); + else + return 0; + end + end + + function countSubstringWithLoop(substr string in, str string in) returns(int) + count int = 0; + loc, index int = 1; + strlen int = str.length(); + substrlen int = substr.length(); + + if(strlen > 0 and substrlen > 0) + while(loc != 0 and index <= strlen) + loc = str.indexOf(substr, index); + if(loc > 0) + count += 1; + index = loc + substrlen; + end + end + end + return count; + end + +end diff --git a/Task/Count-occurrences-of-a-substring/Eiffel/count-occurrences-of-a-substring.e b/Task/Count-occurrences-of-a-substring/Eiffel/count-occurrences-of-a-substring.e new file mode 100644 index 0000000000..0ae8842463 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Eiffel/count-occurrences-of-a-substring.e @@ -0,0 +1,35 @@ +class + APPLICATION +inherit + ARGUMENTS +create + make +feature {NONE} -- Initialization + make + -- Run application. + do + occurance := 0 + from + index := 1 + until + index > text.count + loop + temp := text.fuzzy_index(search_for, index, 0) + if + temp /= 0 + then + index := temp + search_for.count + occurance := occurance + 1 + else + index := text.count + 1 + end + end + print(occurance) + end + + index:INTEGER + temp:INTEGER + occurance:INTEGER + text:STRING = "ababababab" + search_for:STRING = "abab" +end diff --git a/Task/Count-occurrences-of-a-substring/Erlang/count-occurrences-of-a-substring-1.erl b/Task/Count-occurrences-of-a-substring/Erlang/count-occurrences-of-a-substring-1.erl new file mode 100644 index 0000000000..77065064f3 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Erlang/count-occurrences-of-a-substring-1.erl @@ -0,0 +1,24 @@ +%% Count non-overlapping substrings in Erlang for the rosetta code wiki. +%% Implemented by J.W. Luiten + +-module(substrings). +-export([main/2]). + +%% String exhausted, present result +match([], _Sub, _OrigSub, Acc) -> + Acc; + +%% Sub exhausted, count a match +match(String, [], Sub, Acc) -> + match(String, Sub, Sub, Acc+1); + +%% First character matches, advance +match([X|MainTail], [X|SubTail], Sub, Acc) -> + match(MainTail, SubTail, Sub, Acc); + +%% First characters do not match. Keep scanning for sub in remainder of string +match([_X|MainTail], [_Y|_SubTail], Sub, Acc)-> + match(MainTail, Sub, Sub, Acc). + +main(String, Sub) -> + match(String, Sub, Sub, 0). diff --git a/Task/Count-occurrences-of-a-substring/Erlang/count-occurrences-of-a-substring-2.erl b/Task/Count-occurrences-of-a-substring/Erlang/count-occurrences-of-a-substring-2.erl new file mode 100644 index 0000000000..00beb65734 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Erlang/count-occurrences-of-a-substring-2.erl @@ -0,0 +1 @@ +substrings:main("ababababab","abab"). diff --git a/Task/Count-occurrences-of-a-substring/Euphoria/count-occurrences-of-a-substring.euphoria b/Task/Count-occurrences-of-a-substring/Euphoria/count-occurrences-of-a-substring.euphoria new file mode 100644 index 0000000000..fcfb05f0aa --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Euphoria/count-occurrences-of-a-substring.euphoria @@ -0,0 +1,17 @@ +function countSubstring(sequence s, sequence sub) + integer from,count + count = 0 + from = 1 + while 1 do + from = match_from(sub,s,from) + if not from then + exit + end if + from += length(sub) + count += 1 + end while + return count +end function + +? countSubstring("the three truths","th") +? countSubstring("ababababab","abab") diff --git a/Task/Count-occurrences-of-a-substring/Forth/count-occurrences-of-a-substring.fth b/Task/Count-occurrences-of-a-substring/Forth/count-occurrences-of-a-substring.fth new file mode 100644 index 0000000000..c2fa1e1754 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Forth/count-occurrences-of-a-substring.fth @@ -0,0 +1,9 @@ +: str-count ( s1 len s2 len -- n ) + 2swap 0 >r + begin 2over search + while 2over nip /string + r> 1+ >r + repeat 2drop 2drop r> ; + +s" the three truths" s" th" str-count . \ 3 +s" ababababab" s" abab" str-count . \ 2 diff --git a/Task/Count-occurrences-of-a-substring/Fortran/count-occurrences-of-a-substring.f b/Task/Count-occurrences-of-a-substring/Fortran/count-occurrences-of-a-substring.f new file mode 100644 index 0000000000..a9156702ad --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Fortran/count-occurrences-of-a-substring.f @@ -0,0 +1,28 @@ +program Example + implicit none + integer :: n + + n = countsubstring("the three truths", "th") + write(*,*) n + n = countsubstring("ababababab", "abab") + write(*,*) n + n = countsubstring("abaabba*bbaba*bbab", "a*b") + write(*,*) n + +contains + +function countsubstring(s1, s2) result(c) + character(*), intent(in) :: s1, s2 + integer :: c, p, posn + + c = 0 + if(len(s2) == 0) return + p = 1 + do + posn = index(s1(p:), s2) + if(posn == 0) return + c = c + 1 + p = p + posn + len(s2) + end do +end function +end program diff --git a/Task/Count-occurrences-of-a-substring/Go/count-occurrences-of-a-substring.go b/Task/Count-occurrences-of-a-substring/Go/count-occurrences-of-a-substring.go new file mode 100644 index 0000000000..eead800004 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Go/count-occurrences-of-a-substring.go @@ -0,0 +1,10 @@ +package main +import ( + "fmt" + "strings" +) + +func main() { + fmt.Println(strings.Count("the three truths", "th")) // says: 3 + fmt.Println(strings.Count("ababababab", "abab")) // says: 2 +} diff --git a/Task/Count-occurrences-of-a-substring/Haskell/count-occurrences-of-a-substring.hs b/Task/Count-occurrences-of-a-substring/Haskell/count-occurrences-of-a-substring.hs new file mode 100644 index 0000000000..59bb161825 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Haskell/count-occurrences-of-a-substring.hs @@ -0,0 +1,8 @@ +import Data.Text hiding (length) + +-- Return the number of non-overlapping occurrences of sub in str. +countSubStrs str sub = length $ breakOnAll (pack sub) (pack str) + +main = do + print $ countSubStrs "the three truths" "th" + print $ countSubStrs "ababababab" "abab" diff --git a/Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-1.java b/Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-1.java new file mode 100644 index 0000000000..644a1bb051 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-1.java @@ -0,0 +1,11 @@ +public class CountSubstring { + public static int countSubstring(String subStr, String str){ + return (str.length() - str.replace(subStr, "").length()) / subStr.length(); + } + + public static void main(String[] args){ + System.out.println(countSubstring("th", "the three truths")); + System.out.println(countSubstring("abab", "ababababab")); + System.out.println(countSubstring("a*b", "abaabba*bbaba*bbab")); + } +} diff --git a/Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-2.java b/Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-2.java new file mode 100644 index 0000000000..8b78204f13 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-2.java @@ -0,0 +1,15 @@ +import java.util.regex.Pattern; + +public class CountSubstring { + public static int countSubstring(String subStr, String str){ + // the result of split() will contain one more element than the delimiter + // the "-1" second argument makes it not discard trailing empty strings + return str.split(Pattern.quote(subStr), -1).length - 1; + } + + public static void main(String[] args){ + System.out.println(countSubstring("th", "the three truths")); + System.out.println(countSubstring("abab", "ababababab")); + System.out.println(countSubstring("a*b", "abaabba*bbaba*bbab")); + } +} diff --git a/Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-3.java b/Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-3.java new file mode 100644 index 0000000000..47f926cc28 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Java/count-occurrences-of-a-substring-3.java @@ -0,0 +1,15 @@ +public class CountSubstring { + public static int countSubstring(String subStr, String str){ + int count = 0; + for (int loc = str.indexOf(subStr); loc != -1; + loc = str.indexOf(subStr, loc + subStr.length())) + count++; + return count; + } + + public static void main(String[] args){ + System.out.println(countSubstring("th", "the three truths")); + System.out.println(countSubstring("abab", "ababababab")); + System.out.println(countSubstring("a*b", "abaabba*bbaba*bbab")); + } +} diff --git a/Task/Count-occurrences-of-a-substring/JavaScript/count-occurrences-of-a-substring.js b/Task/Count-occurrences-of-a-substring/JavaScript/count-occurrences-of-a-substring.js new file mode 100644 index 0000000000..dd96fa6666 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/JavaScript/count-occurrences-of-a-substring.js @@ -0,0 +1,3 @@ +function countSubstring(str, subStr){ + return str.match(new RegExp(subStr, "g")).length +} diff --git a/Task/Count-occurrences-of-a-substring/Lua/count-occurrences-of-a-substring.lua b/Task/Count-occurrences-of-a-substring/Lua/count-occurrences-of-a-substring.lua new file mode 100644 index 0000000000..96b8e6849a --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Lua/count-occurrences-of-a-substring.lua @@ -0,0 +1,8 @@ +function Count_Substring( s1, s2 ) + local magic = "[%^%$%(%)%%%.%[%]%*%+%-%?]" + local percent = function(s)return "%"..s end + return select( 2, s1:gsub( s2:gsub(magic,percent), "" ) ) +end + +print( Count_Substring( "the three truths", "th" ) ) +print( Count_Substring( "ababababab","abab" ) ) diff --git a/Task/Count-occurrences-of-a-substring/MATLAB/count-occurrences-of-a-substring.m b/Task/Count-occurrences-of-a-substring/MATLAB/count-occurrences-of-a-substring.m new file mode 100644 index 0000000000..054674068e --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/MATLAB/count-occurrences-of-a-substring.m @@ -0,0 +1,6 @@ + % Count occurrences of a substring without overlap + length(findstr("ababababab","abab",0)) + length(findstr("the three truths","th",0)) + + % Count occurrences of a substring with overlap + length(findstr("ababababab","abab",1)) diff --git a/Task/Count-occurrences-of-a-substring/PHP/count-occurrences-of-a-substring.php b/Task/Count-occurrences-of-a-substring/PHP/count-occurrences-of-a-substring.php new file mode 100644 index 0000000000..13549d7c64 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/PHP/count-occurrences-of-a-substring.php @@ -0,0 +1,4 @@ + diff --git a/Task/Count-occurrences-of-a-substring/Perl/count-occurrences-of-a-substring.pl b/Task/Count-occurrences-of-a-substring/Perl/count-occurrences-of-a-substring.pl new file mode 100644 index 0000000000..810e1be46f --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Perl/count-occurrences-of-a-substring.pl @@ -0,0 +1,10 @@ +sub countSubstring { + my $str = shift; + my $sub = quotemeta(shift); + my $count = () = $str =~ /$sub/g; + return $count; +# or return scalar( () = $str =~ /$sub/g ); +} + +print countSubstring("the three truths","th"), "\n"; # prints "3" +print countSubstring("ababababab","abab"), "\n"; # prints "2" diff --git a/Task/Count-occurrences-of-a-substring/PicoLisp/count-occurrences-of-a-substring.l b/Task/Count-occurrences-of-a-substring/PicoLisp/count-occurrences-of-a-substring.l new file mode 100644 index 0000000000..c186865cbb --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/PicoLisp/count-occurrences-of-a-substring.l @@ -0,0 +1,7 @@ +(de countSubstring (Str Sub) + (let (Cnt 0 H (chop Sub)) + (for (S (chop Str) S (cdr S)) + (when (head H S) + (inc 'Cnt) + (setq S (map prog2 H S)) ) ) + Cnt ) ) diff --git a/Task/Count-occurrences-of-a-substring/Python/count-occurrences-of-a-substring.py b/Task/Count-occurrences-of-a-substring/Python/count-occurrences-of-a-substring.py new file mode 100644 index 0000000000..f0bd233198 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Python/count-occurrences-of-a-substring.py @@ -0,0 +1,4 @@ +>>> "the three truths".count("th") +3 +>>> "ababababab".count("abab") +2 diff --git a/Task/Count-occurrences-of-a-substring/REXX/count-occurrences-of-a-substring.rexx b/Task/Count-occurrences-of-a-substring/REXX/count-occurrences-of-a-substring.rexx new file mode 100644 index 0000000000..d7eb4f4eea --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/REXX/count-occurrences-of-a-substring.rexx @@ -0,0 +1,15 @@ +/*REXX program: use a subroutine that counts occurrences of a substring.*/ +bag = "the three truths" + x = "th" + say left(bag,30) left(x,15) 'found' countstr(bag,x) +bag = "ababababab" + x = "abab" + say left(bag,30) left(x,15) 'found' countstr(bag,x) +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────COUNTSTR subroutine──────────────*/ +countstr: procedure; parse arg haystack, needle, startAt +if startAt=='' then startAt=1; width=length(needle) + do k=0 until _==0; _=pos(needle,haystack,startAt) + startAt = _ + width + end /*k*/ +return k diff --git a/Task/Count-occurrences-of-a-substring/Ruby/count-occurrences-of-a-substring.rb b/Task/Count-occurrences-of-a-substring/Ruby/count-occurrences-of-a-substring.rb new file mode 100644 index 0000000000..7e6d5f12bc --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Ruby/count-occurrences-of-a-substring.rb @@ -0,0 +1,8 @@ +def countSubstrings str, subStr + return str.scan(subStr).length +end + +irb(main):001:0> "the three truths".scan("th").length +=> 3 +irb(main):002:0> "ababababab".scan("abab").length +=> 2 diff --git a/Task/Count-occurrences-of-a-substring/Scala/count-occurrences-of-a-substring.scala b/Task/Count-occurrences-of-a-substring/Scala/count-occurrences-of-a-substring.scala new file mode 100644 index 0000000000..9830defcf0 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Scala/count-occurrences-of-a-substring.scala @@ -0,0 +1,11 @@ +import scala.annotation.tailrec +def countSubstring(str1:String, str2:String):Int={ + @tailrec def count(pos:Int, c:Int):Int={ + val idx=str1 indexOf(str2, pos) + if(idx == -1) c else count(idx+str2.size, c+1) + } + count(0,0) +} + +println(countSubstring("ababababab", "abab")) +println(countSubstring("the three truths", "th")) diff --git a/Task/Count-occurrences-of-a-substring/Tcl/count-occurrences-of-a-substring.tcl b/Task/Count-occurrences-of-a-substring/Tcl/count-occurrences-of-a-substring.tcl new file mode 100644 index 0000000000..3698b7537a --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Tcl/count-occurrences-of-a-substring.tcl @@ -0,0 +1,6 @@ +proc countSubstrings {haystack needle} { + regexp -all ***=$needle $haystack +} +puts [countSubstrings "the three truths" "th"] +puts [countSubstrings "ababababab" "abab"] +puts [countSubstrings "abaabba*bbaba*bbab" "a*b"] diff --git a/Task/Count-the-coins/0DESCRIPTION b/Task/Count-the-coins/0DESCRIPTION new file mode 100644 index 0000000000..c02c287227 --- /dev/null +++ b/Task/Count-the-coins/0DESCRIPTION @@ -0,0 +1,16 @@ +There are four types of common coins in US currency: quarters (25 cents), dimes (10), nickels (5) and pennies (1). There are 6 ways to make change for 15 cents: +* A dime and a nickel; +* A dime and 5 pennies; +* 3 nickels; +* 2 nickels and 5 pennies; +* A nickel and 10 pennies; +* 15 pennies. + +How many ways are there to make change for a dollar using these common coins? (1 dollar = 100 cents). + +'''Optional:''' + +Less common are dollar coins (100 cents); very rare are half dollars (50 cents). With the addition of these two coins, how many ways are there to make change for $1000? (note: the answer is larger than 232). + +'''Algorithm''': +See [http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_Temp_52 here]. diff --git a/Task/Count-the-coins/AWK/count-the-coins-1.awk b/Task/Count-the-coins/AWK/count-the-coins-1.awk new file mode 100644 index 0000000000..e4401a8179 --- /dev/null +++ b/Task/Count-the-coins/AWK/count-the-coins-1.awk @@ -0,0 +1,26 @@ +#!/usr/bin/awk -f + +BEGIN { + print cc(100) + exit +} + +function cc(amount, coins, numPennies, numNickles, numQuarters, p, n, d, q, s, count) { + numPennies = amount + numNickles = int(amount / 5) + numDimes = int(amount / 10) + numQuarters = int(amount / 25) + + count = 0 + for (p = 0; p <= numPennies; p++) { + for (n = 0; n <= numNickles; n++) { + for (d = 0; d <= numDimes; d++) { + for (q = 0; q <= numQuarters; q++) { + s = p + n * 5 + d * 10 + q * 25; + if (s == 100) count++; + } + } + } + } + return count; +} diff --git a/Task/Count-the-coins/AWK/count-the-coins-2.awk b/Task/Count-the-coins/AWK/count-the-coins-2.awk new file mode 100644 index 0000000000..c1fcb4362e --- /dev/null +++ b/Task/Count-the-coins/AWK/count-the-coins-2.awk @@ -0,0 +1,27 @@ +#!/usr/bin/awk -f + +BEGIN { + COINSEP = ", " + coins = 1 COINSEP 5 COINSEP 10 COINSEP 25 + print cc(100, coins) + exit +} + +function cc(amt, coins) { + if (length(coins) == 0) return 0 + if (amt < 0) return 0 + if (amt == 0) return 1 + return cc(amt, tail(coins)) + cc(amt - head(coins), coins) +} + +function tail(coins, koins, s, c) { + split(coins, koins, COINSEP) + s = "" + for (c = 2; c <= length(koins); c++) s = s (s == "" ? "" : COINSEP) koins[c] + return s; +} + +function head(coins, koins) { + split(coins, koins, COINSEP) + return koins[1] +} diff --git a/Task/Count-the-coins/Ada/count-the-coins.ada b/Task/Count-the-coins/Ada/count-the-coins.ada new file mode 100644 index 0000000000..307a6c5ac4 --- /dev/null +++ b/Task/Count-the-coins/Ada/count-the-coins.ada @@ -0,0 +1,32 @@ +with Ada.Text_IO; + +procedure Count_The_Coins is + + type Counter_Type is range 0 .. 2**63-1; -- works with gnat + type Coin_List is array(Positive range <>) of Positive; + + function Count(Goal: Natural; Coins: Coin_List) return Counter_Type is + Cnt: array(0 .. Goal) of Counter_Type := (0 => 1, others => 0); + -- 0 => we already know one way to choose (no) coins that sum up to zero + -- 1 .. Goal => we do not (yet) other ways to choose coins + begin + for C in Coins'Range loop + for Amount in 1 .. Cnt'Last loop + if Coins(C) <= Amount then + Cnt(Amount) := Cnt(Amount) + Cnt(Amount-Coins(C)); + -- Amount-Coins(C) plus Coins(C) sums up to Amount; + end if; + end loop; + end loop; + return Cnt(Goal); + end Count; + + procedure Print(C: Counter_Type) is + begin + Ada.Text_IO.Put_Line(Counter_Type'Image(C)); + end Print; + +begin + Print(Count( 1_00, (25, 10, 5, 1))); + Print(Count(1000_00, (100, 50, 25, 10, 5, 1))); +end Count_The_Coins; diff --git a/Task/Count-the-coins/AutoHotkey/count-the-coins.ahk b/Task/Count-the-coins/AutoHotkey/count-the-coins.ahk new file mode 100644 index 0000000000..0d54a70898 --- /dev/null +++ b/Task/Count-the-coins/AutoHotkey/count-the-coins.ahk @@ -0,0 +1,17 @@ +countChange(amount){ + return cc(amount, 4) +} + +cc(amount, kindsOfCoins){ + if ( amount == 0 ) + return 1 + if ( amount < 0 ) || ( kindsOfCoins == 0 ) + return 0 + return cc(amount, kindsOfCoins-1) + + cc(amount - firstDenomination(kindsOfCoins), kindsOfCoins) +} + +firstDenomination(kindsOfCoins){ + return [1, 5, 10, 25][kindsOfCoins] +} +MsgBox % countChange(100) diff --git a/Task/Count-the-coins/BBC-BASIC/count-the-coins.bbc b/Task/Count-the-coins/BBC-BASIC/count-the-coins.bbc new file mode 100644 index 0000000000..26ca2c160e --- /dev/null +++ b/Task/Count-the-coins/BBC-BASIC/count-the-coins.bbc @@ -0,0 +1,36 @@ + DIM uscoins%(3) + uscoins%() = 1, 5, 10, 25 + PRINT FNchange(100, uscoins%()) " ways of making $1" + PRINT FNchange(1000, uscoins%()) " ways of making $10" + + DIM ukcoins%(7) + ukcoins%() = 1, 2, 5, 10, 20, 50, 100, 200 + PRINT FNchange(100, ukcoins%()) " ways of making £1" + PRINT FNchange(1000, ukcoins%()) " ways of making £10" + END + + DEF FNchange(sum%, coins%()) + LOCAL C%, D%, I%, N%, P%, Q%, S%, table() + C% = 0 + N% = DIM(coins%(),1) + 1 + FOR I% = 0 TO N% - 1 + D% = coins%(I%) + IF D% <= sum% IF D% >= C% C% = D% + 1 + NEXT + C% *= N% + DIM table(C%-1) + FOR I% = 0 TO N%-1 : table(I%) = 1 : NEXT + + P% = N% + FOR S% = 1 TO sum% + FOR I% = 0 TO N% - 1 + IF I% = 0 IF P% >= C% P% = 0 + IF coins%(I%) <= S% THEN + Q% = P% - coins%(I%) * N% + IF Q% >= 0 table(P%) = table(Q%) ELSE table(P%) = table(Q% + C%) + ENDIF + IF I% table(P%) += table(P% - 1) + P% += 1 + NEXT + NEXT + = table(P%-1) diff --git a/Task/Count-the-coins/C/count-the-coins-1.c b/Task/Count-the-coins/C/count-the-coins-1.c new file mode 100644 index 0000000000..683d6cc441 --- /dev/null +++ b/Task/Count-the-coins/C/count-the-coins-1.c @@ -0,0 +1,100 @@ +#include +#include +#include + +// ad hoc 128 bit integer type; faster than using GMP because of low +// overhead +typedef struct { uint64_t x[2]; } i128; + +// display in decimal +void show(i128 v) { + uint32_t x[4] = {v.x[0], v.x[0] >> 32, v.x[1], v.x[1] >> 32}; + int i, j = 0, len = 4; + char buf[100]; + do { + uint64_t c = 0; + for (i = len; i--; ) { + c = (c << 32) + x[i]; + x[i] = c / 10, c %= 10; + } + + buf[j++] = c + '0'; + for (len = 4; !x[len - 1]; len--); + } while (len); + + while (j--) putchar(buf[j]); + putchar('\n'); +} + +i128 count(int sum, int *coins) +{ + int n, i, k; + for (n = 0; coins[n]; n++); + + i128 **v = malloc(sizeof(int*) * n); + int *idx = malloc(sizeof(int) * n); + + for (i = 0; i < n; i++) { + idx[i] = coins[i]; + // each v[i] is a cyclic buffer + v[i] = calloc(sizeof(i128), coins[i]); + } + + v[0][coins[0] - 1] = (i128) {{1, 0}}; + + for (k = 0; k <= sum; k++) { + for (i = 0; i < n; i++) + if (!idx[i]--) idx[i] = coins[i] - 1; + + i128 c = v[0][ idx[0] ]; + + for (i = 1; i < n; i++) { + i128 *p = v[i] + idx[i]; + + // 128 bit addition + p->x[0] += c.x[0]; + p->x[1] += c.x[1]; + if (p->x[0] < c.x[0]) // carry + p->x[1] ++; + c = *p; + } + } + + i128 r = v[n - 1][idx[n-1]]; + + for (i = 0; i < n; i++) free(v[i]); + free(v); + free(idx); + + return r; +} + +// simple recursive method; slow +int count2(int sum, int *coins) +{ + if (!*coins || sum < 0) return 0; + if (!sum) return 1; + return count2(sum - *coins, coins) + count2(sum, coins + 1); +} + +int main(void) +{ + int us_coins[] = { 100, 50, 25, 10, 5, 1, 0 }; + int eu_coins[] = { 200, 100, 50, 20, 10, 5, 2, 1, 0 }; + + show(count( 100, us_coins + 2)); + show(count( 1000, us_coins)); + + show(count( 1000 * 100, us_coins)); + show(count( 10000 * 100, us_coins)); + show(count(100000 * 100, us_coins)); + + putchar('\n'); + + show(count( 1 * 100, eu_coins)); + show(count( 1000 * 100, eu_coins)); + show(count( 10000 * 100, eu_coins)); + show(count(100000 * 100, eu_coins)); + + return 0; +} diff --git a/Task/Count-the-coins/C/count-the-coins-2.c b/Task/Count-the-coins/C/count-the-coins-2.c new file mode 100644 index 0000000000..35d6903e16 --- /dev/null +++ b/Task/Count-the-coins/C/count-the-coins-2.c @@ -0,0 +1,9 @@ +242 +13398445413854501 +1333983445341383545001 +133339833445334138335450001 + +4563 +10056050940818192726001 +99341140660285639188927260001 +992198221207406412424859964272600001 diff --git a/Task/Count-the-coins/Common-Lisp/count-the-coins.lisp b/Task/Count-the-coins/Common-Lisp/count-the-coins.lisp new file mode 100644 index 0000000000..7ce5f072e2 --- /dev/null +++ b/Task/Count-the-coins/Common-Lisp/count-the-coins.lisp @@ -0,0 +1,23 @@ +(defun count-change (amount coins) + (let ((cache (make-array (list (1+ amount) (length coins)) + :initial-element nil))) + (macrolet ((h () `(aref cache n l))) + (labels + ((recur (n coins &optional (l (1- (length coins)))) + (cond ((< l 0) 0) + ((< n 0) 0) + ((= n 0) 1) + (t (if (h) (h) ; cached + (setf (h) ; or not + (+ (recur (- n (car coins)) coins l) + (recur n (cdr coins) (1- l))))))))) + + ;; enable next line if recursions too deep + ;(loop for i from 0 below amount do (recur i coins)) + (recur amount coins))))) + +; (compile 'count-change) ; for CLISP + +(print (count-change 100 '(25 10 5 1))) ; = 242 +(print (count-change 100000 '(100 50 25 10 5 1))) ; = 13398445413854501 +(terpri) diff --git a/Task/Count-the-coins/D/count-the-coins-1.d b/Task/Count-the-coins/D/count-the-coins-1.d new file mode 100644 index 0000000000..b6fcffa8f3 --- /dev/null +++ b/Task/Count-the-coins/D/count-the-coins-1.d @@ -0,0 +1,15 @@ +import std.stdio, std.bigint; + +auto changes(int amount, int[] coins) { + auto ways = new BigInt[amount + 1]; + ways[0] = 1; + foreach (coin; coins) + foreach (j; coin .. amount+1) + ways[j] += ways[j - coin]; + return ways[amount]; +} + +void main() { + writeln(changes( 1_00, [25, 10, 5, 1])); + writeln(changes(1000_00, [100, 50, 25, 10, 5, 1])); +} diff --git a/Task/Count-the-coins/D/count-the-coins-2.d b/Task/Count-the-coins/D/count-the-coins-2.d new file mode 100644 index 0000000000..246c5dd4a6 --- /dev/null +++ b/Task/Count-the-coins/D/count-the-coins-2.d @@ -0,0 +1,41 @@ +import std.stdio, std.bigint; + +BigInt countChanges(in int amount, in int[] coins)/*pure nothrow*/ { + immutable size_t n = coins.length; + int cycle; + foreach (const c; coins) + if (c <= amount && c >= cycle) + cycle = c + 1; + cycle *= n; + auto table = new BigInt[cycle]; + table[0 .. n] = BigInt(1); + + int pos = n; + foreach (s; 1 .. amount + 1) { + foreach (i; 0 .. n) { + if (i == 0 && pos >= cycle) + pos = 0; + if (coins[i] <= s) { + immutable int q = pos - (coins[i] * n); + table[pos] = (q >= 0) ? table[q] : table[q + cycle]; + } + if (i) + table[pos] += table[pos - 1]; + pos++; + } + } + + return table[pos - 1]; +} + +void main() { + immutable usCoins = [100, 50, 25, 10, 5, 1]; + immutable euCoins = [200, 100, 50, 20, 10, 5, 2, 1]; + + foreach (coins; [usCoins, euCoins]) { + writeln(countChanges( 1_00, coins[2 .. $])); + writeln(countChanges( 1000_00, coins)); + writeln(countChanges( 10000_00, coins)); + writeln(countChanges(100000_00, coins), "\n"); + } +} diff --git a/Task/Count-the-coins/D/count-the-coins-3.d b/Task/Count-the-coins/D/count-the-coins-3.d new file mode 100644 index 0000000000..acd0d120f3 --- /dev/null +++ b/Task/Count-the-coins/D/count-the-coins-3.d @@ -0,0 +1,60 @@ +import std.stdio, std.bigint, std.algorithm, std.conv; + +struct Ucent { /// Simplified 128-bit integer (like ucent). + ulong hi, lo; + static immutable one = Ucent(0, 1); + + void opOpAssign(string op="+")(in ref Ucent y) pure nothrow { + this.hi += y.hi; + if (this.lo >= ~y.lo) + this.hi++; + this.lo += y.lo; + } + + const string toString() const { + return text((BigInt(this.hi) << 64) + this.lo); + } +} + +Ucent countChanges(in int amount, in int[] coins) pure /*nothrow*/ { + immutable n = coins.length; + + // points to a cyclic buffer of length coins[i] + auto p = (new Ucent*[n]).ptr; + auto q = (new Ucent*[n]).ptr; // iterates it. + //auto buf = new Ucent[sum(coins)]; + auto buf = new Ucent[reduce!q{ a + b }(0, coins)]; // not nothrow + + p[0] = buf.ptr; + foreach (i; 0 .. n) { + if (i) + p[i] = coins[i - 1] + p[i - 1]; + *p[i] = Ucent.one; + q[i] = p[i]; + } + + Ucent prev; + foreach (j; 1 .. amount + 1) + foreach (i; 0 .. n) { + q[i]--; + if (q[i] < p[i]) + q[i] = p[i] + coins[i] - 1; + if (i) + *q[i] += prev; + prev = *q[i]; + } + + return prev; +} + +void main() { + immutable usCoins = [100, 50, 25, 10, 5, 1]; + immutable euCoins = [200, 100, 50, 20, 10, 5, 2, 1]; + + foreach (coins; [usCoins, euCoins]) { + writeln(countChanges( 1_00, coins[2 .. $])); + writeln(countChanges( 1000_00, coins)); + writeln(countChanges( 10000_00, coins)); + writeln(countChanges(100000_00, coins), "\n"); + } +} diff --git a/Task/Count-the-coins/Erlang/count-the-coins.erl b/Task/Count-the-coins/Erlang/count-the-coins.erl new file mode 100644 index 0000000000..d0516a6965 --- /dev/null +++ b/Task/Count-the-coins/Erlang/count-the-coins.erl @@ -0,0 +1,31 @@ +-module(coins). +-compile(export_all). + +count(Amount, Coins) -> + {N,_C} = count(Amount, Coins, dict:new()), + N. + +count(0,_,Cache) -> + {1,Cache}; +count(N,_,Cache) when N < 0 -> + {0,Cache}; +count(_N,[],Cache) -> + {0,Cache}; +count(N,[C|Cs]=Coins,Cache) -> + case dict:is_key({N,length(Coins)},Cache) of + true -> + {dict:fetch({N,length(Coins)},Cache), Cache}; + false -> + {N1,C1} = count(N-C,Coins,Cache), + {N2,C2} = count(N,Cs,C1), + {N1+N2,dict:store({N,length(Coins)},N1+N2,C2)} + end. + +print(Amount, Coins) -> + io:format("~b ways to make change for ~b cents with ~p coins~n",[count(Amount,Coins),Amount,Coins]). + +test() -> + A1 = 100, C1 = [25,10,5,1], + print(A1,C1), + A2 = 100000, C2 = [100, 50, 25, 10, 5, 1], + print(A2,C2). diff --git a/Task/Count-the-coins/Forth/count-the-coins.fth b/Task/Count-the-coins/Forth/count-the-coins.fth new file mode 100644 index 0000000000..06d1de2efe --- /dev/null +++ b/Task/Count-the-coins/Forth/count-the-coins.fth @@ -0,0 +1,16 @@ +\ counting change (SICP section 1.2.2) + +: table create does> swap cells + @ ; +table coin-value 0 , 1 , 5 , 10 , 25 , 50 , + +: count-change ( total coin -- n ) + over 0= if + 2drop 1 + else over 0< over 0= or if + 2drop 0 + else + 2dup coin-value - over recurse + >r 1- recurse r> + + then then ; + +100 5 count-change . diff --git a/Task/Count-the-coins/Go/count-the-coins-1.go b/Task/Count-the-coins/Go/count-the-coins-1.go new file mode 100644 index 0000000000..a13342631c --- /dev/null +++ b/Task/Count-the-coins/Go/count-the-coins-1.go @@ -0,0 +1,37 @@ +package main + +import "fmt" + +func main() { + amount := 100 + fmt.Println("amount, ways to make change:", amount, countChange(amount)) +} + +func countChange(amount int) int64 { + return cc(amount, 4) +} + +func cc(amount, kindsOfCoins int) int64 { + switch { + case amount == 0: + return 1 + case amount < 0 || kindsOfCoins == 0: + return 0 + } + return cc(amount, kindsOfCoins-1) + + cc(amount - firstDenomination(kindsOfCoins), kindsOfCoins) +} + +func firstDenomination(kindsOfCoins int) int { + switch kindsOfCoins { + case 1: + return 1 + case 2: + return 5 + case 3: + return 10 + case 4: + return 25 + } + panic(kindsOfCoins) +} diff --git a/Task/Count-the-coins/Go/count-the-coins-2.go b/Task/Count-the-coins/Go/count-the-coins-2.go new file mode 100644 index 0000000000..fb3f9ba2a5 --- /dev/null +++ b/Task/Count-the-coins/Go/count-the-coins-2.go @@ -0,0 +1,19 @@ +package main + +import "fmt" + +func main() { + amount := 1000 * 100 + fmt.Println("amount, ways to make change:", amount, countChange(amount)) +} + +func countChange(amount int) int64 { + ways := make([]int64, amount+1) + ways[0] = 1 + for _, coin := range []int{100, 50, 25, 10, 5, 1} { + for j := coin; j <= amount; j++ { + ways[j] += ways[j-coin] + } + } + return ways[amount] +} diff --git a/Task/Count-the-coins/Haskell/count-the-coins-1.hs b/Task/Count-the-coins/Haskell/count-the-coins-1.hs new file mode 100644 index 0000000000..f4999213f6 --- /dev/null +++ b/Task/Count-the-coins/Haskell/count-the-coins-1.hs @@ -0,0 +1,5 @@ +count 0 _ = 1 +count _ [] = 0 +count x (c:coins) = sum [ count (x - (n * c)) coins | n <- [0..(quot x c)] ] + +main = print (count 100 [1, 5, 10, 25]) diff --git a/Task/Count-the-coins/Haskell/count-the-coins-2.hs b/Task/Count-the-coins/Haskell/count-the-coins-2.hs new file mode 100644 index 0000000000..753c9195b3 --- /dev/null +++ b/Task/Count-the-coins/Haskell/count-the-coins-2.hs @@ -0,0 +1,7 @@ +count = foldr addCoin (1:repeat 0) + where addCoin c oldlist = newlist + where newlist = (take c oldlist) ++ zipWith (+) newlist (drop c oldlist) + +main = do + print (count [25,10,5,1] !! 100) + print (count [100,50,25,10,5,1] !! 100000) diff --git a/Task/Count-the-coins/Java/count-the-coins.java b/Task/Count-the-coins/Java/count-the-coins.java new file mode 100644 index 0000000000..cf77d3bc10 --- /dev/null +++ b/Task/Count-the-coins/Java/count-the-coins.java @@ -0,0 +1,46 @@ +import java.util.Arrays; +import java.math.BigInteger; + +class CountTheCoins { + private static BigInteger countChanges(int amount, int[] coins){ + final int n = coins.length; + int cycle = 0; + for (int c : coins) + if (c <= amount && c >= cycle) + cycle = c + 1; + cycle *= n; + BigInteger[] table = new BigInteger[cycle]; + Arrays.fill(table, 0, n, BigInteger.ONE); + Arrays.fill(table, n, cycle, BigInteger.ZERO); + + int pos = n; + for (int s = 1; s <= amount; s++) { + for (int i = 0; i < n; i++) { + if (i == 0 && pos >= cycle) + pos = 0; + if (coins[i] <= s) { + final int q = pos - (coins[i] * n); + table[pos] = (q >= 0) ? table[q] : table[q + cycle]; + } + if (i != 0) + table[pos] = table[pos].add(table[pos - 1]); + pos++; + } + } + + return table[pos - 1]; + } + + public static void main(String[] args) { + final int[][] coinsUsEu = {{100, 50, 25, 10, 5, 1}, + {200, 100, 50, 20, 10, 5, 2, 1}}; + + for (int[] coins : coinsUsEu) { + System.out.println(countChanges( 100, + Arrays.copyOfRange(coins, 2, coins.length))); + System.out.println(countChanges( 100000, coins)); + System.out.println(countChanges( 1000000, coins)); + System.out.println(countChanges(10000000, coins) + "\n"); + } + } +} diff --git a/Task/Count-the-coins/JavaScript/count-the-coins-1.js b/Task/Count-the-coins/JavaScript/count-the-coins-1.js new file mode 100644 index 0000000000..035091897e --- /dev/null +++ b/Task/Count-the-coins/JavaScript/count-the-coins-1.js @@ -0,0 +1,19 @@ +function countcoins(t, o) { + 'use strict'; + var targetsLength = t + 1; + var operandsLength = o.length; + t = [1]; + + for (var a = 0; a < operandsLength; a ++) { + for (var b = 1; b < targetsLength; b ++) { + + // initialise undefined target + t[b] = t[b] ? t[b] : 0; + + // accumulate target + operand ways + t[b] += (b < o[a]) ? 0 : t[b - o[a]]; + } + } + + return t[targetsLength - 1]; +} diff --git a/Task/Count-the-coins/JavaScript/count-the-coins-2.js b/Task/Count-the-coins/JavaScript/count-the-coins-2.js new file mode 100644 index 0000000000..395009378e --- /dev/null +++ b/Task/Count-the-coins/JavaScript/count-the-coins-2.js @@ -0,0 +1,2 @@ +countcoins(100, [1,5,10,25]); +242 diff --git a/Task/Count-the-coins/JavaScript/count-the-coins-3.js b/Task/Count-the-coins/JavaScript/count-the-coins-3.js new file mode 100644 index 0000000000..53f1a9ef8e --- /dev/null +++ b/Task/Count-the-coins/JavaScript/count-the-coins-3.js @@ -0,0 +1,25 @@ +function countcoins(t, o) { + 'use strict'; + var operandsLength = o.length; + var solutions = 0; + + function permutate(a, x) { + + // base case + if (a === t) { + solutions ++; + } + + // recursive case + else if (a < t) { + for (var i = 0; i < operandsLength; i ++) { + if (i >= x) { + permutate(o[i] + a, i); + } + } + } + } + + permutate(0, 0); + return solutions; +} diff --git a/Task/Count-the-coins/JavaScript/count-the-coins-4.js b/Task/Count-the-coins/JavaScript/count-the-coins-4.js new file mode 100644 index 0000000000..395009378e --- /dev/null +++ b/Task/Count-the-coins/JavaScript/count-the-coins-4.js @@ -0,0 +1,2 @@ +countcoins(100, [1,5,10,25]); +242 diff --git a/Task/Count-the-coins/PicoLisp/count-the-coins-1.l b/Task/Count-the-coins/PicoLisp/count-the-coins-1.l new file mode 100644 index 0000000000..3747609423 --- /dev/null +++ b/Task/Count-the-coins/PicoLisp/count-the-coins-1.l @@ -0,0 +1,8 @@ +(de coins (Sum Coins) + (let (Buf (mapcar '((N) (cons 1 (need (dec N) 0))) Coins) Prev) + (do Sum + (zero Prev) + (for L Buf + (inc (rot L) Prev) + (setq Prev (car L)) ) ) + Prev ) ) diff --git a/Task/Count-the-coins/PicoLisp/count-the-coins-2.l b/Task/Count-the-coins/PicoLisp/count-the-coins-2.l new file mode 100644 index 0000000000..5c13c8e59e --- /dev/null +++ b/Task/Count-the-coins/PicoLisp/count-the-coins-2.l @@ -0,0 +1,6 @@ +(for Coins '((100 50 25 10 5 1) (200 100 50 20 10 5 2 1)) + (println (coins 100 (cddr Coins))) + (println (coins (* 1000 100) Coins)) + (println (coins (* 10000 100) Coins)) + (println (coins (* 100000 100) Coins)) + (prinl) ) diff --git a/Task/Count-the-coins/Python/count-the-coins-1.py b/Task/Count-the-coins/Python/count-the-coins-1.py new file mode 100644 index 0000000000..ee267f8029 --- /dev/null +++ b/Task/Count-the-coins/Python/count-the-coins-1.py @@ -0,0 +1,10 @@ +def changes(amount, coins): + ways = [0] * (amount + 1) + ways[0] = 1 + for coin in coins: + for j in xrange(coin, amount + 1): + ways[j] += ways[j - coin] + return ways[amount] + +print changes(100, [1, 5, 10, 25]) +print changes(100000, [1, 5, 10, 25, 50, 100]) diff --git a/Task/Count-the-coins/Python/count-the-coins-2.py b/Task/Count-the-coins/Python/count-the-coins-2.py new file mode 100644 index 0000000000..ae621dd06e --- /dev/null +++ b/Task/Count-the-coins/Python/count-the-coins-2.py @@ -0,0 +1,38 @@ +try: + import psyco + psyco.full() +except ImportError: + pass + +def count_changes(amount_cents, coins): + n = len(coins) + # max([]) instead of max() for Psyco + cycle = max([c+1 for c in coins if c <= amount_cents]) * n + table = [0] * cycle + for i in xrange(n): + table[i] = 1 + + pos = n + for s in xrange(1, amount_cents + 1): + for i in xrange(n): + if i == 0 and pos >= cycle: + pos = 0 + if coins[i] <= s: + q = pos - coins[i] * n + table[pos]= table[q] if (q >= 0) else table[q + cycle] + if i: + table[pos] += table[pos - 1] + pos += 1 + return table[pos - 1] + +def main(): + us_coins = [100, 50, 25, 10, 5, 1] + eu_coins = [200, 100, 50, 20, 10, 5, 2, 1] + + for coins in (us_coins, eu_coins): + print count_changes( 100, coins[2:]) + print count_changes( 100000, coins) + print count_changes( 1000000, coins) + print count_changes(10000000, coins), "\n" + +main() diff --git a/Task/Count-the-coins/REXX/count-the-coins.rexx b/Task/Count-the-coins/REXX/count-the-coins.rexx new file mode 100644 index 0000000000..c591fca1cd --- /dev/null +++ b/Task/Count-the-coins/REXX/count-the-coins.rexx @@ -0,0 +1,21 @@ +/*REXX program makes change from some amount with various specie (coins)*/ +parse arg n $ +if n='' then n=100 /*Not specified? Use $1 default.*/ +if $='' then $=1 5 10 25 /*Use penny/nickle/dime/quarter ?*/ +coins=words($) /*count number of coins specified*/ + do j=1 for coins /*create a fast way of accessing.*/ + $.j=word($,j) /*define a stemmed array element.*/ + end /*j*/ + +say 'with an amount of ' n", there're " kaChing(n,coins), + ' ways to make change with: ' $ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────kaChing subroutine──────────────────*/ +kaChing: procedure expose $.; parse arg a,k +if a==0 then f=1 /*unroll some special cases. */ + else if k==0 | k==1 then f=0 /*unroll some more special cases.*/ + else f=kaChing(a,k-1) /*recurse the amount*/ + +if a==$.k then return f+1 /*handle another special case. */ +if a<$.k | k==0 then return f /*if amount is + for (j<-coin to amount) + ways(j) = ways(j) + ways(j - coin) + ) + ways(amount) + } + +countChange (15, List(1, 5, 10, 25)) diff --git a/Task/Count-the-coins/Scheme/count-the-coins.ss b/Task/Count-the-coins/Scheme/count-the-coins.ss new file mode 100644 index 0000000000..1f722c7200 --- /dev/null +++ b/Task/Count-the-coins/Scheme/count-the-coins.ss @@ -0,0 +1,9 @@ +(define ways-to-make-change + (lambda (x coins) + (cond + [(null? coins) 0] + [(< x 0) 0] + [(zero? x) 1] + [else (+ (ways-to-make-change x (cdr coins)) (ways-to-make-change (- x (car coins)) coins))]))) + +(ways-to-make-change 100) diff --git a/Task/Count-the-coins/Tcl/count-the-coins.tcl b/Task/Count-the-coins/Tcl/count-the-coins.tcl new file mode 100644 index 0000000000..933365b844 --- /dev/null +++ b/Task/Count-the-coins/Tcl/count-the-coins.tcl @@ -0,0 +1,22 @@ +package require Tcl 8.5 + +proc makeChange {amount coins} { + set table [lrepeat [expr {$amount+1}] [lrepeat [llength $coins] {}]] + lset table 0 [lrepeat [llength $coins] 1] + for {set i 1} {$i <= $amount} {incr i} { + for {set j 0} {$j < [llength $coins]} {incr j} { + set k [expr {$i - [lindex $coins $j]}] + lset table $i $j [expr { + ($k < 0 ? 0 : [lindex $table $k $j]) + + ($j < 1 ? 0 : [lindex $table $i [expr {$j-1}]]) + }] + } + } + return [lindex $table end end] +} + +puts [makeChange 100 {1 5 10 25}] +puts [makeChange 100000 {1 5 10 25 50 100}] +# Making change with the EU coin set: +puts [makeChange 100 {1 2 5 10 20 50 100 200}] +puts [makeChange 100000 {1 2 5 10 20 50 100 200}] diff --git a/Task/Create-a-file-on-magnetic-tape/0DESCRIPTION b/Task/Create-a-file-on-magnetic-tape/0DESCRIPTION new file mode 100644 index 0000000000..9eeb950432 --- /dev/null +++ b/Task/Create-a-file-on-magnetic-tape/0DESCRIPTION @@ -0,0 +1 @@ +The task is to create a new file called "TAPE.FILE" of any size on Magnetic Tape diff --git a/Task/Create-a-file-on-magnetic-tape/1META.yaml b/Task/Create-a-file-on-magnetic-tape/1META.yaml new file mode 100644 index 0000000000..40458d9f21 --- /dev/null +++ b/Task/Create-a-file-on-magnetic-tape/1META.yaml @@ -0,0 +1,2 @@ +--- +note: File System Operations diff --git a/Task/Create-a-file-on-magnetic-tape/Tcl/create-a-file-on-magnetic-tape.tcl b/Task/Create-a-file-on-magnetic-tape/Tcl/create-a-file-on-magnetic-tape.tcl new file mode 100644 index 0000000000..eb7e91c9c4 --- /dev/null +++ b/Task/Create-a-file-on-magnetic-tape/Tcl/create-a-file-on-magnetic-tape.tcl @@ -0,0 +1,13 @@ +cd /tmp + +# Create the file +set f [open hello.jnk w] +puts $f "Hello World!" +close $f + +# Archive to tape +set fin [open "|tar cf - hello.jnk" rb] +set fout [open /dev/tape wb] +fcopy $fin $fout +close $fin +close $fout diff --git a/Task/Create-a-file/0DESCRIPTION b/Task/Create-a-file/0DESCRIPTION new file mode 100644 index 0000000000..138b299f0d --- /dev/null +++ b/Task/Create-a-file/0DESCRIPTION @@ -0,0 +1,2 @@ +In this task, the job is to create a new empty file called "output.txt" of size 0 bytes +and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root. diff --git a/Task/Create-a-file/1META.yaml b/Task/Create-a-file/1META.yaml new file mode 100644 index 0000000000..40458d9f21 --- /dev/null +++ b/Task/Create-a-file/1META.yaml @@ -0,0 +1,2 @@ +--- +note: File System Operations diff --git a/Task/Create-a-file/4DOS-Batch/create-a-file.4dos b/Task/Create-a-file/4DOS-Batch/create-a-file.4dos new file mode 100644 index 0000000000..32cee116ac --- /dev/null +++ b/Task/Create-a-file/4DOS-Batch/create-a-file.4dos @@ -0,0 +1,5 @@ +echos > output.txt +mkdir docs + +echos > \output.txt +mkdir \docs diff --git a/Task/Create-a-file/ALGOL-68/create-a-file.alg b/Task/Create-a-file/ALGOL-68/create-a-file.alg new file mode 100644 index 0000000000..5a34d47939 --- /dev/null +++ b/Task/Create-a-file/ALGOL-68/create-a-file.alg @@ -0,0 +1,38 @@ +main:( + + INT errno; + + PROC touch = (STRING file name)INT: + BEGIN + FILE actual file; + INT errno := open(actual file, file name, stand out channel); + IF errno NE 0 THEN GO TO stop touch FI; + close(actual file); # detach the book and keep it # + errno + EXIT + stop touch: + errno + END; + + errno := touch("input.txt"); + errno := touch("/input.txt"); + + # ALGOL 68 has no concept of directories, + however a file can have multiple pages, + the pages are identified by page number only # + + PROC mkpage = (STRING file name, INT page x)INT: + BEGIN + FILE actual file; + INT errno := open(actual file, file name, stand out channel); + IF errno NE 0 THEN GO TO stop mkpage FI; + set(actual file,page x,1,1); # skip to page x, line 1, character 1 # + close(actual file); # detach the new page and keep it # + errno + EXIT + stop mkpage: + errno + END; + + errno := mkpage("input.txt",2); +) diff --git a/Task/Create-a-file/APL/create-a-file.apl b/Task/Create-a-file/APL/create-a-file.apl new file mode 100644 index 0000000000..77cee0d85b --- /dev/null +++ b/Task/Create-a-file/APL/create-a-file.apl @@ -0,0 +1,4 @@ + 'output.txt' ⎕ncreate ¯1+⌊/0,⎕nnums + '\output.txt' ⎕ncreate ¯1+⌊/0,⎕nnums + ⎕mkdir 'Docs' + ⎕mkdir '\Docs' diff --git a/Task/Create-a-file/AWK/create-a-file.awk b/Task/Create-a-file/AWK/create-a-file.awk new file mode 100644 index 0000000000..754ca46545 --- /dev/null +++ b/Task/Create-a-file/AWK/create-a-file.awk @@ -0,0 +1,5 @@ +BEGIN { + printf "" > "output.txt" + # try to create the file in the root (for *nix-like systems) + printf "" > "/output.txt" +} diff --git a/Task/Create-a-file/Ada/create-a-file.ada b/Task/Create-a-file/Ada/create-a-file.ada new file mode 100644 index 0000000000..a887e79eaa --- /dev/null +++ b/Task/Create-a-file/Ada/create-a-file.ada @@ -0,0 +1,17 @@ +with Ada.Streams.Stream_IO, Ada.Directories; +use Ada.Streams.Stream_IO, Ada.Directories; + +procedure File_Creation is + + File_Handle : File_Type; + +begin + + Create (File_Handle, Out_File, "output.txt"); + Close (File_Handle); + Create_Directory("docs"); + Create (File_Handle, Out_File, "/output.txt"); + Close (File_Handle); + Create_Directory("/docs"); + +end File_Creation; diff --git a/Task/Create-a-file/Aikido/create-a-file.aikido b/Task/Create-a-file/Aikido/create-a-file.aikido new file mode 100644 index 0000000000..fcb48e7880 --- /dev/null +++ b/Task/Create-a-file/Aikido/create-a-file.aikido @@ -0,0 +1,8 @@ +var sout = openout ("output.txt") // in current dir +sout.close() + +var sout1 = openout ("/output.txt") // in root dir +sout1.close() + +mkdir ("docs") +mkdir ("/docs") diff --git a/Task/Create-a-file/AppleScript/create-a-file-1.applescript b/Task/Create-a-file/AppleScript/create-a-file-1.applescript new file mode 100644 index 0000000000..458ca3b811 --- /dev/null +++ b/Task/Create-a-file/AppleScript/create-a-file-1.applescript @@ -0,0 +1 @@ +close (open for access "output.txt") diff --git a/Task/Create-a-file/AppleScript/create-a-file-2.applescript b/Task/Create-a-file/AppleScript/create-a-file-2.applescript new file mode 100644 index 0000000000..6d7509e308 --- /dev/null +++ b/Task/Create-a-file/AppleScript/create-a-file-2.applescript @@ -0,0 +1 @@ +tell application "Finder" to make new folder at startup disk with properties {name:"docs"} diff --git a/Task/Create-a-file/AppleScript/create-a-file-3.applescript b/Task/Create-a-file/AppleScript/create-a-file-3.applescript new file mode 100644 index 0000000000..5ee24e50a7 --- /dev/null +++ b/Task/Create-a-file/AppleScript/create-a-file-3.applescript @@ -0,0 +1,2 @@ +tell application "Finder" to set wd to target of window 1 as string +close (open for access wd & "output.txt") diff --git a/Task/Create-a-file/AppleScript/create-a-file-4.applescript b/Task/Create-a-file/AppleScript/create-a-file-4.applescript new file mode 100644 index 0000000000..9b2c5ffc98 --- /dev/null +++ b/Task/Create-a-file/AppleScript/create-a-file-4.applescript @@ -0,0 +1 @@ +tell application "Finder" to make new folder at window 1 with properties {name:"docs"} diff --git a/Task/Create-a-file/AutoHotkey/create-a-file.ahk b/Task/Create-a-file/AutoHotkey/create-a-file.ahk new file mode 100644 index 0000000000..505e188de2 --- /dev/null +++ b/Task/Create-a-file/AutoHotkey/create-a-file.ahk @@ -0,0 +1,4 @@ +FileAppend,,output.txt +FileCreateDir, docs +FileAppend,,c:\output.txt +FileCreateDir, c:\docs diff --git a/Task/Create-a-file/BASIC/create-a-file.bas b/Task/Create-a-file/BASIC/create-a-file.bas new file mode 100644 index 0000000000..2efbe156b6 --- /dev/null +++ b/Task/Create-a-file/BASIC/create-a-file.bas @@ -0,0 +1,4 @@ +OPEN "output.txt" FOR OUTPUT AS 1 +CLOSE +OPEN "\output.txt" FOR OUTPUT AS 1 +CLOSE diff --git a/Task/Create-a-file/BBC-BASIC/create-a-file.bbc b/Task/Create-a-file/BBC-BASIC/create-a-file.bbc new file mode 100644 index 0000000000..88655530d9 --- /dev/null +++ b/Task/Create-a-file/BBC-BASIC/create-a-file.bbc @@ -0,0 +1,4 @@ + CLOSE #OPENOUT("output.txt") + CLOSE #OPENOUT("\output.txt") + *MKDIR docs + *MKDIR \docs diff --git a/Task/Create-a-file/Batch-File/create-a-file-1.bat b/Task/Create-a-file/Batch-File/create-a-file-1.bat new file mode 100644 index 0000000000..b7fc5b57de --- /dev/null +++ b/Task/Create-a-file/Batch-File/create-a-file-1.bat @@ -0,0 +1,2 @@ +copy nul output.txt +copy nul \output.txt diff --git a/Task/Create-a-file/Batch-File/create-a-file-2.bat b/Task/Create-a-file/Batch-File/create-a-file-2.bat new file mode 100644 index 0000000000..a1ca232ff6 --- /dev/null +++ b/Task/Create-a-file/Batch-File/create-a-file-2.bat @@ -0,0 +1,2 @@ +md docs +md \docs diff --git a/Task/Create-a-file/Bracmat/create-a-file-1.bracmat b/Task/Create-a-file/Bracmat/create-a-file-1.bracmat new file mode 100644 index 0000000000..62a5c137d3 --- /dev/null +++ b/Task/Create-a-file/Bracmat/create-a-file-1.bracmat @@ -0,0 +1 @@ +put$(,"output.txt",NEW) diff --git a/Task/Create-a-file/Bracmat/create-a-file-2.bracmat b/Task/Create-a-file/Bracmat/create-a-file-2.bracmat new file mode 100644 index 0000000000..c41296e1d3 --- /dev/null +++ b/Task/Create-a-file/Bracmat/create-a-file-2.bracmat @@ -0,0 +1 @@ +fil$("output.txt",w) diff --git a/Task/Create-a-file/Bracmat/create-a-file-3.bracmat b/Task/Create-a-file/Bracmat/create-a-file-3.bracmat new file mode 100644 index 0000000000..66b1f5abe8 --- /dev/null +++ b/Task/Create-a-file/Bracmat/create-a-file-3.bracmat @@ -0,0 +1 @@ +fil$(,SET,-1) diff --git a/Task/Create-a-file/Bracmat/create-a-file-4.bracmat b/Task/Create-a-file/Bracmat/create-a-file-4.bracmat new file mode 100644 index 0000000000..f70952374d --- /dev/null +++ b/Task/Create-a-file/Bracmat/create-a-file-4.bracmat @@ -0,0 +1 @@ +sys$"mkdir docs" diff --git a/Task/Create-a-file/Bracmat/create-a-file-5.bracmat b/Task/Create-a-file/Bracmat/create-a-file-5.bracmat new file mode 100644 index 0000000000..e16abe5b83 --- /dev/null +++ b/Task/Create-a-file/Bracmat/create-a-file-5.bracmat @@ -0,0 +1 @@ +sys$"mkdir \\docs" diff --git a/Task/Create-a-file/C++/create-a-file.cpp b/Task/Create-a-file/C++/create-a-file.cpp new file mode 100644 index 0000000000..15b5af0e67 --- /dev/null +++ b/Task/Create-a-file/C++/create-a-file.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main() { + std::fstream f( "output.txt", std::ios::out ); + f.close(); + f.open( "/output.txt", std::ios::out ); + f.close(); + + _mkdir( "docs" ); + _mkdir( "/docs" ); + + return 0; +} diff --git a/Task/Create-a-file/C/create-a-file-1.c b/Task/Create-a-file/C/create-a-file-1.c new file mode 100644 index 0000000000..da0a8fcc34 --- /dev/null +++ b/Task/Create-a-file/C/create-a-file-1.c @@ -0,0 +1,8 @@ +#include + +int main() { + FILE *fh = fopen("output.txt", "w"); + fclose(fh); + + return 0; +} diff --git a/Task/Create-a-file/C/create-a-file-2.c b/Task/Create-a-file/C/create-a-file-2.c new file mode 100644 index 0000000000..a95fd7e5ec --- /dev/null +++ b/Task/Create-a-file/C/create-a-file-2.c @@ -0,0 +1,14 @@ +#include +#include +#include + +int main() { /* permissions are before umask */ + int fd = open("output.txt", O_WRONLY|O_CREAT|O_TRUNC, 0640); /* rights 0640 for rw-r----- */ + /* or equivalently: + int fd = creat("output.txt", 0640); */ /* rights 0640 for rw-r----- */ + close(fd); + + mkdir("docs", 0750); /* rights 0750 for rwxr-x--- */ + + return 0; +} diff --git a/Task/Create-a-file/Clojure/create-a-file.clj b/Task/Create-a-file/Clojure/create-a-file.clj new file mode 100644 index 0000000000..c8fea074ab --- /dev/null +++ b/Task/Create-a-file/Clojure/create-a-file.clj @@ -0,0 +1,5 @@ +(import '(java.io File)) +(.createNewFile (new File "output.txt")) +(.mkdir (new File "docs")) +(.createNewFile (File. (str (File/separator) "output.txt"))) +(.mkdir (File. (str (File/separator) "docs"))) diff --git a/Task/Create-a-file/Common-Lisp/create-a-file-1.lisp b/Task/Create-a-file/Common-Lisp/create-a-file-1.lisp new file mode 100644 index 0000000000..64706567ad --- /dev/null +++ b/Task/Create-a-file/Common-Lisp/create-a-file-1.lisp @@ -0,0 +1,2 @@ +(let ((stream (open "output.txt" :direction :output))) + (close stream)) diff --git a/Task/Create-a-file/Common-Lisp/create-a-file-2.lisp b/Task/Create-a-file/Common-Lisp/create-a-file-2.lisp new file mode 100644 index 0000000000..f9adb80de1 --- /dev/null +++ b/Task/Create-a-file/Common-Lisp/create-a-file-2.lisp @@ -0,0 +1,3 @@ +(with-open-file (stream "output.txt" :direction :output) + ;; use the stream here + ) diff --git a/Task/Create-a-file/Common-Lisp/create-a-file-3.lisp b/Task/Create-a-file/Common-Lisp/create-a-file-3.lisp new file mode 100644 index 0000000000..d10b3a7682 --- /dev/null +++ b/Task/Create-a-file/Common-Lisp/create-a-file-3.lisp @@ -0,0 +1,3 @@ +(let ((paths (list (make-pathname :directory '(:relative "docs")) + (make-pathname :directory '(:absolute "docs"))))) + (mapcar #'ensure-directories-exist paths)) diff --git a/Task/Create-a-file/Common-Lisp/create-a-file-4.lisp b/Task/Create-a-file/Common-Lisp/create-a-file-4.lisp new file mode 100644 index 0000000000..f65052a36a --- /dev/null +++ b/Task/Create-a-file/Common-Lisp/create-a-file-4.lisp @@ -0,0 +1,4 @@ +(with-open-file + (stream + (make-pathname :directory '(:absolute "") :name "output.txt") + :direction :output)) diff --git a/Task/Create-a-file/Common-Lisp/create-a-file-5.lisp b/Task/Create-a-file/Common-Lisp/create-a-file-5.lisp new file mode 100644 index 0000000000..6576ec9d42 --- /dev/null +++ b/Task/Create-a-file/Common-Lisp/create-a-file-5.lisp @@ -0,0 +1 @@ +(mapcar #'ensure-directories-exist '(#p"docs/" #p"/docs/"))) diff --git a/Task/Create-a-file/D/create-a-file.d b/Task/Create-a-file/D/create-a-file.d new file mode 100644 index 0000000000..1edbdabcc4 --- /dev/null +++ b/Task/Create-a-file/D/create-a-file.d @@ -0,0 +1,46 @@ +module fileio ; +import std.stdio ; +import std.path ; +import std.file ; +import std.stream ; + +string[] genName(string name){ + string cwd = curdir ~ sep ; // on current directory + string root = sep ; // on root + name = std.path.getBaseName(name) ; + return [cwd ~ name, root ~ name] ; +} +void Remove(string target){ + if(exists(target)){ + if (isfile(target)) + std.file.remove(target); + else + std.file.rmdir(target) ; + } +} +void testCreate(string filename, string dirname){ + // files: + foreach(fn ; genName(filename)) + try{ + writefln("file to be created : %s", fn) ; + std.file.write(fn, cast(void[])null) ; + writefln("\tsuccess by std.file.write") ; Remove(fn) ; + (new std.stream.File(fn, FileMode.OutNew)).close() ; + writefln("\tsuccess by std.stream") ; Remove(fn) ; + } catch(Exception e) { + writefln(e.msg) ; + } + // dirs: + foreach(dn ; genName(dirname)) + try{ + writefln("dir to be created : %s", dn) ; + std.file.mkdir(dn) ; + writefln("\tsuccess by std.file.mkdir") ; Remove(dn) ; + } catch(Exception e) { + writefln(e.msg) ; + } +} +void main(){ + writefln("== test: File & Dir Creation ==") ; + testCreate("output.txt", "docs") ; +} diff --git a/Task/Create-a-file/DCL/create-a-file.dcl b/Task/Create-a-file/DCL/create-a-file.dcl new file mode 100644 index 0000000000..322361f194 --- /dev/null +++ b/Task/Create-a-file/DCL/create-a-file.dcl @@ -0,0 +1,4 @@ +open/write output_file output.txt +open/write output_file [000000]output.txt +create/directory [.docs] +create/directory [000000.docs] diff --git a/Task/Create-a-file/Delphi/create-a-file.delphi b/Task/Create-a-file/Delphi/create-a-file.delphi new file mode 100644 index 0000000000..fbd61c2ad2 --- /dev/null +++ b/Task/Create-a-file/Delphi/create-a-file.delphi @@ -0,0 +1,100 @@ +program createFile; + +{$APPTYPE CONSOLE} + +uses + Classes, + SysUtils; + +const + filename = 'output.txt'; + +var + cwdPath, + fsPath: string; + + +// Create empty file in current working directory +function CreateEmptyFile1: Boolean; +var + f: textfile; +begin + // Make path to the file to be created + cwdPath := ExtractFilePath(ParamStr(0)) + '1_'+filename; + + // Create file + AssignFile(f,cwdPath); + {$I-} + Rewrite(f); + {$I+} + Result := IOResult = 0; + CloseFile(f); +end; + +// Create empty file in filesystem root +function CreateEmptyFile2: Boolean; +var + f: textfile; +begin + // Make path to the file to be created + fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '2_'+filename; + + // Create file + AssignFile(f,fsPath); + {$I-} + Rewrite(f); + {$I+} + Result := IOResult = 0; + CloseFile(f); +end; + +function CreateEmptyFile3: Boolean; +var + fs: TFileStream; +begin + // Make path to the file to be created + cwdPath := ExtractFilePath(ParamStr(0)) + '3_'+filename; + + // Create file + fs := TFileStream.Create(cwdPath,fmCreate); + fs.Free; + Result := FileExists(cwdPath); +end; + +function CreateEmptyFile4: Boolean; +var + fs: TFileStream; +begin + // Make path to the file to be created + fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '4_'+filename; + + // Create file + fs := TFileStream.Create(fsPath,fmCreate); + fs.Free; + Result := FileExists(fsPath); +end; + +begin + if CreateEmptyFile1 then + Writeln('File created at '+cwdPath) + else + Writeln('Error creating file at '+cwdPath); + + if CreateEmptyFile2 then + Writeln('File created at '+fsPath) + else + Writeln('Error creating file at '+fsPath); + + if CreateEmptyFile3 then + Writeln('File created at '+cwdPath) + else + Writeln('Error creating file at '+cwdPath); + + if CreateEmptyFile4 then + Writeln('File created at '+fsPath) + else + Writeln('Error creating file at '+fsPath); + + // Keep console window open + Readln; +end. diff --git a/Task/Create-a-file/E/create-a-file.e b/Task/Create-a-file/E/create-a-file.e new file mode 100644 index 0000000000..8b21047db0 --- /dev/null +++ b/Task/Create-a-file/E/create-a-file.e @@ -0,0 +1,4 @@ +.setBytes([]) +.mkdir(null) +.setBytes([]) +.mkdir(null) diff --git a/Task/Create-a-file/Euphoria/create-a-file.euphoria b/Task/Create-a-file/Euphoria/create-a-file.euphoria new file mode 100644 index 0000000000..d34ca677f6 --- /dev/null +++ b/Task/Create-a-file/Euphoria/create-a-file.euphoria @@ -0,0 +1,11 @@ +integer fn + +-- In the current working directory +system("mkdir docs",2) +fn = open("output.txt","w") +close(fn) + +-- In the filesystem root +system("mkdir \\docs",2) +fn = open("\\output.txt","w") +close(fn) diff --git a/Task/Create-a-file/Forth/create-a-file.fth b/Task/Create-a-file/Forth/create-a-file.fth new file mode 100644 index 0000000000..667399ad48 --- /dev/null +++ b/Task/Create-a-file/Forth/create-a-file.fth @@ -0,0 +1,2 @@ + s" output.txt" w/o create-file throw ( fileid) drop +s" /output.txt" w/o create-file throw ( fileid) drop diff --git a/Task/Create-a-file/Fortran/create-a-file.f b/Task/Create-a-file/Fortran/create-a-file.f new file mode 100644 index 0000000000..1a99e9bc02 --- /dev/null +++ b/Task/Create-a-file/Fortran/create-a-file.f @@ -0,0 +1,4 @@ +OPEN (UNIT=5, FILE="output.txt", STATUS="NEW") ! Current directory +CLOSE (UNIT=5) +OPEN (UNIT=5, FILE="/output.txt", STATUS="NEW") ! Root directory +CLOSE (UNIT=5) diff --git a/Task/Create-a-file/Go/create-a-file.go b/Task/Create-a-file/Go/create-a-file.go new file mode 100644 index 0000000000..c3f8acdbab --- /dev/null +++ b/Task/Create-a-file/Go/create-a-file.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "os" +) + +func createFile(fn string) { + // create new; don't overwrite an existing file. + f, err := os.Create(fn) + if err != nil { + fmt.Println(err) + return + } + fmt.Println("file", fn, "created!") + f.Close() +} + +func createDir(dn string) { + err := os.Mkdir(dn, 0666) + if err != nil { + fmt.Println(err) + return + } + fmt.Println("directory", dn, "created!") +} + +func main() { + createFile("input.txt") + createFile("/input.txt") + createDir("docs") + createDir("/docs") +} diff --git a/Task/Create-a-file/Haskell/create-a-file.hs b/Task/Create-a-file/Haskell/create-a-file.hs new file mode 100644 index 0000000000..2f2785260a --- /dev/null +++ b/Task/Create-a-file/Haskell/create-a-file.hs @@ -0,0 +1,9 @@ +import System.Directory + +createFile name = writeFile name "" + +main = do + createFile "output.txt" + createDirectory "docs" + createFile "/output.txt" + createDirectory "/docs" diff --git a/Task/Create-a-file/Java/create-a-file.java b/Task/Create-a-file/Java/create-a-file.java new file mode 100644 index 0000000000..08cef3fa08 --- /dev/null +++ b/Task/Create-a-file/Java/create-a-file.java @@ -0,0 +1,13 @@ +import java.io.*; +public class CreateFileTest { + public static void main(String args[]) { + try { + new File("output.txt").createNewFile(); + new File(File.separator + "output.txt").createNewFile(); + new File("docs").mkdir(); + new File(File.separator + "docs").mkdir(); + } catch (IOException e) { + System.err.println(e.getMessage()); + } + } +} diff --git a/Task/Create-a-file/Lua/create-a-file-1.lua b/Task/Create-a-file/Lua/create-a-file-1.lua new file mode 100644 index 0000000000..682db53488 --- /dev/null +++ b/Task/Create-a-file/Lua/create-a-file-1.lua @@ -0,0 +1,2 @@ +io.open("output.txt", "w"):close() +io.open("\\output.txt", "w"):close() diff --git a/Task/Create-a-file/Lua/create-a-file-2.lua b/Task/Create-a-file/Lua/create-a-file-2.lua new file mode 100644 index 0000000000..b9bb11ac9b --- /dev/null +++ b/Task/Create-a-file/Lua/create-a-file-2.lua @@ -0,0 +1,2 @@ +os.execute("mkdir docs") +os.execute("mkdir \\docs") diff --git a/Task/Create-a-file/Lua/create-a-file-3.lua b/Task/Create-a-file/Lua/create-a-file-3.lua new file mode 100644 index 0000000000..f56ef65fec --- /dev/null +++ b/Task/Create-a-file/Lua/create-a-file-3.lua @@ -0,0 +1,3 @@ +require "lfs" +lfs.mkdir("docs") +lfs.mkdir("/docs") diff --git a/Task/Create-a-file/MATLAB/create-a-file.m b/Task/Create-a-file/MATLAB/create-a-file.m new file mode 100644 index 0000000000..f5a253ef81 --- /dev/null +++ b/Task/Create-a-file/MATLAB/create-a-file.m @@ -0,0 +1,4 @@ + fid = fopen('output.txt','w'); fclose(fid); + fid = fopen('/output.txt','w'); fclose(fid); + mkdir('docs'); + mkdir('/docs'); diff --git a/Task/Create-a-file/PHP/create-a-file.php b/Task/Create-a-file/PHP/create-a-file.php new file mode 100644 index 0000000000..95b242bd5e --- /dev/null +++ b/Task/Create-a-file/PHP/create-a-file.php @@ -0,0 +1,6 @@ + diff --git a/Task/Create-a-file/Perl/create-a-file-1.pl b/Task/Create-a-file/Perl/create-a-file-1.pl new file mode 100644 index 0000000000..c72710f698 --- /dev/null +++ b/Task/Create-a-file/Perl/create-a-file-1.pl @@ -0,0 +1,9 @@ +use File::Spec::Functions qw(catfile rootdir); +{ # here + open my $fh, '>', 'output.txt'; + mkdir 'docs'; +}; +{ # root dir + open my $fh, '>', catfile rootdir, 'output.txt'; + mkdir catfile rootdir, 'docs'; +}; diff --git a/Task/Create-a-file/Perl/create-a-file-2.pl b/Task/Create-a-file/Perl/create-a-file-2.pl new file mode 100644 index 0000000000..697ea2e0ad --- /dev/null +++ b/Task/Create-a-file/Perl/create-a-file-2.pl @@ -0,0 +1,2 @@ +perl -e 'qx(touch output.txt)' +perl -e 'mkdir docs' diff --git a/Task/Create-a-file/Perl/create-a-file-3.pl b/Task/Create-a-file/Perl/create-a-file-3.pl new file mode 100644 index 0000000000..1c12126be4 --- /dev/null +++ b/Task/Create-a-file/Perl/create-a-file-3.pl @@ -0,0 +1,2 @@ +perl -e 'qx(touch /output.txt)' +perl -e 'mkdir "/docs"' diff --git a/Task/Create-a-file/Perl/create-a-file-4.pl b/Task/Create-a-file/Perl/create-a-file-4.pl new file mode 100644 index 0000000000..bc4a271b8a --- /dev/null +++ b/Task/Create-a-file/Perl/create-a-file-4.pl @@ -0,0 +1,4 @@ +for my $prefix (qw( ./ / )) { + mkdir "${prefix}docs"; + open my $FH, '>', "${prefix}docs/output.txt"; +} diff --git a/Task/Create-a-file/Perl/create-a-file-5.pl b/Task/Create-a-file/Perl/create-a-file-5.pl new file mode 100644 index 0000000000..b5066913ff --- /dev/null +++ b/Task/Create-a-file/Perl/create-a-file-5.pl @@ -0,0 +1,2 @@ +unlink $_ for qw(/docs/output.txt ./docs/output.txt); +rmdir $_ for qw(/docs ./docs); diff --git a/Task/Create-a-file/PicoLisp/create-a-file.l b/Task/Create-a-file/PicoLisp/create-a-file.l new file mode 100644 index 0000000000..8a26d7f1bc --- /dev/null +++ b/Task/Create-a-file/PicoLisp/create-a-file.l @@ -0,0 +1,4 @@ +(out "output.txt") # Empty output +(call 'mkdir "docs") # Call external +(out "/output.txt") +(call 'mkdir "/docs") diff --git a/Task/Create-a-file/Python/create-a-file-1.py b/Task/Create-a-file/Python/create-a-file-1.py new file mode 100644 index 0000000000..aa0ec64b2a --- /dev/null +++ b/Task/Create-a-file/Python/create-a-file-1.py @@ -0,0 +1,4 @@ +import os +for directory in ['/', './']: + open(directory + 'output.txt', 'w').close() # create /output.txt, then ./output.txt + os.mkdir(directory + 'docs') # create directory /docs, then ./docs diff --git a/Task/Create-a-file/Python/create-a-file-2.py b/Task/Create-a-file/Python/create-a-file-2.py new file mode 100644 index 0000000000..e479789747 --- /dev/null +++ b/Task/Create-a-file/Python/create-a-file-2.py @@ -0,0 +1,9 @@ +from __future__ import with_statement +import os +def create(directory): + with open(os.path.join(directory, "output.txt"), "w"): + pass + os.mkdir(os.path.join(directory, "docs")) + +create(".") # current directory +create("/") # root directory diff --git a/Task/Create-a-file/R/create-a-file.r b/Task/Create-a-file/R/create-a-file.r new file mode 100644 index 0000000000..797c600121 --- /dev/null +++ b/Task/Create-a-file/R/create-a-file.r @@ -0,0 +1,10 @@ +f <- file("output.txt", "w") +close(f) + +# it may fails and the exact syntax to achieve the root +# changes according to the operating system +f <- file("/output.txt", "w") +close(f) + +success <- dir.create("docs") +success <- dir.create("/docs") diff --git a/Task/Create-a-file/REXX/create-a-file.rexx b/Task/Create-a-file/REXX/create-a-file.rexx new file mode 100644 index 0000000000..2424c5a38b --- /dev/null +++ b/Task/Create-a-file/REXX/create-a-file.rexx @@ -0,0 +1,4 @@ + do 2 + 'COPY NUL>output.txt' + 'CD \' + end diff --git a/Task/Create-a-file/Racket/create-a-file.rkt b/Task/Create-a-file/Racket/create-a-file.rkt new file mode 100644 index 0000000000..fe70cc525b --- /dev/null +++ b/Task/Create-a-file/Racket/create-a-file.rkt @@ -0,0 +1,6 @@ +#lang racket + +(display-to-file "" "output.txt") +(make-directory "docs") +(display-to-file "" "/output.txt") +(make-directory "/docs") diff --git a/Task/Create-a-file/Ruby/create-a-file.rb b/Task/Create-a-file/Ruby/create-a-file.rb new file mode 100644 index 0000000000..ced0b5aee9 --- /dev/null +++ b/Task/Create-a-file/Ruby/create-a-file.rb @@ -0,0 +1,4 @@ +['/', './'].each{|dir| + Dir.mkdir(dir + 'docs') # create '/docs', then './docs' + File.open(dir + 'output.txt', 'w') {} # create empty file /output.txt, then ./output.txt +} diff --git a/Task/Create-a-file/Scheme/create-a-file.ss b/Task/Create-a-file/Scheme/create-a-file.ss new file mode 100644 index 0000000000..d388685a91 --- /dev/null +++ b/Task/Create-a-file/Scheme/create-a-file.ss @@ -0,0 +1,2 @@ +(open-output-file "output.txt") +(open-output-file "/output.txt") diff --git a/Task/Create-a-file/Smalltalk/create-a-file-1.st b/Task/Create-a-file/Smalltalk/create-a-file-1.st new file mode 100644 index 0000000000..a3a869713d --- /dev/null +++ b/Task/Create-a-file/Smalltalk/create-a-file-1.st @@ -0,0 +1 @@ +(FileDirectory on: 'c:\') newFileNamed: 'output.txt'; createDirectory: 'docs'. diff --git a/Task/Create-a-file/Smalltalk/create-a-file-2.st b/Task/Create-a-file/Smalltalk/create-a-file-2.st new file mode 100644 index 0000000000..a2a1bd9fed --- /dev/null +++ b/Task/Create-a-file/Smalltalk/create-a-file-2.st @@ -0,0 +1,7 @@ +ws := (File name: 'output.txt') writeStream. +ws close. +Directory create: 'docs'. + +ws := (File name: '/output.txt') writeStream. +ws close. +Directory create: '/docs'. diff --git a/Task/Create-a-file/Tcl/create-a-file.tcl b/Task/Create-a-file/Tcl/create-a-file.tcl new file mode 100644 index 0000000000..3b7cb751b0 --- /dev/null +++ b/Task/Create-a-file/Tcl/create-a-file.tcl @@ -0,0 +1,5 @@ +close [open output.txt w] +close [open [file nativename /output.txt] w] + +file mkdir docs +file mkdir [file nativename /docs] diff --git a/Task/Create-a-two-dimensional-array-at-runtime/0DESCRIPTION b/Task/Create-a-two-dimensional-array-at-runtime/0DESCRIPTION new file mode 100644 index 0000000000..d3b8899443 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/0DESCRIPTION @@ -0,0 +1,2 @@ +{{data structure}} +Get two integers from the user, then create a two-dimensional array where the two dimensions have the sizes given by those numbers, and which can be accessed in the most natural way possible. Write some element of that array, and then output that element. Finally destroy the array if not done by the language itself. diff --git a/Task/Create-a-two-dimensional-array-at-runtime/1META.yaml b/Task/Create-a-two-dimensional-array-at-runtime/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Create-a-two-dimensional-array-at-runtime/ALGOL-68/create-a-two-dimensional-array-at-runtime.alg b/Task/Create-a-two-dimensional-array-at-runtime/ALGOL-68/create-a-two-dimensional-array-at-runtime.alg new file mode 100644 index 0000000000..e73b1c47c0 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/ALGOL-68/create-a-two-dimensional-array-at-runtime.alg @@ -0,0 +1,6 @@ +main:( + print("Input two positive whole numbers separated by space and press newline:"); + [read int,read int] INT array; + array[1,1]:=42; + print (array[1,1]) +) diff --git a/Task/Create-a-two-dimensional-array-at-runtime/APL/create-a-two-dimensional-array-at-runtime.apl b/Task/Create-a-two-dimensional-array-at-runtime/APL/create-a-two-dimensional-array-at-runtime.apl new file mode 100644 index 0000000000..cb8ca9caf1 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/APL/create-a-two-dimensional-array-at-runtime.apl @@ -0,0 +1,7 @@ +array←m n ⍴ 0 ⍝ array of zeros with shape of m by n. + +array[1;1]←73 ⍝ assign a value to location 1;1. + +array[1;1] ⍝ read the value back out + +⎕ex 'array' ⍝ erase the array diff --git a/Task/Create-a-two-dimensional-array-at-runtime/AWK/create-a-two-dimensional-array-at-runtime.awk b/Task/Create-a-two-dimensional-array-at-runtime/AWK/create-a-two-dimensional-array-at-runtime.awk new file mode 100644 index 0000000000..2360b16e4c --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/AWK/create-a-two-dimensional-array-at-runtime.awk @@ -0,0 +1,13 @@ +/[0-9]+ [0-9]+/ { + for(i=0; i < $1; i++) { + for(j=0; j < $2; j++) { + arr[i, j] = i*j + } + } + + # how to scan "multidim" array as explained in the GNU AWK manual + for (comb in arr) { + split(comb, idx, SUBSEP) + print idx[1] "," idx[2] "->" arr[idx[1], idx[2]] + } +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Ada/create-a-two-dimensional-array-at-runtime.ada b/Task/Create-a-two-dimensional-array-at-runtime/Ada/create-a-two-dimensional-array-at-runtime.ada new file mode 100644 index 0000000000..e419aa5c69 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Ada/create-a-two-dimensional-array-at-runtime.ada @@ -0,0 +1,21 @@ +with Ada.Text_Io; +with Ada.Float_Text_Io; +with Ada.Integer_Text_Io; + +procedure Two_Dimensional_Arrays is + type Matrix_Type is array(Positive range <>, Positive range <>) of Float; + Dim_1 : Positive; + Dim_2 : Positive; +begin + Ada.Integer_Text_Io.Get(Item => Dim_1); + Ada.Integer_Text_Io.Get(Item => Dim_2); + -- Create an inner block with the correctly sized array + declare + Matrix : Matrix_Type(1..Dim_1, 1..Dim_2); + begin + Matrix(1, Dim_2) := 3.14159; + Ada.Float_Text_Io.Put(Item => Matrix(1, Dim_2), Fore => 1, Aft => 5, Exp => 0); + Ada.Text_Io.New_Line; + end; + -- The variable Matrix is popped off the stack automatically +end Two_Dimensional_Arrays; diff --git a/Task/Create-a-two-dimensional-array-at-runtime/AppleScript/create-a-two-dimensional-array-at-runtime.applescript b/Task/Create-a-two-dimensional-array-at-runtime/AppleScript/create-a-two-dimensional-array-at-runtime.applescript new file mode 100644 index 0000000000..04e1af073a --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/AppleScript/create-a-two-dimensional-array-at-runtime.applescript @@ -0,0 +1,24 @@ +set R to text returned of (display dialog "Enter number of rows:" default answer 2) as integer +set c to text returned of (display dialog "Enter number of columns:" default answer 2) as integer +set array to {} +repeat with i from 1 to R + set temp to {} + repeat with j from 1 to c + set temp's end to 0 + end repeat + set array's end to temp +end repeat + +-- Address the first column of the first row: +set array's item 1's item 1 to -10 + +-- Negative index values can be used to address from the end: +set array's item -1's item -1 to 10 + +-- Access an item (row 2 column 1): +set x to array's item 2's item 1 + +return array + +-- Destroy array (typically unnecessary since it'll automatically be destroyed once script ends). +set array to {} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/AutoHotkey/create-a-two-dimensional-array-at-runtime.ahk b/Task/Create-a-two-dimensional-array-at-runtime/AutoHotkey/create-a-two-dimensional-array-at-runtime.ahk new file mode 100644 index 0000000000..e207e857a8 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/AutoHotkey/create-a-two-dimensional-array-at-runtime.ahk @@ -0,0 +1,5 @@ +Array := [] +InputBox, data,, Enter two integers separated by a Space:`n(ex. 5 7) +StringSplit, i, data, %A_Space% +Array[i1,i2] := "that element" +MsgBox, % "Array[" i1 "," i2 "] = " Array[i1,i2] diff --git a/Task/Create-a-two-dimensional-array-at-runtime/AutoIt/create-a-two-dimensional-array-at-runtime.autoit b/Task/Create-a-two-dimensional-array-at-runtime/AutoIt/create-a-two-dimensional-array-at-runtime.autoit new file mode 100644 index 0000000000..7ca80ae9e8 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/AutoIt/create-a-two-dimensional-array-at-runtime.autoit @@ -0,0 +1,12 @@ +; == get dimensions from user input +$sInput = InputBox('2D Array Creation', 'Input comma separated count of rows and columns, i.e. "5,3"') +$aDimension = StringSplit($sInput, ',', 2) + +; == create array +Dim $a2D[ $aDimension[0] ][ $aDimension[1] ] + +; == write value to last row/last column +$a2D[ UBound($a2D) -1 ][ UBound($a2D, 2) -1 ] = 'test string' + +; == output this value to MsgBox +MsgBox(0, 'Output', 'row[' & UBound($a2D) -1 & '], col[' & UBound($a2D, 2) -1 & ']' & @CRLF & '= ' & $a2D[ UBound($a2D) -1 ][ UBound($a2D, 2) -1 ] ) diff --git a/Task/Create-a-two-dimensional-array-at-runtime/BBC-BASIC/create-a-two-dimensional-array-at-runtime.bbc b/Task/Create-a-two-dimensional-array-at-runtime/BBC-BASIC/create-a-two-dimensional-array-at-runtime.bbc new file mode 100644 index 0000000000..d8dccb776f --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/BBC-BASIC/create-a-two-dimensional-array-at-runtime.bbc @@ -0,0 +1,5 @@ + INPUT "Enter array dimensions separated by a comma: " a%, b% + + DIM array(a%, b%) + array(1, 1) = PI + PRINT array(1, 1) diff --git a/Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-1.cpp b/Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-1.cpp new file mode 100644 index 0000000000..11c0c14a03 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-1.cpp @@ -0,0 +1,26 @@ +#include +#include +#include + +int main() +{ + // read values + int dim1, dim2; + std::cin >> dim1 >> dim2; + + // create array + double* array_data = new double[dim1*dim2]; + double** array = new double*[dim1]; + for (int i = 0; i < dim1; ++i) + array[i] = array_data + dim2*i; + + // write element + array[0][0] = 3.5; + + // output element + std::cout << array[0][0] << std::endl; + + // get rid of array + delete[] array; + delete[] array_data; +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-2.cpp b/Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-2.cpp new file mode 100644 index 0000000000..ae34df02f4 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-2.cpp @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +int main() +{ + // read values + int dim1, dim2; + std::cin >> dim1 >> dim2; + + // create array + std::vector > array(dim1, std::vector(dim2)); + + // write element + array[0][0] = 3.5; + + // output element + std::cout << array[0][0] << std::endl; + + // the array is automatically freed at the end of main() +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-3.cpp b/Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-3.cpp new file mode 100644 index 0000000000..39e849ae35 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/C++/create-a-two-dimensional-array-at-runtime-3.cpp @@ -0,0 +1,20 @@ +#include +#include "boost/multi_array.hpp" + +typedef boost::multi_array two_d_array_type; + +int main() +{ + // read values + int dim1, dim2; + std::cin >> dim1 >> dim2; + + // create array + two_d_array_type A(boost::extents[dim1][dim2]); + + // write elements + A[0][0] = 3.1415; + + // read elements + std::cout << A[0][0] << std::endl; +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/C/create-a-two-dimensional-array-at-runtime-1.c b/Task/Create-a-two-dimensional-array-at-runtime/C/create-a-two-dimensional-array-at-runtime-1.c new file mode 100644 index 0000000000..e57b1a91a7 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/C/create-a-two-dimensional-array-at-runtime-1.c @@ -0,0 +1,13 @@ +#include + +int main(int argc, char **argv) { + + int user1 = 0, user2 = 0; + printf("Enter two integers. Space delimited, please: "); + scanf("%d %d",&user1, &user2); + int array[user1][user2]; + array[user1/2][user2/2] = user1 + user2; + printf("array[%d][%d] is %d\n",user1/2,user2/2,array[user1/2][user2/2]); + + return 0; +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/C/create-a-two-dimensional-array-at-runtime-2.c b/Task/Create-a-two-dimensional-array-at-runtime/C/create-a-two-dimensional-array-at-runtime-2.c new file mode 100644 index 0000000000..583ce5cfe3 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/C/create-a-two-dimensional-array-at-runtime-2.c @@ -0,0 +1,20 @@ +#include +#include +int main(int argc, char **argv) +{ + int user1 = 0, user2 = 0; + int *a1, **array, row; + + printf("Enter two integers. Space delimited, please: "); + scanf("%d %d",&user1, &user2); + + a1 = malloc(user1*user2*sizeof(int)); + array = malloc(user2*sizeof(int*)); + for (row=0; row +#include +int main(int argc, char **argv) +{ + int user1 = 0; + int space_needed; + int *a1, **array; + int row, col; + + printf("Enter size of array: "); + scanf("%d",&user1); + + space_needed = (user1+1)*user1/2; + a1 = malloc(space_needed); + array = malloc(user1*sizeof(int*)); + for (row=0,offset=0; row +#include +int main(int argc, char **argv) +{ + int user1 = 0, user2 = 0; + int *a1, **array, row; + + printf("Enter two integers. Space delimited, please: "); + scanf("%d %d",&user1, &user2); + + a1 = alloca(user1*user2*sizeof(int)); + array = alloca(user1*sizeof(int*)); + for (row=0; row { {Real} } +Start world + # (console, world) = stdio world + (_, dim1, console) = freadi console + (_, dim2, console) = freadi console + = createArray dim1 (createArray dim2 1.0) diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Clojure/create-a-two-dimensional-array-at-runtime.clj b/Task/Create-a-two-dimensional-array-at-runtime/Clojure/create-a-two-dimensional-array-at-runtime.clj new file mode 100644 index 0000000000..91c5021760 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Clojure/create-a-two-dimensional-array-at-runtime.clj @@ -0,0 +1,5 @@ +(let [rows (Integer/parseInt (read-line)) + cols (Integer/parseInt (read-line)) + a (to-array-2d (repeat rows (repeat cols nil)))] + (aset a 0 0 12) + (println "Element at 0,0:" (aget a 0 0))) diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Common-Lisp/create-a-two-dimensional-array-at-runtime.lisp b/Task/Create-a-two-dimensional-array-at-runtime/Common-Lisp/create-a-two-dimensional-array-at-runtime.lisp new file mode 100644 index 0000000000..6bad4b0915 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Common-Lisp/create-a-two-dimensional-array-at-runtime.lisp @@ -0,0 +1,10 @@ +(let ((d1 (read)) + (d2 (read))) + (assert (and (typep d1 '(integer 1)) + (typep d2 '(integer 1))) + (d1 d2)) + (let ((array (make-array (list d1 d2) :initial-element nil)) + (p1 0) + (p2 (floor d2 2))) + (setf (aref array p1 p2) t) + (print (aref array p1 p2)))) diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Component-Pascal/create-a-two-dimensional-array-at-runtime.pascal b/Task/Create-a-two-dimensional-array-at-runtime/Component-Pascal/create-a-two-dimensional-array-at-runtime.pascal new file mode 100644 index 0000000000..539f7f931e --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Component-Pascal/create-a-two-dimensional-array-at-runtime.pascal @@ -0,0 +1,18 @@ +MODULE TestArray; +(* Implemented in BlackBox Component Builder *) + + IMPORT Out; + + (* Open array *) + + PROCEDURE DoTwoDim*; + VAR d: POINTER TO ARRAY OF ARRAY OF INTEGER; + BEGIN + NEW(d, 5, 4); (* allocating array in memory *) + d[1, 2] := 100; (* second row, third column element *) + d[4, 3] := -100; (* fifth row, fourth column element *) + Out.Int(d[1, 2], 0); Out.Ln; + Out.Int(d[4, 3], 0); Out.Ln; + END DoTwoDim; + +END TestArray. diff --git a/Task/Create-a-two-dimensional-array-at-runtime/D/create-a-two-dimensional-array-at-runtime.d b/Task/Create-a-two-dimensional-array-at-runtime/D/create-a-two-dimensional-array-at-runtime.d new file mode 100644 index 0000000000..224bc48223 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/D/create-a-two-dimensional-array-at-runtime.d @@ -0,0 +1,25 @@ +import std.stdio, std.conv, std.string; + +void main() { + int nRow, nCol; + + write("Give me the numer of rows: "); + try { + nRow = readln().strip().to!int(); + } catch (StdioException e) { + nRow = 3; + writeln(); + } + + write("Give me the numer of columns: "); + try { + nCol = to!int(readln().strip()); + } catch (StdioException e) { + nCol = 5; + writeln(); + } + + auto array = new float[][](nRow, nCol); + array[0][0] = 3.5; + writeln("The number at place [0, 0] is ", array[0][0]); +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Delphi/create-a-two-dimensional-array-at-runtime.delphi b/Task/Create-a-two-dimensional-array-at-runtime/Delphi/create-a-two-dimensional-array-at-runtime.delphi new file mode 100644 index 0000000000..56ae3a0e32 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Delphi/create-a-two-dimensional-array-at-runtime.delphi @@ -0,0 +1,28 @@ +program Project1; + +{$APPTYPE CONSOLE} + +uses + SysUtils; +var + matrix:array of array of Byte; + i,j:Integer; +begin + Randomize; + //Finalization is not required in this case, but you have to do + //so when reusing the variable in scope + Finalize(matrix); + //Init first dimension with random size from 1..10 + //Remember dynamic arrays are indexed from 0 + SetLength(matrix,Random(10) + 1); + //Init 2nd dimension with random sizes too + for i := Low(matrix) to High(matrix) do + SetLength(matrix[i],Random(10) + 1); + + //End of code, the following part is just output + Writeln(Format('Total amount of columns = %.2d',[Length(matrix)])); + for i := Low(matrix) to High(matrix) do + Writeln(Format('Column %.2d = %.2d rows',[i,Length(matrix[i])])); + + Readln; +end. diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Euphoria/create-a-two-dimensional-array-at-runtime.euphoria b/Task/Create-a-two-dimensional-array-at-runtime/Euphoria/create-a-two-dimensional-array-at-runtime.euphoria new file mode 100644 index 0000000000..c9db5fda0a --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Euphoria/create-a-two-dimensional-array-at-runtime.euphoria @@ -0,0 +1,15 @@ +include get.e + +sequence array +integer height,width,i,j + +height = floor(prompt_number("Enter height: ",{})) +width = floor(prompt_number("Enter width: ",{})) + +array = repeat(repeat(0,width),height) + +i = floor(height/2+0.5) +j = floor(width/2+0.5) +array[i][j] = height + width + +printf(1,"array[%d][%d] is %d\n", {i,j,array[i][j]}) diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Forth/create-a-two-dimensional-array-at-runtime-1.fth b/Task/Create-a-two-dimensional-array-at-runtime/Forth/create-a-two-dimensional-array-at-runtime-1.fth new file mode 100644 index 0000000000..38de95c569 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Forth/create-a-two-dimensional-array-at-runtime-1.fth @@ -0,0 +1,8 @@ +: cell-matrix + create ( width height "name" ) over , * cells allot + does> ( x y -- addr ) dup cell+ >r @ * + cells r> + ; + +5 5 cell-matrix test + +36 0 0 test ! +0 0 test @ . \ 36 diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Forth/create-a-two-dimensional-array-at-runtime-2.fth b/Task/Create-a-two-dimensional-array-at-runtime/Forth/create-a-two-dimensional-array-at-runtime-2.fth new file mode 100644 index 0000000000..9ab251278d --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Forth/create-a-two-dimensional-array-at-runtime-2.fth @@ -0,0 +1,7 @@ +INTEGER DMATRIX my-matrix{{ +& my-matrix{{ 8 9 }}malloc + +8 my-matrix{{ 3 4 }} ! +my-matrix{{ 3 4 }} @ . + +& my-matrix{{ }}free diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Fortran/create-a-two-dimensional-array-at-runtime.f b/Task/Create-a-two-dimensional-array-at-runtime/Fortran/create-a-two-dimensional-array-at-runtime.f new file mode 100644 index 0000000000..ec8de24685 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Fortran/create-a-two-dimensional-array-at-runtime.f @@ -0,0 +1,20 @@ +PROGRAM Example + + IMPLICIT NONE + INTEGER :: rows, columns, errcheck + INTEGER, ALLOCATABLE :: array(:,:) + + WRITE(*,*) "Enter number of rows" + READ(*,*) rows + WRITE(*,*) "Enter number of columns" + READ(*,*) columns + + ALLOCATE (array(rows,columns), STAT=errcheck) ! STAT is optional and is used for error checking + + array(1,1) = 42 + + WRITE(*,*) array(1,1) + + DEALLOCATE (array, STAT=errcheck) + +END PROGRAM Example diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-1.go b/Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-1.go new file mode 100644 index 0000000000..b892576133 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-1.go @@ -0,0 +1,28 @@ +package main + +import "fmt" + +func main() { + var row, col int + fmt.Print("enter rows cols: ") + fmt.Scan(&row, &col) + + // allocate composed 2d array + a := make([][]int, row) + for i := range a { + a[i] = make([]int, col) + } + + // array elements initialized to 0 + fmt.Println("a[0][0] =", a[0][0]) + + // assign + a[row-1][col-1] = 7 + + // retrieve + fmt.Printf("a[%d][%d] = %d\n", row-1, col-1, a[row-1][col-1]) + + // remove only reference + a = nil + // memory allocated earlier with make can now be garbage collected. +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-2.go b/Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-2.go new file mode 100644 index 0000000000..0c7d243719 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-2.go @@ -0,0 +1,6 @@ + // allocate composed 2d array + a := make([][]int, row) + e := make([]int, row * col) + for i := range a { + a[i] = e[i*col:(i+1)*col] + } diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-3.go b/Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-3.go new file mode 100644 index 0000000000..f14bb10d15 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Go/create-a-two-dimensional-array-at-runtime-3.go @@ -0,0 +1,3 @@ +func get(r, c int) int { + return e[r*cols+c] +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Haskell/create-a-two-dimensional-array-at-runtime.hs b/Task/Create-a-two-dimensional-array-at-runtime/Haskell/create-a-two-dimensional-array-at-runtime.hs new file mode 100644 index 0000000000..7e20ef96ec --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Haskell/create-a-two-dimensional-array-at-runtime.hs @@ -0,0 +1 @@ + doit n m = a!(0,0) where a = array ((0,0),(n,m)) [((0,0),42)] diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Java/create-a-two-dimensional-array-at-runtime.java b/Task/Create-a-two-dimensional-array-at-runtime/Java/create-a-two-dimensional-array-at-runtime.java new file mode 100644 index 0000000000..fc5281bc53 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Java/create-a-two-dimensional-array-at-runtime.java @@ -0,0 +1,14 @@ +import java.util.Scanner; + +public class twoDimArray { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + + int nbr1 = in.nextInt(); + int nbr2 = in.nextInt(); + + double[][] array = new double[nbr1][nbr2]; + array[0][0] = 42.0; + System.out.println("The number at place [0 0] is " + array[0][0]); + } +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/JavaScript/create-a-two-dimensional-array-at-runtime.js b/Task/Create-a-two-dimensional-array-at-runtime/JavaScript/create-a-two-dimensional-array-at-runtime.js new file mode 100644 index 0000000000..1ef50ac024 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/JavaScript/create-a-two-dimensional-array-at-runtime.js @@ -0,0 +1,28 @@ +var w = parseInt( get_input("Enter a width:") ); +var w = parseInt( get_input("Enter a height:") ); + +// create the 2-D array +var a = new Array(h); +for (var i = 0; i < h; i++) + a[i] = new Array(w); + +a[0][0] = 'foo'; +WScript.Echo('a[0][0] = ' + a[0][0]); + +a = null; + +function get_input(prompt) { + output(prompt); + try { + return WScript.StdIn.readLine(); + } catch(e) { + return readline(); + } +} +function output(prompt) { + try { + return WScript.echo(prompt); + } catch(e) { + return print(prompt); + } +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Lua/create-a-two-dimensional-array-at-runtime.lua b/Task/Create-a-two-dimensional-array-at-runtime/Lua/create-a-two-dimensional-array-at-runtime.lua new file mode 100644 index 0000000000..a7f9634872 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Lua/create-a-two-dimensional-array-at-runtime.lua @@ -0,0 +1,7 @@ +function multiply(n, a, b) if a <= b then return n, multiply(n, a + 1, b) end end + +a, b = io.read() + 0, io.read() + 0 +matrix = {multiply({multiply(1, 1, b)}, 1, a)} +matrix[a][b] = 5 +print(matrix[a][b]) +print(matrix[1][1]) diff --git a/Task/Create-a-two-dimensional-array-at-runtime/MATLAB/create-a-two-dimensional-array-at-runtime-1.m b/Task/Create-a-two-dimensional-array-at-runtime/MATLAB/create-a-two-dimensional-array-at-runtime-1.m new file mode 100644 index 0000000000..ac1e79eb97 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/MATLAB/create-a-two-dimensional-array-at-runtime-1.m @@ -0,0 +1,10 @@ +width = input('Array Width: '); +height = input('Array Height: '); + +array = zeros(width,height); + +array(1,1) = 12; + +disp(['Array element (1,1) = ' num2str(array(1,1))]); + +clear array; % de-allocate (remove) array from workspace diff --git a/Task/Create-a-two-dimensional-array-at-runtime/MATLAB/create-a-two-dimensional-array-at-runtime-2.m b/Task/Create-a-two-dimensional-array-at-runtime/MATLAB/create-a-two-dimensional-array-at-runtime-2.m new file mode 100644 index 0000000000..f677ba0dab --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/MATLAB/create-a-two-dimensional-array-at-runtime-2.m @@ -0,0 +1,3 @@ +Array Width: 18 +Array Height: 12 +Array element (1,1) = 12 diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Perl/create-a-two-dimensional-array-at-runtime-1.pl b/Task/Create-a-two-dimensional-array-at-runtime/Perl/create-a-two-dimensional-array-at-runtime-1.pl new file mode 100644 index 0000000000..7dcffa259a --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Perl/create-a-two-dimensional-array-at-runtime-1.pl @@ -0,0 +1,19 @@ +sub make_array($ $){ + # get array sizes from provided params, but force numeric value + my $x = ($_[0] =~ /^\d+$/) ? shift : 0; + my $y = ($_[0] =~ /^\d+$/) ? shift : 0; + + # define array, then add multi-dimensional elements + my @array; + $array[0][0] = 'X '; # first by first element + $array[5][7] = 'X ' if (5 <= $y and 7 <= $x); # sixth by eighth element, if the max size is big enough + $array[12][15] = 'X ' if (12 <= $y and 15 <= $x); # thirteenth by sixteenth element, if the max size is big enough + + # loop through the elements expected to exist base on input, and display the elements contents in a grid + foreach my $dy (0 .. $y){ + foreach my $dx (0 .. $x){ + (defined $array[$dy][$dx]) ? (print $array[$dy][$dx]) : (print '. '); + } + print "\n"; + } +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Perl/create-a-two-dimensional-array-at-runtime-2.pl b/Task/Create-a-two-dimensional-array-at-runtime/Perl/create-a-two-dimensional-array-at-runtime-2.pl new file mode 100644 index 0000000000..9e003b06fb --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Perl/create-a-two-dimensional-array-at-runtime-2.pl @@ -0,0 +1,19 @@ +sub array { + my ($x, $y) = @_; + map {[ (0) x $x ]} 1 .. $y +} + +my @square = array 3, 3; + +# everything above this line is mostly redundant in perl, +# since perl would have created the array automatically when used. +# however, the above function initializes the array elements to 0, +# while perl would have used undef +# +# $cube[3][4][5] = 60 # this is valid even if @cube was previously undefined + +$square[1][1] = 1; +print "@$_\n" for @square; +> 0 0 0 +> 0 1 0 +> 0 0 0 diff --git a/Task/Create-a-two-dimensional-array-at-runtime/PicoLisp/create-a-two-dimensional-array-at-runtime.l b/Task/Create-a-two-dimensional-array-at-runtime/PicoLisp/create-a-two-dimensional-array-at-runtime.l new file mode 100644 index 0000000000..ab7646d1a1 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/PicoLisp/create-a-two-dimensional-array-at-runtime.l @@ -0,0 +1,7 @@ +(de 2dimTest (DX DY) + (let A (make (do DX (link (need DY)))) + (set (nth A 3 3) 999) # Set A[3][3] to 999 + (mapc println A) # Print all + (get A 3 3) ) ) # Return A[3][3] + +(2dimTest 5 5) diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Python/create-a-two-dimensional-array-at-runtime-1.py b/Task/Create-a-two-dimensional-array-at-runtime/Python/create-a-two-dimensional-array-at-runtime-1.py new file mode 100644 index 0000000000..b971a418ea --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Python/create-a-two-dimensional-array-at-runtime-1.py @@ -0,0 +1,5 @@ +width = int(raw_input("Width of myarray: ")) +height = int(raw_input("Height of Array: ")) +myarray = [[0] * width for i in xrange(height)] +myarray[0][0] = 3.5 +print myarray[0][0] diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Python/create-a-two-dimensional-array-at-runtime-2.py b/Task/Create-a-two-dimensional-array-at-runtime/Python/create-a-two-dimensional-array-at-runtime-2.py new file mode 100644 index 0000000000..e50caaac0d --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Python/create-a-two-dimensional-array-at-runtime-2.py @@ -0,0 +1,4 @@ +myarray = {(w,h): 0 for w in range(width) for h in range(height)} +# or, in pre 2.7 versions of Python: myarray = dict(((w,h), 0) for w in range(width) for h in range(height)) +myarray[(0,0)] = 3.5 +print myarray[(0,0)] diff --git a/Task/Create-a-two-dimensional-array-at-runtime/R/create-a-two-dimensional-array-at-runtime.r b/Task/Create-a-two-dimensional-array-at-runtime/R/create-a-two-dimensional-array-at-runtime.r new file mode 100644 index 0000000000..f54d4f937c --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/R/create-a-two-dimensional-array-at-runtime.r @@ -0,0 +1,7 @@ +input <- readline("Enter two integers. Space delimited, please: ") +dims <- as.numeric(strsplit(input, " ")[[1]]) +arr <- array(dim=dims) +ii <- ceiling(dims[1]/2) +jj <- ceiling(dims[2]/2) +arr[ii, jj] <- sum(dims) +cat("array[", ii, ",", jj, "] is ", arr[ii, jj], "\n", sep="") diff --git a/Task/Create-a-two-dimensional-array-at-runtime/REXX/create-a-two-dimensional-array-at-runtime.rexx b/Task/Create-a-two-dimensional-array-at-runtime/REXX/create-a-two-dimensional-array-at-runtime.rexx new file mode 100644 index 0000000000..bc533514c9 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/REXX/create-a-two-dimensional-array-at-runtime.rexx @@ -0,0 +1,39 @@ +/*REXX program to allocate/populate/display a two-dimensional array. */ +call bloat + /*no more array named A. at this point.*/ +exit /*stick a fork in it, we're all done. */ +/*─────────────────────────BLOAT subroutine─────────────────────────────*/ +bloat: procedure; say +say 'Enter two positive integers (a 2-dimensional array will be created).' +pull n m . /*there is no way to pre-allocate an array,*/ + /*REXX will allocate each element when it's*/ + /*assigned. */ + +a.='~' /*default value for all elements so far. */ + /*this ensures every element has a value. */ + do j =1 for n + do k=1 for m + if random()//7==0 then a.j.k=j'_'k /*populate every 7th random*/ + end /*k*/ + end /*j*/ + + do r=1 for n /*display array to the console (row,col). */ + _= + do c=1 for m + _=_ right(a.r.c,4) /*display one row at a time, align the vals*/ + end /*kk*/ + say _ + end /*jj*/ + /*when the RETURN is executed (from a */ + /*PROCEDURE in this case), the array A. is*/ + /*"de-allocated", that is, it's no longer */ + /*defined, and the memory that the array */ + /*has is now free for other REXX variables.*/ + + /*If the BLOAT subroutine didn't have */ + /*a "PROCEDURE" on that statement, the */ + /*array "a." would be left intact. */ + + /*The same effect is performed by a DROP. */ +drop a. /*because of the PROCEDURE statement, */ +return /* the DROP statement is superfluous. */ diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Ruby/create-a-two-dimensional-array-at-runtime.rb b/Task/Create-a-two-dimensional-array-at-runtime/Ruby/create-a-two-dimensional-array-at-runtime.rb new file mode 100644 index 0000000000..eaad5e6e89 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Ruby/create-a-two-dimensional-array-at-runtime.rb @@ -0,0 +1,5 @@ +puts 'Enter width and height: ' +w=gets.to_i +arr = Array.new(gets.to_i){Array.new(w)} +arr[1][3] = 5 +p arr[1][3] diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Scala/create-a-two-dimensional-array-at-runtime.scala b/Task/Create-a-two-dimensional-array-at-runtime/Scala/create-a-two-dimensional-array-at-runtime.scala new file mode 100644 index 0000000000..c259b33dfa --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Scala/create-a-two-dimensional-array-at-runtime.scala @@ -0,0 +1,10 @@ +object Array2D{ + def main(args: Array[String]): Unit = { + val x = Console.readInt + val y = Console.readInt + + val a=Array.fill(x, y)(0) + a(0)(0)=42 + println("The number at (0, 0) is "+a(0)(0)) + } +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-1.st b/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-1.st new file mode 100644 index 0000000000..1f517f7127 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-1.st @@ -0,0 +1,11 @@ +m := (FillInTheBlankMorph request: 'Number of rows?') asNumber. +n := (FillInTheBlankMorph request: 'Number of columns?') asNumber. +aMatrix := Matrix rows: m columns: n. +aMatrix + at: (aMatrix rowCount // 2) + at: (aMatrix columnCount // 2) + put: 3.4. +e := aMatrix + at: (aMatrix rowCount // 2) + at: (aMatrix columnCount // 2). +Transcript show: 'Entry is', e printString. diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-2.st b/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-2.st new file mode 100644 index 0000000000..4c46e945db --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-2.st @@ -0,0 +1,17 @@ +|num1 num2 arr| +num1 := stdin nextLine asInteger. +num2 := stdin nextLine asInteger. + +arr := MultidimensionalArray new: { num1. num2 }. + +1 to: num1 do: [ :i | + 1 to: num2 do: [ :j | + arr at: { i. j } put: (i*j) + ] +]. + +1 to: num1 do: [ :i | + 1 to: num2 do: [ :j | + (arr at: {i. j}) displayNl + ] +]. diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-3.st b/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-3.st new file mode 100644 index 0000000000..e6b7beb1e3 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-3.st @@ -0,0 +1,26 @@ +Object subclass: BidimensionalArray [ + |biArr| + +]. +BidimensionalArray class extend [ + new: biDim [ |r| + r := super new. + r init: biDim. + ^ r + ] +]. +BidimensionalArray extend [ + init: biDim [ + biArr := Array new: (biDim at: 1). + 1 to: (biDim at: 1) do: [ :i | + biArr at: i put: (Array new: (biDim at: 2)) + ]. + ^ self + ] + at: biDim [ + ^ (biArr at: (biDim at: 1)) at: (biDim at: 2) + ] + at: biDim put: val [ + ^ (biArr at: (biDim at: 1)) at: (biDim at: 2) put: val + ] +]. diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-4.st b/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-4.st new file mode 100644 index 0000000000..0a4e18a6b1 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Smalltalk/create-a-two-dimensional-array-at-runtime-4.st @@ -0,0 +1,20 @@ +|num1 num2 pseudoArr| +num1 := stdin nextLine asInteger. +num2 := stdin nextLine asInteger. + +"we can 'suggest' an initial value for the number + of ''slot'' the table can hold; anyway, if we use + more than these, the table automatically grows" +pseudoArr := LookupTable new: (num1 * num2). + +1 to: num1 do: [ :i | + 1 to: num2 do: [ :j | + pseudoArr at: {i. j} put: (i * j). + ] +]. + +1 to: num1 do: [ :i | + 1 to: num2 do: [ :j | + (pseudoArr at: {i. j}) displayNl. + ] +]. diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Tcl/create-a-two-dimensional-array-at-runtime.tcl b/Task/Create-a-two-dimensional-array-at-runtime/Tcl/create-a-two-dimensional-array-at-runtime.tcl new file mode 100644 index 0000000000..87e22d72a1 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Tcl/create-a-two-dimensional-array-at-runtime.tcl @@ -0,0 +1,17 @@ +package require Tcl 8.5 + +puts "enter X dimension:" +set dim2 [gets stdin] +puts "enter Y dimension:" +set dim1 [gets stdin] +# Make the "array"; we'll keep it in row-major form +set l [lrepeat $dim1 [lrepeat $dim2 {}]] +# Select a point at around the middle of the "array" +set y [expr {$dim1>>1}] +set x [expr {$dim2>>1}] +# Set the value at that point +lset l $y $x aValue +# Read the value at that point +puts [lindex $l $y $x] +# Delete the "array" +unset l diff --git a/Task/Create-an-HTML-table/0DESCRIPTION b/Task/Create-an-HTML-table/0DESCRIPTION new file mode 100644 index 0000000000..9d4e1386e2 --- /dev/null +++ b/Task/Create-an-HTML-table/0DESCRIPTION @@ -0,0 +1,6 @@ +Create an HTML table. +* The table body should have at least three rows of three columns. +* Each of these three columns should be labelled "X", "Y", and "Z". +* An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. +* The rows of the "X", "Y", and "Z" columns should be filled with random or sequential integers having 4 digits or less. +* The numbers should be aligned in the same fashion for all columns. diff --git a/Task/Create-an-HTML-table/1META.yaml b/Task/Create-an-HTML-table/1META.yaml new file mode 100644 index 0000000000..e403e19ff2 --- /dev/null +++ b/Task/Create-an-HTML-table/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- HTML diff --git a/Task/Create-an-HTML-table/AWK/create-an-html-table.awk b/Task/Create-an-HTML-table/AWK/create-an-html-table.awk new file mode 100644 index 0000000000..5bcd4dec3a --- /dev/null +++ b/Task/Create-an-HTML-table/AWK/create-an-html-table.awk @@ -0,0 +1,13 @@ +#!/usr/bin/awk -f +BEGIN { + print "\n "; + printf " \n \n \n"; +}; + +{ + printf " \n",NR,$1,$2,$3; +}; + +END { + print " \n
XYZ
%2i%5i%5i%5i
\n"; +}; diff --git a/Task/Create-an-HTML-table/Ada/create-an-html-table-1.ada b/Task/Create-an-HTML-table/Ada/create-an-html-table-1.ada new file mode 100644 index 0000000000..a5a00c6abb --- /dev/null +++ b/Task/Create-an-HTML-table/Ada/create-an-html-table-1.ada @@ -0,0 +1,19 @@ +with Ada.Strings.Unbounded; + +generic + type Item_Type is private; + with function To_String(Item: Item_Type) return String is <>; + with procedure Put(S: String) is <>; + with procedure Put_Line(Line: String) is <>; +package HTML_Table is + + subtype U_String is Ada.Strings.Unbounded.Unbounded_String; + function Convert(S: String) return U_String renames + Ada.Strings.Unbounded.To_Unbounded_String; + + type Item_Array is array(Positive range <>, Positive range <>) of Item_Type; + type Header_Array is array(Positive range <>) of U_String; + + procedure Print(Items: Item_Array; Column_Heads: Header_Array); + +end HTML_Table; diff --git a/Task/Create-an-HTML-table/Ada/create-an-html-table-2.ada b/Task/Create-an-HTML-table/Ada/create-an-html-table-2.ada new file mode 100644 index 0000000000..3ae2008131 --- /dev/null +++ b/Task/Create-an-HTML-table/Ada/create-an-html-table-2.ada @@ -0,0 +1,56 @@ +package body HTML_Table is + + procedure Print(Items: Item_Array; Column_Heads: Header_Array) is + + function Blanks(N: Natural) return String is + -- indention for better readable HTML + begin + if N=0 then + return ""; + else + return " " & Blanks(N-1); + end if; + end Blanks; + + procedure Print_Row(Row_Number: Positive) is + begin + Put(Blanks(4) & "" & Positive'Image(Row_Number) & ""); + for I in Items'Range(2) loop + Put("" & To_String(Items(Row_Number, I)) & ""); + end loop; + Put_Line(""); + end Print_Row; + + procedure Print_Body is + begin + Put_Line(Blanks(2)&""); + for I in Items'Range(1) loop + Print_Row(I); + end loop; + Put_Line(Blanks(2)&""); + end Print_Body; + + procedure Print_Header is + function To_Str(U: U_String) return String renames + Ada.Strings.Unbounded.To_String; + begin + Put_Line(Blanks(2) & ""); + Put(Blanks(4) & ""); + for I in Column_Heads'Range loop + Put("" & To_Str(Column_Heads(I)) & ""); + end loop; + Put_Line(""); + Put_Line(Blanks(2) & ""); + end Print_Header; + + begin + if Items'Length(2) /= Column_Heads'Length then + raise Constraint_Error with "number of headers /= number of columns"; + end if; + Put_Line(""); + Print_Header; + Print_Body; + Put_Line("
"); + end Print; + +end HTML_Table; diff --git a/Task/Create-an-HTML-table/Ada/create-an-html-table-3.ada b/Task/Create-an-HTML-table/Ada/create-an-html-table-3.ada new file mode 100644 index 0000000000..a904c858e5 --- /dev/null +++ b/Task/Create-an-HTML-table/Ada/create-an-html-table-3.ada @@ -0,0 +1,32 @@ +with Ada.Text_IO, Ada.Numerics.Discrete_Random, HTML_Table; + +procedure Test_HTML_Table is + + -- define the Item_Type and the random generator + type Four_Digits is mod 10_000; + package Rand is new Ada.Numerics.Discrete_Random(Four_Digits); + Gen: Rand.Generator; + + -- now we instantiate the generic package HTML_Table + package T is new HTML_Table + (Item_Type => Four_Digits, + To_String => Four_Digits'Image, + Put => Ada.Text_IO.Put, + Put_Line => Ada.Text_IO.Put_Line); + + -- define the object that will the values that the table contains + The_Table: T.Item_Array(1 .. 4, 1..3); + +begin + -- fill The_Table with random values + Rand.Reset(Gen); + for Rows in The_Table'Range(1) loop + for Cols in The_Table'Range(2) loop + The_Table(Rows, Cols) := Rand.Random(Gen); + end loop; + end loop; + + -- output The_Table + T.Print(Items => The_Table, + Column_Heads => (T.Convert("X"), T.Convert("Y"), T.Convert("Z"))); +end Test_HTML_Table; diff --git a/Task/Create-an-HTML-table/Ada/create-an-html-table-4.ada b/Task/Create-an-HTML-table/Ada/create-an-html-table-4.ada new file mode 100644 index 0000000000..a3587d5967 --- /dev/null +++ b/Task/Create-an-HTML-table/Ada/create-an-html-table-4.ada @@ -0,0 +1,11 @@ + + + + + + + + + + +
XYZ
1 7255 3014 9436
2 554 3314 8765
3 4832 129 2048
4 31 6897 8265
diff --git a/Task/Create-an-HTML-table/AutoHotkey/create-an-html-table.ahk b/Task/Create-an-HTML-table/AutoHotkey/create-an-html-table.ahk new file mode 100644 index 0000000000..e105dd6f2f --- /dev/null +++ b/Task/Create-an-HTML-table/AutoHotkey/create-an-html-table.ahk @@ -0,0 +1,10 @@ +out = +Loop 4 + out .= "`r`n" +out .= "`r`n
XYZ
" A_Index "" Rand() "" Rand() "" Rand() "
" +MsgBox % clipboard := out + +Rand(u=1000){ + Random, n, 1, % u + return n +} diff --git a/Task/Create-an-HTML-table/BBC-BASIC/create-an-html-table.bbc b/Task/Create-an-HTML-table/BBC-BASIC/create-an-html-table.bbc new file mode 100644 index 0000000000..f695fc6173 --- /dev/null +++ b/Task/Create-an-HTML-table/BBC-BASIC/create-an-html-table.bbc @@ -0,0 +1,30 @@ + ncols% = 3 + nrows% = 4 + + *spool temp.htm + + PRINT "" + PRINT "" + + FOR row% = 0 TO nrows% + IF row% = 0 THEN + PRINT "" ; + ELSE + PRINT "" ; + ENDIF + FOR col% = 1 TO ncols% + IF row% = 0 THEN + PRINT "" ; + ELSE + PRINT "" ; + ENDIF + NEXT col% + PRINT "" + NEXT row% + + PRINT "
" ; row% "" CHR$(87 + col%) "" ; RND(9999) "
" + PRINT "" + + *spool + + SYS "ShellExecute", @hwnd%, 0, "temp.htm", 0, 0, 1 diff --git a/Task/Create-an-HTML-table/C++/create-an-html-table.cpp b/Task/Create-an-HTML-table/C++/create-an-html-table.cpp new file mode 100644 index 0000000000..cd19508d3c --- /dev/null +++ b/Task/Create-an-HTML-table/C++/create-an-html-table.cpp @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include +#include + +void makeGap( int gap , std::string & text ) { + for ( int i = 0 ; i < gap ; i++ ) + text.append( " " ) ; +} + +int main( ) { + boost::array chars = { 'X' , 'Y' , 'Z' } ; + int headgap = 3 ; + int bodygap = 3 ; + int tablegap = 6 ; + int rowgap = 9 ; + std::string tabletext( "\n" ) ; + makeGap( headgap , tabletext ) ; + tabletext += "\n" ; + makeGap( bodygap , tabletext ) ; + tabletext += "\n" ; + makeGap( tablegap , tabletext ) ; + tabletext += "\n" ; + makeGap( tablegap + 1 , tabletext ) ; + tabletext += "\n" ; + makeGap( tablegap, tabletext ) ; + tabletext += "" ; + for ( int i = 0 ; i < 3 ; i++ ) { + tabletext += "" ; + } + tabletext += "\n" ; + makeGap( tablegap + 1 , tabletext ) ; + tabletext += "" ; + makeGap( tablegap + 1 , tabletext ) ; + tabletext += "\n" ; + srand( time( 0 ) ) ; + for ( int row = 0 ; row < 5 ; row++ ) { + makeGap( rowgap , tabletext ) ; + std::ostringstream oss ; + tabletext += "" ; + } + tabletext += "\n" ; + } + makeGap( tablegap + 1 , tabletext ) ; + tabletext += "\n" ; + makeGap( tablegap , tabletext ) ; + tabletext += "
" ; + tabletext += *(chars.begin( ) + i ) ; + tabletext += "
" ; + oss << row ; + tabletext += oss.str( ) ; + for ( int col = 0 ; col < 3 ; col++ ) { + oss.str( "" ) ; + int randnumber = rand( ) % 10000 ; + oss << randnumber ; + tabletext += "" ; + tabletext.append( oss.str( ) ) ; + tabletext += "
\n" ; + makeGap( bodygap , tabletext ) ; + tabletext += "\n" ; + tabletext += "\n" ; + std::ofstream htmltable( "testtable.html" , std::ios::out | std::ios::trunc ) ; + htmltable << tabletext ; + htmltable.close( ) ; + return 0 ; +} diff --git a/Task/Create-an-HTML-table/C-sharp/create-an-html-table.cs b/Task/Create-an-HTML-table/C-sharp/create-an-html-table.cs new file mode 100644 index 0000000000..00e4f7144d --- /dev/null +++ b/Task/Create-an-HTML-table/C-sharp/create-an-html-table.cs @@ -0,0 +1,34 @@ +using System; +using System.Text; + +namespace prog +{ + class MainClass + { + public static void Main (string[] args) + { + StringBuilder s = new StringBuilder(); + Random rnd = new Random(); + + s.AppendLine(""); + s.AppendLine(""); + s.Append(""); + for(int i=0; i<3; i++) + s.Append(""); + s.AppendLine(""); + s.AppendLine(""); + s.AppendLine(""); + for( int i=0; i<3; i++ ) + { + s.Append(""); + for( int j=0; j<3; j++ ) + s.Append(""); + s.AppendLine(""); + } + s.AppendLine(""); + s.AppendLine("
" + "XYZ"[i] + "
"+i+""+rnd.Next(10000)+"
"); + + Console.WriteLine( s ); + } + } +} diff --git a/Task/Create-an-HTML-table/C/create-an-html-table.c b/Task/Create-an-HTML-table/C/create-an-html-table.c new file mode 100644 index 0000000000..8330be300b --- /dev/null +++ b/Task/Create-an-HTML-table/C/create-an-html-table.c @@ -0,0 +1,16 @@ +#include +#include + +int main() +{ + int i; + printf("" + ""); + for (i = 0; i < 4; i++) { + printf("", i, + rand() % 10000, rand() % 10000, rand() % 10000); + } + printf("
XYZ
%d%d%d%d
"); + + return 0; +} diff --git a/Task/Create-an-HTML-table/CoffeeScript/create-an-html-table.coffee b/Task/Create-an-HTML-table/CoffeeScript/create-an-html-table.coffee new file mode 100644 index 0000000000..ee05a79b4a --- /dev/null +++ b/Task/Create-an-HTML-table/CoffeeScript/create-an-html-table.coffee @@ -0,0 +1,32 @@ +# This is one of many ways to create a table. CoffeeScript plays nice +# with any templating solution built for JavaScript, and of course you +# can build tables in the browser using DOM APIs. This approach is just +# brute force string manipulation. + +table = (header_row, rows) -> + """ + + #{header_row} + #{rows.join '\n'} +
+ """ + +tr = (cells) -> "#{cells.join ''}" +th = (s) -> "#{s}" +td = (s) -> "#{s}" +rand_n = -> Math.floor Math.random() * 10000 + +header_cols = ['', 'X', 'Y', 'Z'] +header_row = tr (th s for s in header_cols) + +rows = [] +for i in [1..5] + rows.push tr [ + th(i) + td rand_n() + td rand_n() + td rand_n() + ] + +html = table header_row, rows +console.log html diff --git a/Task/Create-an-HTML-table/D/create-an-html-table.d b/Task/Create-an-HTML-table/D/create-an-html-table.d new file mode 100644 index 0000000000..d6333a60b1 --- /dev/null +++ b/Task/Create-an-HTML-table/D/create-an-html-table.d @@ -0,0 +1,10 @@ +import std.stdio, std.random; + +void main() { + writeln(``); + writeln(""); + foreach (i; 0 .. 4) + writefln("", + i, uniform(0,1000), uniform(0,1000), uniform(0,1000)); + writeln("
XYZ
%d%d%d%d
"); +} diff --git a/Task/Create-an-HTML-table/Delphi/create-an-html-table-1.delphi b/Task/Create-an-HTML-table/Delphi/create-an-html-table-1.delphi new file mode 100644 index 0000000000..3a66c80341 --- /dev/null +++ b/Task/Create-an-HTML-table/Delphi/create-an-html-table-1.delphi @@ -0,0 +1,23 @@ +program CreateHTMLTable; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +function AddTableRow(aRowNo: Integer): string; +begin + Result := Format(' %d%d%d%d', + [aRowNo, Random(10000), Random(10000), Random(10000)]); +end; + +var + i: Integer; +begin + Randomize; + Writeln(''); + Writeln(' '); + for i := 1 to 4 do + Writeln(AddTableRow(i)); + Writeln('
XYZ
'); + Readln; +end. diff --git a/Task/Create-an-HTML-table/Delphi/create-an-html-table-2.delphi b/Task/Create-an-HTML-table/Delphi/create-an-html-table-2.delphi new file mode 100644 index 0000000000..84dd24ffa7 --- /dev/null +++ b/Task/Create-an-HTML-table/Delphi/create-an-html-table-2.delphi @@ -0,0 +1,7 @@ + + + + + + +
XYZ
1737126591393
2671050255203
3131615992086
4478566125042
diff --git a/Task/Create-an-HTML-table/Euphoria/create-an-html-table-1.euphoria b/Task/Create-an-HTML-table/Euphoria/create-an-html-table-1.euphoria new file mode 100644 index 0000000000..0954bcaab4 --- /dev/null +++ b/Task/Create-an-HTML-table/Euphoria/create-an-html-table-1.euphoria @@ -0,0 +1,10 @@ +puts(1,"\n") +puts(1," \n") +for i = 1 to 3 do + printf(1," ",i) + for j = 1 to 3 do + printf(1,"",rand(10000)) + end for + puts(1,"\n") +end for +puts(1,"
XYZ
%d%d
") diff --git a/Task/Create-an-HTML-table/Euphoria/create-an-html-table-2.euphoria b/Task/Create-an-HTML-table/Euphoria/create-an-html-table-2.euphoria new file mode 100644 index 0000000000..8738f86a91 --- /dev/null +++ b/Task/Create-an-HTML-table/Euphoria/create-an-html-table-2.euphoria @@ -0,0 +1,6 @@ + + + + + +
XYZ
1797873762382
2363219478900
3409815632762
diff --git a/Task/Create-an-HTML-table/Go/create-an-html-table-1.go b/Task/Create-an-HTML-table/Go/create-an-html-table-1.go new file mode 100644 index 0000000000..c45c450481 --- /dev/null +++ b/Task/Create-an-HTML-table/Go/create-an-html-table-1.go @@ -0,0 +1,36 @@ +package main + +import ( + "fmt" + "html/template" + "os" +) + +type row struct { + X, Y, Z int +} + +var tmpl = ` + +{{range $ix, $row := .}} ` + + `` + + `` + + ` +{{end}}
XYZ
{{$ix}}{{$row.X}}{{$row.Y}}{{$row.Z}}
+` + +func main() { + // create template + ct := template.Must(template.New("").Parse(tmpl)) + + // make up data + data := make([]row, 4) + for r := range data { + data[r] = row{r*3, r*3+1, r*3+2} + } + + // apply template to data + if err := ct.Execute(os.Stdout, data); err != nil { + fmt.Println(err) + } +} diff --git a/Task/Create-an-HTML-table/Go/create-an-html-table-2.go b/Task/Create-an-HTML-table/Go/create-an-html-table-2.go new file mode 100644 index 0000000000..687f4fbd46 --- /dev/null +++ b/Task/Create-an-HTML-table/Go/create-an-html-table-2.go @@ -0,0 +1,7 @@ + + + + + + +
XYZ
0012
1345
2678
391011
diff --git a/Task/Create-an-HTML-table/Haskell/create-an-html-table.hs b/Task/Create-an-HTML-table/Haskell/create-an-html-table.hs new file mode 100644 index 0000000000..91bc35436a --- /dev/null +++ b/Task/Create-an-HTML-table/Haskell/create-an-html-table.hs @@ -0,0 +1,20 @@ +#!/usr/bin/runhaskell + +import Control.Monad (forM_) +import System.Random +import Data.List as L + +import Text.Blaze.Html5 +import Text.Blaze.Html.Renderer.Pretty + +makeTable :: RandomGen g => [String] -> Int -> g -> Html +makeTable headings nRows gen = + table $ do + thead $ tr $ forM_ (L.map toHtml headings) th + tbody $ forM_ (zip [1 .. nRows] $ unfoldr (Just . split) gen) + (\(x,g) -> tr $ forM_ (take (length headings) + (x:randomRs (1000,9999) g)) (td . toHtml)) + +main = do + g <- getStdGen + putStrLn $ renderHtml $ makeTable ["", "X", "Y", "Z"] 3 g diff --git a/Task/Create-an-HTML-table/Java/create-an-html-table-1.java b/Task/Create-an-HTML-table/Java/create-an-html-table-1.java new file mode 100644 index 0000000000..f5306aa7ac --- /dev/null +++ b/Task/Create-an-HTML-table/Java/create-an-html-table-1.java @@ -0,0 +1,25 @@ +public class HTML { + + public static String array2HTML(Object[][] array){ + StringBuilder html = new StringBuilder( + ""); + for(Object elem:array[0]){ + html.append(""); + } + for(int i = 1; i < array.length; i++){ + Object[] row = array[i]; + html.append(""); + for(Object elem:row){ + html.append(""); + } + html.append(""); + } + html.append("
" + elem.toString() + "
" + elem.toString() + "
"); + return html.toString(); + } + + public static void main(String[] args){ + Object[][] ints = {{"","X","Y","Z"},{1,1,2,3},{2,4,5,6},{3,7,8,9},{4,10,11,12}}; + System.out.println(array2HTML(ints)); + } +} diff --git a/Task/Create-an-HTML-table/Java/create-an-html-table-2.java b/Task/Create-an-HTML-table/Java/create-an-html-table-2.java new file mode 100644 index 0000000000..ccb9391548 --- /dev/null +++ b/Task/Create-an-HTML-table/Java/create-an-html-table-2.java @@ -0,0 +1 @@ +
XYZ
1123
2456
3789
4101112
diff --git a/Task/Create-an-HTML-table/JavaScript/create-an-html-table.js b/Task/Create-an-HTML-table/JavaScript/create-an-html-table.js new file mode 100644 index 0000000000..02d28e0f6d --- /dev/null +++ b/Task/Create-an-HTML-table/JavaScript/create-an-html-table.js @@ -0,0 +1,35 @@ +Table maker + diff --git a/Task/Create-an-HTML-table/MATLAB/create-an-html-table.m b/Task/Create-an-HTML-table/MATLAB/create-an-html-table.m new file mode 100644 index 0000000000..b12b412a09 --- /dev/null +++ b/Task/Create-an-HTML-table/MATLAB/create-an-html-table.m @@ -0,0 +1,12 @@ +function htmltable(fid,table,Label) + fprintf(fid,'\n \n'); + if nargin<3, + fprintf(fid,' \n \n \n'); + else + fprintf(fid,' '); + fprintf(fid,'',Label{:}); + fprintf(fid,'\n \n \n'); + end; + fprintf(fid,' \n', [1:size(table,1);table']); + fprintf(fid,' \n
XYZ
%s
%2i%5i%5i%5i
\n'); +end diff --git a/Task/Create-an-HTML-table/PHP/create-an-html-table-1.php b/Task/Create-an-HTML-table/PHP/create-an-html-table-1.php new file mode 100644 index 0000000000..b53dd1e00b --- /dev/null +++ b/Task/Create-an-HTML-table/PHP/create-an-html-table-1.php @@ -0,0 +1,36 @@ + + * @desc HTML Table - native style + */ +$cols = array('', 'X', 'Y', 'Z'); +$rows = 3; + +$html = ''; +foreach($cols as $col) +{ + $html .= ''; +} +unset($col); +$html .= ''; + +foreach($cols as $col) +{ + $html .= ""; +} +unset($col); + +$html .= ''; +for($r = 1; $r <= $rows; $r++) +{ + $html .= ''; + foreach($cols as $key => $col) + { + $html .= ''; + } + unset($col); + $html .= ''; +} +$html .= '
{$col}
' . (($key > 0) ? rand(1, 9999) : $r) . '
'; + +echo $html; diff --git a/Task/Create-an-HTML-table/PHP/create-an-html-table-2.php b/Task/Create-an-HTML-table/PHP/create-an-html-table-2.php new file mode 100644 index 0000000000..d940f45c88 --- /dev/null +++ b/Task/Create-an-HTML-table/PHP/create-an-html-table-2.php @@ -0,0 +1,35 @@ + + * @desc HTML Table - spaghetti-code style + */ +$cols = array('', 'X', 'Y', 'Z'); +$rows = 3; +?> + + + + + + + + + + + + + + + + + + + $col): ?> + + + + + +
0) ? rand(1, 9999) : $r ?>
+ + diff --git a/Task/Create-an-HTML-table/Perl/create-an-html-table.pl b/Task/Create-an-HTML-table/Perl/create-an-html-table.pl new file mode 100644 index 0000000000..231de12b09 --- /dev/null +++ b/Task/Create-an-HTML-table/Perl/create-an-html-table.pl @@ -0,0 +1,13 @@ +my @heading = qw(X Y Z); +my $rows = 5; +print '" } @heading), + ""; + +for (1 .. $rows) { + print "", + (map { "" } @heading), + ""; +} + +print "
', + (map { "$_
$_".int(rand(10000))."
"; diff --git a/Task/Create-an-HTML-table/PicoLisp/create-an-html-table.l b/Task/Create-an-HTML-table/PicoLisp/create-an-html-table.l new file mode 100644 index 0000000000..fa8823f9e2 --- /dev/null +++ b/Task/Create-an-HTML-table/PicoLisp/create-an-html-table.l @@ -0,0 +1,5 @@ +(load "@lib/xhtml.l") + +( NIL NIL '(NIL (NIL "X") (NIL "Y") (NIL "Z")) + (for N 3 + ( NIL N 124 456 789) ) ) diff --git a/Task/Create-an-HTML-table/Python/create-an-html-table-1.py b/Task/Create-an-HTML-table/Python/create-an-html-table-1.py new file mode 100644 index 0000000000..6831fefc1b --- /dev/null +++ b/Task/Create-an-HTML-table/Python/create-an-html-table-1.py @@ -0,0 +1,17 @@ +import random + +def rand9999(): + return random.randint(1000, 9999) + +def tag(attr='', **kwargs): + for tag, txt in kwargs.items(): + return '<{tag}{attr}>{txt}'.format(**locals()) + +if __name__ == '__main__': + header = tag(tr=''.join(tag(th=txt) for txt in ',X,Y,Z'.split(','))) + '\n' + rows = '\n'.join(tag(tr=''.join(tag(' style="font-weight: bold;"', td=i) + + ''.join(tag(td=rand9999()) + for j in range(3)))) + for i in range(1, 6)) + table = tag(table='\n' + header + rows + '\n') + print(table) diff --git a/Task/Create-an-HTML-table/Python/create-an-html-table-2.py b/Task/Create-an-HTML-table/Python/create-an-html-table-2.py new file mode 100644 index 0000000000..e89aefa0b7 --- /dev/null +++ b/Task/Create-an-HTML-table/Python/create-an-html-table-2.py @@ -0,0 +1,8 @@ +
+ + + + + + +
XYZ
1604046977055
2252554686901
3885137278379
4531343961765
5401359246082
diff --git a/Task/Create-an-HTML-table/REXX/create-an-html-table.rexx b/Task/Create-an-HTML-table/REXX/create-an-html-table.rexx new file mode 100644 index 0000000000..cf270b1745 --- /dev/null +++ b/Task/Create-an-HTML-table/REXX/create-an-html-table.rexx @@ -0,0 +1,32 @@ +/*REXX program to create an HTML table of five rows and three columns. */ + +arg rows .; if rows=='' then rows=5 /*no ROWS specified? Use default*/ + cols=3 + maxRand=9999 /*4-digit numbers, allow negative*/ +headerInfo='X Y Z' /*column header information. */ + oFID='a_table.html' + +call lineout oFid,"" +call lineout oFid,"" +call lineout oFid,"" +call lineout oFid,"" + + do r=0 to rows + if r==0 then call lineout oFid,"" + else call lineout oFid,"" + + do c=1 for cols + if r==0 then call lineout oFid,"" + else call lineout oFid,"" + end /*c*/ + + end /*r*/ + +call lineout oFid,"
" r "" word(headerInfo,c) "" rnd() "
" +call lineout oFid,"" +call lineout oFid,"" +exit + +/*─────────────────────────────────────RND subroutine───────────────────*/ + /*subroutine was subroutinized for better viewfulabilityness.*/ +rnd: return right(random(0,maxRand*2)-maxRand,5) /*REXX doesn't gen negs*/ diff --git a/Task/Create-an-HTML-table/Racket/create-an-html-table.rkt b/Task/Create-an-HTML-table/Racket/create-an-html-table.rkt new file mode 100644 index 0000000000..bbc02ff3d6 --- /dev/null +++ b/Task/Create-an-HTML-table/Racket/create-an-html-table.rkt @@ -0,0 +1,17 @@ +#lang racket + +(require xml) + +(define xexpr + `(html + (head) + (body + (table + (tr (td) (td "X") (td "Y") (td "Z")) + ,@(for/list ([i (in-range 1 4)]) + `(tr (td ,(~a i)) + (td ,(~a (random 10000))) + (td ,(~a (random 10000))) + (td ,(~a (random 10000))))))))) + +(display-xml/content (xexpr->xml xexpr)) diff --git a/Task/Create-an-HTML-table/Ruby/create-an-html-table-1.rb b/Task/Create-an-HTML-table/Ruby/create-an-html-table-1.rb new file mode 100644 index 0000000000..c26f563ece --- /dev/null +++ b/Task/Create-an-HTML-table/Ruby/create-an-html-table-1.rb @@ -0,0 +1,22 @@ +def r + rand(10000) +end + +STDOUT << "".tap do |html| + html << "" + [ + ['X', 'Y', 'Z'], + [r ,r ,r], + [r ,r ,r], + [r ,r ,r], + [r ,r ,r] + + ].each_with_index do |row, index| + html << "" + html << "" + html << row.map { |e| ""}.join + html << "" + end + + html << "
#{index > 0 ? index : nil }#{e}
" +end diff --git a/Task/Create-an-HTML-table/Ruby/create-an-html-table-2.rb b/Task/Create-an-HTML-table/Ruby/create-an-html-table-2.rb new file mode 100644 index 0000000000..9fd85f04d5 --- /dev/null +++ b/Task/Create-an-HTML-table/Ruby/create-an-html-table-2.rb @@ -0,0 +1,20 @@ +def r; rand(10000); end +table = [["", "X", "Y", "Z"], + [ 1, r, r, r], + [ 2, r, r, r], + [ 3, r, r, r]] + +require 'rexml/document' + +xtable = REXML::Element.new("table") +table.each do |row| + xrow = REXML::Element.new("tr", xtable) + row.each do |cell| + xcell = REXML::Element.new("td", xrow) + REXML::Text.new(cell.to_s, false, xcell) + end +end + +formatter = REXML::Formatters::Pretty.new +formatter.compact = true +formatter.write(xtable, $stdout) diff --git a/Task/Create-an-HTML-table/Ruby/create-an-html-table-3.rb b/Task/Create-an-HTML-table/Ruby/create-an-html-table-3.rb new file mode 100644 index 0000000000..3d0daa51a0 --- /dev/null +++ b/Task/Create-an-HTML-table/Ruby/create-an-html-table-3.rb @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
XYZ
1135864886434
2247764931330
324030389849
diff --git a/Task/Create-an-HTML-table/Scheme/create-an-html-table.ss b/Task/Create-an-HTML-table/Scheme/create-an-html-table.ss new file mode 100644 index 0000000000..77c79901c7 --- /dev/null +++ b/Task/Create-an-HTML-table/Scheme/create-an-html-table.ss @@ -0,0 +1,21 @@ +(define table #( + #("" "X" "Y" "Z") + #(1 1 2 3) + #(2 4 5 6) + #(3 7 8 9))) + +(display "") +(do ((r 0 (+ r 1))) ((eq? r (vector-length table))) + (display "") + (do ((c 0 (+ c 1))) ((eq? c (vector-length (vector-ref table r)))) + (if (eq? r 0) + (display ""))) + (display "")) +(display "
")) + (if (> r 0) + (display "")) + (display (vector-ref (vector-ref table r) c)) + (if (eq? r 0) + (display "")) + (if (> r 0) + (display "
") diff --git a/Task/Create-an-HTML-table/Tcl/create-an-html-table.tcl b/Task/Create-an-HTML-table/Tcl/create-an-html-table.tcl new file mode 100644 index 0000000000..0a25494ed2 --- /dev/null +++ b/Task/Create-an-HTML-table/Tcl/create-an-html-table.tcl @@ -0,0 +1,41 @@ +# Make ourselves a very simple templating lib; just two commands +proc TAG {name args} { + set body [lindex $args end] + set result "<$name" + foreach {t v} [lrange $args 0 end-1] { + append result " $t=\"" $v "\"" + } + append result ">" [string trim [uplevel 1 [list subst $body]]] "" +} +proc FOREACH {var lst str} { + upvar 1 $var v + set result {} + set s [list subst $str] + foreach v $lst {append result [string trim [uplevel 1 $s]]} + return $result +} + +# Build the data we're displaying +set titles {"" "X" "Y" "Z"} +set data {} +for {set x 0} {$x < 4} {incr x} { + # Inspired by the Go solution, but with extra arbitrary digits to show 4-char wide values + lappend data [list \ + [expr {$x+1}] [expr {$x*3010}] [expr {$x*3+1298}] [expr {$x*2579+2182}]] +} + +# Write the table to standard out +puts [TAG table border 1 { + [TAG tr bgcolor #f0f0f0 { + [FOREACH head $titles { + [TAG th {$head}] + }] + }] + [FOREACH row $data { + [TAG tr bgcolor #ffffff { + [FOREACH col $row { + [TAG td align right {$col}] + }] + }] + }] +}] diff --git a/Task/Create-an-object-at-a-given-address/0DESCRIPTION b/Task/Create-an-object-at-a-given-address/0DESCRIPTION new file mode 100644 index 0000000000..6b87fa6c82 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/0DESCRIPTION @@ -0,0 +1,11 @@ +{{basic data operation}} +In systems programing it is sometimes required to place language objects at specific memory locations, like I/O registers, hardware interrupt vectors etc. + +'''Task''' + +Show how language objects can be allocated at a specific machine addresses. + +Since most [[OS]]es prohibit access to the physical memory if it is not mapped by the application, as an example, rather than a physical address, take the address of some existing object (using suitable [[Address Operations|address operations]] if necessary). For example, create an integer object. Print the machine address of the object. Take the address of the object and create another integer object at this address. Print the value of this object to verify that it is same as one of the origin. Change the value of the origin and verify it again. + + +{{omit from|Modula-2}} diff --git a/Task/Create-an-object-at-a-given-address/1META.yaml b/Task/Create-an-object-at-a-given-address/1META.yaml new file mode 100644 index 0000000000..a16ddc894f --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic Data Operations diff --git a/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-1.6502 b/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-1.6502 new file mode 100644 index 0000000000..72ea3cd310 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-1.6502 @@ -0,0 +1,3 @@ + sta $1900 + stx $1901 + sty $1902 diff --git a/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-2.6502 b/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-2.6502 new file mode 100644 index 0000000000..25df3f91e2 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-2.6502 @@ -0,0 +1,4 @@ + ldx #54 +.loop sta $1900,X + dex + bne loop diff --git a/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-3.6502 b/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-3.6502 new file mode 100644 index 0000000000..8a4c945e69 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-3.6502 @@ -0,0 +1,6 @@ + lda #0 + sta $70 + lda #$20 + sta $71 + ldy #0 + sta ($70),Y diff --git a/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-4.6502 b/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-4.6502 new file mode 100644 index 0000000000..163158e49e --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/6502-Assembly/create-an-object-at-a-given-address-4.6502 @@ -0,0 +1,6 @@ + lda #0 + sta $70 + lda #$20 + sta $71 + ldx #0 + sta ($70,X) diff --git a/Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-1.ada b/Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-1.ada new file mode 100644 index 0000000000..eaf521cd44 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-1.ada @@ -0,0 +1,3 @@ +type IO_Port is mod 2**8; -- One byte +Device_Port : type IO_Port; +for Device_Port'Address use 16#FFFF_F000#; diff --git a/Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-2.ada b/Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-2.ada new file mode 100644 index 0000000000..18e6cab1c8 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/Ada/create-an-object-at-a-given-address-2.ada @@ -0,0 +1,13 @@ +with Ada.Text_IO; use Ada.Text_IO; +with System.Storage_Elements; use System.Storage_Elements; + +procedure Test_Address is + X : Integer := 123; + Y : Integer; + for Y'Address use X'Address; +begin + Put_Line ("At address:" & Integer_Address'Image (To_Integer (Y'Address))); + Put_Line (Integer'Image (Y)); + X := 456; + Put_Line (Integer'Image (Y)); +end Test_Address; diff --git a/Task/Create-an-object-at-a-given-address/Aikido/create-an-object-at-a-given-address.aikido b/Task/Create-an-object-at-a-given-address/Aikido/create-an-object-at-a-given-address.aikido new file mode 100644 index 0000000000..a264fe09bd --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/Aikido/create-an-object-at-a-given-address.aikido @@ -0,0 +1,9 @@ +var portaddr = 0x80 +var v = peek (portaddr, 1) // 1 byte +v |= 0x40 +poke (portaddr, v, 1) // 1 byte back again + +var addr = malloc (16) +poke (addr, 1234, 4) +poke (addr+4, 0, 2) +poke (addr+6, 12, 2) diff --git a/Task/Create-an-object-at-a-given-address/AutoHotkey/create-an-object-at-a-given-address.ahk b/Task/Create-an-object-at-a-given-address/AutoHotkey/create-an-object-at-a-given-address.ahk new file mode 100644 index 0000000000..ac4171ee35 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/AutoHotkey/create-an-object-at-a-given-address.ahk @@ -0,0 +1,9 @@ +; Create a variable with 4 bytes size and show it's machine address. +VarSetCapacity(var, 4, 0) +pAddress := &var +MsgBox Machine address: %pAddress% + +; pAddress contains the memory address. +; Write a number and read it back. +NumPut(123456, pAddress+0, 0, "UInt") +MsgBox % "Contents of *pAddress: " . NumGet(pAddress+0, 0, "UInt") diff --git a/Task/Create-an-object-at-a-given-address/BBC-BASIC/create-an-object-at-a-given-address.bbc b/Task/Create-an-object-at-a-given-address/BBC-BASIC/create-an-object-at-a-given-address.bbc new file mode 100644 index 0000000000..6eae2c95da --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/BBC-BASIC/create-an-object-at-a-given-address.bbc @@ -0,0 +1,19 @@ + REM Create an integer object: + anInteger% = 12345678 + PRINT "Original value =", anInteger% + + REM Print the machine address of the object: + address% = ^anInteger% + PRINT "Hexadecimal address = ";~address% + + REM Take the address of the object and create + REM another integer object at this address: + !address% = 87654321 + + REM Print the value of this object to verify + REM that it is same as one of the origin: + PRINT "New value =", anInteger% + + REM Change the value and verify it again: + anInteger% = 55555555 + PRINT "Final value =", !address% diff --git a/Task/Create-an-object-at-a-given-address/C++/create-an-object-at-a-given-address.cpp b/Task/Create-an-object-at-a-given-address/C++/create-an-object-at-a-given-address.cpp new file mode 100644 index 0000000000..d2ab369a36 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/C++/create-an-object-at-a-given-address.cpp @@ -0,0 +1,24 @@ +#include +#include + +int main() +{ + // Allocate enough memory to hold an instance of std::string + char* data = new char[sizeof(std::string)]; + + // use placement new to construct a std::string in the memory we allocated previously + std::string* stringPtr = new (data) std::string("ABCD"); + + std::cout << *stringPtr << " 0x" << stringPtr << std::endl; + + // use placement new to construct a new string object in the same memory location + // remember to manually call destructor + stringPtr->~basic_string(); + stringPtr = new (data) std::string("123456"); + + std::cout << *stringPtr << " 0x" << stringPtr << std::endl; + + // clean up + stringPtr->~basic_string(); + delete[] data; +} diff --git a/Task/Create-an-object-at-a-given-address/C/create-an-object-at-a-given-address-1.c b/Task/Create-an-object-at-a-given-address/C/create-an-object-at-a-given-address-1.c new file mode 100644 index 0000000000..f0610ad32c --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/C/create-an-object-at-a-given-address-1.c @@ -0,0 +1,19 @@ +#include + +int main() +{ + int intspace; + int *address; + + address = &intspace; // address = 0x100; + *address = 65535; + printf("%p: %08x (=%08x)\n", address, *address, intspace); + // likely we must be worried about endianness, e.g. + *((char*)address) = 0x00; + *((char*)address+1) = 0x00; + *((char*)address+2) = 0xff; + *((char*)address+3) = 0xff; // if sizeof(int) == 4! + // which maybe is not the best way of writing 32 bit values... + printf("%p: %08x (=%08x)\n", address, *address, intspace); + return 0; +} diff --git a/Task/Create-an-object-at-a-given-address/C/create-an-object-at-a-given-address-2.c b/Task/Create-an-object-at-a-given-address/C/create-an-object-at-a-given-address-2.c new file mode 100644 index 0000000000..5c5531feca --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/C/create-an-object-at-a-given-address-2.c @@ -0,0 +1,15 @@ +// This is a port variable located at address 0x100 +#define PORT_A (*(volatile uint32_t*)0x100) + +void main() +{ + uint32_t dat; + + PORT_A ^= 0x01; // Toggle bit 0 of PORT_A + dat = PORT_A; // Read PORT_A + addr = &PORT_A; // addr = 0x100 + + while (1) + { + } +} diff --git a/Task/Create-an-object-at-a-given-address/COBOL/create-an-object-at-a-given-address.cobol b/Task/Create-an-object-at-a-given-address/COBOL/create-an-object-at-a-given-address.cobol new file mode 100644 index 0000000000..a0967cf614 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/COBOL/create-an-object-at-a-given-address.cobol @@ -0,0 +1,20 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. object-address-test. + DATA DIVISION. + LOCAL-STORAGE SECTION. + 01 int-space. + 05 val PICTURE 9(5) VALUE 12345. + 01 addr BASED. + 05 val PICTURE 9(5) VALUE ZERO. + 01 point USAGE POINTER. + PROCEDURE DIVISION. + DISPLAY val OF int-space END-DISPLAY + SET point TO ADDRESS OF int-space + DISPLAY point END-DISPLAY + SET ADDRESS OF addr TO point + DISPLAY val OF addr END-DISPLAY + MOVE 65535 TO val OF addr + DISPLAY val OF addr END-DISPLAY + DISPLAY val OF int-space END-DISPLAY + STOP RUN. + END PROGRAM object-address-test. diff --git a/Task/Create-an-object-at-a-given-address/D/create-an-object-at-a-given-address.d b/Task/Create-an-object-at-a-given-address/D/create-an-object-at-a-given-address.d new file mode 100644 index 0000000000..6697ee5f1a --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/D/create-an-object-at-a-given-address.d @@ -0,0 +1,34 @@ +import std.stdio ; + +void main() { + int[] arr ; + foreach(i; [0,1,2,3]) + arr ~= i*(1 << 24) + 0x417e7e7e ; + + struct X { + char[16] msg ; + } + + X* xPtr ; + int* iPtr ; + float* fPtr ; + + int adrSpace = cast(int) arr.ptr ; + // get address of an existing object arr + + xPtr = cast(X*) adrSpace ; + // xPtr now point to arr, as a struct X + writefln("arr(as X)'s msg = '%s' (len %d) @ 0x%08x", + xPtr.msg, xPtr.msg.length, xPtr) ; + + iPtr = cast(int*) (adrSpace + 1 * 4 /*bytes*/) ; + fPtr = cast(float*) iPtr ; + // pointers now point to arr[1] + writefln("arr[1] = 0x%8x (%9.4f) @ 0x%08X", *iPtr, *fPtr, iPtr) ; + iPtr = cast(int*) (adrSpace + 3 * 4 /*bytes*/) ; + fPtr = cast(float*) iPtr ; + // pointers now point to arr[3] + writefln("arr[3] = 0x%8x (%9.4f) @ 0x%08X", *iPtr, *fPtr, iPtr) ; + *fPtr = 0.5f ; // change value + writefln("arr[3] = 0x%8x (%9.4f) @ 0x%08X", *iPtr, *fPtr, iPtr) ; +} diff --git a/Task/Create-an-object-at-a-given-address/Forth/create-an-object-at-a-given-address.fth b/Task/Create-an-object-at-a-given-address/Forth/create-an-object-at-a-given-address.fth new file mode 100644 index 0000000000..39732c48dd --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/Forth/create-an-object-at-a-given-address.fth @@ -0,0 +1,4 @@ +$3f8 constant LPT1: + +LPT1: c@ . +$3f LPT1: c! diff --git a/Task/Create-an-object-at-a-given-address/Go/create-an-object-at-a-given-address.go b/Task/Create-an-object-at-a-given-address/Go/create-an-object-at-a-given-address.go new file mode 100644 index 0000000000..93451ce5ee --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/Go/create-an-object-at-a-given-address.go @@ -0,0 +1,58 @@ +package main + +import( + "fmt" + "unsafe" + "reflect" +) + +func pointer() { + fmt.Printf("Pointer:\n") + + // Create a *int and store the address of 'i' in it. To create a pointer to + // an arbitrary memory location, use something like the following: + // p := (*int)(unsafe.Pointer(uintptr(0x100))) + // And replace '0x100' with the desired address. + var i int + p := &i + + fmt.Printf("Before:\n\t%v: %v, %v\n", p, *p, i) + + *p = 3 + + fmt.Printf("After:\n\t%v: %v, %v\n", p, *p, i) +} + +func slice() { + fmt.Printf("Slice:\n") + + var a [10]byte + + // reflect.SliceHeader is a runtime representation of the internal workings + // of a slice. To make it point to a specific address, use something like + // the following: + // h.Data = uintptr(0x100) + // And replace '0x100' with the desired address. + var h reflect.SliceHeader + h.Data = uintptr(unsafe.Pointer(&a)) // The address of the first element of the underlying array. + h.Len = len(a) + h.Cap = len(a) + + // Create an actual slice from the SliceHeader. + s := *(*[]byte)(unsafe.Pointer(&h)) + + fmt.Printf("Before:\n\ts: %v\n\ta: %v\n", s, a) + + // Copy a string into the slice. This fills the underlying array, which in + // this case has been manually set to 'a'. + copy(s, "A string.") + + fmt.Printf("After:\n\ts: %v\n\ta: %v\n", s, a) +} + +func main() { + pointer() + fmt.Println() + + slice() +} diff --git a/Task/Create-an-object-at-a-given-address/PicoLisp/create-an-object-at-a-given-address.l b/Task/Create-an-object-at-a-given-address/PicoLisp/create-an-object-at-a-given-address.l new file mode 100644 index 0000000000..9532bf430a --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/PicoLisp/create-an-object-at-a-given-address.l @@ -0,0 +1,11 @@ +: (setq IntSpace 12345) # Integer +-> 12345 + +: (setq Address (adr 'IntSpace)) # Encoded machine address +-> -2969166782547 + +: (set (adr Address) 65535) # Set this address to a new value +-> 65535 + +: IntSpace # Show the new value +-> 65535 diff --git a/Task/Create-an-object-at-a-given-address/Tcl/create-an-object-at-a-given-address-1.tcl b/Task/Create-an-object-at-a-given-address/Tcl/create-an-object-at-a-given-address-1.tcl new file mode 100644 index 0000000000..fce12a21ea --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/Tcl/create-an-object-at-a-given-address-1.tcl @@ -0,0 +1,21 @@ +package require critcl + +# A command to 'make an integer object' and couple it to a Tcl variable +critcl::cproc linkvar {Tcl_Interp* interp char* var1} int { + int *intPtr = (int *) ckalloc(sizeof(int)); + + *intPtr = 0; + Tcl_LinkVar(interp, var1, (void *) intPtr, TCL_LINK_INT); + return (int) intPtr; +} + +# A command to couple another Tcl variable to an 'integer object'; UNSAFE! +critcl::cproc linkagain(Tcl_Interp* interp int addr char* var2} void { + int *intPtr = (int *) addr; + + Tcl_LinkVar(interp, var2, (void *) intPtr, TCL_LINK_INT); +} + +# Conventionally, programs that use critcl structure in packages +# This is used to prevent recompilation, especially on systems like Windows +package provide machAddrDemo 1 diff --git a/Task/Create-an-object-at-a-given-address/Tcl/create-an-object-at-a-given-address-2.tcl b/Task/Create-an-object-at-a-given-address/Tcl/create-an-object-at-a-given-address-2.tcl new file mode 100644 index 0000000000..a14d6b2f82 --- /dev/null +++ b/Task/Create-an-object-at-a-given-address/Tcl/create-an-object-at-a-given-address-2.tcl @@ -0,0 +1,7 @@ +package require machAddrDemo +set addr [linkvar foo] +puts "var 'foo' at $addr with value $foo" +linkagain $addr bar +puts "var 'bar' at $addr with value $bar" +incr foo +puts "incremented 'foo' so 'bar' is $bar" diff --git a/Task/Cut-a-rectangle/0DESCRIPTION b/Task/Cut-a-rectangle/0DESCRIPTION new file mode 100644 index 0000000000..23645d738e --- /dev/null +++ b/Task/Cut-a-rectangle/0DESCRIPTION @@ -0,0 +1,7 @@ +A given rectangle is made from ''m'' × ''n'' squares. If ''m'' and ''n'' are not both odd, then it is possible to cut a path through the rectangle along the square edges such that the rectangle splits into two connected pieces with the same shape (after rotating one of the pieces by 180°). All such paths for 2 × 2 and 4 × 3 rectangles are shown below. + +[[file:rect-cut.svg]] + +Write a program that calculates the number of different ways to cut an ''m'' × ''n'' rectangle. Optionally, show each of the cuts. + +Possibly related task: [[Maze generation]] for depth-first search. diff --git a/Task/Cut-a-rectangle/C/cut-a-rectangle-1.c b/Task/Cut-a-rectangle/C/cut-a-rectangle-1.c new file mode 100644 index 0000000000..d284167b19 --- /dev/null +++ b/Task/Cut-a-rectangle/C/cut-a-rectangle-1.c @@ -0,0 +1,80 @@ +#include +#include +#include + +typedef unsigned char byte; +byte *grid = 0; + +int w, h, len; +unsigned long long cnt; + +static int next[4], dir[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}}; +void walk(int y, int x) +{ + int i, t; + + if (!y || y == h || !x || x == w) { + cnt += 2; + return; + } + + t = y * (w + 1) + x; + grid[t]++, grid[len - t]++; + + for (i = 0; i < 4; i++) + if (!grid[t + next[i]]) + walk(y + dir[i][0], x + dir[i][1]); + + grid[t]--, grid[len - t]--; +} + +unsigned long long solve(int hh, int ww, int recur) +{ + int t, cx, cy, x; + + h = hh, w = ww; + + if (h & 1) t = w, w = h, h = t; + if (h & 1) return 0; + if (w == 1) return 1; + if (w == 2) return h; + if (h == 2) return w; + + cy = h / 2, cx = w / 2; + + len = (h + 1) * (w + 1); + grid = realloc(grid, len); + memset(grid, 0, len--); + + next[0] = -1; + next[1] = -w - 1; + next[2] = 1; + next[3] = w + 1; + + if (recur) cnt = 0; + for (x = cx + 1; x < w; x++) { + t = cy * (w + 1) + x; + grid[t] = 1; + grid[len - t] = 1; + walk(cy - 1, x); + } + cnt++; + + if (h == w) + cnt *= 2; + else if (!(w & 1) && recur) + solve(w, h, 0); + + return cnt; +} + +int main() +{ + int y, x; + for (y = 1; y <= 10; y++) + for (x = 1; x <= y; x++) + if (!(x & 1) || !(y & 1)) + printf("%d x %d: %llu\n", y, x, solve(y, x, 1)); + + return 0; +} diff --git a/Task/Cut-a-rectangle/C/cut-a-rectangle-2.c b/Task/Cut-a-rectangle/C/cut-a-rectangle-2.c new file mode 100644 index 0000000000..175f160faa --- /dev/null +++ b/Task/Cut-a-rectangle/C/cut-a-rectangle-2.c @@ -0,0 +1,40 @@ +2 x 1: 1 +2 x 2: 2 +3 x 2: 3 +4 x 1: 1 +4 x 2: 4 +4 x 3: 9 +4 x 4: 22 +5 x 2: 5 +5 x 4: 39 +6 x 1: 1 +6 x 2: 6 +6 x 3: 23 +6 x 4: 90 +6 x 5: 263 +6 x 6: 1018 +7 x 2: 7 +7 x 4: 151 +7 x 6: 2947 +8 x 1: 1 +8 x 2: 8 +8 x 3: 53 +8 x 4: 340 +8 x 5: 1675 +8 x 6: 11174 +8 x 7: 55939 +8 x 8: 369050 +9 x 2: 9 +9 x 4: 553 +9 x 6: 31721 +9 x 8: 1812667 +10 x 1: 1 +10 x 2: 10 +10 x 3: 115 +10 x 4: 1228 +10 x 5: 10295 +10 x 6: 118276 +10 x 7: 1026005 +10 x 8: 11736888 +10 x 9: 99953769 +10 x 10: 1124140214 diff --git a/Task/Cut-a-rectangle/C/cut-a-rectangle-3.c b/Task/Cut-a-rectangle/C/cut-a-rectangle-3.c new file mode 100644 index 0000000000..0c9b00cf07 --- /dev/null +++ b/Task/Cut-a-rectangle/C/cut-a-rectangle-3.c @@ -0,0 +1,191 @@ +#include +#include + +typedef unsigned char byte; +int w = 0, h = 0, verbose = 0; +unsigned long count = 0; + +byte **hor, **ver, **vis; +byte **c = 0; + +enum { U = 1, D = 2, L = 4, R = 8 }; + +byte ** alloc2(int w, int h) +{ + int i; + byte **x = calloc(1, sizeof(byte*) * h + h * w); + x[0] = (byte *)&x[h]; + for (i = 1; i < h; i++) + x[i] = x[i - 1] + w; + return x; +} + +void show() +{ + int i, j, v, last_v; + printf("%ld\n", count); +#if 0 + for (i = 0; i <= h; i++) { + for (j = 0; j <= w; j++) + printf("%d ", hor[i][j]); + puts(""); + } + puts(""); + + for (i = 0; i <= h; i++) { + for (j = 0; j <= w; j++) + printf("%d ", ver[i][j]); + puts(""); + } + puts(""); +#endif + for (i = 0; i < h; i++) { + if (!i) v = last_v = 0; + else last_v = v = hor[i][0] ? !last_v : last_v; + + for (j = 0; j < w; v = ver[i][++j] ? !v : v) + printf(v ? "\033[31m[]" : "\033[33m{}"); + puts("\033[m"); + } + putchar('\n'); +} + +void walk(int y, int x) +{ + if (x < 0 || y < 0 || x > w || y > h) return; + + if (!x || !y || x == w || y == h) { + ++count; + if (verbose) show(); + return; + } + + if (vis[y][x]) return; + vis[y][x]++; vis[h - y][w - x]++; + + if (x && !hor[y][x - 1]) { + hor[y][x - 1] = hor[h - y][w - x] = 1; + walk(y, x - 1); + hor[y][x - 1] = hor[h - y][w - x] = 0; + } + if (x < w && !hor[y][x]) { + hor[y][x] = hor[h - y][w - x - 1] = 1; + walk(y, x + 1); + hor[y][x] = hor[h - y][w - x - 1] = 0; + } + + if (y && !ver[y - 1][x]) { + ver[y - 1][x] = ver[h - y][w - x] = 1; + walk(y - 1, x); + ver[y - 1][x] = ver[h - y][w - x] = 0; + } + + if (y < h && !ver[y][x]) { + ver[y][x] = ver[h - y - 1][w - x] = 1; + walk(y + 1, x); + ver[y][x] = ver[h - y - 1][w - x] = 0; + } + + vis[y][x]--; vis[h - y][w - x]--; +} + +void cut(void) +{ + if (1 & (h * w)) return; + + hor = alloc2(w + 1, h + 1); + ver = alloc2(w + 1, h + 1); + vis = alloc2(w + 1, h + 1); + + if (h & 1) { + ver[h/2][w/2] = 1; + walk(h / 2, w / 2); + } else if (w & 1) { + hor[h/2][w/2] = 1; + walk(h / 2, w / 2); + } else { + vis[h/2][w/2] = 1; + + hor[h/2][w/2-1] = hor[h/2][w/2] = 1; + walk(h / 2, w / 2 - 1); + hor[h/2][w/2-1] = hor[h/2][w/2] = 0; + + ver[h/2 - 1][w/2] = ver[h/2][w/2] = 1; + walk(h / 2 - 1, w/2); + } +} + +void cwalk(int y, int x, int d) +{ + if (!y || y == h || !x || x == w) { + ++count; + return; + } + vis[y][x] = vis[h-y][w-x] = 1; + + if (x && !vis[y][x-1]) + cwalk(y, x - 1, d|1); + if ((d&1) && x < w && !vis[y][x+1]) + cwalk(y, x + 1, d|1); + if (y && !vis[y-1][x]) + cwalk(y - 1, x, d|2); + if ((d&2) && y < h && !vis[y + 1][x]) + cwalk(y + 1, x, d|2); + + vis[y][x] = vis[h-y][w-x] = 0; +} + +void count_only(void) +{ + int t; + long res; + if (h * w & 1) return; + if (h & 1) t = h, h = w, w = t; + + vis = alloc2(w + 1, h + 1); + vis[h/2][w/2] = 1; + + if (w & 1) vis[h/2][w/2 + 1] = 1; + if (w > 1) { + cwalk(h/2, w/2 - 1, 1); + res = 2 * count - 1; + count = 0; + if (w != h) + cwalk(h/2+1, w/2, (w & 1) ? 3 : 2); + + res += 2 * count - !(w & 1); + } else { + res = 1; + } + if (w == h) res = 2 * res + 2; + count = res; +} + +int main(int c, char **v) +{ + int i; + + for (i = 1; i < c; i++) { + if (v[i][0] == '-' && v[i][1] == 'v' && !v[i][2]) { + verbose = 1; + } else if (!w) { + w = atoi(v[i]); + if (w <= 0) goto bail; + } else if (!h) { + h = atoi(v[i]); + if (h <= 0) goto bail; + } else + goto bail; + } + if (!w) goto bail; + if (!h) h = w; + + if (verbose) cut(); + else count_only(); + + printf("Total: %ld\n", count); + return 0; + +bail: fprintf(stderr, "bad args\n"); + return 1; +} diff --git a/Task/Cut-a-rectangle/Common-Lisp/cut-a-rectangle-1.lisp b/Task/Cut-a-rectangle/Common-Lisp/cut-a-rectangle-1.lisp new file mode 100644 index 0000000000..12dab66f06 --- /dev/null +++ b/Task/Cut-a-rectangle/Common-Lisp/cut-a-rectangle-1.lisp @@ -0,0 +1,43 @@ +(defun cut-it (w h &optional (recur t)) + (if (oddp (* w h)) (return-from cut-it 0)) + (if (oddp h) (rotatef w h)) + (if (= w 1) (return-from cut-it h)) + + (let ((cnt 0) + (m (make-array (list (1+ h) (1+ w)) + :element-type 'bit + :initial-element 0)) + (cy (truncate h 2)) + (cx (truncate w 2))) + + (setf (aref m cy cx) 1) + (if (oddp w) (setf (aref m cy (1+ cx)) 1)) + + (labels + ((walk (y x turned) + (when (or (= y 0) (= y h) (= x 0) (= x w)) + (incf cnt (if turned 2 1)) + (return-from walk)) + + (setf (aref m y x) 1) + (setf (aref m (- h y) (- w x)) 1) + (loop for i from 0 + for (dy dx) in '((0 -1) (-1 0) (0 1) (1 0)) + while (or turned (< i 2)) do + (let ((y2 (+ y dy)) + (x2 (+ x dx))) + (when (zerop (aref m y2 x2)) + (walk y2 x2 (or turned (> i 0)))))) + (setf (aref m (- h y) (- w x)) 0) + (setf (aref m y x) 0))) + + (walk cy (1- cx) nil) + (cond ((= h w) (incf cnt cnt)) + ((oddp w) (walk (1- cy) cx t)) + (recur (incf cnt (cut-it h w nil)))) + cnt))) + +(loop for w from 1 to 9 do + (loop for h from 1 to w do + (if (evenp (* w h)) + (format t "~d x ~d: ~d~%" w h (cut-it w h))))) diff --git a/Task/Cut-a-rectangle/Common-Lisp/cut-a-rectangle-2.lisp b/Task/Cut-a-rectangle/Common-Lisp/cut-a-rectangle-2.lisp new file mode 100644 index 0000000000..d0ccf19b6e --- /dev/null +++ b/Task/Cut-a-rectangle/Common-Lisp/cut-a-rectangle-2.lisp @@ -0,0 +1,30 @@ +2 x 1: 2 +2 x 2: 2 +3 x 2: 3 +4 x 1: 4 +4 x 2: 4 +4 x 3: 9 +4 x 4: 22 +5 x 2: 5 +5 x 4: 39 +6 x 1: 6 +6 x 2: 6 +6 x 3: 23 +6 x 4: 90 +6 x 5: 263 +6 x 6: 1018 +7 x 2: 7 +7 x 4: 151 +7 x 6: 2947 +8 x 1: 8 +8 x 2: 8 +8 x 3: 53 +8 x 4: 340 +8 x 5: 1675 +8 x 6: 11174 +8 x 7: 55939 +8 x 8: 369050 +9 x 2: 9 +9 x 4: 553 +9 x 6: 31721 +9 x 8: 1812667 diff --git a/Task/Cut-a-rectangle/D/cut-a-rectangle.d b/Task/Cut-a-rectangle/D/cut-a-rectangle.d new file mode 100644 index 0000000000..6c21e6fcb2 --- /dev/null +++ b/Task/Cut-a-rectangle/D/cut-a-rectangle.d @@ -0,0 +1,88 @@ +import core.stdc.stdio, core.stdc.stdlib, + core.stdc.string, std.typetuple; + +template Range(int stop) { // for manual loop unroll + static if (stop <= 0) + alias TypeTuple!() Range; + else + alias TypeTuple!(Range!(stop-1), stop-1) Range; +} + +enum int[2][4] dir = [[0, -1], [-1, 0], [0, 1], [1, 0]]; + +__gshared ubyte[] grid; +__gshared int w, h, len; +__gshared ulong cnt; +__gshared int[4] next; + +void walk(in int y, in int x) nothrow { + if (!y || y == h || !x || x == w) { + cnt += 2; + return; + } + + immutable int t = y * (w + 1) + x; + grid[t]++; + grid[len - t]++; + + foreach (i; Range!4) // manual loop unroll + if (!grid[t + next[i]]) + walk(y + dir[i][0], x + dir[i][1]); + + grid[t]--; + grid[len - t]--; +} + +ulong solve(in int hh, in int ww, in bool recur) nothrow { + h = (hh & 1) ? ww : hh; + w = (hh & 1) ? hh : ww; + + if (h & 1) return 0; + if (w == 1) return 1; + if (w == 2) return h; + if (h == 2) return w; + + immutable int cy = h / 2; + immutable int cx = w / 2; + + len = (h + 1) * (w + 1); + { + // grid = new ubyte[len]; // slower + ubyte* ptr = cast(ubyte*)alloca(len); + if (ptr == null) + exit(1); + grid = ptr[0 .. len]; + } + grid[] = 0; + len--; + + //next = [-1, -w - 1, 1, w + 1]; // slow + next[0] = -1; + next[1] = -w - 1; + next[2] = 1; + next[3] = w + 1; + + if (recur) + cnt = 0; + foreach (x; cx + 1 .. w) { + immutable int t = cy * (w + 1) + x; + grid[t] = 1; + grid[len - t] = 1; + walk(cy - 1, x); + } + cnt++; + + if (h == w) + cnt *= 2; + else if (!(w & 1) && recur) + solve(w, h, 0); + + return cnt; +} + +void main() { + foreach (y; 1 .. 11) + foreach (x; 1 .. y + 1) + if (!(x & 1) || !(y & 1)) + printf("%d x %d: %llu\n", y, x, solve(y, x, true)); +} diff --git a/Task/Cut-a-rectangle/Haskell/cut-a-rectangle.hs b/Task/Cut-a-rectangle/Haskell/cut-a-rectangle.hs new file mode 100644 index 0000000000..7254a2cc15 --- /dev/null +++ b/Task/Cut-a-rectangle/Haskell/cut-a-rectangle.hs @@ -0,0 +1,80 @@ +import qualified Data.Vector.Unboxed.Mutable as V +import Data.STRef +import Control.Monad (forM_, when) +import Control.Monad.ST + +dir :: [(Int, Int)] +dir = [(1, 0), (-1, 0), (0, -1), (0, 1)] + +data Env = Env { w, h, len, count, ret :: !Int, next :: ![Int] } + +cutIt :: STRef s Env -> ST s () +cutIt env = do + e <- readSTRef env + when (odd $ h e) $ modifySTRef env $ \en -> en { h = w e, + w = h e } + e <- readSTRef env + if odd (h e) + then modifySTRef env $ \en -> en { ret = 0 } + else + if w e == 1 + then modifySTRef env $ \en -> en { ret = 1 } + else do + let blen = (h e + 1) * (w e + 1) - 1 + t = (h e `div` 2) * (w e + 1) + (w e `div` 2) + modifySTRef env $ \en -> en { len = blen, + count = 0, + next = [ w e + 1, (negate $ w e) - 1, -1, 1] } + grid <- V.replicate (blen + 1) False + case odd (w e) of + True -> do + V.write grid t True + V.write grid (t + 1) True + walk grid (h e `div` 2) (w e `div` 2 - 1) + e1 <- readSTRef env + let res1 = count e1 + modifySTRef env $ \en -> en { count = 0 } + walk grid (h e `div` 2 - 1) (w e `div` 2) + modifySTRef env $ \en -> en { ret = res1 + + (count en * 2) } + False -> do + V.write grid t True + walk grid (h e `div` 2) (w e `div` 2 - 1) + e2 <- readSTRef env + let count2 = count e2 + if h e == w e + then modifySTRef env $ \en -> en { ret = + count2 * 2 } + else do + walk grid (h e `div` 2 - 1) + (w e `div` 2) + modifySTRef env $ \en -> en { ret = + count en } + where + walk grid y x = do + e <- readSTRef env + if y <= 0 || y >= h e || x <= 0 || x >= w e + then modifySTRef env $ \en -> en { count = count en + 1 } + else do + let t = y * (w e + 1) + x + V.write grid t True + V.write grid (len e - t) True + forM_ (zip (next e) [0..3]) $ \(n, d) -> do + g <- V.read grid (t + n) + when (not g) $ + walk grid (y + fst (dir !! d)) (x + snd (dir !! d)) + V.write grid t False + V.write grid (len e - t) False + +cut :: (Int, Int) -> Int +cut (x, y) = runST $ do + env <- newSTRef $ Env { w = y, h = x, len = 0, count = 0, ret = 0, next = [] } + cutIt env + result <- readSTRef env + return $ ret result + +main :: IO () +main = do + mapM_ (\(x, y) -> when (even (x * y)) (putStrLn $ + show x ++ " x " ++ show y ++ ": " ++ show (cut (x, y)))) + [ (x, y) | x <- [1..10], y <- [1..x] ] diff --git a/Task/Cut-a-rectangle/Python/cut-a-rectangle-1.py b/Task/Cut-a-rectangle/Python/cut-a-rectangle-1.py new file mode 100644 index 0000000000..796ba34d4f --- /dev/null +++ b/Task/Cut-a-rectangle/Python/cut-a-rectangle-1.py @@ -0,0 +1,53 @@ +def cut_it(h, w): + dirs = ((1, 0), (-1, 0), (0, -1), (0, 1)) + if h & 1: h, w = w, h + if h & 1: return 0 + if w == 1: return 1 + count = 0 + + next = [w + 1, -w - 1, -1, 1] + blen = (h + 1) * (w + 1) - 1 + grid = [False] * (blen + 1) + + def walk(y, x, count): + if not y or y == h or not x or x == w: + return count + 1 + + t = y * (w + 1) + x + grid[t] = grid[blen - t] = True + + if not grid[t + next[0]]: + count = walk(y + dirs[0][0], x + dirs[0][1], count) + if not grid[t + next[1]]: + count = walk(y + dirs[1][0], x + dirs[1][1], count) + if not grid[t + next[2]]: + count = walk(y + dirs[2][0], x + dirs[2][1], count) + if not grid[t + next[3]]: + count = walk(y + dirs[3][0], x + dirs[3][1], count) + + grid[t] = grid[blen - t] = False + return count + + t = h // 2 * (w + 1) + w // 2 + if w & 1: + grid[t] = grid[t + 1] = True + count = walk(h // 2, w // 2 - 1, count) + res = count + count = 0 + count = walk(h // 2 - 1, w // 2, count) + return res + count * 2 + else: + grid[t] = True + count = walk(h // 2, w // 2 - 1, count) + if h == w: + return count * 2 + count = walk(h // 2 - 1, w // 2, count) + return count + +def main(): + for w in xrange(1, 10): + for h in xrange(1, w + 1): + if not((w * h) & 1): + print "%d x %d: %d" % (w, h, cut_it(w, h)) + +main() diff --git a/Task/Cut-a-rectangle/Python/cut-a-rectangle-2.py b/Task/Cut-a-rectangle/Python/cut-a-rectangle-2.py new file mode 100644 index 0000000000..8644685df5 --- /dev/null +++ b/Task/Cut-a-rectangle/Python/cut-a-rectangle-2.py @@ -0,0 +1,70 @@ +try: + import psyco +except ImportError: + pass +else: + psyco.full() + +w, h = 0, 0 +count = 0 +vis = [] + +def cwalk(y, x, d): + global vis, count, w, h + if not y or y == h or not x or x == w: + count += 1 + return + + vis[y][x] = vis[h - y][w - x] = 1 + + if x and not vis[y][x - 1]: + cwalk(y, x - 1, d | 1) + if (d & 1) and x < w and not vis[y][x+1]: + cwalk(y, x + 1, d|1) + if y and not vis[y - 1][x]: + cwalk(y - 1, x, d | 2) + if (d & 2) and y < h and not vis[y + 1][x]: + cwalk(y + 1, x, d | 2) + + vis[y][x] = vis[h - y][w - x] = 0 + +def count_only(x, y): + global vis, count, w, h + count = 0 + w = x + h = y + + if (h * w) & 1: + return count + if h & 1: + w, h = h, w + + vis = [[0] * (w + 1) for _ in xrange(h + 1)] + vis[h // 2][w // 2] = 1 + + if w & 1: + vis[h // 2][w // 2 + 1] = 1 + + res = 0 + if w > 1: + cwalk(h // 2, w // 2 - 1, 1) + res = 2 * count - 1 + count = 0 + if w != h: + cwalk(h // 2 + 1, w // 2, 3 if (w & 1) else 2) + + res += 2 * count - (not (w & 1)) + else: + res = 1 + + if w == h: + res = 2 * res + 2 + return res + +def main(): + for y in xrange(1, 10): + for x in xrange(1, y + 1): + if not (x & 1) or not (y & 1): + print "%d x %d: %d" % (y, x, count_only(x, y)) + +main() diff --git a/Task/Cut-a-rectangle/REXX/cut-a-rectangle.rexx b/Task/Cut-a-rectangle/REXX/cut-a-rectangle.rexx new file mode 100644 index 0000000000..39e059b743 --- /dev/null +++ b/Task/Cut-a-rectangle/REXX/cut-a-rectangle.rexx @@ -0,0 +1,45 @@ +/*REXX program cuts rectangles into two symmetric pieces, the rectangles*/ +/*──────────────────── are cut along unit dimensions and may be rotated.*/ +numeric digits 20 /*be able to handle big integers.*/ +parse arg N .; if N=='' then N=10 /*Not specified? Use the default?*/ +dir.=0; dir.0.1=-1; dir.1.0=-1; dir.2.1=1; dir.3.0=1 /*directions.*/ + + do y=2 to N; say /*calculate rectangles up to NxN.*/ + do x=1 for y; if x//2 & y//2 then iterate /*not if both odd.*/ + _=solve(y,x,1); _=right(_,max(10,length(_))) /*align the output*/ + say right(y,9) "x" right(x,2) 'rectangle can be cut' _ "way"s(_)'.' + end /*x*/ + end /*y*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────WALK subroutine─────────────────────*/ +walk: procedure expose # dir. @. h len next. w; parse arg y,x +if y==h then do; #=#+2; return; end /* ◄──┐ REXX short circuit.*/ +if x==0 then do; #=#+2; return; end /* ◄──┤ " " " */ +if x==w then do; #=#+2; return; end /* ◄──┤ " " " */ +if y==0 then do; #=#+2; return; end /* ◄──┤ " " " */ +t=x + y*(w+1); @.t=@.t+1; _=len-t /* │ ordered by most likely►─┐*/ +@._=@._+1 /* └─────────────────────────┘*/ + do j=0 for 4; _ = t+next.j /*try four directions*/ + if @._==0 then call walk y+dir.j.0, x+dir.j.1 + end /*j*/ + +@.t=@.t-1; _=len-t; @._=@._-1 +return +/*──────────────────────────────────S subroutine────────────────────────*/ +s: if arg(1)=1 then return arg(3); return word(arg(2) 's',1) +/*──────────────────────────────────SOLVE subroutine────────────────────*/ +solve: procedure expose # dir. @. h len next. w +parse arg hh 1 h,ww 1 w,recur; @. = 0 /*zero the rectangle coördinates.*/ +if h//2 then do; t=w; w=h; h=t; if h//2 then return 0; end +if w==1 then return 1; if w==2 then return h; if h==2 then return w +cy = h%2; cx=w%2 /*cut the [XY] rectangle in ½. */ +len = (h+1) * (w+1) - 1 /*extended area of the rectangle.*/ +next.0=-1; next.1=-w-1; next.2=1; next.3=w+1 /*compute direction dist*/ +if recur then #=0 + do x=cx+1 to w-1; t=x+cy*(w+1) + @.t=1; _=len-t; @._=1; call walk cy-1,x + end /*x*/ +#=#+1 +if h==w then #=#+# /*double count of rectangle cuts.*/ + else if w//2==0 & recur then call solve w,h,0 +return # diff --git a/Task/Cut-a-rectangle/Tcl/cut-a-rectangle.tcl b/Task/Cut-a-rectangle/Tcl/cut-a-rectangle.tcl new file mode 100644 index 0000000000..2c25f46226 --- /dev/null +++ b/Task/Cut-a-rectangle/Tcl/cut-a-rectangle.tcl @@ -0,0 +1,82 @@ +package require Tcl 8.5 + +proc walk {y x} { + global w ww h cnt grid len + if {!$y || $y==$h || !$x || $x==$w} { + incr cnt 2 + return + } + set t [expr {$y*$ww + $x}] + set m [expr {$len - $t}] + lset grid $t [expr {[lindex $grid $t] + 1}] + lset grid $m [expr {[lindex $grid $m] + 1}] + if {![lindex $grid [expr {$y*$ww + $x-1}]]} { + walk $y [expr {$x-1}] + } + if {![lindex $grid [expr {($y-1)*$ww + $x}]]} { + walk [expr {$y-1}] $x + } + if {![lindex $grid [expr {$y*$ww + $x+1}]]} { + walk $y [expr {$x+1}] + } + if {![lindex $grid [expr {($y+1)*$ww + $x}]]} { + walk [expr {$y+1}] $x + } + lset grid $t [expr {[lindex $grid $t] - 1}] + lset grid $m [expr {[lindex $grid $m] - 1}] +} + +# Factored out core of [solve] +proc SolveCore {} { + global w ww h cnt grid len + set ww [expr {$w+1}] + set cy [expr {$h / 2}] + set cx [expr {$w / 2}] + + set len [expr {($h+1) * $ww}] + set grid [lrepeat $len 0] + incr len -1 + + for {set x $cx;incr x} {$x < $w} {incr x} { + set t [expr {$cy*$ww+$x}] + lset grid $t 1 + lset grid [expr {$len - $t}] 1 + walk [expr {$cy - 1}] $x + } + incr cnt +} +proc solve {H W} { + global w h cnt + set h $H + set w $W + if {$h & 1} { + set h $W + set w $H + } + if {$h & 1} { + return 0 + } + if {$w==1} {return 1} + if {$w==2} {return $h} + if {$h==2} {return $w} + + set cnt 0 + SolveCore + if {$h==$w} { + incr cnt $cnt + } elseif {!($w & 1)} { + lassign [list $w $h] h w + SolveCore + } + return $cnt +} + +apply {{limit} { + for {set yy 1} {$yy <= $limit} {incr yy} { + for {set xx 1} {$xx <= $yy} {incr xx} { + if {!($xx&1 && $yy&1)} { + puts [format "%d x %d: %ld" $yy $xx [solve $yy $xx]] + } + } + } +}} 10 diff --git a/Task/DNS-query/0DESCRIPTION b/Task/DNS-query/0DESCRIPTION new file mode 100644 index 0000000000..2c0694cf80 --- /dev/null +++ b/Task/DNS-query/0DESCRIPTION @@ -0,0 +1,3 @@ +DNS is an internet service that maps domain names, like rosettacode.org, to IP addresses, like 66.220.0.231. + +Use DNS to resolve www.kame.net to both IPv4 and IPv6 addresses. Print these addresses. diff --git a/Task/DNS-query/1META.yaml b/Task/DNS-query/1META.yaml new file mode 100644 index 0000000000..688669690e --- /dev/null +++ b/Task/DNS-query/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Networking and Web Interaction diff --git a/Task/DNS-query/Ada/dns-query.ada b/Task/DNS-query/Ada/dns-query.ada new file mode 100644 index 0000000000..bf03d08eb4 --- /dev/null +++ b/Task/DNS-query/Ada/dns-query.ada @@ -0,0 +1,13 @@ +with Ada.Text_IO; use Ada.Text_IO; +with GNAT.Sockets; use GNAT.Sockets; + +procedure DNSQuerying is + + Host : Host_Entry_Type (1, 1); + Inet_Addr_V4 : Inet_Addr_Type (Family_Inet); +begin + + Host := Get_Host_By_Name (Name => "www.kame.net"); + Inet_Addr_V4 := Addresses (Host); + Put ("IPv4: " & Image (Value => Inet_Addr_V4)); +end DNSQuerying; diff --git a/Task/DNS-query/BBC-BASIC/dns-query-1.bbc b/Task/DNS-query/BBC-BASIC/dns-query-1.bbc new file mode 100644 index 0000000000..d119e86985 --- /dev/null +++ b/Task/DNS-query/BBC-BASIC/dns-query-1.bbc @@ -0,0 +1,52 @@ + name$ = "www.kame.net" + + AF_INET = 2 + AF_INET6 = 23 + WSASYS_STATUS_LEN = 128 + WSADESCRIPTION_LEN = 256 + + SYS "LoadLibrary", "WS2_32.DLL" TO ws2% + SYS "GetProcAddress", ws2%, "WSAStartup" TO `WSAStartup` + SYS "GetProcAddress", ws2%, "WSACleanup" TO `WSACleanup` + SYS "GetProcAddress", ws2%, "getaddrinfo" TO `getaddrinfo` + + DIM WSAdata{wVersion{l&,h&}, wHighVersion{l&,h&}, \ + \ szDescription&(WSADESCRIPTION_LEN), szSystemStatus&(WSASYS_STATUS_LEN), \ + \ iMaxSockets{l&,h&}, iMaxUdpDg{l&,h&}, lpVendorInfo%} + + DIM addrinfo{ai_flags%, ai_family%, ai_socktype%, ai_protocol%, \ + \ ai_addrlen%, lp_ai_canonname%, lp_ai_addr%, lp_ai_next%} + DIM ipv4info{} = addrinfo{}, ipv6info{} = addrinfo{} + + DIM sockaddr_in{sin_family{l&,h&}, sin_port{l&,h&}, sin_addr&(3), sin_zero&(7)} + DIM sockaddr_in6{sin6_family{l&,h&}, sin6_port{l&,h&}, sin6_flowinfo%, \ + \ sin6_addr&(15), sin6_scope_id%} + + SYS `WSAStartup`, &202, WSAdata{} TO res% + IF res% ERROR 102, "WSAStartup failed" + + addrinfo.ai_family% = AF_INET + SYS `getaddrinfo`, name$, 0, addrinfo{}, ^ipv4info{}+4 TO res% + IF res% ERROR 103, "getaddrinfo failed" + + !(^sockaddr_in{}+4) = ipv4info.lp_ai_addr% + PRINT "IPv4 address = " ; + PRINT ;sockaddr_in.sin_addr&(0) "." sockaddr_in.sin_addr&(1) "." ; + PRINT ;sockaddr_in.sin_addr&(2) "." sockaddr_in.sin_addr&(3) + + addrinfo.ai_family% = AF_INET6 + SYS `getaddrinfo`, name$, 0, addrinfo{}, ^ipv6info{}+4 TO res% + IF res% ERROR 104, "getaddrinfo failed" + + !(^sockaddr_in6{}+4) = ipv6info.lp_ai_addr% + PRINT "IPv6 address = " ; + PRINT ;~sockaddr_in6.sin6_addr&(0) * 256 + sockaddr_in6.sin6_addr&(1) ":" ; + PRINT ;~sockaddr_in6.sin6_addr&(2) * 256 + sockaddr_in6.sin6_addr&(3) ":" ; + PRINT ;~sockaddr_in6.sin6_addr&(4) * 256 + sockaddr_in6.sin6_addr&(5) ":" ; + PRINT ;~sockaddr_in6.sin6_addr&(6) * 256 + sockaddr_in6.sin6_addr&(7) ":" ; + PRINT ;~sockaddr_in6.sin6_addr&(8) * 256 + sockaddr_in6.sin6_addr&(9) ":" ; + PRINT ;~sockaddr_in6.sin6_addr&(10) * 256 + sockaddr_in6.sin6_addr&(11) ":" ; + PRINT ;~sockaddr_in6.sin6_addr&(12) * 256 + sockaddr_in6.sin6_addr&(13) ":" ; + PRINT ;~sockaddr_in6.sin6_addr&(14) * 256 + sockaddr_in6.sin6_addr&(15) + + SYS `WSACleanup` diff --git a/Task/DNS-query/BBC-BASIC/dns-query-2.bbc b/Task/DNS-query/BBC-BASIC/dns-query-2.bbc new file mode 100644 index 0000000000..492909278d --- /dev/null +++ b/Task/DNS-query/BBC-BASIC/dns-query-2.bbc @@ -0,0 +1,58 @@ +#include +#include +#include /* getaddrinfo, getnameinfo */ +#include /* fprintf, printf */ +#include /* exit */ +#include /* memset */ + +int +main() +{ + struct addrinfo hints, *res, *res0; + int error; + char host[NI_MAXHOST]; + + /* + * Request only one socket type from getaddrinfo(). Else we + * would get both SOCK_DGRAM and SOCK_STREAM, and print two + * copies of each numeric address. + */ + memset(&hints, 0, sizeof hints); + hints.ai_family = PF_UNSPEC; /* IPv4, IPv6, or anything */ + hints.ai_socktype = SOCK_DGRAM; /* Dummy socket type */ + + /* + * Use getaddrinfo() to resolve "www.kame.net" and allocate + * a linked list of addresses. + */ + error = getaddrinfo("www.kame.net", NULL, &hints, &res0); + if (error) { + fprintf(stderr, "%s\n", gai_strerror(error)); + exit(1); + } + + /* Iterate the linked list. */ + for (res = res0; res; res = res->ai_next) { + /* + * Use getnameinfo() to convert res->ai_addr to a + * printable string. + * + * NI_NUMERICHOST means to present the numeric address + * without doing reverse DNS to get a domain name. + */ + error = getnameinfo(res->ai_addr, res->ai_addrlen, + host, sizeof host, NULL, 0, NI_NUMERICHOST); + + if (error) { + fprintf(stderr, "%s\n", gai_strerror(error)); + } else { + /* Print the numeric address. */ + printf("%s\n", host); + } + } + + /* Free the linked list. */ + freeaddrinfo(res0); + + return 0; +} diff --git a/Task/DNS-query/C-sharp/dns-query.cs b/Task/DNS-query/C-sharp/dns-query.cs new file mode 100644 index 0000000000..b62e8a8c9c --- /dev/null +++ b/Task/DNS-query/C-sharp/dns-query.cs @@ -0,0 +1,18 @@ + private string LookupDns(string s) + { + try + { + System.Net.IPHostEntry ip = System.Net.Dns.GetHostEntry(s); + + string result = ip.AddressList[0].ToString(); + + for (int i = 1; i < ip.AddressList.Length; ++i) + result += ", " + ip.AddressList[i].ToString(); + + return result; + } + catch (System.Net.Sockets.SocketException se) + { + return se.Message; + } + } diff --git a/Task/DNS-query/Cache-ObjectScript/dns-query.cos b/Task/DNS-query/Cache-ObjectScript/dns-query.cos new file mode 100644 index 0000000000..6afc744e83 --- /dev/null +++ b/Task/DNS-query/Cache-ObjectScript/dns-query.cos @@ -0,0 +1,57 @@ +Class Utils.Net [ Abstract ] +{ + +ClassMethod QueryDNS(pHost As %String, Output ip As %List) As %Status +{ + // some initialisation + Set ip=$ListBuild() + + // check input and host operating system + If $Match(pHost, "^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$")=0 { + Quit $$$ERROR($$$GeneralError, "Invalid host name.") + } + Set os=$Case($ZVersion(1), 1: "vms", 2: "win", 3: "*nx", : "") + If (os="vms")||(os="") Quit $$$ERROR($$$GeneralError, "Not implemented.") + If os="win" Set cmd="nslookup "_pHost + If os="*nx" Set cmd="host "_pHost + + // enable end-of-file flagging + Do $System.Process.SetZEOF(1) + + // invoke command + Open cmd:"QR":15 + If $Test { + For i=1:1 { + If i>100 Quit + Use cmd Read row + If $ZEOF Quit + If os="win" Set os=$Select(row["Name:": "", 1: os) Continue + Set ipv4=..GetIPAddr("ipv4", row) + If $Length(ipv4) Set $List(ip, 4)=ipv4 + Set ipv6=..GetIPAddr("ipv6", row) + If $Length(ipv6) Set $List(ip, 6)=ipv6 + } + Close cmd + } + + // disable end-of-file flagging + Do $System.Process.SetZEOF(0) + + // finished + If $ListData(ip, 4)=0, $ListData(ip, 6)=0 Quit $$$ERROR($$$GeneralError, "Lookup failed.") + Quit $$$OK +} + +ClassMethod GetIPAddr(pType As %String = "", pRow As %String = "") As %String +{ + If pType="ipv4" { + Set pos=$Locate(pRow, "((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.|$)){4}") + If pos Quit $Piece($Extract(pRow, pos, *), " ") + } ElseIf pType="ipv6" { + Set pos=$Locate(pRow, "([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})") + If pos Quit $Piece($Extract(pRow, pos, *), " ") + } + Quit "" +} + +} diff --git a/Task/DNS-query/Clojure/dns-query.clj b/Task/DNS-query/Clojure/dns-query.clj new file mode 100644 index 0000000000..0761fb5d29 --- /dev/null +++ b/Task/DNS-query/Clojure/dns-query.clj @@ -0,0 +1,6 @@ +(import java.net.InetAddress java.net.Inet4Address java.net.Inet6Address) + +(doseq [addr (InetAddress/getAllByName "www.kame.net")] + (cond + (instance? Inet4Address addr) (println "IPv4:" (.getHostAddress addr)) + (instance? Inet6Address addr) (println "IPv6:" (.getHostAddress addr)))) diff --git a/Task/DNS-query/CoffeeScript/dns-query.coffee b/Task/DNS-query/CoffeeScript/dns-query.coffee new file mode 100644 index 0000000000..fc6f0f6ee6 --- /dev/null +++ b/Task/DNS-query/CoffeeScript/dns-query.coffee @@ -0,0 +1,10 @@ +# runs under node.js +dns = require 'dns' + +dns.resolve4 'www.kame.net', (err, addresses) -> + console.log 'IP4' + console.log addresses + +dns.resolve6 'www.kame.net', (err, addresses) -> + console.log 'IP6' + console.log addresses diff --git a/Task/DNS-query/Common-Lisp/dns-query-1.lisp b/Task/DNS-query/Common-Lisp/dns-query-1.lisp new file mode 100644 index 0000000000..df32629edb --- /dev/null +++ b/Task/DNS-query/Common-Lisp/dns-query-1.lisp @@ -0,0 +1,3 @@ +(sb-bsd-sockets:host-ent-addresses + (sb-bsd-sockets:get-host-by-name "www.rosettacode.org")) +(#(71 19 147 227)) diff --git a/Task/DNS-query/Common-Lisp/dns-query-2.lisp b/Task/DNS-query/Common-Lisp/dns-query-2.lisp new file mode 100644 index 0000000000..19a736edcd --- /dev/null +++ b/Task/DNS-query/Common-Lisp/dns-query-2.lisp @@ -0,0 +1,3 @@ +(let ((hostname (extensions:lookup-host-entry "www.rosettacode.org"))) + (print (map 'list #'extensions:ip-string (host-entry-addr-list hostname)))) +("71.19.147.227") diff --git a/Task/DNS-query/Common-Lisp/dns-query-3.lisp b/Task/DNS-query/Common-Lisp/dns-query-3.lisp new file mode 100644 index 0000000000..37b68e4f35 --- /dev/null +++ b/Task/DNS-query/Common-Lisp/dns-query-3.lisp @@ -0,0 +1,7 @@ +(iolib:lookup-hostname "www.kame.net" :ipv6 t) + +#/IOLIB.SOCKETS:IP/203.178.141.194 +(#/IOLIB.SOCKETS:IP/2001:200:dff:fff1:216:3eff:feb1:44d7) +"orange.kame.net" +(("orange.kame.net" . #/IOLIB.SOCKETS:IP/203.178.141.194) + ("orange.kame.net" . #/IOLIB.SOCKETS:IP/2001:200:dff:fff1:216:3eff:feb1:44d7)) diff --git a/Task/DNS-query/D/dns-query.d b/Task/DNS-query/D/dns-query.d new file mode 100644 index 0000000000..fc7fe24675 --- /dev/null +++ b/Task/DNS-query/D/dns-query.d @@ -0,0 +1,11 @@ +import std.stdio, std.socket; + +void main() { + auto domain = "www.kame.net", port = "80"; + + auto a = getAddressInfo(domain, port); + writefln("IPv4 address for %s: %s", domain, a[0].address); + + a = getAddressInfo(domain, port, AddressFamily.INET6); + writefln("IPv6 address for %s: %s", domain, a[0].address); +} diff --git a/Task/DNS-query/Delphi/dns-query.delphi b/Task/DNS-query/Delphi/dns-query.delphi new file mode 100644 index 0000000000..6e21129cb1 --- /dev/null +++ b/Task/DNS-query/Delphi/dns-query.delphi @@ -0,0 +1,21 @@ +program DNSQuerying; + +{$APPTYPE CONSOLE} + +uses + IdGlobal, IdStackWindows; + +const + DOMAIN_NAME = 'www.kame.net'; +var + lStack: TIdStackWindows; +begin + lStack := TIdStackWindows.Create; + try + Writeln(DOMAIN_NAME); + Writeln('IPv4: ' + lStack.ResolveHost(DOMAIN_NAME)); + Writeln('IPv6: ' + lStack.ResolveHost(DOMAIN_NAME, Id_IPv6)); + finally + lStack.Free; + end; +end. diff --git a/Task/DNS-query/Go/dns-query-1.go b/Task/DNS-query/Go/dns-query-1.go new file mode 100644 index 0000000000..388858346b --- /dev/null +++ b/Task/DNS-query/Go/dns-query-1.go @@ -0,0 +1,14 @@ +package main + +import ( + "fmt" + "net" +) + +func main() { + if addrs, err := net.LookupHost("www.kame.net"); err == nil { + fmt.Println(addrs) + } else { + fmt.Println(err) + } +} diff --git a/Task/DNS-query/Go/dns-query-2.go b/Task/DNS-query/Go/dns-query-2.go new file mode 100644 index 0000000000..64baaaa7e7 --- /dev/null +++ b/Task/DNS-query/Go/dns-query-2.go @@ -0,0 +1,16 @@ +module Main where + +import Network.Socket + +getWebAddresses :: HostName -> IO [SockAddr] +getWebAddresses host = do + results <- getAddrInfo (Just defaultHints) (Just host) (Just "http") + return [ addrAddress a | a <- results, addrSocketType a == Stream ] + +showIPs :: HostName -> IO () +showIPs host = do + putStrLn $ "IP addresses for " ++ host ++ ":" + addresses <- getWebAddresses host + mapM_ (putStrLn . (" "++) . show) addresses + +main = showIPs "www.kame.net" diff --git a/Task/DNS-query/Go/dns-query-3.go b/Task/DNS-query/Go/dns-query-3.go new file mode 100644 index 0000000000..78757db877 --- /dev/null +++ b/Task/DNS-query/Go/dns-query-3.go @@ -0,0 +1,21 @@ +import java.net.InetAddress; +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.UnknownHostException; + +class DnsQuery { + public static void main(String[] args) { + try { + InetAddress[] ipAddr = InetAddress.getAllByName("www.kame.net"); + for(int i=0; i < ipAddr.length ; i++) { + if (ipAddr[i] instanceof Inet4Address) { + System.out.println("IPv4 : " + ipAddr[i].getHostAddress()); + } else if (ipAddr[i] instanceof Inet6Address) { + System.out.println("IPv6 : " + ipAddr[i].getHostAddress()); + } + } + } catch (UnknownHostException uhe) { + System.err.println("unknown host"); + } + } +} diff --git a/Task/DNS-query/Go/dns-query-4.go b/Task/DNS-query/Go/dns-query-4.go new file mode 100644 index 0000000000..73fb82ed12 --- /dev/null +++ b/Task/DNS-query/Go/dns-query-4.go @@ -0,0 +1,13 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +ir = InetAddress +addresses = InetAddress[] InetAddress.getAllByName('www.kame.net') +loop ir over addresses + if ir <= Inet4Address then do + say 'IPv4 :' ir.getHostAddress + end + if ir <= Inet6Address then do + say 'IPv6 :' ir.getHostAddress + end + end ir diff --git a/Task/DNS-query/PHP/dns-query.php b/Task/DNS-query/PHP/dns-query.php new file mode 100644 index 0000000000..1320f18476 --- /dev/null +++ b/Task/DNS-query/PHP/dns-query.php @@ -0,0 +1,6 @@ + diff --git a/Task/DNS-query/Perl/dns-query.pl b/Task/DNS-query/Perl/dns-query.pl new file mode 100644 index 0000000000..b80c98e979 --- /dev/null +++ b/Task/DNS-query/Perl/dns-query.pl @@ -0,0 +1,8 @@ +require 5.014; # Older versions can't resolve IPv6 with just core Socket module + +use Socket qw(getaddrinfo getnameinfo); +my ($err, @res) = getaddrinfo("www.kame.net", 0, + { protocol=>Socket::IPPROTO_TCP } ); +die "getaddrinfo error: $err" if $err; + +print getnameinfo($_->{addr}, Socket::NI_NUMERICHOST), "\n" for @res diff --git a/Task/DNS-query/PicoLisp/dns-query-1.l b/Task/DNS-query/PicoLisp/dns-query-1.l new file mode 100644 index 0000000000..59084d4254 --- /dev/null +++ b/Task/DNS-query/PicoLisp/dns-query-1.l @@ -0,0 +1,4 @@ +(make + (in '(host "www.kame.net") + (while (from "address ") + (link (till "^J" T)) ) ) ) diff --git a/Task/DNS-query/PicoLisp/dns-query-2.l b/Task/DNS-query/PicoLisp/dns-query-2.l new file mode 100644 index 0000000000..90c5c27a9f --- /dev/null +++ b/Task/DNS-query/PicoLisp/dns-query-2.l @@ -0,0 +1,6 @@ +>>> import socket +>>> ips = set(i[4][0] for i in socket.getaddrinfo('www.kame.net', 80)) +>>> for ip in ips: print ip +... +2001:200:dff:fff1:216:3eff:feb1:44d7 +203.178.141.194 diff --git a/Task/DNS-query/PicoLisp/dns-query-3.l b/Task/DNS-query/PicoLisp/dns-query-3.l new file mode 100644 index 0000000000..e7d685aa6c --- /dev/null +++ b/Task/DNS-query/PicoLisp/dns-query-3.l @@ -0,0 +1,5 @@ +irb(main):001:0> require 'socket' +=> true +irb(main):002:0> Addrinfo.getaddrinfo("www.kame.net", nil, nil, :DGRAM) \ +irb(main):003:0* .map! { |ai| ai.ip_address } +=> ["203.178.141.194", "2001:200:dff:fff1:216:3eff:feb1:44d7"] diff --git a/Task/DNS-query/Racket/dns-query.rkt b/Task/DNS-query/Racket/dns-query.rkt new file mode 100644 index 0000000000..02c06fe326 --- /dev/null +++ b/Task/DNS-query/Racket/dns-query.rkt @@ -0,0 +1,4 @@ +#lang racket + +(require net/dns) +(dns-get-address "8.8.8.8" "www.kame.net") diff --git a/Task/DNS-query/Scheme/dns-query.ss b/Task/DNS-query/Scheme/dns-query.ss new file mode 100644 index 0000000000..82cccbd45d --- /dev/null +++ b/Task/DNS-query/Scheme/dns-query.ss @@ -0,0 +1,7 @@ +; Query DNS +(define n (car (hostent:addr-list (gethost "www.kame.net")))) + +; Display address as IPv4 and IPv6 +(display (inet-ntoa n))(newline) +(display (inet-ntop AF_INET n))(newline) +(display (inet-ntop AF_INET6 n))(newline) diff --git a/Task/DNS-query/Tcl/dns-query.tcl b/Task/DNS-query/Tcl/dns-query.tcl new file mode 100644 index 0000000000..5d9d86df79 --- /dev/null +++ b/Task/DNS-query/Tcl/dns-query.tcl @@ -0,0 +1,10 @@ +package require udp; # Query by UDP more widely supported, but requires external package +package require dns + +set host "www.kame.net" +set v4 [dns::resolve $host -type A]; # Specifically get IPv4 address +set v6 [dns::resolve $host -type AAAA]; # Specifically get IPv6 address +while {[dns::status $v4] eq "connect" || [dns::status $v6] eq "connect"} { + update; # Let queries complete +} +puts "primary addresses of $host are:\n\tIPv4» [dns::address $v4]\n\tIPv6» [dns::address $v6]" diff --git a/Task/Date-format/0DESCRIPTION b/Task/Date-format/0DESCRIPTION new file mode 100644 index 0000000000..f7caf096b9 --- /dev/null +++ b/Task/Date-format/0DESCRIPTION @@ -0,0 +1 @@ +{{Clarified-review}}Display the current date in the formats of "2007-11-10" and "Sunday, November 10, 2007". diff --git a/Task/Date-format/1META.yaml b/Task/Date-format/1META.yaml new file mode 100644 index 0000000000..88eb5468ca --- /dev/null +++ b/Task/Date-format/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Text processing diff --git a/Task/Date-format/ABAP/date-format.abap b/Task/Date-format/ABAP/date-format.abap new file mode 100644 index 0000000000..039ff501f4 --- /dev/null +++ b/Task/Date-format/ABAP/date-format.abap @@ -0,0 +1,21 @@ +report zdate. +data: lv_month type string, + lv_weekday type string, + lv_date type string, + lv_day type c. + +call function 'DATE_COMPUTE_DAY' + exporting date = sy-datum + importing day = lv_day. +select single ltx from t247 into lv_month + where spras = sy-langu and + mnr = sy-datum+4(2). + +select single langt from t246 into lv_weekday + where sprsl = sy-langu and + wotnr = lv_day. + +concatenate lv_weekday ', ' lv_month ' ' sy-datum+6(2) ', ' sy-datum(4) into lv_date respecting blanks. +write lv_date. +concatenate sy-datum(4) '-' sy-datum+4(2) '-' sy-datum+6(2) into lv_date. +write / lv_date. diff --git a/Task/Date-format/ALGOL-68/date-format.alg b/Task/Date-format/ALGOL-68/date-format.alg new file mode 100644 index 0000000000..e3b6365fde --- /dev/null +++ b/Task/Date-format/ALGOL-68/date-format.alg @@ -0,0 +1,23 @@ +# define the layout of the date/time as provided by the call to local time # +STRUCT ( INT sec, min, hour, mday, mon, year, wday, yday, isdst) tm = (6,5,4,3,2,1,7,~,8); + +FORMAT # some useful format declarations # + ymd repr = $4d,"-"2d,"-"2d$, + month repr = $c("January","February","March","April","May","June","July", + "August","September","October","November","December")$, + week day repr = $c("Sunday","Monday","Tuesday","Wednesday", + "Thursday","Friday","Saturday")$, + dmdy repr = $f(week day repr)", "f(month repr)" "g(-0)", "g(-4)$, + + mon = $c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")$, + wday = $c("Sun","Mon","Tue","Wed","Thu","Fri","Sat")$, + tz = $c("MSK","MSD")$, + unix time repr = $f(wday)" "f(mon)z-d," "dd,":"dd,":"dd," "f(tz)" "dddd$; + +[]INT now = local time; + +printf((ymd repr, now[year OF tm:mday OF tm], $l$)); +printf((dmdy repr, now[wday OF tm], now[mon OF tm], now[mday OF tm], now[year OF tm], $l$)); + +printf((unix time repr, now[wday OF tm], now[mon OF tm], now[mday OF tm], + now[hour OF tm:sec OF tm], now[isdst OF tm]+1, now[year OF tm], $l$)) diff --git a/Task/Date-format/AWK/date-format.awk b/Task/Date-format/AWK/date-format.awk new file mode 100644 index 0000000000..e71ac0f912 --- /dev/null +++ b/Task/Date-format/AWK/date-format.awk @@ -0,0 +1,3 @@ +$ awk 'BEGIN{t=systime();print strftime("%Y-%m-%d",t)"\n"strftime("%A, %B %d, %Y",t)}' +2009-05-15 +Friday, May 15, 2009 diff --git a/Task/Date-format/Ada/date-format.ada b/Task/Date-format/Ada/date-format.ada new file mode 100644 index 0000000000..c7fc5f8aa9 --- /dev/null +++ b/Task/Date-format/Ada/date-format.ada @@ -0,0 +1,44 @@ +with Ada.Calendar; use Ada.Calendar; +with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Date_Format is + function Image (Month : Month_Number) return String is + begin + case Month is + when 1 => return "January"; + when 2 => return "February"; + when 3 => return "March"; + when 4 => return "April"; + when 5 => return "May"; + when 6 => return "June"; + when 7 => return "July"; + when 8 => return "August"; + when 9 => return "September"; + when 10 => return "October"; + when 11 => return "November"; + when 12 => return "December"; + end case; + end Image; + function Image (Day : Day_Name) return String is + begin + case Day is + when Monday => return "Monday"; + when Tuesday => return "Tuesday"; + when Wednesday => return "Wednesday"; + when Thursday => return "Thursday"; + when Friday => return "Friday"; + when Saturday => return "Saturday"; + when Sunday => return "Sunday"; + end case; + end Image; + Today : Time := Clock; +begin + Put_Line (Image (Today) (1..10)); + Put_Line + ( Image (Day_Of_Week (Today)) & ", " + & Image (Ada.Calendar.Month (Today)) + & Day_Number'Image (Ada.Calendar.Day (Today)) & "," + & Year_Number'Image (Ada.Calendar.Year (Today)) + ); +end Date_Format; diff --git a/Task/Date-format/AutoHotkey/date-format.ahk b/Task/Date-format/AutoHotkey/date-format.ahk new file mode 100644 index 0000000000..0ff5c192a8 --- /dev/null +++ b/Task/Date-format/AutoHotkey/date-format.ahk @@ -0,0 +1,3 @@ +FormatTime, Date1, , yyyy-MM-dd ; "2007-11-10" +FormatTime, Date2, , LongDate ; "Sunday, November 10, 2007" +MsgBox %Date1% `n %Date2% diff --git a/Task/Date-format/BASIC/date-format.bas b/Task/Date-format/BASIC/date-format.bas new file mode 100644 index 0000000000..b1820a396f --- /dev/null +++ b/Task/Date-format/BASIC/date-format.bas @@ -0,0 +1,6 @@ +#include "vbcompat.bi" + +DIM today As Double = Now() + +PRINT Format(today, "yyyy-mm-dd") +PRINT Format(today, "dddd, mmmm d, yyyy") diff --git a/Task/Date-format/BBC-BASIC/date-format.bbc b/Task/Date-format/BBC-BASIC/date-format.bbc new file mode 100644 index 0000000000..d179318cbc --- /dev/null +++ b/Task/Date-format/BBC-BASIC/date-format.bbc @@ -0,0 +1,18 @@ + daysow$ = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday" + months$ = "January February March April May June " + \ + \ "July August September October November December" + + date$ = TIME$ + dayow% = (INSTR(daysow$, MID$(date$,1,3)) + 9) DIV 10 + month% = (INSTR(months$, MID$(date$,8,3)) + 9) DIV 10 + + PRINT MID$(date$,12,4) "-" RIGHT$("0"+STR$month%,2) + "-" + MID$(date$,5,2) + + PRINT FNrtrim(MID$(daysow$, dayow%*10-9, 10)) ", " ; + PRINT FNrtrim(MID$(months$, month%*10-9, 10)) " " ; + PRINT MID$(date$,5,2) ", " MID$(date$,12,4) + END + + DEF FNrtrim(A$) + WHILE RIGHT$(A$) = " " A$ = LEFT$(A$) : ENDWHILE + = A$ diff --git a/Task/Date-format/C++/date-format.cpp b/Task/Date-format/C++/date-format.cpp new file mode 100644 index 0000000000..8c622c4ef3 --- /dev/null +++ b/Task/Date-format/C++/date-format.cpp @@ -0,0 +1,64 @@ +// Display the current date in the formats of "2007-11-10" +// and "Sunday, November 10, 2007". + +#include +#include +#include +#include + +/** Return the current date in a string, formatted as either ISO-8601 + * or "Weekday-name, Month-name Day, Year". + * + * The date is initialized when the object is created and will return + * the same date for the lifetime of the object. The date returned + * is the date in the local timezone. + */ +class Date +{ + struct tm ltime; + +public: + /// Default constructor. + Date() + { + time_t t = time(0); + localtime_r(&t, <ime); + } + + /** Return the date based on a format string. The format string is + * fed directly into strftime(). See the strftime() documentation + * for information on the proper construction of format strings. + * + * @param[in] fmt is a valid strftime() format string. + * + * @return a string containing the formatted date, or a blank string + * if the format string was invalid or resulted in a string that + * exceeded the internal buffer length. + */ + std::string getDate(const char* fmt) + { + char out[200]; + size_t result = strftime(out, sizeof out, fmt, <ime); + return std::string(out, out + result); + } + + /** Return the date in ISO-8601 date format. + * + * @return a string containing the date in ISO-8601 date format. + */ + std::string getISODate() {return getDate("%F");} + + /** Return the date formatted as "Weekday-name, Month-name Day, Year". + * + * @return a string containing the date in the specified format. + */ + std::string getTextDate() {return getDate("%A, %B %d, %Y");} +}; + +int main() +{ + Date d; + std::cout << d.getISODate() << std::endl; + std::cout << d.getTextDate() << std::endl; + return 0; +} diff --git a/Task/Date-format/C/date-format.c b/Task/Date-format/C/date-format.c new file mode 100644 index 0000000000..b04b4499a6 --- /dev/null +++ b/Task/Date-format/C/date-format.c @@ -0,0 +1,23 @@ +#include +#include +#include +#define MAX_BUF 50 + +int main(void) +{ + char buf[MAX_BUF]; + time_t seconds = time(NULL); + struct tm *now = localtime(&seconds); + const char *months[] = {"January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December"}; + + const char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday"}; + + (void) printf("%d-%d-%d\n", now->tm_year + 1900, now->tm_mon + 1, now->tm_mday); + (void) printf("%s, %s %d, %d\n",days[now->tm_wday], months[now->tm_mon], + now->tm_mday, now->tm_year + 1900); + /* using the strftime (the result depends on the locale) */ + (void) strftime(buf, MAX_BUF, "%A, %B %e, %Y", now); + (void) printf("%s\n", buf); + return EXIT_SUCCESS; +} diff --git a/Task/Date-format/Clojure/date-format.clj b/Task/Date-format/Clojure/date-format.clj new file mode 100644 index 0000000000..e285d15c24 --- /dev/null +++ b/Task/Date-format/Clojure/date-format.clj @@ -0,0 +1,5 @@ +(let [now (.getTime (java.util.Calendar/getInstance)) + f1 (java.text.SimpleDateFormat. "yyyy-MM-dd") + f2 (java.text.SimpleDateFormat. "EEEE, MMMM dd, yyyy")] + (println (.format f1 now)) + (println (.format f2 now))) diff --git a/Task/Date-format/CoffeeScript/date-format-1.coffee b/Task/Date-format/CoffeeScript/date-format-1.coffee new file mode 100644 index 0000000000..b660f6fc13 --- /dev/null +++ b/Task/Date-format/CoffeeScript/date-format-1.coffee @@ -0,0 +1,26 @@ +# JS does not have extensive formatting support out of the box. This code shows +# how you could create a date formatter object. +DateFormatter = -> + weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] + months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] + pad = (n) -> + if n < 10 + "0" + n + else + n + + brief: (date) -> + month = 1 + date.getMonth() + "#{date.getFullYear()}-#{pad month}-#{pad date.getDate()}" + + verbose: (date) -> + weekday = weekdays[date.getDay()] + month = months[date.getMonth()] + day = date.getDate() + year = date.getFullYear(); + "#{weekday}, #{month} #{day}, #{year}" + +formatter = DateFormatter() +date = new Date() +console.log formatter.brief(date) +console.log formatter.verbose(date) diff --git a/Task/Date-format/CoffeeScript/date-format-2.coffee b/Task/Date-format/CoffeeScript/date-format-2.coffee new file mode 100644 index 0000000000..f8514694b2 --- /dev/null +++ b/Task/Date-format/CoffeeScript/date-format-2.coffee @@ -0,0 +1,3 @@ +> coffee date_format.coffee +2012-01-14 +Saturday, January 14, 2012 diff --git a/Task/Date-format/ColdFusion/date-format.cfm b/Task/Date-format/ColdFusion/date-format.cfm new file mode 100644 index 0000000000..9e2e190f98 --- /dev/null +++ b/Task/Date-format/ColdFusion/date-format.cfm @@ -0,0 +1,4 @@ + + #dateFormat(Now(), "YYYY-MM-DD")#
+ #dateFormat(Now(), "DDDD, MMMM DD, YYYY")# +
diff --git a/Task/Date-format/Common-Lisp/date-format.lisp b/Task/Date-format/Common-Lisp/date-format.lisp new file mode 100644 index 0000000000..1bfae2e0da --- /dev/null +++ b/Task/Date-format/Common-Lisp/date-format.lisp @@ -0,0 +1,10 @@ +(defconstant *day-names* + #("Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday")) +(defconstant *month-names* + #(nil "January" "February" "March" "April" "May" "June" "July" + "August" "September" "October" "November" "December")) + +(multiple-value-bind (sec min hour date month year day daylight-p zone) (get-decoded-time) + (format t "~4d-~2,'0d-~2,'0d~%" year month date) + (format t "~a, ~a ~d, ~4d~%" + (aref *day-names* day) (aref *month-names* month) date year)) diff --git a/Task/Date-format/D/date-format.d b/Task/Date-format/D/date-format.d new file mode 100644 index 0000000000..d34c0f47fc --- /dev/null +++ b/Task/Date-format/D/date-format.d @@ -0,0 +1,17 @@ +module datetimedemo ; + +import tango.time.Time ; +import tango.text.locale.Locale ; +import tango.time.chrono.Gregorian ; + +import tango.io.Stdout ; + +void main() { + Gregorian g = new Gregorian ; + Stdout.layout = new Locale; // enable Stdout to handle date/time format + Time d = g.toTime(2007, 11, 10, 0, 0, 0, 0, g.AD_ERA) ; + Stdout.format("{:yyy-MM-dd}", d).newline ; + Stdout.format("{:dddd, MMMM d, yyy}", d).newline ; + d = g.toTime(2008, 2, 1, 0, 0, 0, 0, g.AD_ERA) ; + Stdout.format("{:dddd, MMMM d, yyy}", d).newline ; +} diff --git a/Task/Date-format/Delphi/date-format.delphi b/Task/Date-format/Delphi/date-format.delphi new file mode 100644 index 0000000000..53ebd76976 --- /dev/null +++ b/Task/Date-format/Delphi/date-format.delphi @@ -0,0 +1 @@ +ShowMessage(FormatDateTime('yyyy-mm-dd', Now) +#13#10+ FormatDateTime('dddd, mmmm dd, yyyy', Now)); diff --git a/Task/Date-format/EGL/date-format.egl b/Task/Date-format/EGL/date-format.egl new file mode 100644 index 0000000000..cc0f987fcf --- /dev/null +++ b/Task/Date-format/EGL/date-format.egl @@ -0,0 +1,5 @@ +// 2012-09-26 +SysLib.writeStdout(StrLib.formatDate(DateTimeLib.currentDate(), "yyyy-MM-dd")); +// Wednesday, September 26, 2012 +SysLib.setLocale("en", "US"); +SysLib.writeStdout(StrLib.formatDate(DateTimeLib.currentDate(), "EEEE, MMMM dd, yyyy")); diff --git a/Task/Date-format/Erlang/date-format.erl b/Task/Date-format/Erlang/date-format.erl new file mode 100644 index 0000000000..0b5a046726 --- /dev/null +++ b/Task/Date-format/Erlang/date-format.erl @@ -0,0 +1,24 @@ +-module(format_date). +-export([iso_date/0, iso_date/1, iso_date/3, long_date/0, long_date/1, long_date/3]). +-import(calendar,[day_of_the_week/1]). +-import(io,[format/2]). +-import(lists,[append/1]). + +iso_date() -> iso_date(date()). +iso_date(Year, Month, Day) -> iso_date({Year, Month, Day}). +iso_date(Date) -> + format("~4B-~2..0B-~2..0B~n", tuple_to_list(Date)). + +long_date() -> long_date(date()). +long_date(Year, Month, Day) -> long_date({Year, Month, Day}). +long_date(Date = {Year, Month, Day}) -> + Months = { "January", "February", "March", "April", + "May", "June", "July", "August", + "September", "October", "November", "December" }, + Weekdays = { "Monday", "Tuesday", "Wednesday", "Thursday", + "Friday", "Saturday", "Sunday" }, + Weekday = day_of_the_week(Date), + WeekdayName = element(Weekday, Weekdays), + MonthName = element(Month, Months), + append([WeekdayName, ", ", MonthName, " ", integer_to_list(Day), ", ", + integer_to_list(Year)]). diff --git a/Task/Date-format/Euphoria/date-format.euphoria b/Task/Date-format/Euphoria/date-format.euphoria new file mode 100644 index 0000000000..9c1c8fb8d7 --- /dev/null +++ b/Task/Date-format/Euphoria/date-format.euphoria @@ -0,0 +1,11 @@ +constant days = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"} +constant months = {"January","February","March","April","May","June", + "July","August","September","October","November","December"} + +sequence now + +now = date() +now[1] += 1900 + +printf(1,"%d-%02d-%02d\n",now[1..3]) +printf(1,"%s, %s %d, %d\n",{days[now[7]],months[now[2]],now[3],now[1]}) diff --git a/Task/Date-format/Forth/date-format.fth b/Task/Date-format/Forth/date-format.fth new file mode 100644 index 0000000000..1d482c7d42 --- /dev/null +++ b/Task/Date-format/Forth/date-format.fth @@ -0,0 +1,55 @@ +: .-0 ( n -- n ) + [char] - emit + dup 10 < if [char] 0 emit then ; + +: .short-date + time&date ( s m h D M Y ) + 1 u.r .-0 1 u.r .-0 1 u.r + drop drop drop ; + +: str-table + create ( n -- ) 0 do , loop + does> ( n -- str len ) swap cells + @ count ; + + here ," December" + here ," November" + here ," October" + here ," September" + here ," August" + here ," July" + here ," June" + here ," May" + here ," April" + here ," March" + here ," February" + here ," January" +12 str-table months + + here ," Sunday" + here ," Saturday" + here ," Friday" + here ," Thursday" + here ," Wednesday" + here ," Tuesday" + here ," Monday" +7 str-table weekdays + +\ Zeller's Congruence +: zeller ( m -- days since March 1 ) + 9 + 12 mod 1- 26 10 */ 3 + ; + +: weekday ( d m y -- 0..6 ) \ Monday..Sunday + over 3 < if 1- then + dup 4 / + over 100 / - + over 400 / + + + swap zeller + + + 1+ 7 mod ; + +: 3dup dup 2over rot ; + +: .long-date + time&date ( s m h D M Y ) + 3dup weekday weekdays type ." , " + >R 1- months type space 1 u.r ." , " R> . + drop drop drop ; diff --git a/Task/Date-format/Fortran/date-format.f b/Task/Date-format/Fortran/date-format.f new file mode 100644 index 0000000000..2ec1042ce1 --- /dev/null +++ b/Task/Date-format/Fortran/date-format.f @@ -0,0 +1,69 @@ +PROGRAM DATE + + IMPLICIT NONE + + INTEGER :: dateinfo(8), day + CHARACTER(9) :: month, dayname + + CALL DATE_AND_TIME(VALUES=dateinfo) + SELECT CASE(dateinfo(2)) + CASE(1) + month = "January" + CASE(2) + month = "February" + CASE(3) + month = "March" + CASE(4) + month = "April" + CASE(5) + month = "May" + CASE(6) + month = "June" + CASE(7) + month = "July" + CASE(8) + month = "August" + CASE(9) + month = "September" + CASE(10) + month = "October" + CASE(11) + month = "November" + CASE(12) + month = "December" + END SELECT + + day = Day_of_week(dateinfo(3), dateinfo(2), dateinfo(1)) + + SELECT CASE(day) + CASE(0) + dayname = "Saturday" + CASE(1) + dayname = "Sunday" + CASE(2) + dayname = "Monday" + CASE(3) + dayname = "Tuesday" + CASE(4) + dayname = "Wednesday" + CASE(5) + dayname = "Thursday" + CASE(6) + dayname = "Friday" + END SELECT + + WRITE(*,"(I0,A,I0,A,I0)") dateinfo(1),"-", dateinfo(2),"-", dateinfo(3) + WRITE(*,"(4(A),I0,A,I0)") trim(dayname), ", ", trim(month), " ", dateinfo(3), ", ", dateinfo(1) + +CONTAINS + + FUNCTION Day_of_week(d, m, y) + INTEGER :: Day_of_week, j, k + INTEGER, INTENT(IN) :: d, m, y + + j = y / 100 + k = MOD(y, 100) + Day_of_week = MOD(d + (m+1)*26/10 + k + k/4 + j/4 + 5*j, 7) + END FUNCTION Day_of_week + +END PROGRAM DATE diff --git a/Task/Date-format/Go/date-format.go b/Task/Date-format/Go/date-format.go new file mode 100644 index 0000000000..1f7c671796 --- /dev/null +++ b/Task/Date-format/Go/date-format.go @@ -0,0 +1,9 @@ +package main + +import "time" +import "fmt" + +func main() { + fmt.Println(time.Now().Format("2006-01-02")) + fmt.Println(time.Now().Format("Monday, January 2, 2006")) +} diff --git a/Task/Date-format/Haskell/date-format.hs b/Task/Date-format/Haskell/date-format.hs new file mode 100644 index 0000000000..4c4926aee0 --- /dev/null +++ b/Task/Date-format/Haskell/date-format.hs @@ -0,0 +1,13 @@ +import Control.Monad +import Data.Time +import System.Locale + +format1 :: FormatTime t => t -> String +format1 = formatTime defaultTimeLocale "%Y-%m-%e" + +format2 :: FormatTime t => t -> String +format2 = formatTime defaultTimeLocale "%A, %B %d, %Y" + +main = do + t <- liftM2 utcToLocalTime getCurrentTimeZone getCurrentTime + mapM_ putStrLn [format1 t, format2 t] diff --git a/Task/Date-format/Java/date-format.java b/Task/Date-format/Java/date-format.java new file mode 100644 index 0000000000..e75cb42573 --- /dev/null +++ b/Task/Date-format/Java/date-format.java @@ -0,0 +1,29 @@ +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.text.DateFormatSymbols; +import java.util.Date; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +public class Dates +{ + public static void main(final String[] args) + { + Calendar now = new GregorianCalendar(); //months are 0 indexed, dates are 1 indexed + DateFormatSymbols symbols = new DateFormatSymbols(); //names for our months and weekdays + + //plain numbers way + System.out.println(now.get(Calendar.YEAR) + "-" + (now.get(Calendar.MONTH) + 1) + "-" + now.get(Calendar.DATE)); + + //words way + System.out.print(symbols.getWeekdays()[now.get(Calendar.DAY_OF_WEEK)] + ", "); + System.out.print(symbols.getMonths()[now.get(Calendar.MONTH)] + " "); + System.out.println(now.get(Calendar.DATE) + ", " + now.get(Calendar.YEAR)); + + //using DateFormat + Date date = new Date(); + DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd"); + System.out.println(format1.format(date)); + DateFormat format2 = new SimpleDateFormat("EEEE, MMMM dd, yyyy"); + System.out.println(format2.format(date)); + } +} diff --git a/Task/Date-format/JavaScript/date-format.js b/Task/Date-format/JavaScript/date-format.js new file mode 100644 index 0000000000..cc7c9e5e0d --- /dev/null +++ b/Task/Date-format/JavaScript/date-format.js @@ -0,0 +1,8 @@ +var + now = new Date(), + fmt1 = now.getFullYear() + '-' + (1 + now.getMonth()) + '-' + now.getDate(), + weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], + fmt2 = weekdays[now.getDay()] + ', ' + months[now.getMonth()] + ' ' + now.getDate() + ', ' + now.getFullYear(); +print(fmt1); +print(fmt2); diff --git a/Task/Date-format/Lua/date-format.lua b/Task/Date-format/Lua/date-format.lua new file mode 100644 index 0000000000..0c932639a0 --- /dev/null +++ b/Task/Date-format/Lua/date-format.lua @@ -0,0 +1,2 @@ +print( os.date( "%Y-%m-%d" ) ) +print( os.date( "%A, %B %d, %Y" ) ) diff --git a/Task/Date-format/MATLAB/date-format.m b/Task/Date-format/MATLAB/date-format.m new file mode 100644 index 0000000000..4762c6b35a --- /dev/null +++ b/Task/Date-format/MATLAB/date-format.m @@ -0,0 +1,11 @@ +>> datestr(now,'yyyy-mm-dd') + +ans = + +2010-06-18 + +>> datestr(now,'dddd, mmmm dd, yyyy') + +ans = + +Friday, June 18, 2010 diff --git a/Task/Date-format/PHP/date-format.php b/Task/Date-format/PHP/date-format.php new file mode 100644 index 0000000000..b338ea4ce0 --- /dev/null +++ b/Task/Date-format/PHP/date-format.php @@ -0,0 +1,4 @@ + diff --git a/Task/Date-format/Perl/date-format-1.pl b/Task/Date-format/Perl/date-format-1.pl new file mode 100644 index 0000000000..70d3316825 --- /dev/null +++ b/Task/Date-format/Perl/date-format-1.pl @@ -0,0 +1,4 @@ +use POSIX; + +print strftime('%Y-%m-%d', 0, 0, 0, 10, 10, 107), "\n"; +print strftime('%A, %B %d, %Y', 0, 0, 0, 10, 10, 107), "\n"; diff --git a/Task/Date-format/Perl/date-format-2.pl b/Task/Date-format/Perl/date-format-2.pl new file mode 100644 index 0000000000..2945c11ae8 --- /dev/null +++ b/Task/Date-format/Perl/date-format-2.pl @@ -0,0 +1,4 @@ +use POSIX; + +print strftime('%Y-%m-%d', localtime), "\n"; +print strftime('%A, %B %d, %Y', localtime), "\n"; diff --git a/Task/Date-format/PicoLisp/date-format.l b/Task/Date-format/PicoLisp/date-format.l new file mode 100644 index 0000000000..ca1d990105 --- /dev/null +++ b/Task/Date-format/PicoLisp/date-format.l @@ -0,0 +1,10 @@ +(let (Date (date) Lst (date Date)) + (prinl (dat$ Date "-")) # 2010-02-19 + (prinl # Friday, February 19, 2010 + (day Date) + ", " + (get *MonFmt (cadr Lst)) + " " + (caddr Lst) + ", " + (car Lst) ) ) diff --git a/Task/Date-format/Python/date-format.py b/Task/Date-format/Python/date-format.py new file mode 100644 index 0000000000..0212de14ef --- /dev/null +++ b/Task/Date-format/Python/date-format.py @@ -0,0 +1,6 @@ +import datetime +today = datetime.date.today() +# This one is built in: +print today.isoformat() +# Or use a format string for full flexibility: +print today.strftime('%Y-%m-%d') diff --git a/Task/Date-format/R/date-format.r b/Task/Date-format/R/date-format.r new file mode 100644 index 0000000000..f9e696aace --- /dev/null +++ b/Task/Date-format/R/date-format.r @@ -0,0 +1,3 @@ +now <- Sys.time() +strftime(now, "%Y-%m-%d") +strftime(now, "%A, %B %d, %Y") diff --git a/Task/Date-format/REXX/date-format.rexx b/Task/Date-format/REXX/date-format.rexx new file mode 100644 index 0000000000..37ac8b675a --- /dev/null +++ b/Task/Date-format/REXX/date-format.rexx @@ -0,0 +1,11 @@ +/*show current date in yyyy-mm-dd and also Dayofweek, Month dd, yyyy*/ +x=date('s') /* yyyymmdd */ +yyyy=left(x,4) /* pick off the year. */ +dd=right(x,2) /* pick off the day of month */ +say yyyy'-'substr(x,5,2)"-"dd /*yyyy-mm-dd with leading 0s */ + +weekday =date('w') /* Dayofweek (Saturday) */ +month =date('m') /* Month (December) */ +zdd =dd+0 /* remove leading zero of DD */ +say weekday',' month zdd"," yyyy /*Month dd, yyyy */ + /*stick a fork in it, we're done.*/ diff --git a/Task/Date-format/Racket/date-format.rkt b/Task/Date-format/Racket/date-format.rkt new file mode 100644 index 0000000000..3b2627302e --- /dev/null +++ b/Task/Date-format/Racket/date-format.rkt @@ -0,0 +1,13 @@ +#lang racket +(require srfi/19) + +;;; The first required format is an ISO-8601 year-month-day format, predefined +;;; as ~1 in date->string +(displayln (date->string (current-date) "~1")) + +;;; You should be able to see how each of the components of the following format string +;;; work... +;;; ~d is zero padded day of month: +(displayln (date->string (current-date) "~A, ~B ~d, ~Y")) +;;; ~e is space padded day of month: +(displayln (date->string (current-date) "~A, ~B ~e, ~Y")) diff --git a/Task/Date-format/Ruby/date-format.rb b/Task/Date-format/Ruby/date-format.rb new file mode 100644 index 0000000000..292fc1524a --- /dev/null +++ b/Task/Date-format/Ruby/date-format.rb @@ -0,0 +1,3 @@ +puts Time.now +puts Time.now.strftime('%Y-%m-%d') +puts Time.now.strftime('%A, %B %d, %Y') diff --git a/Task/Date-format/Scala/date-format.scala b/Task/Date-format/Scala/date-format.scala new file mode 100644 index 0000000000..bfcf89fe2c --- /dev/null +++ b/Task/Date-format/Scala/date-format.scala @@ -0,0 +1,3 @@ +val now=new Date() +println("%tF".format(now)) +println("%1$tA, %1$tB %1$td, %1$tY".format(now)) diff --git a/Task/Date-format/Tcl/date-format.tcl b/Task/Date-format/Tcl/date-format.tcl new file mode 100644 index 0000000000..27cbdd7125 --- /dev/null +++ b/Task/Date-format/Tcl/date-format.tcl @@ -0,0 +1,3 @@ +set now [clock seconds] +puts [clock format $now -format "%Y-%m-%d"] +puts [clock format $now -format "%A, %B %d, %Y"] diff --git a/Task/Date-manipulation/0DESCRIPTION b/Task/Date-manipulation/0DESCRIPTION new file mode 100644 index 0000000000..cb23a7e51e --- /dev/null +++ b/Task/Date-manipulation/0DESCRIPTION @@ -0,0 +1,3 @@ +Given the date string "March 7 2009 7:30pm EST", output the time 12 hours later in any human-readable format. + +As extra credit, display the resulting time in a time zone different from your own. diff --git a/Task/Date-manipulation/1META.yaml b/Task/Date-manipulation/1META.yaml new file mode 100644 index 0000000000..88eb5468ca --- /dev/null +++ b/Task/Date-manipulation/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Text processing diff --git a/Task/Date-manipulation/Ada/date-manipulation.ada b/Task/Date-manipulation/Ada/date-manipulation.ada new file mode 100644 index 0000000000..d2e3e6ecc3 --- /dev/null +++ b/Task/Date-manipulation/Ada/date-manipulation.ada @@ -0,0 +1,97 @@ +with Ada.Calendar; +with Ada.Calendar.Formatting; +with Ada.Calendar.Time_Zones; +with Ada.Integer_Text_IO; +with Ada.Text_IO; + +procedure Date_Manipulation is + + type Month_Name_T is + (January, February, March, April, May, June, + July, August, September, October, November, December); + + type Time_Zone_Name_T is (EST, Lisbon); + + type Period_T is (AM, PM); + + package TZ renames Ada.Calendar.Time_Zones; + use type TZ.Time_Offset; + + Time_Zone_Offset : array (Time_Zone_Name_T) of TZ.Time_Offset := + (EST => -5 * 60, + Lisbon => 0); + + Period_Offset : array (Period_T) of Natural := + (AM => 0, + PM => 12); + + package Month_Name_IO is + new Ada.Text_IO.Enumeration_IO (Month_Name_T); + + package Time_Zone_Name_IO is + new Ada.Text_IO.Enumeration_IO (Time_Zone_Name_T); + + package Period_IO is + new Ada.Text_IO.Enumeration_IO (Period_T); + + package Std renames Ada.Calendar; + use type Std.Time; + + package Fmt renames Std.Formatting; + + function To_Number (Name : Month_Name_T) return Std.Month_Number is + begin + return Std.Month_Number (Month_Name_T'Pos (Name) + 1); + end; + + function To_Time (S : String) return Std.Time is + Month : Month_Name_T; + Day : Std.Day_Number; + Year : Std.Year_Number; + Hour : Fmt.Hour_Number; + Minute : Fmt.Minute_Number; + Period : Period_T; + Time_Zone : Time_Zone_Name_T; + I : Natural; + begin + Month_Name_IO.Get + (From => S, Item => Month, Last => I); + Ada.Integer_Text_IO.Get + (From => S (I + 1 .. S'Last), Item => Day, Last => I); + Ada.Integer_Text_IO.Get + (From => S (I + 1 .. S'Last), Item => Year, Last => I); + Ada.Integer_Text_IO.Get + (From => S (I + 1 .. S'Last), Item => Hour, Last => I); + Ada.Integer_Text_IO.Get + (From => S (I + 2 .. S'Last), Item => Minute, Last => I); + -- here we start 2 chars down to skip the ':' + Period_IO.Get + (From => S (I + 1 .. S'Last), Item => Period, Last => I); + Time_Zone_Name_IO.Get + (From => S (I + 1 .. S'Last), Item => Time_Zone, Last => I); + return Fmt.Time_Of + (Year => Year, + Month => To_Number (Month), + Day => Day, + Hour => Hour + Period_Offset (Period), + Minute => Minute, + Second => 0, + Time_Zone => Time_Zone_Offset (Time_Zone)); + end; + + function Img + (Date : Std.Time; Zone : Time_Zone_Name_T) return String is + begin + return + Fmt.Image (Date => Date, Time_Zone => Time_Zone_Offset (Zone)) & + " " & Time_Zone_Name_T'Image (Zone); + end; + + T1, T2 : Std.Time; + use Ada.Text_IO; +begin + T1 := To_Time ("March 7 2009 7:30pm EST"); + T2 := T1 + 12.0 * 60.0 * 60.0; + Put_Line ("T1 => " & Img (T1, EST) & " = " & Img (T1, Lisbon)); + Put_Line ("T2 => " & Img (T2, EST) & " = " & Img (T2, Lisbon)); +end; diff --git a/Task/Date-manipulation/AppleScript/date-manipulation-1.applescript b/Task/Date-manipulation/AppleScript/date-manipulation-1.applescript new file mode 100644 index 0000000000..af16904a94 --- /dev/null +++ b/Task/Date-manipulation/AppleScript/date-manipulation-1.applescript @@ -0,0 +1,2 @@ +set x to "March 7 2009 7:30pm EST" +return (date x) + 12 * hours diff --git a/Task/Date-manipulation/AppleScript/date-manipulation-2.applescript b/Task/Date-manipulation/AppleScript/date-manipulation-2.applescript new file mode 100644 index 0000000000..e3046c6d19 --- /dev/null +++ b/Task/Date-manipulation/AppleScript/date-manipulation-2.applescript @@ -0,0 +1 @@ +date "Sunday, March 8, 2009 7:30:00 AM" diff --git a/Task/Date-manipulation/AutoHotkey/date-manipulation.ahk b/Task/Date-manipulation/AutoHotkey/date-manipulation.ahk new file mode 100644 index 0000000000..31dcb4e69c --- /dev/null +++ b/Task/Date-manipulation/AutoHotkey/date-manipulation.ahk @@ -0,0 +1,65 @@ +DateString := "March 7 2009 7:30pm EST" + +; split the given string with RegExMatch +Needle := "^(?P\S*) (?P\S*) (?P\S*) (?P\S*) (?P\S*)$" +RegExMatch(DateString, Needle, $) + +; split the time with RegExMatch +Needle := "^(?P\d+):(?P\d+)(?P[amp]+)$" +RegExMatch($t, Needle, $) + +; convert am/pm to 24h format +$h += ($xm = "am") ? 0 : 12 + +; knitting YYYYMMDDHH24MI format +_YYYY := $y +_MM := Get_MonthNr($mm) +_DD := SubStr("00" $d, -1) ; last 2 chars +_HH24 := SubStr("00" $h, -1) ; last 2 chars +_MI := $min +YYYYMMDDHH24MI := _YYYY _MM _DD _HH24 _MI + +; add 12 hours as requested +EnvAdd, YYYYMMDDHH24MI, 12, Hours +FormatTime, HumanReadable, %YYYYMMDDHH24MI%, d/MMM/yyyy HH:mm + +; add 5 hours to convert to different timezone (GMT) +EnvAdd, YYYYMMDDHH24MI, 5, Hours +FormatTime, HumanReadable_GMT, %YYYYMMDDHH24MI%, d/MMM/yyyy HH:mm + +; output +MsgBox, % "Given: " DateString "`n`n" + . "12 hours later:`n" + . "(" $tz "):`t" HumanReadable "h`n" + . "(GMT):`t" HumanReadable_GMT "h`n" + + +;--------------------------------------------------------------------------- +Get_MonthNr(Month) { ; convert named month to 2-digit number +;--------------------------------------------------------------------------- + If (Month = "January") + Result := "01" + Else If (Month = "February") + Result := "02" + Else If (Month = "March") + Result := "03" + Else If (Month = "April") + Result := "04" + Else If (Month = "May") + Result := "05" + Else If (Month = "June") + Result := "06" + Else If (Month = "July") + Result := "07" + Else If (Month = "August") + Result := "08" + Else If (Month = "September") + Result := "09" + Else If (Month = "October") + Result := "10" + Else If (Month = "November") + Result := "11" + Else If (Month = "December") + Result := "12" + Return, Result +} diff --git a/Task/Date-manipulation/BBC-BASIC/date-manipulation.bbc b/Task/Date-manipulation/BBC-BASIC/date-manipulation.bbc new file mode 100644 index 0000000000..fdf8880753 --- /dev/null +++ b/Task/Date-manipulation/BBC-BASIC/date-manipulation.bbc @@ -0,0 +1,32 @@ + INSTALL @lib$+"DATELIB" + + date$ = "March 7 2009 7:30pm EST" + + mjd% = FN_readdate(date$, "mdy", 0) + colon% = INSTR(date$, ":") + hours% = VAL(MID$(date$, colon%-2)) + IF INSTR(date$, "am") IF hours%=12 hours% -= 12 + IF INSTR(date$, "pm") IF hours%<>12 hours% += 12 + mins% = VAL(MID$(date$, colon%+1)) + + now% = mjd% * 1440 + hours% * 60 + mins% + new% = now% + 12 * 60 : REM 12 hours later + + PRINT FNformat(new%, "EST") + PRINT FNformat(new% + 5 * 60, "GMT") + PRINT FNformat(new% - 3 * 60, "PST") + END + + DEF FNformat(datetime%, zone$) + LOCAL mjd%, hours%, mins%, ampm$ + mjd% = datetime% DIV 1440 + hours% = (datetime% DIV 60) MOD 24 + mins% = datetime% MOD 60 + + IF hours% < 12 THEN ampm$ = "am" ELSE ampm$ = "pm" + IF hours% = 0 hours% += 12 + IF hours% > 12 hours% -= 12 + + = FN_date$(mjd%, "MMMM d yyyy") + " " + STR$(hours%) + \ + \ ":" + RIGHT$("0"+STR$(mins%), 2) + ampm$ + " " + zone$ + ENDPROC diff --git a/Task/Date-manipulation/C++/date-manipulation.cpp b/Task/Date-manipulation/C++/date-manipulation.cpp new file mode 100644 index 0000000000..f9db9c10ad --- /dev/null +++ b/Task/Date-manipulation/C++/date-manipulation.cpp @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +int main( ) { + std::string datestring ("March 7 2009 7:30pm EST" ) ; + //we must first parse the date string into a date , a time and a time + //zone part , to take account of present restrictions in the input facets + //of the Boost::DateTime library used for this example + std::vector elements ; + //parsing the date string + boost::split( elements , datestring , boost::is_any_of( " " ) ) ; + std::string datepart = elements[ 0 ] + " " + "0" + elements[ 1 ] + " " + + elements[ 2 ] ; //we must add 0 to avoid trouble with the boost::date_input format strings + std::string timepart = elements[ 3 ] ; + std::string timezone = elements[ 4 ] ; + const char meridians[ ] = { 'a' , 'p' } ; + //we have to find out if the time is am or pm, to change the hours appropriately + std::string::size_type found = timepart.find_first_of( meridians, 0 ) ; + std::string twelve_hour ( timepart.substr( found , 1 ) ) ; + timepart = timepart.substr( 0 , found ) ; //we chop off am or pm + elements.clear( ) ; + boost::split( elements , timepart , boost::is_any_of ( ":" ) ) ; + long hour = std::atol( (elements.begin( ))->c_str( ) ) ;// hours in the string + if ( twelve_hour == "p" ) //it's post meridian, we're converting to 24-hour-clock + hour += 12 ; + long minute = std::atol( ( elements.begin( ) + 1)->c_str( ) ) ; + boost::local_time::tz_database tz_db ; + tz_db.load_from_file( "/home/ulrich/internetpages/date_time_zonespec.csv" ) ; + //according to the time zone database, this corresponds to one possible EST time zone + boost::local_time::time_zone_ptr dyc = tz_db.time_zone_from_region( "America/New_York" ) ; + //this is the string input format to initialize the date field + boost::gregorian::date_input_facet *f = + new boost::gregorian::date_input_facet( "%B %d %Y" ) ; + std::stringstream ss ; + ss << datepart ; + ss.imbue( std::locale( std::locale::classic( ) , f ) ) ; + boost::gregorian::date d ; + ss >> d ; + boost::posix_time::time_duration td ( hour , minute , 0 ) ; + //that's how we initialize the New York local time , by using date and adding + //time duration with values coming from parsed date input string + boost::local_time::local_date_time lt ( d , td , dyc , + boost::local_time::local_date_time::NOT_DATE_TIME_ON_ERROR ) ; + std::cout << "local time: " << lt << '\n' ; + ss.str( "" ) ; + ss << lt ; + //we have to add 12 hours, so a new time duration object is created + boost::posix_time::time_duration td2 (12 , 0 , 0 , 0 ) ; + boost::local_time::local_date_time ltlater = lt + td2 ; //local time 12 hours later + boost::gregorian::date_facet *f2 = + new boost::gregorian::date_facet( "%B %d %Y , %R %Z" ) ; + std::cout.imbue( std::locale( std::locale::classic( ) , f2 ) ) ; + std::cout << "12 hours after " << ss.str( ) << " it is " << ltlater << " !\n" ; + //what's New York time in the Berlin time zone ? + boost::local_time::time_zone_ptr bt = tz_db.time_zone_from_region( "Europe/Berlin" ) ; + std::cout.imbue( std::locale( "de_DE.UTF-8" ) ) ; //choose the output forman appropriate for the time zone + std::cout << "This corresponds to " << ltlater.local_time_in( bt ) << " in Berlin!\n" ; + return 0 ; +} diff --git a/Task/Date-manipulation/C/date-manipulation.c b/Task/Date-manipulation/C/date-manipulation.c new file mode 100644 index 0000000000..c03e86f314 --- /dev/null +++ b/Task/Date-manipulation/C/date-manipulation.c @@ -0,0 +1,19 @@ +#include +#include +#include + +int main() +{ + struct tm ts; + time_t t; + const char *d = "March 7 2009 7:30pm EST"; + + strptime(d, "%B %d %Y %I:%M%p %Z", &ts); + /* ts.tm_hour += 12; instead of t += 12*60*60 + works too. */ + t = mktime(&ts); + t += 12*60*60; + printf("%s", ctime(&t)); + + return EXIT_SUCCESS; +} diff --git a/Task/Date-manipulation/Clojure/date-manipulation.clj b/Task/Date-manipulation/Clojure/date-manipulation.clj new file mode 100644 index 0000000000..516fc4124c --- /dev/null +++ b/Task/Date-manipulation/Clojure/date-manipulation.clj @@ -0,0 +1,11 @@ +(import java.util.Date + java.text.SimpleDateFormat) + +(defn time+12 [s] + (let [sdf (SimpleDateFormat. "MMMM d yyyy h:mma zzz")] + (-> (.parse sdf s) + (.getTime ,) + (+ , 43200000) + long + (Date. ,) + (->> , (.format sdf ,))))) diff --git a/Task/Date-manipulation/Delphi/date-manipulation.delphi b/Task/Date-manipulation/Delphi/date-manipulation.delphi new file mode 100644 index 0000000000..424f18ca59 --- /dev/null +++ b/Task/Date-manipulation/Delphi/date-manipulation.delphi @@ -0,0 +1,81 @@ +program DateManipulation; + +{$APPTYPE CONSOLE} + +uses + SysUtils, + DateUtils; + +function MonthNumber(aMonth: string): Word; +begin + //Convert a string value representing the month + //to its corresponding numerical value + if aMonth = 'January' then Result:= 1 + else if aMonth = 'February' then Result:= 2 + else if aMonth = 'March' then Result:= 3 + else if aMonth = 'April' then Result:= 4 + else if aMonth = 'May' then Result:= 5 + else if aMonth = 'June' then Result:= 6 + else if aMonth = 'July' then Result:= 7 + else if aMonth = 'August' then Result:= 8 + else if aMonth = 'September' then Result:= 9 + else if aMonth = 'October' then Result:= 10 + else if aMonth = 'November' then Result:= 11 + else if aMonth = 'December' then Result:= 12 + else Result:= 12; +end; + +function ParseString(aDateTime: string): TDateTime; +var + strDay, + strMonth, + strYear, + strTime: string; + iDay, + iMonth, + iYear: Word; + TimePortion: TDateTime; +begin + //Decode the month from the given string + strMonth:= Copy(aDateTime, 1, Pos(' ', aDateTime) - 1); + Delete(aDateTime, 1, Pos(' ', aDateTime)); + iMonth:= MonthNumber(strMonth); + + //Decode the day from the given string + strDay:= Copy(aDateTime, 1, Pos(' ', aDateTime) - 1); + Delete(aDateTime, 1, Pos(' ', aDateTime)); + iDay:= StrToIntDef(strDay, 30); + + //Decode the year from the given string + strYear:= Copy(aDateTime, 1, Pos(' ', aDateTime) -1); + Delete(aDateTime, 1, Pos(' ', aDateTime)); + iYear:= StrToIntDef(strYear, 1899); + + //Decode the time value from the given string + strTime:= Copy(aDateTime, 1, Pos(' ', aDateTime) -1); + + //Encode the date value and assign it to result + Result:= EncodeDate(iYear, iMonth, iDay); + + //Encode the time value and add it to result + if TryStrToTime(strTime, TimePortion) then + Result:= Result + TimePortion; +end; + +function Add12Hours(aDateTime: string): string; +var + tmpDateTime: TDateTime; +begin + //Adding 12 hours to the given + //date time string value + tmpDateTime:= ParseString(aDateTime); + tmpDateTime:= IncHour(tmpDateTime, 12); + + //Formatting the output + Result:= FormatDateTime('mm/dd/yyyy hh:mm AM/PM', tmpDateTime); +end; + +begin + Writeln(Add12Hours('March 7 2009 7:30pm EST')); + Readln; +end. diff --git a/Task/Date-manipulation/Euphoria/date-manipulation.euphoria b/Task/Date-manipulation/Euphoria/date-manipulation.euphoria new file mode 100644 index 0000000000..9a07fcc4c3 --- /dev/null +++ b/Task/Date-manipulation/Euphoria/date-manipulation.euphoria @@ -0,0 +1,10 @@ +--Date Manipulation task from Rosetta Code wiki +--User:Lnettnay + +include std/datetime.e + +datetime dt + +dt = new(2009, 3, 7, 19, 30) +dt = add(dt, 12, HOURS) +printf(1, "%s EST\n", {format(dt, "%B %d %Y %I:%M %p")}) diff --git a/Task/Date-manipulation/Go/date-manipulation.go b/Task/Date-manipulation/Go/date-manipulation.go new file mode 100644 index 0000000000..ea2b0324ac --- /dev/null +++ b/Task/Date-manipulation/Go/date-manipulation.go @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "time" +) + +const taskDate = "March 7 2009 7:30pm EST" +const taskFormat = "January 2 2006 3:04pm MST" + +func main() { + if etz, err := time.LoadLocation("US/Eastern"); err == nil { + time.Local = etz + } + fmt.Println("Input: ", taskDate) + t, err := time.Parse(taskFormat, taskDate) + if err != nil { + fmt.Println(err) + return + } + t = t.Add(12 * time.Hour) + fmt.Println("+12 hrs: ", t) + if _, offset := t.Zone(); offset == 0 { + fmt.Println("No time zone info.") + return + } + atz, err := time.LoadLocation("US/Arizona") + if err == nil { + fmt.Println("+12 hrs in Arizona:", t.In(atz)) + } +} diff --git a/Task/Date-manipulation/Haskell/date-manipulation.hs b/Task/Date-manipulation/Haskell/date-manipulation.hs new file mode 100644 index 0000000000..bbe0aa6f3a --- /dev/null +++ b/Task/Date-manipulation/Haskell/date-manipulation.hs @@ -0,0 +1,9 @@ +import Data.Time.Clock.POSIX +import Data.Time.Format +import System.Locale + +main = print t2 + where t1 = readTime defaultTimeLocale + "%B %e %Y %l:%M%P %Z" + "March 7 2009 7:30pm EST" + t2 = posixSecondsToUTCTime $ 12*60*60 + utcTimeToPOSIXSeconds t1 diff --git a/Task/Date-manipulation/Java/date-manipulation.java b/Task/Date-manipulation/Java/date-manipulation.java new file mode 100644 index 0000000000..04df0214de --- /dev/null +++ b/Task/Date-manipulation/Java/date-manipulation.java @@ -0,0 +1,16 @@ +import java.util.Date; +import java.text.SimpleDateFormat; +public class DateManip{ + public static void main(String[] args) throws Exception{ + String dateStr = "March 7 2009 7:30pm EST"; + + SimpleDateFormat sdf = new SimpleDateFormat("MMMM d yyyy h:mma zzz"); + + Date date = sdf.parse(dateStr); + + date.setTime(date.getTime() + 43200000l); + + System.out.println(sdf.format(date)); + } + +} diff --git a/Task/Date-manipulation/JavaScript/date-manipulation.js b/Task/Date-manipulation/JavaScript/date-manipulation.js new file mode 100644 index 0000000000..c8b63269c5 --- /dev/null +++ b/Task/Date-manipulation/JavaScript/date-manipulation.js @@ -0,0 +1,51 @@ +function add12hours(dateString) { + + // Get the parts of the date string + var parts = dateString.split(/\s+/); + var date = parts[1]; + var month = parts[0]; + var year = parts[2]; + var time = parts[3]; + var ampm = time && time.match(/[a-z]+$/i)[0]; + var hr = Number(time.split(':')[0]); + var min = Number(time.split(':')[1].replace(/\D/g,'')); + var zone = parts[4].toUpperCase(); + var months = ['January','February','March','April','May','June', + 'July','August','September','October','November','December']; + var zones = {'EST': 300, 'AEST': -600}; // Minutes to add to zone time to get UTC + + // Convert month name to number, zero indexed + // Could use indexOf but not supported widely + for (var i=0, iLen=months.length; imodify('+12 hours'); +echo $time->format('c'); +?> diff --git a/Task/Date-manipulation/Perl/date-manipulation.pl b/Task/Date-manipulation/Perl/date-manipulation.pl new file mode 100644 index 0000000000..22c87fbc71 --- /dev/null +++ b/Task/Date-manipulation/Perl/date-manipulation.pl @@ -0,0 +1,11 @@ +use DateTime; +use DateTime::Format::Strptime 'strptime'; +use feature 'say'; + +my $input = 'March 7 2009 7:30pm EST'; +$input =~ s{EST}{America/New_York}; + +say strptime('%b %d %Y %I:%M%p %O', $input) + ->add(hours => 12) + ->set_time_zone('America/Edmonton') + ->format_cldr('MMMM d yyyy h:mma zzz'); diff --git a/Task/Date-manipulation/PicoLisp/date-manipulation.l b/Task/Date-manipulation/PicoLisp/date-manipulation.l new file mode 100644 index 0000000000..8dd337766c --- /dev/null +++ b/Task/Date-manipulation/PicoLisp/date-manipulation.l @@ -0,0 +1,19 @@ +(de timePlus12 (Str) + (use (@Mon @Day @Year @Time @Zone) + (and + (match + '(@Mon " " @Day " " @Year " " @Time " " @Zone) + (chop Str) ) + (setq @Mon (index (pack @Mon) *MonFmt)) + (setq @Day (format @Day)) + (setq @Year (format @Year)) + (setq @Time + (case (tail 2 @Time) + (("a" "m") ($tim (head -2 @Time))) + (("p" "m") (+ `(time 12 0) ($tim (head -2 @Time)))) + (T ($tim @Time)) ) ) + (let? Date (date @Year @Mon @Day) + (when (>= (inc '@Time `(time 12 0)) 86400) + (dec '@Time 86400) + (inc 'Date) ) + (pack (dat$ Date "-") " " (tim$ @Time T) " " @Zone) ) ) ) ) diff --git a/Task/Date-manipulation/Python/date-manipulation.py b/Task/Date-manipulation/Python/date-manipulation.py new file mode 100644 index 0000000000..15252e1f03 --- /dev/null +++ b/Task/Date-manipulation/Python/date-manipulation.py @@ -0,0 +1,12 @@ +import datetime + +def mt(): + datime1="March 7 2009 7:30pm EST" + formatting = "%B %d %Y %I:%M%p " + datime2 = datime1[:-3] # format can't handle "EST" for some reason + tdelta = datetime.timedelta(hours=12) # twelve hours.. + s3 = datetime.datetime.strptime(datime2, formatting) + datime2 = s3+tdelta + print datime2.strftime("%B %d %Y %I:%M%p %Z") + datime1[-3:] + +mt() diff --git a/Task/Date-manipulation/R/date-manipulation.r b/Task/Date-manipulation/R/date-manipulation.r new file mode 100644 index 0000000000..6de0785ad6 --- /dev/null +++ b/Task/Date-manipulation/R/date-manipulation.r @@ -0,0 +1,5 @@ +time <- strptime("March 7 2009 7:30pm EST", "%B %d %Y %I:%M%p %Z") # "2009-03-07 19:30:00" +isotime <- ISOdatetime(1900 + time$year, time$mon, time$mday, + time$hour, time$min, time$sec, "EST") # "2009-02-07 19:30:00 EST" +twelvehourslater <- isotime + 12 * 60 * 60 # "2009-02-08 07:30:00 EST" +timeincentraleurope <- format(isotime, tz="CET", usetz=TRUE) #"2009-02-08 01:30:00 CET" diff --git a/Task/Date-manipulation/REXX/date-manipulation.rexx b/Task/Date-manipulation/REXX/date-manipulation.rexx new file mode 100644 index 0000000000..5786ec1774 --- /dev/null +++ b/Task/Date-manipulation/REXX/date-manipulation.rexx @@ -0,0 +1,13 @@ +/*REXX pgm to add 12 hours to a date & time, showing the before & after.*/ + aDate = 'March 7 2009 7:30pm EST' +parse var aDate mon dd yyyy hhmm tz . /*obtain the various parts&pieces*/ + mins = time('M',hhmm,'C') /*get the # minutes past midnight*/ + mins = mins + (12*60) /*add twelve hours to timestamp. */ + nMins = mins // 1440 /*compute #min into same/next day*/ + days = mins % 1440 /*compute number of days "added".*/ +aBdays = date('B',dd left(mon,3) yyyy) /*# of base days since REXX epoch*/ +nBdays = aBdays + days /*now, add the # of days "added".*/ + nDate = date(,nBdays,'B') /*calculate the new date (maybe).*/ + nTime = time('C',nMins,'M') /* " " " time " */ +say aDate ' + 12 hours ───► ' ndate ntime tz /*display new timestamp.*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Date-manipulation/Ruby/date-manipulation-1.rb b/Task/Date-manipulation/Ruby/date-manipulation-1.rb new file mode 100644 index 0000000000..40a3824908 --- /dev/null +++ b/Task/Date-manipulation/Ruby/date-manipulation-1.rb @@ -0,0 +1,18 @@ +require 'time' +d = "March 7 2009 7:30pm EST" +t = Time.parse(d) +puts t.rfc2822 +puts t.zone + +new = t + 12*3600 +puts new.rfc2822 +puts new.zone + +# another timezone +require 'rubygems' +require 'active_support' +zone = ActiveSupport::TimeZone['Beijing'] +remote = zone.at(new) +# or, remote = new.in_time_zone('Beijing') +puts remote.rfc2822 +puts remote.zone diff --git a/Task/Date-manipulation/Ruby/date-manipulation-2.rb b/Task/Date-manipulation/Ruby/date-manipulation-2.rb new file mode 100644 index 0000000000..865e97a652 --- /dev/null +++ b/Task/Date-manipulation/Ruby/date-manipulation-2.rb @@ -0,0 +1,3 @@ +new = t + 12.hours +new = t.in(12.hours) +new = t.advance(:hours => 12) diff --git a/Task/Date-manipulation/Scala/date-manipulation.scala b/Task/Date-manipulation/Scala/date-manipulation.scala new file mode 100644 index 0000000000..a407033254 --- /dev/null +++ b/Task/Date-manipulation/Scala/date-manipulation.scala @@ -0,0 +1,17 @@ +import java.text.SimpleDateFormat +import java.util.{Calendar, Locale, TimeZone} + +object DateManipulation { + def main(args: Array[String]): Unit = { + val input="March 7 2009 7:30pm EST" + val df=new SimpleDateFormat("MMMM d yyyy h:mma z", Locale.ENGLISH) + val c=Calendar.getInstance() + c.setTime(df.parse(input)) + + c.add(Calendar.HOUR_OF_DAY, 12) + println(df.format(c.getTime)) + + df.setTimeZone(TimeZone.getTimeZone("GMT")) + println(df.format(c.getTime)) + } +} diff --git a/Task/Date-manipulation/Smalltalk/date-manipulation-1.st b/Task/Date-manipulation/Smalltalk/date-manipulation-1.st new file mode 100644 index 0000000000..1f5ec0fe19 --- /dev/null +++ b/Task/Date-manipulation/Smalltalk/date-manipulation-1.st @@ -0,0 +1,50 @@ +DateTime extend [ + setYear: aNum [ year := aNum ] +]. + +Object subclass: DateTimeTZ [ + |dateAndTime timeZoneDST timeZoneName timeZoneVar| + + DateTimeTZ class >> new [ ^(super basicNew) ] + + DateTimeTZ class >> readFromWithMeridian: aStream andTimeZone: aDict [ + |me| + me := self new. + ^ me initWithMeridian: aStream andTimeZone: aDict + ] + + initWithMeridian: aStream andTimeZone: aDict [ |s| + dateAndTime := DateTime readFrom: aStream copy. + s := aStream collection asString. + s =~ '[pP][mM]' + ifMatched: [ :m | + dateAndTime := dateAndTime + (Duration days: 0 hours: 12 minutes: 0 seconds: 0) + ]. + aDict keysAndValuesDo: [ :k :v | + s =~ k + ifMatched: [ :x | + dateAndTime := dateAndTime setOffset: (v at: 1). + timeZoneDST := (v at: 2) setOffset: (v at: 1). + timeZoneVar := (v at: 3). + timeZoneDST setYear: (self year). "ignore the year" + timeZoneName := k + ] + ]. + ^ self + ] + + setYear: aNum [ dateAndTime setYear: aNum ] + year [ ^ dateAndTime year ] + + timeZoneName [ ^timeZoneName ] + + + aDuration [ |n| + n := dateAndTime + aDuration. + (n > timeZoneDST) ifTrue: [ n := n + timeZoneVar ]. + ^ (self copy dateTime: n) + ] + + dateTime [ ^dateAndTime ] + dateTime: aDT [ dateAndTime := aDT ] + +]. diff --git a/Task/Date-manipulation/Smalltalk/date-manipulation-2.st b/Task/Date-manipulation/Smalltalk/date-manipulation-2.st new file mode 100644 index 0000000000..007dbdcbaf --- /dev/null +++ b/Task/Date-manipulation/Smalltalk/date-manipulation-2.st @@ -0,0 +1,29 @@ +|s abbrDict dt| + +s := 'March 7 2009 7:30pm EST'. + +"Build a abbreviation -> offset for timezones (example)" +abbrDict := Dictionary new. + +abbrDict at: 'EST' + put: { (Duration days: 0 hours: -5 minutes: 0 seconds: 0). + (DateTime year: 2009 month: 3 day: 8 hour: 2 minute: 0 second: 0). + (Duration days: 0 hours: 1 minutes: 0 seconds: 0) }. + +dt := DateTimeTZ readFromWithMeridian: (s readStream) andTimeZone: abbrDict. + +dt := dt + (Duration days: 0 hours: 12 minutes: 0 seconds: 0). + +"let's print it" +('%1 %2 %3 %4:%5%6 %7' % +{ + (dt dateTime) monthName asString. + (dt dateTime) day. + (dt dateTime) year. + (dt dateTime) hour12. + (dt dateTime) minute. + (dt dateTime) meridianAbbreviation asString. + dt timeZoneName. +}) displayNl. + +(dt dateTime) asUTC displayNl. diff --git a/Task/Date-manipulation/Tcl/date-manipulation.tcl b/Task/Date-manipulation/Tcl/date-manipulation.tcl new file mode 100644 index 0000000000..b773038c11 --- /dev/null +++ b/Task/Date-manipulation/Tcl/date-manipulation.tcl @@ -0,0 +1,5 @@ +set date "March 7 2009 7:30pm EST" +set epoch [clock scan $date -format "%B %d %Y %I:%M%p %z"] +set later [clock add $epoch 12 hours] +puts [clock format $later] ;# Sun Mar 08 08:30:00 EDT 2009 +puts [clock format $later -timezone :Asia/Shanghai] ;# Sun Mar 08 20:30:00 CST 2009 diff --git a/Task/Day-of-the-week/0DESCRIPTION b/Task/Day-of-the-week/0DESCRIPTION new file mode 100644 index 0000000000..7899d7c2b7 --- /dev/null +++ b/Task/Day-of-the-week/0DESCRIPTION @@ -0,0 +1,5 @@ +A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January). + +'''In what years between 2008 and 2121 will the 25th of December be a Sunday?''' + +Using any standard date handling libraries of your programming language; compare the dates calculated with the output of other languages to discover any anomalies in the handling of dates which may be due to, for example, overflow in types used to represent dates/times similar to [[wp:Y2k#See_also|y2k]] type problems. diff --git a/Task/Day-of-the-week/ABAP/day-of-the-week.abap b/Task/Day-of-the-week/ABAP/day-of-the-week.abap new file mode 100644 index 0000000000..098376a3df --- /dev/null +++ b/Task/Day-of-the-week/ABAP/day-of-the-week.abap @@ -0,0 +1,24 @@ +report zday_of_week +data: lv_start type i value 2007, + lv_n type i value 114, + lv_date type sy-datum, + lv_weekday type string, + lv_day type c, + lv_year type n length 4. + +write 'December 25 is a Sunday in: '. +do lv_n times. + lv_year = lv_start + sy-index. + concatenate lv_year '12' '25' into lv_date. + call function 'DATE_COMPUTE_DAY' + exporting date = lv_date + importing day = lv_day. + + select single langt from t246 into lv_weekday + where sprsl = sy-langu and + wotnr = lv_day. + + if lv_weekday eq 'Sunday'. + write / lv_year. + endif. +enddo. diff --git a/Task/Day-of-the-week/ALGOL-68/day-of-the-week.alg b/Task/Day-of-the-week/ALGOL-68/day-of-the-week.alg new file mode 100644 index 0000000000..58694d1481 --- /dev/null +++ b/Task/Day-of-the-week/ALGOL-68/day-of-the-week.alg @@ -0,0 +1,22 @@ +# example from: http://www.xs4all.nl/~jmvdveer/algol.html - GPL # +INT sun=0 # , mon=1, tue=2, wed=3, thu=4, fri=5, sat=6 #; + +PROC day of week = (INT year, month, day) INT: ( + # Day of the week by Zeller’s Congruence algorithm from 1887 # + INT y := year, m := month, d := day, c; + IF m <= 2 THEN + m +:= 12; y -:= 1 + FI; + c := y OVER 100; + y %*:= 100; + (d - 1 + ((m + 1) * 26) OVER 10 + y + y OVER 4 + c OVER 4 - 2 * c) MOD 7 +); + +test:( + print("December 25th is a Sunday in:"); + FOR year FROM 2008 TO 2121 DO + INT wd = day of week(year, 12, 25); + IF wd = sun THEN print(whole(year,-5)) FI + OD; + new line(stand out) +) diff --git a/Task/Day-of-the-week/AWK/day-of-the-week.awk b/Task/Day-of-the-week/AWK/day-of-the-week.awk new file mode 100644 index 0000000000..1ebc578a80 --- /dev/null +++ b/Task/Day-of-the-week/AWK/day-of-the-week.awk @@ -0,0 +1,8 @@ +# syntax: GAWK -f DAY_OF_THE_WEEK.AWK +# runtime does not support years > 2037 on my 32-bit Windows XP O/S +BEGIN { + for (i=2008; i<=2121; i++) { + x = strftime("%Y/%m/%d %a",mktime(sprintf("%d 12 25 0 0 0",i))) + if (x ~ /Sun/) { print(x) } + } +} diff --git a/Task/Day-of-the-week/Ada/day-of-the-week.ada b/Task/Day-of-the-week/Ada/day-of-the-week.ada new file mode 100644 index 0000000000..5f74a76f08 --- /dev/null +++ b/Task/Day-of-the-week/Ada/day-of-the-week.ada @@ -0,0 +1,11 @@ +with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Yuletide is +begin + for Year in Ada.Calendar.Year_Number loop -- 1901..2399 + if Day_Of_Week (Time_Of (Year, 12, 25)) = Sunday then + Put_Line (Image (Time_Of (Year, 12, 25))); + end if; + end loop; +end Yuletide; diff --git a/Task/Day-of-the-week/AppleScript/day-of-the-week.applescript b/Task/Day-of-the-week/AppleScript/day-of-the-week.applescript new file mode 100644 index 0000000000..4cf6fed9dc --- /dev/null +++ b/Task/Day-of-the-week/AppleScript/day-of-the-week.applescript @@ -0,0 +1,9 @@ +set ChristmasSundays to {} +set Christmas to (current date) +set month of Christmas to December +set day of Christmas to 25 +repeat with year from 2008 to 2121 + set year of Christmas to year + if weekday of Christmas is Sunday then set end of ChristmasSundays to year +end repeat +ChristmasSundays diff --git a/Task/Day-of-the-week/AutoHotkey/day-of-the-week.ahk b/Task/Day-of-the-week/AutoHotkey/day-of-the-week.ahk new file mode 100644 index 0000000000..f2f5e6020c --- /dev/null +++ b/Task/Day-of-the-week/AutoHotkey/day-of-the-week.ahk @@ -0,0 +1,10 @@ +year = 2008 +stop = 2121 + +While year <= stop { + FormatTime, day,% year 1225, dddd + If day = Sunday + out .= year "`n" + year++ +} +MsgBox,% out diff --git a/Task/Day-of-the-week/AutoIt/day-of-the-week.autoit b/Task/Day-of-the-week/AutoIt/day-of-the-week.autoit new file mode 100644 index 0000000000..5e6f5eaf10 --- /dev/null +++ b/Task/Day-of-the-week/AutoIt/day-of-the-week.autoit @@ -0,0 +1,7 @@ +#include +Const $iSunday = 1 +For $iYear = 2008 To 2121 Step 1 + If $iSunday = _DateToDayOfWeek($iYear, 12, 25) Then + ConsoleWrite(StringFormat($iYear & "\n")) + EndIf +Next diff --git a/Task/Day-of-the-week/BBC-BASIC/day-of-the-week.bbc b/Task/Day-of-the-week/BBC-BASIC/day-of-the-week.bbc new file mode 100644 index 0000000000..e6b0d45dff --- /dev/null +++ b/Task/Day-of-the-week/BBC-BASIC/day-of-the-week.bbc @@ -0,0 +1,7 @@ + INSTALL @lib$+"DATELIB" + + FOR year% = 2008 TO 2121 + IF FN_dow(FN_mjd(25, 12, year%)) = 0 THEN + PRINT "Christmas Day is a Sunday in "; year% + ENDIF + NEXT diff --git a/Task/Day-of-the-week/C++/day-of-the-week.cpp b/Task/Day-of-the-week/C++/day-of-the-week.cpp new file mode 100644 index 0000000000..20bdc6f194 --- /dev/null +++ b/Task/Day-of-the-week/C++/day-of-the-week.cpp @@ -0,0 +1,18 @@ +#include +#include + +int main( ) { + using namespace boost::gregorian ; + + std::cout + << "Yuletide holidays must be allowed in the following years:\n" ; + for ( int i = 2008 ; i < 2121 ; i++ ) { + greg_year gy = i ; + date d ( gy, Dec , 25 ) ; + if ( d.day_of_week( ) == Sunday ) { + std::cout << i << std::endl ; + } + } + std::cout << "\n" ; + return 0 ; +} diff --git a/Task/Day-of-the-week/C/day-of-the-week.c b/Task/Day-of-the-week/C/day-of-the-week.c new file mode 100644 index 0000000000..705e087e31 --- /dev/null +++ b/Task/Day-of-the-week/C/day-of-the-week.c @@ -0,0 +1,24 @@ +#include + +/* Calculate day of week in proleptic Gregorian calendar. Sunday == 0. */ +int wday(int year, int month, int day) +{ + int adjustment, mm, yy; + + adjustment = (14 - month) / 12; + mm = month + 12 * adjustment - 2; + yy = year - adjustment; + return (day + (13 * mm - 1) / 5 + + yy + yy / 4 - yy / 100 + yy / 400) % 7; +} + +int main() +{ + int y; + + for (y = 2008; y <= 2121; y++) { + if (wday(y, 12, 25) == 0) printf("%04d-12-25\n", y); + } + + return 0; +} diff --git a/Task/Day-of-the-week/Clojure/day-of-the-week.clj b/Task/Day-of-the-week/Clojure/day-of-the-week.clj new file mode 100644 index 0000000000..c8f2459c8f --- /dev/null +++ b/Task/Day-of-the-week/Clojure/day-of-the-week.clj @@ -0,0 +1,7 @@ +(import '(java.util GregorianCalendar)) +(defn yuletide [start end] + (filter #(= (. (new GregorianCalendar % + (. GregorianCalendar DECEMBER) 25) get (. GregorianCalendar DAY_OF_WEEK)) + (. GregorianCalendar SUNDAY)) (range start (inc end)))) + +(yuletide 2008 2121) diff --git a/Task/Day-of-the-week/CoffeeScript/day-of-the-week-1.coffee b/Task/Day-of-the-week/CoffeeScript/day-of-the-week-1.coffee new file mode 100644 index 0000000000..d7d4e27db8 --- /dev/null +++ b/Task/Day-of-the-week/CoffeeScript/day-of-the-week-1.coffee @@ -0,0 +1,5 @@ +december = 11 # gotta love Date APIs :) +sunday = 0 +for year in [2008..2121] + xmas = new Date year, december, 25 + console.log year if xmas.getDay() is sunday diff --git a/Task/Day-of-the-week/CoffeeScript/day-of-the-week-2.coffee b/Task/Day-of-the-week/CoffeeScript/day-of-the-week-2.coffee new file mode 100644 index 0000000000..1724202d6d --- /dev/null +++ b/Task/Day-of-the-week/CoffeeScript/day-of-the-week-2.coffee @@ -0,0 +1 @@ +console.log year for year in [2008...2121] when new Date(year, 11, 25).getDay() is 0 diff --git a/Task/Day-of-the-week/CoffeeScript/day-of-the-week-3.coffee b/Task/Day-of-the-week/CoffeeScript/day-of-the-week-3.coffee new file mode 100644 index 0000000000..34aad888da --- /dev/null +++ b/Task/Day-of-the-week/CoffeeScript/day-of-the-week-3.coffee @@ -0,0 +1,17 @@ +2011 +2016 +2022 +2033 +2039 +2044 +2050 +2061 +2067 +2072 +2078 +2089 +2095 +2101 +2107 +2112 +2118 diff --git a/Task/Day-of-the-week/ColdFusion/day-of-the-week.cfm b/Task/Day-of-the-week/ColdFusion/day-of-the-week.cfm new file mode 100644 index 0000000000..0e59d5a26b --- /dev/null +++ b/Task/Day-of-the-week/ColdFusion/day-of-the-week.cfm @@ -0,0 +1,6 @@ + + + + December 25th falls on a Sunday in #i#
+
+
diff --git a/Task/Day-of-the-week/Common-Lisp/day-of-the-week.lisp b/Task/Day-of-the-week/Common-Lisp/day-of-the-week.lisp new file mode 100644 index 0000000000..fa26704b98 --- /dev/null +++ b/Task/Day-of-the-week/Common-Lisp/day-of-the-week.lisp @@ -0,0 +1,6 @@ +(loop for year from 2008 upto 2121 + when (= 6 (multiple-value-bind + (second minute hour date month year day-of-week dst-p tz) + (decode-universal-time (encode-universal-time 0 0 0 25 12 year)) + day-of-week)) + collect year) diff --git a/Task/Day-of-the-week/D/day-of-the-week.d b/Task/Day-of-the-week/D/day-of-the-week.d new file mode 100644 index 0000000000..cc4fa61692 --- /dev/null +++ b/Task/Day-of-the-week/D/day-of-the-week.d @@ -0,0 +1,10 @@ +import std.stdio, std.datetime, std.conv, std.algorithm, std.range; + +void main() { + writeln("Christmas comes on a Sunday in the years:"); + foreach (year; 2008 .. 2122) { + immutable d = text(year) ~ "-Dec-25"; + if (Date.fromSimpleString(d).dayOfWeek() == DayOfWeek.sun) + writeln(year); + } +} diff --git a/Task/Day-of-the-week/Delphi/day-of-the-week.delphi b/Task/Day-of-the-week/Delphi/day-of-the-week.delphi new file mode 100644 index 0000000000..41a1b469e0 --- /dev/null +++ b/Task/Day-of-the-week/Delphi/day-of-the-week.delphi @@ -0,0 +1,17 @@ +procedure IsXmasSunday(fromyear, toyear: integer); +var +i: integer; +TestDate: TDateTime; +outputyears: string; +begin +outputyears := ''; + for i:= fromyear to toyear do + begin + TestDate := EncodeDate(i,12,25); + if dayofweek(TestDate) = 1 then + begin + outputyears := outputyears + inttostr(i) + ' '; + end; + end; + form1.label1.caption := outputyears; +end; diff --git a/Task/Day-of-the-week/Euphoria/day-of-the-week.euphoria b/Task/Day-of-the-week/Euphoria/day-of-the-week.euphoria new file mode 100644 index 0000000000..8175e51836 --- /dev/null +++ b/Task/Day-of-the-week/Euphoria/day-of-the-week.euphoria @@ -0,0 +1,15 @@ +--Day of the week task from Rosetta Code wiki +--User:Lnettnay + +--In what years between 2008 and 2121 will the 25th of December be a Sunday + +include std/datetime.e + +datetime dt + +for year = 2008 to 2121 do + dt = new(year, 12, 25) + if weeks_day(dt) = 1 then -- Sunday = 1 + ? year + end if +end for diff --git a/Task/Day-of-the-week/Forth/day-of-the-week-1.fth b/Task/Day-of-the-week/Forth/day-of-the-week-1.fth new file mode 100644 index 0000000000..dbfe3d254a --- /dev/null +++ b/Task/Day-of-the-week/Forth/day-of-the-week-1.fth @@ -0,0 +1,16 @@ +\ Zeller's Congruence +: weekday ( d m y -- wd) \ 1 mon..7 sun + over 3 < if 1- swap 12 + swap then + 100 /mod + dup 4 / swap 2* - + swap dup 4 / + + + swap 1+ 13 5 */ + + + ( in zeller 0=sat, so -2 to 0= mon, then mod, then 1+ for 1=mon) + 2- 7 mod 1+ ; + +: yuletide + ." December 25 is Sunday in " + 2122 2008 do + 25 12 i weekday + 7 = if i . then + loop cr ; diff --git a/Task/Day-of-the-week/Forth/day-of-the-week-2.fth b/Task/Day-of-the-week/Forth/day-of-the-week-2.fth new file mode 100644 index 0000000000..775298ade9 --- /dev/null +++ b/Task/Day-of-the-week/Forth/day-of-the-week-2.fth @@ -0,0 +1,3 @@ +cr yuletide +December 25 is Sunday in 2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118 + ok diff --git a/Task/Day-of-the-week/Forth/day-of-the-week-3.fth b/Task/Day-of-the-week/Forth/day-of-the-week-3.fth new file mode 100644 index 0000000000..fcc7db7e20 --- /dev/null +++ b/Task/Day-of-the-week/Forth/day-of-the-week-3.fth @@ -0,0 +1,9 @@ +: yuletide + ." December 25 is Sunday in " + 2122 2008 do + 25 12 i d/m/y + 7 mod 0= if i . then + loop cr ; + +cr yuletide +December 25 is Sunday in 2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2100 2106 2117 diff --git a/Task/Day-of-the-week/Forth/day-of-the-week-4.fth b/Task/Day-of-the-week/Forth/day-of-the-week-4.fth new file mode 100644 index 0000000000..e9e74ed90b --- /dev/null +++ b/Task/Day-of-the-week/Forth/day-of-the-week-4.fth @@ -0,0 +1,10 @@ +include lib/time.4th + +: yuletide + ." December 25 is Sunday in " + 2122 2008 do + 25 12 i weekday + 6 = if i . then + loop cr ; + +cr yuletide diff --git a/Task/Day-of-the-week/Fortran/day-of-the-week.f b/Task/Day-of-the-week/Fortran/day-of-the-week.f new file mode 100644 index 0000000000..7fff889988 --- /dev/null +++ b/Task/Day-of-the-week/Fortran/day-of-the-week.f @@ -0,0 +1,30 @@ +PROGRAM YULETIDE + +IMPLICIT NONE + +INTEGER :: day, year + +WRITE(*, "(A)", ADVANCE="NO") "25th of December is a Sunday in" +DO year = 2008, 2121 + day = Day_of_week(25, 12, year) + IF (day == 1) WRITE(*, "(I5)", ADVANCE="NO") year +END DO + +CONTAINS + +FUNCTION Day_of_week(d, m, y) + INTEGER :: Day_of_week, j, k, mm, yy + INTEGER, INTENT(IN) :: d, m, y + + mm=m + yy=y + IF(mm.le.2) THEN + mm=mm+12 + yy=yy-1 + END IF + j = yy / 100 + k = MOD(yy, 100) + Day_of_week = MOD(d + ((mm+1)*26)/10 + k + k/4 + j/4 + 5*j, 7) +END FUNCTION Day_of_week + +END PROGRAM YULETIDE diff --git a/Task/Day-of-the-week/Go/day-of-the-week.go b/Task/Day-of-the-week/Go/day-of-the-week.go new file mode 100644 index 0000000000..87c0d0794a --- /dev/null +++ b/Task/Day-of-the-week/Go/day-of-the-week.go @@ -0,0 +1,13 @@ +package main + +import "fmt" +import "time" + +func main() { + for year := 2008; year <= 2121; year++ { + if time.Date(year, 12, 25, 0, 0, 0, 0, time.UTC).Weekday() == + time.Sunday { + fmt.Printf("25 December %d is Sunday\n", year) + } + } +} diff --git a/Task/Day-of-the-week/Haskell/day-of-the-week-1.hs b/Task/Day-of-the-week/Haskell/day-of-the-week-1.hs new file mode 100644 index 0000000000..7df32420cc --- /dev/null +++ b/Task/Day-of-the-week/Haskell/day-of-the-week-1.hs @@ -0,0 +1,8 @@ +import Data.Time +import Data.Time.Calendar.WeekDate + +isXmasSunday year = wday == 7 + where (_,_,wday) = toWeekDate $ fromGregorian year 12 25 + +main = mapM_ putStrLn ["25 December " ++ show year ++ " is Sunday" + | year <- [2008..2121], isXmasSunday year] diff --git a/Task/Day-of-the-week/Haskell/day-of-the-week-2.hs b/Task/Day-of-the-week/Haskell/day-of-the-week-2.hs new file mode 100644 index 0000000000..c872b5b2a9 --- /dev/null +++ b/Task/Day-of-the-week/Haskell/day-of-the-week-2.hs @@ -0,0 +1,21 @@ +import System.Time + +isXmasSunday year = ctWDay cal == Sunday + where cal = toUTCTime $ toClockTime cal' + cal' = CalendarTime { + ctYear = year, + ctMonth = December, + ctDay = 25, + ctHour = 0, + ctMin = 0, + ctSec = 0, + ctPicosec = 0, + ctWDay = Friday, + ctYDay = 0, + ctTZName = "", + ctTZ = 0, + ctIsDST = False + } + +main = mapM_ putStrLn ["25 December " ++ show year ++ " is Sunday" + | year <- [2008..2121], isXmasSunday year] diff --git a/Task/Day-of-the-week/Java/day-of-the-week.java b/Task/Day-of-the-week/Java/day-of-the-week.java new file mode 100644 index 0000000000..fecea04d75 --- /dev/null +++ b/Task/Day-of-the-week/Java/day-of-the-week.java @@ -0,0 +1,15 @@ +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +public class Yuletide{ + public static void main(String[] args) { + for(int i = 2008;i<=2121;i++){ + Calendar cal = new GregorianCalendar(i, Calendar.DECEMBER, + 25); + if(cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){ + System.out.println(cal.getTime()); + } + } + } +} diff --git a/Task/Day-of-the-week/JavaScript/day-of-the-week.js b/Task/Day-of-the-week/JavaScript/day-of-the-week.js new file mode 100644 index 0000000000..5f87be4bc2 --- /dev/null +++ b/Task/Day-of-the-week/JavaScript/day-of-the-week.js @@ -0,0 +1,5 @@ +for (var year = 2008; year <= 2121; year++){ + var xmas = new Date(year, 11, 25) + if ( xmas.getDay() === 0 ) + console.log(year) +} diff --git a/Task/Day-of-the-week/Lua/day-of-the-week.lua b/Task/Day-of-the-week/Lua/day-of-the-week.lua new file mode 100644 index 0000000000..a6db015304 --- /dev/null +++ b/Task/Day-of-the-week/Lua/day-of-the-week.lua @@ -0,0 +1,7 @@ +require("date") + +for year=2008,2121 do + if date(year, 12, 25):getweekday() == 1 then + print(year) + end +end diff --git a/Task/Day-of-the-week/MATLAB/day-of-the-week.m b/Task/Day-of-the-week/MATLAB/day-of-the-week.m new file mode 100644 index 0000000000..dd95051798 --- /dev/null +++ b/Task/Day-of-the-week/MATLAB/day-of-the-week.m @@ -0,0 +1,3 @@ + t = datenum([[2008:2121]',repmat([12,25,0,0,0], 2121-2007, 1)]); + t = t(strmatch('Sunday', datestr(t,'dddd')), :); + datestr(t,'yyyy') diff --git a/Task/Day-of-the-week/PHP/day-of-the-week.php b/Task/Day-of-the-week/PHP/day-of-the-week.php new file mode 100644 index 0000000000..5ffd7d679b --- /dev/null +++ b/Task/Day-of-the-week/PHP/day-of-the-week.php @@ -0,0 +1,10 @@ +format("w") == 0 ) + { + echo "25 Dec $i is Sunday\n"; + } +} +?> diff --git a/Task/Day-of-the-week/Perl/day-of-the-week-1.pl b/Task/Day-of-the-week/Perl/day-of-the-week-1.pl new file mode 100644 index 0000000000..85279a314f --- /dev/null +++ b/Task/Day-of-the-week/Perl/day-of-the-week-1.pl @@ -0,0 +1,16 @@ +#! /usr/bin/perl -w + +use Time::Local; +use strict; + +foreach my $i (2008 .. 2121) +{ + my $time = timelocal(0,0,0,25,11,$i); + my ($s,$m,$h,$md,$mon,$y,$wd,$yd,$is) = localtime($time); + if ( $wd == 0 ) + { + print "25 Dec $i is Sunday\n"; + } +} + +exit 0; diff --git a/Task/Day-of-the-week/Perl/day-of-the-week-2.pl b/Task/Day-of-the-week/Perl/day-of-the-week-2.pl new file mode 100644 index 0000000000..07a8ab8a9c --- /dev/null +++ b/Task/Day-of-the-week/Perl/day-of-the-week-2.pl @@ -0,0 +1,18 @@ +#! /usr/bin/perl -w + +use DateTime; +use strict; + +foreach my $i (2008 .. 2121) +{ + my $dt = DateTime->new( year => $i, + month => 12, + day => 25 + ); + if ( $dt->day_of_week == 7 ) + { + print "25 Dec $i is Sunday\n"; + } +} + +exit 0; diff --git a/Task/Day-of-the-week/Perl/day-of-the-week-3.pl b/Task/Day-of-the-week/Perl/day-of-the-week-3.pl new file mode 100644 index 0000000000..e7d9dda848 --- /dev/null +++ b/Task/Day-of-the-week/Perl/day-of-the-week-3.pl @@ -0,0 +1,11 @@ +#! /usr/bin/perl -w + +use DateTime; +use strict; + +for (2008 .. 2121) { + print "25 Dec $_ is Sunday\n" + if DateTime->new(year => $_, month => 12, day => 25)->day_of_week == 7; +} + +exit 0; diff --git a/Task/Day-of-the-week/Perl/day-of-the-week-4.pl b/Task/Day-of-the-week/Perl/day-of-the-week-4.pl new file mode 100644 index 0000000000..37adc3b59c --- /dev/null +++ b/Task/Day-of-the-week/Perl/day-of-the-week-4.pl @@ -0,0 +1,8 @@ +#! /usr/bin/perl -w + +use DateTime; +use strict; + +print join " ", grep { DateTime->new(year => $_, month => 12, day => 25)->day_of_week == 7 } (2008 .. 2121); + +0; diff --git a/Task/Day-of-the-week/PicoLisp/day-of-the-week.l b/Task/Day-of-the-week/PicoLisp/day-of-the-week.l new file mode 100644 index 0000000000..162332cb8a --- /dev/null +++ b/Task/Day-of-the-week/PicoLisp/day-of-the-week.l @@ -0,0 +1,3 @@ +(for (Y 2008 (>= 2121 Y) (inc Y)) + (when (= "Sunday" (day (date Y 12 25))) + (printsp Y) ) ) diff --git a/Task/Day-of-the-week/Python/day-of-the-week.py b/Task/Day-of-the-week/Python/day-of-the-week.py new file mode 100644 index 0000000000..4b0627699f --- /dev/null +++ b/Task/Day-of-the-week/Python/day-of-the-week.py @@ -0,0 +1,8 @@ +import datetime + +def yuletide(): + sunday = 6 + days = (day.strftime('%d %b %Y') for day in (datetime.date(year, 12, 25) for year in range(2008,2122)) if day.weekday() == sunday) + print '\n'.join(days) + +yuletide() diff --git a/Task/Day-of-the-week/R/day-of-the-week-1.r b/Task/Day-of-the-week/R/day-of-the-week-1.r new file mode 100644 index 0000000000..22141d587d --- /dev/null +++ b/Task/Day-of-the-week/R/day-of-the-week-1.r @@ -0,0 +1,3 @@ +years <- 2008:2121 +xmas <- as.POSIXlt(paste(years, '/12/25', sep="")) +years[xmas$wday==0] diff --git a/Task/Day-of-the-week/R/day-of-the-week-2.r b/Task/Day-of-the-week/R/day-of-the-week-2.r new file mode 100644 index 0000000000..c40e7af8fd --- /dev/null +++ b/Task/Day-of-the-week/R/day-of-the-week-2.r @@ -0,0 +1,4 @@ +Also: + +xmas=seq(as.Date("2008/12/25"), as.Date("2121/12/25"), by="year") +as.numeric(format(xmas[weekdays(xmas)== 'Sunday'], "%Y")) diff --git a/Task/Day-of-the-week/R/day-of-the-week-3.r b/Task/Day-of-the-week/R/day-of-the-week-3.r new file mode 100644 index 0000000000..2722bb1fe7 --- /dev/null +++ b/Task/Day-of-the-week/R/day-of-the-week-3.r @@ -0,0 +1,6 @@ +#Still another solution, using ISOdate and weekdays +(2008:2121)[weekdays(ISOdate(2008:2121, 12, 25)) == "Sunday"] + +# Simply replace "Sunday" with whatever it's named in your country, +# or set locale first, with +Sys.setlocale(cat="LC_ALL", "en") diff --git a/Task/Day-of-the-week/REXX/day-of-the-week-1.rexx b/Task/Day-of-the-week/REXX/day-of-the-week-1.rexx new file mode 100644 index 0000000000..7a73f8399d --- /dev/null +++ b/Task/Day-of-the-week/REXX/day-of-the-week-1.rexx @@ -0,0 +1,3 @@ + do year=2008 to 2121 + if date('w', year'1225', 's') == 'Sunday' then say year + end diff --git a/Task/Day-of-the-week/REXX/day-of-the-week-2.rexx b/Task/Day-of-the-week/REXX/day-of-the-week-2.rexx new file mode 100644 index 0000000000..ff48359206 --- /dev/null +++ b/Task/Day-of-the-week/REXX/day-of-the-week-2.rexx @@ -0,0 +1,3 @@ + do year=2008 to 2121 + if date('b', year'1225', 's') // 7 == 6 then say year + end diff --git a/Task/Day-of-the-week/REXX/day-of-the-week-3.rexx b/Task/Day-of-the-week/REXX/day-of-the-week-3.rexx new file mode 100644 index 0000000000..40839c6afe --- /dev/null +++ b/Task/Day-of-the-week/REXX/day-of-the-week-3.rexx @@ -0,0 +1,14 @@ +/*REXX program displays which years December 25th falls on a Sunday. */ +parse arg start finish . /*get the start and finish years.*/ +if start=='' then start=2008 /*None specified? Assume default*/ +if finish=='' then finish=2121 /*None specified? Assume default*/ + + do y=start to finish /*process the years specified. */ + + if date('Weekday',y"-12-25",'ISO')\=='Sunday' then iterate + /* if date('w' ,y"-12-25",'i' )\== ... (same as above). */ + /* option yyyy-mm-dd fmt */ + + say 'December 25th,' y "falls on a Sunday." + end /*y*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Day-of-the-week/REXX/day-of-the-week-4.rexx b/Task/Day-of-the-week/REXX/day-of-the-week-4.rexx new file mode 100644 index 0000000000..c6974c1b83 --- /dev/null +++ b/Task/Day-of-the-week/REXX/day-of-the-week-4.rexx @@ -0,0 +1,14 @@ +/*REXX program (old school) displays which years 12/25 falls on a Sunday*// + +parse arg start finish . /*get the start and finish years.*/ +if start=='' then start=2008 /*None specified? Assume default*/ +if finish=='' then finish=2121 /*None specified? Assume default*/ + + do y=start to finish /*process the years specified. */ + if dow(12,25,y)==1 then say 'December 25th,' y "falls on a Sunday." + end /*y*/ +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────DOW (day of week) subroutine─────*/ +dow: procedure; arg m,d,y; if m<3 then do; m=m+12; y=y-1; end +yL=left(y,2); yr=right(y,2); w=(d + (m+1)*26%10+yr+yr%4+yL%4+5*yL) // 7 +if w==0 then w=7; return w /*Sunday=1, Monday=2, ... Saturday=7*/ diff --git a/Task/Day-of-the-week/Ruby/day-of-the-week-1.rb b/Task/Day-of-the-week/Ruby/day-of-the-week-1.rb new file mode 100644 index 0000000000..ee9feb6b0b --- /dev/null +++ b/Task/Day-of-the-week/Ruby/day-of-the-week-1.rb @@ -0,0 +1,5 @@ +require 'date' + +(2008..2121).each do |year| + puts "25 Dec #{year}" if Date.new(year, 12, 25).wday == 0 # Ruby 1.9: if Date.new(year, 12, 25).sunday? +end diff --git a/Task/Day-of-the-week/Ruby/day-of-the-week-2.rb b/Task/Day-of-the-week/Ruby/day-of-the-week-2.rb new file mode 100644 index 0000000000..3b79c5a947 --- /dev/null +++ b/Task/Day-of-the-week/Ruby/day-of-the-week-2.rb @@ -0,0 +1,11 @@ +SUNDAY = 0 + +(2008..2121).each do |year| + begin + day = Time.local(year, 12, 25) + puts "25 Dec #{year}" if day.wday == SUNDAY # Ruby 1.9: if day.sunday? + rescue ArgumentError + puts '%d is the last year we can specify' % (year-1) + break + end +end diff --git a/Task/Day-of-the-week/Scala/day-of-the-week.scala b/Task/Day-of-the-week/Scala/day-of-the-week.scala new file mode 100644 index 0000000000..82cc65dec0 --- /dev/null +++ b/Task/Day-of-the-week/Scala/day-of-the-week.scala @@ -0,0 +1,13 @@ +import java.util.{Calendar, GregorianCalendar} +import Calendar._ + +object DayOfTheWeek { + + def main(args:Array[String]) { + for (year <- 2008 to 2121; + date <- Some(new GregorianCalendar(year, DECEMBER, 25)); + if date.get(DAY_OF_WEEK) == SUNDAY) { + println(year) + } + } +} diff --git a/Task/Day-of-the-week/Scheme/day-of-the-week.ss b/Task/Day-of-the-week/Scheme/day-of-the-week.ss new file mode 100644 index 0000000000..15dea1001f --- /dev/null +++ b/Task/Day-of-the-week/Scheme/day-of-the-week.ss @@ -0,0 +1,19 @@ +(define (day-of-week year month day) +(if (< month 3) + (begin (set! month (+ month 12)) (set! year (- year 1)))) +(+ 1 + (remainder (+ 5 day (quotient (* (+ 1 month) 13) 5) + year (quotient year 4) (* (quotient year 100) 6) (quotient year 400)) + 7))) + +(define (task) +(let loop ((y 2121) (v '())) +(if (< y 2008) + v + (loop (- y 1) + (if (= 7 (day-of-week y 12 25)) + (cons y v) + v))))) + +(task) +; (2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118) diff --git a/Task/Day-of-the-week/Smalltalk/day-of-the-week.st b/Task/Day-of-the-week/Smalltalk/day-of-the-week.st new file mode 100644 index 0000000000..b53e05b917 --- /dev/null +++ b/Task/Day-of-the-week/Smalltalk/day-of-the-week.st @@ -0,0 +1,5 @@ +2008 to: 2121 do: [ :year | |date| + date := Date newDay: 25 monthIndex: 12 year: year. + date dayName = #Sunday + ifTrue: [ date displayNl ] +] diff --git a/Task/Day-of-the-week/Tcl/day-of-the-week.tcl b/Task/Day-of-the-week/Tcl/day-of-the-week.tcl new file mode 100644 index 0000000000..da81a321ea --- /dev/null +++ b/Task/Day-of-the-week/Tcl/day-of-the-week.tcl @@ -0,0 +1,7 @@ +package require Tcl 8.5 + +for {set y 2008} {$y <= 2121} {incr y} { + if {[clock format [clock scan "$y-12-25" -format {%Y-%m-%d}] -format %w] == 0} { + puts "xmas $y is a sunday" + } +} diff --git a/Task/Deal-cards-for-FreeCell/0DESCRIPTION b/Task/Deal-cards-for-FreeCell/0DESCRIPTION new file mode 100644 index 0000000000..ab482c99bc --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/0DESCRIPTION @@ -0,0 +1,53 @@ +''Free Cell'' is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to ''FreeCell'' and reimplemented the game for [[DOS]], then [[Windows]]. This version introduced 32000 numbered deals. (The [http://www.solitairelaboratory.com/fcfaq.html FreeCell FAQ] tells this history.) + +As the game became popular, Jim Horne disclosed [http://www.solitairelaboratory.com/mshuffle.txt the algorithm], and other implementations of FreeCell began to reproduce the Microsoft deals. These deals are numbered from 1 to 32000. Newer versions from Microsoft have 1 million deals, numbered from 1 to 1000000; some implementations allow numbers outside that range. + +The algorithm uses this [[linear congruential generator]] from Microsoft C: + +* state_{n + 1} \equiv 214013 \times state_n + 2531011 \pmod{2^{31}} +* rand_n = state_n \div 2^{16} +* rand_n is in range 0 to 32767. +* Rosetta Code has another task, [[linear congruential generator]], with code for this RNG in several languages. + +The algorithm follows: + +# Seed the RNG with the number of the deal. +# Create an [[array]] of 52 cards: Ace of Clubs, Ace of Diamonds, Ace of Hearts, Ace of Spades, 2 of Clubs, 2 of Diamonds, and so on through the ranks: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King. The array indexes are 0 to 51, with Ace of Clubs at 0, and King of Spades at 51. +# Until the array is empty: +#* Choose a random card at ''index'' ≡ ''next random number'' (mod ''array length''). +#* Swap this random card with the last card of the array. +#* Remove this random card from the array. (Array length goes down by 1.) +#* Deal this random card. +# Deal all 52 cards, face up, across 8 columns. The first 8 cards go in 8 columns, the next 8 cards go on the first 8 cards, and so on. + +{| class="wikitable" +!| Order to deal cards +!| Game #1 +!| Game #617 +|- +||
 1  2  3  4  5  6  7  8
+ 9 10 11 12 13 14 15 16
+17 18 19 20 21 22 23 24
+25 26 27 28 29 30 31 32
+33 34 35 36 37 38 39 40
+41 42 43 44 45 46 47 48
+49 50 51 52
+||
JD 2D 9H JC 5D 7H 7C 5H
+KD KC 9S 5S AD QC KH 3H
+2S KS 9D QD JS AS AH 3C
+4C 5C TS QH 4H AC 4D 7S
+3S TD 4S TH 8H 2C JH 7D
+6D 8S 8D QS 6C 3D 8C TC
+6S 9C 2H 6H
+||
7D AD 5C 3S 5S 8C 2D AH
+TD 7S QD AC 6D 8H AS KH
+TH QC 3H 9D 6S 8D 3D TC
+KD 5H 9S 3C 8S 7H 4D JS
+4C QS 9C 9H 7C 6H 2C 2S
+4S TS 2H 5D JC 6C JH QH
+JD KS KC 4H
+|} + +Deals can also be checked against [http://freecellgamesolutions.com/ FreeCell solutions to 1000000 games]. (Summon a video solution, and it displays the initial deal.) + +Write a program to take a deal number and deal cards in the same order as this algorithm. The program may display the cards with ASCII, with Unicode, by drawing graphics, or any other way. diff --git a/Task/Deal-cards-for-FreeCell/1META.yaml b/Task/Deal-cards-for-FreeCell/1META.yaml new file mode 100644 index 0000000000..a2413d963b --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Games diff --git a/Task/Deal-cards-for-FreeCell/Ada/deal-cards-for-freecell.ada b/Task/Deal-cards-for-FreeCell/Ada/deal-cards-for-freecell.ada new file mode 100644 index 0000000000..72b1382b05 --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/Ada/deal-cards-for-freecell.ada @@ -0,0 +1,38 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure FreeCell is + type State is mod 2**31; + type Deck is array (0..51) of String(1..2); + + package Random is + procedure Init(Seed: State); + function Rand return State; + end Random; + package body Random is + S : State := State'First; + procedure Init(Seed: State) is begin S := Seed; end Init; + function Rand return State is begin + S := S * 214013 + 2531011; return S / 2**16; + end Rand; + end Random; + + procedure Deal (num : State) is + thedeck : Deck; pick : State; + Chars : constant String := "A23456789TJQKCDHS"; + begin + for i in thedeck'Range loop + thedeck(i):= Chars(i/4+1) & Chars(i mod 4 + 14); + end loop; + Random.Init(num); + for i in 0..51 loop + pick := Random.Rand mod State(52-i); + Put(thedeck(Natural(pick))&' '); + if (i+1) mod 8 = 0 then New_Line; end if; + thedeck(Natural(pick)) := thedeck(51-i); + end loop; New_Line; + end Deal; + +begin + Deal(1); + New_Line; + Deal(617); +end FreeCell; diff --git a/Task/Deal-cards-for-FreeCell/BBC-BASIC/deal-cards-for-freecell.bbc b/Task/Deal-cards-for-FreeCell/BBC-BASIC/deal-cards-for-freecell.bbc new file mode 100644 index 0000000000..7e40f685eb --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/BBC-BASIC/deal-cards-for-freecell.bbc @@ -0,0 +1,45 @@ + *FLOAT 64 + + hand% = 617 + + REM Initialise card library: + SYS "LoadLibrary", "CARDS.DLL" TO cards% + IF cards% = 0 ERROR 100, "No CARDS library" + SYS "GetProcAddress", cards%, "cdtInit" TO cdtInit% + SYS "GetProcAddress", cards%, "cdtDraw" TO cdtDraw% + SYS cdtInit%, ^dx%, ^dy% + VDU 23,22,8*dx%;5*dy%;8,16,16,128 + + REM Initialise deck: + DIM card&(51) + FOR I% = 0 TO 51 : card&(I%) = I% : NEXT + + REM Shuffle deck: + dummy% = FNrng(hand%) + FOR I% = 51 TO 0 STEP -1 + C% = FNrng(-1) MOD (I% + 1) + SWAP card&(C%), card&(I%) + NEXT + + REM Display deck: + FOR I% = 0 TO 51 + C% = card&(51 - I%) + X% = (I% MOD 8) * dx% + Y% = (I% DIV 8) * dy% * 2 / 3 + SYS cdtDraw%, @memhdc%, X%, Y%, C%, 0, 0 + NEXT + SYS "InvalidateRect", @hwnd%, 0, 0 + *GSAVE freecell + END + + DEF FNrng(seed) + PRIVATE state, M% + IF seed >= 0 THEN + state = seed + ELSE + state = (state * 214013 + 2531011) + FOR M% = 52 TO 31 STEP -1 + IF state >= 2^M% state -= 2^M% + NEXT + ENDIF + = state >> 16 diff --git a/Task/Deal-cards-for-FreeCell/Bracmat/deal-cards-for-freecell.bracmat b/Task/Deal-cards-for-FreeCell/Bracmat/deal-cards-for-freecell.bracmat new file mode 100644 index 0000000000..09ed2ab890 --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/Bracmat/deal-cards-for-freecell.bracmat @@ -0,0 +1,63 @@ +( ( createArray + = array rank ranks suit suits + . A 2 3 4 5 6 7 8 9 T J Q K:?ranks + & :?array + & whl + ' ( !ranks:%?rank ?ranks + & ♣ ♦ ♥ ♠:?suits + & whl + ' ( !suits:%?suit ?suits + & !array str$(!rank !suit):?array + ) + ) + & !array + ) +& ( deal + = A B D L Z pick card dealt deck + , i last rand row state + . !arg:(?deck:? [?L.?state) + & 8:?row + & :?dealt + & ( pick + = sep + . ( -1+!row:>0:?row + & " ":?sep + | \n:?sep&8:?row + ) + & !dealt !arg !sep:?dealt + ) + & 2^31:?B + & 2^16:?D + & " + 'Hard code' the numbers B and D into the rand function using + macro expansion. (Gives a marginally faster execution speed.) + " + & + ' ( + . mod$(!state*214013+2531011.$B):?state + & div$(!state.$D) + ) + : (=?rand) + & !L+1:?L + & whl + ' ( mod$(rand$.!L+-1:?L):?i + & !deck:?A [!i %?card ?Z + & ( !Z:?Z %@?last&!A !last !Z + | !A + ) + : ?deck + & pick$!card + ) + & pick$\n + & str$!dealt + ) +& createArray$:?deck +& put$("Game #1\n","dealt.txt",NEW) +& put$(deal$(!deck.1),"dealt.txt",APP) +& put$(" + +Game #617 +","dealt.txt",APP) +& put$(deal$(!deck.617),"dealt.txt",APP) +& +) diff --git a/Task/Deal-cards-for-FreeCell/C/deal-cards-for-freecell.c b/Task/Deal-cards-for-FreeCell/C/deal-cards-for-freecell.c new file mode 100644 index 0000000000..15fdac85d2 --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/C/deal-cards-for-freecell.c @@ -0,0 +1,46 @@ +#include +#include +#include + +wchar_t s_suits[] = L"♣♦♥♠", s_nums[] = L"A23456789TJQK"; + +#define RMAX32 ((1U << 31) - 1) +static int seed = 1; +int rnd(void) { return (seed = (seed * 214013 + 2531011) & RMAX32) >> 16; } +void srnd(int x) { seed = x; } + +void show(const int *c) +{ + int i; + for (i = 0; i < 52; c++) { + printf(" \033[%dm%lc\033[m%lc", 32 - (1 + *c) % 4 / 2, + s_suits[*c % 4], s_nums[*c / 4]); + if (!(++i % 8) || i == 52) putchar('\n'); + } +} + +void deal(int s, int *t) +{ + int i, j; + srnd(s); + + for (i = 0; i < 52; i++) t[i] = 51 - i; + for (i = 0; i < 51; i++) { + j = 51 - rnd() % (52 - i); + s = t[i], t[i] = t[j], t[j] = s; + } +} + +int main(int c, char **v) +{ + int s, card[52]; + if (c < 2 || (s = atoi(v[1])) <= 0) s = 11982; + + setlocale(LC_ALL, ""); + + deal(s, card); + printf("Hand %d\n", s); + show(card); + + return 0; +} diff --git a/Task/Deal-cards-for-FreeCell/Common-Lisp/deal-cards-for-freecell.lisp b/Task/Deal-cards-for-FreeCell/Common-Lisp/deal-cards-for-freecell.lisp new file mode 100644 index 0000000000..387a31235a --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/Common-Lisp/deal-cards-for-freecell.lisp @@ -0,0 +1,26 @@ +(defun make-rng (seed) + #'(lambda () + (ash (setf seed (mod (+ (* 214013 seed) 2531011) (expt 2 31))) -16))) + +(defun split (s) (map 'list #'string s)) + +(defun make-deck (seed) + (let ((hand (make-array 52 :fill-pointer 0)) + (rng (make-rng seed))) + (dolist (d (split "A23456789TJQK")) + (dolist (s (split "♣♦♥♠")) + (vector-push (concatenate 'string d s) hand))) + (dotimes (i 52) + (rotatef (aref hand (- 51 i)) + (aref hand (mod (funcall rng) (- 52 i))))) + (nreverse hand))) + +(defun show-deck (seed) + (let ((hand (make-deck seed))) + (format t "~%Hand ~d~%" seed) + (dotimes (i 52) + (format t "~A " (aref hand i)) + (if (= (mod i 8) 7) (write-line ""))))) + +(show-deck 1) +(show-deck 617) diff --git a/Task/Deal-cards-for-FreeCell/D/deal-cards-for-freecell.d b/Task/Deal-cards-for-FreeCell/D/deal-cards-for-freecell.d new file mode 100644 index 0000000000..4aa1b9fb16 --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/D/deal-cards-for-freecell.d @@ -0,0 +1,40 @@ +import std.stdio, std.conv, std.algorithm, std.range; + +struct RandomGenerator { + uint seed = 1; + + @property uint next() pure nothrow { + seed = (seed * 214_013 + 2_531_011) & int.max; + return seed >> 16; + } +} + +struct Deck { + int[52] cards; + + void deal(in uint seed) /*pure nothrow*/ { + enum int nc = cards.length; // Must be signed for iota. + + copy(iota(nc - 1, -1, -1), cards[]); // not pure nothrow + + auto rnd = RandomGenerator(seed); + foreach (i, ref c; cards) + swap(c, cards[(nc - 1) - rnd.next % (nc - i)]); + } + + void show() { + foreach (row; std.range.chunks(cards[], 8)) { + foreach (c; row) + write(" ", "A23456789TJQK"[c / 4], "CDHS"[c % 4]); + writeln(); + } + } +} + +void main(in string[] args) { + immutable seed = (args.length == 2) ? to!uint(args[1]) : 11_982; + writeln("Hand ", seed); + Deck cards; + cards.deal(seed); + cards.show(); +} diff --git a/Task/Deal-cards-for-FreeCell/Go/deal-cards-for-freecell.go b/Task/Deal-cards-for-FreeCell/Go/deal-cards-for-freecell.go new file mode 100644 index 0000000000..240fabba6b --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/Go/deal-cards-for-freecell.go @@ -0,0 +1,65 @@ +package main + +import ( + "fmt" + "math" + "math/rand" + "os" + "strconv" + "time" +) + +const sSuits = "CDHS" +const sNums = "A23456789TJQK" +const rMax32 = math.MaxInt32 + +var seed = 1 + +func rnd() int { + seed = (seed*214013 + 2531011) & rMax32 + return seed >> 16 +} + +func deal(s int) []int { + seed = s + t := make([]int, 52) + for i := 0; i < 52; i++ { + t[i] = 51 - i + } + for i := 0; i < 51; i++ { + j := 51 - rnd()%(52-i) + t[i], t[j] = t[j], t[i] + } + return t +} + +func show(cs []int) { + for i, c := range cs { + fmt.Printf(" %c%c", sNums[c/4], sSuits[c%4]) + if (i+1)%8 == 0 || i+1 == len(cs) { + fmt.Println() + } + } +} + +func main() { + var game int + switch len(os.Args) { + case 1: + rand.Seed(time.Now().UnixNano()) + game = 1 + rand.Intn(32000) + case 2: + var err error + game, err = strconv.Atoi(os.Args[1]) + if err == nil && game >= 1 && game <= 32000 { + break + } + fallthrough + default: + fmt.Println("usage: deal [game]") + fmt.Println(" where game is a number in the range 1 to 32000") + return + } + fmt.Printf("\nGame #%d\n", game) + show(deal(game)) +} diff --git a/Task/Deal-cards-for-FreeCell/Haskell/deal-cards-for-freecell.hs b/Task/Deal-cards-for-FreeCell/Haskell/deal-cards-for-freecell.hs new file mode 100644 index 0000000000..f122af900d --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/Haskell/deal-cards-for-freecell.hs @@ -0,0 +1,36 @@ +import Data.Int +import Data.Bits +import Data.List +import Data.Array.ST +import Control.Monad +import Control.Monad.ST +import System.Environment + +srnd :: Int32 -> [Int] +srnd = map (fromIntegral . flip shiftR 16) . + tail . iterate (\x -> (x * 214013 + 2531011) .&. maxBound) + +deal :: Int32 -> [String] +deal s = runST (do + ar <- newListArray (0,51) $ sequence ["A23456789TJQK", "CDHS"] + :: ST s (STArray s Int String) + forM (zip [52,51..1] rnd) $ \(n, r) -> do + let j = r `mod` n + vj <- readArray ar j + vn <- readArray ar (n - 1) + writeArray ar j vn + return vj) + where rnd = srnd s + +showCards :: [String] -> IO () +showCards = mapM_ (putStrLn . unwords) . + takeWhile (not . null) . + unfoldr (Just . splitAt 8) + +main :: IO () +main = do + args <- getArgs + let s = read (head args) :: Int32 + putStrLn $ "Deal " ++ show s ++ ":" + let cards = deal s + showCards cards diff --git a/Task/Deal-cards-for-FreeCell/JavaScript/deal-cards-for-freecell.js b/Task/Deal-cards-for-FreeCell/JavaScript/deal-cards-for-freecell.js new file mode 100644 index 0000000000..9ed230d84d --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/JavaScript/deal-cards-for-freecell.js @@ -0,0 +1,87 @@ +"use strict"; +/* + * Microsoft C Run-time-Library-compatible Random Number Generator + * Copyright by Shlomi Fish, 2011. + * Released under the MIT/X11 License + * ( http://en.wikipedia.org/wiki/MIT_License ). + * */ +/* This uses Joose 2.x-or-above, an object system for JavaScript - http://code.google.com/p/joose-js/ . */ + +Class('MSRand', { + has: { + seed: { is: rw, }, + }, + methods: { + rand: function() { + this.setSeed((this.getSeed() * 214013 + 2531011) & 0x7FFFFFFF); + return ((this.getSeed() >> 16) & 0x7fff); + }, + max_rand: function(mymax) { + return this.rand() % mymax; + }, + shuffle: function(deck) { + if (deck.length) { + var i = deck.length; + while (--i) { + var j = this.max_rand(i+1); + var tmp = deck[i]; + deck[i] = deck[j]; + deck[j] = tmp; + } + } + return deck; + }, + }, +}); + +/* + * Microsoft Windows Freecell / Freecell Pro boards generation. + * + * See: + * + * - http://rosettacode.org/wiki/Deal_cards_for_FreeCell + * + * - http://www.solitairelaboratory.com/mshuffle.txt + * + * Under MIT/X11 Licence. + * + * */ + +function deal_ms_fc_board(seed) { + var randomizer = new MSRand({ seed: seed }); + var num_cols = 8; + + var _perl_range = function(start, end) { + var ret = []; + + for (var i = start; i <= end; i++) { + ret.push(i); + } + + return ret; + }; + + var columns = _perl_range(0, num_cols-1).map(function () { return []; }); + var deck = _perl_range(0, 4*13-1); + + randomizer.shuffle(deck); + + deck = deck.reverse() + + for (var i = 0; i < 52; i++) { + columns[i % num_cols].push(deck[i]); + } + + var render_card = function (card) { + var suit = (card % 4); + var rank = Math.floor(card / 4); + + return "A23456789TJQK".charAt(rank) + "CDHS".charAt(suit); + } + + var render_column = function(col) { + return ": " + col.map(render_card).join(" ") + "\n"; + } + + return columns.map(render_column).join(""); +} diff --git a/Task/Deal-cards-for-FreeCell/Perl/deal-cards-for-freecell.pl b/Task/Deal-cards-for-FreeCell/Perl/deal-cards-for-freecell.pl new file mode 100644 index 0000000000..c0bd407a86 --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/Perl/deal-cards-for-freecell.pl @@ -0,0 +1,42 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use utf8; + +sub deal { + my $s = shift; + + my $rnd = sub { + return (($s = ($s * 214013 + 2531011) & 0x7fffffff) >> 16 ); + }; + + my @d; + for my $b (split "", "A23456789TJQK") { + push @d, map("$_$b", qw/♣ ♦ ♥ ♠/); + } + + for my $idx (reverse 0 .. $#d) { + my $r = $rnd->() % ($idx + 1); + @d[$r, $idx] = @d[$idx, $r]; + } + + return [reverse @d]; +} + +my $hand_idx = shift(@ARGV) // 11_982; + +my $cards = deal($hand_idx); + +my $num_cards_in_height = 8; +my $string = ''; + +while (@$cards) +{ + $string .= join(' ', splice(@$cards, 0, 8)) . "\n"; +} + +binmode STDOUT, ':encoding(utf-8)'; +print "Hand $hand_idx\n"; +print $string; diff --git a/Task/Deal-cards-for-FreeCell/PicoLisp/deal-cards-for-freecell.l b/Task/Deal-cards-for-FreeCell/PicoLisp/deal-cards-for-freecell.l new file mode 100644 index 0000000000..f095f628c3 --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/PicoLisp/deal-cards-for-freecell.l @@ -0,0 +1,20 @@ +(setq *MsSeed 11982) + +(de msRand () + (>> 16 + (setq *MsSeed + (& (+ 2531011 (* 214013 *MsSeed)) `(dec (** 2 31))) ) ) ) + +(let L + (make + (for Num (range 13 1) + (for Suit '((32 . "♠") (31 . "♥") (31 . "♦") (32 . "♣")) + (link (cons (get '`(chop "A23456789TJQK") Num) Suit)) ) ) ) + (for I 51 + (xchg + (nth L I) + (nth L (- 52 (% (msRand) (- 53 I)))) ) ) + (for C L + (prin " ^[[" (cadr C) "m" (cddr C) "^[[m" (car C)) + (at (0 . 8) (prinl)) ) + (prinl) ) diff --git a/Task/Deal-cards-for-FreeCell/Python/deal-cards-for-freecell.py b/Task/Deal-cards-for-FreeCell/Python/deal-cards-for-freecell.py new file mode 100644 index 0000000000..35d0985560 --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/Python/deal-cards-for-freecell.py @@ -0,0 +1,29 @@ +from sys import argv + +def randomGenerator(seed=1): + max_int32 = (1 << 31) - 1 + seed = seed & max_int32 + + while True: + seed = (seed * 214013 + 2531011) & max_int32 + yield seed >> 16 + +def deal(seed): + nc = 52 + cards = range(nc - 1, -1, -1) + rnd = randomGenerator(seed) + for i, r in zip(range(nc), rnd): + j = (nc - 1) - r % (nc - i) + cards[i], cards[j] = cards[j], cards[i] + return cards + +def show(cards): + l = ["A23456789TJQK"[c / 4] + "CDHS"[c % 4] for c in cards] + for i in range(0, len(cards), 8): + print " ", " ".join(l[i : i+8]) + +if __name__ == '__main__': + seed = int(argv[1]) if len(argv) == 2 else 11982 + print "Hand", seed + deck = deal(seed) + show(deck) diff --git a/Task/Deal-cards-for-FreeCell/Ruby/deal-cards-for-freecell.rb b/Task/Deal-cards-for-FreeCell/Ruby/deal-cards-for-freecell.rb new file mode 100644 index 0000000000..9ab3282702 --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/Ruby/deal-cards-for-freecell.rb @@ -0,0 +1,72 @@ +# Deal cards for FreeCell. +# http://rosettacode.org/wiki/Deal_cards_for_FreeCell + +require 'optparse' + +# Parse command-line arguments. +# games = ARGV converted to Integer +# No arguments? Pick any of first 32000 games. +games = nil +OptionParser.new do |o| + begin + o.banner = "Usage: #{o.program_name} number..." + o.parse! + games = ARGV.map {|s| Integer(s)} + games.empty? and games = [rand(32000)] + rescue => e + $stderr.puts e, o + abort + end +end + +# Define methods for old Ruby versions. +# Enumerable#each_slice appeared in Ruby 1.8.7. +# Enumerable#flat_map appeared in Ruby 1.9.2. +module Enumerable + unless method_defined? :each_slice + def each_slice(count) + block_given? or return enum_for(:each_slice, count) + ary = [] + each {|e| + ary << e + ary.length == count and (yield ary.dup; ary.clear)} + ary.empty? or yield ary.dup + nil + end + end + + unless method_defined? :flat_map + def flat_map + block_given? or return enum_for(:flat_map) + ary = [] + each {|e| + y = yield e + ary.concat(y) rescue ary.push(y)} + ary + end + end +end + +# Create original deck of 52 cards, not yet shuffled. +orig_deck = %w{A 2 3 4 5 6 7 8 9 T J Q K +}.flat_map {|rank| %w{C D H S}.map {|suit| "#{rank}#{suit}"}} + +games.each do |seed| + deck = orig_deck.dup + + # Shuffle deck with random index from linear congruential + # generator like Microsoft. + state = seed + 52.downto(2) do |len| + state = ((214013 * state) + 2531011) & 0x7fff_ffff + index = (state >> 16) % len + last = len - 1 + deck[index], deck[last] = deck[last], deck[index] + end + + deck.reverse! # Shuffle did reverse deck. Do reverse again. + + # Deal cards. + puts "Game ##{seed}" + deck.each_slice(8) {|row| puts " " + row.join(" ")} +end diff --git a/Task/Deal-cards-for-FreeCell/Tcl/deal-cards-for-freecell.tcl b/Task/Deal-cards-for-FreeCell/Tcl/deal-cards-for-freecell.tcl new file mode 100644 index 0000000000..b7f3813278 --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/Tcl/deal-cards-for-freecell.tcl @@ -0,0 +1,31 @@ +proc rnd {{*r seed}} { + upvar 1 ${*r} r + expr {[set r [expr {($r * 214013 + 2531011) & 0x7fffffff}]] >> 16} +} +proc show cards { + set suits {\u2663 \u2666 \u2665 \u2660} + set values {A 2 3 4 5 6 7 8 9 T J Q K} + for {set i 0} {$i < 52} {incr i} { + set c [lindex $cards $i] + puts -nonewline [format " \033\[%dm%s\033\[m%s" [expr {32-(1+$c)%4/2}] \ + [lindex $suits [expr {$c % 4}]] [lindex $values [expr {$c / 4}]]] + if {($i&7)==7 || $i==51} {puts ""} + } +} +proc deal {seed} { + for {set i 0} {$i < 52} {incr i} {lappend cards [expr {51 - $i}]} + for {set i 0} {$i < 51} {incr i} { + set j [expr {51 - [rnd]%(52-$i)}] + set tmp [lindex $cards $i] + lset cards $i [lindex $cards $j] + lset cards $j $tmp + } + return $cards +} + +if {![scan =[lindex $argv 0]= =%d= s] || $s <= 0} { + set s 11982 +} +set cards [deal $s] +puts "Hand $s" +show $cards diff --git a/Task/Death-Star/D/death-star.d b/Task/Death-Star/D/death-star.d new file mode 100644 index 0000000000..c39ff7bdfa --- /dev/null +++ b/Task/Death-Star/D/death-star.d @@ -0,0 +1,109 @@ +import std.stdio, std.math, std.numeric, std.algorithm; + +struct V3 { + double[3] v; + + @property V3 normalize() pure nothrow const { + immutable double len = dotProduct(v, v).sqrt(); + //return V3(v[] / len); + return V3([v[0] / len, v[1] / len, v[2] / len]); + } + + double dot(in ref V3 y) pure nothrow const { + immutable double d = dotProduct(v, y.v); + return d < 0 ? -d : 0; + } +} + + +const struct Sphere { double cx, cy, cz, r; } + +void drawSphere(in double k, in double ambient, in V3 light) nothrow { + /** Check if a ray (x,y, -inf).(x, y, inf) hits a sphere; if so, + return the intersecting z values. z1 is closer to the eye */ + static bool hitSphere(in ref Sphere sph, + in double x0, in double y0, + out double z1, + out double z2) pure nothrow { + immutable double x = x0 - sph.cx; + immutable double y = y0 - sph.cy; + immutable double zsq = sph.r ^^ 2 - (x ^^ 2 + y ^^ 2); + if (zsq < 0) + return false; + immutable double szsq = sqrt(zsq); + z1 = sph.cz - szsq; + z2 = sph.cz + szsq; + return true; + } + + enum string shades = ".:!*oe&#%@"; + // positive and negative spheres + immutable pos = Sphere(20, 20, 0, 20); + immutable neg = Sphere(1, 1, -6, 20); + + foreach (int i; cast(int)floor(pos.cy - pos.r) .. + cast(int)ceil(pos.cy + pos.r) + 1) { + immutable double y = i + 0.5; + jloop: + foreach (int j; cast(int)floor(pos.cx - 2 * pos.r) .. + cast(int)ceil(pos.cx + 2 * pos.r) + 1) { + immutable double x = (j - pos.cx) / 2.0 + 0.5 + pos.cx; + + enum Hit { background, posSphere, negSphere } + Hit hitResult; + double zb1, zs2; + { + double zb2, zs1; + if (!hitSphere(pos, x, y, zb1, zb2)) { + // Ray lands in blank space, draw bg + hitResult = Hit.background; + } else if (!hitSphere(neg, x, y, zs1, zs2)) { + // Ray hits pos sphere but not neg one, + // draw pos sphere surface + hitResult = Hit.posSphere; + } else if (zs1 > zb1) { + // ray hits both, but pos front surface is closer + hitResult = Hit.posSphere; + } else if (zs2 > zb2) { + // pos sphere surface is inside neg sphere, + // show bg + hitResult = Hit.background; + } else if (zs2 > zb1) { + // Back surface on neg sphere is inside pos + // sphere, the only place where neg sphere + // surface will be shown + hitResult = Hit.negSphere; + } else { + hitResult = Hit.posSphere; + } + } + + V3 vec_; + final switch (hitResult) { + case Hit.background: + putchar(' '); + continue jloop; + case Hit.posSphere: + vec_ = V3([x - pos.cx, y - pos.cy, zb1 - pos.cz]); + break; + case Hit.negSphere: + vec_ = V3([neg.cx - x, neg.cy - y, neg.cz - zs2]); + break; + } + immutable V3 nvec = vec_.normalize; + + immutable double b = light.dot(nvec) ^^ k + ambient; + int intensity = cast(int)((1 - b) * shades.length); + intensity = min(shades.length, max(0, intensity)); + putchar(shades[intensity]); + } + + putchar('\n'); + } +} + + +void main() { + enum light = V3([-50, 30, 50]).normalize; + drawSphere(2, 0.5, light); +} diff --git a/Task/Death-Star/DWScript/death-star.dwscript b/Task/Death-Star/DWScript/death-star.dwscript new file mode 100644 index 0000000000..7bbb8b590d --- /dev/null +++ b/Task/Death-Star/DWScript/death-star.dwscript @@ -0,0 +1,94 @@ +const cShades = '.:!*oe&#%@'; + +type TVector = array [0..2] of Float; + +var light : TVector = [-50.0, 30, 50]; + +procedure Normalize(var v : TVector); +begin + var len := Sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + v[0] /= len; v[1] /= len; v[2] /= len; +end; + +function Dot(x, y : TVector) : Float; +begin + var d :=x[0]*y[0] + x[1]*y[1] + x[2]*y[2]; + if d<0 then + Result:=-d + else Result:=0; +end; + +type + TSphere = record + cx, cy, cz, r : Float; + end; + +const big : TSphere = (cx: 20; cy: 20; cz: 0; r: 20); +const small : TSphere = (cx: 7; cy: 7; cz: -10; r: 15); + +function HitSphere(sph : TSphere; x, y : Float; var z1, z2 : Float) : Boolean; +begin + x -= sph.cx; + y -= sph.cy; + var zsq = sph.r * sph.r - (x * x + y * y); + if (zsq < 0) then Exit False; + zsq := Sqrt(zsq); + z1 := sph.cz - zsq; + z2 := sph.cz + zsq; + Result:=True; +end; + +procedure DrawSphere(k, ambient : Float); +var + i, j, intensity : Integer; + b : Float; + x, y, zb1, zb2, zs1, zs2 : Float; + vec : TVector; +begin + for i:=Trunc(big.cy-big.r) to Trunc(big.cy+big.r)+1 do begin + y := i + 0.5; + for j := Trunc(big.cx-2*big.r) to Trunc(big.cx+2*big.r) do begin + x := (j-big.cx)/2 + 0.5 + big.cx; + + if not HitSphere(big, x, y, zb1, zb2) then begin + Print(' '); + continue; + end; + if not HitSphere(small, x, y, zs1, zs2) then begin + vec[0] := x - big.cx; + vec[1] := y - big.cy; + vec[2] := zb1 - big.cz; + end else begin + if zs1 < zb1 then begin + if zs2 > zb2 then begin + Print(' '); + continue; + end; + if zs2 > zb1 then begin + vec[0] := small.cx - x; + vec[1] := small.cy - y; + vec[2] := small.cz - zs2; + end else begin + vec[0] := x - big.cx; + vec[1] := y - big.cy; + vec[2] := zb1 - big.cz; + end; + end else begin + vec[0] := x - big.cx; + vec[1] := y - big.cy; + vec[2] := zb1 - big.cz; + end; + end; + + Normalize(vec); + b := Power(Dot(light, vec), k) + ambient; + intensity := Round((1 - b) * Length(cShades)); + Print(cShades[ClampInt(intensity+1, 1, Length(cShades))]); + end; + PrintLn(''); + end; +end; + +Normalize(light); + +DrawSphere(2, 0.3); diff --git a/Task/Deconvolution-1D/0DESCRIPTION b/Task/Deconvolution-1D/0DESCRIPTION new file mode 100644 index 0000000000..630e811fc5 --- /dev/null +++ b/Task/Deconvolution-1D/0DESCRIPTION @@ -0,0 +1,78 @@ +The convolution of two functions \mathit{F} and \mathit{H} of +an integer variable is defined as the function \mathit{G} +satisfying + +: G(n) = \sum_{m=-\infty}^{\infty} F(m) H(n-m) + +for all integers \mathit{n}. Assume F(n) can be non-zero only for 0\mathit{n}|\mathit{F}|, where |\mathit{F}| is the "length" of \mathit{F}, and similarly for \mathit{G} and \mathit{H}, so that the functions can be modeled as finite sequences by identifying f_0, f_1, f_2, \dots with F(0), F(1), F(2), \dots, etc. Then for example, values of |\mathit{F}| = 6 and |\mathit{H}| = 5 would determine the following value of \mathit{g} by definition. + +: +\begin{array}{lllllllllll} +g_0 &= &f_0h_0\\ +g_1 &= &f_1h_0 &+ &f_0h_1\\ +g_2 &= &f_2h_0 &+ &f_1h_1 &+ &f_0h_2\\ +g_3 &= &f_3h_0 &+ &f_2h_1 &+ &f_1h_2 &+ &f_0h_3\\ +g_4 &= &f_4h_0 &+ &f_3h_1 &+ &f_2h_2 &+ &f_1h_3 &+ &f_0h_4\\ +g_5 &= &f_5h_0 &+ &f_4h_1 &+ &f_3h_2 &+ &f_2h_3 &+ &f_1h_4\\ +g_6 &= & & &f_5h_1 &+ &f_4h_2 &+ &f_3h_3 &+ &f_2h_4\\ +g_7 &= & & & & &f_5h_2 &+ &f_4h_3 &+ &f_3h_4\\ +g_8 &= & & & & & & &f_5h_3 &+ &f_4h_4\\ +g_9 &= & & & & & & & & &f_5h_4 +\end{array} + + +We can write this in matrix form as: + +: +\left( +\begin{array}{l} +g_0 \\ +g_1 \\ +g_2 \\ +g_3 \\ +g_4 \\ +g_5 \\ +g_6 \\ +g_7 \\ +g_8 \\ +g_9 \\ +\end{array} +\right) = \left( +\begin{array}{lllll} +f_0\\ +f_1 & f_0\\ +f_2 & f_1 & f_0\\ +f_3 & f_2 & f_1 & f_0\\ +f_4 & f_3 & f_2 & f_1 & f_0\\ +f_5 & f_4 & f_3 & f_2 & f_1\\ + & f_5 & f_4 & f_3 & f_2\\ + & & f_5 & f_4 & f_3\\ + & & & f_5 & f_4\\ + & & & & f_5 +\end{array} +\right) \; \left( +\begin{array}{l} +h_0 \\ +h_1 \\ +h_2 \\ +h_3 \\ +h_4 \\ +\end{array} \right) + + +or + +: +g = A \; h + + +For this task, implement a function (or method, procedure, subroutine, etc.) deconv to perform ''deconvolution'' (i.e., the ''inverse'' of convolution) by constructing and solving such a system of equations represented by the above matrix A for \mathit{h} given \mathit{f} and \mathit{g}. + +* The function should work for \mathit{G} of arbitrary length (i.e., not hard coded or constant) and \mathit{F} of any length up to that of \mathit{G}. Note that |\mathit{H}| will be given by |\mathit{G}| - |\mathit{F}| + 1. +* There may be more equations than unknowns. If convenient, use a function from a [http://www.netlib.org/lapack/lug/node27.html library] that finds the best fitting solution to an overdetermined system of linear equations (as in the [[Multiple regression]] task). Otherwise, prune the set of equations as needed and solve as in the [[Reduced row echelon form]] task. +* Test your solution on the following data. Be sure to verify both that deconv(g,f) = h and deconv(g,h) = f and display the results in a human readable form. + +h = [-8,-9,-3,-1,-6,7]
+f = [-3,-6,-1,8,-6,3,-1,-9,-9,3,-2,5,2,-2,-7,-1]
+g = [24,75,71,-34,3,22,-45,23,245,25,52,25,-67,-96,96,31,55,36,29,-43,-7] +
diff --git a/Task/Deconvolution-1D/1META.yaml b/Task/Deconvolution-1D/1META.yaml new file mode 100644 index 0000000000..8d1c0603c8 --- /dev/null +++ b/Task/Deconvolution-1D/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Mathematical operations diff --git a/Task/Deconvolution-1D/BBC-BASIC/deconvolution-1d.bbc b/Task/Deconvolution-1D/BBC-BASIC/deconvolution-1d.bbc new file mode 100644 index 0000000000..592395c93b --- /dev/null +++ b/Task/Deconvolution-1D/BBC-BASIC/deconvolution-1d.bbc @@ -0,0 +1,38 @@ + *FLOAT 64 + DIM h(5), f(15), g(20) + h() = -8,-9,-3,-1,-6,7 + f() = -3,-6,-1,8,-6,3,-1,-9,-9,3,-2,5,2,-2,-7,-1 + g() = 24,75,71,-34,3,22,-45,23,245,25,52,25,-67,-96,96,31,55,36,29,-43,-7 + + PROCdeconv(g(), f(), x()) + PRINT "deconv(g,f) = " FNprintarray(x()) + x() -= h() : IF SUM(x()) <> 0 PRINT "Error!" + + PROCdeconv(g(), h(), y()) + PRINT "deconv(g,h) = " FNprintarray(y()) + y() -= f() : IF SUM(y()) <> 0 PRINT "Error!" + END + + DEF PROCdeconv(g(), f(), RETURN h()) + LOCAL f%, g%, i%, l%, n% + f% = DIM(f(),1) + 1 + g% = DIM(g(),1) + 1 + DIM h(g% - f%) + FOR n% = 0 TO g% - f% + h(n%) = g(n%) + IF n% < f% THEN l% = 0 ELSE l% = n% - f% + 1 + IF n% THEN + FOR i% = l% TO n% - 1 + h(n%) -= h(i%) * f(n% - i%) + NEXT + ENDIF + h(n%) /= f(0) + NEXT n% + ENDPROC + + DEF FNprintarray(a()) + LOCAL i%, a$ + FOR i% = 0 TO DIM(a(),1) + a$ += STR$(a(i%)) + ", " + NEXT + = LEFT$(LEFT$(a$)) diff --git a/Task/Deconvolution-1D/C/deconvolution-1d-1.c b/Task/Deconvolution-1D/C/deconvolution-1d-1.c new file mode 100644 index 0000000000..0d1cec01f9 --- /dev/null +++ b/Task/Deconvolution-1D/C/deconvolution-1d-1.c @@ -0,0 +1,92 @@ +#include +#include +#include +#include + +double PI; +typedef double complex cplx; + +void _fft(cplx buf[], cplx out[], int n, int step) +{ + if (step < n) { + _fft(out, buf, n, step * 2); + _fft(out + step, buf + step, n, step * 2); + + for (int i = 0; i < n; i += 2 * step) { + cplx t = cexp(-I * PI * i / n) * out[i + step]; + buf[i / 2] = out[i] + t; + buf[(i + n)/2] = out[i] - t; + } + } +} + +void fft(cplx buf[], int n) +{ + cplx out[n]; + for (int i = 0; i < n; i++) out[i] = buf[i]; + _fft(buf, out, n, 1); +} + +/* pad array length to power of two */ +cplx *pad_two(double g[], int len, int *ns) +{ + int n = 1; + if (*ns) n = *ns; + else while (n < len) n *= 2; + + cplx *buf = calloc(sizeof(cplx), n); + for (int i = 0; i < len; i++) buf[i] = g[i]; + *ns = n; + return buf; +} + +void deconv(double g[], int lg, double f[], int lf, double out[]) { + int ns = 0; + cplx *g2 = pad_two(g, lg, &ns); + cplx *f2 = pad_two(f, lf, &ns); + + fft(g2, ns); + fft(f2, ns); + + cplx h[ns]; + for (int i = 0; i < ns; i++) h[i] = g2[i] / f2[i]; + fft(h, ns); + + for (int i = 0; i >= lf - lg; i--) + out[-i] = h[(i + ns) % ns]/32; + free(g2); + free(f2); +} + +int main() +{ + PI = atan2(1,1) * 4; + double g[] = {24,75,71,-34,3,22,-45,23,245,25,52,25,-67,-96,96,31,55,36,29,-43,-7}; + double f[] = { -3,-6,-1,8,-6,3,-1,-9,-9,3,-2,5,2,-2,-7,-1 }; + double h[] = { -8,-9,-3,-1,-6,7 }; + + int lg = sizeof(g)/sizeof(double); + int lf = sizeof(f)/sizeof(double); + int lh = sizeof(h)/sizeof(double); + + double h2[lh]; + double f2[lf]; + + printf("f[] data is : "); + for (int i = 0; i < lf; i++) printf(" %g", f[i]); + printf("\n"); + + printf("deconv(g, h): "); + deconv(g, lg, h, lh, f2); + for (int i = 0; i < lf; i++) printf(" %g", f2[i]); + printf("\n"); + + printf("h[] data is : "); + for (int i = 0; i < lh; i++) printf(" %g", h[i]); + printf("\n"); + + printf("deconv(g, f): "); + deconv(g, lg, f, lf, h2); + for (int i = 0; i < lh; i++) printf(" %g", h2[i]); + printf("\n"); +} diff --git a/Task/Deconvolution-1D/C/deconvolution-1d-2.c b/Task/Deconvolution-1D/C/deconvolution-1d-2.c new file mode 100644 index 0000000000..eccf0bd94e --- /dev/null +++ b/Task/Deconvolution-1D/C/deconvolution-1d-2.c @@ -0,0 +1,4 @@ +f[] data is : -3 -6 -1 8 -6 3 -1 -9 -9 3 -2 5 2 -2 -7 -1 +deconv(g, h): -3 -6 -1 8 -6 3 -1 -9 -9 3 -2 5 2 -2 -7 -1 +h[] data is : -8 -9 -3 -1 -6 7 +deconv(g, f): -8 -9 -3 -1 -6 7 diff --git a/Task/Deconvolution-1D/Common-Lisp/deconvolution-1d-1.lisp b/Task/Deconvolution-1D/Common-Lisp/deconvolution-1d-1.lisp new file mode 100644 index 0000000000..25be2bf236 --- /dev/null +++ b/Task/Deconvolution-1D/Common-Lisp/deconvolution-1d-1.lisp @@ -0,0 +1,22 @@ +;; Assemble the mxn matrix A from the 2D row vector x. +(defun make-conv-matrix (x m n) + (let ((lx (cadr (array-dimensions x))) + (A (make-array `(,m ,n) :initial-element 0))) + + (loop for j from 0 to (- n 1) do + (loop for i from 0 to (- m 1) do + (setf (aref A i j) + (cond ((or (< i j) (>= i (+ j lx))) + 0) + ((and (>= i j) (< i (+ j lx))) + (aref x 0 (- i j))))))) + A)) + +;; Solve the overdetermined system A(f)*h=g by linear least squares. +(defun deconv (g f) + (let* ((lg (cadr (array-dimensions g))) + (lf (cadr (array-dimensions f))) + (lh (+ (- lg lf) 1)) + (A (make-conv-matrix f lg lh))) + + (lsqr A (mtp g)))) diff --git a/Task/Deconvolution-1D/Common-Lisp/deconvolution-1d-2.lisp b/Task/Deconvolution-1D/Common-Lisp/deconvolution-1d-2.lisp new file mode 100644 index 0000000000..739720615e --- /dev/null +++ b/Task/Deconvolution-1D/Common-Lisp/deconvolution-1d-2.lisp @@ -0,0 +1,29 @@ +(setf f #2A((-3 -6 -1 8 -6 3 -1 -9 -9 3 -2 5 2 -2 -7 -1))) +(setf h #2A((-8 -9 -3 -1 -6 7))) +(setf g #2A((24 75 71 -34 3 22 -45 23 245 25 52 25 -67 -96 96 31 55 36 29 -43 -7))) + +(deconv g f) +#2A((-8.0) + (-9.000000000000002) + (-2.999999999999999) + (-0.9999999999999997) + (-6.0) + (7.000000000000002)) + +(deconv g h) +#2A((-2.999999999999999) + (-6.000000000000001) + (-1.0000000000000002) + (8.0) + (-5.999999999999999) + (3.0000000000000004) + (-1.0000000000000004) + (-9.000000000000002) + (-9.0) + (2.9999999999999996) + (-1.9999999999999991) + (5.0) + (1.9999999999999996) + (-2.0000000000000004) + (-7.000000000000001) + (-0.9999999999999994)) diff --git a/Task/Deconvolution-1D/D/deconvolution-1d.d b/Task/Deconvolution-1D/D/deconvolution-1d.d new file mode 100644 index 0000000000..520e7fbfe8 --- /dev/null +++ b/Task/Deconvolution-1D/D/deconvolution-1d.d @@ -0,0 +1,23 @@ +T[] deconv(T)(in T[] g, in T[] f) pure nothrow { + int flen = f.length; + int glen = g.length; + auto result = new T[glen - flen + 1]; + foreach (int n, ref e; result) { + e = g[n]; + immutable lowerBound = (n >= flen) ? n - flen + 1 : 0; + foreach (i; lowerBound .. n) + e -= result[i] * f[n - i]; + e /= f[0]; + } + return result; +} + +void main() { + import std.stdio; + immutable h = [-8,-9,-3,-1,-6,7]; + immutable f = [-3,-6,-1,8,-6,3,-1,-9,-9,3,-2,5,2,-2,-7,-1]; + immutable g = [24,75,71,-34,3,22,-45,23,245,25,52,25,-67, + -96,96,31,55,36,29,-43,-7]; + writeln(deconv(g, f) == h, " ", deconv(g, f)); + writeln(deconv(g, h) == f, " ", deconv(g, h)); +} diff --git a/Task/Deconvolution-1D/Fortran/deconvolution-1d-1.f b/Task/Deconvolution-1D/Fortran/deconvolution-1d-1.f new file mode 100644 index 0000000000..5d0080e76e --- /dev/null +++ b/Task/Deconvolution-1D/Fortran/deconvolution-1d-1.f @@ -0,0 +1,73 @@ +! Build +! Windows: ifort /I "%IFORT_COMPILER11%\mkl\include\ia32" deconv1d.f90 "%IFORT_COMPILER11%\mkl\ia32\lib\*.lib" +! Linux: + +program deconv + ! Use gelsd from LAPACK95. + use mkl95_lapack, only : gelsd + + implicit none + real(8), allocatable :: g(:), href(:), A(:,:), f(:) + real(8), pointer :: h(:), r(:) + integer :: N + character(len=16) :: cbuff + integer :: i + intrinsic :: nint + + ! Allocate data arrays + allocate(g(21),f(16)) + g = [24,75,71,-34,3,22,-45,23,245,25,52,25,-67,-96,96,31,55,36,29,-43,-7] + f = [-3,-6,-1,8,-6,3,-1,-9,-9,3,-2,5,2,-2,-7,-1] + + ! Calculate deconvolution + h => deco(f, g) + + ! Check result against reference + N = size(h) + allocate(href(N)) + href = [-8,-9,-3,-1,-6,7] + cbuff = ' ' + write(cbuff,'(a,i0,a)') '(a,',N,'(i0,a),i0)' + if (any(abs(h-href) > 1.0d-4)) then + write(*,'(a)') 'deconv(f, g) - FAILED' + else + write(*,cbuff) 'deconv(f, g) = ',(nint(h(i)),', ',i=1,N-1),nint(h(N)) + end if + + ! Calculate deconvolution + r => deco(h, g) + + cbuff = ' ' + N = size(r) + write(cbuff,'(a,i0,a)') '(a,',N,'(i0,a),i0)' + if (any(abs(r-f) > 1.0d-4)) then + write(*,'(a)') 'deconv(h, g) - FAILED' + else + write(*,cbuff) 'deconv(h, g) = ',(nint(r(i)),', ',i=1,N-1),nint(r(N)) + end if + +contains + function deco(p, q) + real(8), pointer :: deco(:) + real(8), intent(in) :: p(:), q(:) + + real(8), allocatable, target :: r(:) + real(8), allocatable :: A(:,:) + integer :: N + + ! Construct derived arrays + N = size(q) - size(p) + 1 + allocate(A(size(q),N),r(size(q))) + A = 0.0d0 + do i=1,N + A(i:i+size(p)-1,i) = p + end do + + ! Invoke the LAPACK routine to do the work + r = q + call gelsd(A, r) + + deco => r(1:N) + end function deco + +end program deconv diff --git a/Task/Deconvolution-1D/Fortran/deconvolution-1d-2.f b/Task/Deconvolution-1D/Fortran/deconvolution-1d-2.f new file mode 100644 index 0000000000..cf4b4ce861 --- /dev/null +++ b/Task/Deconvolution-1D/Fortran/deconvolution-1d-2.f @@ -0,0 +1,2 @@ +deconv(f, g) = -8, -9, -3, -1, -6, 7 +deconv(h, g) = -3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1 diff --git a/Task/Deconvolution-1D/Go/deconvolution-1d-1.go b/Task/Deconvolution-1D/Go/deconvolution-1d-1.go new file mode 100644 index 0000000000..c92523d633 --- /dev/null +++ b/Task/Deconvolution-1D/Go/deconvolution-1d-1.go @@ -0,0 +1,30 @@ +package main + +import "fmt" + +func main() { + h := []float64{-8, -9, -3, -1, -6, 7} + f := []float64{-3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1} + g := []float64{24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, + 96, 31, 55, 36, 29, -43, -7} + fmt.Println(h) + fmt.Println(deconv(g, f)) + fmt.Println(f) + fmt.Println(deconv(g, h)) +} + +func deconv(g, f []float64) []float64 { + h := make([]float64, len(g)-len(f)+1) + for n := range h { + h[n] = g[n] + var lower int + if n >= len(f) { + lower = n - len(f) + 1 + } + for i := lower; i < n; i++ { + h[n] -= h[i] * f[n-i] + } + h[n] /= f[0] + } + return h +} diff --git a/Task/Deconvolution-1D/Go/deconvolution-1d-2.go b/Task/Deconvolution-1D/Go/deconvolution-1d-2.go new file mode 100644 index 0000000000..be8c0bd5ad --- /dev/null +++ b/Task/Deconvolution-1D/Go/deconvolution-1d-2.go @@ -0,0 +1,65 @@ +package main + +import ( + "fmt" + "math" + "math/cmplx" +) + +func main() { + h := []float64{-8, -9, -3, -1, -6, 7} + f := []float64{-3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1} + g := []float64{24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, + 96, 31, 55, 36, 29, -43, -7} + fmt.Printf("%.1f\n", h) + fmt.Printf("%.1f\n", deconv(g, f)) + fmt.Printf("%.1f\n", f) + fmt.Printf("%.1f\n", deconv(g, h)) +} + +func deconv(g, f []float64) []float64 { + n := 1 + for n < len(g) { + n *= 2 + } + g2 := make([]complex128, n) + for i, x := range g { + g2[i] = complex(x, 0) + } + f2 := make([]complex128, n) + for i, x := range f { + f2[i] = complex(x, 0) + } + gt := fft(g2) + ft := fft(f2) + for i := range gt { + gt[i] /= ft[i] + } + ht := fft(gt) + it := 1 / float64(n) + out := make([]float64, len(g)-len(f)+1) + out[0] = real(ht[0]) * it + for i := 1; i < len(out); i++ { + out[i] = real(ht[n-i]) * it + } + return out +} + +func fft(in []complex128) []complex128 { + out := make([]complex128, len(in)) + ditfft2(in, out, len(in), 1) + return out +} + +func ditfft2(x, y []complex128, n, s int) { + if n == 1 { + y[0] = x[0] + return + } + ditfft2(x, y, n/2, 2*s) + ditfft2(x[s:], y[n/2:], n/2, 2*s) + for k := 0; k < n/2; k++ { + tf := cmplx.Rect(1, -2*math.Pi*float64(k)/float64(n)) * y[k+n/2] + y[k], y[k+n/2] = y[k]+tf, y[k]-tf + } +} diff --git a/Task/Deconvolution-1D/Haskell/deconvolution-1d-1.hs b/Task/Deconvolution-1D/Haskell/deconvolution-1d-1.hs new file mode 100644 index 0000000000..8a530721db --- /dev/null +++ b/Task/Deconvolution-1D/Haskell/deconvolution-1d-1.hs @@ -0,0 +1,16 @@ +import Data.List + +h, f, g :: [Double] +h = [-8,-9,-3,-1,-6,7] +f = [-3,-6,-1,8,-6,3,-1,-9,-9,3,-2,5,2,-2,-7,-1] +g = [24,75,71,-34,3,22,-45,23,245,25,52,25,-67,-96,96,31,55,36,29,-43,-7] + +scale x ys = map (x*) ys + +deconv1d :: (Fractional a) => [a] -> [a] -> [a] +deconv1d xs ys = takeWhile (/=0) $ deconv xs ys + where [] `deconv` _ = [] + (0:xs) `deconv` (0:ys) = xs `deconv` ys + (x:xs) `deconv` (y:ys) = + q : zipWith (-) xs (scale q ys ++ repeat 0) `deconv` (y:ys) + where q = x / y diff --git a/Task/Deconvolution-1D/Haskell/deconvolution-1d-2.hs b/Task/Deconvolution-1D/Haskell/deconvolution-1d-2.hs new file mode 100644 index 0000000000..a3e7ab1b18 --- /dev/null +++ b/Task/Deconvolution-1D/Haskell/deconvolution-1d-2.hs @@ -0,0 +1,5 @@ +*Main> h == deconv1d g f +True + +*Main> f == deconv1d g h +True diff --git a/Task/Deconvolution-1D/Java/deconvolution-1d.java b/Task/Deconvolution-1D/Java/deconvolution-1d.java new file mode 100644 index 0000000000..daf4bd250a --- /dev/null +++ b/Task/Deconvolution-1D/Java/deconvolution-1d.java @@ -0,0 +1,26 @@ +import java.util.Arrays; + +public class Deconvolution1D { + public static double[] deconv(double[] f, double[] g) { + double[] h = new double[g.length - f.length + 1]; + for (int n = 0; n < h.length; n++) { + h[n] = g[n]; + int lower = Math.max(n - f.length + 1, 0); + for (int i = lower; i < n; i++) + h[n] -= h[i] * f[n-i]; + h[n] /= f[0]; + } + return h; + } + + public static void main(String[] args) { + double[] h = {-8, -9, -3, -1, -6, 7}; + double[] f = {-3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1}; + double[] g = {24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, + 96, 31, 55, 36, 29, -43, -7}; + System.out.println(Arrays.toString(h)); + System.out.println(Arrays.toString(deconv(g, f))); + System.out.println(Arrays.toString(f)); + System.out.println(Arrays.toString(deconv(g, h))); + } +} diff --git a/Task/Deconvolution-1D/Lua/deconvolution-1d-1.lua b/Task/Deconvolution-1D/Lua/deconvolution-1d-1.lua new file mode 100644 index 0000000000..4fd4ac91a9 --- /dev/null +++ b/Task/Deconvolution-1D/Lua/deconvolution-1d-1.lua @@ -0,0 +1,15 @@ +function deconvolve(f, g) + local h = setmetatable({}, {__index = function(self, n) + if n == 1 then self[1] = g[1] / f[1] + else + self[n] = g[n] + for i = 1, n - 1 do + self[n] = self[n] - self[i] * (f[n - i + 1] or 0) + end + self[n] = self[n] / f[1] + end + return self[n] + end}) + local _ = h[#g - #f + 1] + return setmetatable(h, nil) +end diff --git a/Task/Deconvolution-1D/Lua/deconvolution-1d-2.lua b/Task/Deconvolution-1D/Lua/deconvolution-1d-2.lua new file mode 100644 index 0000000000..5f024c8839 --- /dev/null +++ b/Task/Deconvolution-1D/Lua/deconvolution-1d-2.lua @@ -0,0 +1,5 @@ +local f = {-3,-6,-1,8,-6,3,-1,-9,-9,3,-2,5,2,-2,-7,-1} +local g = {24,75,71,-34,3,22,-45,23,245,25,52,25,-67,-96,96,31,55,36,29,-43,-7} +local h = {-8,-9,-3,-1,-6,7} +print(unpack(deconvolve(f, g))) --> -8 -9 -3 -1 -6 7 +print(unpack(deconvolve(h, g))) --> -3 -6 -1 8 -6 3 -1 -9 -9 3 -2 5 2 -2 -7 -1 diff --git a/Task/Deconvolution-1D/MATLAB/deconvolution-1d.m b/Task/Deconvolution-1D/MATLAB/deconvolution-1d.m new file mode 100644 index 0000000000..b6f618df59 --- /dev/null +++ b/Task/Deconvolution-1D/MATLAB/deconvolution-1d.m @@ -0,0 +1,14 @@ +>> h = [-8,-9,-3,-1,-6,7]; +>> g = [24,75,71,-34,3,22,-45,23,245,25,52,25,-67,-96,96,31,55,36,29,-43,-7]; +>> f = [-3,-6,-1,8,-6,3,-1,-9,-9,3,-2,5,2,-2,-7,-1]; +>> deconv(g,f) + +ans = + + -8.0000 -9.0000 -3.0000 -1.0000 -6.0000 7.0000 + +>> deconv(g,h) + +ans = + + -3 -6 -1 8 -6 3 -1 -9 -9 3 -2 5 2 -2 -7 -1 diff --git a/Task/Deconvolution-1D/PicoLisp/deconvolution-1d-1.l b/Task/Deconvolution-1D/PicoLisp/deconvolution-1d-1.l new file mode 100644 index 0000000000..83f80d064d --- /dev/null +++ b/Task/Deconvolution-1D/PicoLisp/deconvolution-1d-1.l @@ -0,0 +1,10 @@ +(load "@lib/math.l") + +(de deconv (G F) + (let A (pop 'F) + (make + (for (N . H) (head (- (length F)) G) + (for (I . M) (made) + (dec 'H + (*/ M (get F (- N I)) 1.0) ) ) + (link (*/ H 1.0 A)) ) ) ) ) diff --git a/Task/Deconvolution-1D/PicoLisp/deconvolution-1d-2.l b/Task/Deconvolution-1D/PicoLisp/deconvolution-1d-2.l new file mode 100644 index 0000000000..ce4fd9c5f5 --- /dev/null +++ b/Task/Deconvolution-1D/PicoLisp/deconvolution-1d-2.l @@ -0,0 +1,7 @@ +(setq + F (-3. -6. -1. 8. -6. 3. -1. -9. -9. 3. -2. 5. 2. -2. -7. -1.) + G (24. 75. 71. -34. 3. 22. -45. 23. 245. 25. 52. 25. -67. -96. 96. 31. 55. 36. 29. -43. -7.) + H (-8. -9. -3. -1. -6. 7.) ) + +(test H (deconv G F)) +(test F (deconv G H)) diff --git a/Task/Deconvolution-1D/Python/deconvolution-1d.py b/Task/Deconvolution-1D/Python/deconvolution-1d.py new file mode 100644 index 0000000000..fa4555e4cb --- /dev/null +++ b/Task/Deconvolution-1D/Python/deconvolution-1d.py @@ -0,0 +1,53 @@ +def ToReducedRowEchelonForm( M ): + if not M: return + lead = 0 + rowCount = len(M) + columnCount = len(M[0]) + for r in range(rowCount): + if lead >= columnCount: + return + i = r + while M[i][lead] == 0: + i += 1 + if i == rowCount: + i = r + lead += 1 + if columnCount == lead: + return + M[i],M[r] = M[r],M[i] + lv = M[r][lead] + M[r] = [ mrx / lv for mrx in M[r]] + for i in range(rowCount): + if i != r: + lv = M[i][lead] + M[i] = [ iv - lv*rv for rv,iv in zip(M[r],M[i])] + lead += 1 + +def pmtx(mtx): + print ('\n'.join(''.join(' %4s' % col for col in row) for row in mtx)) + +def convolve(f, h): + g = [0] * (len(f) + len(h) - 1) + for hindex, hval in enumerate(h): + for findex, fval in enumerate(f): + g[hindex + findex] += fval * hval + return g + +def deconvolve(g, f): + lenh = len(g) - len(f) + 1 + mtx = [[0 for x in range(lenh+1)] for y in g] + for hindex in range(lenh): + for findex, fval in enumerate(f): + gindex = hindex + findex + mtx[gindex][hindex] = fval + for gindex, gval in enumerate(g): + mtx[gindex][lenh] = gval + ToReducedRowEchelonForm( mtx ) + return [mtx[i][lenh] for i in range(lenh)] # h + +if __name__ == '__main__': + h = [-8,-9,-3,-1,-6,7] + f = [-3,-6,-1,8,-6,3,-1,-9,-9,3,-2,5,2,-2,-7,-1] + g = [24,75,71,-34,3,22,-45,23,245,25,52,25,-67,-96,96,31,55,36,29,-43,-7] + assert convolve(f,h) == g + assert deconvolve(g, f) == h diff --git a/Task/Deconvolution-1D/R/deconvolution-1d-1.r b/Task/Deconvolution-1D/R/deconvolution-1d-1.r new file mode 100644 index 0000000000..f84997524f --- /dev/null +++ b/Task/Deconvolution-1D/R/deconvolution-1d-1.r @@ -0,0 +1,17 @@ +conv <- function(a, b) { + p <- length(a) + q <- length(b) + n <- p + q - 1 + r <- nextn(n, f=2) + y <- fft(fft(c(a, rep(0, r-p))) * fft(c(b, rep(0, r-q))), inverse=TRUE)/r + y[1:n] +} + +deconv <- function(a, b) { + p <- length(a) + q <- length(b) + n <- p - q + 1 + r <- nextn(max(p, q), f=2) + y <- fft(fft(c(a, rep(0, r-p))) / fft(c(b, rep(0, r-q))), inverse=TRUE)/r + return(y[1:n]) +} diff --git a/Task/Deconvolution-1D/R/deconvolution-1d-2.r b/Task/Deconvolution-1D/R/deconvolution-1d-2.r new file mode 100644 index 0000000000..d936fed9da --- /dev/null +++ b/Task/Deconvolution-1D/R/deconvolution-1d-2.r @@ -0,0 +1,7 @@ +h <- c(-8,-9,-3,-1,-6,7) +f <- c(-3,-6,-1,8,-6,3,-1,-9,-9,3,-2,5,2,-2,-7,-1) +g <- c(24,75,71,-34,3,22,-45,23,245,25,52,25,-67,-96,96,31,55,36,29,-43,-7) + +max(abs(conv(f,h) - g)) +max(abs(deconv(g,f) - h)) +max(abs(deconv(g,h) - f)) diff --git a/Task/Deconvolution-1D/R/deconvolution-1d-3.r b/Task/Deconvolution-1D/R/deconvolution-1d-3.r new file mode 100644 index 0000000000..9f6f272d5d --- /dev/null +++ b/Task/Deconvolution-1D/R/deconvolution-1d-3.r @@ -0,0 +1 @@ +conv(a, b) == convolve(a, rev(b), type="open") diff --git a/Task/Deconvolution-1D/Tcl/deconvolution-1d-1.tcl b/Task/Deconvolution-1D/Tcl/deconvolution-1d-1.tcl new file mode 100644 index 0000000000..a5a4bbff7e --- /dev/null +++ b/Task/Deconvolution-1D/Tcl/deconvolution-1d-1.tcl @@ -0,0 +1,100 @@ +package require Tcl 8.5 +namespace eval 1D { + namespace ensemble create; # Will be same name as namespace + namespace export convolve deconvolve + # Access core language math utility commands + namespace path {::tcl::mathfunc ::tcl::mathop} + + # Utility for converting a matrix to Reduced Row Echelon Form + # From http://rosettacode.org/wiki/Reduced_row_echelon_form#Tcl + proc toRREF {m} { + set lead 0 + set rows [llength $m] + set cols [llength [lindex $m 0]] + for {set r 0} {$r < $rows} {incr r} { + if {$cols <= $lead} { + break + } + set i $r + while {[lindex $m $i $lead] == 0} { + incr i + if {$rows == $i} { + set i $r + incr lead + if {$cols == $lead} { + # Tcl can't break out of nested loops + return $m + } + } + } + # swap rows i and r + foreach j [list $i $r] row [list [lindex $m $r] [lindex $m $i]] { + lset m $j $row + } + # divide row r by m(r,lead) + set val [lindex $m $r $lead] + for {set j 0} {$j < $cols} {incr j} { + lset m $r $j [/ [double [lindex $m $r $j]] $val] + } + + for {set i 0} {$i < $rows} {incr i} { + if {$i != $r} { + # subtract m(i,lead) multiplied by row r from row i + set val [lindex $m $i $lead] + for {set j 0} {$j < $cols} {incr j} { + lset m $i $j \ + [- [lindex $m $i $j] [* $val [lindex $m $r $j]]] + } + } + } + incr lead + } + return $m + } + + # How to apply a 1D convolution of two "functions" + proc convolve {f h} { + set g [lrepeat [+ [llength $f] [llength $h] -1] 0] + set fi -1 + foreach fv $f { + incr fi + set hi -1 + foreach hv $h { + set gi [+ $fi [incr hi]] + lset g $gi [+ [lindex $g $gi] [* $fv $hv]] + } + } + return $g + } + + # How to apply a 1D deconvolution of two "functions" + proc deconvolve {g f} { + # Compute the length of the result vector + set hlen [- [llength $g] [llength $f] -1] + + # Build a matrix of equations to solve + set matrix {} + set i -1 + foreach gv $g { + lappend matrix [list {*}[lrepeat $hlen 0] $gv] + set j [incr i] + foreach fv $f { + if {$j < 0} { + break + } elseif {$j < $hlen} { + lset matrix $i $j $fv + } + incr j -1 + } + } + + # Convert to RREF, solving the system of simultaneous equations + set reduced [toRREF $matrix] + + # Extract the deconvolution from the last column of the reduced matrix + for {set i 0} {$i<$hlen} {incr i} { + lappend result [lindex $reduced $i end] + } + return $result + } +} diff --git a/Task/Deconvolution-1D/Tcl/deconvolution-1d-2.tcl b/Task/Deconvolution-1D/Tcl/deconvolution-1d-2.tcl new file mode 100644 index 0000000000..4d85bd02b6 --- /dev/null +++ b/Task/Deconvolution-1D/Tcl/deconvolution-1d-2.tcl @@ -0,0 +1,18 @@ +# Simple pretty-printer +proc pp {name nlist} { + set sep "" + puts -nonewline "$name = \[" + foreach n $nlist { + puts -nonewline [format %s%g $sep $n] + set sep , + } + puts "\]" +} + +set h {-8 -9 -3 -1 -6 7} +set f {-3 -6 -1 8 -6 3 -1 -9 -9 3 -2 5 2 -2 -7 -1} +set g {24 75 71 -34 3 22 -45 23 245 25 52 25 -67 -96 96 31 55 36 29 -43 -7} + +pp "deconv(g,f) = h" [1D deconvolve $g $f] +pp "deconv(g,h) = f" [1D deconvolve $g $h] +pp " conv(f,h) = g" [1D convolve $f $h] diff --git a/Task/Deconvolution-2D+/0DESCRIPTION b/Task/Deconvolution-2D+/0DESCRIPTION new file mode 100644 index 0000000000..ae67bde8d8 --- /dev/null +++ b/Task/Deconvolution-2D+/0DESCRIPTION @@ -0,0 +1,79 @@ +This task is a straightforward generalization of [[Deconvolution/1D]] to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in \mathit d dimensions of two functions + +:H,F:\mathbb{Z}^d\rightarrow\mathbb{R} + +taking \mathit d-tuples of integers to real numbers as the function + +:G:\mathbb{Z}^d\rightarrow\mathbb{R} + +also taking \mathit d-tuples of integers to reals and satisfying + +:G(n_0, \dots, n_{d-1})=\sum_{m_0=-\infty}^{\infty}\dots\sum_{m_{d-1}=-\infty}^{\infty}F(m_0, \dots, m_{d-1})H(n_0-m_0, \dots, n_{d-1}-m_{d-1}) + +for all \mathit d-tuples of integers (n_0, \dots, n_{d-1})\in\mathbb{Z}^d. Assume +\mathit F and \mathit H (and therefore \mathit G) are non-zero over only a finite domain bounded by the origin, hence possible to represent as finite multi-dimensional arrays or nested lists \mathit f, \mathit h, and \mathit g. + +For this task, implement a function (or method, procedure, subroutine, etc.) deconv to perform ''deconvolution'' (i.e., the ''inverse'' of convolution) by solving for \mathit{h} given \mathit{f} and \mathit{g}. (See [[Deconvolution/1D]] for details.) +* The function should work for \mathit{g} of arbitrary length in each dimension (i.e., not hard coded or constant) and \mathit{f} of any length up to that of \mathit{g} in the corresponding dimension. +* The deconv function will need to be parameterized by the dimension \mathit d unless the dimension can be inferred from the data structures representing \mathit g and \mathit f. +* There may be more equations than unknowns. If convenient, use a function from a [http://www.netlib.org/lapack/lug/node27.html library] that finds the best fitting solution to an overdetermined system of linear equations (as in the [[Multiple regression]] task). Otherwise, prune the set of equations as needed and solve as in the [[Reduced row echelon form]] task. +* Debug your solution using [http://rosettacode.org/mw/index.php?title=Deconvolution/2D%2B/Test_data&action=raw this test data], of which a portion is shown below. Be sure to verify both that the deconvolution of \mathit g with \mathit f is \mathit h and that the deconvolution of \mathit g with \mathit h is \mathit f. Display the results in a human readable form for the three dimensional case ''only''. + +dimension 1: +
+h: [-8, 2, -9, -2, 9, -8, -2]
+f: [ 6, -9, -7, -5]
+g: [-48, 84, -16, 95, 125, -70, 7, 29, 54, 10]
+
+dimension 2: +
+h: [
+      [-8, 1, -7, -2, -9, 4],
+      [4, 5, -5, 2, 7, -1],
+      [-6, -3, -3, -6, 9, 5]]
+f: [
+      [-5, 2, -2, -6, -7],
+      [9, 7, -6, 5, -7],
+      [1, -1, 9, 2, -7],
+      [5, 9, -9, 2, -5],
+      [-8, 5, -2, 8, 5]]
+g: [
+      [40, -21, 53, 42, 105, 1, 87, 60, 39, -28],
+      [-92, -64, 19, -167, -71, -47, 128, -109, 40, -21],
+      [58, 85, -93, 37, 101, -14, 5, 37, -76, -56],
+      [-90, -135, 60, -125, 68, 53, 223, 4, -36, -48],
+      [78, 16, 7, -199, 156, -162, 29, 28, -103, -10],
+      [-62, -89, 69, -61, 66, 193, -61, 71, -8, -30],
+      [48, -6, 21, -9, -150, -22, -56, 32, 85, 25]]
+
+dimension 3: +
+h: [
+      [[-6, -8, -5, 9], [-7, 9, -6, -8], [2, -7, 9, 8]],
+      [[7, 4, 4, -6], [9, 9, 4, -4], [-3, 7, -2, -3]]]
+f: [
+      [[-9, 5, -8], [3, 5, 1]],
+      [[-1, -7, 2], [-5, -6, 6]],
+      [[8, 5, 8],[-2, -6, -4]]]
+g: [
+      [
+         [54, 42, 53, -42, 85, -72],
+         [45, -170, 94, -36, 48, 73],
+         [-39, 65, -112, -16, -78, -72],
+         [6, -11, -6, 62, 49, 8]],
+      [
+         [-57, 49, -23, 52, -135, 66],
+         [-23, 127, -58, -5, -118, 64],
+         [87, -16, 121, 23, -41, -12],
+         [-19, 29, 35, -148, -11, 45]],
+      [
+         [-55, -147, -146, -31, 55, 60],
+         [-88, -45, -28, 46, -26, -144],
+         [-12, -107, -34, 150, 249, 66],
+         [11, -15, -34, 27, -78, -50]],
+      [
+         [56, 67, 108, 4, 2, -48],
+         [58, 67, 89, 32, 32, -8],
+         [-42, -31, -103, -30, -23, -8],
+         [6, 4, -26, -10, 26, 12]]]
+
diff --git a/Task/Deconvolution-2D+/1META.yaml b/Task/Deconvolution-2D+/1META.yaml new file mode 100644 index 0000000000..8d1c0603c8 --- /dev/null +++ b/Task/Deconvolution-2D+/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Mathematical operations diff --git a/Task/Deconvolution-2D+/C/deconvolution-2d+-1.c b/Task/Deconvolution-2D+/C/deconvolution-2d+-1.c new file mode 100644 index 0000000000..596966f15f --- /dev/null +++ b/Task/Deconvolution-2D+/C/deconvolution-2d+-1.c @@ -0,0 +1,218 @@ +#include +#include +#include +#include + +double PI; +typedef double complex cplx; + +void _fft(cplx buf[], cplx out[], int n, int step) +{ + if (step < n) { + _fft(out, buf, n, step * 2); + _fft(out + step, buf + step, n, step * 2); + + for (int i = 0; i < n; i += 2 * step) { + cplx t = cexp(-I * PI * i / n) * out[i + step]; + buf[i / 2] = out[i] + t; + buf[(i + n)/2] = out[i] - t; + } + } +} + +void fft(cplx buf[], int n) +{ + cplx out[n]; + for (int i = 0; i < n; i++) out[i] = buf[i]; + _fft(buf, out, n, 1); +} + +/* pad array length to power of two */ +cplx *pad_two(double g[], int len, int *ns) +{ + int n = 1; + if (*ns) n = *ns; + else while (n < len) n *= 2; + + cplx *buf = calloc(sizeof(cplx), n); + for (int i = 0; i < len; i++) buf[i] = g[i]; + *ns = n; + return buf; +} + +void deconv(double g[], int lg, double f[], int lf, double out[], int row_len) { + int ns = 0; + cplx *g2 = pad_two(g, lg, &ns); + cplx *f2 = pad_two(f, lf, &ns); + + fft(g2, ns); + fft(f2, ns); + + cplx h[ns]; + for (int i = 0; i < ns; i++) h[i] = g2[i] / f2[i]; + fft(h, ns); + + for (int i = 0; i < ns; i++) { + if (cabs(creal(h[i])) < 1e-10) + h[i] = 0; + } + + for (int i = 0; i > lf - lg - row_len; i--) + out[-i] = h[(i + ns) % ns]/32; + free(g2); + free(f2); +} + +double* unpack2(void *m, int rows, int len, int to_len) +{ + double *buf = calloc(sizeof(double), rows * to_len); + for (int i = 0; i < rows; i++) + for (int j = 0; j < len; j++) + buf[i * to_len + j] = ((double(*)[len])m)[i][j]; + return buf; +} + +void pack2(double * buf, int rows, int from_len, int to_len, void *out) +{ + for (int i = 0; i < rows; i++) + for (int j = 0; j < to_len; j++) + ((double(*)[to_len])out)[i][j] = buf[i * from_len + j] / 4; +} + +void deconv2(void *g, int row_g, int col_g, void *f, int row_f, int col_f, void *out) { + double *g2 = unpack2(g, row_g, col_g, col_g); + double *f2 = unpack2(f, row_f, col_f, col_g); + + double ff[(row_g - row_f + 1) * col_g]; + deconv(g2, row_g * col_g, f2, row_f * col_g, ff, col_g); + pack2(ff, row_g - row_f + 1, col_g, col_g - col_f + 1, out); + + free(g2); + free(f2); +} + +double* unpack3(void *m, int x, int y, int z, int to_y, int to_z) +{ + double *buf = calloc(sizeof(double), x * to_y * to_z); + for (int i = 0; i < x; i++) + for (int j = 0; j < y; j++) { + for (int k = 0; k < z; k++) + buf[(i * to_y + j) * to_z + k] = + ((double(*)[y][z])m)[i][j][k]; + } + return buf; +} + +void pack3(double * buf, int x, int y, int z, int to_y, int to_z, void *out) +{ + for (int i = 0; i < x; i++) + for (int j = 0; j < to_y; j++) + for (int k = 0; k < to_z; k++) + ((double(*)[to_y][to_z])out)[i][j][k] = + buf[(i * y + j) * z + k] / 4; +} + +void deconv3(void *g, int gx, int gy, int gz, void *f, int fx, int fy, int fz, void *out) { + double *g2 = unpack3(g, gx, gy, gz, gy, gz); + double *f2 = unpack3(f, fx, fy, fz, gy, gz); + + double ff[(gx - fx + 1) * gy * gz]; + deconv(g2, gx * gy * gz, f2, fx * gy * gz, ff, gy * gz); + pack3(ff, gx - fx + 1, gy, gz, gy - fy + 1, gz - fz + 1, out); + + free(g2); + free(f2); +} + +int main() +{ + PI = atan2(1,1) * 4; + double h[2][3][4] = { + {{-6, -8, -5, 9}, {-7, 9, -6, -8}, { 2, -7, 9, 8}}, + {{ 7, 4, 4, -6}, { 9, 9, 4, -4}, {-3, 7, -2, -3}} + }; + int hx = 2, hy = 3, hz = 4; + double f[3][2][3] = { {{-9, 5, -8}, { 3, 5, 1}}, + {{-1, -7, 2}, {-5, -6, 6}}, + {{ 8, 5, 8}, {-2, -6, -4}} }; + int fx = 3, fy = 2, fz = 3; + double g[4][4][6] = { + { { 54, 42, 53, -42, 85, -72}, { 45,-170, 94, -36, 48, 73}, + {-39, 65,-112, -16, -78, -72}, { 6, -11, -6, 62, 49, 8} }, + { {-57, 49, -23, 52, -135, 66},{-23, 127, -58, -5, -118, 64}, + { 87, -16, 121, 23, -41, -12},{-19, 29, 35,-148, -11, 45} }, + { {-55, -147, -146, -31, 55, 60},{-88, -45, -28, 46, -26,-144}, + {-12, -107, -34, 150, 249, 66},{ 11, -15, -34, 27, -78, -50} }, + { { 56, 67, 108, 4, 2,-48},{ 58, 67, 89, 32, 32, -8}, + {-42, -31,-103, -30,-23, -8},{ 6, 4, -26, -10, 26, 12} + } + }; + int gx = 4, gy = 4, gz = 6; + + double h2[gx - fx + 1][gy - fy + 1][gz - fz + 1]; + deconv3(g, gx, gy, gz, f, fx, fy, fz, h2); + printf("deconv3(g, f):\n"); + for (int i = 0; i < gx - fx + 1; i++) { + for (int j = 0; j < gy - fy + 1; j++) { + for (int k = 0; k < gz - fz + 1; k++) + printf("%g ", h2[i][j][k]); + printf("\n"); + } + if (i < gx - fx) printf("\n"); + } + + double f2[gx - hx + 1][gy - hy + 1][gz - hz + 1]; + deconv3(g, gx, gy, gz, h, hx, hy, hz, f2); + printf("\ndeconv3(g, h):\n"); + for (int i = 0; i < gx - hx + 1; i++) { + for (int j = 0; j < gy - hy + 1; j++) { + for (int k = 0; k < gz - hz + 1; k++) + printf("%g ", f2[i][j][k]); + printf("\n"); + } + if (i < gx - hx) printf("\n"); + } +} + +/* two-D case; since task doesn't require showing it, it's commented out */ +/* +int main() +{ + PI = atan2(1,1) * 4; + double h[][6] = { {-8, 1, -7, -2, -9, 4}, + {4, 5, -5, 2, 7, -1}, + {-6, -3, -3, -6, 9, 5} }; + int hr = 3, hc = 6; + + double f[][5] = { {-5, 2, -2, -6, -7}, + {9, 7, -6, 5, -7}, + {1, -1, 9, 2, -7}, + {5, 9, -9, 2, -5}, + {-8, 5, -2, 8, 5} }; + int fr = 5, fc = 5; + double g[][10] = { + {40, -21, 53, 42, 105, 1, 87, 60, 39, -28}, + {-92, -64, 19, -167, -71, -47, 128, -109, 40, -21}, + {58, 85, -93, 37, 101, -14, 5, 37, -76, -56}, + {-90, -135, 60, -125, 68, 53, 223, 4, -36, -48}, + {78, 16, 7, -199, 156, -162, 29, 28, -103, -10}, + {-62, -89, 69, -61, 66, 193, -61, 71, -8, -30}, + {48, -6, 21, -9, -150, -22, -56, 32, 85, 25} }; + int gr = 7, gc = 10; + + double h2[gr - fr + 1][gc - fc + 1]; + deconv2(g, gr, gc, f, fr, fc, h2); + for (int i = 0; i < gr - fr + 1; i++) { + for (int j = 0; j < gc - fc + 1; j++) + printf(" %g", h2[i][j]); + printf("\n"); + } + + double f2[gr - hr + 1][gc - hc + 1]; + deconv2(g, gr, gc, h, hr, hc, f2); + for (int i = 0; i < gr - hr + 1; i++) { + for (int j = 0; j < gc - hc + 1; j++) + printf(" %g", f2[i][j]); + printf("\n"); + } +}*/ diff --git a/Task/Deconvolution-2D+/C/deconvolution-2d+-2.c b/Task/Deconvolution-2D+/C/deconvolution-2d+-2.c new file mode 100644 index 0000000000..089571271d --- /dev/null +++ b/Task/Deconvolution-2D+/C/deconvolution-2d+-2.c @@ -0,0 +1,18 @@ +deconv3(g, f): +-6 -8 -5 9 +-7 9 -6 -8 +2 -7 9 8 + +7 4 4 -6 +9 9 4 -4 +-3 7 -2 -3 + +deconv3(g, h): +-9 5 -8 +3 5 1 + +-1 -7 2 +-5 -6 6 + +8 5 8 +-2 -6 -4 diff --git a/Task/Deconvolution-2D+/D/deconvolution-2d+.d b/Task/Deconvolution-2D+/D/deconvolution-2d+.d new file mode 100644 index 0000000000..4e58b189f3 --- /dev/null +++ b/Task/Deconvolution-2D+/D/deconvolution-2d+.d @@ -0,0 +1,185 @@ +import std.stdio, std.conv, std.array, std.algorithm, std.numeric, + std.range; + +class M(T) { + private size_t[] dim; + private size_t[] subsize; + private T[] d; + + this(size_t[] dimension ...) { + setDimension(dimension); + d[] = 0; // init each entry to zero; + } + + M!T dup() { + M!T m = new M!T(dim); + return m.set1DArray(d); + } + + M!T setDimension(size_t[] dimension ...) { + foreach (e; dimension) + assert(e > 0, "no zero dimension"); + dim = dimension.dup; + subsize = dim.dup; + foreach (i; 0 .. dim.length) + subsize[i] = reduce!"a*b"(1, dim[i + 1 .. $]); + auto dlength = dim[0] * subsize[0]; + if (d.length != dlength) + d = new T[dlength]; + return this; + } + + M!T set1DArray(T[] t ...) { + auto minLen = min(t.length, d.length); + d[] = 0; + d[0 .. minLen] = t[0 .. minLen]; + return this; + } + + size_t[] seq2idx(size_t seq) { + size_t acc = seq, tmp; + size_t[] idx; + foreach (e; subsize) { + idx ~= tmp = acc / e; + acc = acc - tmp * e; // same as % (mod) e; + } + return idx; + } + + size_t size() const @property { return d.length; } + + size_t rank() const @property { return dim.length; } + + size_t[] shape() const @property { return dim.dup; } + + T[] raw() const @property { return d.dup; } + + bool checkBound(size_t[] idx ...) const { + if (idx.length > dim.length) + return false; + foreach (i, dm; idx) + if (dm >= dim[i]) + return false; + return true; + } + + T opIndex(size_t[] idx ...) { + assert(checkBound(idx), "OOPS"); + return d[dotProduct(idx, subsize)]; + } + + T opIndexAssign(T v, size_t[] idx ...) { + assert(checkBound(idx), "OOPS"); + d[dotProduct(idx, subsize)] = v; + return v; + } + + override bool opEquals(Object o) { + auto rhs = to!(M!T)(o); + return dim == rhs.dim && d == rhs.d; + } + + int opApply(int delegate(ref size_t[]) dg) { + size_t[] yieldIdx; + foreach (i; 0 .. d.length) { + yieldIdx = seq2idx(i); + if (dg(yieldIdx)) + break; + } + return 0; + } + + int opApply(int delegate(ref size_t[], ref T) dg) { + size_t idx1d = 0; + foreach (size_t[] idx; this) { + if (dg(idx, d[idx1d++])) + break; + } + return 0; + } + + M!T convolute(M!T rhs) { // _this_ is h, rhs is f, output g + auto dm = dim.dup; + dm[] += rhs.dim[] - 1; + M!T m = new M!T(dm); // dm will be reused as m's idx + auto bound = m.size; + foreach (i; 0 .. d.length) { + auto thisIdx = seq2idx(i); + foreach (j; 0 .. rhs.d.length) { + dm[] = thisIdx[] + rhs.seq2idx(j)[]; + auto midx1d = dotProduct(dm, m.subsize); + if ( midx1d < bound) + m.d[midx1d] += d[i] * rhs.d[j]; + else + break; // bound reach, ok to break + } + } + return m; + } + + M!T deconvolute(M!T rhs) { // _this_ is g, rhs is f, output is h + auto dm = dim.dup; + foreach (i, e; dm) + assert(e + 1 > rhs.dim[i], + "deconv : dimensions is zero or negative"); + dm[] -= (rhs.dim[] - 1); + M!T m = new M!T(dm); // dm will be reused as rhs' idx + + foreach (i; 0 .. m.size) { + auto idx = m.seq2idx(i); + m.d[i] = this[idx]; + foreach (j; 0 .. i) { + auto jdx = m.seq2idx(j); + dm[] = idx[] - jdx[]; + if (rhs.checkBound(dm)) + m.d[i] -= m.d[j] * rhs[dm]; + } + m.d[i] /= rhs.d[0]; + } + return m; + } + + override string toString() { return to!string(d); } +} + +auto fold(T)(T[] arr, ref size_t[] d) { + if (d.length == 0) + d ~= arr.length; + static if (is(T U : U[])) { // is arr an array of arrays? + assert(arr.length > 0, "no empty dimension"); + d ~= arr[0].length; + foreach (e; arr) + assert(e.length == arr[0].length, "not rectangular"); + return fold(reduce!q{a ~ b}(arr), d); + } else { + assert(arr.length == reduce!q{a * b}(d), "not same size"); + return arr; + } +} + +auto arr2M(T)(T a) { + size_t[] dm; + auto d = fold(a, dm); + alias ElementType!(typeof(d)) E; + auto m = new M!E(dm); + m.set1DArray(d); + return m; +} + +void main() { + alias M!int Mi; + auto hh = [[[-6, -8, -5, 9], [-7, 9, -6, -8], [2, -7, 9, 8]], + [[7, 4, 4, -6], [9, 9, 4, -4], [-3, 7, -2, -3]]]; + auto ff = [[[-9, 5, -8], [3, 5, 1]],[[-1, -7, 2], [-5, -6, 6]], + [[8, 5, 8],[-2, -6, -4]]]; + auto h = arr2M(hh); + auto f = arr2M(ff); + + auto g = h.convolute(f); + + writeln("g == f convolute h ? ", g == f.convolute(h)); + writeln("h == g deconv f ? ", h == g.deconvolute(f)); + writeln("f == g deconv h ? ", f == g.deconvolute(h)); + writeln(" f = ", f); + writeln("g deconv h = ", g.deconvolute(h)); +} diff --git a/Task/Deconvolution-2D+/Tcl/deconvolution-2d+-1.tcl b/Task/Deconvolution-2D+/Tcl/deconvolution-2d+-1.tcl new file mode 100644 index 0000000000..90ad044cd8 --- /dev/null +++ b/Task/Deconvolution-2D+/Tcl/deconvolution-2d+-1.tcl @@ -0,0 +1,165 @@ +package require Tcl 8.5 +namespace path {::tcl::mathfunc ::tcl::mathop} + +# Utility to extract the number of dimensions of a matrix +proc rank m { + for {set rank 0} {[llength $m] > 1} {incr rank} { + set m [lindex $m 0] + } + return $rank +} + +# Utility to get the size of a matrix, as a list of lengths +proc size m { + set r [rank $m] + set index {} + set size {} + for {set i 0} {$i<$r} {incr i} { + lappend size [llength [lindex $m $index]] + lappend index 0 + } + return $size +} + +# Utility that iterates over the space of coordinates within a matrix. +# +# Arguments: +# var The name of the variable (in the caller's context) to set to each +# coordinate. +# size The size of matrix whose coordinates are to be iterated over. +# body The script to evaluate (in the caller's context) for each coordinate, +# with the variable named by 'var' set to the coordinate for the particular +# iteration. +proc loopcoords {var size body} { + upvar 1 $var v + set count [* {*}$size] + for {set i 0} {$i < $count} {incr i} { + set coords {} + set j $i + for {set s $size} {[llength $s]} {set s [lrange $s 0 end-1]} { + set dimension [lindex $s end] + lappend coords [expr {$j % $dimension}] + set j [expr {$j / $dimension}] + } + set v [lreverse $coords] + uplevel 1 $body + } +} + +# Assembles a row, which is one of the simultaneous equations that needs +# to be solved by reducing the whole set to reduced row echelon form. Note +# that each row describes the equation for a single cell of the 'g' function. +# +# Arguments: +# g The "result" matrix of the convolution being undone. +# h The known "input" matrix of the convolution being undone. +# gs The size descriptor of 'g', passed as argument for efficiency. +# gc The coordinate in 'g' that we are generating the equation for. +# fs The size descriptor of 'f', passed as argument for efficiency. +# hs The size descriptor of 'h' (the unknown "input" matrix), passed +# as argument for efficiency. +proc row {g f gs gc fs hs} { + loopcoords hc $hs { + set fc {} + set ok 1 + foreach a $gc b $fs c $hc { + set d [expr {$a - $c}] + if {$d < 0 || $d >= $b} { + set ok 0 + break + } + lappend fc $d + } + if {$ok} { + lappend row [lindex $f $fc] + } else { + lappend row 0 + } + } + return [lappend row [lindex $g $gc]] +} + +# Utility for converting a matrix to Reduced Row Echelon Form +# From http://rosettacode.org/wiki/Reduced_row_echelon_form#Tcl +proc toRREF {m} { + set lead 0 + set rows [llength $m] + set cols [llength [lindex $m 0]] + for {set r 0} {$r < $rows} {incr r} { + if {$cols <= $lead} { + break + } + set i $r + while {[lindex $m $i $lead] == 0} { + incr i + if {$rows == $i} { + set i $r + incr lead + if {$cols == $lead} { + # Tcl can't break out of nested loops + return $m + } + } + } + # swap rows i and r + foreach j [list $i $r] row [list [lindex $m $r] [lindex $m $i]] { + lset m $j $row + } + # divide row r by m(r,lead) + set val [lindex $m $r $lead] + for {set j 0} {$j < $cols} {incr j} { + lset m $r $j [/ [double [lindex $m $r $j]] $val] + } + + for {set i 0} {$i < $rows} {incr i} { + if {$i != $r} { + # subtract m(i,lead) multiplied by row r from row i + set val [lindex $m $i $lead] + for {set j 0} {$j < $cols} {incr j} { + lset m $i $j \ + [- [lindex $m $i $j] [* $val [lindex $m $r $j]]] + } + } + } + incr lead + } + return $m +} + +# Deconvolve a pair of matrixes. Solves for 'h' such that 'g = f convolve h'. +# +# Arguments: +# g The matrix of data to be deconvolved. +# f The matrix describing the convolution to be removed. +# type Optional description of the type of data expected. Defaults to 32-bit +# integer data; use 'double' for floating-point data. +proc deconvolve {g f {type int}} { + # Compute the sizes of the various matrixes involved. + set gsize [size $g] + set fsize [size $f] + foreach gs $gsize fs $fsize { + lappend hsize [expr {$gs - $fs + 1}] + } + + # Prepare the set of simultaneous equations to solve + set toSolve {} + loopcoords coords $gsize { + lappend toSolve [row $g $f $gsize $coords $fsize $hsize] + } + + # Solve the equations + set solved [toRREF $toSolve] + + # Make a dummy result matrix of the right size + set h 0 + foreach hs [lreverse $hsize] {set h [lrepeat $hs $h]} + + # Fill the results from the equations into the result matrix + set idx 0 + loopcoords coords $hsize { + lset h $coords [$type [lindex $solved $idx end]] + incr idx + } + + return $h +} diff --git a/Task/Deconvolution-2D+/Tcl/deconvolution-2d+-2.tcl b/Task/Deconvolution-2D+/Tcl/deconvolution-2d+-2.tcl new file mode 100644 index 0000000000..2e109b92e3 --- /dev/null +++ b/Task/Deconvolution-2D+/Tcl/deconvolution-2d+-2.tcl @@ -0,0 +1,52 @@ +# A pretty-printer +proc pretty matrix { + set size [rank $matrix] + if {$size == 1} { + return \[[join $matrix ", "]\] + } elseif {$size == 2} { + set out "" + foreach row $matrix { + append out " " [pretty $row] ",\n" + } + return \[[string trimleft [string trimright $out ,\n]]\] + } + set rowout {} + foreach row $matrix {append rowout [pretty $row] ,\n} + set rowout2 {} + foreach row [split [string trimright $rowout ,\n] \n] { + append rowout2 " " $row \n + } + return \[\n[string trimright $rowout2 \n]\n\] +} + +# The 3D test data +set f { + {{-9 5 -8} {3 5 1}} + {{-1 -7 2} {-5 -6 6}} + {{8 5 8} {-2 -6 -4}} +} +set g { + { + {54 42 53 -42 85 -72} + {45 -170 94 -36 48 73} + {-39 65 -112 -16 -78 -72} + {6 -11 -6 62 49 8}} + { + {-57 49 -23 52 -135 66} + {-23 127 -58 -5 -118 64} + {87 -16 121 23 -41 -12} + {-19 29 35 -148 -11 45}} + { + {-55 -147 -146 -31 55 60} + {-88 -45 -28 46 -26 -144} + {-12 -107 -34 150 249 66} + {11 -15 -34 27 -78 -50}} + { + {56 67 108 4 2 -48} + {58 67 89 32 32 -8} + {-42 -31 -103 -30 -23 -8} + {6 4 -26 -10 26 12}} +} + +# Now do the deconvolution and print it out +puts h:\ [pretty [deconvolve $g $f]] diff --git a/Task/Deepcopy/0DESCRIPTION b/Task/Deepcopy/0DESCRIPTION new file mode 100644 index 0000000000..d8acd3bf9d --- /dev/null +++ b/Task/Deepcopy/0DESCRIPTION @@ -0,0 +1,13 @@ +Demonstrate how to copy data structures containing complex hetrogeneous and cyclic semantics. This is often referred to as [[wp:Deep_copy#Deep_copy|deep copying]], and is normally required where structures are mutable and to ensure that independent copies can be manipulated without side-effects. + +If this facility is not built into the language, it is permissible to use functions from a common library, or a coded procedure. + +The task should show: + +* Relevant semantics of structures, such as their [[wp:Homogeneity and heterogeneity|homogeneous or heterogeneous]] properties, or containment of (self- or mutual-reference) cycles. + +* Any limitations of the method. + +* That the structure and its copy are different. + +* Suitable links to external documentation for common libraries. diff --git a/Task/Deepcopy/C-sharp/deepcopy.cs b/Task/Deepcopy/C-sharp/deepcopy.cs new file mode 100644 index 0000000000..dd7ee3f54a --- /dev/null +++ b/Task/Deepcopy/C-sharp/deepcopy.cs @@ -0,0 +1,28 @@ +using System; + +namespace prog +{ + class MainClass + { + class MyClass : ICloneable + { + public MyClass() { f = new int[3]{2,3,5}; c = '1'; } + + public object Clone() + { + MyClass cpy = (MyClass) this.MemberwiseClone(); + cpy.f = (int[]) this.f.Clone(); + return cpy; + } + + public char c; + public int[] f; + } + + public static void Main( string[] args ) + { + MyClass c1 = new MyClass(); + MyClass c2 = (MyClass) c1.Clone(); + } + } +} diff --git a/Task/Deepcopy/Common-Lisp/deepcopy.lisp b/Task/Deepcopy/Common-Lisp/deepcopy.lisp new file mode 100644 index 0000000000..469fa8fb8b --- /dev/null +++ b/Task/Deepcopy/Common-Lisp/deepcopy.lisp @@ -0,0 +1,7 @@ +$ clisp -q +[1]> (setf *print-circle* t) +T +[2]> (let ((a (cons 1 nil))) (setf (cdr a) a)) ;; create circular list +#1=(1 . #1#) +[3]> (read-from-string "#1=(1 . #1#)") ;; read it from a string +#1=(1 . #1#) ;; a similar circular list is returned diff --git a/Task/Deepcopy/E/deepcopy-1.e b/Task/Deepcopy/E/deepcopy-1.e new file mode 100644 index 0000000000..586e5c2058 --- /dev/null +++ b/Task/Deepcopy/E/deepcopy-1.e @@ -0,0 +1,4 @@ +def deSubgraphKit := +def deepcopy(x) { + return deSubgraphKit.recognize(x, deSubgraphKit.makeBuilder()) +} diff --git a/Task/Deepcopy/E/deepcopy-2.e b/Task/Deepcopy/E/deepcopy-2.e new file mode 100644 index 0000000000..35f94a3cd1 --- /dev/null +++ b/Task/Deepcopy/E/deepcopy-2.e @@ -0,0 +1,22 @@ +? def x := ["a" => 1, "b" => [x].diverge()] +# value: ["a" => 1, "b" => [<***CYCLE***>].diverge()] + +? def y := deepcopy(x) +# value: ["a" => 1, "b" => [<***CYCLE***>].diverge()] + +? y["b"].push(2) + +? y +# value: ["a" => 1, "b" => [<***CYCLE***>, 2].diverge()] + +? x +# value: ["a" => 1, "b" => [<***CYCLE***>].diverge()] + +? y["b"][0] == y +# value: true + +? y["b"][0] == x +# value: false + +? x["b"][0] == x +# value: true diff --git a/Task/Deepcopy/Go/deepcopy-1.go b/Task/Deepcopy/Go/deepcopy-1.go new file mode 100644 index 0000000000..a9af758f5a --- /dev/null +++ b/Task/Deepcopy/Go/deepcopy-1.go @@ -0,0 +1,37 @@ +package main + +import "fmt" + +// a complex data structure +type cds struct { + i int // no special handling needed for deep copy + s string // no special handling + b []byte // copied easily with append function + m map[int]bool // deep copy requires looping +} + +// a method +func (c cds) deepcopy() *cds { + // copy what you can in one line + r := &cds{c.i, c.s, append([]byte{}, c.b...), make(map[int]bool)} + // populate map with a loop + for k, v := range c.m { + r.m[k] = v + } + return r +} + +// demo +func main() { + // create and populate a structure + c1 := &cds{1, "one", []byte("unit"), map[int]bool{1: true}} + fmt.Println(c1) // show it + c2 := c1.deepcopy() // copy it + fmt.Println(c2) // show copy + c1.i = 0 // change original + c1.s = "nil" + copy(c1.b, "zero") + c1.m[1] = false + fmt.Println(c1) // show changes + fmt.Println(c2) // show copy unaffected +} diff --git a/Task/Deepcopy/Go/deepcopy-2.go b/Task/Deepcopy/Go/deepcopy-2.go new file mode 100644 index 0000000000..1da88fa9cc --- /dev/null +++ b/Task/Deepcopy/Go/deepcopy-2.go @@ -0,0 +1,62 @@ +package main + +import ( + "encoding/gob" + "fmt" + "os" +) + +// capability requested by task +func deepcopy(dst, src interface{}) error { + r, w, err := os.Pipe() + if err != nil { + return err + } + enc := gob.NewEncoder(w) + err = enc.Encode(src) + if err != nil { + return err + } + dec := gob.NewDecoder(r) + return dec.Decode(dst) +} + +// define linked list type, an example of a recursive type +type link struct { + Value string + Next *link +} + +// method satisfies stringer interface for fmt.Println +func (l *link) String() string { + if l == nil { + return "nil" + } + s := "(" + l.Value + for l = l.Next; l != nil; l = l.Next { + s += " " + l.Value + } + return s + ")" +} + +func main() { + // create a linked list with two elements + l1 := &link{"a", &link{Value: "b"}} + // print original + fmt.Println(l1) + // declare a variable to hold deep copy + var l2 *link + // copy + if err := deepcopy(&l2, l1); err != nil { + fmt.Println(err) + return + } + // print copy + fmt.Println(l2) + // now change contents of original list + l1.Value, l1.Next.Value = "c", "d" + // show that it is changed + fmt.Println(l1) + // show that copy is unaffected + fmt.Println(l2) +} diff --git a/Task/Deepcopy/JavaScript/deepcopy-1.js b/Task/Deepcopy/JavaScript/deepcopy-1.js new file mode 100644 index 0000000000..afd192275b --- /dev/null +++ b/Task/Deepcopy/JavaScript/deepcopy-1.js @@ -0,0 +1,8 @@ +var deepcopy = function(o){ + return JSON.parse(JSON.stringify(src)); +}; + +var src = {foo:0,bar:[0,1]}; +print(JSON.stringify(src)); +var dst = deepcopy(src); +print(JSON.stringify(src)); diff --git a/Task/Deepcopy/JavaScript/deepcopy-2.js b/Task/Deepcopy/JavaScript/deepcopy-2.js new file mode 100644 index 0000000000..cb86c0a33a --- /dev/null +++ b/Task/Deepcopy/JavaScript/deepcopy-2.js @@ -0,0 +1,8 @@ +var deepcopy = function(o){ + return eval(uneval(o)); +}; +var src = {foo:0,bar:[0,1]}; +src['baz'] = src; +print(uneval(src)); +var dst = deepcopy(src); +print(uneval(src)); diff --git a/Task/Deepcopy/PHP/deepcopy-1.php b/Task/Deepcopy/PHP/deepcopy-1.php new file mode 100644 index 0000000000..3cc0074a6d --- /dev/null +++ b/Task/Deepcopy/PHP/deepcopy-1.php @@ -0,0 +1,21 @@ +child = clone $this->child; + } +} + +$object = new Foo; +$object->some_value = 1; +$object->child = new stdClass; +$object->child->some_value = 1; + +$deepcopy = clone $object; +$deepcopy->some_value++; +$deepcopy->child->some_value++; + +echo "Object contains {$object->some_value}, child contains {$object->child->some_value}\n", + "Clone of object contains {$deepcopy->some_value}, child contains {$deepcopy->child->some_value}\n"; +?> diff --git a/Task/Deepcopy/PHP/deepcopy-2.php b/Task/Deepcopy/PHP/deepcopy-2.php new file mode 100644 index 0000000000..d00ba3fb28 --- /dev/null +++ b/Task/Deepcopy/PHP/deepcopy-2.php @@ -0,0 +1,14 @@ +some_value = 1; +$object->child = new stdClass; +$object->child->some_value = 1; + +$deepcopy = unserialize(serialize($object)); +$deepcopy->some_value++; +$deepcopy->child->some_value++; + +echo "Object contains {$object->some_value}, child contains {$object->child->some_value}\n", + "Clone of object contains {$deepcopy->some_value}, child contains {$deepcopy->child->some_value}\n"; diff --git a/Task/Deepcopy/Perl/deepcopy.pl b/Task/Deepcopy/Perl/deepcopy.pl new file mode 100644 index 0000000000..923d64b827 --- /dev/null +++ b/Task/Deepcopy/Perl/deepcopy.pl @@ -0,0 +1,11 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Storable; +use Data::Dumper; + +my $src = { foo => 0, bar => [0, 1] }; +$src->{baz} = $src; +my $dst = Storable::dclone($src); +print Dumper($src); +print Dumper($dst); diff --git a/Task/Deepcopy/PicoLisp/deepcopy-1.l b/Task/Deepcopy/PicoLisp/deepcopy-1.l new file mode 100644 index 0000000000..c0ed73f898 --- /dev/null +++ b/Task/Deepcopy/PicoLisp/deepcopy-1.l @@ -0,0 +1 @@ +(mapcar copy List) diff --git a/Task/Deepcopy/PicoLisp/deepcopy-2.l b/Task/Deepcopy/PicoLisp/deepcopy-2.l new file mode 100644 index 0000000000..5452874953 --- /dev/null +++ b/Task/Deepcopy/PicoLisp/deepcopy-2.l @@ -0,0 +1,4 @@ +(de deepCopy (X) + (if (atom X) + X + (cons (deepCopy (car X)) (deepCopy (cdr X))) ) ) diff --git a/Task/Deepcopy/PicoLisp/deepcopy-3.l b/Task/Deepcopy/PicoLisp/deepcopy-3.l new file mode 100644 index 0000000000..617e6d2cd1 --- /dev/null +++ b/Task/Deepcopy/PicoLisp/deepcopy-3.l @@ -0,0 +1,25 @@ +: (setq A '((a . b) (c d e) f g . e)) +-> ((a . b) (c d e) f g . e) + +: (setq B (deepCopy A)) +-> ((a . b) (c d e) f g . e) + +: A +-> ((a . b) (c d e) f g . e) + +: B +-> ((a . b) (c d e) f g . e) + +: (= A B) +-> T # A and its copy B are structure-equal +: (== A B) +-> NIL # but they are not identical (pointer-equal) + +: (cadr A) +-> (c d e) + +: (cadr B) +-> (c d e) + +: (== (cadr A) (cadr B)) +-> NIL # The same holds for sub-structures diff --git a/Task/Deepcopy/PicoLisp/deepcopy-4.l b/Task/Deepcopy/PicoLisp/deepcopy-4.l new file mode 100644 index 0000000000..41f4711e81 --- /dev/null +++ b/Task/Deepcopy/PicoLisp/deepcopy-4.l @@ -0,0 +1,11 @@ +(de deepCopy (X) + (let Mark NIL + (recur (X) + (cond + ((atom X) X) + ((asoq X Mark) (cdr @)) + (T + (prog1 (cons) + (push 'Mark (cons X @)) + (set @ (recurse (car X))) + (con @ (recurse (cdr X))) ) ) ) ) ) ) diff --git a/Task/Deepcopy/PicoLisp/deepcopy-5.l b/Task/Deepcopy/PicoLisp/deepcopy-5.l new file mode 100644 index 0000000000..a365d75dc4 --- /dev/null +++ b/Task/Deepcopy/PicoLisp/deepcopy-5.l @@ -0,0 +1,12 @@ +: (setq A '(a b .) B (deepCopy A)) +-> (a b .) +: A +-> (a b .) +: B +-> (a b .) + +: (= A B) +-> T # A and its copy B are structure-equal + +: (== A B) +-> NIL # but they are not identical (pointer-equal) diff --git a/Task/Deepcopy/Python/deepcopy.py b/Task/Deepcopy/Python/deepcopy.py new file mode 100644 index 0000000000..2141f3f23a --- /dev/null +++ b/Task/Deepcopy/Python/deepcopy.py @@ -0,0 +1,2 @@ +import copy +deepcopy_of_obj = copy.deepcopy(obj) diff --git a/Task/Deepcopy/Ruby/deepcopy.rb b/Task/Deepcopy/Ruby/deepcopy.rb new file mode 100644 index 0000000000..1f6aff7a9b --- /dev/null +++ b/Task/Deepcopy/Ruby/deepcopy.rb @@ -0,0 +1,22 @@ +# _orig_ is a Hash that contains an Array. +orig = { :num => 1, :ary => [2, 3] } +orig[:cycle] = orig # _orig_ also contains itself. + +# _copy_ becomes a deep copy of _orig_. +copy = Marshal.load(Marshal.dump orig) + +# These changes to _orig_ never affect _copy_, +# because _orig_ and _copy_ are disjoint structures. +orig[:ary] << 4 +orig[:rng] = (5..6) + +# Because of deep copy, orig[:ary] and copy[:ary] +# refer to different Arrays. +p orig # => {:num=>1, :ary=>[2, 3, 4], :cycle=>{...}, :rng=>5..6} +p copy # => {:num=>1, :ary=>[2, 3], :cycle=>{...}} + +# The original contains itself, and the copy contains itself, +# but the original and the copy are not the same object. +p [(orig.equal? orig[:cycle]), + (copy.equal? copy[:cycle]), + (not orig.equal? copy)] # => [true, true, true] diff --git a/Task/Deepcopy/Tcl/deepcopy-1.tcl b/Task/Deepcopy/Tcl/deepcopy-1.tcl new file mode 100644 index 0000000000..143f0757f8 --- /dev/null +++ b/Task/Deepcopy/Tcl/deepcopy-1.tcl @@ -0,0 +1 @@ +set deepCopy [string range ${valueToCopy}x 0 end-1] diff --git a/Task/Deepcopy/Tcl/deepcopy-2.tcl b/Task/Deepcopy/Tcl/deepcopy-2.tcl new file mode 100644 index 0000000000..471b7ae0f7 --- /dev/null +++ b/Task/Deepcopy/Tcl/deepcopy-2.tcl @@ -0,0 +1 @@ +set copiedObject [oo::copy $originalObject] diff --git a/Task/Define-a-primitive-data-type/C++/define-a-primitive-data-type.cpp b/Task/Define-a-primitive-data-type/C++/define-a-primitive-data-type.cpp new file mode 100644 index 0000000000..ae5ef628be --- /dev/null +++ b/Task/Define-a-primitive-data-type/C++/define-a-primitive-data-type.cpp @@ -0,0 +1,62 @@ +#include + +class tiny_int +{ +public: + tiny_int(int i): + value(i) + { + if (value < 1) + throw std::out_of_range("tiny_int: value smaller than 1"); + if (value > 10) + throw std::out_of_range("tiny_int: value larger than 10"); + } + operator int() const + { + return value; + } + tiny_int& operator+=(int i) + { + // by assigning to *this instead of directly modifying value, the + // constructor is called and thus the check is enforced + *this = value + i; + return *this; + } + tiny_int& operator-=(int i) + { + *this = value - i; + return *this; + } + tiny_int& operator*=(int i) + { + *this = value * i; + return *this; + } + tiny_int& operator/=(int i) + { + *this = value / i; + return *this; + } + tiny_int& operator<<=(int i) + { + *this = value << i; + return *this; + } + tiny_int& operator>>=(int i) + { + *this = value >> i; + return *this; + } + tiny_int& operator&=(int i) + { + *this = value & i; + return *this; + } + tiny_int& operator|=(int i) + { + *this = value | i; + return *this; + } +private: + unsigned char value; // we don't need more space +}; diff --git a/Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-1.lisp b/Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-1.lisp new file mode 100644 index 0000000000..84e386b27b --- /dev/null +++ b/Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-1.lisp @@ -0,0 +1,2 @@ +(deftype one-to-ten () + '(integer 1 10)) diff --git a/Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-2.lisp b/Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-2.lisp new file mode 100644 index 0000000000..2d4f6873d9 --- /dev/null +++ b/Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-2.lisp @@ -0,0 +1,13 @@ +(defun word (i) + (check-type i one-to-ten) + (case i + (1 "one") + (2 "two") + (3 "three") + (4 "four") + (5 "five") + (6 "six") + (7 "seven") + (8 "eight") + (9 "nine") + (10 "ten"))) diff --git a/Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-3.lisp b/Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-3.lisp new file mode 100644 index 0000000000..f053e8a733 --- /dev/null +++ b/Task/Define-a-primitive-data-type/Common-Lisp/define-a-primitive-data-type-3.lisp @@ -0,0 +1,3 @@ +(dolist (i numbers) + (declare (type one-to-ten i)) + ...) diff --git a/Task/Define-a-primitive-data-type/D/define-a-primitive-data-type.d b/Task/Define-a-primitive-data-type/D/define-a-primitive-data-type.d new file mode 100644 index 0000000000..c7c6e4b0f2 --- /dev/null +++ b/Task/Define-a-primitive-data-type/D/define-a-primitive-data-type.d @@ -0,0 +1,84 @@ +import std.exception, std.string, std.traits; + +/++ +A bounded integral type template. +Template params: +- min: the minimal value +- max: the maximal value +- I: the type used to store the value internally ++/ +struct BoundedInt(alias min, alias max, I = int) +{ + // Static checks + static assert(isIntegral!(typeof(min))); + static assert(isIntegral!(typeof(max))); + static assert(isIntegral!I); + static assert(min < max); + static assert(cast(I) max == max, "Type " ~ I.stringof + ~ " cannot hold values up to " ~ max.stringof); + + /// The actual value stored in this struct + private I _value; + + /// Getter for the internal value + @property I internalValue() + { + return _value; + } + + /// 'alias this' to make this struct look like a built-in integer + alias internalValue this; + + /// Constructor + this(T)(T value) + { + opAssign(value); + } + + /// Assignment operator + void opAssign(T)(T value) + if (isIntegral!T) + { + _value = checked(value); + } + + /// Unary operators + auto opUnary(string op)() const + { + return checked(mixin(op ~ "_value")); + } + + /// Binary operators + auto opBinary(string op, T)(T other) const + { + return checked(mixin("_value" ~ op ~ "other")); + } + + /// ditto + auto opBinaryRight(string op, T)(T other) const + if (isIntegral!T) + { + return checked(mixin("_value" ~ op ~ "other")); + } + + // Bounds enforcement + private I checked(T)(T value) const + { + enforce(value >= min && value <= max, + format("Value %s is out of bounds (%s to %s).", value, min, max)); + return cast(I) value; + } +} + +unittest +{ + alias MyInt = BoundedInt!(1, 10); + // alias BoundInt!(1, 10) MyInt; // D < 2.061 + + MyInt i = 4; + MyInt j = i + i; + assert(j / 2 == 4); + assert(2 + j == 10); + assert(i < 5); + assert(j > i); +} diff --git a/Task/Define-a-primitive-data-type/E/define-a-primitive-data-type.e b/Task/Define-a-primitive-data-type/E/define-a-primitive-data-type.e new file mode 100644 index 0000000000..fed5703f90 --- /dev/null +++ b/Task/Define-a-primitive-data-type/E/define-a-primitive-data-type.e @@ -0,0 +1,5 @@ +def MyNumber := 1..10 + +for i :MyNumber in [0, 5, 10, 15, 20, 25] { + println(i) +} diff --git a/Task/Define-a-primitive-data-type/Euphoria/define-a-primitive-data-type.euphoria b/Task/Define-a-primitive-data-type/Euphoria/define-a-primitive-data-type.euphoria new file mode 100644 index 0000000000..9113cb3e37 --- /dev/null +++ b/Task/Define-a-primitive-data-type/Euphoria/define-a-primitive-data-type.euphoria @@ -0,0 +1,3 @@ +type My_Type(integer i) + return i >= 1 and i <= 10 +end type diff --git a/Task/Delegates/C++/delegates.cpp b/Task/Delegates/C++/delegates.cpp new file mode 100644 index 0000000000..a266ac8f93 --- /dev/null +++ b/Task/Delegates/C++/delegates.cpp @@ -0,0 +1,79 @@ +#include +#include +#include +#include + +using namespace std; +using namespace std::tr1; +using std::tr1::function; + +// interface for all delegates +class IDelegate +{ +public: + virtual ~IDelegate() {} +}; + +//interface for delegates supporting thing +class IThing +{ +public: + virtual ~IThing() {} + virtual std::string Thing() = 0; +}; + +// Does not handle Thing +class DelegateA : virtual public IDelegate +{ +}; + +// Handles Thing +class DelegateB : public IThing, public IDelegate +{ + std::string Thing() + { + return "delegate implementation"; + } +}; + +class Delegator +{ +public: + std::string Operation() + { + if(Delegate) //have delegate + if (IThing * pThing = dynamic_cast(Delegate.get())) + //delegate provides IThing interface + return pThing->Thing(); + + return "default implementation"; + } + + shared_ptr Delegate; +}; + +int main() +{ + shared_ptr delegateA(new DelegateA()); + shared_ptr delegateB(new DelegateB()); + Delegator delegator; + + // No delegate + std::cout << delegator.Operation() << std::endl; + + // Delegate doesn't handle "Thing" + delegator.Delegate = delegateA; + std::cout << delegator.Operation() << std::endl; + + // Delegate handles "Thing" + delegator.Delegate = delegateB; + std::cout << delegator.Operation() << std::endl; + +/* +Prints: + + default implementation + default implementation + delegate implementation + */ +} diff --git a/Task/Delegates/C-sharp/delegates.cs b/Task/Delegates/C-sharp/delegates.cs new file mode 100644 index 0000000000..0a4c06bae5 --- /dev/null +++ b/Task/Delegates/C-sharp/delegates.cs @@ -0,0 +1,39 @@ +using System; + +interface IOperable +{ + string Operate(); +} + +class Inoperable +{ +} + +class Operable : IOperable +{ + public string Operate() + { + return "Delegate implementation."; + } +} + +class Delegator : IOperable +{ + object Delegate; + + public string Operate() + { + var operable = Delegate as IOperable; + return operable != null ? operable.Operate() : "Default implementation."; + } + + static void Main() + { + var delegator = new Delegator(); + foreach (var @delegate in new object[] { null, new Inoperable(), new Operable() }) + { + delegator.Delegate = @delegate; + Console.WriteLine(delegator.Operate()); + } + } +} diff --git a/Task/Delegates/Common-Lisp/delegates.lisp b/Task/Delegates/Common-Lisp/delegates.lisp new file mode 100644 index 0000000000..c225372415 --- /dev/null +++ b/Task/Delegates/Common-Lisp/delegates.lisp @@ -0,0 +1,29 @@ +(defgeneric thing (object) + (:documentation "Thing the object.")) + +(defmethod thing (object) + "default implementation") + +(defclass delegator () + ((delegate + :initarg :delegate + :reader delegator-delegate))) + +(defmethod thing ((delegator delegator)) + "If delegator has a delegate, invoke thing on the delegate, +otherwise return \"no delegate\"." + (if (slot-boundp delegator 'delegate) + (thing (delegator-delegate delegator)) + "no delegate")) + +(defclass delegate () ()) + +(defmethod thing ((delegate delegate)) + "delegate implementation") + +(let ((d1 (make-instance 'delegator)) + (d2 (make-instance 'delegator :delegate nil)) + (d3 (make-instance 'delegator :delegate (make-instance 'delegate)))) + (assert (string= "no delegate" (thing d1))) + (assert (string= "default implementation" (thing d2))) + (assert (string= "delegate implementation" (thing d3)))) diff --git a/Task/Delegates/D/delegates-1.d b/Task/Delegates/D/delegates-1.d new file mode 100644 index 0000000000..5e8bbfcfe2 --- /dev/null +++ b/Task/Delegates/D/delegates-1.d @@ -0,0 +1,24 @@ +class Delegator { + string delegate() hasDelegate; + + string operation() { + if (hasDelegate is null) + return "Default implementation"; + return hasDelegate(); + } + + typeof(this) setDg(string delegate() dg) { + hasDelegate = dg; + return this; + } +} + +void main() { + import std.stdio; + auto dr = new Delegator; + string delegate() thing = () => "Delegate implementation"; + + writeln(dr.operation()); + writeln(dr.operation()); + writeln(dr.setDg(thing).operation()); +} diff --git a/Task/Delegates/D/delegates-2.d b/Task/Delegates/D/delegates-2.d new file mode 100644 index 0000000000..050a2c395e --- /dev/null +++ b/Task/Delegates/D/delegates-2.d @@ -0,0 +1,29 @@ +import tango.io.Stdout; + +class Delegator +{ + private char[] delegate() hasDelegate; +public: + char[] operation() { + if (hasDelegate is null) + return "default implementation"; + return hasDelegate(); + } + + typeof(this) setDg(char[] delegate() dg) + { + hasDelegate = dg; + return this; + } +} + +int main(char[][] args) +{ + auto dr = new Delegator(); + auto thing = delegate char[]() { return "delegate implementation"; }; + + Stdout ( dr.operation ).newline; + Stdout ( dr.operation ).newline; + Stdout ( dr.setDg(thing).operation ).newline; + return 0; +} diff --git a/Task/Delegates/Dart/delegates.dart b/Task/Delegates/Dart/delegates.dart new file mode 100644 index 0000000000..009bf39aa9 --- /dev/null +++ b/Task/Delegates/Dart/delegates.dart @@ -0,0 +1,29 @@ +class Delegator { + var delegate; + + String operation() { + if (delegate == null) + return "default implementation"; + else + return delegate.thing(); + } +} + +class Delegate { + String thing() => "delegate implementation"; +} + +main() { + // Without a delegate: + Delegator a = new Delegator(); + Expect.equals("default implementation",a.operation()); + + // any object doesn't work unless we can check for existing methods + // a.delegate=new Object(); + // Expect.equals("default implementation",a.operation()); + + // With a delegate: + Delegate d = new Delegate(); + a.delegate = d; + Expect.equals("delegate implementation",a.operation()); +} diff --git a/Task/Delegates/Delphi/delegates-1.delphi b/Task/Delegates/Delphi/delegates-1.delphi new file mode 100644 index 0000000000..8e0a12f6f1 --- /dev/null +++ b/Task/Delegates/Delphi/delegates-1.delphi @@ -0,0 +1,50 @@ +unit Printer; + +interface + +type + // the "delegate" + TRealPrinter = class + public + procedure Print; + end; + + // the "delegator" + TPrinter = class + private + FPrinter: TRealPrinter; + public + constructor Create; + destructor Destroy; override; + procedure Print; + end; + +implementation + +{ TRealPrinter } + +procedure TRealPrinter.Print; +begin + Writeln('Something...'); +end; + +{ TPrinter } + +constructor TPrinter.Create; +begin + inherited Create; + FPrinter:= TRealPrinter.Create; +end; + +destructor TPrinter.Destroy; +begin + FPrinter.Free; + inherited; +end; + +procedure TPrinter.Print; +begin + FPrinter.Print; +end; + +end. diff --git a/Task/Delegates/Delphi/delegates-2.delphi b/Task/Delegates/Delphi/delegates-2.delphi new file mode 100644 index 0000000000..3e47286943 --- /dev/null +++ b/Task/Delegates/Delphi/delegates-2.delphi @@ -0,0 +1,19 @@ +program Delegate; + +{$APPTYPE CONSOLE} + +uses + SysUtils, + Printer in 'Printer.pas'; + +var + PrinterObj: TPrinter; +begin + PrinterObj:= TPrinter.Create; + try + PrinterObj.Print; + Readln; + finally + PrinterObj.Free; + end; +end. diff --git a/Task/Delegates/E/delegates.e b/Task/Delegates/E/delegates.e new file mode 100644 index 0000000000..f042733460 --- /dev/null +++ b/Task/Delegates/E/delegates.e @@ -0,0 +1,34 @@ +def makeDelegator { + /** construct without an explicit delegate */ + to run() { + return makeDelegator(null) + } + + /** construct with a delegate */ + to run(delegateO) { # suffix because "delegate" is a reserved keyword + def delegator { + to operation() { + return if (delegateO.__respondsTo("thing", 0)) { + delegateO.thing() + } else { + "default implementation" + } + } + } + return delegator + } +} + +? def delegator := makeDelegator() +> delegator.operation() +# value: "default implementation" + +? def delegator := makeDelegator(def doesNotImplement {}) +> delegator.operation() +# value: "default implementation" + +? def delegator := makeDelegator(def doesImplement { +> to thing() { return "delegate implementation" } +> }) +> delegator.operation() +# value: "default implementation" diff --git a/Task/Delete-a-file/C++/delete-a-file.cpp b/Task/Delete-a-file/C++/delete-a-file.cpp new file mode 100644 index 0000000000..b06b9839d8 --- /dev/null +++ b/Task/Delete-a-file/C++/delete-a-file.cpp @@ -0,0 +1,11 @@ +#include +#include + +int main() { + remove( "input.txt" ); + remove( "/input.txt" ); + _rmdir( "docs" ); + _rmdir( "/docs" ); + + return 0; +} diff --git a/Task/Delete-a-file/Common-Lisp/delete-a-file-1.lisp b/Task/Delete-a-file/Common-Lisp/delete-a-file-1.lisp new file mode 100644 index 0000000000..197558dcf1 --- /dev/null +++ b/Task/Delete-a-file/Common-Lisp/delete-a-file-1.lisp @@ -0,0 +1,2 @@ +(delete-file (make-pathname :name "input.txt")) +(delete-file (make-pathname :directory '(:absolute "") :name "input.txt")) diff --git a/Task/Delete-a-file/Common-Lisp/delete-a-file-2.lisp b/Task/Delete-a-file/Common-Lisp/delete-a-file-2.lisp new file mode 100644 index 0000000000..cab9bd6e00 --- /dev/null +++ b/Task/Delete-a-file/Common-Lisp/delete-a-file-2.lisp @@ -0,0 +1,5 @@ +(let ((path (make-pathname :directory '(:relative "docs")))) + (ext:delete-dir path)) + +(let ((path (make-pathname :directory '(:absolute "docs")))) + (ext:delete-dir path)) diff --git a/Task/Delete-a-file/Common-Lisp/delete-a-file-3.lisp b/Task/Delete-a-file/Common-Lisp/delete-a-file-3.lisp new file mode 100644 index 0000000000..56b05aa8ee --- /dev/null +++ b/Task/Delete-a-file/Common-Lisp/delete-a-file-3.lisp @@ -0,0 +1,2 @@ +(let ((path (make-pathname :directory '(:relative "docs")))) + (cl-fad:delete-directory-and-files path)) diff --git a/Task/Delete-a-file/D/delete-a-file-1.d b/Task/Delete-a-file/D/delete-a-file-1.d new file mode 100644 index 0000000000..cf1b4ce454 --- /dev/null +++ b/Task/Delete-a-file/D/delete-a-file-1.d @@ -0,0 +1,5 @@ +import std.file: remove; + +void main() { + remove("data.txt"); +} diff --git a/Task/Delete-a-file/D/delete-a-file-2.d b/Task/Delete-a-file/D/delete-a-file-2.d new file mode 100644 index 0000000000..7a32732f3a --- /dev/null +++ b/Task/Delete-a-file/D/delete-a-file-2.d @@ -0,0 +1,8 @@ +import tango.io.Path; + +void main() { + remove("input.txt"); + remove("/input.txt"); + remove("docs"); + remove("/docs"); +} diff --git a/Task/Delete-a-file/D/delete-a-file-3.d b/Task/Delete-a-file/D/delete-a-file-3.d new file mode 100644 index 0000000000..d5c4ea4357 --- /dev/null +++ b/Task/Delete-a-file/D/delete-a-file-3.d @@ -0,0 +1,8 @@ +import tango.stdc.posix.unistd; + +void main() { + unlink("input.txt"); + unlink("/input.txt"); + rmdir("docs"); + rmdir("/docs"); +} diff --git a/Task/Delete-a-file/Delphi/delete-a-file.delphi b/Task/Delete-a-file/Delphi/delete-a-file.delphi new file mode 100644 index 0000000000..01d4dbcbb6 --- /dev/null +++ b/Task/Delete-a-file/Delphi/delete-a-file.delphi @@ -0,0 +1,12 @@ +procedure TMain.btnDeleteClick(Sender: TObject); +var + CurrentDirectory : String; +begin + CurrentDirectory := GetCurrentDir; + + DeleteFile(CurrentDirectory + '\input.txt'); + RmDir(PChar(CurrentDirectory + '\docs')); + + DeleteFile('c:\input.txt'); + RmDir(PChar('c:\docs')); +end; diff --git a/Task/Delete-a-file/E/delete-a-file.e b/Task/Delete-a-file/E/delete-a-file.e new file mode 100644 index 0000000000..b03a9a38de --- /dev/null +++ b/Task/Delete-a-file/E/delete-a-file.e @@ -0,0 +1,4 @@ +.delete(null) +.delete(null) +.delete(null) +.delete(null) diff --git a/Task/Detect-division-by-zero/Common-Lisp/detect-division-by-zero.lisp b/Task/Detect-division-by-zero/Common-Lisp/detect-division-by-zero.lisp new file mode 100644 index 0000000000..3f95c73645 --- /dev/null +++ b/Task/Detect-division-by-zero/Common-Lisp/detect-division-by-zero.lisp @@ -0,0 +1,2 @@ +(handler-case (/ x y) + (division-by-zero () (format t "division by zero caught!~%"))) diff --git a/Task/Detect-division-by-zero/D/detect-division-by-zero.d b/Task/Detect-division-by-zero/D/detect-division-by-zero.d new file mode 100644 index 0000000000..1e82fc6802 --- /dev/null +++ b/Task/Detect-division-by-zero/D/detect-division-by-zero.d @@ -0,0 +1,59 @@ +module divzero ; +import std.stdio ; +import std.format ; + +// check if a is unordered (NaN) +bool isNaN(T)(T a) { return a !<>= T.min ; } +// check for +ve & -ve infinity +bool isInf(T)(T a) { return a == T.infinity || -a == T.infinity ; } +// check if neither NaN nor Inf +bool isNormal(T)(T a) { return !(a !<> T.infinity || -a !<> T.infinity) ; } + +string divCheck(T)(T numer, T denom) { + T result ; + string msg = "" ; + static if (is(T : long)) { // Integral Type + try { + result = numer / denom ; + } catch(Exception e) { + msg = "! " ~ e.msg ~"(by Exception)" ; + result = T.max ; + } + } else { // Float Type + result = numer / denom ; + if(isNormal(numer) && isInf(result)) + msg = "! Division by Zero" ; + else if (!isNormal(result)) { + if (isNaN(numer)) + msg = "! NaN numerator" ; + else if(isNaN(denom)) + msg = "! NaN denominator" ; + else if(isInf(numer)) + msg = "! Inf numerator" ; + else + msg = "! NaN(Zero Division by Zero)" ; + } + } + return std.format.format("%5s %s", std.format.format("%1.1g", cast(real)result), msg) ; +} + +void main() { + writefln("Div with Check") ; + writefln("int 1/ 0 : %s", divCheck(1, 0)) ; + writefln("ubyte 1/ 0 : %s", divCheck(cast(ubyte)1, cast(ubyte)0)) ; + writefln("real 1/ 0 : %s", divCheck(1.0L, 0.0L)) ; + writefln("real -1/ 0 : %s", divCheck(-1.0L, 0.0L)) ; + writefln("real 0/ 0 : %s", divCheck(0.0L, 0.0L)) ; + writefln() ; + writefln("real -4/-2 : %s", divCheck(-4.0L,-2.0L)) ; + real inf = -1.0L / 0.0L ; // make an infinity + writefln("real 2/-inf: %s", divCheck(2.0L, inf)) ; + writefln() ; + writefln("real -inf/-2 : %s", divCheck(inf, -2.0L)) ; + writefln("real +inf/-2 : %s", divCheck(real.infinity, -2.0L)) ; + writefln("real nan/-2 : %s", divCheck(real.nan, -2.0L)) ; + writefln("real -2/ nan: %s", divCheck(-2.0L, real.nan)) ; + writefln("real nan/ 0 : %s", divCheck(real.nan, 0.0L)) ; + writefln("real inf/ inf: %s", divCheck(real.infinity, real.infinity)) ; + writefln("real nan/ nan: %s", divCheck(real.nan, real.nan)) ; +} diff --git a/Task/Detect-division-by-zero/Delphi/detect-division-by-zero.delphi b/Task/Detect-division-by-zero/Delphi/detect-division-by-zero.delphi new file mode 100644 index 0000000000..33abf6ec1d --- /dev/null +++ b/Task/Detect-division-by-zero/Delphi/detect-division-by-zero.delphi @@ -0,0 +1,18 @@ +program DivideByZero; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +var + a, b: Integer; +begin + a := 1; + b := 0; + try + WriteLn(a / b); + except + on e: EZeroDivide do + Writeln(e.Message); + end; +end. diff --git a/Task/Detect-division-by-zero/E/detect-division-by-zero.e b/Task/Detect-division-by-zero/E/detect-division-by-zero.e new file mode 100644 index 0000000000..1a4fa4d037 --- /dev/null +++ b/Task/Detect-division-by-zero/E/detect-division-by-zero.e @@ -0,0 +1,8 @@ +def divide(numerator, denominator) { + def floatQuotient := numerator / denominator + if (floatQuotient.isNaN() || floatQuotient.isInfinite()) { + return ["zero denominator"] + } else { + return ["ok", floatQuotient] + } +} diff --git a/Task/Detect-division-by-zero/Ela/detect-division-by-zero-1.ela b/Task/Detect-division-by-zero/Ela/detect-division-by-zero-1.ela new file mode 100644 index 0000000000..6a76162956 --- /dev/null +++ b/Task/Detect-division-by-zero/Ela/detect-division-by-zero-1.ela @@ -0,0 +1,6 @@ +open core number + +x /. y = try Some (x `div` y) with + _ = None + +(12 /. 2, 12 /. 0) diff --git a/Task/Detect-division-by-zero/Ela/detect-division-by-zero-2.ela b/Task/Detect-division-by-zero/Ela/detect-division-by-zero-2.ela new file mode 100644 index 0000000000..52a5edd197 --- /dev/null +++ b/Task/Detect-division-by-zero/Ela/detect-division-by-zero-2.ela @@ -0,0 +1,2 @@ +x /. 0 = None +x /. y = Some (x / y) diff --git a/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-1.cpp b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-1.cpp new file mode 100644 index 0000000000..dd177cb3ad --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-1.cpp @@ -0,0 +1,28 @@ +#include // for istringstream + +using namespace std; + +bool isNumeric( const char* pszInput, int nNumberBase ) +{ + istringstream iss( pszInput ); + + if ( nNumberBase == 10 ) + { + double dTestSink; + iss >> dTestSink; + } + else if ( nNumberBase == 8 || nNumberBase == 16 ) + { + int nTestSink; + iss >> ( ( nNumberBase == 8 ) ? oct : hex ) >> nTestSink; + } + else + return false; + + // was any input successfully consumed/converted? + if ( ! iss ) + return false; + + // was all the input successfully consumed/converted? + return ( iss.rdbuf()->in_avail() == 0 ); +} diff --git a/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-2.cpp b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-2.cpp new file mode 100644 index 0000000000..a10b821d80 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-2.cpp @@ -0,0 +1,7 @@ +bool isNumeric( const char* pszInput, int nNumberBase ) +{ + string base = "0123456789ABCDEF"; + string input = pszInput; + + return (input.find_first_not_of(base.substr(0, nNumberBase)) == string::npos); +} diff --git a/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-3.cpp b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-3.cpp new file mode 100644 index 0000000000..94c934e8bc --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/C++/determine-if-a-string-is-numeric-3.cpp @@ -0,0 +1,3 @@ +bool isNumeric(const std::string& input) { + return std::all_of(input.begin(), input.end(), ::isdigit); +} diff --git a/Task/Determine-if-a-string-is-numeric/ColdFusion/determine-if-a-string-is-numeric.cfm b/Task/Determine-if-a-string-is-numeric/ColdFusion/determine-if-a-string-is-numeric.cfm new file mode 100644 index 0000000000..ed3842823a --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/ColdFusion/determine-if-a-string-is-numeric.cfm @@ -0,0 +1,15 @@ + + TestValue: #TestValue#
+ + is Numeric. + + is NOT Numeric. + + + + TestValue: #TestValue#
+ + is Numeric. + + is NOT Numeric. + diff --git a/Task/Determine-if-a-string-is-numeric/Common-Lisp/determine-if-a-string-is-numeric-1.lisp b/Task/Determine-if-a-string-is-numeric/Common-Lisp/determine-if-a-string-is-numeric-1.lisp new file mode 100644 index 0000000000..ae265e64dd --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Common-Lisp/determine-if-a-string-is-numeric-1.lisp @@ -0,0 +1,3 @@ +(defun numeric-string-p (string) + (let ((*read-eval* nil)) + (ignore-errors (numberp (read-from-string string))))) diff --git a/Task/Determine-if-a-string-is-numeric/Common-Lisp/determine-if-a-string-is-numeric-2.lisp b/Task/Determine-if-a-string-is-numeric/Common-Lisp/determine-if-a-string-is-numeric-2.lisp new file mode 100644 index 0000000000..8f2e5a1fd3 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Common-Lisp/determine-if-a-string-is-numeric-2.lisp @@ -0,0 +1,5 @@ +(defun numeric-string-p (string) + (handler-case (progn (parse-number:parse-number string) + t) ; parse succeeded, discard it and return true (t) + (parse-number::invalid-number () + nil))) ; parse failed, return false (nil) diff --git a/Task/Determine-if-a-string-is-numeric/D/determine-if-a-string-is-numeric-1.d b/Task/Determine-if-a-string-is-numeric/D/determine-if-a-string-is-numeric-1.d new file mode 100644 index 0000000000..83c1e79a64 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/D/determine-if-a-string-is-numeric-1.d @@ -0,0 +1,9 @@ +import std.stdio, std.string, std.array; + +void main() { + foreach (const s; ["12", " 12\t", "hello12", "-12", "02" + "0-12", "+12", "1.5", "1,000", "1_000", + "0x10", "0b10101111_11110000_11110000_00110011", + "-0b10101", "0x10.5"]) + writefln(`isNumeric("%s"): %s`, s, s.strip().isNumeric(true)); +} diff --git a/Task/Determine-if-a-string-is-numeric/D/determine-if-a-string-is-numeric-2.d b/Task/Determine-if-a-string-is-numeric/D/determine-if-a-string-is-numeric-2.d new file mode 100644 index 0000000000..42d4928c3c --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/D/determine-if-a-string-is-numeric-2.d @@ -0,0 +1,27 @@ +import std.stdio, std.string, std.conv, std.array, std.exception; + +bool isNumeric(in string s) /*pure*/ { + const s2 = s.strip().toLower().replace("_", "").replace(",", ""); + try { + s2.to!real(); + } catch (ConvException e) { + if (s2.startsWith("0x")) + return !to!ulong(s2[2 .. $], 16) + .collectException!ConvException(); + else if (s2.startsWith("0b")) + return !to!ulong(s2[2 .. $], 2) + .collectException!ConvException(); + else + return false; + } + + return true; +} + +void main() { + foreach (const s; ["12", " 12\t", "hello12", "-12", "02" + "0-12", "+12", "1.5", "1,000", "1_000", + "0x10", "0b10101111_11110000_11110000_00110011", + "-0b10101", "0x10.5"]) + writefln(`isNumeric("%s"): %s`, s, isNumeric(s)); +} diff --git a/Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-1.delphi b/Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-1.delphi new file mode 100644 index 0000000000..c45a422e20 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-1.delphi @@ -0,0 +1,6 @@ +function IsNumericString(const inStr: string): Boolean; +var + i: extended; +begin + Result := TryStrToFloat(inStr,i); +end; diff --git a/Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-2.delphi b/Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-2.delphi new file mode 100644 index 0000000000..b3621621a6 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Delphi/determine-if-a-string-is-numeric-2.delphi @@ -0,0 +1,51 @@ +program isNumeric; + +{$APPTYPE CONSOLE} + +uses + Classes, + SysUtils; + +function IsNumericString(const inStr: string): Boolean; +var + i: extended; +begin + Result := TryStrToFloat(inStr,i); +end; + + +{ Test function } +var + s: string; + c: Integer; + +const + MAX_TRIES = 10; + sPROMPT = 'Enter a string (or type "quit" to exit):'; + sIS = ' is numeric'; + sISNOT = ' is NOT numeric'; + +begin + c := 0; + s := ''; + repeat + Inc(c); + Writeln(sPROMPT); + Readln(s); + if (s <> '') then + begin + tmp.Add(s); + if IsNumericString(s) then + begin + Writeln(s+sIS); + end + else + begin + Writeln(s+sISNOT); + end; + Writeln(''); + end; + until + (c >= MAX_TRIES) or (LowerCase(s) = 'quit'); + +end. diff --git a/Task/Determine-if-a-string-is-numeric/E/determine-if-a-string-is-numeric.e b/Task/Determine-if-a-string-is-numeric/E/determine-if-a-string-is-numeric.e new file mode 100644 index 0000000000..8a435b5cb7 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/E/determine-if-a-string-is-numeric.e @@ -0,0 +1,8 @@ +def isNumeric(specimen :String) { + try { + .valueOf(specimen) + return true + } catch _ { + return false + } +} diff --git a/Task/Determine-if-a-string-is-numeric/Euphoria/determine-if-a-string-is-numeric.euphoria b/Task/Determine-if-a-string-is-numeric/Euphoria/determine-if-a-string-is-numeric.euphoria new file mode 100644 index 0000000000..c7c2dbe767 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Euphoria/determine-if-a-string-is-numeric.euphoria @@ -0,0 +1,7 @@ +include get.e + +function is_numeric(sequence s) + sequence val + val = value(s) + return val[1]=GET_SUCCESS and atom(val[2]) +end function diff --git a/Task/Determine-if-only-one-instance-is-running/0DESCRIPTION b/Task/Determine-if-only-one-instance-is-running/0DESCRIPTION new file mode 100644 index 0000000000..e1c7805f4a --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/0DESCRIPTION @@ -0,0 +1 @@ +This task is to determine if there is only one instance of an application running. If the program discovers that an instance of it is already running, then it should display a message indicating that it is already running and exit. diff --git a/Task/Determine-if-only-one-instance-is-running/1META.yaml b/Task/Determine-if-only-one-instance-is-running/1META.yaml new file mode 100644 index 0000000000..f6d82c59ad --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming environment operations diff --git a/Task/Determine-if-only-one-instance-is-running/Ada/determine-if-only-one-instance-is-running.ada b/Task/Determine-if-only-one-instance-is-running/Ada/determine-if-only-one-instance-is-running.ada new file mode 100644 index 0000000000..c7e023d564 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Ada/determine-if-only-one-instance-is-running.ada @@ -0,0 +1,28 @@ +with Ada.Text_IO; + +procedure Single_Instance is + + package IO renames Ada.Text_IO; + Lock_File: IO.File_Type; + Lock_File_Name: String := "single_instance.magic_lock"; + +begin + begin + IO.Open(File => Lock_File, Mode=> IO.In_File, Name => Lock_File_Name); + IO.Close(Lock_File); + IO.Put_Line("I can't -- another instance of me is running ..."); + exception + when IO.Name_Error => + IO.Put_Line("I can run!"); + IO.Create(File => Lock_File, Name => Lock_File_Name); + for I in 1 .. 10 loop + IO.Put(Integer'Image(I)); + delay 1.0; -- wait one second + end loop; + IO.Delete(Lock_File); + IO.New_Line; + IO.Put_Line("I am done!"); + end; +exception + when others => IO.Delete(Lock_File); +end Single_Instance; diff --git a/Task/Determine-if-only-one-instance-is-running/BBC-BASIC/determine-if-only-one-instance-is-running.bbc b/Task/Determine-if-only-one-instance-is-running/BBC-BASIC/determine-if-only-one-instance-is-running.bbc new file mode 100644 index 0000000000..fbe864f7f7 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/BBC-BASIC/determine-if-only-one-instance-is-running.bbc @@ -0,0 +1,11 @@ + SYS "CreateMutex", 0, 1, "UniqueLockName" TO Mutex% + SYS "GetLastError" TO lerr% + IF lerr% = 183 THEN + SYS "CloseHandle", Mutex% + SYS "MessageBox", @hwnd%, "I am already running", 0, 0 + QUIT + ENDIF + + SYS "ReleaseMutex", Mutex% + SYS "CloseHandle", Mutex% + END diff --git a/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-1.cpp b/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-1.cpp new file mode 100644 index 0000000000..66234f5a92 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-1.cpp @@ -0,0 +1 @@ +#include diff --git a/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-2.cpp b/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-2.cpp new file mode 100644 index 0000000000..d799f0d90a --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-2.cpp @@ -0,0 +1 @@ +HANDLE mutex; diff --git a/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-3.cpp b/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-3.cpp new file mode 100644 index 0000000000..adccaaa4f0 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-3.cpp @@ -0,0 +1,5 @@ +mutex = CreateMutex( NULL, TRUE, "MyApp" ); +if ( GetLastError() == ERROR_ALREADY_EXISTS ) +{ + // There's another instance running. What do you do? +} diff --git a/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-4.cpp b/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-4.cpp new file mode 100644 index 0000000000..79e0f9abd3 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/C++/determine-if-only-one-instance-is-running-4.cpp @@ -0,0 +1 @@ +CloseHandle( mutex ); diff --git a/Task/Determine-if-only-one-instance-is-running/C/determine-if-only-one-instance-is-running-1.c b/Task/Determine-if-only-one-instance-is-running/C/determine-if-only-one-instance-is-running-1.c new file mode 100644 index 0000000000..c3f6fd4774 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/C/determine-if-only-one-instance-is-running-1.c @@ -0,0 +1,94 @@ +#include /* fcntl, open */ +#include /* atexit, getenv, malloc */ +#include /* fputs, printf, puts, snprintf */ +#include /* memcpy */ +#include /* sleep, unlink */ + +/* Filename for only_one_instance() lock. */ +#define INSTANCE_LOCK "rosetta-code-lock" + +void +fail(const char *message) +{ + perror(message); + exit(1); +} + +/* Path to only_one_instance() lock. */ +static char *ooi_path; + +void +ooi_unlink(void) +{ + unlink(ooi_path); +} + +/* Exit if another instance of this program is running. */ +void +only_one_instance(void) +{ + struct flock fl; + size_t dirlen; + int fd; + char *dir; + + /* + * Place the lock in the home directory of this user; + * therefore we only check for other instances by the same + * user (and the user can trick us by changing HOME). + */ + dir = getenv("HOME"); + if (dir == NULL || dir[0] != '/') { + fputs("Bad home directory.\n", stderr); + exit(1); + } + dirlen = strlen(dir); + + ooi_path = malloc(dirlen + sizeof("/" INSTANCE_LOCK)); + if (ooi_path == NULL) + fail("malloc"); + memcpy(ooi_path, dir, dirlen); + memcpy(ooi_path + dirlen, "/" INSTANCE_LOCK, + sizeof("/" INSTANCE_LOCK)); /* copies '\0' */ + + fd = open(ooi_path, O_RDWR | O_CREAT, 0600); + if (fd < 0) + fail(ooi_path); + + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = F_WRLCK; + fl.l_whence = SEEK_SET; + if (fcntl(fd, F_SETLK, &fl) < 0) { + fputs("Another instance of this program is running.\n", + stderr); + exit(1); + } + + /* + * Run unlink(ooi_path) when the program exits. The program + * always releases locks when it exits. + */ + atexit(ooi_unlink); +} + +/* + * Demo for Rosetta Code. + * http://rosettacode.org/wiki/Determine_if_only_one_instance_is_running + */ +int +main() +{ + int i; + + only_one_instance(); + + /* Play for 10 seconds. */ + for(i = 10; i > 0; i--) { + printf("%d...%s", i, i % 5 == 1 ? "\n" : " "); + fflush(stdout); + sleep(1); + } + puts("Fin!"); + return 0; +} diff --git a/Task/Determine-if-only-one-instance-is-running/C/determine-if-only-one-instance-is-running-2.c b/Task/Determine-if-only-one-instance-is-running/C/determine-if-only-one-instance-is-running-2.c new file mode 100644 index 0000000000..257f9d6799 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/C/determine-if-only-one-instance-is-running-2.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +/* unistd for sleep */ + +void sigint_handler(int sig) +{ + fprintf(stderr, "Caught signal %d.\n", sig); + unlink("/tmp/MyUniqueName"); + /* exit() is not safe in a signal handler, use _exit() */ + _exit(1); +} + +int main() +{ + struct sigaction act; + int myfd; + + myfd = open("/tmp/MyUniqueName", O_CREAT|O_EXCL); + if ( myfd < 0 ) + { + fprintf(stderr, "I am already running!\n"); + exit(1); + } + act.sa_handler = sigint_handler; + sigemptyset(&act.sa_mask); + act.sa_flags = 0; + sigaction(SIGINT, &act, NULL); + /* here the real code of the app*/ + sleep(20); + /* end of the app */ + unlink("/tmp/MyUniqueName"); close(myfd); + return 0; +} diff --git a/Task/Determine-if-only-one-instance-is-running/Clojure/determine-if-only-one-instance-is-running.clj b/Task/Determine-if-only-one-instance-is-running/Clojure/determine-if-only-one-instance-is-running.clj new file mode 100644 index 0000000000..09694f0048 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Clojure/determine-if-only-one-instance-is-running.clj @@ -0,0 +1,5 @@ +(import (java.net ServerSocket InetAddress)) + +(def *port* 12345) ; random large port number +(try (new ServerSocket *port* 10 (. InetAddress getLocalHost)) + (catch IOException e (System/exit 0))) ; port taken, so app is already running diff --git a/Task/Determine-if-only-one-instance-is-running/Delphi/determine-if-only-one-instance-is-running.delphi b/Task/Determine-if-only-one-instance-is-running/Delphi/determine-if-only-one-instance-is-running.delphi new file mode 100644 index 0000000000..157cf4d2e7 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Delphi/determine-if-only-one-instance-is-running.delphi @@ -0,0 +1,27 @@ +program OneInstance; + +{$APPTYPE CONSOLE} + +uses SysUtils, Windows; + +var + FMutex: THandle; +begin + FMutex := CreateMutex(nil, True, 'OneInstanceMutex'); + if FMutex = 0 then + RaiseLastOSError + else + begin + try + if GetLastError = ERROR_ALREADY_EXISTS then + Writeln('Program already running. Closing...') + else + begin + // do stuff ... + Readln; + end; + finally + CloseHandle(FMutex); + end; + end; +end. diff --git a/Task/Determine-if-only-one-instance-is-running/Go/determine-if-only-one-instance-is-running.go b/Task/Determine-if-only-one-instance-is-running/Go/determine-if-only-one-instance-is-running.go new file mode 100644 index 0000000000..bdb8d8c615 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Go/determine-if-only-one-instance-is-running.go @@ -0,0 +1,49 @@ +package main + +import ( + "fmt" + "os" + "strconv" + "strings" + "time" +) + +// The path to the lock file should be an absolute path starting from the root. +// (If you wish to prevent the same program running in different directories, that is.) +const lfn = "/tmp/rclock" + +func main() { + lf, err := os.OpenFile(lfn, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) + if err == nil { + // good + // 10 digit pid seems to be a standard for lock files + fmt.Fprintf(lf, "%10d", os.Getpid()) + lf.Close() + defer os.Remove(lfn) + } else { + // problem + fmt.Println(err) + // dig deeper + lf, err = os.Open(lfn) + if err != nil { + return + } + defer lf.Close() + fmt.Println("inspecting lock file...") + b10 := make([]byte, 10) + _, err = lf.Read(b10) + if err != nil { + fmt.Println(err) + return + } + pid, err := strconv.Atoi(strings.TrimSpace(string(b10))) + if err != nil { + fmt.Println(err) + return + } + fmt.Println("lock file created by pid", pid) + return + } + fmt.Println(os.Getpid(), "running...") + time.Sleep(1e10) +} diff --git a/Task/Determine-if-only-one-instance-is-running/Haskell/determine-if-only-one-instance-is-running.hs b/Task/Determine-if-only-one-instance-is-running/Haskell/determine-if-only-one-instance-is-running.hs new file mode 100644 index 0000000000..376572c5e2 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Haskell/determine-if-only-one-instance-is-running.hs @@ -0,0 +1,42 @@ +import Control.Concurrent +import System.Directory (doesFileExist, getAppUserDataDirectory, + removeFile) +import System.IO (withFile, Handle, IOMode(WriteMode), hPutStr) + +oneInstance :: IO () +oneInstance = do + -- check if file "$HOME/.myapp.lock" exists + user <- getAppUserDataDirectory "myapp.lock" + locked <- doesFileExist user + if locked + then print "There is already one instance of this program running." + else do + t <- myThreadId + -- this is the entry point to the main program: + -- withFile creates a file, then calls a function, + -- then closes the file + withFile user WriteMode (do_program t) + -- remove the lock when we're done + removeFile user + +do_program :: ThreadId -> Handle -> IO () +do_program t h = do + let s = "Locked by thread: " ++ show t + -- print what thread has acquired the lock + putStrLn s + -- write the same message to the file, to show that the + -- thread "owns" the file + hPutStr h s + -- wait for one second + threadDelay 1000000 + +main :: IO () +main = do + -- launch the first thread, which will create the lock file + forkIO oneInstance + -- wait for half a second + threadDelay 500000 + -- launch the second thread, which will find the lock file and + -- thus will exit immediately + forkIO oneInstance + return () diff --git a/Task/Determine-if-only-one-instance-is-running/Java/determine-if-only-one-instance-is-running.java b/Task/Determine-if-only-one-instance-is-running/Java/determine-if-only-one-instance-is-running.java new file mode 100644 index 0000000000..c6029dcfba --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Java/determine-if-only-one-instance-is-running.java @@ -0,0 +1,23 @@ +import java.io.IOExeception; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.UnknownHostException; + +public class SingletonApp +{ + private static final int PORT = 12345; // random large port number + private static ServerSocket s; + + // static initializer + { + try { + s = new ServerSocket(PORT, 10, InetAddress.getLocalHost()); + } catch (UnknownHostException e) { + // shouldn't happen for localhost + } catch (IOException e) { + // port taken, so app is already running + System.exit(0); + } + } + // main() and rest of application... +} diff --git a/Task/Determine-if-only-one-instance-is-running/Perl/determine-if-only-one-instance-is-running.pl b/Task/Determine-if-only-one-instance-is-running/Perl/determine-if-only-one-instance-is-running.pl new file mode 100644 index 0000000000..6c7ab49391 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Perl/determine-if-only-one-instance-is-running.pl @@ -0,0 +1,9 @@ +use Fcntl ':flock'; + +INIT +{ + die "Not able to open $0\n" unless (open ME, $0); + die "I'm already running !!\n" unless(flock ME, LOCK_EX|LOCK_NB); +} + +sleep 60; # then your code goes here diff --git a/Task/Determine-if-only-one-instance-is-running/PicoLisp/determine-if-only-one-instance-is-running-1.l b/Task/Determine-if-only-one-instance-is-running/PicoLisp/determine-if-only-one-instance-is-running-1.l new file mode 100644 index 0000000000..e7734fb4a8 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/PicoLisp/determine-if-only-one-instance-is-running-1.l @@ -0,0 +1,3 @@ +$ pil + +: (call "killall" "-0" "-q" "myScript") +-> T diff --git a/Task/Determine-if-only-one-instance-is-running/PicoLisp/determine-if-only-one-instance-is-running-2.l b/Task/Determine-if-only-one-instance-is-running/PicoLisp/determine-if-only-one-instance-is-running-2.l new file mode 100644 index 0000000000..301787278a --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/PicoLisp/determine-if-only-one-instance-is-running-2.l @@ -0,0 +1,2 @@ +: (acquire "running1") +-> 30817 # A successful call returns the PID diff --git a/Task/Determine-if-only-one-instance-is-running/Python/determine-if-only-one-instance-is-running.py b/Task/Determine-if-only-one-instance-is-running/Python/determine-if-only-one-instance-is-running.py new file mode 100644 index 0000000000..76a42c3792 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Python/determine-if-only-one-instance-is-running.py @@ -0,0 +1,8 @@ +import __main__, os + +def isOnlyInstance(): + # Determine if there are more than the current instance of the application + # running at the current time. + return os.system("(( $(ps -ef | grep python | grep '[" + + __main__.__file__[0] + "]" + __main__.__file__[1:] + + "' | wc -l) > 1 ))") != 0 diff --git a/Task/Determine-if-only-one-instance-is-running/Ruby/determine-if-only-one-instance-is-running.rb b/Task/Determine-if-only-one-instance-is-running/Ruby/determine-if-only-one-instance-is-running.rb new file mode 100644 index 0000000000..0b4aa505ab --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Ruby/determine-if-only-one-instance-is-running.rb @@ -0,0 +1,15 @@ +def main + puts "first instance" + sleep 20 + puts :done +end + +if $0 == __FILE__ + if File.new(__FILE__).flock(File::LOCK_EX | File::LOCK_NB) + main + else + raise "another instance of this program is running" + end +end + +__END__ diff --git a/Task/Determine-if-only-one-instance-is-running/Tcl/determine-if-only-one-instance-is-running.tcl b/Task/Determine-if-only-one-instance-is-running/Tcl/determine-if-only-one-instance-is-running.tcl new file mode 100644 index 0000000000..72df8bf430 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Tcl/determine-if-only-one-instance-is-running.tcl @@ -0,0 +1,10 @@ +package require Tcl 8.6 +try { + # Pick a port number based on the name of the main script executing + socket -server {apply {{chan args} {close $chan}}} -myaddr localhost \ + [expr {1024 + [zlib crc32 [file normalize $::argv0]] % 30000}] +} trap {POSIX EADDRINUSE} {} { + # Generate a nice error message + puts stderr "Application $::argv0 already running?" + exit 1 +} diff --git a/Task/Digital-root/0DESCRIPTION b/Task/Digital-root/0DESCRIPTION new file mode 100644 index 0000000000..02d372d43c --- /dev/null +++ b/Task/Digital-root/0DESCRIPTION @@ -0,0 +1,20 @@ +Related task [[Sum digits of an integer]] + +The digital root (X) of a number (N) is calculated: +: find X as the sum of the digits of N +: find a new X by summing the digits of X repeating until X has only one digit. + +The additive persistence is the number of summations required to obtain the single digit. + +The task is to calculate the additive persistence and the digital root of a number. e.g. +:627615 has additive persistence 2 and digital root of 9; +:39390 has additive persistence 2 and digital root of 6; +:588225 has additive persistence 2 and digital root of 3; +:393900588225 has additive persistence 2 and digital root of 9; + +The digital root may be calculated in bases other than 10. + +See: +*[[Casting out nines]] for this wiki's use of this procedure. +*[[oeis:A010888|Digital root sequence on OEIS]] +*[[oeis:A031286|Additive persistence sequence on OEIS]] diff --git a/Task/Digital-root/Ada/digital-root.ada b/Task/Digital-root/Ada/digital-root.ada new file mode 100644 index 0000000000..ed39a307aa --- /dev/null +++ b/Task/Digital-root/Ada/digital-root.ada @@ -0,0 +1,48 @@ +with Ada.Text_IO; + +procedure Digital_Root is + + type Number is range 0 .. 2**63-1; + type Number_Array is array(Positive range <>) of Number; + type Base_Type is range 2 .. 16; -- any reasonable base to write down numbers + + procedure Compute(N: Number; Digital_Root, Persistence: out Number; + Base: Base_Type := 10) is + + function Digit_Sum(N: Number) return Number is + begin + if N < Number(Base) then + return N; + else + return (N mod Number(Base)) + Digit_Sum(N / Number(Base)); + end if; + end Digit_Sum; + + begin + if N < Number(Base) then + Digital_Root := N; + Persistence := 0; + else + Compute(Digit_Sum(N), Digital_Root, Persistence, Base); + Persistence := Persistence + 1; + end if; + end Compute; + + procedure Compute_And_Write(Values: Number_Array; Base: Base_Type := 10) is + Root, Pers: Number; + package NIO is new Ada.Text_IO.Integer_IO(Number); + begin + for I in Values'Range loop + Compute(Values(I), Root, Pers, Base); + NIO.Put(Values(I), Base => Integer(Base), Width => 12); + Ada.Text_IO.Put(" has digital root "); + NIO.Put(Root, Base => Integer(Base), Width => 0); + Ada.Text_IO.Put(" and additive persistence" & Number'Image(Pers)); + Ada.Text_IO.Put_Line(" (base" & Base_Type'Image(Base) & ")."); + end loop; + end Compute_And_Write; + +begin + Compute_And_Write((961038, 923594037444, 670033, 448944221089)); + Compute_And_Write((16#7e0#, 16#14e344#, 16#12343210#), 16); +end Digital_Root; diff --git a/Task/Digital-root/BASIC/digital-root.bas b/Task/Digital-root/BASIC/digital-root.bas new file mode 100644 index 0000000000..59b9471d0f --- /dev/null +++ b/Task/Digital-root/BASIC/digital-root.bas @@ -0,0 +1,24 @@ +DECLARE SUB digitalRoot (what AS LONG) + +'test inputs: +digitalRoot 627615 +digitalRoot 39390 +digitalRoot 588225 + +SUB digitalRoot (what AS LONG) + DIM w AS LONG, t AS LONG, c AS INTEGER + + w = ABS(what) + IF w > 10 THEN + DO + c = c + 1 + WHILE w + t = t + (w MOD (10)) + w = w \ 10 + WEND + w = t + t = 0 + LOOP WHILE w > 9 + END IF + PRINT what; ": additive persistance "; c; ", digital root "; w +END SUB diff --git a/Task/Digital-root/BBC-BASIC/digital-root.bbc b/Task/Digital-root/BBC-BASIC/digital-root.bbc new file mode 100644 index 0000000000..a87badc0e8 --- /dev/null +++ b/Task/Digital-root/BBC-BASIC/digital-root.bbc @@ -0,0 +1,29 @@ + *FLOAT64 + PRINT "Digital root of 627615 is "; FNdigitalroot(627615, 10, p) ; + PRINT " (additive persistence " ; p ")" + PRINT "Digital root of 39390 is "; FNdigitalroot(39390, 10, p) ; + PRINT " (additive persistence " ; p ")" + PRINT "Digital root of 588225 is "; FNdigitalroot(588225, 10, p) ; + PRINT " (additive persistence " ; p ")" + PRINT "Digital root of 393900588225 is "; FNdigitalroot(393900588225, 10, p) ; + PRINT " (additive persistence " ; p ")" + PRINT "Digital root of 9992 is "; FNdigitalroot(9992, 10, p) ; + PRINT " (additive persistence " ; p ")" + END + + DEF FNdigitalroot(n, b, RETURN c) + c = 0 + WHILE n >= b + c += 1 + n = FNdigitsum(n, b) + ENDWHILE + = n + + DEF FNdigitsum(n, b) + LOCAL q, s + WHILE n <> 0 + q = INT(n / b) + s += n - q * b + n = q + ENDWHILE + = s diff --git a/Task/Digital-root/C++/digital-root.cpp b/Task/Digital-root/C++/digital-root.cpp new file mode 100644 index 0000000000..a68e715484 --- /dev/null +++ b/Task/Digital-root/C++/digital-root.cpp @@ -0,0 +1,32 @@ +// Calculate the Digital Root and Additive Persistance of an Integer - Compiles with gcc4.7 +// +// Nigel Galloway. July 23rd., 2012 +// +#include +#include +#include + +std::tuple DigitalRoot(const unsigned long long int digits, const int BASE = 10) { + int x = SumDigits(digits,BASE); + int ap = 1; + while (x >= BASE) { + x = SumDigits(x,BASE); + ap++; + } + return std::make_tuple(digits,ap,x); +} + +int main() { + const unsigned long long int ip[] = {961038,923594037444,670033,448944221089}; + for (auto i:ip){ + auto res = DigitalRoot(i); + std::cout << std::get<0>(res) << " has digital root " << std::get<2>(res) << " and additive persistance " << std::get<1>(res) << "\n"; + } + std::cout << "\n"; + const unsigned long long int hip[] = {0x7e0,0x14e344,0xd60141,0x12343210}; + for (auto i:hip){ + auto res = DigitalRoot(i,16); + std::cout << std::hex << std::get<0>(res) << " has digital root " << std::get<2>(res) << " and additive persistance " << std::get<1>(res) << "\n"; + } + return 0; +} diff --git a/Task/Digital-root/C/digital-root.c b/Task/Digital-root/C/digital-root.c new file mode 100644 index 0000000000..e73f3529a8 --- /dev/null +++ b/Task/Digital-root/C/digital-root.c @@ -0,0 +1,26 @@ +#include + +int droot(long long int x, int base, int *pers) +{ + int d = 0; + if (pers) + for (*pers = 0; x >= base; x = d, (*pers)++) + for (d = 0; x; d += x % base, x /= base); + else if (x && !(d = x % (base - 1))) + d = base - 1; + + return d; +} + +int main(void) +{ + int i, d, pers; + long long x[] = {627615, 39390, 588225, 393900588225LL}; + + for (i = 0; i < 4; i++) { + d = droot(x[i], 10, &pers); + printf("%lld: pers %d, root %d\n", x[i], pers, d); + } + + return 0; +} diff --git a/Task/Digital-root/D/digital-root.d b/Task/Digital-root/D/digital-root.d new file mode 100644 index 0000000000..a6c63a7903 --- /dev/null +++ b/Task/Digital-root/D/digital-root.d @@ -0,0 +1,37 @@ +import std.stdio, std.typecons, std.conv, std.bigint; + +Tuple!(int, T) digitalRoot(T)(T root, in uint base) /*pure nothrow*/ +in { + assert(base > 1); +} body { + if (root < 0) + root = -root; + int persistence = 0; + while (root >= base) { + auto num = root; + root = 0; + while (num != 0) { + root += num % base; + num /= base; + } + persistence++; + } + return tuple(persistence, root); +} + +void main() { + // import std.stdio, std.conv, std.bigint; + enum f1 = "%s(%d): additive persistance= %d, digital root= %d"; + foreach (b; [2, 3, 8, 10, 16, 36]) { + foreach (n; [5, 627615, 39390, 588225, 393900588225]) + writefln(f1, to!string(n,b), b, digitalRoot(n, b).tupleof); + writeln(); + } + + enum f2 = "(%d): additive persistance= %d, digital root= %d"; + foreach (b; [2, 3, 8, 10, 16, 36]) { + auto n = BigInt("58142718981673030403681039458302204471" ~ + "300738980834668522257090844071443085937"); + writefln(f2, b, digitalRoot(n, b).tupleof); // shortened output + } +} diff --git a/Task/Digital-root/Dc/digital-root.dc b/Task/Digital-root/Dc/digital-root.dc new file mode 100644 index 0000000000..c6d5934fb6 --- /dev/null +++ b/Task/Digital-root/Dc/digital-root.dc @@ -0,0 +1 @@ +?[10~rd10 (x, digRoot 10 x)) [627615, 39390, 588225, 393900588225] diff --git a/Task/Digital-root/Haskell/digital-root-2.hs b/Task/Digital-root/Haskell/digital-root-2.hs new file mode 100644 index 0000000000..3df61a7be5 --- /dev/null +++ b/Task/Digital-root/Haskell/digital-root-2.hs @@ -0,0 +1,52 @@ +import Data.List (elemIndex) +import Data.Maybe (fromJust) +import Numeric (readInt, showIntAtBase) + +-- Return a pair consisting of the additive persistence and digital root of a +-- base b number. +digRoot :: Integer -> Integer -> (Integer, Integer) +digRoot b = find . zip [0..] . iterate (sum . toDigits b) + where find = head . dropWhile ((>= b) . snd) + +-- Print the additive persistence and digital root of a base b number (given as +-- a string). +printDigRoot :: Integer -> String -> IO () +printDigRoot b s = do + let (p, r) = digRoot b $ strToInt b s + putStrLn $ s ++ ": additive persistence " ++ show p ++ + ", digital root " ++ intToStr b r + +-- +-- Utility methods for dealing with numbers in different bases. +-- + +-- Convert a base b number to a list of digits, from least to most significant. +toDigits :: Integral a => a -> a -> [a] +toDigits b n = toDigits' n 0 + where toDigits' 0 0 = [0] + toDigits' 0 _ = [] + toDigits' m _ = let (q, r) = m `quotRem` b in r : toDigits' q r + +-- A list of digits, for bases up to 36. +digits :: String +digits = ['0'..'9'] ++ ['A'..'Z'] + +-- Return a number's base b string representation. +intToStr :: Integral a => a -> a -> String +intToStr b n | b < 2 || b > 36 = error "intToStr: base must be in [2..36]" + | otherwise = showIntAtBase b (digits !!) n "" + +-- Return the number for the base b string representation. +strToInt :: Integral a => a -> String -> a +strToInt b = fst . head . readInt b (`elem` digits) + (fromJust . (`elemIndex` digits)) + +main :: IO () +main = do + printDigRoot 2 "1001100111011110" + printDigRoot 3 "2000000220" + printDigRoot 8 "5566623376301" + printDigRoot 10 "39390" + printDigRoot 16 "99DE" + printDigRoot 36 "50YE8N29" + printDigRoot 36 "37C71GOYNYJ25M3JTQQVR0FXUK0W9QM71C1LVN" diff --git a/Task/Digital-root/Java/digital-root.java b/Task/Digital-root/Java/digital-root.java new file mode 100644 index 0000000000..6e3ced91c7 --- /dev/null +++ b/Task/Digital-root/Java/digital-root.java @@ -0,0 +1,31 @@ +import java.math.BigInteger; + +class DigitalRoot +{ + public static int[] calcDigitalRoot(String number, int base) + { + BigInteger bi = new BigInteger(number, base); + int additivePersistence = 0; + if (bi.signum() < 0) + bi = bi.negate(); + BigInteger biBase = BigInteger.valueOf(base); + while (bi.compareTo(biBase) >= 0) + { + number = bi.toString(base); + bi = BigInteger.ZERO; + for (int i = 0; i < number.length(); i++) + bi = bi.add(new BigInteger(number.substring(i, i + 1), base)); + additivePersistence++; + } + return new int[] { additivePersistence, bi.intValue() }; + } + + public static void main(String[] args) + { + for (String arg : args) + { + int[] results = calcDigitalRoot(arg, 10); + System.out.println(arg + " has additive persistence " + results[0] + " and digital root of " + results[1]); + } + } +} diff --git a/Task/Digital-root/PicoLisp/digital-root.l b/Task/Digital-root/PicoLisp/digital-root.l new file mode 100644 index 0000000000..ec0251eafb --- /dev/null +++ b/Task/Digital-root/PicoLisp/digital-root.l @@ -0,0 +1,4 @@ +(for N (627615 39390 588225 393900588225) + (for ((A . I) N T (sum format (chop I))) + (T (> 10 I) + (prinl N " has additive persistance " (dec A) " and digital root of " I ";") ) ) ) diff --git a/Task/Digital-root/Python/digital-root.py b/Task/Digital-root/Python/digital-root.py new file mode 100644 index 0000000000..53491cb521 --- /dev/null +++ b/Task/Digital-root/Python/digital-root.py @@ -0,0 +1,10 @@ +def droot (n): + x = [n] + while x[-1] > 10: + x.append(sum(int(dig) for dig in str(x[-1]))) + return len(x) - 1, x[-1] + +for n in [627615, 39390, 588225, 393900588225]: + a, d = droot (n) + print "%12i has additive persistance %2i and digital root of %i" % ( + n, a, d) diff --git a/Task/Digital-root/REXX/digital-root-1.rexx b/Task/Digital-root/REXX/digital-root-1.rexx new file mode 100644 index 0000000000..30304bba13 --- /dev/null +++ b/Task/Digital-root/REXX/digital-root-1.rexx @@ -0,0 +1,27 @@ +/* REXX *************************************************************** +* Test digroot +**********************************************************************/ + /* n r p */ +say right(7 ,12) digroot(7 ) /* 7 7 0 */ +say right(627615 ,12) digroot(627615 ) /* 627615 9 2 */ +say right(39390 ,12) digroot(39390 ) /* 39390 6 2 */ +say right(588225 ,12) digroot(588225 ) /* 588225 3 2 */ +say right(393900588225,12) digroot(393900588225) /*393900588225 9 2 */ + Exit +digroot: Procedure +/********************************************************************** +* Compute the digital root and persistence of the given decimal number +* 25.07.2012 Walter Pachl +**************************** Bottom of Data **************************/ +Parse Arg n /* the number */ +p=0 /* persistence */ +Do While length(n)>1 /* more than one digit in n */ + s=0 /* initialize sum */ + p=p+1 /* increment persistence */ + Do while n<>'' /* as long as there are digits */ + Parse Var n c +1 n /* pick the first one */ + s=s+c /* add to the new sum */ + End + n=s /* the 'new' number */ + End +return n p /* return root and persistence */ diff --git a/Task/Digital-root/REXX/digital-root-2.rexx b/Task/Digital-root/REXX/digital-root-2.rexx new file mode 100644 index 0000000000..ca0869427c --- /dev/null +++ b/Task/Digital-root/REXX/digital-root-2.rexx @@ -0,0 +1,21 @@ +/*REXX program calculates the digital root and additive persistence. */ +numeric digits 1000 /*lets handle biguns.*/ +say 'digital' /*part of the header.*/ +say ' root persistence' center('number',79) /* " " " " */ +say '═══════ ═══════════' center('' ,79,'═') /* " " " " */ +call digRoot 627615 +call digRoot 39390 +call digRoot 588225 +call digRoot 393900588225 +call digRoot 899999999999999999999999999999999999999999999999999999999999999999999999999999999 +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────DIGROOT subroutine──────────────────*/ +digRoot: procedure; parse arg x 1 ox /*get the num, save as original. */ + do pers=0 while length(x)\==1; r=0 /*keep summing until digRoot=1dig*/ + do j=1 for length(x) /*add each digit in the number. */ + r=r+substr(x,j,1) /*add a digit to the digital root*/ + end /*j*/ + x=r /*'new' num, it may be multi-dig.*/ + end /*pers*/ +say center(x,7) center(pers,11) ox /*show a nicely formatted line. */ +return diff --git a/Task/Digital-root/REXX/digital-root-3.rexx b/Task/Digital-root/REXX/digital-root-3.rexx new file mode 100644 index 0000000000..fd0c7c7d3f --- /dev/null +++ b/Task/Digital-root/REXX/digital-root-3.rexx @@ -0,0 +1,11 @@ +/*──────────────────────────────────DIGROOT subroutine──────────────────*/ +digRoot: procedure; parse arg x 1 ox /*get the num, save as original. */ + do pers=0 while length(x)\==1; r=0 /*keep summing until digRoot=1dig*/ + do j=1 for length(x) /*add each digit in the number. */ + ?=substr(x,j,1) /*pick off a char, maybe a dig ? */ + if datatype(?,'W') then r=r+? /*add a digit to the digital root*/ + end /*j*/ + x=r /*'new' num, it may be multi-dig.*/ + end /*pers*/ +say center(x,7) center(pers,11) ox /*show a nicely formatted line. */ +return diff --git a/Task/Digital-root/Racket/digital-root.rkt b/Task/Digital-root/Racket/digital-root.rkt new file mode 100644 index 0000000000..74643da6ce --- /dev/null +++ b/Task/Digital-root/Racket/digital-root.rkt @@ -0,0 +1,25 @@ +#lang racket +(define/contract (additive-persistence/digital-root n (ap 0)) + (->* (natural-number/c) (natural-number/c) (values natural-number/c natural-number/c)) + (define/contract (sum-digits x (acc 0)) + (->* (natural-number/c) (natural-number/c) natural-number/c) + (if (= x 0) + acc + (let-values (((q r) (quotient/remainder x 10))) + (sum-digits q (+ acc r))))) + (if (< n 10) + (values ap n) + (additive-persistence/digital-root (sum-digits n) (+ ap 1)))) + +(module+ test + (require rackunit) + + (for ((n (in-list '(627615 39390 588225 393900588225))) + (ap (in-list '(2 2 2 2))) + (dr (in-list '(9 6 3 9)))) + (call-with-values + (lambda () (additive-persistence/digital-root n)) + (lambda (a d) + (check-equal? a ap) + (check-equal? d dr) + (printf ":~a has additive persistence ~a and digital root of ~a;~%" n a d))))) diff --git a/Task/Digital-root/Scala/digital-root.scala b/Task/Digital-root/Scala/digital-root.scala new file mode 100644 index 0000000000..7551863d8e --- /dev/null +++ b/Task/Digital-root/Scala/digital-root.scala @@ -0,0 +1,12 @@ +def digitalRoot(x:BigInt, base:Int=10):(Int,Int) = { + def sumDigits(x:BigInt):Int=x.toString(base) map (_.asDigit) sum + def loop(s:Int, c:Int):(Int,Int)=if (s < 10) (s, c) else loop(sumDigits(s), c+1) + loop(sumDigits(x), 1) +} + +Seq[BigInt](627615, 39390, 588225, BigInt("393900588225")) foreach {x => + var (s, c)=digitalRoot(x) + println("%d has additive persistance %d and digital root of %d".format(x,c,s)) +} +var (s, c)=digitalRoot(0x7e0, 16) +println("%x has additive persistance %d and digital root of %d".format(0x7e0,c,s)) diff --git a/Task/Digital-root/Tcl/digital-root.tcl b/Task/Digital-root/Tcl/digital-root.tcl new file mode 100644 index 0000000000..69d6eef569 --- /dev/null +++ b/Task/Digital-root/Tcl/digital-root.tcl @@ -0,0 +1,12 @@ +package require Tcl 8.5 +proc digitalroot num { + for {set p 0} {[string length $num] > 1} {incr p} { + set num [::tcl::mathop::+ {*}[split $num ""]] + } + list $p $num +} + +foreach n {627615 39390 588225 393900588225} { + lassign [digitalroot $n] p r + puts [format "$n has additive persistence $p and digital root of $r"] +} diff --git a/Task/Dinesmans-multiple-dwelling-problem/0DESCRIPTION b/Task/Dinesmans-multiple-dwelling-problem/0DESCRIPTION new file mode 100644 index 0000000000..34159920f2 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/0DESCRIPTION @@ -0,0 +1,8 @@ +The task is to '''solve Dinesman's multiple dwelling [http://www-mitpress.mit.edu/sicp/full-text/book/book-Z-H-28.html#%_sec_4.3.2 problem] but in a way that most naturally follows the problem statement given below'''. Solutions are allowed (but not required) to parse and interpret the problem text, but should remain flexible and should state what changes to the problem text are allowed. Flexibility and ease of expression are valued. + +Examples may be be split into "setup", "problem statement", and "output" sections where the ease and naturalness of stating the problem and getting an answer, as well as the ease and flexibility of modifying the problem are the primary concerns. + +Example output should be shown here, as well as any comments on the examples flexibility. + +;The problem: +:''Baker, Cooper, Fletcher, Miller, and Smith live on different floors of an apartment house that contains only five floors. Baker does not live on the top floor. Cooper does not live on the bottom floor. Fletcher does not live on either the top or the bottom floor. Miller lives on a higher floor than does Cooper. Smith does not live on a floor adjacent to Fletcher's. Fletcher does not live on a floor adjacent to Cooper's. Where does everyone live?'' diff --git a/Task/Dinesmans-multiple-dwelling-problem/Ada/dinesmans-multiple-dwelling-problem.ada b/Task/Dinesmans-multiple-dwelling-problem/Ada/dinesmans-multiple-dwelling-problem.ada new file mode 100644 index 0000000000..f5879c27d5 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Ada/dinesmans-multiple-dwelling-problem.ada @@ -0,0 +1,46 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure Dinesman is + subtype Floor is Positive range 1 .. 5; + type People is (Baker, Cooper, Fletcher, Miller, Smith); + type Floors is array (People'Range) of Floor; + type PtFloors is access all Floors; + + function Constrained (f : PtFloors) return Boolean is begin + if f (Baker) /= Floor'Last and + f (Cooper) /= Floor'First and + Floor'First < f (Fletcher) and f (Fletcher) < Floor'Last and + f (Miller) > f (Cooper) and + abs (f (Smith) - f (Fletcher)) /= 1 and + abs (f (Fletcher) - f (Cooper)) /= 1 + then return True; end if; + return False; + end Constrained; + + procedure Solve (list : PtFloors; n : Natural) is + procedure Swap (I : People; J : Natural) is + temp : constant Floor := list (People'Val (J)); + begin list (People'Val (J)) := list (I); list (I) := temp; + end Swap; + begin + if n = 1 then + if Constrained (list) then + for p in People'Range loop + Put_Line (p'Img & " on floor " & list (p)'Img); + end loop; + end if; + return; + end if; + for i in People'First .. People'Val (n - 1) loop + Solve (list, n - 1); + if n mod 2 = 1 then Swap (People'First, n - 1); + else Swap (i, n - 1); end if; + end loop; + end Solve; + + thefloors : aliased Floors; +begin + for person in People'Range loop + thefloors (person) := People'Pos (person) + Floor'First; + end loop; + Solve (thefloors'Access, Floors'Length); +end Dinesman; diff --git a/Task/Dinesmans-multiple-dwelling-problem/BBC-BASIC/dinesmans-multiple-dwelling-problem.bbc b/Task/Dinesmans-multiple-dwelling-problem/BBC-BASIC/dinesmans-multiple-dwelling-problem.bbc new file mode 100644 index 0000000000..a66d249173 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/BBC-BASIC/dinesmans-multiple-dwelling-problem.bbc @@ -0,0 +1,48 @@ + REM Floors are numbered 0 (ground) to 4 (top) + + REM "Baker, Cooper, Fletcher, Miller, and Smith live on different floors": + stmt1$ = "Baker<>Cooper AND Baker<>Fletcher AND Baker<>Miller AND " + \ + \ "Baker<>Smith AND Cooper<>Fletcher AND Cooper<>Miller AND " + \ + \ "Cooper<>Smith AND Fletcher<>Miller AND Fletcher<>Smith AND " + \ + \ "Miller<>Smith" + + REM "Baker does not live on the top floor": + stmt2$ = "Baker<>4" + + REM "Cooper does not live on the bottom floor": + stmt3$ = "Cooper<>0" + + REM "Fletcher does not live on either the top or the bottom floor": + stmt4$ = "Fletcher<>0 AND Fletcher<>4" + + REM "Miller lives on a higher floor than does Cooper": + stmt5$ = "Miller>Cooper" + + REM "Smith does not live on a floor adjacent to Fletcher's": + stmt6$ = "ABS(Smith-Fletcher)<>1" + + REM "Fletcher does not live on a floor adjacent to Cooper's": + stmt7$ = "ABS(Fletcher-Cooper)<>1" + + FOR Baker = 0 TO 4 + FOR Cooper = 0 TO 4 + FOR Fletcher = 0 TO 4 + FOR Miller = 0 TO 4 + FOR Smith = 0 TO 4 + IF EVAL(stmt2$) IF EVAL(stmt3$) IF EVAL(stmt5$) THEN + IF EVAL(stmt4$) IF EVAL(stmt6$) IF EVAL(stmt7$) THEN + IF EVAL(stmt1$) THEN + PRINT "Baker lives on floor " ; Baker + PRINT "Cooper lives on floor " ; Cooper + PRINT "Fletcher lives on floor " ; Fletcher + PRINT "Miller lives on floor " ; Miller + PRINT "Smith lives on floor " ; Smith + ENDIF + ENDIF + ENDIF + NEXT Smith + NEXT Miller + NEXT Fletcher + NEXT Cooper + NEXT Baker + END diff --git a/Task/Dinesmans-multiple-dwelling-problem/Bracmat/dinesmans-multiple-dwelling-problem.bracmat b/Task/Dinesmans-multiple-dwelling-problem/Bracmat/dinesmans-multiple-dwelling-problem.bracmat new file mode 100644 index 0000000000..53b31dff70 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Bracmat/dinesmans-multiple-dwelling-problem.bracmat @@ -0,0 +1,26 @@ +( Baker Cooper Fletcher Miller Smith:?people +& ( constraints + = + . !arg + : ~(? Baker) + : ~(Cooper ?) + : ~(Fletcher ?|? Fletcher) + : ? Cooper ? Miller ? + : ~(? Smith Fletcher ?|? Fletcher Smith ?) + : ~(? Cooper Fletcher ?|? Fletcher Cooper ?) + ) +& ( solution + = floors persons A Z person + . !arg:(?floors.?persons) + & ( !persons: + & constraints$!floors + & out$("Inhabitants, from bottom to top:" !floors) + | !persons + : ?A + %?`person + (?Z&solution$(!floors !person.!A !Z)) + ) + ) +& solution$(.!people) +& +); diff --git a/Task/Dinesmans-multiple-dwelling-problem/C/dinesmans-multiple-dwelling-problem-1.c b/Task/Dinesmans-multiple-dwelling-problem/C/dinesmans-multiple-dwelling-problem-1.c new file mode 100644 index 0000000000..66917bcff2 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/C/dinesmans-multiple-dwelling-problem-1.c @@ -0,0 +1,81 @@ +#include +#include + +int verbose = 0; +#define COND(a, b) int a(int *s) { return (b); } +typedef int(*condition)(int *); + +/* BEGIN problem specific setup */ +#define N_FLOORS 5 +#define TOP (N_FLOORS - 1) +int solution[N_FLOORS] = { 0 }; +int occupied[N_FLOORS] = { 0 }; + +enum tenants { + baker = 0, + cooper, + fletcher, + miller, + smith, + phantom_of_the_opera, +}; + +const char *names[] = { + "baker", + "cooper", + "fletcher", + "miller", + "smith", +}; + +COND(c0, s[baker] != TOP); +COND(c1, s[cooper] != 0); +COND(c2, s[fletcher] != 0 && s[fletcher] != TOP); +COND(c3, s[miller] > s[cooper]); +COND(c4, abs(s[smith] - s[fletcher]) != 1); +COND(c5, abs(s[cooper] - s[fletcher]) != 1); +#define N_CONDITIONS 6 + +condition cond[] = { c0, c1, c2, c3, c4, c5 }; + +/* END of problem specific setup */ + + +int solve(int person) +{ + int i, j; + if (person == phantom_of_the_opera) { + /* check condition */ + for (i = 0; i < N_CONDITIONS; i++) { + if (cond[i](solution)) continue; + + if (verbose) { + for (j = 0; j < N_FLOORS; j++) + printf("%d %s\n", solution[j], names[j]); + printf("cond %d bad\n\n", i); + } + return 0; + } + + printf("Found arrangement:\n"); + for (i = 0; i < N_FLOORS; i++) + printf("%d %s\n", solution[i], names[i]); + return 1; + } + + for (i = 0; i < N_FLOORS; i++) { + if (occupied[i]) continue; + solution[person] = i; + occupied[i] = 1; + if (solve(person + 1)) return 1; + occupied[i] = 0; + } + return 0; +} + +int main() +{ + verbose = 0; + if (!solve(0)) printf("Nobody lives anywhere\n"); + return 0; +} diff --git a/Task/Dinesmans-multiple-dwelling-problem/C/dinesmans-multiple-dwelling-problem-2.c b/Task/Dinesmans-multiple-dwelling-problem/C/dinesmans-multiple-dwelling-problem-2.c new file mode 100644 index 0000000000..2026e0e224 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/C/dinesmans-multiple-dwelling-problem-2.c @@ -0,0 +1,6 @@ +Found arrangement: +2 baker +1 cooper +3 fletcher +4 miller +0 smith diff --git a/Task/Dinesmans-multiple-dwelling-problem/D/dinesmans-multiple-dwelling-problem-1.d b/Task/Dinesmans-multiple-dwelling-problem/D/dinesmans-multiple-dwelling-problem-1.d new file mode 100644 index 0000000000..813395da94 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/D/dinesmans-multiple-dwelling-problem-1.d @@ -0,0 +1,17 @@ +import std.stdio, std.math, std.algorithm, std.traits, permutations2; + +void main() { + enum Names { Baker, Cooper, Fletcher, Miller, Smith } + + immutable(bool function(in Names[]) pure nothrow)[] predicates = [ + s => s[Names.Baker] != s.length - 1, + s => s[Names.Cooper] != 0, + s => s[Names.Fletcher] != 0 && s[Names.Fletcher] != s.length-1, + s => s[Names.Miller] > s[Names.Cooper], + s => abs(s[Names.Smith] - s[Names.Fletcher]) != 1, + s => abs(s[Names.Cooper] - s[Names.Fletcher]) != 1]; + + permutations([EnumMembers!Names]) + .filter!(solution => predicates.all!(pred => pred(solution))) + .writeln; +} diff --git a/Task/Dinesmans-multiple-dwelling-problem/D/dinesmans-multiple-dwelling-problem-2.d b/Task/Dinesmans-multiple-dwelling-problem/D/dinesmans-multiple-dwelling-problem-2.d new file mode 100644 index 0000000000..98f5ee21f3 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/D/dinesmans-multiple-dwelling-problem-2.d @@ -0,0 +1,13 @@ +import std.stdio, std.math, std.algorithm, permutations2; + +void main() { + ["Baker", "Cooper", "Fletcher", "Miller", "Smith"] + .permutations + .filter!(s => + s.countUntil("Baker") != 4 && s.countUntil("Cooper") && + s.countUntil("Fletcher") && s.countUntil("Fletcher") != 4 && + s.countUntil("Miller") > s.countUntil("Cooper") && + abs(s.countUntil("Smith") - s.countUntil("Fletcher")) != 1 && + abs(s.countUntil("Cooper") - s.countUntil("Fletcher")) != 1) + .writeln; +} diff --git a/Task/Dinesmans-multiple-dwelling-problem/Forth/dinesmans-multiple-dwelling-problem.fth b/Task/Dinesmans-multiple-dwelling-problem/Forth/dinesmans-multiple-dwelling-problem.fth new file mode 100644 index 0000000000..0ba8c01784 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Forth/dinesmans-multiple-dwelling-problem.fth @@ -0,0 +1,51 @@ + 0 enum baker \ enumeration of all tenants + enum cooper + enum fletcher + enum miller +constant smith + +create names \ names of all the tenants + ," Baker" + ," Cooper" + ," Fletcher" + ," Miller" + ," Smith" \ get name, type it +does> swap cells + @c count type ." lives in " ; + + 5 constant #floor \ number of floors +#floor 1- constant top \ top floor + 0 constant bottom \ we're counting the floors from 0 + +: num@ c@ [char] 0 - ; ( a -- n) +: floor chars over + num@ ; ( a n1 -- a n2) + \ is it a valid permutation? +: perm? ( n -- a f) + #floor base ! 0 swap s>d <# #floor 0 ?do # loop #> + over >r bounds do 1 i num@ lshift + loop + 31 = r> swap decimal \ create binary mask and check +; + \ test a solution +: solution? ( a -- a f) + baker floor top <> \ baker on top floor? + if cooper floor bottom <> \ cooper on the bottom floor? + if fletcher floor dup bottom <> swap top <> and + if cooper floor swap miller floor rot > + if smith floor swap fletcher floor rot - abs 1 <> + if cooper floor swap fletcher floor rot - abs 1 <> + if true exit then \ we found a solution! + then + then + then + then + then false \ nice try, no cigar.. +; + ( a --) +: .solution #floor 0 do i names i chars over + c@ 1+ emit cr loop drop ; + \ main routine +: dinesman ( --) + 2932 194 do + i perm? if solution? if .solution leave else drop then else drop then + loop +; \ show the solution + +dinesman diff --git a/Task/Dinesmans-multiple-dwelling-problem/Haskell/dinesmans-multiple-dwelling-problem-1.hs b/Task/Dinesmans-multiple-dwelling-problem/Haskell/dinesmans-multiple-dwelling-problem-1.hs new file mode 100644 index 0000000000..96cbe4aa1c --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Haskell/dinesmans-multiple-dwelling-problem-1.hs @@ -0,0 +1,37 @@ +import Data.List (permutations) +import Control.Monad (guard) + +dinesman :: [(Int,Int,Int,Int,Int)] +dinesman = do + -- baker, cooper, fletcher, miller, smith are integers representing + -- the floor that each person lives on, from 1 to 5 + + -- Baker, Cooper, Fletcher, Miller, and Smith live on different floors + -- of an apartment house that contains only five floors. + [baker, cooper, fletcher, miller, smith] <- permutations [1..5] + + -- Baker does not live on the top floor. + guard $ baker /= 5 + + -- Cooper does not live on the bottom floor. + guard $ cooper /= 1 + + -- Fletcher does not live on either the top or the bottom floor. + guard $ fletcher /= 5 && fletcher /= 1 + + -- Miller lives on a higher floor than does Cooper. + guard $ miller > cooper + + -- Smith does not live on a floor adjacent to Fletcher's. + guard $ abs (smith - fletcher) /= 1 + + -- Fletcher does not live on a floor adjacent to Cooper's. + guard $ abs (fletcher - cooper) /= 1 + + -- Where does everyone live? + return (baker, cooper, fletcher, miller, smith) + +main :: IO () +main = do + print $ head dinesman -- print first solution: (3,2,4,5,1) + print dinesman -- print all solutions (only one): [(3,2,4,5,1)] diff --git a/Task/Dinesmans-multiple-dwelling-problem/Haskell/dinesmans-multiple-dwelling-problem-2.hs b/Task/Dinesmans-multiple-dwelling-problem/Haskell/dinesmans-multiple-dwelling-problem-2.hs new file mode 100644 index 0000000000..5658a86993 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Haskell/dinesmans-multiple-dwelling-problem-2.hs @@ -0,0 +1,2 @@ +import Data.List (permutations) +main = print [ (b,c,f,m,s) | [b,c,f,m,s] <- permutations [1..5], b/=5,c/=1,f/=1,f/=5,m>c,abs(s-f)>1,abs(c-f)>1] diff --git a/Task/Dinesmans-multiple-dwelling-problem/Java/dinesmans-multiple-dwelling-problem.java b/Task/Dinesmans-multiple-dwelling-problem/Java/dinesmans-multiple-dwelling-problem.java new file mode 100644 index 0000000000..29e8dc8242 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Java/dinesmans-multiple-dwelling-problem.java @@ -0,0 +1,64 @@ +import java.util.*; + +class DinesmanMultipleDwelling +{ + private static void generatePermutations(String[] apartmentDwellers, Set set, String curPermutation) + { + for (String s : apartmentDwellers) + { + if (!curPermutation.contains(s)) + { + String nextPermutation = curPermutation + s; + if (nextPermutation.length() == apartmentDwellers.length) + set.add(nextPermutation); + else + generatePermutations(apartmentDwellers, set, nextPermutation); + } + } + return; + } + + private static boolean topFloor(String permutation, String person) + { return permutation.endsWith(person); } + + private static boolean bottomFloor(String permutation, String person) + { return permutation.startsWith(person); } + + public static boolean livesAbove(String permutation, String upperPerson, String lowerPerson) + { return permutation.indexOf(upperPerson) > permutation.indexOf(lowerPerson); } + + public static boolean adjacent(String permutation, String person1, String person2) + { return (Math.abs(permutation.indexOf(person1) - permutation.indexOf(person2)) == 1); } + + private static boolean isPossible(String s) + { + // Conditions here + if (topFloor(s, "B")) + return false; + if (bottomFloor(s, "C")) + return false; + if (topFloor(s, "F") || bottomFloor(s, "F")) + return false; + if (!livesAbove(s, "M", "C")) + return false; + if (adjacent(s, "S", "F")) + return false; + if (adjacent(s, "F", "C")) + return false; + return true; + } + + public static void main(String[] args) + { + Set set = new HashSet(); + generatePermutations(new String[] { "B", "C", "F", "M", "S" }, set, ""); + for (Iterator iterator = set.iterator(); iterator.hasNext(); ) + { + String permutation = iterator.next(); + if (!isPossible(permutation)) + iterator.remove(); + } + for (String s : set) + System.out.println("Possible arrangement: " + s); + } +} diff --git a/Task/Dinesmans-multiple-dwelling-problem/PicoLisp/dinesmans-multiple-dwelling-problem.l b/Task/Dinesmans-multiple-dwelling-problem/PicoLisp/dinesmans-multiple-dwelling-problem.l new file mode 100644 index 0000000000..ed027063f1 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/PicoLisp/dinesmans-multiple-dwelling-problem.l @@ -0,0 +1,27 @@ +# Problem statement +(be dwelling (@Tenants) + (permute (Baker Cooper Fletcher Miller Smith) @Tenants) + (not (topFloor Baker @Tenants)) + (not (bottomFloor Cooper @Tenants)) + (not (or ((topFloor Fletcher @Tenants)) ((bottomFloor Fletcher @Tenants)))) + (higherFloor Miller Cooper @Tenants) + (not (adjacentFloor Smith Fletcher @Tenants)) + (not (adjacentFloor Fletcher Cooper @Tenants)) ) + +# Utility rules +(be topFloor (@Tenant @Lst) + (equal (@ @ @ @ @Tenant) @Lst) ) + +(be bottomFloor (@Tenant @Lst) + (equal (@Tenant @ @ @ @) @Lst) ) + +(be higherFloor (@Tenant1 @Tenant2 @Lst) + (append @ @Rest @Lst) + (equal (@Tenant2 . @Higher) @Rest) + (member @Tenant1 @Higher) ) + +(be adjacentFloor (@Tenant1 @Tenant2 @Lst) + (append @ @Rest @Lst) + (or + ((equal (@Tenant1 @Tenant2 . @) @Rest)) + ((equal (@Tenant2 @Tenant1 . @) @Rest)) ) ) diff --git a/Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-1.pro b/Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-1.pro new file mode 100644 index 0000000000..d865bca5dc --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-1.pro @@ -0,0 +1,82 @@ +:- use_module(library(clpfd)). + +:- dynamic top/1, bottom/1. + +% Baker does not live on the top floor +rule1(L) :- + member((baker, F), L), + top(Top), + F #\= Top. + +% Cooper does not live on the bottom floor. +rule2(L) :- + member((cooper, F), L), + bottom(Bottom), + F #\= Bottom. + +% Fletcher does not live on either the top or the bottom floor. +rule3(L) :- + member((fletcher, F), L), + top(Top), + bottom(Bottom), + F #\= Top, + F #\= Bottom. + +% Miller lives on a higher floor than does Cooper. +rule4(L) :- + member((miller, Fm), L), + member((cooper, Fc), L), + Fm #> Fc. + +% Smith does not live on a floor adjacent to Fletcher's. +rule5(L) :- + member((smith, Fs), L), + member((fletcher, Ff), L), + abs(Fs-Ff) #> 1. + +% Fletcher does not live on a floor adjacent to Cooper's. +rule6(L) :- + member((cooper, Fc), L), + member((fletcher, Ff), L), + abs(Fc-Ff) #> 1. + +init(L) :- + % we need to define top and bottom + assert(bottom(1)), + length(L, Top), + assert(top(Top)), + + % we say that they are all in differents floors + bagof(F, X^member((X, F), L), LF), + LF ins 1..Top, + all_different(LF), + + % Baker does not live on the top floor + rule1(L), + + % Cooper does not live on the bottom floor. + rule2(L), + + % Fletcher does not live on either the top or the bottom floor. + rule3(L), + + % Miller lives on a higher floor than does Cooper. + rule4(L), + + % Smith does not live on a floor adjacent to Fletcher's. + rule5(L), + + % Fletcher does not live on a floor adjacent to Cooper's. + rule6(L). + + +solve(L) :- + bagof(F, X^member((X, F), L), LF), + label(LF). + +dinners :- + retractall(top(_)), retractall(bottom(_)), + L = [(baker, _Fb), (cooper, _Fc), (fletcher, _Ff), (miller, _Fm), (smith, _Fs)], + init(L), + solve(L), + maplist(writeln, L). diff --git a/Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-2.pro b/Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-2.pro new file mode 100644 index 0000000000..caac8c0bb1 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-2.pro @@ -0,0 +1,33 @@ +select([A|As],S):- select(A,S,S1),select(As,S1). +select([],_). + +dinesmans(X) :- + %% Baker, Cooper, Fletcher, Miller, and Smith live on different floors + %% of an apartment house that contains only five floors. + select([Baker,Cooper,Fletcher,Miller,Smith],[1,2,3,4,5]), + + %% Baker does not live on the top floor. + Baker =\= 5, + + %% Cooper does not live on the bottom floor. + Cooper =\= 1, + + %% Fletcher does not live on either the top or the bottom floor. + Fletcher =\= 1, Fletcher =\= 5, + + %% Miller lives on a higher floor than does Cooper. + Miller > Cooper, + + %% Smith does not live on a floor adjacent to Fletcher's. + 1 =\= abs(Smith - Fletcher), + + %% Fletcher does not live on a floor adjacent to Cooper's. + 1 =\= abs(Fletcher - Cooper), + + %% Where does everyone live? + X = ['Baker'(Baker), 'Cooper'(Cooper), 'Fletcher'(Fletcher), + 'Miller'(Miller), 'Smith'(Smith)]. + +main :- bagof( X, dinesmans(X), L ) + -> maplist( writeln, L), nl, write('No more solutions.') + ; write('No solutions.'). diff --git a/Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-3.pro b/Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-3.pro new file mode 100644 index 0000000000..ee8b8a841f --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Prolog/dinesmans-multiple-dwelling-problem-3.pro @@ -0,0 +1,26 @@ +dinesmans(X) :- + %% 1. Baker, Cooper, Fletcher, Miller, and Smith live on different floors + %% of an apartment house that contains only five floors. + Domain = [1,2,3,4,5], + + %% 2. Baker does not live on the top floor. + select(Baker,Domain,D1), Baker =\= 5, + + %% 3. Cooper does not live on the bottom floor. + select(Cooper,D1,D2), Cooper =\= 1, + + %% 4. Fletcher does not live on either the top or the bottom floor. + select(Fletcher,D2,D3), Fletcher =\= 1, Fletcher =\= 5, + + %% 5. Miller lives on a higher floor than does Cooper. + select(Miller,D3,D4), Miller > Cooper, + + %% 6. Smith does not live on a floor adjacent to Fletcher's. + select(Smith,D4,_), 1 =\= abs(Smith - Fletcher), + + %% 7. Fletcher does not live on a floor adjacent to Cooper's. + 1 =\= abs(Fletcher - Cooper), + + %% Where does everyone live? + X = ['Baker'(Baker), 'Cooper'(Cooper), 'Fletcher'(Fletcher), + 'Miller'(Miller), 'Smith'(Smith)]. diff --git a/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-1.py b/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-1.py new file mode 100644 index 0000000000..432fc381fc --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-1.py @@ -0,0 +1,132 @@ +import re +from itertools import product + +problem_re = re.compile(r"""(?msx)(?: + +# Multiple names of form n1, n2, n3, ... , and nK +(?P [a-zA-Z]+ (?: , \s+ [a-zA-Z]+)* (?: ,? \s+ and) \s+ [a-zA-Z]+ ) + +# Flexible floor count (2 to 10 floors) +| (?: .* house \s+ that \s+ contains \s+ only \s+ + (?P two|three|four|five|six|seven|eight|nine|ten ) \s+ floors \s* \.) + +# Constraint: "does not live on the n'th floor" +|(?: (?P \b [a-zA-Z]+ \s+ does \s+ not \s+ live \s+ on \s+ the \s+ + (?: top|bottom|first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth) \s+ floor \s* \. )) + +# Constraint: "does not live on either the I'th or the J'th [ or the K'th ...] floor +|(?P \b [a-zA-Z]+ \s+ does \s+ not \s+ live \s+ on \s+ either + (?: \s+ (?: or \s+)? the \s+ + (?: top|bottom|first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth))+ \s+ floor \s* \. ) + +# Constraint: "P1 lives on a higher/lower floor than P2 does" +|(?P \b [a-zA-Z]+ \s+ lives \s+ on \s+ a \s (?: higher|lower) + \s+ floor \s+ than (?: \s+ does) \s+ [a-zA-Z]+ \s* \. ) + +# Constraint: "P1 does/does not live on a floor adjacent to P2's" +|(?P \b [a-zA-Z]+ \s+ does (?:\s+ not)? \s+ live \s+ on \s+ a \s+ + floor \s+ adjacent \s+ to \s+ [a-zA-Z]+ (?: 's )? \s* \. ) + +# Ask for the solution +|(?P Where \s+ does \s+ everyone \s+ live \s* \?) + +) +""") + +names, lennames = None, None +floors = None +constraint_expr = 'len(set(alloc)) == lennames' # Start with all people on different floors + +def do_namelist(txt): + " E.g. 'Baker, Cooper, Fletcher, Miller, and Smith'" + global names, lennames + names = txt.replace(' and ', ' ').split(', ') + lennames = len(names) + +def do_floorcount(txt): + " E.g. 'five'" + global floors + floors = '||two|three|four|five|six|seven|eight|nine|ten'.split('|').index(txt) + +def do_not_live(txt): + " E.g. 'Baker does not live on the top floor.'" + global constraint_expr + t = txt.strip().split() + who, floor = t[0], t[-2] + w, f = (names.index(who), + ('|first|second|third|fourth|fifth|sixth|' + + 'seventh|eighth|ninth|tenth|top|bottom|').split('|').index(floor) + ) + if f == 11: f = floors + if f == 12: f = 1 + constraint_expr += ' and alloc[%i] != %i' % (w, f) + +def do_not_either(txt): + " E.g. 'Fletcher does not live on either the top or the bottom floor.'" + global constraint_expr + t = txt.replace(' or ', ' ').replace(' the ', ' ').strip().split() + who, floor = t[0], t[6:-1] + w, fl = (names.index(who), + [('|first|second|third|fourth|fifth|sixth|' + + 'seventh|eighth|ninth|tenth|top|bottom|').split('|').index(f) + for f in floor] + ) + for f in fl: + if f == 11: f = floors + if f == 12: f = 1 + constraint_expr += ' and alloc[%i] != %i' % (w, f) + + +def do_hi_lower(txt): + " E.g. 'Miller lives on a higher floor than does Cooper.'" + global constraint_expr + t = txt.replace('.', '').strip().split() + name_indices = [names.index(who) for who in (t[0], t[-1])] + if 'lower' in t: + name_indices = name_indices[::-1] + constraint_expr += ' and alloc[%i] > alloc[%i]' % tuple(name_indices) + +def do_adjacency(txt): + ''' E.g. "Smith does not live on a floor adjacent to Fletcher's."''' + global constraint_expr + t = txt.replace('.', '').replace("'s", '').strip().split() + name_indices = [names.index(who) for who in (t[0], t[-1])] + constraint_expr += ' and abs(alloc[%i] - alloc[%i]) > 1' % tuple(name_indices) + +def do_question(txt): + global constraint_expr, names, lennames + + exec_txt = ''' +for alloc in product(range(1,floors+1), repeat=len(names)): + if %s: + break +else: + alloc = None +''' % constraint_expr + exec(exec_txt, globals(), locals()) + a = locals()['alloc'] + if a: + output= ['Floors are numbered from 1 to %i inclusive.' % floors] + for a2n in zip(a, names): + output += [' Floor %i is occupied by %s' % a2n] + output.sort(reverse=True) + print('\n'.join(output)) + else: + print('No solution found.') + print() + +handler = { + 'namelist': do_namelist, + 'floorcount': do_floorcount, + 'not_live': do_not_live, + 'not_either': do_not_either, + 'hi_lower': do_hi_lower, + 'adjacency': do_adjacency, + 'question': do_question, + } +def parse_and_solve(problem): + p = re.sub(r'\s+', ' ', problem).strip() + for x in problem_re.finditer(p): + groupname, txt = [(k,v) for k,v in x.groupdict().items() if v][0] + #print ("%r, %r" % (groupname, txt)) + handler[groupname](txt) diff --git a/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-2.py b/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-2.py new file mode 100644 index 0000000000..ed839fb01e --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-2.py @@ -0,0 +1,22 @@ +if __name__ == '__main__': + parse_and_solve(""" + Baker, Cooper, Fletcher, Miller, and Smith + live on different floors of an apartment house that contains + only five floors. Baker does not live on the top floor. Cooper + does not live on the bottom floor. Fletcher does not live on + either the top or the bottom floor. Miller lives on a higher + floor than does Cooper. Smith does not live on a floor + adjacent to Fletcher's. Fletcher does not live on a floor + adjacent to Cooper's. Where does everyone live?""") + + print('# Add another person with more constraints and more floors:') + parse_and_solve(""" + Baker, Cooper, Fletcher, Miller, Guinan, and Smith + live on different floors of an apartment house that contains + only seven floors. Guinan does not live on either the top or the third or the fourth floor. + Baker does not live on the top floor. Cooper + does not live on the bottom floor. Fletcher does not live on + either the top or the bottom floor. Miller lives on a higher + floor than does Cooper. Smith does not live on a floor + adjacent to Fletcher's. Fletcher does not live on a floor + adjacent to Cooper's. Where does everyone live?""") diff --git a/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-3.py b/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-3.py new file mode 100644 index 0000000000..2d3eeed4f4 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-3.py @@ -0,0 +1,57 @@ +from amb import Amb + +if __name__ == '__main__': + amb = Amb() + + maxfloors = 5 + floors = range(1, maxfloors+1) + # Possible floors for each person + Baker, Cooper, Fletcher, Miller, Smith = (amb(floors) for i in range(5)) + for _dummy in amb( lambda Baker, Cooper, Fletcher, Miller, Smith: ( + len(set([Baker, Cooper, Fletcher, Miller, Smith])) == 5 # each to a separate floor + and Baker != maxfloors + and Cooper != 1 + and Fletcher not in (maxfloors, 1) + and Miller > Cooper + and (Smith - Fletcher) not in (1, -1) # Not adjacent + and (Fletcher - Cooper) not in (1, -1) # Not adjacent + ) ): + + print 'Floors are numbered from 1 to %i inclusive.' % maxfloors + print '\n'.join(sorted(' Floor %i is occupied by %s' + % (globals()[name], name) + for name in 'Baker, Cooper, Fletcher, Miller, Smith'.split(', '))) + break + else: + print 'No solution found.' + print + + + print '# Add another person with more constraints and more floors:' + # The order that Guinan is added to any list of people must stay consistant + + amb = Amb() + + maxfloors = 7 + floors = range(1, maxfloors+1) + # Possible floors for each person + Baker, Cooper, Fletcher, Miller, Guinan, Smith = (amb(floors) for i in range(6)) + for _dummy in amb( lambda Baker, Cooper, Fletcher, Miller, Guinan, Smith: ( + len(set([Baker, Cooper, Fletcher, Miller, Guinan, Smith])) == 6 # each to a separate floor + and Guinan not in (maxfloors, 3, 4) + and Baker != maxfloors + and Cooper != 1 + and Fletcher not in (maxfloors, 1) + and Miller > Cooper + and (Smith - Fletcher) not in (1, -1) # Not adjacent + and (Fletcher - Cooper) not in (1, -1) # Not adjacent + ) ): + + print 'Floors are numbered from 1 to %i inclusive.' % maxfloors + print '\n'.join(sorted(' Floor %i is occupied by %s' + % (globals()[name], name) + for name in 'Baker, Cooper, Fletcher, Miller, Guinan, Smith'.split(', '))) + break + else: + print 'No solution found.' + print diff --git a/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-4.py b/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-4.py new file mode 100644 index 0000000000..5801b8c2ce --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Python/dinesmans-multiple-dwelling-problem-4.py @@ -0,0 +1,18 @@ +from itertools import permutations + +class Names: + Baker, Cooper, Fletcher, Miller, Smith = range(5) + seq = [Baker, Cooper, Fletcher, Miller, Smith] + strings = "Baker Cooper Fletcher Miller Smith".split() + +predicates = [ + lambda s: s[Names.Baker] != len(s)-1, + lambda s: s[Names.Cooper] != 0, + lambda s: s[Names.Fletcher] != 0 and s[Names.Fletcher] != len(s)-1, + lambda s: s[Names.Miller] > s[Names.Cooper], + lambda s: abs(s[Names.Smith] - s[Names.Fletcher]) != 1, + lambda s: abs(s[Names.Cooper] - s[Names.Fletcher]) != 1]; + +for sol in permutations(Names.seq): + if all(p(sol) for p in predicates): + print " ".join(Names.strings[s] for s in sol) diff --git a/Task/Dinesmans-multiple-dwelling-problem/REXX/dinesmans-multiple-dwelling-problem.rexx b/Task/Dinesmans-multiple-dwelling-problem/REXX/dinesmans-multiple-dwelling-problem.rexx new file mode 100644 index 0000000000..90de6fb764 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/REXX/dinesmans-multiple-dwelling-problem.rexx @@ -0,0 +1,32 @@ +/*REXX pgm: Dinesman's multiple-dwelling problem with "natural" wording.*/ +names= 'Baker Cooper Fletcher Miller Smith' /*names of the tenants.*/ +floors=5; top=floors; bottom=1; #=floors; sols=0 + /*floor 1 is the ground floor. */ + do !.1=1 for #;do !.2=1 for #;do !.3=1 for #;do !.4=1 for #;do !.5=1 for # + do p=1 for words(names); _=word(names,p); upper _; call value _,!.p + end /*p*/ + /* [↓] don't live on same floor.*/ + do j=1 for #-1; do k=j+1 to #; if !.j==!.k then iterate !.5; end;end + + call Waldo /* ◄───────────────────where the rubber meets the road.*/ + end /*!.5*/; end /*!.4*/; end /*!.3*/; end /*!.2*/; end /*!.1*/ + +say; say 'found' sols "solution"s(sols)'.' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────Waldo subroutine────────────────────*/ +Waldo: + if Baker == top then return + if Cooper == bottom then return + if Fletcher == bottom | Fletcher == top then return + if Miller <= Cooper then return + if Smith == Fletcher-1 | Smith == Fletcher+1 then return + if Fletcher == Cooper-1 | Fletcher == Cooper+1 then return + +say; sols=sols+1 /*list tenants in order in list. */ + do p=1 for words(names); _=word(names,p) + say right(_,20) 'lives on the' !.p||th(!.p) "floor." + end /*p*/ +return +/*──────────────────────────────────one-liner subroutines───────────────*/ +s: if arg(1)=1 then return ''; return 's' /*a simple pluralizer funct.*/ +th:procedure;parse arg x;x=abs(x);return word('th st nd rd',1+x//10*(x//100%10\==1)*(x//10<4)) diff --git a/Task/Dinesmans-multiple-dwelling-problem/Ruby/dinesmans-multiple-dwelling-problem.rb b/Task/Dinesmans-multiple-dwelling-problem/Ruby/dinesmans-multiple-dwelling-problem.rb new file mode 100644 index 0000000000..2ab9c3631d --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Ruby/dinesmans-multiple-dwelling-problem.rb @@ -0,0 +1,38 @@ +def dinesman(floors, names, criteria) + # the "bindVars" method returns a context where the "name" variables are bound to values + eval " + def bindVars(#{names.map {|n| n.downcase}.join ','}) + return binding + end + " + expression = criteria.map {|c| "(#{c.downcase})"}.join " and " + + floors.permutation.each do |perm| + b = bindVars *perm + return b if b.eval(expression) + end + nil +end + +floors = (1..5).to_a +names = %w(Baker Cooper Fletcher Miller Smith) +criteria = [ + "Baker != 5", + "Cooper != 1", + "Fletcher != 1", + "Fletcher != 5", + "Miller > Cooper", + "(Smith - Fletcher).abs != 1", + "(Fletcher - Cooper).abs != 1", +] + +b = dinesman(floors, names, criteria) + +if b.nil? + puts "no solution" +else + puts "Found a solution:" + len = names.map {|n| n.length}.max + residents = names.inject({}) {|r, n| r[b.eval(n.downcase)] = n; r} + floors.each {|f| puts " Floor #{f}: #{residents[f]}"} +end diff --git a/Task/Dinesmans-multiple-dwelling-problem/Scala/dinesmans-multiple-dwelling-problem-1.scala b/Task/Dinesmans-multiple-dwelling-problem/Scala/dinesmans-multiple-dwelling-problem-1.scala new file mode 100644 index 0000000000..14ff415481 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Scala/dinesmans-multiple-dwelling-problem-1.scala @@ -0,0 +1,31 @@ +object Dinesman extends App { + + val tenants = List("Baker", "Cooper", "Fletcher", "Miller", "Smith") + val floors = (1 to tenants.size).toList + + // define the predicates + import scala.math.abs + val predicates = + List((perm: Map[String, Int]) => !(perm("Baker")==floors.size) + ,(perm: Map[String, Int]) => !(perm("Cooper")==1) + ,(perm: Map[String, Int]) => !(perm("Fletcher")==1 || perm("Fletcher")==floors.size) + ,(perm: Map[String, Int]) => !(perm("Miller")<=perm("Cooper")) + ,(perm: Map[String, Int]) => !(abs(perm("Smith")-perm("Fletcher"))==1) + ,(perm: Map[String, Int]) => !(abs(perm("Fletcher")-perm("Cooper"))==1) + ) + + val p: Seq[(String, Int)] => Boolean = perm => !predicates.map(_(perm.toMap)).contains(false) + + tenants.permutations.map(_ zip floors).toList + .map(perm=>Pair(perm,p(perm))).filter(_._2==true).map(p=>p._1.toList) + match { + case Nil => println("no solution") + case xss => { println("solutions: "+xss.size) + xss.foreach{l=> + println("possible solution:") + l.foreach(p=>println(" "+p._1+ " lives on floor number "+p._2)) + } + } + } + +} diff --git a/Task/Dinesmans-multiple-dwelling-problem/Scala/dinesmans-multiple-dwelling-problem-2.scala b/Task/Dinesmans-multiple-dwelling-problem/Scala/dinesmans-multiple-dwelling-problem-2.scala new file mode 100644 index 0000000000..72040e4237 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Scala/dinesmans-multiple-dwelling-problem-2.scala @@ -0,0 +1,11 @@ +... + val tenants = List("Baker", "Cooper", "Fletcher", "Miller", "Smith", "Rollo") +... + val predicates = + List((perm: Map[String, Int]) => !(perm("Baker")==floors.size) +... + ,(perm: Map[String, Int]) => !(perm("Rollo")==floors.size || perm("Rollo")==3 || perm("Rollo")==4) + ,(perm: Map[String, Int]) => !(perm("Rollo")>perm("Smith")) + ,(perm: Map[String, Int]) => !(perm("Rollo") $Cooper} + {abs($Smith-$Fletcher) != 1} + {abs($Fletcher-$Cooper) != 1} +}] +puts "Solution found:" +foreach {where who} $soln {puts " Floor ${where}: $who"} diff --git a/Task/Dining-philosophers/0DESCRIPTION b/Task/Dining-philosophers/0DESCRIPTION new file mode 100644 index 0000000000..007fe8b06b --- /dev/null +++ b/Task/Dining-philosophers/0DESCRIPTION @@ -0,0 +1,7 @@ +The dining philosophers problem illustrates non-composability of low-level synchronization primitives like [[semaphore]]s. It is a modification of a problem posed by Edsger Dijkstra. + +Five philosophers, Aristotle, Kant, Spinoza, Marx, and Russell (the [[task]]s) spend their time thinking and eating spaghetti. They eat at a round table with five individual seats. For eating each philosopher needs two forks (the resources). There are five forks on the table, one left and one right of each seat. When a philosopher cannot grab both forks it sits and waits. Eating takes random time, then the philosopher puts the forks down and leaves the dining room. After spending some random time thinking about the nature of the universe, he again becomes hungry, and the circle repeats itself. + +It can be observed that a straightforward solution, when forks are implemented by [[semaphore]]s, is exposed to deadlock. There exist two deadlock states when all five philosophers are sitting at the table holding one fork each. One deadlock state is when each philosopher has grabbed the fork left of him, and another is when each has the fork on his right. + +There are many solutions of the problem, program at least one, and explain how the deadlock is prevented. diff --git a/Task/Dining-philosophers/1META.yaml b/Task/Dining-philosophers/1META.yaml new file mode 100644 index 0000000000..f6cada46d5 --- /dev/null +++ b/Task/Dining-philosophers/1META.yaml @@ -0,0 +1,6 @@ +--- +category: +- Classic CS problems and programs +note: Concurrency +requires: +- Concurrency diff --git a/Task/Dining-philosophers/Ada/dining-philosophers-1.ada b/Task/Dining-philosophers/Ada/dining-philosophers-1.ada new file mode 100644 index 0000000000..664cf7e688 --- /dev/null +++ b/Task/Dining-philosophers/Ada/dining-philosophers-1.ada @@ -0,0 +1,50 @@ +with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random; +with Ada.Text_IO; use Ada.Text_IO; + +with Synchronization.Generic_Mutexes_Array; + +procedure Test_Dining_Philosophers is + type Philosopher is (Aristotle, Kant, Spinoza, Marx, Russel); + package Fork_Arrays is new Synchronization.Generic_Mutexes_Array (Philosopher); + use Fork_Arrays; + + Life_Span : constant := 20; -- In his life a philosopher eats 20 times + Forks : aliased Mutexes_Array; -- Forks for hungry philosophers + + function Left_Of (Fork : Philosopher) return Philosopher is + begin + if Fork = Philosopher'First then + return Philosopher'Last; + else + return Philosopher'Pred (Fork); + end if; + end Left_Of; + + task type Person (ID : Philosopher); + task body Person is + Cutlery : aliased Mutexes_Set := ID or Left_Of (ID); + Dice : Generator; + begin + Reset (Dice); + for Life_Cycle in 1..Life_Span loop + Put_Line (Philosopher'Image (ID) & " is thinking"); + delay Duration (Random (Dice) * 0.100); + Put_Line (Philosopher'Image (ID) & " is hungry"); + declare + Lock : Set_Holder (Forks'Access, Cutlery'Access); + begin + Put_Line (Philosopher'Image (ID) & " is eating"); + delay Duration (Random (Dice) * 0.100); + end; + end loop; + Put_Line (Philosopher'Image (ID) & " is leaving"); + end Person; + + Ph_1 : Person (Aristotle); -- Start philosophers + Ph_2 : Person (Kant); + Ph_3 : Person (Spinoza); + Ph_4 : Person (Marx); + Ph_5 : Person (Russel); +begin + null; -- Nothing to do in the main task, just sit and behold +end Test_Dining_Philosophers; diff --git a/Task/Dining-philosophers/Ada/dining-philosophers-2.ada b/Task/Dining-philosophers/Ada/dining-philosophers-2.ada new file mode 100644 index 0000000000..40ac76f6b3 --- /dev/null +++ b/Task/Dining-philosophers/Ada/dining-philosophers-2.ada @@ -0,0 +1,53 @@ +with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Dining_Philosophers is + type Philosopher is (Aristotle, Kant, Spinoza, Marx, Russel); + protected type Fork is + entry Grab; + procedure Put_Down; + private + Seized : Boolean := False; + end Fork; + protected body Fork is + entry Grab when not Seized is + begin + Seized := True; + end Grab; + procedure Put_Down is + begin + Seized := False; + end Put_Down; + end Fork; + + Life_Span : constant := 20; -- In his life a philosopher eats 20 times + + task type Person (ID : Philosopher; First, Second : not null access Fork); + task body Person is + Dice : Generator; + begin + Reset (Dice); + for Life_Cycle in 1..Life_Span loop + Put_Line (Philosopher'Image (ID) & " is thinking"); + delay Duration (Random (Dice) * 0.100); + Put_Line (Philosopher'Image (ID) & " is hungry"); + First.Grab; + Second.Grab; + Put_Line (Philosopher'Image (ID) & " is eating"); + delay Duration (Random (Dice) * 0.100); + Second.Put_Down; + First.Put_Down; + end loop; + Put_Line (Philosopher'Image (ID) & " is leaving"); + end Person; + + Forks : array (1..5) of aliased Fork; -- Forks for hungry philosophers + -- Start philosophers + Ph_1 : Person (Aristotle, Forks (1)'Access, Forks (2)'Access); + Ph_2 : Person (Kant, Forks (2)'Access, Forks (3)'Access); + Ph_3 : Person (Spinoza, Forks (3)'Access, Forks (4)'Access); + Ph_4 : Person (Marx, Forks (4)'Access, Forks (5)'Access); + Ph_5 : Person (Russel, Forks (1)'Access, Forks (5)'Access); +begin + null; -- Nothing to do in the main task, just sit and behold +end Test_Dining_Philosophers; diff --git a/Task/Dining-philosophers/Ada/dining-philosophers-3.ada b/Task/Dining-philosophers/Ada/dining-philosophers-3.ada new file mode 100644 index 0000000000..c505ecc7a9 --- /dev/null +++ b/Task/Dining-philosophers/Ada/dining-philosophers-3.ada @@ -0,0 +1,75 @@ +with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Dining_Philosophers is + type Philosopher is (Aristotle, Kant, Spinoza, Marx, Russel); + + protected type Fork is + entry Grab; + procedure Put_Down; + private + Seized : Boolean := False; + end Fork; + + protected Host is + entry Greet; + procedure Farewell; + private + Guests : Natural := 0; + end Host; + + protected body Fork is + entry Grab when not Seized is + begin + Seized := True; + end Grab; + procedure Put_Down is + begin + Seized := False; + end Put_Down; + end Fork; + + protected body Host is + entry Greet when Guests < 5 is + begin + Guests := Guests + 1; + end Greet; + procedure Farewell is + begin + Guests := Guests - 1; + end Farewell; + end Host; + + Life_Span : constant := 20; -- In his life a philosopher eats 20 times + + task type Person (ID : Philosopher; Left, Right : not null access Fork); + task body Person is + Dice : Generator; + begin + Reset (Dice); + for Life_Cycle in 1..Life_Span loop + Put_Line (Philosopher'Image (ID) & " is thinking"); + delay Duration (Random (Dice) * 0.100); + Put_Line (Philosopher'Image (ID) & " is hungry"); + Host.Greet; + Left.Grab; + Right.Grab; + Put_Line (Philosopher'Image (ID) & " is eating"); + delay Duration (Random (Dice) * 0.100); + Left.Put_Down; + Right.Put_Down; + Host.Farewell; + end loop; + Put_Line (Philosopher'Image (ID) & " is leaving"); + end Person; + + Forks : array (1..5) of aliased Fork; -- Forks for hungry philosophers + -- Start philosophers + Ph_1 : Person (Aristotle, Forks (1)'Access, Forks (2)'Access); + Ph_2 : Person (Kant, Forks (2)'Access, Forks (3)'Access); + Ph_3 : Person (Spinoza, Forks (3)'Access, Forks (4)'Access); + Ph_4 : Person (Marx, Forks (4)'Access, Forks (5)'Access); + Ph_5 : Person (Russel, Forks (5)'Access, Forks (1)'Access); +begin + null; -- Nothing to do in the main task, just sit and behold +end Test_Dining_Philosophers; diff --git a/Task/Dining-philosophers/BBC-BASIC/dining-philosophers.bbc b/Task/Dining-philosophers/BBC-BASIC/dining-philosophers.bbc new file mode 100644 index 0000000000..3e846b482d --- /dev/null +++ b/Task/Dining-philosophers/BBC-BASIC/dining-philosophers.bbc @@ -0,0 +1,66 @@ + INSTALL @lib$+"TIMERLIB" + + nSeats% = 5 + DIM Name$(nSeats%-1), Fork%(nSeats%-1), tID%(nSeats%-1), Leftie%(nSeats%-1) + + Name$() = "Aristotle", "Kant", "Spinoza", "Marx", "Russell" + Fork%() = TRUE : REM All forks are initially on the table + Leftie%(RND(nSeats%)-1) = TRUE : REM One philosopher is lefthanded + + tID%(0) = FN_ontimer(10, PROCphilosopher0, 1) + tID%(1) = FN_ontimer(10, PROCphilosopher1, 1) + tID%(2) = FN_ontimer(10, PROCphilosopher2, 1) + tID%(3) = FN_ontimer(10, PROCphilosopher3, 1) + tID%(4) = FN_ontimer(10, PROCphilosopher4, 1) + + ON CLOSE PROCcleanup : QUIT + ON ERROR PRINT REPORT$ : PROCcleanup : END + + DEF PROCphilosopher0 : PROCtask(0) : ENDPROC + DEF PROCphilosopher1 : PROCtask(1) : ENDPROC + DEF PROCphilosopher2 : PROCtask(2) : ENDPROC + DEF PROCphilosopher3 : PROCtask(3) : ENDPROC + DEF PROCphilosopher4 : PROCtask(4) : ENDPROC + + REPEAT + WAIT 0 + UNTIL FALSE + END + + DEF PROCtask(n%) + PRIVATE state%(), lh%(), rh%() + DIM state%(nSeats%-1), lh%(nSeats%-1), rh%(nSeats%-1) + REM States: 0 = waiting for forks, > 0 = eating, < 0 = left the room + CASE TRUE OF + WHEN state%(n%) < 0: + state%(n%) += 1 : REM Waiting to get hungry again + IF state%(n%) = 0 PRINT Name$(n%) " is hungry again" + WHEN state%(n%) > 0: + state%(n%) -= 1 : REM Eating + IF state%(n%) = 0 THEN + SWAP Fork%((n%-1+nSeats%) MOD nSeats%), lh%(n%) + SWAP Fork%((n% + 1) MOD nSeats%), rh%(n%) + state%(n%) = -RND(100) + PRINT Name$(n%) " is leaving the room" + ENDIF + WHEN state%(n%) = 0: + IF Leftie%(n%) THEN + IF NOT lh%(n%) SWAP Fork%((n%-1+nSeats%) MOD nSeats%), lh%(n%) + IF lh%(n%) IF NOT rh%(n%) SWAP Fork%((n% + 1) MOD nSeats%), rh%(n%) + ELSE + IF NOT rh%(n%) SWAP Fork%((n% + 1) MOD nSeats%), rh%(n%) + IF rh%(n%) IF NOT lh%(n%) SWAP Fork%((n%-1+nSeats%) MOD nSeats%), lh%(n%) + ENDIF + IF lh%(n%) AND rh%(n%) THEN + state%(n%) = RND(100) + PRINT Name$(n%) " is eating (" ; state%(n%) " ticks)" + ENDIF + ENDCASE + ENDPROC + + DEF PROCcleanup + LOCAL I% + FOR I% = 0 TO nSeats%-1 + PROC_killtimer(tID%(I%)) + NEXT + ENDPROC diff --git a/Task/Dining-philosophers/C++/dining-philosophers.cpp b/Task/Dining-philosophers/C++/dining-philosophers.cpp new file mode 100644 index 0000000000..66fac1aa80 --- /dev/null +++ b/Task/Dining-philosophers/C++/dining-philosophers.cpp @@ -0,0 +1,159 @@ +#include +#include +#include + +#include +#include +#include +#include +#include + +typedef boost::mutex Fork; +typedef boost::shared_ptr< Fork > ForkPtr; +typedef boost::lock_guard< Fork > ForkLock; + +#define MIN_WAIT_TIME 100 +#define NUM_MEALS 10 +#define MAX_JITTER 50 + +template< typename Stream > +class AtomicLogger { +public: + + AtomicLogger( Stream& stream ) : + m_mutex(), + m_stream( stream ) + { + } + + void log( const std::string& str ) { + boost::mutex::scoped_lock lock( m_mutex ); + m_stream << str << std::endl; + } + +private: + mutable boost::mutex m_mutex; + Stream& m_stream; +}; +typedef AtomicLogger< std::ostream > AtomicLoggerOstream; +typedef boost::shared_ptr< AtomicLoggerOstream > AtomicLoggerOstreamPtr; + +class Philosopher { +public: + + Philosopher( + const std::string& name, + ForkPtr fork_left, + ForkPtr fork_right, + AtomicLoggerOstreamPtr p_logger ) : + m_name( name ), + m_continue( true ), + mp_fork_left( fork_left ), + mp_fork_right( fork_right ), + m_thread( boost::thread( boost::bind( &Philosopher::thread_func, + this, + &m_continue, + mp_fork_left, + mp_fork_right ) ) ), + m_meals_left( NUM_MEALS ), + mp_logger( p_logger ) + { + } + + ~Philosopher() { + done_dining(); + wait_for_cmplt(); + } + + void done_dining() { m_continue = false; } + + void wait_for_cmplt() { m_thread.join(); } + +private: + inline bool can_grab_fork( ForkPtr& p_fork ) { return p_fork->try_lock(); } + + void thread_func( volatile bool* p_continue, ForkPtr fork_left, ForkPtr fork_right ) { + bool failed_to_grab_fork = false; + + while( p_continue && m_meals_left ) { + mp_logger->log( boost::str( boost::format( "%1% is thinking" ) % this->m_name ) ); + wait(); + mp_logger->log( boost::str( boost::format( "%1% is hungry" ) % this->m_name ) ); + + // attempt to grab forks + if( can_grab_fork( fork_left ) ) { + ForkLock::lock_guard lock_left( *fork_left, boost::adopt_lock ); + if( can_grab_fork( fork_right ) ) { + ForkLock::lock_guard lock_right( *fork_right, boost::adopt_lock ); + // eating + mp_logger->log( boost::str( boost::format( "%1% is eating (%2%)..." ) % m_name % m_meals_left ) ); + wait(); + // record the meal + --m_meals_left; + } else { + failed_to_grab_fork = true; + } + } else { + failed_to_grab_fork = true; + } + + if( failed_to_grab_fork ) { + mp_logger->log( boost::str( boost::format( "%1% couldn't get forks; waiting..." ) % m_name ) ); + failed_to_grab_fork = false; + wait(); + } + } + + mp_logger->log( boost::str( boost::format( "%1% is done dining" ) % m_name ) ); + } + + inline void wait() { + wait( MIN_WAIT_TIME + ( std::rand() % MAX_JITTER ) ); + } + + inline void wait( boost::uint32_t time_in_ms ) { + boost::this_thread::sleep( boost::posix_time::milliseconds( time_in_ms ) ); + } + + std::string m_name; + volatile bool m_continue; + ForkPtr mp_fork_left; // must be declared before the thread + ForkPtr mp_fork_right; // must be declared before the thread + boost::thread m_thread; + boost::uint32_t m_meals_left; + AtomicLoggerOstreamPtr mp_logger; +}; +typedef boost::shared_ptr< Philosopher > PhilosopherPtr; + +int main() { + const int N = 5; + std::string names[] = { "Aristotle", "Spinoza", "Russell", "Kant", "Plato" }; + + std::vector< PhilosopherPtr > philosophers; + philosophers.reserve( N ); + + // create logger + AtomicLoggerOstreamPtr p_logger( new AtomicLoggerOstream( std::cout ) ); + + // create forks + std::vector< ForkPtr > forks; + forks.reserve( N ); + for( int i = 0; i < N; ++i ) { + forks.push_back( ForkPtr( new Fork() ) ); + } + + // create philosophers + for( int i = 0; i < N; ++i ) { + philosophers.push_back( PhilosopherPtr( + new Philosopher( names[ i ], forks[ i ], forks[ (i + 1) % N ], p_logger ) ) ); + } + + // wait for them to finish + for( int i = 0; i < N; ++i ) { + philosophers[ i ]->wait_for_cmplt(); + } + + p_logger->log( "Everyone is done dining." ); + + return 0; +} diff --git a/Task/Dining-philosophers/C/dining-philosophers-1.c b/Task/Dining-philosophers/C/dining-philosophers-1.c new file mode 100644 index 0000000000..8661d1dbe0 --- /dev/null +++ b/Task/Dining-philosophers/C/dining-philosophers-1.c @@ -0,0 +1,95 @@ +#include +#include +#include +#include +#include + +#define N 5 +const char *names[N] = { "Aristotle", "Kant", "Spinoza", "Marx", "Russell" }; +pthread_mutex_t forks[N]; + +#define M 5 /* think bubbles */ +const char *topic[M] = { "Spaghetti!", "Life", "Universe", "Everything", "Bathroom" }; + +#define lock pthread_mutex_lock +#define unlock pthread_mutex_unlock +#define xy(x, y) printf("\033[%d;%dH", x, y) +#define clear_eol(x) print(x, 12, "\033[K") +void print(int y, int x, const char *fmt, ...) +{ + static pthread_mutex_t screen = PTHREAD_MUTEX_INITIALIZER; + va_list ap; + va_start(ap, fmt); + + lock(&screen); + xy(y + 1, x), vprintf(fmt, ap); + xy(N + 1, 1), fflush(stdout); + unlock(&screen); +} + +void eat(int id) +{ + int f[2], ration, i; /* forks */ + f[0] = f[1] = id; + + /* make some (but not all) philosophers leftie. + could have been f[!id] = (id + 1) %N; for example */ + f[id & 1] = (id + 1) % N; + + clear_eol(id); + print(id, 12, "..oO (forks, need forks)"); + + for (i = 0; i < 2; i++) { + lock(forks + f[i]); + if (!i) clear_eol(id); + + print(id, 12 + (f[i] != id) * 6, "fork%d", f[i]); + /* delay 1 sec to clearly show the order of fork acquisition */ + sleep(1); + } + + for (i = 0, ration = 3 + rand() % 8; i < ration; i++) + print(id, 24 + i * 4, "nom"), sleep(1); + + /* done nomming, give up forks (order doesn't matter) */ + for (i = 0; i < 2; i++) unlock(forks + f[i]); +} + +void think(int id) +{ + int i, t; + char buf[64] = {0}; + + do { + clear_eol(id); + sprintf(buf, "..oO (%s)", topic[t = rand() % M]); + + for (i = 0; buf[i]; i++) { + print(id, i+12, "%c", buf[i]); + if (i < 5) usleep(200000); + } + usleep(500000 + rand() % 1000000); + } while (t); +} + +void* philosophize(void *a) +{ + int id = *(int*)a; + print(id, 1, "%10s", names[id]); + while(1) think(id), eat(id); +} + +int main() +{ + int i, id[N]; + pthread_t tid[N]; + + for (i = 0; i < N; i++) + pthread_mutex_init(forks + (id[i] = i), 0); + + for (i = 0; i < N; i++) + pthread_create(tid + i, 0, philosophize, id + i); + + /* wait forever: the threads don't actually stop */ + return pthread_join(tid[0], 0); +} diff --git a/Task/Dining-philosophers/C/dining-philosophers-2.c b/Task/Dining-philosophers/C/dining-philosophers-2.c new file mode 100644 index 0000000000..8f10988ab6 --- /dev/null +++ b/Task/Dining-philosophers/C/dining-philosophers-2.c @@ -0,0 +1,94 @@ +#include +#include +#include +#include + +typedef struct philData { + pthread_mutex_t *fork_lft, *fork_rgt; + const char *name; + pthread_t thread; + int fail; +} Philosopher; + +int running = 1; + +void *PhilPhunction(void *p) { + Philosopher *phil = (Philosopher*)p; + int failed; + int tries_left; + pthread_mutex_t *fork_lft, *fork_rgt, *fork_tmp; + + while (running) { + printf("%s is sleeping --er thinking\n", phil->name); + sleep( 1+ rand()%8); + + fork_lft = phil->fork_lft; + fork_rgt = phil->fork_rgt; + printf("%s is hungry\n", phil->name); + tries_left = 2; /* try twice before being forceful */ + do { + failed = pthread_mutex_lock( fork_lft); + failed = (tries_left>0)? pthread_mutex_trylock( fork_rgt ) + : pthread_mutex_lock(fork_rgt); + if (failed) { + pthread_mutex_unlock( fork_lft); + fork_tmp = fork_lft; + fork_lft = fork_rgt; + fork_rgt = fork_tmp; + tries_left -= 1; + } + } while(failed && running); + + if (!failed) { + printf("%s is eating\n", phil->name); + sleep( 1+ rand() % 8); + pthread_mutex_unlock( fork_rgt); + pthread_mutex_unlock( fork_lft); + } + } + return NULL; +} + +void Ponder() +{ + const char *nameList[] = { "Kant", "Guatma", "Russel", "Aristotle", "Bart" }; + pthread_mutex_t forks[5]; + Philosopher philosophers[5]; + Philosopher *phil; + int i; + int failed; + + for (i=0;i<5; i++) { + failed = pthread_mutex_init(&forks[i], NULL); + if (failed) { + printf("Failed to initialize mutexes."); + exit(1); + } + } + + for (i=0;i<5; i++) { + phil = &philosophers[i]; + phil->name = nameList[i]; + phil->fork_lft = &forks[i]; + phil->fork_rgt = &forks[(i+1)%5]; + phil->fail = pthread_create( &phil->thread, NULL, PhilPhunction, phil); + } + + sleep(40); + running = 0; + printf("cleanup time\n"); + + for(i=0; i<5; i++) { + phil = &philosophers[i]; + if ( !phil->fail && pthread_join( phil->thread, NULL) ) { + printf("error joining thread for %s", phil->name); + exit(1); + } + } +} + +int main() +{ + Ponder(); + return 0; +} diff --git a/Task/Dining-philosophers/Clojure/dining-philosophers-1.clj b/Task/Dining-philosophers/Clojure/dining-philosophers-1.clj new file mode 100644 index 0000000000..10f7f094ff --- /dev/null +++ b/Task/Dining-philosophers/Clojure/dining-philosophers-1.clj @@ -0,0 +1,30 @@ +(defn make-fork [] + (ref true)) + +(defn make-philosopher [name forks food-amt] + (ref {:name name :forks forks :eating? false :food food-amt})) + +(defn start-eating [phil] + (dosync + (if (every? true? (map ensure (:forks @phil))) ; <-- the essential solution + (do + (doseq [f (:forks @phil)] (alter f not)) + (alter phil assoc :eating? true) + (alter phil update-in [:food] dec) + true) + false))) + +(defn stop-eating [phil] + (dosync + (when (:eating? @phil) + (alter phil assoc :eating? false) + (doseq [f (:forks @phil)] (alter f not))))) + +(defn dine [phil retry-interval max-eat-duration max-think-duration] + (while (pos? (:food @phil)) + (if (start-eating phil) + (do + (Thread/sleep (rand-int max-eat-duration)) + (stop-eating phil) + (Thread/sleep (rand-int max-think-duration))) + (Thread/sleep retry-interval)))) diff --git a/Task/Dining-philosophers/Clojure/dining-philosophers-2.clj b/Task/Dining-philosophers/Clojure/dining-philosophers-2.clj new file mode 100644 index 0000000000..7d57363848 --- /dev/null +++ b/Task/Dining-philosophers/Clojure/dining-philosophers-2.clj @@ -0,0 +1,20 @@ +(def *forks* (cycle (take 5 (repeatedly #(make-fork))))) + +(def *philosophers* + (doall (map #(make-philosopher %1 [(nth *forks* %2) (nth *forks* (inc %2))] 1000) + ["Aristotle" "Kant" "Spinoza" "Marx" "Russell"] + (range 5)))) + +(defn start [] + (doseq [phil *philosophers*] + (.start (Thread. #(dine phil 5 100 100))))) + +(defn status [] + (dosync + (doseq [i (range 5)] + (let [f @(nth *forks* i) + p @(nth *philosophers* i)] + (println (str "fork: available=" f)) + (println (str (:name p) + ": eating=" (:eating? p) + " food=" (:food p))))))) diff --git a/Task/Dining-philosophers/Common-Lisp/dining-philosophers.lisp b/Task/Dining-philosophers/Common-Lisp/dining-philosophers.lisp new file mode 100644 index 0000000000..2c55ef8d7f --- /dev/null +++ b/Task/Dining-philosophers/Common-Lisp/dining-philosophers.lisp @@ -0,0 +1,73 @@ +(defvar *philosophers* '(Aristotle Kant Spinoza Marx Russell)) + +(defclass philosopher () + ((name :initarg :name :reader name-of) + (left-fork :initarg :left-fork :accessor left-fork-of) + (right-fork :initarg :right-fork :accessor right-fork-of) + (meals-left :initarg :meals-left :accessor meals-left-of))) + +(defclass fork () + ((lock :initform (make-lock "fork") :reader lock-of))) + +(defun random-normal (&optional (mean 0.0) (sd 1.0)) + (do* ((x1 #1=(1- (* 2.0d0 (random 1d0))) #1#) + (x2 #2=(1- (* 2.0d0 (random 1d0))) #2#) + (w #3=(+ (* x1 x1) (* x2 x2)) #3#)) + ((< w 1d0) (+ (* (* x1 (sqrt (/ (* -2d0 (log w)) w))) sd) mean)))) + +(defun sleep* (time) (sleep (max time (/ (expt 10 7))))) + +(defun dining-philosophers (&key (philosopher-names *philosophers*) + (meals 30) + (dining-time'(1 2)) + (thinking-time '(1 2)) + ((stream e) *error-output*)) + (let* ((count (length philosopher-names)) + (forks (loop repeat count collect (make-instance 'fork))) + (philosophers (loop for i from 0 + for name in philosopher-names collect + (make-instance 'philosopher + :left-fork (nth (mod i count) forks) + :right-fork (nth (mod (1+ i) count) forks) + :name name + :meals-left meals))) + (condition (make-condition-variable)) + (lock (make-lock "main loop")) + (output-lock (make-lock "output lock"))) + (dolist (p philosophers) + (labels ((think () + (/me "is now thinking") + (sleep* (apply #'random-normal thinking-time)) + (/me "is now hungry") + (dine)) + (dine () + (with-lock-held ((lock-of (left-fork-of p))) + (or (acquire-lock (lock-of (right-fork-of p)) nil) + (progn (/me "couldn't get a fork and ~ + returns to thinking") + (release-lock (lock-of (left-fork-of p))) + (return-from dine (think)))) + (/me "is eating") + (sleep* (apply #'random-normal dining-time)) + (release-lock (lock-of (right-fork-of p))) + (/me "is done eating (~A meals left)" + (decf (meals-left-of p)))) + (cond ((<= (meals-left-of p) 0) + (/me "leaves the dining room") + (with-lock-held (lock) + (setq philosophers (delete p philosophers)) + (condition-notify condition))) + (t (think)))) + (/me (control &rest args) + (with-lock-held (output-lock) + (write-sequence (string (name-of p)) e) + (write-char #\Space e) + (apply #'format e (concatenate 'string control "~%") + args)))) + (make-thread #'think))) + (loop (with-lock-held (lock) + (when (endp philosophers) + (format e "all philosophers are done dining~%") + (return))) + (with-lock-held (lock) + (condition-wait condition lock))))) diff --git a/Task/Dining-philosophers/D/dining-philosophers.d b/Task/Dining-philosophers/D/dining-philosophers.d new file mode 100644 index 0000000000..30caf59899 --- /dev/null +++ b/Task/Dining-philosophers/D/dining-philosophers.d @@ -0,0 +1,40 @@ +import std.stdio, std.algorithm, std.string, std.parallelism, + core.sync.mutex; + +void eat(in uint i, in string name, Mutex[] forks) { + writeln(name, " is hungry."); + + immutable j = (i + 1) % forks.length; + + // Take forks i and j. The lower one first to prevent deadlock. + auto fork1 = forks[min(i, j)]; + auto fork2 = forks[max(i, j)]; + + fork1.lock(); + scope(exit) fork1.unlock(); + + fork2.lock(); + scope(exit) fork2.unlock(); + + writeln(name, " is eating."); + writeln(name, " is full."); +} + +void think(in string name) { + writeln(name, " is thinking."); +} + +void main() { + const philosophers = "Aristotle Kant Spinoza Marx Russell".split(); + Mutex[philosophers.length] forks; + foreach (ref fork; forks) + fork = new Mutex(); + + defaultPoolThreads = forks.length; + foreach (uint i, philo; taskPool.parallel(philosophers)) { + foreach (_; 0 .. 100) { + eat(i, philo, forks); + think(philo); + } + } +} diff --git a/Task/Dining-philosophers/Eiffel/dining-philosophers-1.e b/Task/Dining-philosophers/Eiffel/dining-philosophers-1.e new file mode 100644 index 0000000000..22495fe321 --- /dev/null +++ b/Task/Dining-philosophers/Eiffel/dining-philosophers-1.e @@ -0,0 +1,58 @@ +class + DINING_PHILOSOPHERS + +create + make + +feature -- Initialization + + make + -- Create philosophers and forks. + local + first_fork: separate FORK + left_fork: separate FORK + right_fork: separate FORK + philosopher: separate PHILOSOPHER + i: INTEGER + do + print ("Dining Philosophers%N" + philosopher_count.out + " philosophers, " + round_count.out + " rounds%N%N") + create philosophers.make + from + i := 1 + create first_fork.make (philosopher_count, 1) + left_fork := first_fork + until + i > philosopher_count + loop + if i < philosopher_count then + create right_fork.make (i, i + 1) + else + right_fork := first_fork + end + create philosopher.make (i, left_fork, right_fork, round_count) + philosophers.extend (philosopher) + left_fork := right_fork + i := i + 1 + end + philosophers.do_all (agent launch_philosopher) + print ("Make Done!%N") + end + +feature {NONE} -- Implementation + + philosopher_count: INTEGER = 5 + -- Number of philosophers. + + round_count: INTEGER = 30 + -- Number of times each philosopher should eat. + + philosophers: LINKED_LIST [separate PHILOSOPHER] + -- List of philosophers. + + launch_philosopher (a_philosopher: separate PHILOSOPHER) + -- Launch a_philosopher. + do + a_philosopher.live + end + +end -- class DINING_PHILOSOPHERS diff --git a/Task/Dining-philosophers/Eiffel/dining-philosophers-2.e b/Task/Dining-philosophers/Eiffel/dining-philosophers-2.e new file mode 100644 index 0000000000..3dd6e0fd7d --- /dev/null +++ b/Task/Dining-philosophers/Eiffel/dining-philosophers-2.e @@ -0,0 +1,110 @@ +class + PHILOSOPHER + +create + make + +feature -- Initialization + + make (philosopher: INTEGER; left, right: separate FORK; rounds: INTEGER) + -- Initialize with ID of `philosopher', forks `left' and `right', and for `rounds' times to eat. + require + valid_id: philosopher >= 1 + valid_times_to_eat: rounds >= 1 + do + id := philosopher + left_fork := left + right_fork := right + round_count := rounds + report ("announced") + ensure + id_set: id = philosopher + left_fork_set: left_fork = left + right_fork_set: right_fork = right + rounds_set: round_count = rounds + end + +feature -- Access + + id: INTEGER + -- Philosopher's id. + +feature -- Basic operations + + live + -- Model philosopher's life. + do + from + report ("joined") + has_eaten_count := 0 + until + has_eaten_count >= round_count + loop + think + eat (left_fork, right_fork) + end + report ("done") + end + + eat (left, right: separate FORK) + -- Eat, having acquired `left' and `right' forks. + do + -- Take forks. + report ("taking forks") + left.pick (Current) + right.pick (Current) + -- Eat. + report ("eating") + delay (200) + -- Put forks back. + report ("putting forks back") + left.put (Current) + right.put (Current) + -- Report statistics. + has_eaten_count := has_eaten_count + 1 + report ("has eaten " + has_eaten_count.out + " times") + end + + think + -- Think ... for a short time. + do + report ("thinking") + delay (400) + end + +feature {NONE} -- Output + + report (task: STRING) + -- Report about execution of the specified `task'. + do + print ("Philosopher " + id.out + ": " + task + ".%N") + end + +feature {NONE} -- Timing + + delay (milliseconds: INTEGER_64) + -- Delay execution by `milliseconds'. + do + (create {EXECUTION_ENVIRONMENT}).sleep (milliseconds * 1_000_000) + end + +feature {NONE} -- Status + + round_count: INTEGER + -- Number of times philosopher should eat. + + has_eaten_count: INTEGER + -- Number of times philosopher has eaten so far. + + left_fork: separate FORK + -- Left fork used for eating. + + right_fork: separate FORK + -- Right fork used for eating. + +invariant + valid_id: id >= 1 + valid_round_count: round_count >= 1 + valid_has_eaten_count: has_eaten_count <= round_count + +end -- class PHILOSOPHER diff --git a/Task/Dining-philosophers/Eiffel/dining-philosophers-3.e b/Task/Dining-philosophers/Eiffel/dining-philosophers-3.e new file mode 100644 index 0000000000..cf18ba345f --- /dev/null +++ b/Task/Dining-philosophers/Eiffel/dining-philosophers-3.e @@ -0,0 +1,34 @@ +class + FORK + +create + make + +feature -- Initialization + + make (left, right: INTEGER) + -- Initialize between philosophers `left' and `right'. + do + id := left.out + "F" + right.out + end + +feature -- Access + + id: STRING + -- Identification: `F' enclosed by adjacent philosopher id's. + +feature -- Basic operations + + pick (philosopher: separate PHILOSOPHER) + -- Report fork picked up. + do + print ("Fork " + id + " picked up by Philosopher " + philosopher.id.out + ".%N") + end + + put (philosopher: separate PHILOSOPHER) + -- Report fork put back. + do + print ("Fork " + id + " put back by Philosopher " + philosopher.id.out + ".%N") + end + +end -- class FORK diff --git a/Task/Dining-philosophers/Erlang/dining-philosophers.erl b/Task/Dining-philosophers/Erlang/dining-philosophers.erl new file mode 100644 index 0000000000..c8748dce1f --- /dev/null +++ b/Task/Dining-philosophers/Erlang/dining-philosophers.erl @@ -0,0 +1,105 @@ +-module(philosophers). +-export([dining/0]). + +sleep(T) -> + receive +after T -> + true + end. + +doForks(ForkList) -> + receive + {grabforks, {Left, Right}} -> doForks(ForkList -- [Left, Right]); + {releaseforks, {Left, Right}} -> doForks([Left, Right| ForkList]); + {available, {Left, Right}, Sender} -> + Sender ! {areAvailable, lists:member(Left, ForkList) andalso lists:member(Right, ForkList)}, + doForks(ForkList); + {die} -> io:format("Forks put away.~n") + end. + +areAvailable(Forks) -> + forks ! {available, Forks, self()}, + receive + {areAvailable, false} -> false; + {areAvailable, true} -> true + end. + + +processWaitList([]) -> false; +processWaitList([H|T]) -> + {Client, Forks} = H, + case areAvailable(Forks) of + true -> Client ! {served}, + true; + false -> processWaitList(T) + end. + +doWaiter([], 0, 0, false) -> + forks ! {die}, + io:format("Waiter is leaving.~n"), + diningRoom ! {allgone}; +doWaiter(WaitList, ClientCount, EatingCount, Busy) -> + receive + {waiting, Client} -> + WaitList1 = [Client|WaitList], %% add to waiting list + case (not Busy) and (EatingCount<2) of + true -> Busy1 = processWaitList(WaitList1); + false -> Busy1 = Busy + end, + doWaiter(WaitList1, ClientCount, EatingCount, Busy1); + + {eating, Client} -> + doWaiter(WaitList -- [Client], ClientCount, EatingCount+1, false); + + {finished} -> + doWaiter(WaitList, ClientCount, EatingCount-1, + processWaitList(WaitList)); + {leaving} -> + doWaiter(WaitList, ClientCount-1, EatingCount, Busy) + end. + + +philosopher(Name, Forks, 0) -> + io:format("~s is leaving.~n", [Name]), + + waiter ! {leaving}; + + +philosopher(Name, Forks, Cycle) -> + io:format("~s is thinking.~n", [Name]), + sleep(random:uniform(1000)), + + io:format("~s is hungry.~n", [Name]), + waiter ! {waiting, {self(), Forks}}, %%sit at table + + receive + {served}-> forks ! {grabforks, Forks}, %%grab forks + waiter ! {eating, {self(), Forks}}, %%start eating + io:format("~s is eating.~n", [Name]) + end, + + sleep(random:uniform(1000)), + forks ! {releaseforks, Forks}, %% put forks down + waiter ! {finished}, + + philosopher(Name, Forks, Cycle-1). + + +dining() -> AllForks = [1, 2, 3, 4, 5], + Clients = 5, + register(diningRoom, self()), + + register(forks, spawn(fun()-> doForks(AllForks) end)), + register(waiter, spawn(fun()-> doWaiter([], Clients, 0, false) end)), + Life_span = 20, + spawn(fun()-> philosopher('Aristotle', {5, 1}, Life_span) end), + spawn(fun()-> philosopher('Kant', {1, 2}, Life_span) end), + spawn(fun()-> philosopher('Spinoza', {2, 3}, Life_span) end), + spawn(fun()-> philosopher('Marx', {3, 4}, Life_span) end), + spawn(fun()-> philosopher('Russel', {4, 5}, Life_span) end), + + receive + {allgone} -> io:format("Dining room closed.~n") + + end, + unregister(diningRoom). diff --git a/Task/Dining-philosophers/Euphoria/dining-philosophers.euphoria b/Task/Dining-philosophers/Euphoria/dining-philosophers.euphoria new file mode 100644 index 0000000000..71034b50ae --- /dev/null +++ b/Task/Dining-philosophers/Euphoria/dining-philosophers.euphoria @@ -0,0 +1,54 @@ +constant FREE = 0, LOCKED = 1 +sequence forks +forks = repeat(FREE,5) + +procedure person(sequence name, integer left_fork, integer right_fork) + while 1 do + while forks[left_fork] = LOCKED or forks[right_fork] = LOCKED do + if forks[left_fork] = FREE then + puts(1, name & " hasn't right fork.\n") + elsif forks[right_fork] = FREE then + puts(1, name & " hasn't left fork.\n") + else + puts(1, name & " hasn't both forks.\n") + end if + puts(1, name & " is waiting.\n") + task_yield() + end while + + puts(1, name & " grabs forks.\n") + forks[left_fork] = LOCKED + forks[right_fork] = LOCKED + for i = 1 to rand(10) do + puts(1, name & " is eating.\n") + task_yield() + end for + puts(1, name & " puts forks down and leaves the dinning room.\n") + forks[left_fork] = FREE + forks[right_fork] = FREE + + for i = 1 to rand(10) do + puts(1, name & " is thinking.\n") + task_yield() + end for + puts(1, name & " becomes hungry.\n") + end while +end procedure + +integer rid +atom taskid +rid = routine_id("person") +taskid = task_create(rid,{"Aristotle",1,2}) +task_schedule(taskid,{1,2}) +taskid = task_create(rid,{"Kant",2,3}) +task_schedule(taskid,{1,2}) +taskid = task_create(rid,{"Spinoza",3,4}) +task_schedule(taskid,{1,2}) +taskid = task_create(rid,{"Marx",4,5}) +task_schedule(taskid,{1,2}) +taskid = task_create(rid,{"Russell",5,1}) +task_schedule(taskid,{1,2}) + +while get_key() = -1 do + task_yield() +end while diff --git a/Task/Dining-philosophers/Go/dining-philosophers.go b/Task/Dining-philosophers/Go/dining-philosophers.go new file mode 100644 index 0000000000..02949e7bb8 --- /dev/null +++ b/Task/Dining-philosophers/Go/dining-philosophers.go @@ -0,0 +1,74 @@ +package main + +import ( + "log" + "math/rand" + "os" + "time" +) + +// Number of philosophers is simply the length of this list. +// It is not otherwise fixed in the program. +var ph = []string{"Aristotle", "Kant", "Spinoza", "Marx", "Russell"} + +const nBites = 3 // number of times each philosopher eats + +var fmt = log.New(os.Stdout, "", 0) // for thread-safe output + +// This solution uses channels to implement synchronization. +// Sent over channels are "forks." +type fork byte + +// A fork object in the program obviously models a physical fork in the +// philosopher simulation. In the more general context of resource +// sharing, the object would represent exclusive control of a resource. +// A separate channel represents each fork place. Two philosophers +// have access to each fork. The channels are buffered with capacity = 1, +// representing a place for a single fork. + +// Goroutine for philosopher actions. An instance is run for each +// philosopher. Instances run concurrently. +func philosopher(phName string, + dominantHand, otherHand chan fork, done chan bool) { + fmt.Println(phName, "seated") + rg := rand.New(rand.NewSource(time.Now().UnixNano())) + for i := 0; i < nBites; i++ { + fmt.Println(phName, "hungry") + <-dominantHand // pick up forks + <-otherHand + fmt.Println(phName, "eating") + time.Sleep(time.Duration(rg.Int63n(1e8))) + dominantHand <- 'f' // put down forks + otherHand <- 'f' + fmt.Println(phName, "thinking") + time.Sleep(time.Duration(rg.Int63n(1e8))) + } + fmt.Println(phName, "satisfied") + done <- true + fmt.Println(phName, "left the table") +} + +func main() { + fmt.Println("table empty") + // Create fork channels and start philosopher goroutines, + // supplying each goroutine with the appropriate channels + done := make(chan bool) + place0 := make(chan fork, 1) + place0 <- 'f' // byte in channel represents a fork on the table. + placeLeft := place0 + for i := 1; i < len(ph); i++ { + placeRight := make(chan fork, 1) + placeRight <- 'f' + go philosopher(ph[i], placeLeft, placeRight, done) + placeLeft = placeRight + } + // Make one philosopher left handed by reversing fork place + // supplied to philosopher's dominant hand. + // This makes precedence acyclic, preventing deadlock. + go philosopher(ph[0], place0, placeLeft, done) + // they are all now busy eating + for _ = range ph { + <-done // wait for philosphers to finish + } + fmt.Println("table empty") +} diff --git a/Task/Dining-philosophers/Haskell/dining-philosophers.hs b/Task/Dining-philosophers/Haskell/dining-philosophers.hs new file mode 100644 index 0000000000..4950cb0480 --- /dev/null +++ b/Task/Dining-philosophers/Haskell/dining-philosophers.hs @@ -0,0 +1,65 @@ +module Philosophers where + +import Control.Monad +import Control.Concurrent +import Control.Concurrent.STM +import System.Random + +-- TMVars are transactional references. They can only be used in transactional actions. +-- They are either empty or contain one value. Taking an empty reference fails and +-- putting a value in a full reference fails. A transactional action only succeeds +-- when all the component actions succeed, else it rolls back and retries until it +-- succeeds. +-- The Int is just for display purposes. +type Fork = TMVar Int + +newFork :: Int -> IO Fork +newFork i = newTMVarIO i + +-- The basic transactional operations on forks +takeFork :: Fork -> STM Int +takeFork fork = takeTMVar fork + +releaseFork :: Int -> Fork -> STM () +releaseFork i fork = putTMVar fork i + +type Name = String + +runPhilosopher :: Name -> (Fork, Fork) -> IO () +runPhilosopher name (left, right) = forever $ do + putStrLn (name ++ " is hungry.") + + -- Run the transactional action atomically. + -- The type system ensures this is the only way to run transactional actions. + (leftNum, rightNum) <- atomically $ do + leftNum <- takeFork left + rightNum <- takeFork right + return (leftNum, rightNum) + + putStrLn (name ++ " got forks " ++ show leftNum ++ " and " ++ show rightNum ++ " and is now eating.") + delay <- randomRIO (1,10) + threadDelay (delay * 1000000) -- 1, 10 seconds. threadDelay uses nanoseconds. + putStrLn (name ++ " is done eating. Going back to thinking.") + + atomically $ do + releaseFork leftNum left + releaseFork rightNum right + + delay <- randomRIO (1, 10) + threadDelay (delay * 1000000) + +philosophers :: [String] +philosophers = ["Aristotle", "Kant", "Spinoza", "Marx", "Russel"] + +main = do + forks <- mapM newFork [1..5] + let namedPhilosophers = map runPhilosopher philosophers + forkPairs = zip forks (tail . cycle $ forks) + philosophersWithForks = zipWith ($) namedPhilosophers forkPairs + + putStrLn "Running the philosophers. Press enter to quit." + + mapM_ forkIO philosophersWithForks + + -- All threads exit when the main thread exits. + getLine diff --git a/Task/Dining-philosophers/Java/dining-philosophers.java b/Task/Dining-philosophers/Java/dining-philosophers.java new file mode 100644 index 0000000000..aa537e414a --- /dev/null +++ b/Task/Dining-philosophers/Java/dining-philosophers.java @@ -0,0 +1,113 @@ +package diningphilosophers; + +import java.util.ArrayList; +import java.util.Random; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +enum PhilosopherState { Get, Eat, Pon } + +class Fork { + public static final int ON_TABLE = -1; + static int instances = 0; + public int id; + public AtomicInteger holder = new AtomicInteger(ON_TABLE); + + Fork() { id = instances++; } +} + +class Philosopher implements Runnable { + static final int maxWaitMs = 100; // must be > 0 + static AtomicInteger token = new AtomicInteger(0); + static int instances = 0; + static Random rand = new Random(); + AtomicBoolean end = new AtomicBoolean(false); + int id; + PhilosopherState state = PhilosopherState.Get; + Fork left; + Fork right; + int timesEaten = 0; + + Philosopher() { + id = instances++; + left = Main.forks.get(id); + right = Main.forks.get((id+1)%Main.philosopherCount); + } + + void sleep() { try { Thread.sleep(rand.nextInt(maxWaitMs)); } + catch (InterruptedException ex) {} } + + void waitForFork(Fork fork) { + do { + if (fork.holder.get() == Fork.ON_TABLE) { + fork.holder.set(id); // my id shows I hold it + return; + } else { // someone still holds it + sleep(); // check again later + } + } while (true); + } + + public void run() { + do { + if (state == PhilosopherState.Pon) { // all that pondering + state = PhilosopherState.Get; // made me hungry + } else { // ==PhilosopherState.Get + if (token.get() == id) { // my turn now + waitForFork(left); + waitForFork(right); // Ah needs me some foahks! + token.set((id+2)% Main.philosopherCount); + state = PhilosopherState.Eat; + timesEaten++; + sleep(); // eat for a while + left.holder.set(Fork.ON_TABLE); + right.holder.set(Fork.ON_TABLE); + state = PhilosopherState.Pon; // ponder for a while + sleep(); + } else { // token.get() != id, so not my turn + sleep(); + } + } + } while (!end.get()); + } +} + +public class Main { + static final int philosopherCount = 5; // token +2 behavior good for odd #s + static final int runSeconds = 15; + static ArrayList forks = new ArrayList(); + static ArrayList philosophers = new ArrayList(); + + public static void main(String[] args) { + for (int i = 0 ; i < philosopherCount ; i++) forks.add(new Fork()); + for (int i = 0 ; i < philosopherCount ; i++) + philosophers.add(new Philosopher()); + for (Philosopher p : philosophers) new Thread(p).start(); + long endTime = System.currentTimeMillis() + (runSeconds * 1000); + + do { // print status + StringBuilder sb = new StringBuilder("|"); + + for (Philosopher p : philosophers) { + sb.append(p.state.toString()); + sb.append("|"); // This is a snapshot at a particular + } // instant. Plenty happens between. + + sb.append(" |"); + + for (Fork f : forks) { + int holder = f.holder.get(); + sb.append(holder==-1?" ":String.format("P%02d",holder)); + sb.append("|"); + } + + System.out.println(sb.toString()); + try {Thread.sleep(1000);} catch (Exception ex) {} + } while (System.currentTimeMillis() < endTime); + + for (Philosopher p : philosophers) p.end.set(true); + for (Philosopher p : philosophers) + System.out.printf("P%02d: ate %,d times, %,d/sec\n", + p.id, p.timesEaten, p.timesEaten/runSeconds); + } +} diff --git a/Task/Dining-philosophers/PicoLisp/dining-philosophers.l b/Task/Dining-philosophers/PicoLisp/dining-philosophers.l new file mode 100644 index 0000000000..def9ceb1b4 --- /dev/null +++ b/Task/Dining-philosophers/PicoLisp/dining-philosophers.l @@ -0,0 +1,36 @@ +(de dining (Name State) + (loop + (prinl Name ": " State) + (state 'State # Dispatch according to state + (thinking 'hungry) # If thinking, get hungry + (hungry # If hungry, grab random fork + (if (rand T) + (and (acquire leftFork) 'leftFork) + (and (acquire rightFork) 'rightFork) ) ) + (hungry 'hungry # Failed, stay hungry for a while + (wait (rand 1000 3000)) ) + (leftFork # If holding left fork, try right one + (and (acquire rightFork) 'eating) + (wait 2000) ) # then eat for 2 seconds + (rightFork # If holding right fork, try left one + (and (acquire leftFork) 'eating) + (wait 2000) ) # then eat for 2 seconds + ((leftFork rightFork) 'hungry # Otherwise, go back to hungry, + (release (val State)) # release left or right fork + (wait (rand 1000 3000)) ) # and stay hungry + (eating 'thinking # After eating, resume thinking + (release leftFork) + (release rightFork) + (wait 6000) ) ) ) ) # for 6 seconds + +(setq *Philosophers + (maplist + '((Phils Forks) + (let (leftFork (tmp (car Forks)) rightFork (tmp (cadr Forks))) + (or + (fork) # Parent: Collect child process IDs + (dining (car Phils) 'hungry) ) ) ) # Initially hungry + '("Aristotle" "Kant" "Spinoza" "Marx" "Russell") + '("ForkA" "ForkB" "ForkC" "ForkD" "ForkE" .) ) ) + +(push '*Bye '(mapc kill *Philosophers)) # Terminate all upon exit diff --git a/Task/Dining-philosophers/Prolog/dining-philosophers.pro b/Task/Dining-philosophers/Prolog/dining-philosophers.pro new file mode 100644 index 0000000000..e70d02bf52 --- /dev/null +++ b/Task/Dining-philosophers/Prolog/dining-philosophers.pro @@ -0,0 +1,449 @@ +dining_philosophers :- + new(D, window('Dining philosophers')), + new(S, window('Dining philosophers : statistics')), + send(D, size, new(_, size(800,800))), + + new(E, ellipse(400,400)), + send(E, center, point(400,400)), + send(D, display, E), + + new(F1, fork(0)), + new(F2, fork(1)), + new(F3, fork(2)), + new(F4, fork(3)), + new(F5, fork(4)), + + send_list(D, display, [F1,F2,F3,F4,F5]), + + new(Waiter, waiter(F1, F2, F3, F4, F5)), + + create_plate(P1, 0), + create_plate(P2, 1), + create_plate(P3, 2), + create_plate(P4, 3), + create_plate(P5, 4), + + create_point(0, Pt1), + create_point(1, Pt2), + create_point(2, Pt3), + create_point(3, Pt4), + create_point(4, Pt5), + + + new(Ph1, philosopher('Aristotle', Waiter, P1, D, S, 0, Pt1, left)), + new(Ph2, philosopher('Kant', Waiter, P2, D, S, 1, Pt2, left)), + new(Ph3, philosopher('Spinoza', Waiter, P3, D, S, 2, Pt3, right)), + new(Ph4, philosopher('Marx', Waiter, P4, D, S, 3, Pt4, right)), + new(Ph5, philosopher('Russell', Waiter, P5, D, S, 4, Pt5, left)), + + send(Waiter, init_phi, Ph1, Ph2, Ph3, Ph4, Ph5), + + send_list([Ph1, Ph2, Ph3, Ph4, Ph5], start), + + send(D, done_message, and(message(Waiter, free), + message(Ph1, free), + message(Ph2, free), + message(Ph3, free), + message(Ph4, free), + message(Ph5, free), + message(S, open), + message(D, destroy))), + + send(D, open). + + +create_plate(P, N) :- + new(P, ellipse(80,80)), + X is 400 + 140 * cos(N * pi / 2.5), + Y is 400 + 140 * sin(N * pi / 2.5), + send(P, center, point(X, Y)). + +create_point(N, point(X, Y)) :- + X is 400 + 220 * cos(N * pi / 2.5), + Y is 400 + 220 * sin(N * pi / 2.5) - 20. + + +:- pce_begin_class(waiter , object, "gives the forks to the philosophers"). +variable(f1, fork, both, "free or used"). +variable(f2, fork, both, "free or used"). +variable(f3, fork, both, "free or used"). +variable(f4, fork, both, "free or used"). +variable(f5, fork, both, "free or used"). +variable(phi1, philosopher, both, "philosopher"). +variable(phi2, philosopher, both, "philosopher"). +variable(phi3, philosopher, both, "philosopher"). +variable(phi4, philosopher, both, "philosopher"). +variable(phi5, philosopher, both, "philosopher"). + +initialise(P, F1, F2, F3, F4, F5) :-> + send(P, slot, f1, F1), + send(P, slot, f2, F2), + send(P, slot, f3, F3), + send(P, slot, f4, F4), + send(P, slot, f5, F5). + +init_phi(P, Phi1,Phi2, Phi3, Phi4, Phi5) :-> + send(P, slot, phi1, Phi1), + send(P, slot, phi2, Phi2), + send(P, slot, phi3, Phi3), + send(P, slot, phi4, Phi4), + send(P, slot, phi5, Phi5). + + +want_forks(P, Phi) :-> + ( get(P, slot, phi1, Phi) ,!, check_forks(P, Phi, f5, f1); + get(P, slot, phi2, Phi),!, check_forks(P, Phi, f1, f2); + get(P, slot, phi3, Phi),!, check_forks(P, Phi, f2, f3); + get(P, slot, phi4, Phi),!, check_forks(P, Phi, f3, f4); + get(P, slot, phi5, Phi),!, check_forks(P, Phi, f4, f5)). + + + + +give_back_forks(P, Phi) :-> + ( get(P, slot, phi1, Phi) ,!, release_forks(P, phi1); + get(P, slot, phi2, Phi),!, release_forks(P, phi2); + get(P, slot, phi3, Phi),!, release_forks(P, phi3); + get(P, slot, phi4, Phi),!, release_forks(P, phi4); + get(P, slot, phi5, Phi),!, release_forks(P, phi5)), + + get(P, slot, phi1, Phi1), + check_forks(P, Phi1, f5, f1), + get(P, slot, phi2, Phi2), + check_forks(P, Phi2, f1, f2), + get(P, slot, phi3, Phi3), + check_forks(P, Phi3, f2, f3), + get(P, slot, phi4, Phi4), + check_forks(P, Phi4, f3, f4), + get(P, slot, phi5, Phi5), + check_forks(P, Phi5, f4, f5). + +release_forks(P, phi1) :- + get(P, slot, f5, F5), + send(F5, free), + get(P, slot, f1, F1), + send(F1, free). + +release_forks(P, phi2) :- + get(P, slot, f1, F1), + send(F1, free), + get(P, slot, f2, F2), + send(F2, free). + +release_forks(P, phi3) :- + get(P, slot, f2, F2), + send(F2, free), + get(P, slot, f3, F3), + send(F3, free). + +release_forks(P, phi4) :- + get(P, slot, f3, F3), + send(F3, free), + get(P, slot, f4, F4), + send(F4, free). + +release_forks(P, phi5) :- + get(P, slot, f4, F4), + send(F4, free), + get(P, slot, f5, F5), + send(F5, free). + +check_forks(P, Phi, F1, F2) :- + get(P, slot, F1, FF1), + get(P, slot, F2, FF2), + ( (get(Phi, slot, status, waiting), + get(FF1, slot, status, free), + get(FF2, slot, status, free)) + -> + send(Phi, receive_forks), + send(FF1, used, right), + send(FF2, used, left) + ; + true). + +:- pce_end_class. + + +:- pce_begin_class(philosopher , object, "eat, think or wait !"). +variable(name, string, both). +variable(window, object, both). +variable(status, object, both, "eating/thinking/waiting"). +variable(waiter, object, both). +variable(plate, object, both). +variable(mytimer, timer, both). +variable(pos, point, both). +variable(side, object, both). +variable(old_text, object, both). +variable(window_stat, object, both). +variable(line_stat, number, both). +variable(stat_wait, my_stat, both). +variable(stat_eat, my_stat, both). +variable(stat_think, my_stat, both). + +% méthode appelée lors de la destruction de l'objet +% On arrête d'abord le timer pour poursuivre ensuite +% sans problème (appel par le timer de ressources libérées) +unlink(P) :-> + send(P?mytimer, stop), + + get(P, status, Sta), + stop_timer(P, Sta), + get(P, slot, window_stat, WS), + get(P, slot, line_stat, LS), + get(LS, value, VLS), + get(P, slot, name, Name), + get(Name, value, V), + sformat(A, 'Statistics of philosopher : ~w', [V]), + new(Text, text(A)), + send(Text, font, font(times, bold, 16)), + Y is VLS * 30, + send(WS, display, Text, point(30, Y)), + + VLS1 is VLS+1, + get(P, slot, stat_think, ST), + send(ST, statistics, WS, VLS1), + + VLS2 is VLS+2, + get(P, slot, stat_eat, SE), + send(SE, statistics, WS, VLS2), + + VLS3 is VLS+3, + get(P, slot, stat_wait, SW), + send(SW, statistics, WS, VLS3), + + send(P, send_super, unlink). + +initialise(P, Name, Waiter, Plate, Window, Window_stat, Line_stat, Point, Side) :-> + % gtrace, + send(P, slot, name, Name), + send(P, slot, window, Window), + send(P, slot, window_stat, Window_stat), + Line is Line_stat * 5, + send(P, slot, line_stat, Line), + send(P, slot, waiter,Waiter), + send(P, slot, plate,Plate), + send(P, slot, status, thinking), + send(P, slot, pos, Point), + send(P, slot, side, Side), + send(Window, display, Plate), + send(P, slot, old_text, new(_, text(' '))), + send(P, display_status), + send(P, slot, stat_wait, new(_, my_stat('Waiting'))), + send(P, slot, stat_eat, new(_, my_stat('Eating'))), + send(P, slot, stat_think, new(_, my_stat('Thinking'))). + + +stop_timer(P, eating) :- + get(P, slot, stat_eat, SE), + send(SE, stop). + +stop_timer(P, waiting) :- + get(P, slot, stat_wait, SW), + send(SW, stop). + +stop_timer(P, thinking) :- + get(P, slot, stat_think, ST), + send(ST, stop). + + +% internal message send by the timer +my_message(P) :-> + % gtrace, + get(P, slot, status, Status), + next_status(P, Status). + +% philosopher eating ==> thinking +next_status(P, eating) :- + get(P, slot, waiter, Waiter), + get(P, slot, stat_eat, SE), + send(SE, stop), + get(P, slot, stat_think, ST), + send(ST, start), + send(Waiter, give_back_forks, P), + send(P, slot, status, thinking), + send(P, display_status), + get(P, plate, Plate), + send(Plate, fill_pattern, colour(white)), + I is random(20)+ 10, + get(P, slot, mytimer, Timer), + send(Timer, interval, I), + send(Timer, start, once). + +next_status(P, thinking) :- + get(P, slot, waiter, Waiter), + send(P, slot, status, waiting), + send(P, display_status), + get(P, slot, stat_think, ST), + send(ST, stop), + get(P, slot, stat_wait, SW), + send(SW, start), + send(Waiter, want_forks, P). + +% send by the waiter +% philosopher can eat ! +receive_forks(P) :-> + get(P, slot, stat_wait, SW), + send(SW, stop), + get(P, slot, stat_eat, SE), + send(SE, start), + send(P, slot, status, eating), + send(P, display_status), + get(P, plate, Plate), + send(Plate, fill_pattern, colour(black)), + I is random(20)+ 5, + get(P, slot, mytimer, Timer), + send(Timer, interval, I), + send(Timer, start, once). + +display_status(P) :-> + get(P, old_text, OT), + free(OT), + get(P, name, Name), + get(Name, value, V), + get(P, status, Status), + choose_color(Status, Colour), + sformat(A, '~w ~w', [V, Status]), + get(P, window, W), + get(P, pos, point(X, Y)), + new(Text, text(A)), + send(Text, font, font(times, bold, 16)), + send(Text, colour, Colour), + get(Text, string, Str), + get(font(times, bold, 16), width(Str), M), + (get(P, side, right) -> X1 is X - M; X1 = X), + send(W, display, Text, point(X1, Y)), + send(P, old_text, Text). + + +start(P) :-> + I is random(10)+ 2, + get(P, slot, stat_think, ST), + send(ST, start), + send(P, mytimer, new(_, timer(I,message(P, my_message)))), + send(P?mytimer, start, once). + + +choose_color(eating, colour(blue)). +choose_color(thinking, colour(green)). +choose_color(waiting, colour(red)). + +:- pce_end_class. + + + +:- pce_begin_class(disk, ellipse, "disk with color "). + +initialise(P, C, R, Col) :-> + send(P, send_super, initialise, R, R), + send(P, center, C), + send(P, pen, 0), + send(P, fill_pattern, Col). + +change_color(P, Col) :-> + send(P, fill_pattern, Col). + +:- pce_end_class. + +:- pce_begin_class(my_stat , object, "statistics"). +variable(name, string, both). +variable(nb, number, both). +variable(duration, real, both). +variable(start, real, both). + +initialise(P, Name) :-> + send(P, name, Name), + send(P, nb, 0), + send(P, duration, 0.0). + +start(P) :-> + get_time(T), + send(P, slot, start, T). + +stop(P) :-> + get_time(Fin), + + get(P, slot, nb, N), + send(N, plus,1), + send(P, slot, nb, N), + + get(P, slot, duration, D), + get(P, slot, start, Deb), + + get(D, value, VD), + get(Deb, value, VDeb), + X is VD + Fin - VDeb, + + send(P, slot, duration, X). + +statistics(P, W, L) :-> + get(P, nb, N), + get(N, value, VN), + get(P, duration, D), + get(D, value, VD), + get(P, name, Name), + get(Name, value, V), + sformat(A, '~w~tnb :~13| ~t~w~17| duration : ~t~1f~35|', [V, VN, VD]), + new(Text, text(A)), + send(Text, font, font(screen, roman, 14)), + Y is L * 30, + send(W, display, Text, point(40, Y)). + +:-pce_end_class. + +% forks changes of place +:- pce_begin_class(fork, line, "to help philosopphers to eat"). +variable(value, number, both, "0 => 4"). +variable(side, object, both), "left / right". +variable(status, object, both, "free / used"). + +initialise(P, Val) :-> + send_super(P, initialise), + send(P, slot, value, Val), + send(P, slot, status, free), + compute(Val, free, _, PS, PE), + send(P, start, PS), + send(P, end, PE). + +free(P) :-> + send(P, status, free), + send(P, position). + + +used(P, Side) :-> + send(P, status, used), + send(P, side, Side), + send(P, position). + +position(P) :-> + get(P, value, V), + get(V, value, N), + get(P, status, St), + get(P, side, Side), + compute(N, St, Side, PS, PE), + send(P, start, PS), + send(P, end, PE). + + +compute(N, free, _Side, point(XS,YS), point(XE,YE)) :- + A is N * pi / 2.5 + pi / 5, + XS is 400 + 100 * cos(A), + YS is 400 + 100 * sin(A), + XE is 400 + 180 * cos(A), + YE is 400 + 180 * sin(A). + + +compute(N, used, left, point(XS,YS), point(XE,YE)) :- + A is N * pi / 2.5 + pi / 5 - 2 * pi / 15, + XS is 400 + 100 * cos(A), + YS is 400 + 100 * sin(A), + XE is 400 + 180 * cos(A), + YE is 400 + 180 * sin(A). + +compute(N, used, right, point(XS,YS), point(XE,YE)) :- + A is N * pi / 2.5 + pi / 5 + 2 * pi / 15, + XS is 400 + 100 * cos(A), + YS is 400 + 100 * sin(A), + XE is 400 + 180 * cos(A), + YE is 400 + 180 * sin(A). + +:- pce_end_class. diff --git a/Task/Dining-philosophers/Python/dining-philosophers.py b/Task/Dining-philosophers/Python/dining-philosophers.py new file mode 100644 index 0000000000..5b364ee6ff --- /dev/null +++ b/Task/Dining-philosophers/Python/dining-philosophers.py @@ -0,0 +1,67 @@ +import threading +import random +import time + +# Dining philosophers, 5 Phillies with 5 forks. Must have two forks to eat. +# +# Deadlock is avoided by never waiting for a fork while holding a fork (locked) +# Procedure is to do block while waiting to get first fork, and a nonblocking +# acquire of second fork. If failed to get second fork, release first fork, +# swap which fork is first and which is second and retry until getting both. +# +# See discussion page note about 'live lock'. + +class Philosopher(threading.Thread): + + running = True + + def __init__(self, xname, forkOnLeft, forkOnRight): + threading.Thread.__init__(self) + self.name = xname + self.forkOnLeft = forkOnLeft + self.forkOnRight = forkOnRight + + def run(self): + while(self.running): + # Philosopher is thinking (but really is sleeping). + time.sleep( random.uniform(3,13)) + print '%s is hungry.' % self.name + self.dine() + + def dine(self): + fork1, fork2 = self.forkOnLeft, self.forkOnRight + + while self.running: + fork1.acquire(True) + locked = fork2.acquire(False) + if locked: break + fork1.release() + print '%s swaps forks' % self.name + fork1, fork2 = fork2, fork1 + else: + return + + self.dining() + fork2.release() + fork1.release() + + def dining(self): + print '%s starts eating '% self.name + time.sleep(random.uniform(1,10)) + print '%s finishes eating and leaves to think.' % self.name + +def DiningPhilosophers(): + forks = [threading.Lock() for n in range(5)] + philosopherNames = ('Aristotle','Kant','Buddha','Marx', 'Russel') + + philosophers= [Philosopher(philosopherNames[i], forks[i%5], forks[(i+1)%5]) \ + for i in range(5)] + + random.seed(507129) + Philosopher.running = True + for p in philosophers: p.start() + time.sleep(100) + Philosopher.running = False + print ("Now we're finishing.") + +DiningPhilosophers() diff --git a/Task/Dining-philosophers/Ruby/dining-philosophers.rb b/Task/Dining-philosophers/Ruby/dining-philosophers.rb new file mode 100644 index 0000000000..0c6fcce88e --- /dev/null +++ b/Task/Dining-philosophers/Ruby/dining-philosophers.rb @@ -0,0 +1,70 @@ +require 'mutex_m' + +class Philosopher + def initialize(name, left_fork, right_fork) + @name = name + @left_fork = left_fork + @right_fork = right_fork + @meals = 0 + end + + def go + while @meals < 5 + think + dine + end + puts "philosopher #@name is full!" + end + + def think + puts "philosopher #@name is thinking..." + sleep(rand()) + puts "philosopher #@name is hungry..." + end + + def dine + fork1, fork2 = @left_fork, @right_fork + while true + pickup(fork1, :wait => true) + puts "philosopher #@name has fork #{fork1.fork_id}..." + if pickup(fork2, :wait => false) + break + end + puts "philosopher #@name cannot pickup second fork #{fork2.fork_id}..." + release(fork1) + fork1, fork2 = fork2, fork1 + end + puts "philosopher #@name has the second fork #{fork2.fork_id}..." + + puts "philosopher #@name eats..." + sleep(rand()) + puts "philosopher #@name belches" + @meals += 1 + + release(@left_fork) + release(@right_fork) + end + + def pickup(fork, opt) + puts "philosopher #@name attempts to pickup fork #{fork.fork_id}..." + opt[:wait] ? fork.mutex.mu_lock : fork.mutex.mu_try_lock + end + + def release(fork) + puts "philosopher #@name releases fork #{fork.fork_id}..." + fork.mutex.unlock + end +end + +n = 5 + +Fork = Struct.new(:fork_id, :mutex) +forks = Array.new(n) {|i| Fork.new(i, Object.new.extend(Mutex_m))} + +philosophers = Array.new(n) do |i| + Thread.new(i, forks[i], forks[(i+1)%n]) do |id, f1, f2| + ph = Philosopher.new(id, f1, f2).go + end + end + +philosophers.each {|thread| thread.join} diff --git a/Task/Dining-philosophers/Smalltalk/dining-philosophers.st b/Task/Dining-philosophers/Smalltalk/dining-philosophers.st new file mode 100644 index 0000000000..4238b0cd11 --- /dev/null +++ b/Task/Dining-philosophers/Smalltalk/dining-philosophers.st @@ -0,0 +1,97 @@ +'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 13 October 2011 at 2:44:42 pm'! +Object subclass: #Philosopher + instanceVariableNames: 'table random name seat forks running' + classVariableNames: '' + poolDictionaries: '' + category: 'rosettacode'! + +!Philosopher methodsFor: 'private'! +createfork + ^ Semaphore forMutualExclusion! ! + +!Philosopher methodsFor: 'private'! +displayState: aStateName + Transcript show: name , ' is ' , aStateName; + cr! ! + +!Philosopher methodsFor: 'private'! +pickUpForkAt: relativePosition + | fork pos | + pos := self tableIndex: seat + relativePosition. + (fork := table at: pos) + ifNotNil: [fork + critical: [(table at: pos) notNil + ifTrue: [table at: pos put: nil] + ifFalse: [fork := nil]]]. + ^ (forks at: relativePosition put: fork) notNil! ! + +!Philosopher methodsFor: 'private'! +putBackForkAt: aRelativePosition + | fork | + fork := forks at: aRelativePosition. + fork + ifNotNil: [table + at: (self tableIndex: seat + aRelativePosition) + put: fork. + forks at: aRelativePosition put: nil]! ! + +!Philosopher methodsFor: 'private'! +tableIndex: aNum + ^ aNum - 1 \\ table size + 1! ! + +!Philosopher methodsFor: 'private'! +waitRandomTime + (Delay forMilliseconds: (random next * 4000) rounded) wait! ! + + +!Philosopher methodsFor: 'dining'! +eat + self displayState: 'eating'; + waitRandomTime; + putBackForkAt: -1; + putBackForkAt: 1! ! + +!Philosopher methodsFor: 'dining'! +pickUpForks + self displayState: 'trying to pick up forks'. + [(self pickUpForkAt: -1) + ifTrue: [(self pickUpForkAt: 1) + ifFalse: [self putBackForkAt: -1]]. + (forks at: 1) notNil] + whileFalse: [(Delay forMilliseconds: 10) wait]! ! + +!Philosopher methodsFor: 'dining'! +think + self displayState: 'thinking'; + waitRandomTime! ! + + +!Philosopher methodsFor: 'initialize-release'! +beginDining: aName at: aTable + name := aName. + table := aTable. + forks := Dictionary new at: -1 put: nil; + at: 1 put: nil; + yourself. + random := Random new seed: name hash. + seat := table size + 1. + table add: self; + add: self createfork. + running := true. + [(Delay forSeconds: 20) wait. + running := false] fork. + [[running] + whileTrue: [self think; pickUpForks; eat]. + nil] fork! ! + +"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! + +Philosopher class + instanceVariableNames: ''! + +!Philosopher class methodsFor: 'examples'! +diningPhilosophersTest + | diningTable | + diningTable := OrderedCollection new. + #('Aristotle' 'Kant' 'Buddha' 'Marx' 'Russel' ) + do: [:aName | Philosopher new beginDining: aName at: diningTable]! ! diff --git a/Task/Dining-philosophers/Tcl/dining-philosophers.tcl b/Task/Dining-philosophers/Tcl/dining-philosophers.tcl new file mode 100644 index 0000000000..af08bfc5bd --- /dev/null +++ b/Task/Dining-philosophers/Tcl/dining-philosophers.tcl @@ -0,0 +1,68 @@ +package require Thread + +foreach name {Aristotle Kant Spinoza Marx Russel} { + lappend forks [thread::mutex create] + lappend tasks [set t [thread::create -preserved { + # Implement each task as a coroutine internally for simplicity of presentation + # This is because we want to remain able to receive messages so we can shut + # down neatly at the end of the program. + interp alias {} doTask {} coroutine t philosopher + proc delay {expression} { + yield [after [expr $expression] [info coroutine]] + } + + # Forks are mutexes... + proc pickUpFork fork { + thread::mutex lock $fork + } + proc putDownFork fork { + thread::mutex unlock $fork + } + + # The actual implementation of the task + proc philosopher {f1 f2} { + global name + # Always acquire forks in order; prevents deadlock + # Uses the "natural" order of the lexicographical order of the fork names + if {$f1 > $f2} { + lassign [list $f1 $f2] f2 f1 + } + + # The classic "philosophers" loop + while {true} { + puts "$name is thinking" + delay {int(200*rand())} + + puts "$name is hungry, getting fork in left hand" + pickUpFork $f1 + delay {int(2000*rand())} ;# Make deadlock likely if it is possible! + + puts "$name is hungry, getting fork in right hand" + pickUpFork $f2 + + puts "$name is eating" + delay {int(2000*rand())} + + puts "$name has finished eating; putting down forks" + putDownFork $f2 + putDownFork $f1 + delay 100 + } + } + thread::wait + }]] + thread::send $t [list set name $name] +} + +# Set the tasks going +foreach t $tasks {f1 f2} {0 1 1 2 2 3 3 4 4 0} { + thread::send -async $t [list \ + doTask [lindex $forks $f1] [lindex $forks $f2]] +} + +# Kill everything off after 30 seconds; that's enough for demonstration! +after 30000 +puts "Completing..." +foreach t $tasks { + thread::send -async $t thread::exit +} diff --git a/Task/Discordian-date/0DESCRIPTION b/Task/Discordian-date/0DESCRIPTION new file mode 100644 index 0000000000..2a77e38ad6 --- /dev/null +++ b/Task/Discordian-date/0DESCRIPTION @@ -0,0 +1,4 @@ +Convert a given date from the Gregorian calendar to the Discordian calendar. + +'''See Also''' +* [[wp:Discordian calendar|Discordian calendar (wiki)]] diff --git a/Task/Discordian-date/AWK/discordian-date.awk b/Task/Discordian-date/AWK/discordian-date.awk new file mode 100644 index 0000000000..b227b8f3a7 --- /dev/null +++ b/Task/Discordian-date/AWK/discordian-date.awk @@ -0,0 +1,95 @@ +# DDATE.AWK - Gregorian to Discordian date contributed by Dan Nielsen +# syntax: GAWK -f DDATE.AWK [YYYYMMDD | YYYY-MM-DD | MM-DD-YYYY | DDMMMYYYY | YYYY] ... +# examples: +# GAWK -f DDATE.AWK today +# GAWK -f DDATE.AWK 20110722 one date +# GAWK -f DDATE.AWK 20110722 20120229 two dates +# GAWK -f DDATE.AWK 2012 yearly calendar +BEGIN { + split("Chaos,Discord,Confusion,Bureaucracy,The Aftermath",season_arr,",") + split("Sweetmorn,Boomtime,Pungenday,Prickle-Prickle,Setting Orange",weekday_arr,",") + split("Mungday,Mojoday,Syaday,Zaraday,Maladay",apostle_holyday_arr,",") + split("Chaoflux,Discoflux,Confuflux,Bureflux,Afflux",season_holyday_arr,",") + split("31,28,31,30,31,30,31,31,30,31,30,31",days_in_month,",") # days per month in non leap year + split("0 31 59 90 120 151 181 212 243 273 304 334",rdt," ") # relative day table + mmm = "JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC" +# 1 2 3 4 5 6 7 8 9 10 11 12 + if (ARGV[1] == "") { # use current date + ARGV[ARGC++] = strftime("%Y%m%d") # GAWK only + # ARGV[ARGC++] = dos_date() # any AWK + # timetab(arr); ARGV[ARGC++] = sprintf("%04d%02d%02d",arr["YEAR"],arr["MONTH"],arr["DAY"]) # TAWK only + } + for (argno=1; argno<=ARGC-1; argno++) { # validate command line arguments + print("") + x = toupper(ARGV[argno]) + if (x ~ /^[0-9][0-9][0-9][0-9][01][0-9][0-3][0-9]$/) { # YYYYMMDD + main(x) + } + else if (x ~ /^[0-9][0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]$/) { # YYYY-MM-DD + gsub(/-/,"",x) + main(x) + } + else if (x ~ /^[01][0-9]-[0-3][0-9]-[0-9][0-9][0-9][0-9]$/) { # MM-DD-YYYY + main(substr(x,7,4) substr(x,1,2) substr(x,4,2)) + } + else if (x ~ /^[0-3][0-9](JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)[0-9][0-9][0-9][0-9]$/) { # DDMMMYYYY + main(sprintf("%04d%02d%02d",substr(x,6,4),int((match(mmm,substr(x,3,3))/4)+1),substr(x,1,2))) + } + else if (x ~ /^[0-9][0-9][0-9][0-9]$/) { # YYYY + yearly_calendar(x) + } + else { + error("begin") + } + } + if (errors == 0) { exit(0) } else { exit(1) } +} +function main(x, d,dyear,m,season_day,season_nbr,text,weekday_nbr,y,year_day) { + y = substr(x,1,4) + 0 + m = substr(x,5,2) + 0 + d = substr(x,7,2) + 0 + days_in_month[2] = (leap_year(y) == 1) ? 29 : 28 + if (m < 1 || m > 12 || d < 1 || d > days_in_month[m]+0) { + error("main") + return + } + year_day = rdt[m] + d + dyear = y + 1166 # Discordian year + season_nbr = int((year_day - 1 ) / 73) + 1 + season_day = ((year_day - 1) % 73) + 1 + weekday_nbr = ((year_day - 1 ) % 5) + 1 + if (season_day == 5) { + text = ", " apostle_holyday_arr[season_nbr] + } + else if (season_day == 50) { + text = ", " season_holyday_arr[season_nbr] + } + if (leap_year(y) && m == 2 && d == 29) { + printf("%04d-%02d-%02d is St. Tib's day, Year of Our Lady of Discord %s\n",y,m,d,dyear) + } + else { + printf("%04d-%02d-%02d is %s, %s %s, Year of Our Lady of Discord %s%s\n", + y,m,d,weekday_arr[weekday_nbr],season_arr[season_nbr],season_day,dyear,text) + } +} +function leap_year(y) { # leap year: 0=no, 1=yes + return (y % 400 == 0 || (y % 4 == 0 && y % 100)) ? 1 : 0 +} +function yearly_calendar(y, d,m) { + days_in_month[2] = (leap_year(y) == 1) ? 29 : 28 + for (m=1; m<=12; m++) { + for (d=1; d<=days_in_month[m]; d++) { + main(sprintf("%04d%02d%02d",y,m,d)) + } + } +} +function dos_date( cmd,x) { # under Microsoft Windows XP + cmd = "DATE Year (From), Month => 1, Day => 1); + Number_Days := From - First_Day; + + To.Year := Year (Date => From) + 1166; + To.Is_Tibs_Day := False; + if (To.Year - 2) mod 4 = 0 then + if Number_Days > 59 then + Number_Days := Number_Days - 1; + elsif Number_Days = 59 then + To.Is_Tibs_Day := True; + end if; + end if; + To.Day := Day_Number (Number_Days mod 73 + 1); + case Number_Days / 73 is + when 0 => To.Season := Chaos; + when 1 => To.Season := Discord; + when 2 => To.Season := Confusion; + when 3 => To.Season := Bureaucracy; + when 4 => To.Season := The_Aftermath; + when others => raise Constraint_Error; + end case; + end Convert; + + procedure Put (Item : Discordian_Date) is + begin + Ada.Text_IO.Put ("YOLD" & Integer'Image (Item.Year)); + if Item.Is_Tibs_Day then + Ada.Text_IO.Put (", St. Tib's Day"); + else + Ada.Text_IO.Put (", " & Seasons'Image (Item.Season)); + Ada.Text_IO.Put (" " & Integer'Image (Item.Day)); + end if; + Ada.Text_IO.New_Line; + end Put; + + Test_Day : Time; + Test_DDay : Discordian_Date; +begin + Test_Day := Clock; + Convert (From => Test_Day, To => Test_DDay); + Put (Test_DDay); + Test_Day := Time_Of (Year => 2012, Month => 2, Day => 28); + Convert (From => Test_Day, To => Test_DDay); + Put (Test_DDay); + Test_Day := Time_Of (Year => 2012, Month => 2, Day => 29); + Convert (From => Test_Day, To => Test_DDay); + Put (Test_DDay); + Test_Day := Time_Of (Year => 2012, Month => 3, Day => 1); + Convert (From => Test_Day, To => Test_DDay); + Put (Test_DDay); + Test_Day := Time_Of (Year => 2010, Month => 7, Day => 22); + Convert (From => Test_Day, To => Test_DDay); + Put (Test_DDay); + Test_Day := Time_Of (Year => 2012, Month => 9, Day => 2); + Convert (From => Test_Day, To => Test_DDay); + Put (Test_DDay); + Test_Day := Time_Of (Year => 2012, Month => 12, Day => 31); + Convert (From => Test_Day, To => Test_DDay); + Put (Test_DDay); +end Discordian; diff --git a/Task/Discordian-date/BASIC/discordian-date.bas b/Task/Discordian-date/BASIC/discordian-date.bas new file mode 100644 index 0000000000..4afb668ee1 --- /dev/null +++ b/Task/Discordian-date/BASIC/discordian-date.bas @@ -0,0 +1,52 @@ +#INCLUDE "datetime.bi" + +DECLARE FUNCTION julian(AS DOUBLE) AS INTEGER + + +SeasonNames: +DATA "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath" +Weekdays: +DATA "Setting Orange", "Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle" +DaysPreceding1stOfMonth: +' jan feb mar apr may jun jul aug sep oct nov dec +DATA 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 + +DIM dyear AS INTEGER, dseason AS STRING, dday AS INTEGER, dweekday AS STRING +DIM tmpdate AS DOUBLE, jday AS INTEGER, result AS STRING +DIM L0 AS INTEGER + +IF LEN(COMMAND$) THEN + tmpdate = DATEVALUE(COMMAND$) +ELSE + tmpdate = FIX(NOW()) +END IF +dyear = YEAR(tmpdate) + 1166 +IF (2 = MONTH(tmpdate)) AND (29 = DAY(tmpdate)) THEN + result = "Saint Tib's Day, " & STR$(dyear) & " YOLD" +ELSE + jday = julian(tmpdate) + RESTORE SeasonNames + FOR L0 = 1 TO (jday \ 73) + 1 + READ dseason + NEXT + dday = (jday MOD 73) + IF 0 = dday THEN dday = 73 + RESTORE Weekdays + FOR L0 = 1 TO (jday MOD 5) + 1 + READ dweekday + NEXT + result = dweekday & ", " & dseason & " " & TRIM$(STR$(dday)) & ", " & TRIM$(STR$(dyear)) & " YOLD" +END IF + +? result +END + +FUNCTION julian(d AS DOUBLE) AS INTEGER + 'doesn't account for leap years (not needed for ddate) + DIM tmp AS INTEGER, L1 AS INTEGER + RESTORE DaysPreceding1stOfMonth + FOR L1 = 1 TO MONTH(d) + READ tmp + NEXT + FUNCTION = tmp + DAY(d) +END FUNCTION diff --git a/Task/Discordian-date/BBC-BASIC/discordian-date.bbc b/Task/Discordian-date/BBC-BASIC/discordian-date.bbc new file mode 100644 index 0000000000..eb660feaa9 --- /dev/null +++ b/Task/Discordian-date/BBC-BASIC/discordian-date.bbc @@ -0,0 +1,38 @@ + INSTALL @lib$+"DATELIB" + + PRINT "01/01/2011 -> " FNdiscordian("01/01/2011") + PRINT "05/01/2011 -> " FNdiscordian("05/01/2011") + PRINT "28/02/2011 -> " FNdiscordian("28/02/2011") + PRINT "01/03/2011 -> " FNdiscordian("01/03/2011") + PRINT "22/07/2011 -> " FNdiscordian("22/07/2011") + PRINT "31/12/2011 -> " FNdiscordian("31/12/2011") + + PRINT "01/01/2012 -> " FNdiscordian("01/01/2012") + PRINT "05/01/2012 -> " FNdiscordian("05/01/2012") + PRINT "28/02/2012 -> " FNdiscordian("28/02/2012") + PRINT "29/02/2012 -> " FNdiscordian("29/02/2012") + PRINT "01/03/2012 -> " FNdiscordian("01/03/2012") + PRINT "22/07/2012 -> " FNdiscordian("22/07/2012") + PRINT "31/12/2012 -> " FNdiscordian("31/12/2012") + END + + DEF FNdiscordian(date$) + LOCAL Season$(), Weekday$(), mjd%, year%, day% + DIM Season$(4), Weekday$(4) + Season$() = "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath" + Weekday$() = "Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange" + + mjd% = FN_readdate(date$, "dmy", 2000) + year% = FN_year(mjd%) + + IF FN_month(mjd%)=2 AND FN_day(mjd%)=29 THEN + = "St. Tib's Day, YOLD " + STR$(year% + 1166) + ENDIF + + IF FN_month(mjd%) < 3 THEN + day% = mjd% - FN_mjd(1, 1, year%) + ELSE + day% = mjd% - FN_mjd(1, 3, year%) + 59 + ENDIF + = Weekday$(day% MOD 5) + ", " + STR$(day% MOD 73 + 1) + " " + \ + \ Season$(day% DIV 73) + ", YOLD " + STR$(year% + 1166) diff --git a/Task/Discordian-date/C/discordian-date.c b/Task/Discordian-date/C/discordian-date.c new file mode 100644 index 0000000000..3b7d51c958 --- /dev/null +++ b/Task/Discordian-date/C/discordian-date.c @@ -0,0 +1,65 @@ +#include +#include +#include + +#define season( x ) ((x) == 0 ? "Chaos" :\ + (x) == 1 ? "Discord" :\ + (x) == 2 ? "Confusion" :\ + (x) == 3 ? "Bureaucracy" :\ + "The Aftermath") + +#define date( x ) ((x)%73 == 0 ? 73 : (x)%73) + +#define leap_year( x ) ((x) % 400 == 0 || (((x) % 4) == 0 && (x) % 100)) + +char * ddate( int y, int d ){ + int dyear = 1166 + y; + char * result = malloc( 100 * sizeof( char ) ); + + if( leap_year( y ) ){ + if( d == 60 ){ + sprintf( result, "St. Tib's Day, YOLD %d", dyear ); + return result; + } else if( d >= 60 ){ + -- d; + } + } + + sprintf( result, "%s %d, YOLD %d", season( d/73 ), date( d ), dyear ); + + return result; +} + + +int day_of_year( int y, int m, int d ){ + int month_lengths[ 12 ] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + + for( ; m > 1; m -- ){ + d += month_lengths[ m - 2 ]; + if( m == 3 && leap_year( y ) ){ + ++ d; + } + } + return d; +} + + +int main( int argc, char * argv[] ){ + time_t now; + struct tm * now_time; + int year, doy; + + if( argc == 1 ){ + now = time( NULL ); + now_time = localtime( &now ); + year = now_time->tm_year + 1900; doy = now_time->tm_yday + 1; + } else if( argc == 4 ){ + year = atoi( argv[ 1 ] ); doy = day_of_year( atoi( argv[ 1 ] ), atoi( argv[ 2 ] ), atoi( argv[ 3 ] ) ); + } + + char * result = ddate( year, doy ); + puts( result ); + free( result ); + + return 0; +} diff --git a/Task/Discordian-date/D/discordian-date.d b/Task/Discordian-date/D/discordian-date.d new file mode 100644 index 0000000000..dfa0b83283 --- /dev/null +++ b/Task/Discordian-date/D/discordian-date.d @@ -0,0 +1,55 @@ +import std.stdio, std.datetime, std.conv, std.string; + +immutable seasons = ["Chaos", "Discord", "Confusion", "Bureaucracy", + "The Aftermath"]; + +immutable weekday = ["Sweetmorn", "Boomtime", "Pungenday", + "Prickle-Prickle", "Setting Orange"]; + +immutable apostle = ["Mungday", "Mojoday", "Syaday", "Zaraday", + "Maladay"]; + +immutable holiday = ["Chaoflux", "Discoflux", "Confuflux", + "Bureflux", "Afflux"]; + +string discordianDate(in Date date) { + auto dyear = text(date.year + 1166); + + auto isLeapYear = date.isLeapYear; + if (isLeapYear && date.month == 2 && date.day == 29) + return "St. Tib's Day, in the YOLD " ~ dyear; + + auto doy = date.dayOfYear; + if (isLeapYear && doy >= 60) + doy--; + + auto dsday = doy % 73; // season day + if (dsday == 5) return apostle[doy / 73] ~ ", in the YOLD " ~ dyear; + if (dsday == 50) return holiday[doy / 73] ~ ", in the YOLD " ~ dyear; + + auto dseas = seasons[doy / 73]; + auto dwday = weekday[(doy-1) % 5]; + + return format("%s, day %s of %s in the YOLD %s", dwday, dsday, dseas, + dyear); +} + +void main() { + auto today = cast(Date)Clock.currTime(); + writeln(discordianDate(today)); +} + +unittest { + assert(discordianDate(Date(2010,7,22)) == + "Pungenday, day 57 of Confusion in the YOLD 3176"); + assert(discordianDate(Date(2012,2,28)) == + "Prickle-Prickle, day 59 of Chaos in the YOLD 3178"); + assert(discordianDate(Date(2012,2,29)) == + "St. Tib's Day, in the YOLD 3178"); + assert(discordianDate(Date(2012,3, 1)) == + "Setting Orange, day 60 of Chaos in the YOLD 3178"); + assert(discordianDate(Date(2010,1, 5)) == + "Mungday, in the YOLD 3176"); + assert(discordianDate(Date(2011,5, 3)) == + "Discoflux, in the YOLD 3177"); +} diff --git a/Task/Discordian-date/Euphoria/discordian-date.euphoria b/Task/Discordian-date/Euphoria/discordian-date.euphoria new file mode 100644 index 0000000000..c89f306479 --- /dev/null +++ b/Task/Discordian-date/Euphoria/discordian-date.euphoria @@ -0,0 +1,59 @@ +function isLeapYear(integer year) + return remainder(year,4)=0 and remainder(year,100)!=0 or remainder(year,400)=0 +end function + +constant YEAR = 1, MONTH = 2, DAY = 3, DAY_OF_YEAR = 8 + +constant month_lengths = {31,28,31,30,31,30,31,31,30,31,30,31} +function dayOfYear(sequence Date) + integer d + if length(Date) = DAY_OF_YEAR then + d = Date[DAY_OF_YEAR] + else + d = Date[DAY] + for i = Date[MONTH]-1 to 1 by -1 do + d += month_lengths[i] + if i = 2 and isLeapYear(Date[YEAR]) then + d += 1 + end if + end for + end if + return d +end function + +constant seasons = {"Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"} +constant weekday = {"Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"} +constant apostle = {"Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay"} +constant holiday = {"Chaoflux", "Discoflux", "Confuflux", "Bureflux", "Afflux"} + +function discordianDate(sequence Date) + sequence dyear, dseas, dwday + integer leap, doy, dsday + dyear = sprintf("%d",Date[YEAR]+1166) + leap = isLeapYear(Date[YEAR]) + if leap and Date[MONTH] = 2 and Date[DAY] = 29 then + return "St. Tib's Day, in the YOLD " & dyear + end if + + doy = dayOfYear(Date) + if leap and doy >= 60 then + doy -= 1 + end if + + dsday = remainder(doy,73) + if dsday = 5 then + return apostle[doy/73+1] & ", in the YOLD " & dyear + elsif dsday = 50 then + return holiday[doy/73+1] & ", in the YOLD " & dyear + end if + + dseas = seasons[doy/73+1] + dwday = weekday[remainder(doy-1,5)+1] + + return sprintf("%s, day %d of %s in the YOLD %s", {dwday, dsday, dseas, dyear}) +end function + +sequence today +today = date() +today[YEAR] += 1900 +puts(1, discordianDate(today)) diff --git a/Task/Discordian-date/Go/discordian-date-1.go b/Task/Discordian-date/Go/discordian-date-1.go new file mode 100644 index 0000000000..d3f330d01a --- /dev/null +++ b/Task/Discordian-date/Go/discordian-date-1.go @@ -0,0 +1,133 @@ +package ddate + +import ( + "strconv" + "strings" + "time" +) + +// Predefined formats for DiscDate.Format +const ( + DefaultFmt = "Pungenday, Discord 5, 3131 YOLD" + OldFmt = `Today is Pungenday, the 5th day of Discord in the YOLD 3131 +Celebrate Mojoday` +) + +// Formats passed to DiscDate.Format are protypes for formated dates. +// Format replaces occurrences of prototype elements (the constant strings +// listed here) with values corresponding to the date being formatted. +// If the date is St. Tib's Day, the string from the first date element +// through the last is replaced with "St. Tib's Day". +const ( + protoLongSeason = "Discord" + protoShortSeason = "Dsc" + protoLongDay = "Pungenday" + protoShortDay = "PD" + protoOrdDay = "5" + protoCardDay = "5th" + protoHolyday = "Mojoday" + protoYear = "3131" +) + +var ( + longDay = []string{"Sweetmorn", "Boomtime", "Pungenday", + "Prickle-Prickle", "Setting Orange"} + shortDay = []string{"SM", "BT", "PD", "PP", "SO"} + longSeason = []string{ + "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"} + shortSeason = []string{"Chs", "Dsc", "Cfn", "Bcy", "Afm"} + holyday = [][]string{{"Mungday", "Chaoflux"}, {"Mojoday", "Discoflux"}, + {"Syaday", "Confuflux"}, {"Zaraday", "Bureflux"}, {"Maladay", "Afflux"}} +) + +type DiscDate struct { + StTibs bool + Dayy int // zero based day of year, meaningless if StTibs is true + Year int // gregorian + 1166 +} + +func New(eris time.Time) DiscDate { + t := time.Date(eris.Year(), 1, 1, eris.Hour(), eris.Minute(), + eris.Second(), eris.Nanosecond(), eris.Location()) + bob := int(eris.Sub(t).Hours()) / 24 + raw := eris.Year() + hastur := DiscDate{Year: raw + 1166} + if raw%4 == 0 && (raw%100 != 0 || raw%400 == 0) { + if bob > 59 { + bob-- + } else if bob == 59 { + hastur.StTibs = true + return hastur + } + } + hastur.Dayy = bob + return hastur +} + +func (dd DiscDate) Format(f string) (r string) { + var st, snarf string + var dateElement bool + f6 := func(proto, wibble string) { + if !dateElement { + snarf = r + dateElement = true + } + if st > "" { + r = "" + } else { + r += wibble + } + f = f[len(proto):] + } + f4 := func(proto, wibble string) { + if dd.StTibs { + st = "St. Tib's Day" + } + f6(proto, wibble) + } + season, day := dd.Dayy/73, dd.Dayy%73 + for f > "" { + switch { + case strings.HasPrefix(f, protoLongDay): + f4(protoLongDay, longDay[dd.Dayy%5]) + case strings.HasPrefix(f, protoShortDay): + f4(protoShortDay, shortDay[dd.Dayy%5]) + case strings.HasPrefix(f, protoCardDay): + funkychickens := "th" + if day/10 != 1 { + switch day % 10 { + case 0: + funkychickens = "st" + case 1: + funkychickens = "nd" + case 2: + funkychickens = "rd" + } + } + f4(protoCardDay, strconv.Itoa(day+1)+funkychickens) + case strings.HasPrefix(f, protoOrdDay): + f4(protoOrdDay, strconv.Itoa(day+1)) + case strings.HasPrefix(f, protoLongSeason): + f6(protoLongSeason, longSeason[season]) + case strings.HasPrefix(f, protoShortSeason): + f6(protoShortSeason, shortSeason[season]) + case strings.HasPrefix(f, protoHolyday): + if day == 4 { + r += holyday[season][0] + } else if day == 49 { + r += holyday[season][1] + } + f = f[len(protoHolyday):] + case strings.HasPrefix(f, protoYear): + r += strconv.Itoa(dd.Year) + f = f[4:] + default: + r += f[:1] + f = f[1:] + } + } + if st > "" { + r = snarf + st + r + } + return +} diff --git a/Task/Discordian-date/Go/discordian-date-2.go b/Task/Discordian-date/Go/discordian-date-2.go new file mode 100644 index 0000000000..56701ba9a1 --- /dev/null +++ b/Task/Discordian-date/Go/discordian-date-2.go @@ -0,0 +1,43 @@ +package main + +import ( + "ddate" + "fmt" + "os" + "strings" + "time" +) + +func main() { + pi := 1 + fnord := ddate.DefaultFmt + if len(os.Args) > 1 { + switch os.Args[1][0] { + case '+': + pi++ + fnord = os.Args[1][1:] + case '-': + usage() + } + } + var eris time.Time + switch len(os.Args) - pi { + case 0: + eris = time.Now() + case 3: + var err error + eris, err = time.Parse("2 1 2006", strings.Join(os.Args[pi:pi+3], " ")) + if err != nil { + fmt.Println(err) + usage() + } + default: + usage() + } + fmt.Println(ddate.New(eris).Format(fnord)) +} + +func usage() { + fmt.Fprintf(os.Stderr, "usage: %s [+format] [day month year]\n", os.Args[0]) + os.Exit(1) +} diff --git a/Task/Discordian-date/Haskell/discordian-date.hs b/Task/Discordian-date/Haskell/discordian-date.hs new file mode 100644 index 0000000000..c74545f458 --- /dev/null +++ b/Task/Discordian-date/Haskell/discordian-date.hs @@ -0,0 +1,14 @@ +import Data.List +import Data.Time +import Data.Time.Calendar.MonthDay + +seasons = words "Chaos Discord Confusion Bureaucracy The_Aftermath" + +discordianDate (y,m,d) = do + let doy = monthAndDayToDayOfYear (isLeapYear y) m d + (season, dday) = divMod doy 73 + dos = dday - fromEnum (isLeapYear y && m >2) + dDate + | isLeapYear y && m==2 && d==29 = "St. Tib's Day, " ++ show (y+1166) ++ " YOLD" + | otherwise = seasons!!season ++ " " ++ show dos ++ ", " ++ show (y+1166) ++ " YOLD" + putStrLn dDate diff --git a/Task/Discordian-date/JavaScript/discordian-date-1.js b/Task/Discordian-date/JavaScript/discordian-date-1.js new file mode 100644 index 0000000000..953d91ea84 --- /dev/null +++ b/Task/Discordian-date/JavaScript/discordian-date-1.js @@ -0,0 +1,49 @@ +/** + * All Hail Discordia! - this script prints Discordian date using system date. + * author: s1w_, lang: JavaScript + */ +function print_ddate(mod) { + var p; + switch(mod || 0) {// <--choose display pattern or pass option by parameter + default: + case 0:/* Sweetmorn, Day 57 of the Season of Confusion, Anno Mung 3177 */ p="{0}, [Day {1} of the Season of {2}], Anno Mung {3}"; break; + case 1:/* Sweetmorn, The 57th Day of Confusion, 3177 YOLD */ p="{0}, [The {1}th Day of {2}], {3} YOLD"; break; + case 2:/* Sweetmorn, the 57th day of Confusion, AM 3177 */ p="{0}, [the {1}th day of {2}], AM {3}"; break; + case 3:/* Sweetmorn / Confusion 57th / AM 3177 */ p="{0} / [{2} {1}th] / AM {3}"; break; + } + var ddateStr, curr, sum, extra, today, day, month, year, dSeason, dDay, season, ddate, dyear; + + format = function(s, $1, $2, $3, $4) { + if ($2 != undefined) { + var postfix; + switch(parseInt($2.charAt($2.length-1))) { + case 1: postfix = '}st'; break; + case 2: postfix = '}nd'; break; + case 3: postfix = '}rd'; break; + default:postfix = '}th'; + } + return p.replace(/\}th/, postfix).replace(/(\[|\])/g, '').format($1, $2, $3, $4); + } + else return p.replace(/\[.*?\]/,"{2}").format($1, $2, $3, $4); + } + + String.prototype.format = function() { + var pattern = /\{\d+\}/g; + var args = arguments; + return this.replace(pattern, function(capture){ return args[capture.match(/\d+/)]; }); + } + + dDay = new Array("Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"); + dSeason = new Array("Chaos", "Discord", "Confusion", "Bureaucracy", "Aftermath"); + curr = new Date(); extra = new Array(0,3,0,3,2,3,2,3,3,2,3,2); + today = curr.getDate(); month = curr.getMonth(); year = curr.getFullYear(); + sum = month * 28; + for(var i=0; i<=month; i++) + sum += extra[i]; + sum += today; + day = (sum - 1) % 5; ddate = sum % 73; + season = (month==1)&&(today==29) ? "St. Tib\'s Day" : dSeason[Math.floor(sum/73)]; + dyear = year+1166; + ddateStr = ""+dDay[day]+ddate+season+dyear; + document.write(ddateStr.replace(/(\D+)(?:(\d+)(?!St)|(?:\d+))(\D+)(\d+)/i, format)); +} diff --git a/Task/Discordian-date/JavaScript/discordian-date-2.js b/Task/Discordian-date/JavaScript/discordian-date-2.js new file mode 100644 index 0000000000..3c654e9faf --- /dev/null +++ b/Task/Discordian-date/JavaScript/discordian-date-2.js @@ -0,0 +1,8 @@ +print_ddate() +"Sweetmorn, Day 57 of the Season of Confusion, Anno Mung 3177" +print_ddate(1) +"Sweetmorn, The 57th Day of Confusion, 3177 YOLD" +print_ddate(2) +"Sweetmorn, the 57th day of Confusion, AM 3177" +print_ddate(3) +"Sweetmorn / Confusion 57th / AM 3177" diff --git a/Task/Discordian-date/PHP/discordian-date.php b/Task/Discordian-date/PHP/discordian-date.php new file mode 100644 index 0000000000..8e7d6cfc8b --- /dev/null +++ b/Task/Discordian-date/PHP/discordian-date.php @@ -0,0 +1,62 @@ += 60) { //offset day by one if leap year + $dday -= 1; + if($dday % 5 == 0) $ddayname = $DAYS[4]; + else $ddayname = $DAYS[($dday%5)]; + } + } + // Display Discordian date + echo "Today is " . $ddayname . ", " . $dmonth . " " . $dday . ", YOLD " . $dyear; +} +else { // Leap year exception for date from URL + if ($usery % 100 == 0) { // leap year exception for years that are divisible by one hundred + if ($usery % 400 == 0 && $userm == 2 && $userd == 29) { echo "Today is St. Tib's Day, YOLD " . $dyear; } + } + else if ($usery % 4 == 0) { // if the year is a leap year + if ($userm == 2 && $userd == 29) { echo "Today is St. Tib's Day, YOLD " . $dyear; } + elseif ($ddays >= 60) { // offset day by one if leap year + $dday -=1; + if($dday % 5 == 0) $ddayname = $DAYS[4]; + else $ddayname=$DAYS[($dday%5-1)]; + echo "Today is " . $ddayname . ", " . $dmonth . " " . $dday . ", YOLD " . $dyear; + } + else { echo "Today is " . $ddayname . ", " . $dmonth . " " . $dday . ", YOLD " . $dyear; } + } + // Display Discordian date + else { echo "Today is " . $ddayname . ", " . $dmonth . " " . $dday . ", YOLD " . $dyear; } +} +?> diff --git a/Task/Discordian-date/PicoLisp/discordian-date.l b/Task/Discordian-date/PicoLisp/discordian-date.l new file mode 100644 index 0000000000..2cacb5e4cf --- /dev/null +++ b/Task/Discordian-date/PicoLisp/discordian-date.l @@ -0,0 +1,14 @@ +(de disdate (Year Month Day) + (let? Date (date Year Month Day) + (let (Leap (date Year 2 29) D (- Date (date Year 1 1))) + (if (and Leap (= 2 Month) (= 29 Day)) + (pack "St. Tib's Day, YOLD " (+ Year 1166)) + (and Leap (>= D 60) (dec 'D)) + (pack + (get + '("Chaos" "Discord" "Confusion" "Bureaucracy" "The Aftermath") + (inc (/ D 73)) ) + " " + (inc (% D 73)) + ", YOLD " + (+ Year 1166) ) ) ) ) ) diff --git a/Task/Discordian-date/Python/discordian-date.py b/Task/Discordian-date/Python/discordian-date.py new file mode 100644 index 0000000000..6ffe94be2f --- /dev/null +++ b/Task/Discordian-date/Python/discordian-date.py @@ -0,0 +1,17 @@ +import datetime, calendar + +DISCORDIAN_SEASONS = ["Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"] + +def ddate(year, month, day): + today = datetime.date(year, month, day) + is_leap_year = calendar.isleap(year) + if is_leap_year and month == 2 and day == 29: + return "St. Tib's Day, YOLD " + (year + 1166) + + day_of_year = today.timetuple().tm_yday - 1 + + if is_leap_year and day_of_year >= 60: + day_of_year -= 1 # Compensate for St. Tib's Day + + season, dday = divmod(day_of_year, 73) + return "%s %d, YOLD %d" % (DISCORDIAN_SEASONS[season], dday + 1, year + 1166) diff --git a/Task/Discordian-date/REXX/discordian-date.rexx b/Task/Discordian-date/REXX/discordian-date.rexx new file mode 100644 index 0000000000..63705e12ee --- /dev/null +++ b/Task/Discordian-date/REXX/discordian-date.rexx @@ -0,0 +1,30 @@ +/*REXX program converts mm/dd/yyyy Gregorian date ───> Discordian date. */ +/*Gregorian date may be m/d/yy ──or── m/d format. */ + +day.1='Sweetness' /*define 1st day-of-Discordian-week.*/ +day.2='Boomtime' /*define 2nd day-of-Discordian-week.*/ +day.3='Pungenday' /*define 3rd day-of-Discordian-week.*/ +day.4='Prickle-Prickle' /*define 4th day-of-Discordian-week.*/ +day.5='Setting Orange' /*define 5th day-of-Discordian-week.*/ + +seas.0="St. Tib's day," /*define the leap-day of Discordian yr.*/ +seas.1='Chaos' /*define 1st season-of-Discordian-year.*/ +seas.2='Discord' /*define 2nd season-of-Discordian-year.*/ +seas.3='Confusion' /*define 3rd season-of-Discordian-year.*/ +seas.4='Bureaucracy' /*define 4th season-of-Discordian-year.*/ +seas.5='The Aftermath' /*define 5th season-of-Discordian-year.*/ + +parse arg gM '/' gD "/" gY . /*get the date specified. */ +gY=left(right(date(),4),4-length(Gy))gY /*adjust for a 2-dig yr or none*/ + /*below:get day-of-year,adj LeapY*/ +doy=date('d',gY||right(gM,2,0)right(gD,2,0),"s")-(leapyear(gY) & gM>2) +dW=doy//5;if dW==0 then dW=5 /*compute the Discordian weekday.*/ +dS=(doy-1)%73+1 /*compute the Discordian season. */ +dD=doy//73;if dD==0 then dD=73; dD=dD',' /*Discordian day-of-month.*/ +if leapyear(gY) & gM==02 & gD==29 then do; dD=''; ds=0; end /*St. Tib's?*/ +say space(day.dW',' seas.dS dD gY+1166) /*show and tell Discordian date*/ +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────LEAPYEAR subroutine──────────────*/ +leapyear: procedure; arg y +if y//4\==0 then return 0 /* not ≈ by 4? Not a leapyear.*/ +return y//100\==0 | y//400==0 /*apply 100 and 400 year rule. */ diff --git a/Task/Discordian-date/Ruby/discordian-date-1.rb b/Task/Discordian-date/Ruby/discordian-date-1.rb new file mode 100644 index 0000000000..3a9c77b8e6 --- /dev/null +++ b/Task/Discordian-date/Ruby/discordian-date-1.rb @@ -0,0 +1,44 @@ +require 'date' + +class DiscordianDate + SEASON_NAMES = ["Chaos","Discord","Confusion","Bureaucracy","The Aftermath"] + DAY_NAMES = ["Sweetmorn","Boomtime","Pungenday","Prickle-Prickle","Setting Orange"] + YEAR_OFFSET = 1166 + DAYS_PER_SEASON = 73 + DAYS_PER_WEEK = 5 + ST_TIBS_DAY_OF_YEAR = 60 + + def initialize(year, month, day) + gregorian_date = Date.new(year, month, day) + @day_of_year = gregorian_date.yday + + @st_tibs = false + if gregorian_date.leap? + if @day_of_year == ST_TIBS_DAY_OF_YEAR + @st_tibs = true + elsif @day_of_year > ST_TIBS_DAY_OF_YEAR + @day_of_year -= 1 + end + end + + @season, @day = @day_of_year.divmod(DAYS_PER_SEASON) + @year = gregorian_date.year + YEAR_OFFSET + end + attr_reader :year, :day + + def season + SEASON_NAMES[@season] + end + + def weekday + if @st_tibs + "St. Tib's Day" + else + DAY_NAMES[(@day_of_year - 1) % DAYS_PER_WEEK] + end + end + + def to_s + %Q{#{@st_tibs ? "St. Tib's Day" : "%s, %s %d" % [weekday, season, day]}, #{year} YOLD} + end +end diff --git a/Task/Discordian-date/Ruby/discordian-date-2.rb b/Task/Discordian-date/Ruby/discordian-date-2.rb new file mode 100644 index 0000000000..d00dfb4cb1 --- /dev/null +++ b/Task/Discordian-date/Ruby/discordian-date-2.rb @@ -0,0 +1,4 @@ +[[2012, 2, 28], [2012, 2, 29], [2012, 3, 1], [2011, 10, 5]].each do |date| + dd = DiscordianDate.new(*date) + puts "#{"%4d-%02d-%02d" % date} => #{dd}" +end diff --git a/Task/Discordian-date/Scala/discordian-date.scala b/Task/Discordian-date/Scala/discordian-date.scala new file mode 100644 index 0000000000..589c675dd7 --- /dev/null +++ b/Task/Discordian-date/Scala/discordian-date.scala @@ -0,0 +1,19 @@ +import java.util.{GregorianCalendar, Calendar} + +val DISCORDIAN_SEASONS=Array("Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath") +def ddate(year:Int, month:Int, day:Int):String={ + val date=new GregorianCalendar(year, month-1, day) + val dyear=year+1166 + + val isLeapYear=date.isLeapYear(year) + if(isLeapYear && month==2 && day==29) + return "St. Tib's Day "+dyear+" YOLD" + + var dayOfYear=date.get(Calendar.DAY_OF_YEAR) + if(isLeapYear && dayOfYear>=60) + dayOfYear-=1 // compensate for St. Tib's Day + + val dday=dayOfYear%73 + val season=dayOfYear/73 + "%s %d, %d YOLD".format(DISCORDIAN_SEASONS(season), dday, dyear) +} diff --git a/Task/Discordian-date/Tcl/discordian-date-1.tcl b/Task/Discordian-date/Tcl/discordian-date-1.tcl new file mode 100644 index 0000000000..8d3518efb7 --- /dev/null +++ b/Task/Discordian-date/Tcl/discordian-date-1.tcl @@ -0,0 +1,23 @@ +package require Tcl 8.5 +proc disdate {year month day} { + # Get the day of the year + set now [clock scan [format %02d-%02d-%04d $day $month $year] -format %d-%m-%Y] + scan [clock format $now -format %j] %d doy + + # Handle leap years + if {!($year%4) && (($year%100) || !($year%400))} { + if {$doy == 60} { + return "St. Tib's Day, [expr {$year + 1166}] YOLD" + } elseif {$doy > 60} { + incr doy -1 + } + } + + # Main conversion to discordian format now that special cases are handled + incr doy -1; # Allow div/mod to work right + set season [lindex {Chaos Discord Confusion Bureaucracy {The Aftermath}} \ + [expr {$doy / 73}]] + set dos [expr {$doy % 73 + 1}] + incr year 1166 + return "$season $dos, $year YOLD" +} diff --git a/Task/Discordian-date/Tcl/discordian-date-2.tcl b/Task/Discordian-date/Tcl/discordian-date-2.tcl new file mode 100644 index 0000000000..6990cb9adf --- /dev/null +++ b/Task/Discordian-date/Tcl/discordian-date-2.tcl @@ -0,0 +1,4 @@ +puts [disdate 2010 7 22]; # Today +puts [disdate 2012 2 28] +puts [disdate 2012 2 29] +puts [disdate 2012 3 1] diff --git a/Task/Distributed-programming/0DESCRIPTION b/Task/Distributed-programming/0DESCRIPTION new file mode 100644 index 0000000000..a7c95a614d --- /dev/null +++ b/Task/Distributed-programming/0DESCRIPTION @@ -0,0 +1,5 @@ +Write two programs (or one program with two modes) which run on networked computers, and send some messages between them. + +The protocol used may be language-specific or not, and should be '''suitable for general distributed programming'''; that is, the ''protocol'' should be generic (not designed just for the particular example application), readily capable of handling the independent communications of many different components of a single application, and the transferring of arbitrary data structures natural for the language. + +This task is intended to demonstrate high-level communication facilities beyond just creating [[sockets]]. diff --git a/Task/Distributed-programming/1META.yaml b/Task/Distributed-programming/1META.yaml new file mode 100644 index 0000000000..688669690e --- /dev/null +++ b/Task/Distributed-programming/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Networking and Web Interaction diff --git a/Task/Distributed-programming/Ada/distributed-programming-1.ada b/Task/Distributed-programming/Ada/distributed-programming-1.ada new file mode 100644 index 0000000000..889510a2a6 --- /dev/null +++ b/Task/Distributed-programming/Ada/distributed-programming-1.ada @@ -0,0 +1,5 @@ +package Server is + pragma Remote_Call_Interface; + procedure Foo; + function Bar return Natural; +end Server; diff --git a/Task/Distributed-programming/Ada/distributed-programming-2.ada b/Task/Distributed-programming/Ada/distributed-programming-2.ada new file mode 100644 index 0000000000..17ff448bb7 --- /dev/null +++ b/Task/Distributed-programming/Ada/distributed-programming-2.ada @@ -0,0 +1,13 @@ +package body Server is + Count : Natural := 0; + + procedure Foo is + begin + Count := Count + 1; + end Foo; + + function Bar return Natural is + begin + return Count; + end Bar; +end Server; diff --git a/Task/Distributed-programming/Ada/distributed-programming-3.ada b/Task/Distributed-programming/Ada/distributed-programming-3.ada new file mode 100644 index 0000000000..58b4c80e44 --- /dev/null +++ b/Task/Distributed-programming/Ada/distributed-programming-3.ada @@ -0,0 +1,9 @@ +with Server; +with Ada.Text_IO; + +procedure Client is +begin + Ada.Text_IO.Put_Line ("Calling Foo..."); + Server.Foo; + Ada.Text_IO.Put_Line ("Calling Bar: " & Integer'Image (Server.Bar)); +end Client; diff --git a/Task/Distributed-programming/Ada/distributed-programming-4.ada b/Task/Distributed-programming/Ada/distributed-programming-4.ada new file mode 100644 index 0000000000..b49486f2e5 --- /dev/null +++ b/Task/Distributed-programming/Ada/distributed-programming-4.ada @@ -0,0 +1,13 @@ +configuration DSA is + pragma Starter (None); + + -- Server + Server_Partition : Partition := (Server); + procedure Run_Server is in Server_Partition; + + -- Client + Client_Partition : Partition; + for Client_Partition'Termination use Local_Termination; + procedure Client; + for Client_Partition'Main use Client; +end DSA; diff --git a/Task/Distributed-programming/C/distributed-programming-1.c b/Task/Distributed-programming/C/distributed-programming-1.c new file mode 100644 index 0000000000..eba00274c5 --- /dev/null +++ b/Task/Distributed-programming/C/distributed-programming-1.c @@ -0,0 +1,50 @@ +#include +#include +#include + +int main(int c, char **v) +{ + int tids[10]; + int parent, spawn; + int i_data, i2; + double f_data; + + if (c > 1) { + spawn = pvm_spawn("/tmp/a.out", 0, PvmTaskDefault, 0, 1, tids); + if (spawn <= 0) { + printf("Can't spawn task\n"); + return 1; + } + + printf("Spawning successful\n"); + + /* pvm_recv(task_id, msgtag). msgtag identifies what kind of data it is, + * for here: 1 = (int, double), 2 = (int, int) + * The receiving order is intentionally swapped, just to show. + * task_id = -1 means "receive from any task" + */ + pvm_recv(-1, 2); + pvm_unpackf("%d %d", &i_data, &i2); + printf("got msg type 2: %d %d\n", i_data, i2); + + pvm_recv(-1, 1); + pvm_unpackf("%d %lf", &i_data, &f_data); + printf("got msg type 1: %d %f\n", i_data, f_data); + } else { + parent = pvm_parent(); + + pvm_initsend(PvmDataDefault); + i_data = rand(); + f_data = (double)rand() / RAND_MAX; + pvm_packf("%d %lf", i_data, f_data); + pvm_send(parent, 1); /* send msg type 1 */ + + pvm_initsend(PvmDataDefault); + i2 = rand(); + pvm_packf("%d %d", i_data, i2); + pvm_send(parent, 2); /* send msg type 2 */ + } + + pvm_exit(); + return 0; +} diff --git a/Task/Distributed-programming/C/distributed-programming-2.c b/Task/Distributed-programming/C/distributed-programming-2.c new file mode 100644 index 0000000000..748a075324 --- /dev/null +++ b/Task/Distributed-programming/C/distributed-programming-2.c @@ -0,0 +1,11 @@ +pvm> spawn -> /tmp/a.out 1 +spawn -> /tmp/a.out 1 +[2] +1 successful +t40028 +pvm> [2:t40029] EOF +[2:t40028] Spawning successful +[2:t40028] got msg type 2: 1804289383 1681692777 +[2:t40028] got msg type 1: 1804289383 0.394383 +[2:t40028] EOF +[2] finished diff --git a/Task/Distributed-programming/D/distributed-programming-1.d b/Task/Distributed-programming/D/distributed-programming-1.d new file mode 100644 index 0000000000..90abe01ea8 --- /dev/null +++ b/Task/Distributed-programming/D/distributed-programming-1.d @@ -0,0 +1,38 @@ +module distributedserver ; +import tango.net.ServerSocket, tango.text.convert.Integer, + tango.text.Util, tango.io.Stdout ; + +void main() { + auto Ip = new InternetAddress("localhost", 12345) ; + auto server = new ServerSocket(Ip) ; + auto socket = server.accept ; + auto buffer = new char[socket.bufferSize] ; + + bool quit = false ; + + while(!quit) { + bool error = false ; + + try { + auto len = socket.input.read(buffer) ; + auto cmd = (len > 0) ? delimit(buffer[0..len], " ") : [""] ; + Stdout(cmd).newline.flush ; + switch (cmd[0]) { + case "square": + socket.output.write(toString(toInt(cmd[1]) * toInt(cmd[1]))) ; break ; + case"add": + socket.output.write(toString(toInt(cmd[1]) + toInt(cmd[2]))) ; break ; + case "quit": + socket.output.write("Server Shut down") ; + quit = true ; break ; + default: error = true ; + } + } catch (Exception e) + error = true ; + if(error) socket.output.write("") ; + if(socket) socket.close ; + if(!quit) socket = server.accept ; + } + + if(socket) socket.close ; +} diff --git a/Task/Distributed-programming/D/distributed-programming-2.d b/Task/Distributed-programming/D/distributed-programming-2.d new file mode 100644 index 0000000000..303af1c933 --- /dev/null +++ b/Task/Distributed-programming/D/distributed-programming-2.d @@ -0,0 +1,24 @@ +module distributedclient ; +import tango.net.SocketConduit, tango.net.InternetAddress, + tango.text.Util, tango.io.Stdout ; + +void main(char[][] args) { + + if(args.length> 1) { + try { + auto Ip = new InternetAddress("localhost", 12345) ; + auto socket = new SocketConduit ; + socket.connect(Ip) ; + auto buffer = new char[socket.bufferSize] ; + + socket.output.write(join(args[1..$]," ")) ; + auto len = socket.input.read(buffer) ; + if(len > 0) Stdout(buffer[0..len]).newline ; + + if(socket) socket.close ; + } catch(Exception e) + Stdout(e.msg).newline ; + } else + Stdout("usage: supply argument as,\n\tquit\n" + "\tsquare \n\tadd ").newline ; +} diff --git a/Task/Distributed-programming/E/distributed-programming-1.e b/Task/Distributed-programming/E/distributed-programming-1.e new file mode 100644 index 0000000000..6dfd480e8e --- /dev/null +++ b/Task/Distributed-programming/E/distributed-programming-1.e @@ -0,0 +1,19 @@ +def storage := [].diverge() + +def logService { + to log(line :String) { + storage.push([timer.now(), line]) + } + to search(substring :String) { + var matches := [] + for [time, line] ? (line.startOf(substring) != -1) in storage { + matches with= [time, line] + } + return matches + } +} + +introducer.onTheAir() +def sturdyRef := makeSturdyRef.temp(logService) +println(.sturdyToURI(sturdyRef)) +interp.blockAtTop() diff --git a/Task/Distributed-programming/E/distributed-programming-2.e b/Task/Distributed-programming/E/distributed-programming-2.e new file mode 100644 index 0000000000..349ab4f280 --- /dev/null +++ b/Task/Distributed-programming/E/distributed-programming-2.e @@ -0,0 +1,14 @@ +def [uri] := interp.getArgs() +introducer.onTheAir() +def sturdyRef := .sturdyFromURI(uri) +def logService := sturdyRef.getRcvr() + +logService <- log("foot") +logService <- log("shoe") + +println("Searching...") +when (def result := logService <- search("foo")) -> { + for [time, line] in result { + println(`At $time: $line`) + } +} diff --git a/Task/Distributed-programming/Erlang/distributed-programming-1.erl b/Task/Distributed-programming/Erlang/distributed-programming-1.erl new file mode 100644 index 0000000000..69311e3ef1 --- /dev/null +++ b/Task/Distributed-programming/Erlang/distributed-programming-1.erl @@ -0,0 +1,19 @@ +-module(srv). +-export([start/0, wait/0]). + +start() -> + net_kernel:start([srv,shortnames]), + erlang:set_cookie(node(), rosetta), + Pid = spawn(srv,wait,[]), + register(srv,Pid), + io:fwrite("~p ready~n",[node(Pid)]), + ok. + +wait() -> + receive + {echo, Pid, Any} -> + io:fwrite("-> ~p from ~p~n", [Any, node(Pid)]), + Pid ! {hello, Any}, + wait(); + Any -> io:fwrite("Error ~p~n", [Any]) + end. diff --git a/Task/Distributed-programming/Erlang/distributed-programming-2.erl b/Task/Distributed-programming/Erlang/distributed-programming-2.erl new file mode 100644 index 0000000000..a631d88ce3 --- /dev/null +++ b/Task/Distributed-programming/Erlang/distributed-programming-2.erl @@ -0,0 +1,17 @@ +-module(client). +-export([start/0, wait/0]). + +start() -> + net_kernel:start([client,shortnames]), + erlang:set_cookie(node(), rosetta), + {ok,[[Srv]]} = init:get_argument(server), + io:fwrite("connecting to ~p~n", [Srv]), + {srv, list_to_atom(Srv)} ! {echo,self(), hi}, + wait(), + ok. + +wait() -> + receive + {hello, Any} -> io:fwrite("Received ~p~n", [Any]); + Any -> io:fwrite("Error ~p~n", [Any]) + end. diff --git a/Task/Distributed-programming/Go/distributed-programming-1.go b/Task/Distributed-programming/Go/distributed-programming-1.go new file mode 100644 index 0000000000..48b164c6e0 --- /dev/null +++ b/Task/Distributed-programming/Go/distributed-programming-1.go @@ -0,0 +1,30 @@ +package main + +import ( + "errors" + "log" + "net" + "net/http" + "net/rpc" +) + +type TaxComputer float64 + +func (taxRate TaxComputer) Tax(x float64, r *float64) error { + if x < 0 { + return errors.New("Negative values not allowed") + } + *r = x * float64(taxRate) + return nil +} + +func main() { + c := TaxComputer(.05) + rpc.Register(c) + rpc.HandleHTTP() + listener, err := net.Listen("tcp", ":1234") + if err != nil { + log.Fatal(err) + } + http.Serve(listener, nil) +} diff --git a/Task/Distributed-programming/Go/distributed-programming-2.go b/Task/Distributed-programming/Go/distributed-programming-2.go new file mode 100644 index 0000000000..e9ac3ecf65 --- /dev/null +++ b/Task/Distributed-programming/Go/distributed-programming-2.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "log" + "net/rpc" +) + +func main() { + client, err := rpc.DialHTTP("tcp", "localhost:1234") + if err != nil { + fmt.Println(err) + return + } + + amount := 3. + var tax float64 + err = client.Call("TaxComputer.Tax", amount, &tax) + if err != nil { + log.Fatal(err) + } + fmt.Printf("Tax on %.2f: %.2f\n", amount, tax) +} diff --git a/Task/Distributed-programming/JavaScript/distributed-programming-1.js b/Task/Distributed-programming/JavaScript/distributed-programming-1.js new file mode 100644 index 0000000000..6e5bb60713 --- /dev/null +++ b/Task/Distributed-programming/JavaScript/distributed-programming-1.js @@ -0,0 +1,8 @@ +var net = require('net') + +var server = net.createServer(function (c){ + c.write('hello\r\n') + c.pipe(c) // echo messages back +}) + +server.listen(3000, 'localhost') diff --git a/Task/Distributed-programming/JavaScript/distributed-programming-2.js b/Task/Distributed-programming/JavaScript/distributed-programming-2.js new file mode 100644 index 0000000000..9a9e4e182b --- /dev/null +++ b/Task/Distributed-programming/JavaScript/distributed-programming-2.js @@ -0,0 +1,12 @@ +var net = require('net') + +conn = net.createConnection(3000, '192.168.1.x') + +conn.on('connect', function(){ + console.log('connected') + conn.write('test') +}) + +conn.on('data', function(msg){ + console.log(msg.toString()) +}) diff --git a/Task/Distributed-programming/Perl/distributed-programming.pl b/Task/Distributed-programming/Perl/distributed-programming.pl new file mode 100644 index 0000000000..e6f5d96ffc --- /dev/null +++ b/Task/Distributed-programming/Perl/distributed-programming.pl @@ -0,0 +1,43 @@ +use Data::Dumper; +use IO::Socket::INET; +use Safe; + +sub get_data { + my $sock = new IO::Socket::INET + LocalHost => "localhost", + LocalPort => "10000", + Proto => "tcp", + Listen => 1, + Reuse => 1; + unless ($sock) { die "Socket creation failure" } + my $cli = $sock->accept(); + + # of course someone may be tempted to send you 'system("rm -rf /")', + # to be safe(r), use Safe:: + my $safe = new Safe; + my $x = $safe->reval(join("", <$cli>)); + close $cli; + close $sock; + return $x; +} + +sub send_data { + my $host = shift; + my $data = shift; + my $sock = new IO::Socket::INET + PeerAddr => "$host:10000", + Proto => "tcp", + Reuse => 1; + + unless ($sock) { die "Socket creation failure" } + + print $sock Data::Dumper->Dump([$data]); + close $sock; +} + +if (@ARGV) { + my $x = get_data(); + print "Got data\n", Data::Dumper->Dump([$x]); +} else { + send_data('some_host', { a=>100, b=>[1 .. 10] }); +} diff --git a/Task/Distributed-programming/PicoLisp/distributed-programming-1.l b/Task/Distributed-programming/PicoLisp/distributed-programming-1.l new file mode 100644 index 0000000000..0326e12e28 --- /dev/null +++ b/Task/Distributed-programming/PicoLisp/distributed-programming-1.l @@ -0,0 +1,9 @@ +(task (port 12321) # Background server task + (let? Sock (accept @) + (unless (fork) # Handle request in child process + (in Sock + (while (rd) # Handle requests + (out Sock + (pr (eval @)) ) ) ) # Evaluate and send reply + (bye) ) # Exit child process + (close Sock) ) ) # Close socket in parent process diff --git a/Task/Distributed-programming/PicoLisp/distributed-programming-2.l b/Task/Distributed-programming/PicoLisp/distributed-programming-2.l new file mode 100644 index 0000000000..f8a38bd75e --- /dev/null +++ b/Task/Distributed-programming/PicoLisp/distributed-programming-2.l @@ -0,0 +1,6 @@ +(let? Sock (connect "localhost" 12321) + (out Sock (pr '*Pid)) # Query PID from server + (println 'PID (in Sock (rd))) # Receive and print reply + (out Sock (pr '(* 3 4))) # Request some calculation + (println 'Result (in Sock (rd))) # Print result + (close Sock) ) # Close connection to server diff --git a/Task/Distributed-programming/Python/distributed-programming-1.py b/Task/Distributed-programming/Python/distributed-programming-1.py new file mode 100644 index 0000000000..3ee0a0e584 --- /dev/null +++ b/Task/Distributed-programming/Python/distributed-programming-1.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import SimpleXMLRPCServer + +class MyHandlerInstance: + def echo(self, data): + '''Method for returning data got from client''' + return 'Server responded: %s' % data + + def div(self, num1, num2): + '''Method for divide 2 numbers''' + return num1/num2 + +def foo_function(): + '''A function (not an instance method)''' + return True + +HOST = "localhost" +PORT = 8000 + +server = SimpleXMLRPCServer.SimpleXMLRPCServer((HOST, PORT)) + +# register built-in system.* functions. +server.register_introspection_functions() + +# register our instance +server.register_instance(MyHandlerInstance()) + +# register our function as well +server.register_function(foo_function) + +try: + # serve forever + server.serve_forever() +except KeyboardInterrupt: + print 'Exiting...' + server.server_close() diff --git a/Task/Distributed-programming/Python/distributed-programming-10.py b/Task/Distributed-programming/Python/distributed-programming-10.py new file mode 100644 index 0000000000..4669af78cd --- /dev/null +++ b/Task/Distributed-programming/Python/distributed-programming-10.py @@ -0,0 +1,12 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import spread + +PORT = '4803' + +conn = spread.connect(PORT) +conn.join('test') + +conn.multicast(spread.RELIABLE_MESS, 'test', 'hello, this is message sent from python') +conn.disconnect() diff --git a/Task/Distributed-programming/Python/distributed-programming-2.py b/Task/Distributed-programming/Python/distributed-programming-2.py new file mode 100644 index 0000000000..7455d08272 --- /dev/null +++ b/Task/Distributed-programming/Python/distributed-programming-2.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import xmlrpclib + +HOST = "localhost" +PORT = 8000 + +rpc = xmlrpclib.ServerProxy("http://%s:%d" % (HOST, PORT)) + +# print what functions does server support +print 'Server supports these functions:', +print ' '.join(rpc.system.listMethods()) + +# echo something +rpc.echo("We sent this data to server") + +# div numbers +print 'Server says: 8 / 4 is: %d' % rpc.div(8, 4) + +# control if foo_function returns True +if rpc.foo_function(): + print 'Server says: foo_function returned True' diff --git a/Task/Distributed-programming/Python/distributed-programming-3.py b/Task/Distributed-programming/Python/distributed-programming-3.py new file mode 100644 index 0000000000..a1d1aea1ad --- /dev/null +++ b/Task/Distributed-programming/Python/distributed-programming-3.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import BaseHTTPServer + +HOST = "localhost" +PORT = 8000 + +# we just want to write own class, we replace do_GET method. This could be extended, I just added basics +# see; http://docs.python.org/lib/module-BaseHTTPServer.html +class MyHTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler): + def do_GET(self): + # send 200 (OK) message + self.send_response(200) + # send header + self.send_header("Content-type", "text/html") + self.end_headers() + + # send context + self.wfile.write("Our Web Title") + self.wfile.write("

This is our body. You wanted to visit %s page

" % self.path) + self.wfile.write("") + +if __name__ == '__main__': + server = BaseHTTPServer.HTTPServer((HOST, PORT), MyHTTPHandler) + try: + server.serve_forever() + except KeyboardInterrupt: + print 'Exiting...' + server.server_close() diff --git a/Task/Distributed-programming/Python/distributed-programming-4.py b/Task/Distributed-programming/Python/distributed-programming-4.py new file mode 100644 index 0000000000..6d8f279611 --- /dev/null +++ b/Task/Distributed-programming/Python/distributed-programming-4.py @@ -0,0 +1,15 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import httplib + +HOST = "localhost" +PORT = 8000 + +conn = httplib.HTTPConnection(HOST, PORT) +conn.request("GET", "/somefile") + +response = conn.getresponse() +print 'Server Status: %d' % response.status + +print 'Server Message: %s' % response.read() diff --git a/Task/Distributed-programming/Python/distributed-programming-5.py b/Task/Distributed-programming/Python/distributed-programming-5.py new file mode 100644 index 0000000000..01b1e88b8d --- /dev/null +++ b/Task/Distributed-programming/Python/distributed-programming-5.py @@ -0,0 +1,57 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import SocketServer +import pickle + +HOST = "localhost" +PORT = 8000 + +class RPCServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): + # The object_to_proxy member should be set to the object we want + # methods called on. Unfortunately, we can't do this in the constructor + # because the constructor should not be overridden in TCPServer... + + daemon_threads = True + +class RPCHandler(SocketServer.StreamRequestHandler): + def handle(self): + in_channel = pickle.Unpickler(self.rfile) + out_channel = pickle.Pickler(self.wfile, protocol=2) + while True: + try: + name, args, kwargs = in_channel.load() + print 'got %s %s %s' % (name, args, kwargs) + except EOFError: + # EOF means we're done with this request. + # Catching this exception to detect EOF is a bit hackish, + # but will work for a quick demo like this + break + try: + method = getattr(self.server.object_to_proxy, name) + result = method(*args, **kwargs) + except Exception, e: + out_channel.dump(('Error',e)) + else: + out_channel.dump(('OK',result)) + +class MyHandlerInstance(object): + def echo(self, data): + '''Method for returning data got from client''' + return 'Server responded: %s' % data + + def div(self, dividend, divisor): + '''Method to divide 2 numbers''' + return dividend/divisor + + def is_computer_on(self): + return True + +if __name__ == '__main__': + rpcserver = RPCServer((HOST, PORT), RPCHandler) + rpcserver.object_to_proxy = MyHandlerInstance() + try: + rpcserver.serve_forever() + except KeyboardInterrupt: + print 'Exiting...' + rpcserver.server_close() diff --git a/Task/Distributed-programming/Python/distributed-programming-6.py b/Task/Distributed-programming/Python/distributed-programming-6.py new file mode 100644 index 0000000000..9a88a4c30f --- /dev/null +++ b/Task/Distributed-programming/Python/distributed-programming-6.py @@ -0,0 +1,55 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import socket +import pickle + +HOST = "localhost" +PORT = 8000 + +class RPCClient(object): + def __init__(self, host, port): + self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.socket.connect((host, port)) + self.rfile = self.socket.makefile('rb') + self.wfile = self.socket.makefile('wb') + self.in_channel = pickle.Unpickler(self.rfile) + self.out_channel = pickle.Pickler(self.wfile, protocol=2) + + def _close(self): + self.socket.close() + self.rfile.close() + self.wfile.close() + + # Make calling remote methods easy by overriding attribute access. + # Accessing any attribute on our instances will give a proxy method that + # calls the method with the same name on the remote machine. + def __getattr__(self, name): + def proxy(*args, **kwargs): + self.out_channel.dump((name, args, kwargs)) + self.wfile.flush() # to make sure the server won't wait forever + status, result = self.in_channel.load() + if status == 'OK': + return result + else: + raise result + + return proxy + +if __name__ == '__main__': + # connect to server and send data + rpcclient = RPCClient(HOST, PORT) + + print 'Testing the echo() method:' + print rpcclient.echo('Hello world!') + print + print 'Calculating 42/2 on the remote machine:' + print rpcclient.div(42, 2) + print + print 'is_computer_on on the remote machine returns:' + print rpcclient.is_computer_on() + print + print 'Testing keyword args:' + print '42/2 is:', rpcclient.div(divisor=2, dividend=42) + rpcclient._close() + del rpcclient diff --git a/Task/Distributed-programming/Python/distributed-programming-7.py b/Task/Distributed-programming/Python/distributed-programming-7.py new file mode 100644 index 0000000000..61b789f7c0 --- /dev/null +++ b/Task/Distributed-programming/Python/distributed-programming-7.py @@ -0,0 +1,26 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import Pyro.core +import Pyro.naming + +# create instance that will return upper case +class StringInstance(Pyro.core.ObjBase): + def makeUpper(self, data): + return data.upper() + +class MathInstance(Pyro.core.ObjBase): + def div(self, num1, num2): + return num1/num2 + +if __name__ == '__main__': + server = Pyro.core.Daemon() + name_server = Pyro.naming.NameServerLocator().getNS() + server.useNameServer(name_server) + server.connect(StringInstance(), 'string') + server.connect(MathInstance(), 'math') + try: + server.requestLoop() + except KeyboardInterrupt: + print 'Exiting...' + server.shutdown() diff --git a/Task/Distributed-programming/Python/distributed-programming-8.py b/Task/Distributed-programming/Python/distributed-programming-8.py new file mode 100644 index 0000000000..bbbbd7badf --- /dev/null +++ b/Task/Distributed-programming/Python/distributed-programming-8.py @@ -0,0 +1,17 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import Pyro.core + +DATA = "my name is eren" +NUM1 = 10 +NUM2 = 5 + +string = Pyro.core.getProxyForURI("PYRONAME://string") +math = Pyro.core.getProxyForURI("PYRONAME://math") + +print 'We sent: %s' % DATA +print 'Server responded: %s\n' % string.makeUpper(DATA) + +print 'We sent two numbers to divide: %d and %d' % (NUM1, NUM2) +print 'Server responded the result: %s' % math.div(NUM1, NUM2) diff --git a/Task/Distributed-programming/Python/distributed-programming-9.py b/Task/Distributed-programming/Python/distributed-programming-9.py new file mode 100644 index 0000000000..9b5b45347c --- /dev/null +++ b/Task/Distributed-programming/Python/distributed-programming-9.py @@ -0,0 +1,18 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import spread + +PORT = '4803' + +# connect spread daemon +conn = spread.connect(PORT) +# join the room +conn.join('test') + +print 'Waiting for messages... If you want to stop this script, please stop spread daemon' +while True: + recv = conn.receive() + if hasattr(recv, 'sender') and hasattr(recv, 'message'): + print 'Sender: %s' % recv.sender + print 'Message: %s' % recv.message diff --git a/Task/Distributed-programming/Ruby/distributed-programming-1.rb b/Task/Distributed-programming/Ruby/distributed-programming-1.rb new file mode 100644 index 0000000000..ffadd88ca2 --- /dev/null +++ b/Task/Distributed-programming/Ruby/distributed-programming-1.rb @@ -0,0 +1,21 @@ +require 'drb/drb' + +# The URI for the server to connect to +URI="druby://localhost:8787" + +class TimeServer + + def get_current_time + return Time.now + end + +end + +# The object that handles requests on the server +FRONT_OBJECT = TimeServer.new + +$SAFE = 1 # disable eval() and friends + +DRb.start_service(URI, FRONT_OBJECT) +# Wait for the drb server thread to finish before exiting. +DRb.thread.join diff --git a/Task/Distributed-programming/Ruby/distributed-programming-2.rb b/Task/Distributed-programming/Ruby/distributed-programming-2.rb new file mode 100644 index 0000000000..dac6f5a414 --- /dev/null +++ b/Task/Distributed-programming/Ruby/distributed-programming-2.rb @@ -0,0 +1,14 @@ +require 'drb/drb' + +# The URI to connect to +SERVER_URI = "druby://localhost:8787" + +# Start a local DRbServer to handle callbacks. +# +# Not necessary for this small example, but will be required +# as soon as we pass a non-marshallable object as an argument +# to a dRuby call. +DRb.start_service + +timeserver = DRbObject.new_with_uri(SERVER_URI) +puts timeserver.get_current_time diff --git a/Task/Distributed-programming/Tcl/distributed-programming-1.tcl b/Task/Distributed-programming/Tcl/distributed-programming-1.tcl new file mode 100644 index 0000000000..3717fbea45 --- /dev/null +++ b/Task/Distributed-programming/Tcl/distributed-programming-1.tcl @@ -0,0 +1,63 @@ +proc main {} { + global connections + set connections [dict create] + socket -server handleConnection 12345 + vwait dummyVar ;# enter the event loop +} + +proc handleConnection {channel clientaddr clientport} { + global connections + dict set connections $channel address "$clientaddr:$clientport" + fconfigure $channel -buffering line + fileevent $channel readable [list handleMessage $channel] +} + +proc handleMessage {channel} { + global connections + if {[gets $channel line] == -1} { + disconnect $channel + } else { + if {[string index [string trimleft $line] 0] eq "/"} { + set words [lassign [split [string trim $line]] command] + handleCommand $command $words $channel + } else { + echo $line $channel + } + } +} + +proc disconnect {channel} { + global connections + dict unset connections $channel + fileevent $channel readable "" + close $channel +} + +proc handleCommand {command words channel} { + global connections + switch -exact -- [string tolower $command] { + /nick { + dict set connections $channel nick [lindex $words 0] + } + /quit { + echo bye $channel + disconnect $channel + } + default { + puts $channel "\"$command\" not implemented" + } + } +} + +proc echo {message senderchannel} { + global connections + foreach channel [dict keys $connections] { + if {$channel ne $senderchannel} { + set time [clock format [clock seconds] -format "%T"] + set nick [dict get $connections $channel nick] + puts $channel [format "\[%s\] %s: %s" $time $nick $message] + } + } +} + +main diff --git a/Task/Distributed-programming/Tcl/distributed-programming-2.tcl b/Task/Distributed-programming/Tcl/distributed-programming-2.tcl new file mode 100644 index 0000000000..5bf55e92a5 --- /dev/null +++ b/Task/Distributed-programming/Tcl/distributed-programming-2.tcl @@ -0,0 +1,36 @@ +proc main {} { + global argv argc + if {$argc != 2} { + error "usage: [info script] serveraddress serverport" + } + connect {*}$argv + vwait dummyVar +} + +proc connect {addr port} { + global sock + set sock [socket $addr $port] + fconfigure $sock -buffering line + fileevent $sock readable getFromServer + fileevent stdin readable sendToServer +} + +proc getFromServer {} { + global sock + if {[gets $sock line] == -1} { + puts "disconnected..." + exit + } else { + puts $line + } +} + +proc sendToServer {} { + global sock + set msg [string trim [gets stdin]] + if {[string length $msg] > 0} { + puts $sock $msg + } +} + +main diff --git a/Task/Documentation/0DESCRIPTION b/Task/Documentation/0DESCRIPTION new file mode 100644 index 0000000000..662af89c57 --- /dev/null +++ b/Task/Documentation/0DESCRIPTION @@ -0,0 +1 @@ +Show how to insert documentation for classes, functions, and/or variables in your language. If this documentation is built-in to the language, note it. If this documentation requires external tools, note them. diff --git a/Task/Documentation/1META.yaml b/Task/Documentation/1META.yaml new file mode 100644 index 0000000000..0f04524f9d --- /dev/null +++ b/Task/Documentation/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Software Engineering diff --git a/Task/Documentation/Ada/documentation.ada b/Task/Documentation/Ada/documentation.ada new file mode 100644 index 0000000000..72b5fa5055 --- /dev/null +++ b/Task/Documentation/Ada/documentation.ada @@ -0,0 +1,25 @@ +with Ada.Text_Io; use Ada.Text_Io; + +generic + SortName : in String; + type DataType is (<>); + type SortArrayType is array (Integer range <>) of DataType; + with procedure Sort (SortArray : in out SortArrayType; + Comp, Write, Ex : in out Natural); + +package Instrument is + -- This generic package essentially accomplishes turning the sort + -- procedures into first-class functions for this limited purpose. + -- Obviously it doesn't change the way that Ada works with them; + -- the same thing would have been much more straightforward to + -- program in a language that had true first-class functions + + package Dur_Io is new Fixed_Io(Duration); + + procedure TimeSort (Arr : in out SortArrayType); + + procedure Put; + + procedure Put (File : in out File_Type); + +end Instrument; diff --git a/Task/Documentation/AutoHotkey/documentation.ahk b/Task/Documentation/AutoHotkey/documentation.ahk new file mode 100644 index 0000000000..6c90988ef9 --- /dev/null +++ b/Task/Documentation/AutoHotkey/documentation.ahk @@ -0,0 +1,17 @@ +; +; Function: example_add +; Description: +; Adds two or three numbers (see [url=http://en.wikipedia.org/Number]Number [/url]) +; Syntax: example_add(number1, number2[, number3=0]) +; Parameters: +; number1 - First number to add. +; number2 - Second number to add. +; number3 - (Optional) Third number to add. You can just omit this parameter. +; Return Value: +; sum of parameters +; Example: +; MsgBox % example_add(example_add(2, 3, 4), 5) +; +example_add(number1, number2, number3=0){ + return number1 + number2 + number3 +} diff --git a/Task/Documentation/C/documentation.c b/Task/Documentation/C/documentation.c new file mode 100644 index 0000000000..34b5dc8fc2 --- /dev/null +++ b/Task/Documentation/C/documentation.c @@ -0,0 +1,13 @@ +/** + * \brief Perform addition on \b a and \b b. + * + * \param int One of the numbers to be added. + * \param int Another number to be added. + * \return The sum of \b a and \b + * \code + * int sum = add(1, 2) + * \endcode + */ +int add(int a, int b) { + return a + b; +} diff --git a/Task/Documentation/Clojure/documentation.clj b/Task/Documentation/Clojure/documentation.clj new file mode 100644 index 0000000000..2ecbd4be4b --- /dev/null +++ b/Task/Documentation/Clojure/documentation.clj @@ -0,0 +1,7 @@ +(def + #^{:doc "Metadata can contain documentation and can be added to vars like this."} + test1) + +(defn test2 + "defn and some other macros allow you add documentation like this. Works the same way" + []) diff --git a/Task/Documentation/D/documentation.d b/Task/Documentation/D/documentation.d new file mode 100644 index 0000000000..e666a5ac8f --- /dev/null +++ b/Task/Documentation/D/documentation.d @@ -0,0 +1,29 @@ +/** + * This is a documentation comment for somefunc and somefunc2. + * Does not need to be preceded by '*' in every line - this is done purely for code style + * $(DDOC_COMMENT comment inside a documentation comment (results in a HTML comment not displayed by the browser)) + * Header: + * content (does not need to be tabbed out; this is done for clarity of the comments and has no effect on the + * resulting documentation) + * Params: + * arg1 = Something (listed as "int arg1 Something") + * arg2 = Something else + * Returns: + * Nothing + * TODO: + * Nothing at all + * BUGS: + * None found + */ +void somefunc(int arg1, int arg2) +{ +} +// this groups this function with the above (both have the same doc and are listed together) +/// ditto +void somefunc2(int arg1, int arg2) +{ +} +/++ Another documentation comment +/ +void main() +{ +} diff --git a/Task/Documentation/Delphi/documentation.delphi b/Task/Documentation/Delphi/documentation.delphi new file mode 100644 index 0000000000..378aa70e69 --- /dev/null +++ b/Task/Documentation/Delphi/documentation.delphi @@ -0,0 +1,10 @@ +type + /// Sample class. + TMyClass = class + public + /// Converts a string into a number. + /// String parameter + /// Numeric equivalent of aValue + /// aValue is not a valid integer. + function StringToNumber(aValue: string): Integer; + end; diff --git a/Task/Documentation/E/documentation.e b/Task/Documentation/E/documentation.e new file mode 100644 index 0000000000..9f1a470219 --- /dev/null +++ b/Task/Documentation/E/documentation.e @@ -0,0 +1,8 @@ +? /** This is an object with documentation */ +> def foo { +> # ... +> } +# value: + +? foo.__getAllegedType().getDocComment() +# value: " This is an object with documentation " diff --git a/Task/Documentation/Eiffel/documentation-1.e b/Task/Documentation/Eiffel/documentation-1.e new file mode 100644 index 0000000000..530006c119 --- /dev/null +++ b/Task/Documentation/Eiffel/documentation-1.e @@ -0,0 +1,88 @@ +note + description: "Objects that model Times of Day: 00:00:00 - 23:59:59" + author: "Eiffel Software Construction Students" + +class + TIME_OF_DAY +create + make + +feature -- Initialization + + make + -- Initialize to 00:00:00 + do + hour := 0 + minute := 0 + second := 0 + ensure + initialized: hour = 0 and + minute = 0 and + second = 0 + end + +feature -- Access + + hour: INTEGER + -- Hour expressed as 24-hour value + + minute: INTEGER + -- Minutes past the hour + + second: INTEGER + -- Seconds past the minute + +feature -- Element change + + set_hour (h: INTEGER) + -- Set the hour from `h' + require + argument_hour_valid: 0 <= h and h <= 23 + do + hour := h + ensure + hour_set: hour = h + minute_unchanged: minute = old minute + second_unchanged: second = old second + end + + set_minute (m: INTEGER) + -- Set the minute from `m' + require + argument_minute_valid: 0 <= m and m <= 59 + do + minute := m + ensure + minute_set: minute = m + hour_unchanged: hour = old hour + second_unchanged: second = old second + end + + set_second (s: INTEGER) + -- Set the second from `s' + require + argument_second_valid: 0 <= s and s <= 59 + do + second := s + ensure + second_set: second = s + hour_unchanged: hour = old hour + minute_unchanged: minute = old minute + end + +feature {NONE} -- Implementation + + protected_routine + -- A protected routine (not available to client classes) + -- Will not be present in documentation (Contract) view + do + + end + +invariant + + hour_valid: 0 <= hour and hour <= 23 + minute_valid: 0 <= minute and minute <= 59 + second_valid: 0 <= second and second <= 59 + +end -- class TIME_OF_DAY diff --git a/Task/Documentation/Eiffel/documentation-2.e b/Task/Documentation/Eiffel/documentation-2.e new file mode 100644 index 0000000000..0175748172 --- /dev/null +++ b/Task/Documentation/Eiffel/documentation-2.e @@ -0,0 +1,63 @@ +note + description: "Objects that model Times of Day: 00:00:00 - 23:59:59" + author: "Eiffel Software Construction Students" + +class interface + TIME_OF_DAY + +create + make + +feature -- Initialization + + make + -- Initialize to 00:00:00 + ensure + initialized: hour = 0 and minute = 0 and second = 0 + +feature -- Access + + hour: INTEGER_32 + -- Hour expressed as 24-hour value + + minute: INTEGER_32 + -- Minutes past the hour + + second: INTEGER_32 + -- Seconds past the minute + +feature -- Element change + + set_hour (h: INTEGER_32) + -- Set the hour from `h' + require + argument_hour_valid: 0 <= h and h <= 23 + ensure + hour_set: hour = h + minute_unchanged: minute = old minute + second_unchanged: second = old second + + set_minute (m: INTEGER_32) + -- Set the minute from `m' + require + argument_minute_valid: 0 <= m and m <= 59 + ensure + minute_set: minute = m + hour_unchanged: hour = old hour + second_unchanged: second = old second + + set_second (s: INTEGER_32) + -- Set the second from `s' + require + argument_second_valid: 0 <= s and s <= 59 + ensure + second_set: second = s + hour_unchanged: hour = old hour + minute_unchanged: minute = old minute + +invariant + hour_valid: 0 <= hour and hour <= 23 + minute_valid: 0 <= minute and minute <= 59 + second_valid: 0 <= second and second <= 59 + +end -- class TIME_OF_DAY diff --git a/Task/Documentation/Go/documentation.go b/Task/Documentation/Go/documentation.go new file mode 100644 index 0000000000..f6becb0a97 --- /dev/null +++ b/Task/Documentation/Go/documentation.go @@ -0,0 +1,25 @@ +// Example serves as an example but does nothing useful. +// +// A package comment preceeds the package clause and explains the purpose +// of the package. +package example + +// Exported variables. +var ( + // lookie + X, Y, Z int // popular names +) + +/* XP does nothing. + +Here's a block comment. */ +func XP() { // here we go! + // comments inside +} + +// Non-exported. +func nonXP() {} + +// Doc not extracted. + +var MEMEME int diff --git a/Task/Documentation/Haskell/documentation-1.hs b/Task/Documentation/Haskell/documentation-1.hs new file mode 100644 index 0000000000..2d6541820e --- /dev/null +++ b/Task/Documentation/Haskell/documentation-1.hs @@ -0,0 +1,26 @@ +-- |This is a documentation comment for the following function +square1 :: Int -> Int +square1 x = x * x + +-- |It can even +-- span multiple lines +square2 :: Int -> Int +square2 x = x * x + +square3 :: Int -> Int +-- ^You can put the comment underneath if you like, like this +square3 x = x * x + +{-| + Haskell block comments + are also supported +-} +square4 :: Int -> Int +square4 x = x * x + +-- |This is a documentation comment for the following datatype +data Tree a = Leaf a | Node [Tree a] + +-- |This is a documentation comment for the following type class +class Foo a where + bar :: a diff --git a/Task/Documentation/Haskell/documentation-2.hs b/Task/Documentation/Haskell/documentation-2.hs new file mode 100644 index 0000000000..0f12d4e6cb --- /dev/null +++ b/Task/Documentation/Haskell/documentation-2.hs @@ -0,0 +1,25 @@ +############################################################################ +# +# File: filename.icn +# +# Subject: Short Description +# +# Author: Author's name +# +# Date: Date +# +############################################################################ +# +# This file is in the public domain. (or other license) +# +############################################################################ +# +# Long form docmentation +# +############################################################################ +# +# Links: +# +############################################################################ + +procedure x1() #: short description of procedure diff --git a/Task/Documentation/Haskell/documentation-3.hs b/Task/Documentation/Haskell/documentation-3.hs new file mode 100644 index 0000000000..d4e3ab0035 --- /dev/null +++ b/Task/Documentation/Haskell/documentation-3.hs @@ -0,0 +1 @@ +XYZ diff --git a/Task/Documentation/Java/documentation.java b/Task/Documentation/Java/documentation.java new file mode 100644 index 0000000000..d2b17a40c9 --- /dev/null +++ b/Task/Documentation/Java/documentation.java @@ -0,0 +1,22 @@ +/** + * This is a class documentation comment. This text shows at the top of the page for this class + * @author Joe Schmoe + */ +public class Doc{ + /** + * This is a field comment for a variable + */ + private String field; + + /** + * This is a method comment. It has parameter tags (param), an exception tag (throws), + * and a return value tag (return). + * + * @param num a number with the variable name "num" + * @throws BadException when something bad happens + * @return another number + */ + public int method(long num) throws BadException{ + //...code here + } +} diff --git a/Task/Documentation/PicoLisp/documentation.l b/Task/Documentation/PicoLisp/documentation.l new file mode 100644 index 0000000000..53fff8d32d --- /dev/null +++ b/Task/Documentation/PicoLisp/documentation.l @@ -0,0 +1,5 @@ +: (doc 'car) # View documentation of a function + +: (doc '+Entity) # View documentation of a class + +: (doc '+ 'firefox) # Explicitly specify a browser diff --git a/Task/Documentation/Python/documentation-1.py b/Task/Documentation/Python/documentation-1.py new file mode 100644 index 0000000000..845224defa --- /dev/null +++ b/Task/Documentation/Python/documentation-1.py @@ -0,0 +1,8 @@ +class Doc(object): + """ + This is a class docstring. Traditionally triple-quoted strings are used because + they can span multiple lines and you can include quotation marks without escaping. + """ + def method(self, num): + """This is a method docstring.""" + pass diff --git a/Task/Documentation/Python/documentation-2.py b/Task/Documentation/Python/documentation-2.py new file mode 100644 index 0000000000..352b7bded2 --- /dev/null +++ b/Task/Documentation/Python/documentation-2.py @@ -0,0 +1,11 @@ +>>> def somefunction(): + "takes no args and returns None after doing not a lot" + + +>>> help(somefunction) +Help on function somefunction in module __main__: + +somefunction() + takes no args and returns None after doing not a lot + +>>> diff --git a/Task/Documentation/R/documentation-1.r b/Task/Documentation/R/documentation-1.r new file mode 100644 index 0000000000..9904db36f8 --- /dev/null +++ b/Task/Documentation/R/documentation-1.r @@ -0,0 +1 @@ +example(package.skeleton) diff --git a/Task/Documentation/R/documentation-2.r b/Task/Documentation/R/documentation-2.r new file mode 100644 index 0000000000..ef8b02331d --- /dev/null +++ b/Task/Documentation/R/documentation-2.r @@ -0,0 +1,59 @@ +\name{f} +\Rdversion{1.1} +\alias{f} +%- Also NEED an '\alias' for EACH other topic documented here. +\title{ +%% ~~function to do ... ~~ +} +\description{ +%% ~~ A concise (1-5 lines) description of what the function does. ~~ +} +\usage{ +f(x, y) +} +%- maybe also 'usage' for other objects documented here. +\arguments{ + \item{x}{ +%% ~~Describe \code{x} here~~ +} + \item{y}{ +%% ~~Describe \code{y} here~~ +} +} +\details{ +%% ~~ If necessary, more details than the description above ~~ +} +\value{ +%% ~Describe the value returned +%% If it is a LIST, use +%% \item{comp1 }{Description of 'comp1'} +%% \item{comp2 }{Description of 'comp2'} +%% ... +} +\references{ +%% ~put references to the literature/web site here ~ +} +\author{ +%% ~~who you are~~ +} +\note{ +%% ~~further notes~~ +} + +%% ~Make other sections like Warning with \section{Warning }{....} ~ + +\seealso{ +%% ~~objects to See Also as \code{\link{help}}, ~~~ +} +\examples{ +##---- Should be DIRECTLY executable !! ---- +##-- ==> Define data, use random, +##-- or do help(data=index) for the standard data sets. + +## The function is currently defined as +function(x,y) x+y +} +% Add one or more standard keywords, see file 'KEYWORDS' in the +% R documentation directory. +\keyword{ ~kwd1 } +\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line diff --git a/Task/Documentation/REXX/documentation.rexx b/Task/Documentation/REXX/documentation.rexx new file mode 100644 index 0000000000..289d39e386 --- /dev/null +++ b/Task/Documentation/REXX/documentation.rexx @@ -0,0 +1,36 @@ +/*REXX program to show how to display embedded documention in REXX code.*/ +parse arg doc +doc=space(doc) +if doc=='?' then call help /*show doc if arg is a single ? */ +/*════════════════════════regular═══════════════════════════════════════*/ +/*════════════════════════════════mainline══════════════════════════════*/ +/*═════════════════════════════════════════code═════════════════════════*/ +/*══════════════════════════════════════════════here.═══════════════════*/ +exit + +/*──────────────────────────────────HELP subroutine─────────────────────*/ +help: help=0; do j=1 for sourceline() + _=sourceline(j) + if _=='' then do; help=1; iterate; end + if _=='' then exit + if help then say _ + end /*j*/ +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────start of the in─line documentation. + +To use the YYYY program, enter: + + + YYYY numberOfItems + YYYY (with no args for the default) + YYYY ? (to see this documentation) + + +─── where: + +numberOfItems is the number of items to be processed. + +If no "numberOfItems" are entered, the default of 100 is used. + +────────────────────────────────────end of the in─line documentation. */ diff --git a/Task/Documentation/Racket/documentation.rkt b/Task/Documentation/Racket/documentation.rkt new file mode 100644 index 0000000000..d22f3f27cf --- /dev/null +++ b/Task/Documentation/Racket/documentation.rkt @@ -0,0 +1,7 @@ +#lang scribble/manual +(require (for-label "sandwiches.rkt")) + +@defproc[(make-sandwich [ingredients (listof ingredient?)]) + sandwich?]{ + Returns a sandwich given the right ingredients. +} diff --git a/Task/Documentation/Ruby/documentation.rb b/Task/Documentation/Ruby/documentation.rb new file mode 100644 index 0000000000..7661b0e9f9 --- /dev/null +++ b/Task/Documentation/Ruby/documentation.rb @@ -0,0 +1,35 @@ +=begin rdoc +RDoc is documented here[http://www.ruby-doc.org/core/classes/RDoc.html]. + +This is a class documentation comment. This text shows at the top of the page +for the class. + +Comments can be written inside "=begin rdoc"/"end" blocks or +in normal '#' comment blocks. + +There are no '@parameters' like javadoc, but 'name-value' lists can be written: +Author:: Joe Schmoe +Date:: today +=end + +class Doc + # This is a comment for a Constant + Constant = nil + + # This is a method comment. Parameters and return values can be named + # with the "call-seq" directive. + # + # call-seq: + # a_method(first_arg, second_arg) -> return_value + # + def a_method(arg1, arg2='default value') + do_stuff + end + + # Class methods will be shown in a separate section of the generated documentation. + def self.class_method + Constant + end +end + +# :include:boilerplate.txt diff --git a/Task/Documentation/Smalltalk/documentation.st b/Task/Documentation/Smalltalk/documentation.st new file mode 100644 index 0000000000..c9bd31146f --- /dev/null +++ b/Task/Documentation/Smalltalk/documentation.st @@ -0,0 +1 @@ +FooClass comment: 'This is a comment ....'. diff --git a/Task/Documentation/Tcl/documentation.tcl b/Task/Documentation/Tcl/documentation.tcl new file mode 100644 index 0000000000..2985d2345f --- /dev/null +++ b/Task/Documentation/Tcl/documentation.tcl @@ -0,0 +1,18 @@ +#****f* RosettaCode/TclDocDemo +# FUNCTION +# TclDocDemo is a simple illustration of how to do documentation +# of Tcl code using Robodoc. +# SYNOPSYS +# TclDocDemo foo bar +# INPUTS +# foo -- the first part of the message to print +# bar -- the last part of the message to print +# RESULT +# No result +# NOTES +# Prints a message based on a template by filling in with the +# supplied strings. +#***** +proc TclDocDemo {foo bar} { + puts [format "%s -- %s" $foo $bar] +} diff --git a/Task/Dot-product/0DESCRIPTION b/Task/Dot-product/0DESCRIPTION new file mode 100644 index 0000000000..1699af2558 --- /dev/null +++ b/Task/Dot-product/0DESCRIPTION @@ -0,0 +1,8 @@ +Create a function/use an in-built function, to compute the '''[[wp:Dot product|dot product]]''', also known as the '''scalar product''' of two vectors. If possible, make the vectors of arbitrary length. + +As an example, compute the dot product of the vectors [1, 3, -5] and [4, -2, -1]. + +If implementing the dot product of two vectors directly, each vector must be the same length; multiply corresponding terms from each vector then sum the results to produce the answer. + +;Reference: +* [[Vector products]] here on RC. diff --git a/Task/Dot-product/ABAP/dot-product.abap b/Task/Dot-product/ABAP/dot-product.abap new file mode 100644 index 0000000000..ad6873dc06 --- /dev/null +++ b/Task/Dot-product/ABAP/dot-product.abap @@ -0,0 +1,26 @@ +report zdot_product +data: lv_n type i, + lv_sum type i, + lt_a type standard table of i, + lt_b type standard table of i. + +append: '1' to lt_a, '3' to lt_a, '-5' to lt_a. +append: '4' to lt_b, '-2' to lt_b, '-1' to lt_b. +describe table lt_a lines lv_n. + +perform dot_product using lt_a lt_b lv_n changing lv_sum. + +write lv_sum left-justified. + +form dot_product using it_a like lt_a + it_b like lt_b + iv_n type i + changing + ev_sum type i. + field-symbols: type i, type i. + + do iv_n times. + read table: it_a assigning index sy-index, it_b assigning index sy-index. + lv_sum = lv_sum + ( * ). + enddo. +endform. diff --git a/Task/Dot-product/ACL2/dot-product.acl2 b/Task/Dot-product/ACL2/dot-product.acl2 new file mode 100644 index 0000000000..4eee7ccf60 --- /dev/null +++ b/Task/Dot-product/ACL2/dot-product.acl2 @@ -0,0 +1,5 @@ +(defun dotp (v u) + (if (or (endp v) (endp u)) + 0 + (+ (* (first v) (first u)) + (dotp (rest v) (rest u))))) diff --git a/Task/Dot-product/ALGOL-68/dot-product.alg b/Task/Dot-product/ALGOL-68/dot-product.alg new file mode 100644 index 0000000000..665dc4753b --- /dev/null +++ b/Task/Dot-product/ALGOL-68/dot-product.alg @@ -0,0 +1,38 @@ +MODE DOTFIELD = REAL; +MODE DOTVEC = [1:0]DOTFIELD; + +# The "Spread Sheet" way of doing a dot product: + o Assume bounds are equal, and start at 1 + o Ignore round off error +# +PRIO SSDOT = 7; +OP SSDOT = (DOTVEC a,b)DOTFIELD: ( + DOTFIELD sum := 0; + FOR i TO UPB a DO sum +:= a[i]*b[i] OD; + sum +); + +# An improved dot-product version: + o Handles sparse vectors + o Improves summation by gathering round off error + with no additional multiplication - or LONG - operations. +# +OP * = (DOTVEC a,b)DOTFIELD: ( + DOTFIELD sum := 0, round off error:= 0; + FOR i +# Assume bounds may not be equal, empty members are zero (sparse) # + FROM LWB (LWB a > LWB b | a | b ) + TO UPB (UPB a < UPB b | a | b ) + DO + DOTFIELD org = sum, prod = a[i]*b[i]; + sum +:= prod; + round off error +:= sum - org - prod + OD; + sum - round off error +); + +# Test: # +DOTVEC a=(1,3,-5), b=(4,-2,-1); + +print(("a SSDOT b = ",fixed(a SSDOT b,0,real width), new line)); +print(("a * b = ",fixed(a * b,0,real width), new line)) diff --git a/Task/Dot-product/ActionScript/dot-product.as b/Task/Dot-product/ActionScript/dot-product.as new file mode 100644 index 0000000000..89443c9d28 --- /dev/null +++ b/Task/Dot-product/ActionScript/dot-product.as @@ -0,0 +1,9 @@ +function dotProduct(v1:Vector., v2:Vector.):Number +{ + if(v1.length != v2.length) return NaN; + var sum:Number = 0; + for(var i:uint = 0; i < v1.length; i++) + sum += v1[i]*v2[i]; + return sum; +} +trace(dotProduct(Vector.([1,3,-5]),Vector.([4,-2,-1]))); diff --git a/Task/Dot-product/Ada/dot-product.ada b/Task/Dot-product/Ada/dot-product.ada new file mode 100644 index 0000000000..a63d87c748 --- /dev/null +++ b/Task/Dot-product/Ada/dot-product.ada @@ -0,0 +1,19 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure dot_product is + type vect is array(Positive range <>) of Integer; + v1 : vect := (1,3,-5); + v2 : vect := (4,-2,-1); + + function dotprod(a: vect; b: vect) return Integer is + sum : Integer := 0; + begin + if not (a'Length=b'Length) then raise Constraint_Error; end if; + for p in a'Range loop + sum := sum + a(p)*b(p); + end loop; + return sum; + end dotprod; + +begin +put_line(Integer'Image(dotprod(v1,v2))); +end dot_product; diff --git a/Task/Dot-product/AutoHotkey/dot-product.ahk b/Task/Dot-product/AutoHotkey/dot-product.ahk new file mode 100644 index 0000000000..94a6b43b52 --- /dev/null +++ b/Task/Dot-product/AutoHotkey/dot-product.ahk @@ -0,0 +1,17 @@ +Vet1 := "1,3,-5" +Vet2 := "4 , -2 , -1" +MsgBox % DotProduct( Vet1 , Vet2 ) + +;--------------------------- + +DotProduct( VectorA , VectorB ) +{ + Sum := 0 + StringSplit, ArrayA, VectorA, `,, %A_Space% + StringSplit, ArrayB, VectorB, `,, %A_Space% + If ( ArrayA0 <> ArrayB0 ) + Return ERROR + While ( A_Index <= ArrayA0 ) + Sum += ArrayA%A_Index% * ArrayB%A_Index% + Return Sum +} diff --git a/Task/Dot-product/BBC-BASIC/dot-product.bbc b/Task/Dot-product/BBC-BASIC/dot-product.bbc new file mode 100644 index 0000000000..8d71daf079 --- /dev/null +++ b/Task/Dot-product/BBC-BASIC/dot-product.bbc @@ -0,0 +1,7 @@ + DIM vec1(2), vec2(2), dot(0) + + vec1() = 1, 3, -5 + vec2() = 4, -2, -1 + + dot() = vec1() . vec2() + PRINT "Result is "; dot(0) diff --git a/Task/Dot-product/Bracmat/dot-product.bracmat b/Task/Dot-product/Bracmat/dot-product.bracmat new file mode 100644 index 0000000000..39c43cc14e --- /dev/null +++ b/Task/Dot-product/Bracmat/dot-product.bracmat @@ -0,0 +1,7 @@ + ( dot + = a A z Z + . !arg:(%?a ?z.%?A ?Z) + & !a*!A+dot$(!z.!Z) + | 0 + ) +& out$(dot$(1 3 -5.4 -2 -1)); diff --git a/Task/Dot-product/C++/dot-product.cpp b/Task/Dot-product/C++/dot-product.cpp new file mode 100644 index 0000000000..cb26a2e3a5 --- /dev/null +++ b/Task/Dot-product/C++/dot-product.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main() +{ + int a[] = { 1, 3, -5 }; + int b[] = { 4, -2, -1 }; + + std::cout << std::inner_product(a, a + sizeof(a) / sizeof(a[0]), b, 0) << std::endl; + + return 0; +} diff --git a/Task/Dot-product/C/dot-product.c b/Task/Dot-product/C/dot-product.c new file mode 100644 index 0000000000..4825c675e3 --- /dev/null +++ b/Task/Dot-product/C/dot-product.c @@ -0,0 +1,28 @@ +#include +#include + +int dot_product(int *, int *, size_t); + +int +main(void) +{ + int a[3] = {1, 3, -5}; + int b[3] = {4, -2, -1}; + + printf("%d\n", dot_product(a, b, sizeof(a) / sizeof(a[0]))); + + return EXIT_SUCCESS; +} + +int +dot_product(int *a, int *b, size_t n) +{ + int sum = 0; + size_t i; + + for (i = 0; i < n; i++) { + sum += a[i] * b[i]; + } + + return sum; +} diff --git a/Task/Dot-product/Clojure/dot-product.clj b/Task/Dot-product/Clojure/dot-product.clj new file mode 100644 index 0000000000..888b409395 --- /dev/null +++ b/Task/Dot-product/Clojure/dot-product.clj @@ -0,0 +1,6 @@ +(defn dot-product [& matrix] + {:pre [(apply == (map count matrix))]} + (apply + (apply map * matrix))) + +;Example Usage +(println (dot-product [1 3 -5] [4 -2 -1])) diff --git a/Task/Dot-product/CoffeeScript/dot-product.coffee b/Task/Dot-product/CoffeeScript/dot-product.coffee new file mode 100644 index 0000000000..d2e678b3ce --- /dev/null +++ b/Task/Dot-product/CoffeeScript/dot-product.coffee @@ -0,0 +1,13 @@ +dot_product = (ary1, ary2) -> + if ary1.length != ary2.length + throw "can't find dot product: arrays have different lengths" + dotprod = 0 + for v, i in ary1 + dotprod += v * ary2[i] + dotprod + +console.log dot_product([ 1, 3, -5 ], [ 4, -2, -1 ]) # 3 +try + console.log dot_product([ 1, 3, -5 ], [ 4, -2, -1, 0 ]) # exception +catch e + console.log e diff --git a/Task/Dot-product/Common-Lisp/dot-product-1.lisp b/Task/Dot-product/Common-Lisp/dot-product-1.lisp new file mode 100644 index 0000000000..cbdc252951 --- /dev/null +++ b/Task/Dot-product/Common-Lisp/dot-product-1.lisp @@ -0,0 +1,2 @@ +(defun dot-product (a b) + (apply #'+ (mapcar #'* (coerce a 'list) (coerce b 'list)))) diff --git a/Task/Dot-product/Common-Lisp/dot-product-2.lisp b/Task/Dot-product/Common-Lisp/dot-product-2.lisp new file mode 100644 index 0000000000..4a6979cbd8 --- /dev/null +++ b/Task/Dot-product/Common-Lisp/dot-product-2.lisp @@ -0,0 +1,2 @@ +(defun dot-prod (a b) + (reduce #'+ (map 'simple-vector #'* a b))) diff --git a/Task/Dot-product/D/dot-product-1.d b/Task/Dot-product/D/dot-product-1.d new file mode 100644 index 0000000000..84db9b88d5 --- /dev/null +++ b/Task/Dot-product/D/dot-product-1.d @@ -0,0 +1,5 @@ +import std.stdio, std.numeric; + +void main() { + writeln(dotProduct([1.0, 3.0, -5.0], [4.0, -2.0, -1.0])); +} diff --git a/Task/Dot-product/D/dot-product-2.d b/Task/Dot-product/D/dot-product-2.d new file mode 100644 index 0000000000..21fdaca6f9 --- /dev/null +++ b/Task/Dot-product/D/dot-product-2.d @@ -0,0 +1,9 @@ +import std.stdio, std.range, std.algorithm; + +void main() { + double[3] a = [1.0, 3.0, -5.0]; + double[3] b = [4.0, -2.0, -1.0]; + double[3] c; + c[] = a[] * b[]; + writeln(reduce!q{a + b}(c)); +} diff --git a/Task/Dot-product/DWScript/dot-product-1.dwscript b/Task/Dot-product/DWScript/dot-product-1.dwscript new file mode 100644 index 0000000000..07d2101167 --- /dev/null +++ b/Task/Dot-product/DWScript/dot-product-1.dwscript @@ -0,0 +1,12 @@ +function DotProduct(a, b : array of Float) : Float; +require + a.Length = b.Length; +var + i : Integer; +begin + Result := 0; + for i := 0 to a.High do + Result += a[i]*b[i]; +end; + +PrintLn(DotProduct([1,3,-5], [4,-2,-1])); diff --git a/Task/Dot-product/DWScript/dot-product-2.dwscript b/Task/Dot-product/DWScript/dot-product-2.dwscript new file mode 100644 index 0000000000..4a2230a966 --- /dev/null +++ b/Task/Dot-product/DWScript/dot-product-2.dwscript @@ -0,0 +1,4 @@ +var a := Vector(1, 3, -5, 0); +var b := Vector(4, -2, -1, 0); + +PrintLn(a * b); diff --git a/Task/Dot-product/Delphi/dot-product.delphi b/Task/Dot-product/Delphi/dot-product.delphi new file mode 100644 index 0000000000..868ac6c211 --- /dev/null +++ b/Task/Dot-product/Delphi/dot-product.delphi @@ -0,0 +1,27 @@ +program Project1; + +{$APPTYPE CONSOLE} + +type + doublearray = array of Double; + +function DotProduct(const A, B : doublearray): Double; +var +I: integer; +begin + assert (Length(A) = Length(B), 'Input arrays must be the same length'); + Result := 0; + for I := 0 to Length(A) - 1 do + Result := Result + (A[I] * B[I]); +end; + +var + x,y: doublearray; +begin + SetLength(x, 3); + SetLength(y, 3); + x[0] := 1; x[1] := 3; x[2] := -5; + y[0] := 4; y[1] :=-2; y[2] := -1; + WriteLn(DotProduct(x,y)); + ReadLn; +end. diff --git a/Task/Dot-product/Ela/dot-product.ela b/Task/Dot-product/Ela/dot-product.ela new file mode 100644 index 0000000000..367b387f0c --- /dev/null +++ b/Task/Dot-product/Ela/dot-product.ela @@ -0,0 +1,6 @@ +open list + +dotp a b | length a == length b = sum (zipWith (*) a b) + | else = fail "Vector sizes must match." + +dotp [1,3,-5] [4,-2,-1] diff --git a/Task/Dot-product/Erlang/dot-product.erl b/Task/Dot-product/Erlang/dot-product.erl new file mode 100644 index 0000000000..e8daf45ce2 --- /dev/null +++ b/Task/Dot-product/Erlang/dot-product.erl @@ -0,0 +1,7 @@ +dotProduct(A,B) when length(A) == length(B) -> dotProduct(A,B,0); +dotProduct(_,_) -> erlang:error('Vectors must have the same length.'). + +dotProduct([H1|T1],[H2|T2],P) -> dotProduct(T1,T2,P+H1*H2); +dotProduct([],[],P) -> P. + +dotProduct([1,3,-5],[4,-2,-1]). diff --git a/Task/Dot-product/Euphoria/dot-product-1.euphoria b/Task/Dot-product/Euphoria/dot-product-1.euphoria new file mode 100644 index 0000000000..a05d35cecb --- /dev/null +++ b/Task/Dot-product/Euphoria/dot-product-1.euphoria @@ -0,0 +1,11 @@ +function dotprod(sequence a, sequence b) + atom sum + a *= b + sum = 0 + for n = 1 to length(a) do + sum += a[n] + end for + return sum +end function + +? dotprod({1,3,-5},{4,-2,-1}) diff --git a/Task/Dot-product/Euphoria/dot-product-2.euphoria b/Task/Dot-product/Euphoria/dot-product-2.euphoria new file mode 100644 index 0000000000..b7ad8e77c9 --- /dev/null +++ b/Task/Dot-product/Euphoria/dot-product-2.euphoria @@ -0,0 +1,5 @@ +-- Here is an alternative method, +-- using the standard Euphoria Version 4+ Math Library +include std/math.e +sequence a = {1,3,-5}, b = {4,-2,-1} -- Make them any length you want +? sum(a * b) diff --git a/Task/Dot-product/Forth/dot-product.fth b/Task/Dot-product/Forth/dot-product.fth new file mode 100644 index 0000000000..120c9d47b3 --- /dev/null +++ b/Task/Dot-product/Forth/dot-product.fth @@ -0,0 +1,17 @@ +: vector create cells allot ; +: th cells + ; + +3 constant /vector +/vector vector a +/vector vector b + +: dotproduct ( a1 a2 -- n) + 0 tuck ?do -rot over i th @ over i th @ * >r rot r> + loop nip nip +; + +: vector! cells over + swap ?do i ! 1 cells +loop ; + +-5 3 1 a /vector vector! +-1 -2 4 b /vector vector! + +a b /vector dotproduct . 3 ok diff --git a/Task/Dot-product/Fortran/dot-product.f b/Task/Dot-product/Fortran/dot-product.f new file mode 100644 index 0000000000..09d9c4fcea --- /dev/null +++ b/Task/Dot-product/Fortran/dot-product.f @@ -0,0 +1,5 @@ +program test_dot_product + + write (*, '(i0)') dot_product ((/1, 3, -5/), (/4, -2, -1/)) + +end program test_dot_product diff --git a/Task/Dot-product/Go/dot-product.go b/Task/Dot-product/Go/dot-product.go new file mode 100644 index 0000000000..6a49539f4e --- /dev/null +++ b/Task/Dot-product/Go/dot-product.go @@ -0,0 +1,25 @@ +package main + +import ( + "errors" + "fmt" +) + +func dot(x, y []int) (r int, err error) { + if len(x) != len(y) { + return 0, errors.New("incompatible lengths") + } + for i := range x { + r += x[i] * y[i] + } + return +} + +func main() { + d, err := dot([]int{1, 3, -5}, []int{4, -2, -1}) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(d) +} diff --git a/Task/Dot-product/Haskell/dot-product.hs b/Task/Dot-product/Haskell/dot-product.hs new file mode 100644 index 0000000000..f5931bebef --- /dev/null +++ b/Task/Dot-product/Haskell/dot-product.hs @@ -0,0 +1,4 @@ +dotp a b | length a == length b = sum (zipWith (*) a b) + | otherwise = error "Vector sizes must match" + +main = print $ dotp [1, 3, -5] [4, -2, -1] -- prints 3 diff --git a/Task/Dot-product/Java/dot-product.java b/Task/Dot-product/Java/dot-product.java new file mode 100644 index 0000000000..ecbaf46d37 --- /dev/null +++ b/Task/Dot-product/Java/dot-product.java @@ -0,0 +1,20 @@ +public class DotProduct { + + public static void main(String[] args) { + double[] a = {1, 3, -5}; + double[] b = {4, -2, -1}; + + System.out.println(dotProd(a,b)); + } + + public static double dotProd(double[] a, double[] b){ + if(a.length != b.length){ + throw new IllegalArgumentException("The dimensions have to be equal!"); + } + double sum = 0; + for(int i = 0; i < a.length; i++){ + sum += a[i] * b[i]; + } + return sum; + } +} diff --git a/Task/Dot-product/JavaScript/dot-product.js b/Task/Dot-product/JavaScript/dot-product.js new file mode 100644 index 0000000000..355007b3d6 --- /dev/null +++ b/Task/Dot-product/JavaScript/dot-product.js @@ -0,0 +1,11 @@ +function dot_product(ary1, ary2) { + if (ary1.length != ary2.length) + throw "can't find dot product: arrays have different lengths"; + var dotprod = 0; + for (var i = 0; i < ary1.length; i++) + dotprod += ary1[i] * ary2[i]; + return dotprod; +} + +print(dot_product([1,3,-5],[4,-2,-1])); // ==> 3 +print(dot_product([1,3,-5],[4,-2,-1,0])); // ==> exception diff --git a/Task/Dot-product/Lua/dot-product.lua b/Task/Dot-product/Lua/dot-product.lua new file mode 100644 index 0000000000..5a2712f983 --- /dev/null +++ b/Task/Dot-product/Lua/dot-product.lua @@ -0,0 +1,9 @@ +function dotprod(a, b) + local ret = 0 + for i = 1, #a do + ret = ret + a[i] * b[i] + end + return ret +end + +print(dotprod({1, 3, -5}, {4, -2, 1})) diff --git a/Task/Dot-product/MATLAB/dot-product-1.m b/Task/Dot-product/MATLAB/dot-product-1.m new file mode 100644 index 0000000000..03bad175a4 --- /dev/null +++ b/Task/Dot-product/MATLAB/dot-product-1.m @@ -0,0 +1,3 @@ +A = [1 3 -5] +B = [4 -2 -1] +C = dot(A,B) diff --git a/Task/Dot-product/MATLAB/dot-product-2.m b/Task/Dot-product/MATLAB/dot-product-2.m new file mode 100644 index 0000000000..bf5469a19c --- /dev/null +++ b/Task/Dot-product/MATLAB/dot-product-2.m @@ -0,0 +1,3 @@ +function C = DotPro(A,B) + C = sum( A.*B ); +end diff --git a/Task/Dot-product/PHP/dot-product.php b/Task/Dot-product/PHP/dot-product.php new file mode 100644 index 0000000000..2545f22822 --- /dev/null +++ b/Task/Dot-product/PHP/dot-product.php @@ -0,0 +1,9 @@ + diff --git a/Task/Dot-product/Perl/dot-product.pl b/Task/Dot-product/Perl/dot-product.pl new file mode 100644 index 0000000000..23973338d3 --- /dev/null +++ b/Task/Dot-product/Perl/dot-product.pl @@ -0,0 +1,13 @@ +sub dotprod +{ + my($vec_a, $vec_b) = @_; + die "they must have the same size\n" unless @$vec_a == @$vec_b; + my $sum = 0; + $sum += $vec_a->[$_] * $vec_b->[$_] for 0..$#$vec_a; + return $sum; +} + +my @vec_a = (1,3,-5); +my @vec_b = (4,-2,-1); + +print dotprod(\@vec_a,\@vec_b), "\n"; # 3 diff --git a/Task/Dot-product/PicoLisp/dot-product.l b/Task/Dot-product/PicoLisp/dot-product.l new file mode 100644 index 0000000000..85be9204ad --- /dev/null +++ b/Task/Dot-product/PicoLisp/dot-product.l @@ -0,0 +1,4 @@ +(de dotProduct (A B) + (sum * A B) ) + +(dotProduct (1 3 -5) (4 -2 -1)) diff --git a/Task/Dot-product/Prolog/dot-product.pro b/Task/Dot-product/Prolog/dot-product.pro new file mode 100644 index 0000000000..2d9bef9a69 --- /dev/null +++ b/Task/Dot-product/Prolog/dot-product.pro @@ -0,0 +1,6 @@ +dot_product(L1, L2, N) :- + maplist(mult, L1, L2, P), + sumlist(P, N). + +mult(A,B,C) :- + C is A*B. diff --git a/Task/Dot-product/Python/dot-product.py b/Task/Dot-product/Python/dot-product.py new file mode 100644 index 0000000000..8ec49867ea --- /dev/null +++ b/Task/Dot-product/Python/dot-product.py @@ -0,0 +1,7 @@ +def dotp(a,b): + assert len(a) == len(b), 'Vector sizes must match' + return sum(aterm * bterm for aterm,bterm in zip(a, b)) + +if __name__ == '__main__': + a, b = [1, 3, -5], [4, -2, -1] + assert dotp(a,b) == 3 diff --git a/Task/Dot-product/R/dot-product.r b/Task/Dot-product/R/dot-product.r new file mode 100644 index 0000000000..2c86504928 --- /dev/null +++ b/Task/Dot-product/R/dot-product.r @@ -0,0 +1,16 @@ +x <- c(1, 3, -5) +y <- c(4, -2, -1) + +sum(x*y) # compute products, then do the sum +x %*% y # inner product + +# loop implementation +dotp <- function(x, y) { + n <- length(x) + if(length(y) != n) stop("invalid argument") + s <- 0 + for(i in 1:n) s <- s + x[i]*y[i] + s +} + +dotp(x, y) diff --git a/Task/Dot-product/REXX/dot-product.rexx b/Task/Dot-product/REXX/dot-product.rexx new file mode 100644 index 0000000000..8fe6608e94 --- /dev/null +++ b/Task/Dot-product/REXX/dot-product.rexx @@ -0,0 +1,32 @@ +/*REXX program computes the dot product of two equal size vectors. */ +vectorA = ' 1 3 -5 ' /*populate vectorA with numbers, */ +vectorB = ' 4 -2 -1 ' /* ∙∙∙ and the same for vectorB. */ +say /*display a blank line. */ +say 'vector A='vectorA /*echo the vectorA's values. */ +say 'vector B='vectorB /*echo the vectorB's values. */ +say /*display another blank line. */ +p = dotProd(vectorA, vectorB) /*go and compute the dot product.*/ +say 'dot product = ' p /*show and tell the dot product. */ +say /*display another a blank line. */ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────DOTPROD subroutine──────────────────*/ +dotProd: procedure; parse arg A,B /*compute the dot product. */ +sum = 0 /*initilize the sum to 0 (zero). */ +lenA = words(A) /*length of vector A in words. */ +lenB = words(B) /*length of vector B in words. */ + +if lenA\==lenB then do + say + say '*** error! ***' + say "vectors aren't the same size:" + say 'vectorA length='lenA + say 'vectorB length='lenB + say + exit 13 /*exit with return code 13. */ + end + + do j=1 for lenA /*multiply each number in vectors*/ + sum = sum + word(A,j) * word(B,j) /*∙∙∙ and add the product to SUM.*/ + end /*j*/ + +return sum /*return the SUM to the invoker. */ diff --git a/Task/Dot-product/Racket/dot-product.rkt b/Task/Dot-product/Racket/dot-product.rkt new file mode 100644 index 0000000000..68d36f236d --- /dev/null +++ b/Task/Dot-product/Racket/dot-product.rkt @@ -0,0 +1,7 @@ +#lang racket +(define (dot-product l r) (for/sum ([x l] [y r]) (* x y))) + +(dot-product '(1 3 -5) '(4 -2 -1)) + +;; dot-product works on sequences such as vectors: +(dot-product #(1 2 3) #(4 5 6)) diff --git a/Task/Dot-product/Ruby/dot-product-1.rb b/Task/Dot-product/Ruby/dot-product-1.rb new file mode 100644 index 0000000000..433ad2bd04 --- /dev/null +++ b/Task/Dot-product/Ruby/dot-product-1.rb @@ -0,0 +1,4 @@ +irb(main):001:0> require 'matrix' +=> true +irb(main):002:0> Vector[1, 3, -5].inner_product Vector[4, -2, -1] +=> 3 diff --git a/Task/Dot-product/Ruby/dot-product-2.rb b/Task/Dot-product/Ruby/dot-product-2.rb new file mode 100644 index 0000000000..1aae2d5db3 --- /dev/null +++ b/Task/Dot-product/Ruby/dot-product-2.rb @@ -0,0 +1,8 @@ +class Array + def dot_product(other) + raise "not the same size!" if self.length != other.length + self.zip(other).inject(0) {|dp, (a, b)| dp += a*b} + end +end + +p [1, 3, -5].dot_product [4, -2, -1] # => 3 diff --git a/Task/Dot-product/Sather/dot-product.sa b/Task/Dot-product/Sather/dot-product.sa new file mode 100644 index 0000000000..755f59aa0b --- /dev/null +++ b/Task/Dot-product/Sather/dot-product.sa @@ -0,0 +1,7 @@ +class MAIN is + main is + x ::= #VEC(|1.0, 3.0, -5.0|); + y ::= #VEC(|4.0, -2.0, -1.0|); + #OUT + x.dot(y) + "\n"; + end; +end; diff --git a/Task/Dot-product/Scala/dot-product.scala b/Task/Dot-product/Scala/dot-product.scala new file mode 100644 index 0000000000..28723cc556 --- /dev/null +++ b/Task/Dot-product/Scala/dot-product.scala @@ -0,0 +1,12 @@ +class Dot[T](v1: Seq[T])(implicit n: Numeric[T]) { + import n._ + def dot(v2: Seq[T]) = { + require(v1.length == v2.length) + v1 zip v2 map Function.tupled(_*_) sum + } +} + +implicit def toDot[T : Numeric](v1: Seq[T]) = new Dot(v1) +val v1 = List(1, 3, -5) +val v2 = List(4, -2, -1) +println(v1 dot v2) diff --git a/Task/Dot-product/Scheme/dot-product.ss b/Task/Dot-product/Scheme/dot-product.ss new file mode 100644 index 0000000000..6324059743 --- /dev/null +++ b/Task/Dot-product/Scheme/dot-product.ss @@ -0,0 +1,5 @@ +(define (dot-product a b) + (apply + (map * a b))) + +(display (dot-product '(1 3 -5) '(4 -2 -1))) +(newline) diff --git a/Task/Dot-product/Smalltalk/dot-product.st b/Task/Dot-product/Smalltalk/dot-product.st new file mode 100644 index 0000000000..b052b779d8 --- /dev/null +++ b/Task/Dot-product/Smalltalk/dot-product.st @@ -0,0 +1,12 @@ +Array extend +[ + * anotherArray [ + |acc| acc := 0. + self with: anotherArray collect: [ :a :b | + acc := acc + ( a * b ) + ]. + ^acc + ] +] + +( #(1 3 -5) * #(4 -2 -1 ) ) printNl. diff --git a/Task/Dot-product/Tcl/dot-product.tcl b/Task/Dot-product/Tcl/dot-product.tcl new file mode 100644 index 0000000000..4974c0b502 --- /dev/null +++ b/Task/Dot-product/Tcl/dot-product.tcl @@ -0,0 +1,7 @@ +package require math::linearalgebra + +set a {1 3 -5} +set b {4 -2 -1} +set dotp [::math::linearalgebra::dotproduct $a $b] +proc pp vec {return \[[join $vec ,]\]} +puts "[pp $a] \u2219 [pp $b] = $dotp" diff --git a/Task/Doubly-linked-list-Definition/0DESCRIPTION b/Task/Doubly-linked-list-Definition/0DESCRIPTION new file mode 100644 index 0000000000..f9618409be --- /dev/null +++ b/Task/Doubly-linked-list-Definition/0DESCRIPTION @@ -0,0 +1,7 @@ +Define the data structure for a complete Doubly Linked List. + +* The structure should support adding elements to the head, tail and middle of the list. +* The structure should not allow circular loops + +See also +[[Linked List]] diff --git a/Task/Doubly-linked-list-Definition/1META.yaml b/Task/Doubly-linked-list-Definition/1META.yaml new file mode 100644 index 0000000000..32d20151af --- /dev/null +++ b/Task/Doubly-linked-list-Definition/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Data Structures diff --git a/Task/Doubly-linked-list-Definition/ALGOL-68/doubly-linked-list-definition.alg b/Task/Doubly-linked-list-Definition/ALGOL-68/doubly-linked-list-definition.alg new file mode 100644 index 0000000000..5f240d5464 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/ALGOL-68/doubly-linked-list-definition.alg @@ -0,0 +1,113 @@ +MODE DATA = STRING; # user defined data type # + +MODE MNODE = STRUCT ( + NODE pred, + succ, + DATA value +); + +MODE LIST = REF MNODE; +MODE NODE = REF MNODE; + +STRUCT ( + PROC LIST new list, + PROC (LIST)BOOL is empty, + PROC (LIST)NODE get head, + get tail, + PROC (LIST, NODE)NODE add tail, + add head, + PROC (LIST)NODE remove head, + remove tail, + PROC (LIST, NODE, NODE)NODE insert after, + PROC (LIST, NODE)NODE remove node +) class list; + +new list OF class list := LIST: ( + HEAP MNODE master link; + master link := (master link, master link, ~); + master link +); + +is empty OF class list := (LIST self)BOOL: + (LIST(pred OF self) :=: LIST(self)) AND (LIST(self) :=: LIST(succ OF self)); + +get head OF class list := (LIST self)NODE: + succ OF self; + +get tail OF class list := (LIST self)NODE: + pred OF self; + +add tail OF class list := (LIST self, NODE node)NODE: + (insert after OF class list)(self, pred OF self, node); + +add head OF class list := (LIST self, NODE node)NODE: + (insert after OF class list)(self, succ OF self, node); + +remove head OF class list := (LIST self)NODE: + (remove node OF class list)(self, succ OF self); + +remove tail OF class list := (LIST self)NODE: + (remove node OF class list)(self, pred OF self); + +insert after OF class list := (LIST self, NODE cursor, NODE node)NODE: ( + succ OF node := succ OF cursor; + pred OF node := cursor; + succ OF cursor := node; + pred OF succ OF node := node; + node +); + +remove node OF class list := (LIST self, NODE node)NODE: ( + succ OF pred OF node := succ OF node; + pred OF succ OF node := pred OF node; + succ OF node := pred OF node := NIL; # garbage collection hint # + node +); + +main: ( + + []DATA sample = ("Was", "it", "a", "cat", "I", "saw"); + + LIST list a := new list OF class list; + + NODE tmp; + + IF list a :/=: REF LIST(NIL) THEN # technically "list a" is never NIL # +# Add some data to a list # + FOR i TO UPB sample DO + tmp := HEAP MNODE; + IF tmp :/=: NODE(NIL) THEN # technically "tmp" is never NIL # + value OF tmp := sample[i]; + (add tail OF class list)(list a, tmp) + FI + OD; + +# Iterate throught the list forward # + NODE node := (get head OF class list)(list a); + print("Iterate orward: "); + WHILE node :/=: NODE(list a) DO + print((value OF node, " ")); + node := succ OF node + OD; + print(new line); + +# Iterate throught the list backward # + node := (get tail OF class list)(list a); + print("Iterate backward: "); + WHILE node :/=: NODE(list a) DO + print((value OF node, " ")); + node := pred OF node + OD; + print(new line); + +# Finally empty the list # + print("Empty from tail: "); + WHILE NOT (is empty OF class list)(list a) DO + tmp := (remove tail OF class list)(list a); + print((value OF tmp, " ")) + # sweep heap # + OD; + print(new line) + # sweep heap # + FI +) diff --git a/Task/Doubly-linked-list-Definition/C-sharp/doubly-linked-list-definition.cs b/Task/Doubly-linked-list-Definition/C-sharp/doubly-linked-list-definition.cs new file mode 100644 index 0000000000..7cd302b307 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/C-sharp/doubly-linked-list-definition.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +namespace Doubly_Linked_List +{ + class Program + { + static void Main(string[] args) + { + LinkedList list = new LinkedList(); + list.AddFirst(".AddFirst() adds at the head."); + list.AddLast(".AddLast() adds at the tail."); + LinkedListNode head = list.Find(".AddFirst() adds at the head."); + list.AddAfter(head, ".AddAfter() adds after a specified node."); + LinkedListNode tail = list.Find(".AddLast() adds at the tail."); + list.AddBefore(tail, "Betcha can't guess what .AddBefore() does."); + + System.Console.WriteLine("Forward:"); + foreach (string nodeValue in list) { System.Console.WriteLine(nodeValue); } + + System.Console.WriteLine("\nBackward:"); + LinkedListNode current = tail; + while (current != null) + { + System.Console.WriteLine(current.Value); + current = current.Previous; + } + } + } +} + +/* Output: + Forward: + .AddFirst() adds at the head. + .AddAfter() adds after a specified node. + Betcha can't guess what .AddBefore() does. + .AddLast() adds at the tail. + + Backward: + .AddLast() adds at the tail. + Betcha can't guess what .AddBefore() does. + .AddAfter() adds after a specified node. + .AddFirst() adds at the head. +*/ diff --git a/Task/Doubly-linked-list-Definition/C/doubly-linked-list-definition-1.c b/Task/Doubly-linked-list-Definition/C/doubly-linked-list-definition-1.c new file mode 100644 index 0000000000..4c07c62ad9 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/C/doubly-linked-list-definition-1.c @@ -0,0 +1,157 @@ +/* double linked list */ +#include +#include + +struct List { + struct MNode *head; + struct MNode *tail; + struct MNode *tail_pred; +}; + +struct MNode { + struct MNode *succ; + struct MNode *pred; +}; + +typedef struct MNode *NODE; +typedef struct List *LIST; + +/* +** LIST l = newList() +** create (alloc space for) and initialize a list +*/ +LIST newList(void); + +/* +** int isEmpty(LIST l) +** test if a list is empty +*/ +int isEmpty(LIST); + +/* +** NODE n = getTail(LIST l) +** get the tail node of the list, without removing it +*/ +NODE getTail(LIST); + +/* +** NODE n = getHead(LIST l) +** get the head node of the list, without removing it +*/ +NODE getHead(LIST); + +/* +** NODE rn = addTail(LIST l, NODE n) +** add the node n to the tail of the list l, and return it (rn==n) +*/ +NODE addTail(LIST, NODE); + +/* +** NODE rn = addHead(LIST l, NODE n) +** add the node n to the head of the list l, and return it (rn==n) +*/ +NODE addHead(LIST, NODE); + +/* +** NODE n = remHead(LIST l) +** remove the head node of the list and return it +*/ +NODE remHead(LIST); + +/* +** NODE n = remTail(LIST l) +** remove the tail node of the list and return it +*/ +NODE remTail(LIST); + +/* +** NODE rn = insertAfter(LIST l, NODE r, NODE n) +** insert the node n after the node r, in the list l; return n (rn==n) +*/ +NODE insertAfter(LIST, NODE, NODE); + +/* +** NODE rn = removeNode(LIST l, NODE n) +** remove the node n (that must be in the list l) from the list and return it (rn==n) +*/ +NODE removeNode(LIST, NODE); + + +LIST newList(void) +{ + LIST tl = malloc(sizeof(struct List)); + if ( tl != NULL ) + { + tl->tail_pred = (NODE)&tl->head; + tl->tail = NULL; + tl->head = (NODE)&tl->tail; + return tl; + } + return NULL; +} + +int isEmpty(LIST l) +{ + return (l->head->succ == 0); +} + +NODE getHead(LIST l) +{ + return l->head; +} + +NODE getTail(LIST l) +{ + return l->tail_pred; +} + + +NODE addTail(LIST l, NODE n) +{ + n->succ = (NODE)&l->tail; + n->pred = l->tail_pred; + l->tail_pred->succ = n; + l->tail_pred = n; + return n; +} + +NODE addHead(LIST l, NODE n) +{ + n->succ = l->head; + n->pred = (NODE)&l->head; + l->head->pred = n; + l->head = n; + return n; +} + +NODE remHead(LIST l) +{ + NODE h; + h = l->head; + l->head = l->head->succ; + l->head->pred = (NODE)&l->head; + return h; +} + +NODE remTail(LIST l) +{ + NODE t; + t = l->tail_pred; + l->tail_pred = l->tail_pred->pred; + l->tail_pred->succ = (NODE)&l->tail; + return t; +} + +NODE insertAfter(LIST l, NODE r, NODE n) +{ + n->pred = r; n->succ = r->succ; + n->succ->pred = n; r->succ = n; + return n; +} + +NODE removeNode(LIST l, NODE n) +{ + n->pred->succ = n->succ; + n->succ->pred = n->pred; + return n; +} diff --git a/Task/Doubly-linked-list-Definition/C/doubly-linked-list-definition-2.c b/Task/Doubly-linked-list-Definition/C/doubly-linked-list-definition-2.c new file mode 100644 index 0000000000..88716cc54d --- /dev/null +++ b/Task/Doubly-linked-list-Definition/C/doubly-linked-list-definition-2.c @@ -0,0 +1,35 @@ +/* basic test */ + +struct IntNode { + struct MNode node; + int data; +}; + +int main() +{ + int i; + LIST lista; + struct IntNode *m; + NODE n; + + lista = newList(); + if ( lista != NULL ) + { + for(i=0; i < 5; i++) + { + m = malloc(sizeof(struct IntNode)); + if ( m != NULL ) + { + m->data = rand()%64; + addTail(lista, (NODE)m); + } + } + while( !isEmpty(lista) ) + { + m = (struct IntNode *)remTail(lista); + printf("%d\n", m->data); + free(m); + } + free(lista); + } +} diff --git a/Task/Doubly-linked-list-Definition/Clojure/doubly-linked-list-definition-1.clj b/Task/Doubly-linked-list-Definition/Clojure/doubly-linked-list-definition-1.clj new file mode 100644 index 0000000000..dfd8fb30cc --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Clojure/doubly-linked-list-definition-1.clj @@ -0,0 +1,111 @@ +(ns double-list) + +(defprotocol PDoubleList + (get-head [this]) + (add-head [this x]) + (get-tail [this]) + (add-tail [this x]) + (remove-node [this node]) + (add-before [this node x]) + (add-after [this node x]) + (get-nth [this n])) + +(defrecord Node [prev next data]) + +(defn make-node + "Create an internal or finalized node" + ([prev next data] (Node. prev next data)) + ([m key] (when-let [node (get m key)] + (assoc node :m m :key key)))) + +(defn get-next [node] (make-node (:m node) (:next node))) +(defn get-prev [node] (make-node (:m node) (:prev node))) + +(defn- seq* [m start next] + (seq + (for [x (iterate #(get m (next %)) (get m start)) + :while x] + (:data x)))) + +(defmacro when-> + ([x pred form] `(let [x# ~x] (if ~pred (-> x# ~form) x#))) + ([x pred form & more] `(when-> (when-> ~x ~pred ~form) ~@more))) + +(declare get-nth-key) + +(deftype DoubleList [m head tail] + Object + (equals [this x] + (and (instance? DoubleList x) + (= m (.m ^DoubleList x)))) + (hashCode [this] (hash (or this ()))) + clojure.lang.Sequential + clojure.lang.Counted + (count [_] (count m)) + clojure.lang.Seqable + (seq [_] (seq* m head :next)) + clojure.lang.Reversible + (rseq [_] (seq* m tail :prev)) + clojure.lang.IPersistentCollection + (empty [_] (DoubleList. (empty m) nil nil)) + (equiv [this x] + (and (sequential? x) + (= (seq x) (seq this)))) + (cons [this x] (.add-tail this x)) + PDoubleList + (get-head [_] (make-node m head)) + (add-head [this x] + (let [new-key (Object.) + m (when-> (assoc m new-key (make-node nil head x)) + head (assoc-in [head :prev] new-key)) + tail (if tail tail new-key)] + (DoubleList. m new-key tail))) + (get-tail [_] (make-node m tail)) + (add-tail [this x] + (if-let [tail (.get-tail this)] + (.add-after this tail x) + (.add-head this x))) + (remove-node [this node] + (if (get m (:key node)) + (let [{:keys [prev next key]} node + head (if prev head next) + tail (if next tail prev) + m (when-> (dissoc m key) + prev (assoc-in [prev :next] next) + next (assoc-in [next :prev] prev))] + (DoubleList. m head tail)) + this)) + (add-after [this node x] + (if (get m (:key node)) + (let [{:keys [prev next key]} node + new-key (Object.) + m (when-> (-> (assoc m new-key (make-node key next x)) + (assoc-in , [key :next] new-key)) + next (assoc-in [next :prev] new-key)) + tail (if next tail new-key)] + (DoubleList. m head tail)) + this)) + (add-before [this node x] + (if (:prev node) + (.add-after this (get-prev node) x) + (.add-head this x))) + (get-nth [this n] (make-node m (get-nth-key this n)))) + +(defn get-nth-key [^DoubleList this n] + (if (< -1 n (.count this)) + (let [[start next n] (if (< n (/ (.count this) 2)) + [(.head this) :next n] + [(.tail this) :prev (- (.count this) n 1)])] + (nth (iterate #(get-in (.m this) [% next]) start) n)) + (throw (IndexOutOfBoundsException.)))) + +(defn double-list + ([] (DoubleList. nil nil nil)) + ([coll] (into (double-list) coll))) + +(defmethod print-method DoubleList [dl w] + (print-method (interpose '<-> (seq dl)) w)) + +(defmethod print-method Node [n w] + (print-method (symbol "#:double_list.Node") w) + (print-method (into {} (dissoc n :m)) w)) diff --git a/Task/Doubly-linked-list-Definition/Clojure/doubly-linked-list-definition-2.clj b/Task/Doubly-linked-list-Definition/Clojure/doubly-linked-list-definition-2.clj new file mode 100644 index 0000000000..16b5015b2c --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Clojure/doubly-linked-list-definition-2.clj @@ -0,0 +1,22 @@ +(use 'double-list) +;=> nil +(def dl (double-list (range 10))) +;=> #'user/dl +dl +;=> (0 <-> 1 <-> 2 <-> 3 <-> 4 <-> 5 <-> 6 <-> 7 <-> 8 <-> 9) +(remove-node dl (get-tail dl)) +;=> (0 <-> 1 <-> 2 <-> 3 <-> 4 <-> 5 <-> 6 <-> 7 <-> 8) +dl +;=> (0 <-> 1 <-> 2 <-> 3 <-> 4 <-> 5 <-> 6 <-> 7 <-> 8 <-> 9) +((juxt seq rseq) dl) +;=> [(0 1 2 3 4 5 6 7 8 9) (9 8 7 6 5 4 3 2 1 0)] +(remove-node dl (get-nth dl 5)) +;=> (0 <-> 1 <-> 2 <-> 3 <-> 4 <-> 6 <-> 7 <-> 8 <-> 9) +(add-after *1 (get-nth *1 4) 10) +;=> (0 <-> 1 <-> 2 <-> 3 <-> 4 <-> 10 <-> 6 <-> 7 <-> 8 <-> 9) +(get-head *1) +;=> #:double_list.Node{:prev nil, :next #, :data 0, :key } +(get-next *1) +;=> #:double_list.Node{:prev #, :next #, :data 1, :key #} +(get-prev *1) +;=> #:double_list.Node{:prev #, :next #, :data 1, :key #} diff --git a/Task/Doubly-linked-list-Definition/Common-Lisp/doubly-linked-list-definition-1.lisp b/Task/Doubly-linked-list-Definition/Common-Lisp/doubly-linked-list-definition-1.lisp new file mode 100644 index 0000000000..c13b857a55 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Common-Lisp/doubly-linked-list-definition-1.lisp @@ -0,0 +1,48 @@ +(defstruct dlist head tail) +(defstruct dlink content prev next) + +(defun insert-between (dlist before after data) + "Insert a fresh link containing DATA after existing link BEFORE if not nil and before existing link AFTER if not nil" + (let ((new-link (make-dlink :content data :prev before :next after))) + (if (null before) + (setf (dlist-head dlist) new-link) + (setf (dlink-next before) new-link)) + (if (null after) + (setf (dlist-tail dlist) new-link) + (setf (dlink-prev after) new-link)) + new-link)) + +(defun insert-before (dlist dlink data) + "Insert a fresh link containing DATA before existing link DLINK" + (insert-between dlist (dlink-prev dlink) dlink data)) + +(defun insert-after (dlist dlink data) + "Insert a fresh link containing DATA after existing link DLINK" + (insert-between dlist dlink (dlink-next dlink) data)) + +(defun insert-head (dlist data) + "Insert a fresh link containing DATA at the head of DLIST" + (insert-between dlist nil (dlist-head dlist) data)) + +(defun insert-tail (dlist data) + "Insert a fresh link containing DATA at the tail of DLIST" + (insert-between dlist (dlist-tail dlist) nil data)) + +(defun remove-link (dlist dlink) + "Remove link DLINK from DLIST and return its content" + (let ((before (dlink-prev dlink)) + (after (dlink-next dlink))) + (if (null before) + (setf (dlist-head dlist) after) + (setf (dlink-next before) after)) + (if (null after) + (setf (dlist-tail dlist) before) + (setf (dlink-prev after) before)))) + +(defun dlist-elements (dlist) + "Returns the elements of DLIST as a list" + (labels ((extract-values (dlink acc) + (if (null dlink) + acc + (extract-values (dlink-next dlink) (cons (dlink-content dlink) acc))))) + (reverse (extract-values (dlist-head dlist) nil)))) diff --git a/Task/Doubly-linked-list-Definition/Common-Lisp/doubly-linked-list-definition-2.lisp b/Task/Doubly-linked-list-Definition/Common-Lisp/doubly-linked-list-definition-2.lisp new file mode 100644 index 0000000000..4ede6f9bee --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Common-Lisp/doubly-linked-list-definition-2.lisp @@ -0,0 +1,8 @@ +(let ((dlist (make-dlist))) + (insert-head dlist 1) + (insert-tail dlist 4) + (insert-after dlist (dlist-head dlist) 2) + (let* ((next-to-last (insert-before dlist (dlist-tail dlist) 3)) + (bad-link (insert-before dlist next-to-last 42))) + (remove-link dlist bad-link)) + (print (dlist-elements dlist))) diff --git a/Task/Doubly-linked-list-Definition/D/doubly-linked-list-definition.d b/Task/Doubly-linked-list-Definition/D/doubly-linked-list-definition.d new file mode 100644 index 0000000000..6b3ade3663 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/D/doubly-linked-list-definition.d @@ -0,0 +1,106 @@ +class LinkedList(T) +{ + Node!(T) head, tail; + + /** Iterate in the forward direction. */ + int opApply (int delegate(uint, Node!(T)) dg) + { + uint i = 0; + auto link = head; + int result = 0; + while (link) + { + result = dg (i, link); + if (result) return result; + i++; + link = link.next; + } + return result; + } + + static LinkedList!(T) fromArray (T[] array) + { + Node!(T) link = null; + auto head = link; + auto self = new LinkedList!(T); + foreach (elem; array) + { + link = new Node!(T)(null, link, elem, self); + if (!head) + head = link; + } + return self; + } +} + +class Node(T) +{ + Node!(T) next; + Node!(T) previous; + LinkedList!(T) parent; + T value; + + this (Node!(T) next, Node!(T) previous, T value, LinkedList!(T) parent) + in + { + assert (parent !is null); + } + body + { + this.next = next; + if (next) + next.previous = this; + if (previous) + previous.next = this; + this.previous = previous; + this.value = value; + this.parent = parent; + + if (parent.head == next) + parent.head = this; + if (parent.tail == previous) + parent.tail = this; + } + + /** Insert an element after this one. */ + void insertAfter (T value) + { + new Node!(T)(this, next, value, parent); + } + + /** Insert an element before this one. */ + void insertBefore (T value) + { + new Node!(T)(previous, this, value, parent); + } + + /** Remove the current node from the list. */ + void remove () + { + if (next) + next.previous = previous; + if (previous) + previous.next = next; + if (parent.tail == this) + parent.tail = previous; + if (parent.head == this) + parent.head = next; + } +} + +void main () +{ + char[][] sample = ["was", "it", "a", "cat", "I", "saw"]; + auto list = LinkedList!(char[]).fromArray (sample); + for (auto elem = list.head; elem; elem = elem.next) + { + writef ("%s ", elem.value); + if (elem.value == "it") elem.insertAfter("really"); + } + writeln; + for (auto elem = list.tail; elem; elem = elem.previous) + { + writef ("%s ", elem.value); + } + writeln; +} diff --git a/Task/Doubly-linked-list-Definition/E/doubly-linked-list-definition-1.e b/Task/Doubly-linked-list-Definition/E/doubly-linked-list-definition-1.e new file mode 100644 index 0000000000..187f3a532c --- /dev/null +++ b/Task/Doubly-linked-list-Definition/E/doubly-linked-list-definition-1.e @@ -0,0 +1,107 @@ +def makeDLList() { + def firstINode + def lastINode + + def makeNode(var value, var prevI, var nextI) { + # To meet the requirement that the client cannot create a loop, the + # inter-node refs are protected: clients only get the external facet + # with invariant-preserving operations. + def iNode + + def node { # external facet + + to get() { return value } + to put(new) { value := new } + + /** Return the value of the element of the list at the specified offset + from this element. */ + to get(index :int) { + if (index > 0 && node.hasNext()) { + return nextI.node().get(index - 1) + } else if (index < 0 && node.hasPrev()) { + return prevI.node().get(index + 1) + } else if (index <=> 0) { + return value + } else { + throw("index out of range in dlList") + } + } + to hasPrev() { + return prevI != firstINode && prevI != null + } + to prev() { + if (!node.hasPrev()) { + throw("there is no previous node") + } + return prevI.node() + } + to hasNext() { + return nextI != lastINode && nextI != null + } + to next() { + if (!node.hasNext()) { + throw("there is no next node") + } + return nextI.node() + } + to remove() { + if (prevI == null || nextI == null) { return } + prevI.setNextI(nextI) + nextI.setPrevI(prevI) + prevI := null + nextI := null + } + to insertAfter(newValue) { + def newI := makeNode(newValue, iNode, nextI) + nextI.setPrevI(newI) + nextI := newI + } + to insertBefore(newValue) { + prevI.node().insertAfter(newValue) + } + } + + bind iNode { # internal facet + to node() { return node } + to nextI() { return nextI } + to prevI() { return prevI } + to setNextI(new) { nextI := new } + to setPrevI(new) { prevI := new } + } + + return iNode + } # end makeNode + + bind firstINode := makeNode(null, Ref.broken("no first prev"), lastINode) + bind lastINode := makeNode(null, firstINode, Ref.broken("no last next")) + + def dlList { + to __printOn(out) { + out.print("<") + var sep := "" + for x in dlList { + out.print(sep) + out.quote(x) + sep := ", " + } + out.print(">") + } + to iterate(f) { + var n := firstINode + while (n.node().hasNext()) { + n := n.nextI() + f(n.node(), n.node()[]) + } + } + to atFirst() { return firstINode.nextI().node() } + to atLast() { return lastINode.prevI().node() } + to insertFirst(new) { return firstINode.node().insertAfter(new) } + to push(new) { return lastINode.node().insertBefore(new) } + + /** Return the node which has the specified value */ + to nodeOf(value) { + for node => v ? (v == value) in dlList { return node } + } + } + return dlList +} diff --git a/Task/Doubly-linked-list-Definition/E/doubly-linked-list-definition-2.e b/Task/Doubly-linked-list-Definition/E/doubly-linked-list-definition-2.e new file mode 100644 index 0000000000..e800128abe --- /dev/null +++ b/Task/Doubly-linked-list-Definition/E/doubly-linked-list-definition-2.e @@ -0,0 +1,31 @@ +? def list := makeDLList() +# value: <> + +? list.push(1) +? list +# value: <1> + +? list.push(10) +? list.push(100) +? list +# value: <1, 10, 100> + +? list.atFirst().insertAfter(5) +? list +# value: <1, 5, 10, 100> + +? list.insertFirst(0) +? list +# value: <0, 1, 5, 10, 100> + +? list.atLast().prev().remove() +? list +# value: <0, 1, 5, 100> + +? list.atLast()[] := 10 +? list +# value: <0, 1, 5, 10> + +? for x in 11..20 { list.push(x) } +? list +# value: <0, 1, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20> diff --git a/Task/Doubly-linked-list-Definition/Fortran/doubly-linked-list-definition.f b/Task/Doubly-linked-list-Definition/Fortran/doubly-linked-list-definition.f new file mode 100644 index 0000000000..24372d7221 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Fortran/doubly-linked-list-definition.f @@ -0,0 +1,207 @@ +module dlist + implicit none + type node + type(node), pointer :: next => null() + type(node), pointer :: prev => null() + integer :: data + end type node + + type dll + type(node), pointer :: head => null() + type(node), pointer :: tail => null() + integer :: num_nodes = 0 + end type dll + + public :: node, dll, append, prepend, insert, dump, reverse_dump, tidy + private :: init + +contains + ! Create a new doubly-linked list + elemental type(dll) function new_dll() + new_dll = dll(null(),null(),0) + return + end function new_dll + + ! Append an element to the end of the list + elemental subroutine append(dl2, value) + type(dll), intent(inout) :: dl2 + integer, intent(in) :: value + + type(node), pointer :: np + + ! If the list is empty + if (dl2%num_nodes == 0) then + call init(dl2, value) + return + end if + + ! Add new element to the end + dl2%num_nodes = dl2%num_nodes + 1 + np => dl2%tail + allocate(dl2%tail) + dl2%tail%data = value + dl2%tail%prev => np + dl2%tail%prev%next => dl2%tail + end subroutine append + + ! Prepend an element to the beginning of the list + elemental subroutine prepend(dl2, value) + type(dll), intent(inout) :: dl2 + integer, intent(in) :: value + + type(node), pointer :: np + + if (dl2%num_nodes == 0) then + call init(dl2, value) + return + end if + + dl2%num_nodes = dl2%num_nodes + 1 + np => dl2%head + allocate(dl2%head) + dl2%head%data = value + dl2%head%next => np + dl2%head%next%prev => dl2%head + end subroutine prepend + + ! Insert immediately before the given index + elemental subroutine insert(dl2, index, value) + type(dll), intent(inout) :: dl2 + integer, intent(in) :: index + integer, intent(in) :: value + + type(node), pointer :: element + type(node), pointer :: np1, np2 + integer :: i + + if (dl2%num_nodes == 0) then + call init(dl2, value) + return + end if + + ! If index is beyond the end then append + if (index > dl2%num_nodes) then + call append(dl2, value) + return + end if + + ! If index is less than 1 then prepend + if (index <= 1) then + call prepend(dl2, value) + return + end if + + ! Find the node at position 'index' counting from 1 + np1 => dl2%head + do i=1, index-2 + np1 => np1%next + end do + np2 => np1%next + + ! Create the new node + allocate(element) + element%data = value + + ! Connect it up + element%prev => np1 + element%next => np2 + np1%next => element + np2%prev => element + dl2%num_nodes = dl2%num_nodes + 1 + end subroutine insert + + subroutine dump(dl2) + type(dll), intent(in) :: dl2 + type(node), pointer :: current + integer :: i + + write(*,fmt='(a,i0,a)',advance='no') 'Doubly-linked list has ',dl2%num_nodes,' element - fwd = ' + current => dl2%head + i = 1 + write(*,fmt='(i0,a)',advance='no') current%data,', ' + do + current => current%next + if (.not. associated(current)) then + exit + end if + i = i + 1 + if (i == dl2%num_nodes) then + write(*,'(i0)') current%data + else + write(*,fmt='(i0,a)',advance='no') current%data,', ' + end if + end do + end subroutine dump + + subroutine reverse_dump(dl2) + type(dll), intent(in) :: dl2 + type(node), pointer :: current + integer :: i + + write(*,fmt='(a,i0,a)',advance='no') 'Doubly-linked list has ',dl2%num_nodes,' element - bwd = ' + current => dl2%tail + write(*,fmt='(i0,a)',advance='no') current%data,', ' + i = 1 + do + current => current%prev + if (.not. associated(current)) then + exit + end if + i = i + 1 + if (i == dl2%num_nodes) then + write(*,'(i0)') current%data + else + write(*,fmt='(i0,a)',advance='no') current%data,', ' + end if + end do + end subroutine reverse_dump + + ! Deallocate all allocated memory + elemental subroutine tidy(dl2) + type(dll), intent(inout) :: dl2 + type(node), pointer :: current, last + + current => dl2%head + do + last => current + current => current%next + if (associated(last)) then + deallocate(last) + end if + if (associated(current, dl2%tail)) then + deallocate(current) + exit + end if + end do + end subroutine tidy + + elemental subroutine init(dl2, value) + type(dll), intent(inout) :: dl2 + integer, intent(in) :: value + allocate(dl2%head) + dl2%tail => dl2%head + dl2%tail%data = value + dl2%num_nodes = 1 + return + end subroutine init + +end module dlist + +program dl + use dlist + implicit none + + type(dll) :: mydll + + mydll = new_dll() + call append(mydll, 5) + call append(mydll, 7) + call prepend(mydll, 3) + call prepend(mydll, 1) + call insert(mydll, 3, 4) + call dump(mydll) + + call reverse_dump(mydll) + + call tidy(mydll) +end program dl diff --git a/Task/Doubly-linked-list-Definition/Go/doubly-linked-list-definition.go b/Task/Doubly-linked-list-Definition/Go/doubly-linked-list-definition.go new file mode 100644 index 0000000000..bcd5a26c17 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Go/doubly-linked-list-definition.go @@ -0,0 +1,13 @@ +type dlNode struct { + int + next, prev *dlNode +} + +// Field 'members' allows loops to be prevented. All nodes +// inserted should be added to members. Code that operates +// on the list can check any pointer against members to +// find out if the pointer is already in the list. +type dlList struct { + members map[*dlNode]int + head, tail **dlNode +} diff --git a/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-1.hs b/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-1.hs new file mode 100644 index 0000000000..ba85dde2a2 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-1.hs @@ -0,0 +1,55 @@ +import qualified Data.Map as M + +type NodeID = Maybe Rational +data Node a = Node + {vNode :: a, + pNode, nNode :: NodeID} +type DLList a = M.Map Rational (Node a) + +empty = M.empty + +singleton a = M.singleton 0 $ Node a Nothing Nothing + +fcons :: a -> DLList a -> DLList a +fcons a list | M.null list = singleton a + | otherwise = M.insert newid new $ + M.insert firstid changed list + where (firstid, Node firstval _ secondid) = M.findMin list + newid = firstid - 1 + new = Node a Nothing (Just firstid) + changed = Node firstval (Just newid) secondid + +rcons :: a -> DLList a -> DLList a +rcons a list | M.null list = singleton a + | otherwise = M.insert lastid changed $ + M.insert newid new list + where (lastid, Node lastval penultimateid _) = M.findMax list + newid = lastid + 1 + changed = Node lastval penultimateid (Just newid) + new = Node a (Just lastid) Nothing + +mcons :: a -> Node a -> Node a -> DLList a -> DLList a +mcons a n1 n2 = M.insert n1id left . + M.insert midid mid . M.insert n2id right + where Node n1val farleftid (Just n2id) = n1 + Node n2val (Just n1id) farrightid = n2 + midid = (n1id + n2id) / 2 -- Hence the use of Rationals. + mid = Node a (Just n1id) (Just n2id) + left = Node n1val farleftid (Just midid) + right = Node n2val (Just midid) farrightid + +firstNode :: DLList a -> Node a +firstNode = snd . M.findMin + +lastNode :: DLList a -> Node a +lastNode = snd . M.findMax + +nextNode :: DLList a -> Node a -> Maybe (Node a) +nextNode l n = nNode n >>= flip M.lookup l + +prevNode :: DLList a -> Node a -> Maybe (Node a) +prevNode l n = pNode n >>= flip M.lookup l + +fromList = foldr fcons empty + +toList = map vNode . M.elems diff --git a/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-2.hs b/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-2.hs new file mode 100644 index 0000000000..24894932f3 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-2.hs @@ -0,0 +1,5 @@ +main = putStrLn $ toList l + where l = mcons 'M' n1 n2 x + x = rcons 'Z' $ fcons 'a' $ fcons 'q' $ singleton 'w' + n1 = firstNode x + Just n2 = nextNode x n1 diff --git a/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-3.hs b/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-3.hs new file mode 100644 index 0000000000..4f42cec061 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-3.hs @@ -0,0 +1,38 @@ +class DoubleList (item) + + method head () + node := item + every (node := node.traverse_backwards ()) # move to start of list + return node + end + + method tail () + node := item + every (node := node.traverse_forwards ()) # move to end of list + return node + end + + method insert_at_head (value) + head().insert_before (DoubleLink(value)) + end + + method insert_at_tail (value) + tail().insert_after (DoubleLink (value)) + end + + # insert a node for new_value after that for target_value, + # i.e. in the middle of the list + method insert_after (target_value, new_value) + node := head () + every node := head().traverse_forwards () do + if (node.value = target_value) + then { + node.insert_after (DoubleLink (new_value)) + break + } + end + + # constructor initiates a list making a node from given value + initially (value) + self.item := DoubleLink (value) +end diff --git a/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-4.hs b/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-4.hs new file mode 100644 index 0000000000..4da9a5d4a4 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-4.hs @@ -0,0 +1,7 @@ + # insert given node before this one, losing its existing connections + method insert_before (node) + if (\prev_link) then prev_link.next_link := node + node.prev_link := prev_link + node.next_link := self + self.prev_link := node + end diff --git a/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-5.hs b/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-5.hs new file mode 100644 index 0000000000..c502e8bf8a --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Haskell/doubly-linked-list-definition-5.hs @@ -0,0 +1,12 @@ +procedure main () + dlist := DoubleList (5) + every i := 4 to 1 by -1 do + dlist.insert_at_head (i) + every i := 6 to 10 do + dlist.insert_at_tail (i) + + dlist.insert_after (3, 11) + + every node := dlist.head().traverse_forwards () do + write (node.value) +end diff --git a/Task/Doubly-linked-list-Definition/PicoLisp/doubly-linked-list-definition.l b/Task/Doubly-linked-list-Definition/PicoLisp/doubly-linked-list-definition.l new file mode 100644 index 0000000000..1598d33531 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/PicoLisp/doubly-linked-list-definition.l @@ -0,0 +1,10 @@ +# Build a doubly-linked list +(de 2list @ + (let Prev NIL + (let L + (make + (while (args) + (setq Prev (chain (list (next) Prev))) ) ) + (cons L Prev) ) ) ) + +(setq *DLst (2list 'was 'it 'a 'cat 'I 'saw)) diff --git a/Task/Doubly-linked-list-Definition/REXX/doubly-linked-list-definition.rexx b/Task/Doubly-linked-list-Definition/REXX/doubly-linked-list-definition.rexx new file mode 100644 index 0000000000..1706eb0c62 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/REXX/doubly-linked-list-definition.rexx @@ -0,0 +1,70 @@ +/*REXX program that implements various List Manager functions. */ +/*┌────────────────────────────────────────────────────────────────────┐ +┌─┘ ☼☼☼☼☼☼☼☼☼☼☼ Functions of the List Manager ☼☼☼☼☼☼☼☼☼☼☼ └─┐ +│ @init ─── initializes the List. │ +│ │ +│ @size ─── returns the size of the List [could be 0 (zero)]. │ +│ │ +│ @show ─── shows (displays) the complete List. │ +│ @show k,1 ─── shows (displays) the Kth item. │ +│ @show k,m ─── shows (displays) M items, starting with Kth item.│ +│ @show ,,─1 ─── shows (displays) the complete List backwards. │ +│ │ +│ @get k ─── returns the Kth item. │ +│ @get k,m ─── returns the M items starting with the Kth item. │ +│ │ +│ @put x ─── adds the X items to the end (tail) of the List. │ +│ @put x,0 ─── adds the X items to the start (head) of the List. │ +│ @put x,k ─── adds the X items to before of the Kth item. │ +│ │ +│ @del k ─── deletes the item K. │ +└─┐ @del k,m ─── deletes the M items starting with item K. ┌─┘ + └────────────────────────────────────────────────────────────────────┘*/ +call sy 'initializing the list.' ; call @init +call sy 'building list: Was it a cat I saw'; call @put 'Was it a cat I saw' +call sy 'displaying list size.' ; say 'list size='@size() +call sy 'forward list' ; call @show +call sy 'backward list' ; call @show ,,-1 +call sy 'showing 4th item' ; call @show 4,1 +call sy 'showing 5th & 6th items' ; call @show 5,2 +call sy 'adding item before item 4: black' ; call @put 'black',4 +call sy 'showing list' ; call @show +call sy 'adding to tail: there, in the ...'; call @put 'there, in the shadows, stalking its prey (and next meal).' +call sy 'showing list' ; call @show +call sy 'adding to head: Oy!' ; call @put 'Oy!',0 +call sy 'showing list' ; call @show +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────subroutines─────────────────────────*/ +p: return word(arg(1), 1) /*pick the first word of many. */ +sy: say; say left('', 30) "───" arg(1) '───'; return +@init: $.@=; @adjust: $.@=space($.@); $.#=words($.@); return +@hasopt: arg o; return pos(o, opt)\==0 +@size: return $.# + +@del: procedure expose $.; arg k,m; call @parms 'km' + _=subword($.@, k, k-1) subword($.@, k+m) + $.@=_; call @adjust + return + +@get: procedure expose $.; arg k,m,dir,_ + call @parms 'kmd' + do j=k for m by dir while j>0 & j<=$.# + _=_ subword($.@, j, 1) + end /*j*/ + return strip(_) + +@parms: arg opt /*define a variable based on OPT.*/ + if @hasopt('k') then k=min($.#+1, max(1,p(k 1))) + if @hasopt('m') then m=p(m 1) + if @hasopt('d') then dir=p(dir 1) + return + +@put: procedure expose $.; parse arg x,k ; k=p(k $.#+1) + call @parms 'k' + $.@=subword($.@, 1, max(0, k-1)) x subword($.@, k) + call @adjust + return + +@show: procedure expose $.; parse arg k,m,dir + if dir==-1 & k=='' then k=$.#; m=p(m $.#) + call @parms 'kmd'; say @get(k,m, dir); return diff --git a/Task/Doubly-linked-list-Definition/Tcl/doubly-linked-list-definition-1.tcl b/Task/Doubly-linked-list-Definition/Tcl/doubly-linked-list-definition-1.tcl new file mode 100644 index 0000000000..02719568ef --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Tcl/doubly-linked-list-definition-1.tcl @@ -0,0 +1,71 @@ +package require Tcl 8.4 +proc dl {_name cmd {where error} {value ""}} { + upvar 1 $_name N + switch -- $cmd { + insert { + if ![info exists N()] {set N() {"" "" 0}} + set id [lindex $N() 2] + lset N() 2 [incr id] + switch -- $where { + head { + set prev {} + set next [lindex $N() 0] + lset N() 0 $id + } + end { + set prev [lindex $N() 1] + set next {} + lset N() 1 $id + } + default { + set prev $where + set next [lindex $N($where) 1] + lset N($where) 1 $id + } + } + if {$prev ne ""} {lset N($prev) 1 $id} + if {$next ne ""} {lset N($next) 0 $id} + if {[lindex $N() 1] eq ""} {lset N() 1 $id} + set N($id) [list $prev $next $value] + return $id + } + delete { + set i $where + if {$where eq "head"} {set i [dl N head]} + if {$where eq "end"} {set i [dl N end]} + foreach {prev next} $N($i) break + if {$prev ne ""} {lset N($prev) 1 $next} + if {$next ne ""} {lset N($next) 0 $prev} + if {[dl N head] == $i} {lset N() 0 $next} + if {[dl N end] == $i} {lset N() 1 $prev} + unset N($i) + } + findfrom { + if {$where eq "head"} {set where [dl N head]} + for {set i $where} {$i ne ""} {set i [dl N next $i]} { + if {[dl N get $i] eq $value} {return $i} + } + } + get {lindex $N($where) 2} + set {lset N($where) 2 $value; set value} + head {lindex $N() 0} + end {lindex $N() 1} + next {lindex $N($where) 1} + prev {lindex $N($where) 0} + length {expr {[array size N]-1}} + asList { + set res {} + for {set i [dl N head]} {$i ne ""} {set i [dl N next $i]} { + lappend res [dl N get $i] + } + return $res + } + asList2 { + set res {} + for {set i [dl N end]} {$i ne ""} {set i [dl N prev $i]} { + lappend res [dl N get $i] + } + return $res + } + } +} diff --git a/Task/Doubly-linked-list-Definition/Tcl/doubly-linked-list-definition-2.tcl b/Task/Doubly-linked-list-Definition/Tcl/doubly-linked-list-definition-2.tcl new file mode 100644 index 0000000000..0a68342e27 --- /dev/null +++ b/Task/Doubly-linked-list-Definition/Tcl/doubly-linked-list-definition-2.tcl @@ -0,0 +1,26 @@ +# Testing code +set testcases [split { + dl D insert head foo + dl D insert end bar + dl D insert head hello + dl D set [dl D head] hi + dl D insert end grill + set i [dl D findfrom head bar] + dl D set $i BAR + dl D insert $i and + dl D length + dl D asList2 + dl D delete $i + dl D findfrom head nix + dl D delete head + dl D delete end + dl D delete end + dl D delete head + dl D length +} \n] +foreach case $testcases { + if {[string trim $case] ne ""} { + puts " $case -> [eval $case] : [dl D asList]" + if {[lsearch $argv -p] >= 0} {parray D} + } +} diff --git a/Task/Doubly-linked-list-Element-definition/0DESCRIPTION b/Task/Doubly-linked-list-Element-definition/0DESCRIPTION new file mode 100644 index 0000000000..4b780eb08e --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/0DESCRIPTION @@ -0,0 +1 @@ +Define the data structure for a [[Linked_List#Doubly-Linked_List|doubly-linked list]] element. The element should include a data member to hold its value and pointers to both the next element in the list and the previous element in the list. The pointers should be mutable. diff --git a/Task/Doubly-linked-list-Element-definition/1META.yaml b/Task/Doubly-linked-list-Element-definition/1META.yaml new file mode 100644 index 0000000000..32d20151af --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Data Structures diff --git a/Task/Doubly-linked-list-Element-definition/ALGOL-68/doubly-linked-list-element-definition.alg b/Task/Doubly-linked-list-Element-definition/ALGOL-68/doubly-linked-list-element-definition.alg new file mode 100644 index 0000000000..7513c95827 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/ALGOL-68/doubly-linked-list-element-definition.alg @@ -0,0 +1,26 @@ +MODE LINK = STRUCT ( + REF LINK prev, + REF LINK next, + DATA value +); + +MODE DATA = STRUCT(INT year elected, STRING name); + +LINK previous, incumbent, elect; +previous := (NIL, incumbent, DATA(1993, "Clinton")); +incumbent:= (previous, elect,DATA(2001, "Bush" )); +elect := (incumbent, NIL, DATA(2008, "Obama" )); + +REF LINK node := previous; +WHILE REF LINK(node) ISNT NIL DO + printf(($dddd": "g"; "$,value OF node)); + node := next OF node +OD; +print(new line); + +node := elect; +WHILE REF LINK(node) ISNT NIL DO + printf(($dddd": "g"; "$,value OF node)); + node := prev OF node +OD; +print((newline)) diff --git a/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-1.ada b/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-1.ada new file mode 100644 index 0000000000..5efcca34af --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-1.ada @@ -0,0 +1,7 @@ +type Link; +type Link_Access is access Link; +type Link is record + Next : Link_Access := null; + Prev : Link_Access := null; + Data : Integer; +end record; diff --git a/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-2.ada b/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-2.ada new file mode 100644 index 0000000000..217ff601da --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-2.ada @@ -0,0 +1,23 @@ +generic + type Element_Type is private; +package Linked_List is + type List_Type is limited private; +... +private + type List_Element; + type List_Element_Ptr is access list_element; + type List_Element is + record + Prev : List_Element_Ptr; + Data : Element_Type; + Next : List_Element_Ptr; + end record; + type List_Type is + record + Head : List_Element_Ptr; -- Pointer to first element. + Tail : List_Element_Ptr; -- Pointer to last element. + Cursor : List_Element_Ptr; -- Pointer to cursor element. + Count : Natural := 0; -- Number of items in list. + Traversing : Boolean := False; -- True when in a traversal. + end record; +end Linked_List; diff --git a/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-3.ada b/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-3.ada new file mode 100644 index 0000000000..4928f98f81 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Ada/doubly-linked-list-element-definition-3.ada @@ -0,0 +1,5 @@ +type Link is limited record + Next : not null access Link := Link'Unchecked_Access; + Prev : not null access Link := Link'Unchecked_Access; + Data : Integer; +end record; diff --git a/Task/Doubly-linked-list-Element-definition/BBC-BASIC/doubly-linked-list-element-definition.bbc b/Task/Doubly-linked-list-Element-definition/BBC-BASIC/doubly-linked-list-element-definition.bbc new file mode 100644 index 0000000000..8c2b4883ab --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/BBC-BASIC/doubly-linked-list-element-definition.bbc @@ -0,0 +1 @@ + DIM node{pPrev%, pNext%, iData%} diff --git a/Task/Doubly-linked-list-Element-definition/C/doubly-linked-list-element-definition.c b/Task/Doubly-linked-list-Element-definition/C/doubly-linked-list-element-definition.c new file mode 100644 index 0000000000..e57c406cad --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/C/doubly-linked-list-element-definition.c @@ -0,0 +1,5 @@ +struct link { + struct link *next; + struct link *prev; + int data; +}; diff --git a/Task/Doubly-linked-list-Element-definition/Clojure/doubly-linked-list-element-definition.clj b/Task/Doubly-linked-list-Element-definition/Clojure/doubly-linked-list-element-definition.clj new file mode 100644 index 0000000000..1675fdfecd --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Clojure/doubly-linked-list-element-definition.clj @@ -0,0 +1,4 @@ +(defrecord Node [prev next data]) + +(defn new-node [prev next data] + (Node. (ref prev) (ref next) data)) diff --git a/Task/Doubly-linked-list-Element-definition/Common-Lisp/doubly-linked-list-element-definition.lisp b/Task/Doubly-linked-list-Element-definition/Common-Lisp/doubly-linked-list-element-definition.lisp new file mode 100644 index 0000000000..22074e57ec --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Common-Lisp/doubly-linked-list-element-definition.lisp @@ -0,0 +1,2 @@ +(defstruct dlist head tail) +(defstruct dlink content prev next) diff --git a/Task/Doubly-linked-list-Element-definition/D/doubly-linked-list-element-definition.d b/Task/Doubly-linked-list-Element-definition/D/doubly-linked-list-element-definition.d new file mode 100644 index 0000000000..3a21453c84 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/D/doubly-linked-list-element-definition.d @@ -0,0 +1,4 @@ +struct Node(T) { + T data; + Node* prev, next; +} diff --git a/Task/Doubly-linked-list-Element-definition/Delphi/doubly-linked-list-element-definition.delphi b/Task/Doubly-linked-list-Element-definition/Delphi/doubly-linked-list-element-definition.delphi new file mode 100644 index 0000000000..40c7f89993 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Delphi/doubly-linked-list-element-definition.delphi @@ -0,0 +1,13 @@ +struct Node(T) { + +type + + pList = ^List ; + + list = record + data : pointer ; + prev : pList ; + next : pList ; + end; + +} diff --git a/Task/Doubly-linked-list-Element-definition/E/doubly-linked-list-element-definition.e b/Task/Doubly-linked-list-Element-definition/E/doubly-linked-list-element-definition.e new file mode 100644 index 0000000000..75bab635f4 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/E/doubly-linked-list-element-definition.e @@ -0,0 +1,14 @@ +def makeElement(var value, var next, var prev) { + def element { + to setValue(v) { value := v } + to getValue() { return value } + + to setNext(n) { next := n } + to getNext() { return next } + + to setPrev(p) { prev := p } + to getPrev() { return prev } + } + + return element +} diff --git a/Task/Doubly-linked-list-Element-definition/Fortran/doubly-linked-list-element-definition.f b/Task/Doubly-linked-list-Element-definition/Fortran/doubly-linked-list-element-definition.f new file mode 100644 index 0000000000..a4b5c9626c --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Fortran/doubly-linked-list-element-definition.f @@ -0,0 +1,8 @@ +type node + real :: data + type(node), pointer :: next => null(), previous => null() +end type node +! +! . . . . +! +type( node ), target :: head diff --git a/Task/Doubly-linked-list-Element-definition/Go/doubly-linked-list-element-definition.go b/Task/Doubly-linked-list-Element-definition/Go/doubly-linked-list-element-definition.go new file mode 100644 index 0000000000..764f2c57fc --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Go/doubly-linked-list-element-definition.go @@ -0,0 +1,4 @@ +type dlNode struct { + string + next, prev *dll +} diff --git a/Task/Doubly-linked-list-Element-definition/Haskell/doubly-linked-list-element-definition-1.hs b/Task/Doubly-linked-list-Element-definition/Haskell/doubly-linked-list-element-definition-1.hs new file mode 100644 index 0000000000..3c5f0a5766 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Haskell/doubly-linked-list-element-definition-1.hs @@ -0,0 +1,13 @@ +data DList a = Leaf | Node (DList a) a (DList a) + +updateLeft _ Leaf = Leaf +updateLeft Leaf (Node _ v r) = Node Leaf v r +updateLeft new@(Node nl _ _) (Node _ v r) = current + where current = Node prev v r + prev = updateLeft nl new + +updateRight _ Leaf = Leaf +updateRight Leaf (Node l v _) = Node l v Leaf +updateRight new@(Node _ _ nr) (Node l v _) = current + where current = Node l v next + next = updateRight nr new diff --git a/Task/Doubly-linked-list-Element-definition/Haskell/doubly-linked-list-element-definition-2.hs b/Task/Doubly-linked-list-Element-definition/Haskell/doubly-linked-list-element-definition-2.hs new file mode 100644 index 0000000000..54b3b5fd16 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Haskell/doubly-linked-list-element-definition-2.hs @@ -0,0 +1,6 @@ +class DoubleLink (value, prev_link, next_link) + initially (value, prev_link, next_link) + self.value := value + self.prev_link := prev_link # links are 'null' if not given + self.next_link := next_link +end diff --git a/Task/Doubly-linked-list-Element-definition/Java/doubly-linked-list-element-definition.java b/Task/Doubly-linked-list-Element-definition/Java/doubly-linked-list-element-definition.java new file mode 100644 index 0000000000..e23bad2cc5 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Java/doubly-linked-list-element-definition.java @@ -0,0 +1,42 @@ +public class Node { + private T element; + private Node next, prev; + + public Node(){ + next = prev = element = null; + } + + public Node(Node n, Node p, T elem){ + next = n; + prev = p; + element = elem; + } + + public void setNext(Node n){ + next = n; + } + + public Node getNext(){ + return next; + } + + public void setElem(T elem){ + element = elem; + } + + public T getElem(){ + return element; + } + + public void setNext(Node n){ + next = n; + } + + public Node setPrev(Node p){ + prev = p; + } + + public getPrev(){ + return prev; + } +} diff --git a/Task/Doubly-linked-list-Element-definition/JavaScript/doubly-linked-list-element-definition.js b/Task/Doubly-linked-list-Element-definition/JavaScript/doubly-linked-list-element-definition.js new file mode 100644 index 0000000000..7749528162 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/JavaScript/doubly-linked-list-element-definition.js @@ -0,0 +1,27 @@ +function DoublyLinkedList(value, next, prev) { + this._value = value; + this._next = next; + this._prev = prev; +} +// from LinkedList, inherit: value(), next(), traverse(), print() +DoublyLinkedList.prototype = new LinkedList(); + +DoublyLinkedList.prototype.prev = function() { + if (arguments.length == 1) + this._prev = arguments[0]; + else + return this._prev; +} + +function createDoublyLinkedListFromArray(ary) { + var node, prev, head = new DoublyLinkedList(ary[0], null, null); + prev = head; + for (var i = 1; i < ary.length; i++) { + node = new DoublyLinkedList(ary[i], null, prev); + prev.next(node); + prev = node; + } + return head; +} + +var head = createDoublyLinkedListFromArray([10,20,30,40]); diff --git a/Task/Doubly-linked-list-Element-definition/Perl/doubly-linked-list-element-definition.pl b/Task/Doubly-linked-list-Element-definition/Perl/doubly-linked-list-element-definition.pl new file mode 100644 index 0000000000..4d7bd6325a --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Perl/doubly-linked-list-element-definition.pl @@ -0,0 +1,6 @@ +my %node = ( + data => 'say what', + next => \%foo_node, + prev => \%bar_node, +); +$node{next} = \%quux_node; # mutable diff --git a/Task/Doubly-linked-list-Element-definition/PicoLisp/doubly-linked-list-element-definition.l b/Task/Doubly-linked-list-Element-definition/PicoLisp/doubly-linked-list-element-definition.l new file mode 100644 index 0000000000..71d0888da3 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/PicoLisp/doubly-linked-list-element-definition.l @@ -0,0 +1,10 @@ +# 'cons' an element to a doubly-linked list +(de 2cons (X DLst) + (let L (car DLst) # Get current data list + (set DLst (cons X NIL L)) # Prepend two new cons pairs + (if L # Unless DLst was empty + (set (cdr L) (car DLst)) # set new 'prev' link + (con DLst (car DLst)) ) ) ) # otherwise set 'end' link + +# We prepend 'not' to the list in the previous example +(2cons 'not *DLst) diff --git a/Task/Doubly-linked-list-Element-definition/Python/doubly-linked-list-element-definition.py b/Task/Doubly-linked-list-Element-definition/Python/doubly-linked-list-element-definition.py new file mode 100644 index 0000000000..9d5b4be0ec --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Python/doubly-linked-list-element-definition.py @@ -0,0 +1,19 @@ +class Node(object): + def __init__(self, data = None, prev = None, next = None): + self.prev = prev + self.next = next + self.data = data + def __str__(self): + return str(self.data) + def __repr__(self): + return repr(self.data) + def iter_forward(self): + c = self + while c != None: + yield c + c = c.next + def iter_backward(self): + c = self + while c != None: + yield c + c = c.prev diff --git a/Task/Doubly-linked-list-Element-definition/REXX/doubly-linked-list-element-definition.rexx b/Task/Doubly-linked-list-Element-definition/REXX/doubly-linked-list-element-definition.rexx new file mode 100644 index 0000000000..d7744b6517 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/REXX/doubly-linked-list-element-definition.rexx @@ -0,0 +1,79 @@ +/*REXX program that implements various List Manager functions. */ +/*┌────────────────────────────────────────────────────────────────────┐ +┌─┘ Functions of the List Manager └─┐ +│ │ +│ @init ─── initializes the List. │ +│ │ +│ @size ─── returns the size of the List [could be 0 (zero)]. │ +│ │ +│ @show ─── shows (displays) the complete List. │ +│ @show k,1 ─── shows (displays) the Kth item. │ +│ @show k,m ─── shows (displays) M items, starting with Kth item. │ +│ @show ,,─1 ─── shows (displays) the complete List backwards. │ +│ │ +│ @get k ─── returns the Kth item. │ +│ @get k,m ─── returns the M items starting with the Kth item. │ +│ │ +│ @put x ─── adds the X items to the end (tail) of the List. │ +│ @put x,0 ─── adds the X items to the start (head) of the List. │ +│ @put x,k ─── adds the X items to before of the Kth item. │ +│ │ +│ @del k ─── deletes the item K. │ +│ @del k,m ─── deletes the M items starting with item K. │ +└─┐ ┌─┘ + └────────────────────────────────────────────────────────────────────┘*/ +call sy 'initializing the list.' ; call @init +call sy 'building list: Was it a cat I saw'; call @put 'Was it a cat I saw' +call sy 'displaying list size.' ; say 'list size='@size() +call sy 'forward list' ; call @show +call sy 'backward list' ; call @show ,,-1 +call sy 'showing 4th item' ; call @show 4,1 +call sy 'showing 6th & 6th items' ; call @show 5,2 +call sy 'adding item before item 4: black' ; call @put 'black',4 +call sy 'showing list' ; call @show +call sy 'adding to tail: there, in the ...'; call @put 'there, in the shadows, stalking its prey (and next meal).' +call sy 'showing list' ; call @show +call sy 'adding to head: Oy!' ; call @put 'Oy!',0 +call sy 'showing list' ; call @show +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────subroutines─────────────────────────*/ +p: return word(arg(1),1) +sy: say; say left('',30) "───" arg(1) '───'; return +@hasopt: arg o; return pos(o,opt)\==0 +@size: return $.# +@init: $.@=''; $.#=0; return 0 +@adjust: $.@=space($.@); $.#=words($.@); return 0 + +@parms: arg opt + if @hasopt('k') then k=min($.#+1,max(1,p(k 1))) + if @hasopt('m') then m=p(m 1) + if @hasopt('d') then dir=p(dir 1) + return + +@show: procedure expose $.; parse arg k,m,dir + if dir==-1 & k=='' then k=$.# + m=p(m $.#); + call @parms 'kmd' + say @get(k,m,dir); + return 0 + +@get: procedure expose $.; arg k,m,dir,_ + call @parms 'kmd' + do j=k for m by dir while j>0 & j<=$.# + _=_ subword($.@,j,1) + end /*j*/ + return strip(_) + +@put: procedure expose $.; parse arg x,k + k=p(k $.#+1) + call @parms 'k' + $.@=subword($.@,1,max(0,k-1)) x subword($.@,k) + call @adjust + return 0 + +@del: procedure expose $.; arg k,m + call @parms 'km' + _=subword($.@,k,k-1) subword($.@,k+m) + $.@=_ + call @adjust + return diff --git a/Task/Doubly-linked-list-Element-definition/Ruby/doubly-linked-list-element-definition.rb b/Task/Doubly-linked-list-Element-definition/Ruby/doubly-linked-list-element-definition.rb new file mode 100644 index 0000000000..54428ca754 --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Ruby/doubly-linked-list-element-definition.rb @@ -0,0 +1,20 @@ +class DListNode < ListNode + attr_accessor :prev + # accessors :succ and :value are inherited + + def initialize(value, prev=nil, succ=nil) + @value = value + @prev = prev + @prev.succ = self if prev + @succ = succ + @succ.prev = self if succ + end + + def self.from_values(*ary) + ary << (f = ary.pop) + ary.map! {|i| new i } + ary.inject(f) {|p, c| p.succ = c; c.prev = p; c } + end +end + +list = DListNode.from_values 1,2,3,4 diff --git a/Task/Doubly-linked-list-Element-definition/Tcl/doubly-linked-list-element-definition.tcl b/Task/Doubly-linked-list-Element-definition/Tcl/doubly-linked-list-element-definition.tcl new file mode 100644 index 0000000000..250563d16a --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Tcl/doubly-linked-list-element-definition.tcl @@ -0,0 +1,20 @@ +oo::class create List { + variable content next prev + constructor {value {list ""}} { + set content $value + set next $list + set prev "" + if {$next ne ""} { + $next previous [self] + } + } + method value args { + set content {*}$args + } + method next args { + set next {*}$args + } + method previous args { + set prev {*}$args + } +} diff --git a/Task/Doubly-linked-list-Element-insertion/0DESCRIPTION b/Task/Doubly-linked-list-Element-insertion/0DESCRIPTION new file mode 100644 index 0000000000..f18451a2c8 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/0DESCRIPTION @@ -0,0 +1,3 @@ +Use the link structure defined in [[Doubly-Linked List (element)]] to define a procedure for inserting a link into a doubly-linked list. Call this procedure to insert element C into a list {A,B}, between elements A and B. + +This is much like inserting into a [[Singly-Linked List (element insertion)|Singly-Linked List]], but with added assignments so that the backwards-pointing links remain correct. diff --git a/Task/Doubly-linked-list-Element-insertion/1META.yaml b/Task/Doubly-linked-list-Element-insertion/1META.yaml new file mode 100644 index 0000000000..32d20151af --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Data Structures diff --git a/Task/Doubly-linked-list-Element-insertion/ALGOL-68/doubly-linked-list-element-insertion.alg b/Task/Doubly-linked-list-Element-insertion/ALGOL-68/doubly-linked-list-element-insertion.alg new file mode 100644 index 0000000000..9f048d16b2 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/ALGOL-68/doubly-linked-list-element-insertion.alg @@ -0,0 +1,51 @@ +#!/usr/local/bin/a68g --script # + +# SEMA do link OF splice = LEVEL 1 # +MODE LINK = STRUCT ( + REF LINK prev, + REF LINK next, + DATA value +); + +# BEGIN rosettacode task specimen code: + can handle insert both before the first, and after the last link # + +PROC insert after = (REF LINK #self,# prev, DATA new data)LINK: ( +# DOWN do link OF splice OF self; to make thread safe # + REF LINK next = next OF prev; + HEAP LINK new link := LINK(prev, next, new data); + next OF prev := prev OF next := new link; +# UP do link OF splice OF self; # + new link +); + +PROC insert before = (REF LINK #self,# next, DATA new data)LINK: + insert after(#self,# prev OF next, new data); + +# END rosettacode task specimen code # + +# Test case: # +MODE DATA = STRUCT(INT year elected, STRING name); +FORMAT data fmt = $dddd": "g"; "$; + +test:( + +# manually initialise the back splices # + LINK presidential splice; + presidential splice := (presidential splice, presidential splice, SKIP); + +# manually build the chain # + LINK previous, incumbent, elect; + previous := (presidential splice, incumbent, DATA(1993, "Clinton")); + incumbent:= (previous, elect, DATA(2001, "Bush" )); + elect := (incumbent, presidential splice, DATA(2008, "Obama" )); + + insert after(incumbent, LOC DATA := DATA(2004, "Cheney")); + + REF LINK node := previous; + WHILE REF LINK(node) ISNT presidential splice DO + printf((data fmt, value OF node)); + node := next OF node + OD; + print(new line) +) diff --git a/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-1.ada b/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-1.ada new file mode 100644 index 0000000000..9e82cde7e0 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-1.ada @@ -0,0 +1,11 @@ +procedure Insert (Anchor : Link_Access; New_Link : Link_Access) is +begin + if Anchor /= Null and New_Link /= Null then + New_Link.Next := Anchor.Next; + New_Link.Prev := Anchor; + if New_Link.Next /= Null then + New_Link.Next.Prev := New_Link; + end if; + Anchor.Next := New_Link; + end if; +end Insert; diff --git a/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-2.ada b/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-2.ada new file mode 100644 index 0000000000..97726c509c --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-2.ada @@ -0,0 +1,12 @@ +procedure Make_List is + Link_Access : A, B, C; +begin + A := new Link; + B := new Link; + C := new Link; + A.Data := 1; + B.Data := 2; + C.Data := 2; + Insert(Anchor => A, New_Link => B); -- The list is (A, B) + Insert(Anchor => A, New_Link => C); -- The list is (A, C, B) +end Make_List; diff --git a/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-3.ada b/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-3.ada new file mode 100644 index 0000000000..2c57bc3055 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Ada/doubly-linked-list-element-insertion-3.ada @@ -0,0 +1,19 @@ +with Ada.Containers.Doubly_Linked_Lists; +with Ada.Text_Io; use Ada.Text_Io; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; + +procedure List_Insertion is + package String_List is new Ada.Containers.Doubly_Linked_Lists(Unbounded_String); + use String_List; + procedure Print(Position : Cursor) is + begin + Put_Line(To_String(Element(Position))); + end Print; + The_List : List; +begin + The_List.Append(To_Unbounded_String("A")); + The_List.Append(To_Unbounded_String("B")); + The_List.Insert(Before => The_List.Find(To_Unbounded_String("B")), + New_Item => To_Unbounded_String("C")); + The_List.Iterate(Print'access); +end List_Insertion; diff --git a/Task/Doubly-linked-list-Element-insertion/BBC-BASIC/doubly-linked-list-element-insertion.bbc b/Task/Doubly-linked-list-Element-insertion/BBC-BASIC/doubly-linked-list-element-insertion.bbc new file mode 100644 index 0000000000..e82ebba1e1 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/BBC-BASIC/doubly-linked-list-element-insertion.bbc @@ -0,0 +1,20 @@ + DIM node{pPrev%, pNext%, iData%} + DIM a{} = node{}, b{} = node{}, c{} = node{} + + a.pNext% = b{} + a.iData% = 123 + b.pPrev% = a{} + b.iData% = 456 + c.iData% = 789 + + PROCinsert(a{}, c{}) + END + + DEF PROCinsert(here{}, new{}) + LOCAL temp{} : DIM temp{} = node{} + new.pNext% = here.pNext% + new.pPrev% = here{} + !(^temp{}+4) = new.pNext% + temp.pPrev% = new{} + here.pNext% = new{} + ENDPROC diff --git a/Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-1.c b/Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-1.c new file mode 100644 index 0000000000..4bd9ede603 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-1.c @@ -0,0 +1,6 @@ +void insert(link* anchor, link* newlink) { + newlink->next = anchor->next; + newlink->prev = anchor; + (newlink->next)->prev = newlink; + anchor->next = newlink; +} diff --git a/Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-2.c b/Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-2.c new file mode 100644 index 0000000000..d2ee537573 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-2.c @@ -0,0 +1,8 @@ +link a, b, c; +a.next = &b; +a.prev = null; +a.data = 1; +b.next = null; +b.prev = &a; +b.data = 3; +c.data = 2; diff --git a/Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-3.c b/Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-3.c new file mode 100644 index 0000000000..329cad316b --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/C/doubly-linked-list-element-insertion-3.c @@ -0,0 +1 @@ +insert(&a, &c); diff --git a/Task/Doubly-linked-list-Element-insertion/Clojure/doubly-linked-list-element-insertion.clj b/Task/Doubly-linked-list-Element-insertion/Clojure/doubly-linked-list-element-insertion.clj new file mode 100644 index 0000000000..0cdc4615ab --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Clojure/doubly-linked-list-element-insertion.clj @@ -0,0 +1,24 @@ +(defrecord Node [prev next data]) + +(defn new-node [prev next data] + (Node. (ref prev) (ref next) data)) + +(defn new-list [head tail] + (List. (ref head) (ref tail))) + +(defn insert-between [node1 node2 new-node] + (dosync + (ref-set (:next node1) new-node) + (ref-set (:prev new-node) node1) + (ref-set (:next new-node) node2) + (ref-set (:prev node2) new-node))) + +(set! *print-level* 1) + +;; warning: depending on the value of *print-level* +;; this could cause a stack overflow when printing + +(let [h (new-node nil nil :A) + t (new-node nil nil :B)] + (insert-between h t (new-node nil nil :C)) + (new-list h t)) diff --git a/Task/Doubly-linked-list-Element-insertion/D/doubly-linked-list-element-insertion.d b/Task/Doubly-linked-list-Element-insertion/D/doubly-linked-list-element-insertion.d new file mode 100644 index 0000000000..131cf49f22 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/D/doubly-linked-list-element-insertion.d @@ -0,0 +1,41 @@ +import std.stdio; + +struct Node(T) { + T data; + Node* prev, next; + + this(T data_, Node* prev_=null, Node* next_=null) { + data = data_; + prev = prev_; + next = next_; + } +} + +void show(T)(Node!(T)* list) { + while (list) { + write(list.data, " "); + list = list.next; + } + writeln(); +} + +/// If prev is null, prev gets to point to a new node +void insertAfter(T)(ref Node!(T)* prev, T item) { + if (prev) { + auto newNode = new Node!T(item, prev, prev.next); + prev.next = newNode; + if (newNode.next) + newNode.next.prev = newNode; + } else + prev = new Node!T(item); +} + +void main() { + Node!(string)* list; + insertAfter(list, "A"); + show(list); + insertAfter(list, "B"); + show(list); + insertAfter(list, "C"); + show(list); +} diff --git a/Task/Doubly-linked-list-Element-insertion/E/doubly-linked-list-element-insertion-1.e b/Task/Doubly-linked-list-Element-insertion/E/doubly-linked-list-element-insertion-1.e new file mode 100644 index 0000000000..ce2ef2189e --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/E/doubly-linked-list-element-insertion-1.e @@ -0,0 +1,5 @@ +def insert(after, value) { + def newNode := makeElement(value, after, after.getNext()) + after.getNext().setPrev(newNode) + after.setNext(newNode) +} diff --git a/Task/Doubly-linked-list-Element-insertion/E/doubly-linked-list-element-insertion-2.e b/Task/Doubly-linked-list-Element-insertion/E/doubly-linked-list-element-insertion-2.e new file mode 100644 index 0000000000..dfd0e415a6 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/E/doubly-linked-list-element-insertion-2.e @@ -0,0 +1 @@ +insert(A_node, C) diff --git a/Task/Doubly-linked-list-Element-insertion/Fortran/doubly-linked-list-element-insertion-1.f b/Task/Doubly-linked-list-Element-insertion/Fortran/doubly-linked-list-element-insertion-1.f new file mode 100644 index 0000000000..f97d8e0930 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Fortran/doubly-linked-list-element-insertion-1.f @@ -0,0 +1,55 @@ +module dlList + public :: node, insertAfter, getNext + + type node + real :: data + type( node ), pointer :: next => null() + type( node ), pointer :: previous => null() + end type node + +contains + subroutine insertAfter(nodeBefore, value) + type( node ), intent(inout), target :: nodeBefore + type( node ), pointer :: newNode + real, intent(in) :: value + + allocate( newNode ) + newNode%data = value + newNode%next => nodeBefore%next + newNode%previous => nodeBefore + + if (associated( newNode%next )) then + newNode%next%previous => newNode + end if + newNode%previous%next => newNode + end subroutine insertAfter + + subroutine delete(current) + type( node ), intent(inout), pointer :: current + + if (associated( current%next )) current%next%previous => current%previous + if (associated( current%previous )) current%previous%next => current%next + deallocate(current) + end subroutine delete +end module dlList + +program dlListTest + use dlList + type( node ), target :: head + type( node ), pointer :: current, next + + head%data = 1.0 + current => head + do i = 1, 20 + call insertAfter(current, 2.0**i) + current => current%next + end do + + current => head + do while (associated(current)) + print *, current%data + next => current%next + if (.not. associated(current, head)) call delete(current) + current => next + end do +end program dlListTest diff --git a/Task/Doubly-linked-list-Element-insertion/Fortran/doubly-linked-list-element-insertion-2.f b/Task/Doubly-linked-list-Element-insertion/Fortran/doubly-linked-list-element-insertion-2.f new file mode 100644 index 0000000000..825b28e911 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Fortran/doubly-linked-list-element-insertion-2.f @@ -0,0 +1,21 @@ +1. +2. +4. +8. +16. +32. +64. +128. +256. +512. +1024. +2048. +4096. +8192. +16384. +32768. +65536. +131072. +262144. +524288. +1048576. diff --git a/Task/Doubly-linked-list-Element-insertion/Go/doubly-linked-list-element-insertion.go b/Task/Doubly-linked-list-Element-insertion/Go/doubly-linked-list-element-insertion.go new file mode 100644 index 0000000000..8837bb6186 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Go/doubly-linked-list-element-insertion.go @@ -0,0 +1,55 @@ +package main + +import "fmt" + +type dlNode struct { + string + next, prev *dlNode +} + +type dlList struct { + head, tail *dlNode +} + +func (list *dlList) String() string { + if list.head == nil { + return fmt.Sprint(list.head) + } + r := "[" + list.head.string + for p := list.head.next; p != nil; p = p.next { + r += " " + p.string + } + return r + "]" +} + +func (list *dlList) insertTail(node *dlNode) { + if list.tail == nil { + list.head = node + } else { + list.tail.next = node + } + node.next = nil + node.prev = list.tail + list.tail = node +} + +func (list *dlList) insertAfter(existing, insert *dlNode) { + insert.prev = existing + insert.next = existing.next + existing.next.prev = insert + existing.next = insert + if existing == list.tail { + list.tail = insert + } +} + +func main() { + dll := &dlList{} + fmt.Println(dll) + a := &dlNode{string: "A"} + dll.insertTail(a) + dll.insertTail(&dlNode{string: "B"}) + fmt.Println(dll) + dll.insertAfter(a, &dlNode{string: "C"}) + fmt.Println(dll) +} diff --git a/Task/Doubly-linked-list-Element-insertion/Haskell/doubly-linked-list-element-insertion-1.hs b/Task/Doubly-linked-list-Element-insertion/Haskell/doubly-linked-list-element-insertion-1.hs new file mode 100644 index 0000000000..beea92f7ec --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Haskell/doubly-linked-list-element-insertion-1.hs @@ -0,0 +1,7 @@ +insert _ Leaf = Leaf +insert nv l@(Node pl v r) = (\(Node c _ _) -> c) new + where new = updateLeft left . updateRight right $ Node l nv r + left = Node pl v new + right = case r of + Leaf -> Leaf + Node _ v r -> Node new v r diff --git a/Task/Doubly-linked-list-Element-insertion/Haskell/doubly-linked-list-element-insertion-2.hs b/Task/Doubly-linked-list-Element-insertion/Haskell/doubly-linked-list-element-insertion-2.hs new file mode 100644 index 0000000000..11547f4db7 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Haskell/doubly-linked-list-element-insertion-2.hs @@ -0,0 +1,15 @@ +class DoubleLink (value, prev_link, next_link) + + # insert given node after this one, losing its existing connections + method insert_after (node) + node.prev_link := self + if (\next_link) then next_link.prev_link := node + node.next_link := next_link + self.next_link := node + end + + initially (value, prev_link, next_link) + self.value := value + self.prev_link := prev_link # links are 'null' if not given + self.next_link := next_link +end diff --git a/Task/Doubly-linked-list-Element-insertion/JavaScript/doubly-linked-list-element-insertion.js b/Task/Doubly-linked-list-Element-insertion/JavaScript/doubly-linked-list-element-insertion.js new file mode 100644 index 0000000000..e3062581b8 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/JavaScript/doubly-linked-list-element-insertion.js @@ -0,0 +1,16 @@ +DoublyLinkedList.prototype.insertAfter = function(searchValue, nodeToInsert) { + if (this._value == searchValue) { + var after = this.next(); + this.next(nodeToInsert); + nodeToInsert.prev(this); + nodeToInsert.next(after); + after.prev(nodeToInsert); + } + else if (this.next() == null) + throw new Error(0, "value '" + searchValue + "' not found in linked list.") + else + this.next().insertAfter(searchValue, nodeToInsert); +} + +var list = createDoublyLinkedListFromArray(['A','B']); +list.insertAfter('A', new DoublyLinkedList('C', null, null)); diff --git a/Task/Doubly-linked-list-Element-insertion/Perl/doubly-linked-list-element-insertion.pl b/Task/Doubly-linked-list-Element-insertion/Perl/doubly-linked-list-element-insertion.pl new file mode 100644 index 0000000000..972b1b7f5d --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Perl/doubly-linked-list-element-insertion.pl @@ -0,0 +1,25 @@ +my %node_model = ( + data => 'something', + prev => undef, + next => undef, +); + +sub insert +{ + my ($anchor, $newlink) = @_; + $newlink->{next} = $anchor->{next}; + $newlink->{prev} = $anchor; + $newlink->{next}->{prev} = $newlink; + $anchor->{next} = $newlink; +} + +# create the list {A,B} +my $node_a = { %node_model }; +my $node_b = { %node_model }; + +$node_a->{next} = $node_b; +$node_b->{prev} = $node_a; + +# insert element C into a list {A,B}, between elements A and B. +my $node_c = { %node_model }; +insert($node_a, $node_c); diff --git a/Task/Doubly-linked-list-Element-insertion/PicoLisp/doubly-linked-list-element-insertion.l b/Task/Doubly-linked-list-Element-insertion/PicoLisp/doubly-linked-list-element-insertion.l new file mode 100644 index 0000000000..20e260e057 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/PicoLisp/doubly-linked-list-element-insertion.l @@ -0,0 +1,12 @@ +# Insert an element X at position Pos +(de 2insert (X Pos DLst) + (let (Lst (nth (car DLst) (dec (* 2 Pos))) New (cons X (cadr Lst) Lst)) + (if (cadr Lst) + (con (cdr @) New) + (set DLst New) ) + (if (cdr Lst) + (set @ New) + (con DLst New) ) ) ) + +(setq *DL (2list 'A 'B)) # Build a two-element doubly-linked list +(2insert 'C 2 *DL) # Insert C at position 2 diff --git a/Task/Doubly-linked-list-Element-insertion/Python/doubly-linked-list-element-insertion.py b/Task/Doubly-linked-list-Element-insertion/Python/doubly-linked-list-element-insertion.py new file mode 100644 index 0000000000..a8b28073f1 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Python/doubly-linked-list-element-insertion.py @@ -0,0 +1,5 @@ +def insert(anchor, new): + new.next = anchor.next + new.prev = anchor + anchor.next.prev = new + anchor.next = new diff --git a/Task/Doubly-linked-list-Element-insertion/REXX/doubly-linked-list-element-insertion.rexx b/Task/Doubly-linked-list-Element-insertion/REXX/doubly-linked-list-element-insertion.rexx new file mode 100644 index 0000000000..d7744b6517 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/REXX/doubly-linked-list-element-insertion.rexx @@ -0,0 +1,79 @@ +/*REXX program that implements various List Manager functions. */ +/*┌────────────────────────────────────────────────────────────────────┐ +┌─┘ Functions of the List Manager └─┐ +│ │ +│ @init ─── initializes the List. │ +│ │ +│ @size ─── returns the size of the List [could be 0 (zero)]. │ +│ │ +│ @show ─── shows (displays) the complete List. │ +│ @show k,1 ─── shows (displays) the Kth item. │ +│ @show k,m ─── shows (displays) M items, starting with Kth item. │ +│ @show ,,─1 ─── shows (displays) the complete List backwards. │ +│ │ +│ @get k ─── returns the Kth item. │ +│ @get k,m ─── returns the M items starting with the Kth item. │ +│ │ +│ @put x ─── adds the X items to the end (tail) of the List. │ +│ @put x,0 ─── adds the X items to the start (head) of the List. │ +│ @put x,k ─── adds the X items to before of the Kth item. │ +│ │ +│ @del k ─── deletes the item K. │ +│ @del k,m ─── deletes the M items starting with item K. │ +└─┐ ┌─┘ + └────────────────────────────────────────────────────────────────────┘*/ +call sy 'initializing the list.' ; call @init +call sy 'building list: Was it a cat I saw'; call @put 'Was it a cat I saw' +call sy 'displaying list size.' ; say 'list size='@size() +call sy 'forward list' ; call @show +call sy 'backward list' ; call @show ,,-1 +call sy 'showing 4th item' ; call @show 4,1 +call sy 'showing 6th & 6th items' ; call @show 5,2 +call sy 'adding item before item 4: black' ; call @put 'black',4 +call sy 'showing list' ; call @show +call sy 'adding to tail: there, in the ...'; call @put 'there, in the shadows, stalking its prey (and next meal).' +call sy 'showing list' ; call @show +call sy 'adding to head: Oy!' ; call @put 'Oy!',0 +call sy 'showing list' ; call @show +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────subroutines─────────────────────────*/ +p: return word(arg(1),1) +sy: say; say left('',30) "───" arg(1) '───'; return +@hasopt: arg o; return pos(o,opt)\==0 +@size: return $.# +@init: $.@=''; $.#=0; return 0 +@adjust: $.@=space($.@); $.#=words($.@); return 0 + +@parms: arg opt + if @hasopt('k') then k=min($.#+1,max(1,p(k 1))) + if @hasopt('m') then m=p(m 1) + if @hasopt('d') then dir=p(dir 1) + return + +@show: procedure expose $.; parse arg k,m,dir + if dir==-1 & k=='' then k=$.# + m=p(m $.#); + call @parms 'kmd' + say @get(k,m,dir); + return 0 + +@get: procedure expose $.; arg k,m,dir,_ + call @parms 'kmd' + do j=k for m by dir while j>0 & j<=$.# + _=_ subword($.@,j,1) + end /*j*/ + return strip(_) + +@put: procedure expose $.; parse arg x,k + k=p(k $.#+1) + call @parms 'k' + $.@=subword($.@,1,max(0,k-1)) x subword($.@,k) + call @adjust + return 0 + +@del: procedure expose $.; arg k,m + call @parms 'km' + _=subword($.@,k,k-1) subword($.@,k+m) + $.@=_ + call @adjust + return diff --git a/Task/Doubly-linked-list-Element-insertion/Ruby/doubly-linked-list-element-insertion.rb b/Task/Doubly-linked-list-Element-insertion/Ruby/doubly-linked-list-element-insertion.rb new file mode 100644 index 0000000000..9d62d1fe99 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Ruby/doubly-linked-list-element-insertion.rb @@ -0,0 +1,19 @@ +class DListNode + def insert_after(search_value, new_value) + if search_value == value + new_node = self.class.new(new_value, nil, nil) + next_node = self.succ + self.succ = new_node + new_node.prev = self + new_node.succ = next_node + next_node.prev = new_node + elsif self.succ.nil? + raise StandardError, "value #{search_value} not found in list" + else + self.succ.insert_after(search_value, new_value) + end + end +end + +head = DListNode.from_array([:a, :b]) +head.insert_after(:a, :c) diff --git a/Task/Doubly-linked-list-Element-insertion/Tcl/doubly-linked-list-element-insertion-1.tcl b/Task/Doubly-linked-list-Element-insertion/Tcl/doubly-linked-list-element-insertion-1.tcl new file mode 100644 index 0000000000..d7e69143f4 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Tcl/doubly-linked-list-element-insertion-1.tcl @@ -0,0 +1,18 @@ +oo::define List { + method insertBefore {elem} { + $elem next [self] + $elem previous $prev + if {$prev ne ""} { + $prev next $elem + } + set prev $elem + } + method insertAfter {elem} { + $elem previous [self] + $elem next $next + if {$next ne ""} { + $next previous $elem + } + set next $elem + } +} diff --git a/Task/Doubly-linked-list-Element-insertion/Tcl/doubly-linked-list-element-insertion-2.tcl b/Task/Doubly-linked-list-Element-insertion/Tcl/doubly-linked-list-element-insertion-2.tcl new file mode 100644 index 0000000000..07647985c4 --- /dev/null +++ b/Task/Doubly-linked-list-Element-insertion/Tcl/doubly-linked-list-element-insertion-2.tcl @@ -0,0 +1,5 @@ +set B [List new 3] +set A [List new 1 $B] +set C [List new 2] +$A insertAfter $C +puts [format "{%d,%d,%d}" [$A value] [[$A next] value] [[[$A next] next] value]] diff --git a/Task/Doubly-linked-list-Traversal/0DESCRIPTION b/Task/Doubly-linked-list-Traversal/0DESCRIPTION new file mode 100644 index 0000000000..91d9f22ea6 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/0DESCRIPTION @@ -0,0 +1 @@ +Traverse from the beginning of a [[Doubly-linked list/Definition|doubly-linked list]] to the end, and from the end to the beginning. diff --git a/Task/Doubly-linked-list-Traversal/1META.yaml b/Task/Doubly-linked-list-Traversal/1META.yaml new file mode 100644 index 0000000000..60e9ee5c5f --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Iteration +note: Data Structures diff --git a/Task/Doubly-linked-list-Traversal/Ada/doubly-linked-list-traversal.ada b/Task/Doubly-linked-list-Traversal/Ada/doubly-linked-list-traversal.ada new file mode 100644 index 0000000000..d652f32ab0 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/Ada/doubly-linked-list-traversal.ada @@ -0,0 +1,27 @@ +with Ada.Containers.Doubly_Linked_Lists; +with Ada.Text_IO; + +procedure Traversing is + package Char_Lists is new Ada.Containers.Doubly_Linked_Lists (Character); + + procedure Print (Position : in Char_Lists.Cursor) is + begin + Ada.Text_IO.Put (Char_Lists.Element (Position)); + end Print; + + My_List : Char_Lists.List; +begin + My_List.Append ('R'); + My_List.Append ('o'); + My_List.Append ('s'); + My_List.Append ('e'); + My_List.Append ('t'); + My_List.Append ('t'); + My_List.Append ('a'); + + My_List.Iterate (Print'Access); + Ada.Text_IO.New_Line; + + My_List.Reverse_Iterate (Print'Access); + Ada.Text_IO.New_Line; +end Traversing; diff --git a/Task/Doubly-linked-list-Traversal/BBC-BASIC/doubly-linked-list-traversal.bbc b/Task/Doubly-linked-list-Traversal/BBC-BASIC/doubly-linked-list-traversal.bbc new file mode 100644 index 0000000000..63b835bbfe --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/BBC-BASIC/doubly-linked-list-traversal.bbc @@ -0,0 +1,37 @@ + DIM node{pPrev%, pNext%, iData%} + DIM a{} = node{}, b{} = node{}, c{} = node{} + + a.pNext% = b{} + a.iData% = 123 + b.pPrev% = a{} + b.iData% = 789 + c.iData% = 456 + + PROCinsert(a{}, c{}) + + PRINT "Traverse forwards:" + pnode% = a{} + REPEAT + !(^node{}+4) = pnode% + PRINT node.iData% + pnode% = node.pNext% + UNTIL pnode% = 0 + + PRINT "Traverse backwards:" + pnode% = b{} + REPEAT + !(^node{}+4) = pnode% + PRINT node.iData% + pnode% = node.pPrev% + UNTIL pnode% = 0 + + END + + DEF PROCinsert(here{}, new{}) + LOCAL temp{} : DIM temp{} = node{} + new.pNext% = here.pNext% + new.pPrev% = here{} + !(^temp{}+4) = new.pNext% + temp.pPrev% = new{} + here.pNext% = new{} + ENDPROC diff --git a/Task/Doubly-linked-list-Traversal/C-sharp/doubly-linked-list-traversal.cs b/Task/Doubly-linked-list-Traversal/C-sharp/doubly-linked-list-traversal.cs new file mode 100644 index 0000000000..28008199f4 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/C-sharp/doubly-linked-list-traversal.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; + +namespace RosettaCode.DoublyLinkedList +{ + internal static class Program + { + private static void Main() + { + var list = new LinkedList("hello"); + + var current = list.First; + do + { + Console.WriteLine(current.Value); + } while ((current = current.Next) != null); + + Console.WriteLine(); + + current = list.Last; + do + { + Console.WriteLine(current.Value); + } while ((current = current.Previous) != null); + } + } +} diff --git a/Task/Doubly-linked-list-Traversal/C/doubly-linked-list-traversal.c b/Task/Doubly-linked-list-Traversal/C/doubly-linked-list-traversal.c new file mode 100644 index 0000000000..07656a9677 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/C/doubly-linked-list-traversal.c @@ -0,0 +1,128 @@ +// A doubly linked list of strings; +#include +#include +#include + +typedef struct sListEntry { + const char *value; + struct sListEntry *next; + struct sListEntry *prev; +} *ListEntry, *LinkedList; + +typedef struct sListIterator{ + ListEntry link; + LinkedList head; +} *LIterator; + +LinkedList NewList() { + ListEntry le = malloc(sizeof(struct sListEntry)); + if (le) { + le->value = NULL; + le->next = le->prev = NULL; + } + return le; +} + +int LL_Append(LinkedList ll, const char *newVal) +{ + ListEntry le = malloc(sizeof(struct sListEntry)); + if (le) { + le->value = strdup(newVal); + le->prev = ll->prev; + le->next = NULL; + if (le->prev) + le->prev->next = le; + else + ll->next = le; + ll->prev = le; + } + return (le!= NULL); +} + +int LI_Insert(LIterator iter, const char *newVal) +{ + ListEntry crnt = iter->link; + ListEntry le = malloc(sizeof(struct sListEntry)); + if (le) { + le->value = strdup(newVal); + if ( crnt == iter->head) { + le->prev = NULL; + le->next = crnt->next; + crnt->next = le; + if (le->next) + le->next->prev = le; + else + crnt->prev = le; + } + else { + le->prev = ( crnt == NULL)? iter->head->prev : crnt->prev; + le->next = crnt; + if (le->prev) + le->prev->next = le; + else + iter->head->next = le; + if (crnt) + crnt->prev = le; + else + iter->head->prev = le; + } + } + return (le!= NULL); +} + +LIterator LL_GetIterator(LinkedList ll ) +{ + LIterator liter = malloc(sizeof(struct sListIterator)); + liter->head = ll; + liter->link = ll; + return liter; +} + +#define LLI_Delete( iter ) \ + {free(iter); \ + iter = NULL;} + +int LLI_AtEnd(LIterator iter) +{ + return iter->link == NULL; +} +const char *LLI_Value(LIterator iter) +{ + return (iter->link)? iter->link->value: NULL; +} +int LLI_Next(LIterator iter) +{ + if (iter->link) iter->link = iter->link->next; + return(iter->link != NULL); +} +int LLI_Prev(LIterator iter) +{ + if (iter->link) iter->link = iter->link->prev; + return(iter->link != NULL); +} + +int main() +{ + static const char *contents[] = {"Read", "Orage", "Yeller", + "Glean", "Blew", "Burple"}; + int ix; + LinkedList ll = NewList(); //new linked list + LIterator iter; + + for (ix=0; ix<6; ix++) //insert contents + LL_Append(ll, contents[ix]); + + iter = LL_GetIterator(ll); //get an iterator + printf("forward\n"); + while(LLI_Next(iter)) //iterate forward + printf("value=%s\n", LLI_Value(iter)); + LLI_Delete(iter); //delete iterator + + printf("\nreverse\n"); + iter = LL_GetIterator(ll); + while(LLI_Prev(iter)) //iterate reverse + printf("value=%s\n", LLI_Value(iter)); + LLI_Delete(iter); + //uhhh-- delete list?? + return 0; +} diff --git a/Task/Doubly-linked-list-Traversal/Clojure/doubly-linked-list-traversal.clj b/Task/Doubly-linked-list-Traversal/Clojure/doubly-linked-list-traversal.clj new file mode 100644 index 0000000000..850122811a --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/Clojure/doubly-linked-list-traversal.clj @@ -0,0 +1,18 @@ +(def dl (double-list [:a :b :c :d])) +;=> #'user/dl + +((juxt seq rseq) dl) +;=> [(:a :b :c :d) (:d :c :b :a)] + +(take-while identity (iterate get-next (get-head dl))) +;=> (#:double_list.Node{:prev nil, :next #, :data :a, :key #} +;=> #:double_list.Node{:prev #, :next #, :data :b, :key #} +;=> #:double_list.Node{:prev #, :next #, :data :c, :key #} +;=> #:double_list.Node{:prev #, :next nil, :data :d, :key #}) + +(take-while identity (iterate get-prev (get-tail dl))) + +;=> (#:double_list.Node{:prev #, :next nil, :data :d, :key #} +;=> #:double_list.Node{:prev #, :next #, :data :c, :key #} +;=> #:double_list.Node{:prev #, :next #, :data :b, :key #} +;=> #:double_list.Node{:prev nil, :next #, :data :a, :key #}) diff --git a/Task/Doubly-linked-list-Traversal/D/doubly-linked-list-traversal.d b/Task/Doubly-linked-list-Traversal/D/doubly-linked-list-traversal.d new file mode 100644 index 0000000000..d0114def0a --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/D/doubly-linked-list-traversal.d @@ -0,0 +1,42 @@ +import std.stdio; + +struct Node(T) { + T data; + Node* prev, next; + + this(T data_, Node* prev_=null, Node* next_=null) { + data = data_; + prev = prev_; + next = next_; + } +} + +void prepend(T)(ref Node!(T)* head, T item) { + auto newNode = new Node!T(item, null, head); + if (head) + head.prev = newNode; + head = newNode; +} + +void main() { + Node!(string)* head; + prepend(head, "D"); + prepend(head, "C"); + prepend(head, "B"); + prepend(head, "A"); + + auto p = head; + auto last = p; + while (p) { + write(p.data, " "); + last = p; + p = p.next; + } + writeln(); + + while (last) { + write(last.data, " "); + last = last.prev; + } + writeln(); +} diff --git a/Task/Doubly-linked-list-Traversal/Delphi/doubly-linked-list-traversal.delphi b/Task/Doubly-linked-list-Traversal/Delphi/doubly-linked-list-traversal.delphi new file mode 100644 index 0000000000..b9ad57e46d --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/Delphi/doubly-linked-list-traversal.delphi @@ -0,0 +1,26 @@ +uses system ; + +type + + // declare the list pointer type + plist = ^List ; + + // declare the list type, a generic data pointer prev and next pointers + List = record + data : pointer ; + prev : pList ; + next : pList ; + end; + +// since this task is just showing the traversal I am not allocating the memory and setting up the root node etc. +// Note the use of the carat symbol for de-referencing the pointer. + +begin + + // beginning to end + while not (pList^.Next = NIL) do pList := pList^.Next ; + + // end to beginning + while not (pList^.prev = NIL) do pList := pList^.prev ; + +end; diff --git a/Task/Doubly-linked-list-Traversal/E/doubly-linked-list-traversal-1.e b/Task/Doubly-linked-list-Traversal/E/doubly-linked-list-traversal-1.e new file mode 100644 index 0000000000..37a45a124d --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/E/doubly-linked-list-traversal-1.e @@ -0,0 +1,19 @@ +def traverse(list) { + var node := list.atFirst() + while (true) { + println(node[]) + if (node.hasNext()) { + node := node.next() + } else { + break + } + } + while (true) { + println(node[]) + if (node.hasPrev()) { + node := node.prev() + } else { + break + } + } +} diff --git a/Task/Doubly-linked-list-Traversal/E/doubly-linked-list-traversal-2.e b/Task/Doubly-linked-list-Traversal/E/doubly-linked-list-traversal-2.e new file mode 100644 index 0000000000..4a2ce20702 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/E/doubly-linked-list-traversal-2.e @@ -0,0 +1,14 @@ +? def list := makeDLList() +# value: <> + +? list.push(1) +? list.push(2) +? list.push(3) + +? traverse(list) +1 +2 +3 +3 +2 +1 diff --git a/Task/Doubly-linked-list-Traversal/Fortran/doubly-linked-list-traversal.f b/Task/Doubly-linked-list-Traversal/Fortran/doubly-linked-list-traversal.f new file mode 100644 index 0000000000..f04c1668f3 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/Fortran/doubly-linked-list-traversal.f @@ -0,0 +1,48 @@ +class DoubleLink (value, prev_link, next_link) + + # insert given node after this one, removing its existing connections + method insert_after (node) + node.prev_link := self + if (\next_link) then next_link.prev_link := node + node.next_link := next_link + self.next_link := node + end + + # use a generator to traverse + # - keep suspending the prev/next link until a null node is reached + method traverse_backwards () + current := self + while \current do { + suspend current + current := current.prev_link + } + end + + method traverse_forwards () + current := self + while \current do { + suspend current + current := current.next_link + } + end + + initially (value, prev_link, next_link) + self.value := value + self.prev_link := prev_link # links are 'null' if not given + self.next_link := next_link +end + +procedure main () + l1 := DoubleLink (1) + l2 := DoubleLink (2) + l1.insert_after (l2) + l1.insert_after (DoubleLink (3)) + + write ("Traverse from beginning to end") + every (node := l1.traverse_forwards ()) do + write (node.value) + + write ("Traverse from end to beginning") + every (node := l2.traverse_backwards ()) do + write (node.value) +end diff --git a/Task/Doubly-linked-list-Traversal/Go/doubly-linked-list-traversal.go b/Task/Doubly-linked-list-Traversal/Go/doubly-linked-list-traversal.go new file mode 100644 index 0000000000..66465ad999 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/Go/doubly-linked-list-traversal.go @@ -0,0 +1,62 @@ +package main + +import "fmt" + +type dlNode struct { + string + next, prev *dlNode +} + +type dlList struct { + head, tail *dlNode +} + +func (list *dlList) String() string { + if list.head == nil { + return fmt.Sprint(list.head) + } + r := "[" + list.head.string + for p := list.head.next; p != nil; p = p.next { + r += " " + p.string + } + return r + "]" +} + +func (list *dlList) insertTail(node *dlNode) { + if list.tail == nil { + list.head = node + } else { + list.tail.next = node + } + node.next = nil + node.prev = list.tail + list.tail = node +} + +func (list *dlList) insertAfter(existing, insert *dlNode) { + insert.prev = existing + insert.next = existing.next + existing.next.prev = insert + existing.next = insert + if existing == list.tail { + list.tail = insert + } +} + +func main() { + dll := &dlList{} + fmt.Println(dll) + a := &dlNode{string: "A"} + dll.insertTail(a) + dll.insertTail(&dlNode{string: "B"}) + fmt.Println(dll) + dll.insertAfter(a, &dlNode{string: "C"}) + fmt.Println(dll) + + // traverse from end to beginning + fmt.Print("From tail:") + for p := dll.tail; p != nil; p = p.prev { + fmt.Print(" ", p.string) + } + fmt.Println("") +} diff --git a/Task/Doubly-linked-list-Traversal/Haskell/doubly-linked-list-traversal.hs b/Task/Doubly-linked-list-Traversal/Haskell/doubly-linked-list-traversal.hs new file mode 100644 index 0000000000..29165518ee --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/Haskell/doubly-linked-list-traversal.hs @@ -0,0 +1,19 @@ +main = print . traverse True $ create [10,20,30,40] + +data DList a = Leaf | Node { prev::(DList a), elt::a, next::(DList a) } + +create = go Leaf + where go _ [] = Leaf + go prev (x:xs) = current + where current = Node prev x next + next = go current xs + +isLeaf Leaf = True +isLeaf _ = False + +lastNode Leaf = Leaf +lastNode dl = until (isLeaf.next) next dl + +traverse _ Leaf = [] +traverse True (Node l v Leaf) = v : v : traverse False l +traverse dir (Node l v r) = v : traverse dir (if dir then r else l) diff --git a/Task/Doubly-linked-list-Traversal/Java/doubly-linked-list-traversal.java b/Task/Doubly-linked-list-Traversal/Java/doubly-linked-list-traversal.java new file mode 100644 index 0000000000..7cf86c7f72 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/Java/doubly-linked-list-traversal.java @@ -0,0 +1,13 @@ +import java.util.LinkedList; + +public static void main(){ + LinkedList LL = new LinkedList(); + traverse(LL.iterator()); + traverse(LL.descendingIterator()); +} + +private static void traverse(Iterator iter){ + while(iter.hasNext()){ + iter.next(); + } +} diff --git a/Task/Doubly-linked-list-Traversal/JavaScript/doubly-linked-list-traversal.js b/Task/Doubly-linked-list-Traversal/JavaScript/doubly-linked-list-traversal.js new file mode 100644 index 0000000000..75ee4f2b25 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/JavaScript/doubly-linked-list-traversal.js @@ -0,0 +1,17 @@ +DoublyLinkedList.prototype.getTail = function() { + var tail; + this.traverse(function(node){tail = node;}); + return tail; +} +DoublyLinkedList.prototype.traverseBackward = function(func) { + func(this); + if (this.prev() != null) + this.prev().traverseBackward(func); +} +DoublyLinkedList.prototype.printBackward = function() { + this.traverseBackward( function(node) {print(node.value())} ); +} + +var head = createDoublyLinkedListFromArray([10,20,30,40]); +head.print(); +head.getTail().printBackward(); diff --git a/Task/Doubly-linked-list-Traversal/PicoLisp/doubly-linked-list-traversal.l b/Task/Doubly-linked-list-Traversal/PicoLisp/doubly-linked-list-traversal.l new file mode 100644 index 0000000000..6ba4649336 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/PicoLisp/doubly-linked-list-traversal.l @@ -0,0 +1,11 @@ +# Print the elements a doubly-linked list +(de 2print (DLst) + (for (L (car DLst) L (cddr L)) + (printsp (car L)) ) + (prinl) ) + +# Print the elements a doubly-linked list in reverse order +(de 2printReversed (DLst) + (for (L (cdr DLst) L (cadr L)) + (printsp (car L)) ) + (prinl) ) diff --git a/Task/Doubly-linked-list-Traversal/Python/doubly-linked-list-traversal-1.py b/Task/Doubly-linked-list-Traversal/Python/doubly-linked-list-traversal-1.py new file mode 100644 index 0000000000..acad6cda24 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/Python/doubly-linked-list-traversal-1.py @@ -0,0 +1,29 @@ +class List: + def __init__(self, data, next=None, prev=None): + self.data = data + self.next = next + self.prev = prev + + def append(self, data): + if self.next == None: + self.next = List(data, None, self) + return self.next + else: + return self.next.append(data) + +# Build the list +tail = head = List(10) +for i in [ 20, 30, 40 ]: + tail = tail.append(i) + +# Traverse forwards +node = head +while node != None: + print(node.data) + node = node.next + +# Traverse Backwards +node = tail +while node != None: + print(node.data) + node = node.prev diff --git a/Task/Doubly-linked-list-Traversal/Python/doubly-linked-list-traversal-2.py b/Task/Doubly-linked-list-Traversal/Python/doubly-linked-list-traversal-2.py new file mode 100644 index 0000000000..e82087c1ae --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/Python/doubly-linked-list-traversal-2.py @@ -0,0 +1,5 @@ +l = [ 10, 20, 30, 40 ] +for i in l: + print(i) +for i in reversed(l): # reversed produces an iterator, so only O(1) memory is used + print(i) diff --git a/Task/Doubly-linked-list-Traversal/REXX/doubly-linked-list-traversal.rexx b/Task/Doubly-linked-list-Traversal/REXX/doubly-linked-list-traversal.rexx new file mode 100644 index 0000000000..d7744b6517 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/REXX/doubly-linked-list-traversal.rexx @@ -0,0 +1,79 @@ +/*REXX program that implements various List Manager functions. */ +/*┌────────────────────────────────────────────────────────────────────┐ +┌─┘ Functions of the List Manager └─┐ +│ │ +│ @init ─── initializes the List. │ +│ │ +│ @size ─── returns the size of the List [could be 0 (zero)]. │ +│ │ +│ @show ─── shows (displays) the complete List. │ +│ @show k,1 ─── shows (displays) the Kth item. │ +│ @show k,m ─── shows (displays) M items, starting with Kth item. │ +│ @show ,,─1 ─── shows (displays) the complete List backwards. │ +│ │ +│ @get k ─── returns the Kth item. │ +│ @get k,m ─── returns the M items starting with the Kth item. │ +│ │ +│ @put x ─── adds the X items to the end (tail) of the List. │ +│ @put x,0 ─── adds the X items to the start (head) of the List. │ +│ @put x,k ─── adds the X items to before of the Kth item. │ +│ │ +│ @del k ─── deletes the item K. │ +│ @del k,m ─── deletes the M items starting with item K. │ +└─┐ ┌─┘ + └────────────────────────────────────────────────────────────────────┘*/ +call sy 'initializing the list.' ; call @init +call sy 'building list: Was it a cat I saw'; call @put 'Was it a cat I saw' +call sy 'displaying list size.' ; say 'list size='@size() +call sy 'forward list' ; call @show +call sy 'backward list' ; call @show ,,-1 +call sy 'showing 4th item' ; call @show 4,1 +call sy 'showing 6th & 6th items' ; call @show 5,2 +call sy 'adding item before item 4: black' ; call @put 'black',4 +call sy 'showing list' ; call @show +call sy 'adding to tail: there, in the ...'; call @put 'there, in the shadows, stalking its prey (and next meal).' +call sy 'showing list' ; call @show +call sy 'adding to head: Oy!' ; call @put 'Oy!',0 +call sy 'showing list' ; call @show +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────subroutines─────────────────────────*/ +p: return word(arg(1),1) +sy: say; say left('',30) "───" arg(1) '───'; return +@hasopt: arg o; return pos(o,opt)\==0 +@size: return $.# +@init: $.@=''; $.#=0; return 0 +@adjust: $.@=space($.@); $.#=words($.@); return 0 + +@parms: arg opt + if @hasopt('k') then k=min($.#+1,max(1,p(k 1))) + if @hasopt('m') then m=p(m 1) + if @hasopt('d') then dir=p(dir 1) + return + +@show: procedure expose $.; parse arg k,m,dir + if dir==-1 & k=='' then k=$.# + m=p(m $.#); + call @parms 'kmd' + say @get(k,m,dir); + return 0 + +@get: procedure expose $.; arg k,m,dir,_ + call @parms 'kmd' + do j=k for m by dir while j>0 & j<=$.# + _=_ subword($.@,j,1) + end /*j*/ + return strip(_) + +@put: procedure expose $.; parse arg x,k + k=p(k $.#+1) + call @parms 'k' + $.@=subword($.@,1,max(0,k-1)) x subword($.@,k) + call @adjust + return 0 + +@del: procedure expose $.; arg k,m + call @parms 'km' + _=subword($.@,k,k-1) subword($.@,k+m) + $.@=_ + call @adjust + return diff --git a/Task/Doubly-linked-list-Traversal/Ruby/doubly-linked-list-traversal.rb b/Task/Doubly-linked-list-Traversal/Ruby/doubly-linked-list-traversal.rb new file mode 100644 index 0000000000..f842962227 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/Ruby/doubly-linked-list-traversal.rb @@ -0,0 +1,15 @@ +class DListNode + def get_tail + # parent class (ListNode) includes Enumerable, so the find method is available to us + self.find {|node| node.succ.nil?} + end + + def each_previous(&b) + yield self + self.prev.each_previous(&b) if self.prev + end +end + +head = DListNode.from_array([:a, :b, :c]) +head.each {|node| p node.value} +head.get_tail.each_previous {|node| p node.value} diff --git a/Task/Doubly-linked-list-Traversal/Tcl/doubly-linked-list-traversal.tcl b/Task/Doubly-linked-list-Traversal/Tcl/doubly-linked-list-traversal.tcl new file mode 100644 index 0000000000..13b7eff8a1 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/Tcl/doubly-linked-list-traversal.tcl @@ -0,0 +1,24 @@ +# Modify the List class to add the iterator methods +oo::define List { + method foreach {varName script} { + upvar 1 $varName v + for {set node [self]} {$node ne ""} {set node [$node next]} { + set v [$node value] + uplevel 1 $script + } + } + method revforeach {varName script} { + upvar 1 $varName v + for {set node [self]} {$node ne ""} {set node [$node previous]} { + set v [$node value] + uplevel 1 $script + } + } +} + +# Demonstrating... +set first [List new a [List new b [List new c [set last [List new d]]]]] +puts "Forward..." +$first foreach char { puts $char } +puts "Backward..." +$last revforeach char { puts $char } diff --git a/Task/Draw-a-cuboid/0DESCRIPTION b/Task/Draw-a-cuboid/0DESCRIPTION new file mode 100644 index 0000000000..d9c45e5366 --- /dev/null +++ b/Task/Draw-a-cuboid/0DESCRIPTION @@ -0,0 +1 @@ +The task is to draw a cuboid with relative dimensions of 2x3x4. The cuboid can be represented graphically, or in ascii art, depending on the language capabilities. To fulfil the criteria of being a cuboid, three faces must be visible. Either static or rotational projection is acceptable for this task. diff --git a/Task/Draw-a-cuboid/1META.yaml b/Task/Draw-a-cuboid/1META.yaml new file mode 100644 index 0000000000..15987484ad --- /dev/null +++ b/Task/Draw-a-cuboid/1META.yaml @@ -0,0 +1,4 @@ +--- +note: Geometric Primitives +requires: +- Graphics diff --git a/Task/Draw-a-cuboid/Ada/draw-a-cuboid.ada b/Task/Draw-a-cuboid/Ada/draw-a-cuboid.ada new file mode 100644 index 0000000000..8c95bac239 --- /dev/null +++ b/Task/Draw-a-cuboid/Ada/draw-a-cuboid.ada @@ -0,0 +1,55 @@ +with Ada.Text_IO; + +procedure Main is + type Char_Matrix is + array (Positive range <>, Positive range <>) of Character; + + function Create_Cuboid + (Width, Height, Depth : Positive) + return Char_Matrix + is + Result : Char_Matrix (1 .. Height + Depth + 3, + 1 .. 2 * Width + Depth + 3) := (others => (others => ' ')); + begin + -- points + Result (1, 1) := '+'; + Result (Height + 2, 1) := '+'; + Result (1, 2 * Width + 2) := '+'; + Result (Height + 2, 2 * Width + 2) := '+'; + Result (Height + Depth + 3, Depth + 2) := '+'; + Result (Depth + 2, 2 * Width + Depth + 3) := '+'; + Result (Height + Depth + 3, 2 * Width + Depth + 3) := '+'; + -- width lines + for I in 1 .. 2 * Width loop + Result (1, I + 1) := '-'; + Result (Height + 2, I + 1) := '-'; + Result (Height + Depth + 3, Depth + I + 2) := '-'; + end loop; + -- height lines + for I in 1 .. Height loop + Result (I + 1, 1) := '|'; + Result (I + 1, 2 * Width + 2) := '|'; + Result (Depth + I + 2, 2 * Width + Depth + 3) := '|'; + end loop; + -- depth lines + for I in 1 .. Depth loop + Result (Height + 2 + I, 1 + I) := '/'; + Result (1 + I, 2 * Width + 2 + I) := '/'; + Result (Height + 2 + I, 2 * Width + 2 + I) := '/'; + end loop; + return Result; + end Create_Cuboid; + + procedure Print_Cuboid (Width, Height, Depth : Positive) is + Cuboid : Char_Matrix := Create_Cuboid (Width, Height, Depth); + begin + for Row in reverse Cuboid'Range (1) loop + for Col in Cuboid'Range (2) loop + Ada.Text_IO.Put (Cuboid (Row, Col)); + end loop; + Ada.Text_IO.New_Line; + end loop; + end Print_Cuboid; +begin + Print_Cuboid (2, 3, 4); +end Main; diff --git a/Task/Draw-a-cuboid/BBC-BASIC/draw-a-cuboid.bbc b/Task/Draw-a-cuboid/BBC-BASIC/draw-a-cuboid.bbc new file mode 100644 index 0000000000..fbdeb4b944 --- /dev/null +++ b/Task/Draw-a-cuboid/BBC-BASIC/draw-a-cuboid.bbc @@ -0,0 +1,10 @@ + ORIGIN 100, 100 + PROCcuboid(200, 300, 400) + END + + DEF PROCcuboid(x, y, z) + MOVE 0, 0 : MOVE 0, y + GCOL 1 : PLOT 117, x, y + GCOL 2 : PLOT 117, x + z * 0.4, y + z * 0.4 + GCOL 4 : PLOT 117, x + z * 0.4, z * 0.4 + ENDPROC diff --git a/Task/Draw-a-cuboid/Brlcad/draw-a-cuboid.brlcad b/Task/Draw-a-cuboid/Brlcad/draw-a-cuboid.brlcad new file mode 100644 index 0000000000..197ad98e67 --- /dev/null +++ b/Task/Draw-a-cuboid/Brlcad/draw-a-cuboid.brlcad @@ -0,0 +1,3 @@ +opendb cuboid.g y # Create a database to hold our shapes +units cm # Set the unit of measure +in cuboid.s rpp 0 2 0 3 0 4 # Create a 2 x 3 x 4 cuboid named cuboid.s diff --git a/Task/Draw-a-cuboid/C/draw-a-cuboid-1.c b/Task/Draw-a-cuboid/C/draw-a-cuboid-1.c new file mode 100644 index 0000000000..dee16bab57 --- /dev/null +++ b/Task/Draw-a-cuboid/C/draw-a-cuboid-1.c @@ -0,0 +1,136 @@ +#include +#include +#include + +const char *shades = ".:!*oe&#%@"; + +void vsub(double *v1, double *v2, double *s) { + s[0] = v1[0] - v2[0]; + s[1] = v1[1] - v2[1]; + s[2] = v1[2] - v2[2]; +} + +double normalize(double * v) { + double len = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + v[0] /= len; v[1] /= len; v[2] /= len; + return len; +} + +double dot(double *x, double *y) { + return x[0]*y[0] + x[1]*y[1] + x[2]*y[2]; +} + +double * cross(double x[3], double y[3], double s[3]) { + s[0] = x[1] * y[2] - x[2] * y[1]; + s[1] = x[2] * y[0] - x[0] * y[2]; + s[2] = x[0] * y[1] - x[1] * y[0]; + return s; +} + +double* madd(double *x, double *y, double d, double *r) { + r[0] = x[0] + y[0] * d; + r[1] = x[1] + y[1] * d; + r[2] = x[2] + y[2] * d; + return r; +} + +double v000[] = { -4, -3, -2 }; +double v100[] = { 4, -3, -2 }; +double v010[] = { -4, 3, -2 }; +double v110[] = { 4, 3, -2 }; +double v001[] = { -4, -3, 2 }; +double v101[] = { 4, -3, 2 }; +double v011[] = { -4, 3, 2 }; +double v111[] = { 4, 3, 2 }; + +typedef struct { + double * v[4]; + double norm[3]; +} face_t; + +face_t f[] = { + { { v000, v010, v110, v100 }, { 0, 0, -1 } }, + { { v001, v011, v111, v101 }, { 0, 0, 1 } }, + { { v000, v010, v011, v001 }, { -1, 0, 0 } }, + { { v100, v110, v111, v101 }, { 1, 0, 0 } }, + { { v000, v100, v101, v001 }, { 0, -1, 0 } }, + { { v010, v110, v111, v011 }, { 0, 1, 0 } }, +}; + +int in_range(double x, double x0, double x1) { + return (x - x0) * (x - x1) <= 0; +} + +int face_hit(face_t *face, double src[3], double dir[3], double hit[3], double *d) +{ + int i; + double dist; + for (i = 0; i < 3; i++) + if (face->norm[i]) + dist = (face->v[0][i] - src[i]) / dir[i]; + + madd(src, dir, dist, hit); + *d = fabs(dot(dir, face->norm) * dist); + + if (face->norm[0]) { + return in_range(hit[1], face->v[0][1], face->v[2][1]) && + in_range(hit[2], face->v[0][2], face->v[2][2]); + } + else if (face->norm[1]) { + return in_range(hit[0], face->v[0][0], face->v[2][0]) && + in_range(hit[2], face->v[0][2], face->v[2][2]); + } + else if (face->norm[2]) { + return in_range(hit[0], face->v[0][0], face->v[2][0]) && + in_range(hit[1], face->v[0][1], face->v[2][1]); + } + return 0; +} + +int main() +{ + int i, j, k; + double eye[3] = { 7, 7, 6 }; + double dir[3] = { -1, -1, -1 }, orig[3] = {0, 0, 0}; + double hit[3], dx[3], dy[3] = {0, 0, 1}, proj[3]; + double d, *norm, dbest, b; + double light[3] = { 6, 8, 6 }, ldist[3], decay, strength = 10; + + normalize(cross(eye, dy, dx)); + normalize(cross(eye, dx, dy)); + + for (i = -10; i <= 17; i++) { + for (j = -35; j < 35; j++) { + vsub(orig, orig, proj); + madd(madd(proj, dx, j / 6., proj), dy, i/3., proj); + vsub(proj, eye, dir); + dbest = 1e100; + norm = 0; + for (k = 0; k < 6; k++) { + if (!face_hit(f + k, eye, dir, hit, &d)) continue; + if (dbest > d) { + dbest = d; + norm = f[k].norm; + } + } + + if (!norm) { + putchar(' '); + continue; + } + + vsub(light, hit, ldist); + decay = normalize(ldist); + b = dot(norm, ldist) / decay * strength; + if (b < 0) b = 0; + else if (b > 1) b = 1; + b += .2; + if (b > 1) b = 0; + else b = 1 - b; + putchar(shades[(int)(b * (sizeof(shades) - 2))]); + } + putchar('\n'); + } + + return 0; +} diff --git a/Task/Draw-a-cuboid/C/draw-a-cuboid-2.c b/Task/Draw-a-cuboid/C/draw-a-cuboid-2.c new file mode 100644 index 0000000000..01aa465244 --- /dev/null +++ b/Task/Draw-a-cuboid/C/draw-a-cuboid-2.c @@ -0,0 +1,28 @@ + * + **************!! + *************!!!!!!!!!!!!!!!!!! + ooo************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + *oooo***********!!!!!!!!!!!!!!!!!::::::::::::::::::::!!! + o*************!!!!!!!!!!!!::::::::::::::::::::::::::::::::::::: + o****!!****!!!!!!!!!!:::::::::::::::::::::::::::::::::::::::::&& + oo****!!!!:!!!!!!!::::::::::::::::.................::::::::e&&& + o*****!!!!:::!!!:::::::::::............................eee&&&& + oo*****!!!!:::...:::::::.............................eeeee&&& + oo*****!!!!:::.....::............................oeeeeee&&& + ooo*****!!!!:::...............................ooooeeeee&&&& + ooo*****!!!!:::...........................ooooooeeeeee&&& + oooo*****!!!!::::......................**ooooooeeeeee&&&& + ooo*****!!!!::::..................****ooooooeeeeee&&&& + oo*****!!!!::::...............*****oooooooeeeeee&&&& + o*****!!!!::::..............****oooooooeeeeee&&&& + *****!!!!:::::............***oooooooeeeeee&&& + ***!!!!!::::...........**oooooooeeeeee&& + ***!!!!:::::.........ooooooooeeeeeee + **!!!!!::::........oooooooeeeeee + *!!!!!:::::.....oooooooeeeee + !!!!!::::....oooooeeeee + !!!!:::::..ooooeeeee + !!!!:::::oooeeee + !!!!:::oeeee + !!!::eee + !ee diff --git a/Task/Draw-a-cuboid/D/draw-a-cuboid.d b/Task/Draw-a-cuboid/D/draw-a-cuboid.d new file mode 100644 index 0000000000..eda303db4b --- /dev/null +++ b/Task/Draw-a-cuboid/D/draw-a-cuboid.d @@ -0,0 +1,27 @@ +import std.stdio, std.array; + +void printCuboid(in int dx, in int dy, in int dz) { + static cline(in int n, in int dx, in int dy, in string cde) { + writef("%*s", n+1, cde[0 .. 1]); + write(cde[1 .. 2].replicate(9*dx - 1)); + write(cde[0]); + writefln("%*s", dy+1, cde[2 .. $]); + } + + cline(dy+1, dx, 0, "+-"); + foreach (i; 1 .. dy+1) + cline(dy-i+1, dx, i-1, "/ |"); + cline(0, dx, dy, "+-|"); + foreach (_; 0 .. 4*dz - dy - 2) + cline(0, dx, dy, "| |"); + cline(0, dx, dy, "| +"); + foreach_reverse (i; 0 .. dy) + cline(0, dx, i, "| /"); + cline(0, dx, 0, "+-\n"); +} + +void main() { + printCuboid(2, 3, 4); + printCuboid(1, 1, 1); + printCuboid(6, 2, 1); +} diff --git a/Task/Draw-a-cuboid/Go/draw-a-cuboid.go b/Task/Draw-a-cuboid/Go/draw-a-cuboid.go new file mode 100644 index 0000000000..e0d6cd5da1 --- /dev/null +++ b/Task/Draw-a-cuboid/Go/draw-a-cuboid.go @@ -0,0 +1,35 @@ +package main + +import "fmt" + +func cuboid(dx, dy, dz int) { + fmt.Printf("cuboid %d %d %d:\n", dx, dy, dz) + cubLine(dy+1, dx, 0, "+-") + for i := 1; i <= dy; i++ { + cubLine(dy-i+1, dx, i-1, "/ |") + } + cubLine(0, dx, dy, "+-|") + for i := 4*dz - dy - 2; i > 0; i-- { + cubLine(0, dx, dy, "| |") + } + cubLine(0, dx, dy, "| +") + for i := 1; i <= dy; i++ { + cubLine(0, dx, dy-i, "| /") + } + cubLine(0, dx, 0, "+-\n") +} + +func cubLine(n, dx, dy int, cde string) { + fmt.Printf("%*s", n+1, cde[:1]) + for d := 9*dx - 1; d > 0; d-- { + fmt.Print(cde[1:2]) + } + fmt.Print(cde[:1]) + fmt.Printf("%*s\n", dy+1, cde[2:]) +} + +func main() { + cuboid(2, 3, 4) + cuboid(1, 1, 1) + cuboid(6, 2, 1) +} diff --git a/Task/Draw-a-cuboid/Haskell/draw-a-cuboid.hs b/Task/Draw-a-cuboid/Haskell/draw-a-cuboid.hs new file mode 100644 index 0000000000..7cdc3b212d --- /dev/null +++ b/Task/Draw-a-cuboid/Haskell/draw-a-cuboid.hs @@ -0,0 +1,60 @@ +import Graphics.Rendering.OpenGL +import Graphics.UI.GLUT + +-- Draw a cuboid. Its vertices are those of a unit cube, which is then scaled +-- to the required dimensions. We only specify the visible faces, each of +-- which is composed of two triangles. The faces are rotated into position and +-- rendered with a perspective transformation. + +type Fl = GLfloat + +cuboid :: IO () +cuboid = do + color red ; render front + color green ; render side + color blue ; render top + +red,green,blue :: Color4 GLfloat +red = Color4 1 0 0 1 +green = Color4 0 1 0 1 +blue = Color4 0 0 1 1 + +render :: [(Fl, Fl, Fl)] -> IO () +render = renderPrimitive TriangleStrip . mapM_ toVertex + where toVertex (x,y,z) = vertex $ Vertex3 x y z + +front,side,top :: [(Fl,Fl,Fl)] +front = vertices [0,1,2,3] +side = vertices [4,1,5,3] +top = vertices [3,2,5,6] + +vertices :: [Int] -> [(Fl,Fl,Fl)] +vertices = map (verts !!) + +verts :: [(Fl,Fl,Fl)] +verts = [(0,0,1), (1,0,1), (0,1,1), (1,1,1), (1,0,0), (1,1,0), (0,1,0)] + +transform :: IO () +transform = do + translate $ Vector3 0 0 (-10 :: Fl) + rotate (-14) $ Vector3 0 0 (1 :: Fl) + rotate (-30) $ Vector3 0 1 (0 :: Fl) + rotate 25 $ Vector3 1 0 (0 :: Fl) + scale 2 3 (4 :: Fl) + translate $ Vector3 (-0.5) (-0.5) (-0.5 :: Fl) + +display :: IO () +display = do + clear [ColorBuffer] + perspective 40 1 1 (15 :: GLdouble) + transform + cuboid + flush + +main :: IO () +main = do + let name = "Cuboid" + initialize name [] + createWindow name + displayCallback $= display + mainLoop diff --git a/Task/Draw-a-cuboid/Perl/draw-a-cuboid-1.pl b/Task/Draw-a-cuboid/Perl/draw-a-cuboid-1.pl new file mode 100644 index 0000000000..f890b06a11 --- /dev/null +++ b/Task/Draw-a-cuboid/Perl/draw-a-cuboid-1.pl @@ -0,0 +1,38 @@ +sub cubLine ($$$$) { + my ($n, $dx, $dy, $cde) = @_; + + printf '%*s', $n + 1, substr($cde, 0, 1); + + for (my $d = 9 * $dx - 1 ; $d > 0 ; --$d) { + print substr($cde, 1, 1); + } + + print substr($cde, 0, 1); + printf "%*s\n", $dy + 1, substr($cde, 2, 1); +} + +sub cuboid ($$$) { + my ($dx, $dy, $dz) = @_; + + printf "cuboid %d %d %d:\n", $dx, $dy, $dz; + cubLine $dy + 1, $dx, 0, '+-'; + + for (my $i = 1 ; $i <= $dy ; ++$i) { + cubLine $dy - $i + 1, $dx, $i - 1, '/ |'; + } + cubLine 0, $dx, $dy, '+-|'; + + for (my $i = 4 * $dz - $dy - 2 ; $i > 0 ; --$i) { + cubLine 0, $dx, $dy, '| |'; + } + cubLine 0, $dx, $dy, '| +'; + + for (my $i = 1 ; $i <= $dy ; ++$i) { + cubLine 0, $dx, $dy - $i, '| /'; + } + cubLine 0, $dx, 0, "+-\n"; +} + +cuboid 2, 3, 4; +cuboid 1, 1, 1; +cuboid 6, 2, 1; diff --git a/Task/Draw-a-cuboid/Perl/draw-a-cuboid-2.pl b/Task/Draw-a-cuboid/Perl/draw-a-cuboid-2.pl new file mode 100644 index 0000000000..ded3fe56ef --- /dev/null +++ b/Task/Draw-a-cuboid/Perl/draw-a-cuboid-2.pl @@ -0,0 +1,34 @@ +use 5.010; + +sub cuboid { + + # Constant dimnesions of the cuboid + my ($x, $y, $z) = map int, @_[0 .. 2]; + + # ASCII characters + # $c = corner point + # $h = horizontal line + # $v = vertical line + # $d = diagonal line + # $s = space (inside the cuboid) + my ($c, $h, $v, $d, $s) = ('+', '-', '|', '/', shift(@ARGV) // q{ }); + + # Some variables + my ($p, $o) = (0, 0); + + say q{ } x ($z + 1), $c, $h x $x, $c; + say q{ } x ($z - $_ + 1), $d, $s x $x, $d, $s x ($_ - 1 - $p), + $_ > $y ? !$p && ++$p ? do { $o = $z - $y; $c } : $p++ ? $d : $c : $v + for 1 .. $z; + say $c, $h x $x, $c, $p ? ($s x ($z - $o), $d) : ($s x $z, $z < $y ? $v : $c); + say $v, $s x $x, $v, $z - 1 >= $y + ? $_ >= $z + ? ($s x $x, $c) + : ($s x ($z - $_ - $o), $d) + : $y - $_ > $z ? ($s x $z, $v) + : ($s x ($y - $_), $y - $_ == $z ? $c : $d) + for 1 .. $y; + say $c, $h x $x, $c; +} + +cuboid shift // rand 20, shift // rand 10, shift // rand 10; diff --git a/Task/Draw-a-cuboid/PicoLisp/draw-a-cuboid-1.l b/Task/Draw-a-cuboid/PicoLisp/draw-a-cuboid-1.l new file mode 100644 index 0000000000..e577a6147e --- /dev/null +++ b/Task/Draw-a-cuboid/PicoLisp/draw-a-cuboid-1.l @@ -0,0 +1,19 @@ +(de cuboid (DX DY DZ) + (cubLine (inc DY) "+" DX "-" 0) + (for I DY + (cubLine (- DY I -1) "/" DX " " (dec I) "|") ) + (cubLine 0 "+" DX "-" DY "|") + (do (- (* 4 DZ) DY 2) + (cubLine 0 "|" DX " " DY "|") ) + (cubLine 0 "|" DX " " DY "+") + (for I DY + (cubLine 0 "|" DX " " (- DY I) "/") ) + (cubLine 0 "+" DX "-" 0) ) + +(de cubLine (N C DX D DY E) + (space N) + (prin C) + (do (dec (* 9 DX)) (prin D)) + (prin C) + (space DY) + (prinl E) ) diff --git a/Task/Draw-a-cuboid/PicoLisp/draw-a-cuboid-2.l b/Task/Draw-a-cuboid/PicoLisp/draw-a-cuboid-2.l new file mode 100644 index 0000000000..f535a47e80 --- /dev/null +++ b/Task/Draw-a-cuboid/PicoLisp/draw-a-cuboid-2.l @@ -0,0 +1,59 @@ +(load "@lib/openGl.l") + +(setq *AngleX -26.0 *AngleY 74.0) +(setq *LastX 0 *LastY 0) + +(glutInit) +(glutInitDisplayMode (| GLUT_RGBA GLUT_DOUBLE GLUT_DEPTH)) +(glutInitWindowSize 512 512) +(glutInitWindowPosition 10 50) +(glutCreateWindow "PicoLisp Cube") + +(glClearColor 1.0 1.0 1.0 1.0) # The background color +(glEnable GL_DEPTH_TEST) +(glEnable GL_LIGHTING) +(glEnable GL_LIGHT0) +(glDisable GL_CULL_FACE) + +(glEnable GL_BLEND) +(glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA) +(glEnable GL_LINE_SMOOTH) +(glHint GL_LINE_SMOOTH_HINT GL_NICEST) +(glLineWidth 2.0) + +(mouseFunc + '((Btn State X Y) + (setq *LastX X *LastY Y) ) ) + +(motionFunc + '((X Y) + (inc '*AngleX (* (- Y *LastY) 1.0)) + (inc '*AngleY (* (- X *LastX) 1.0)) + (setq *LastX X *LastY Y) + (glutPostRedisplay) ) ) + +(reshapeFunc + '((Width Height) + (glMatrixMode GL_PROJECTION) + (glLoadIdentity) + (gluPerspective 45.0 (*/ Width 1.0 Height) 1.0 10.0) + (glMatrixMode GL_MODELVIEW) + (glViewport 0 0 Width Height) ) ) + +(displayPrg + (glClear (| GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) + (glLoadIdentity) + (glTranslatef 0.0 0.0 -3.0) + (glRotatef *AngleX 1 0 0) + (glRotatef *AngleY 0 1 0) + (glutSolidCube 1.0) + + (glDisable GL_LIGHTING) + (glColor4f 0.4 0.4 0.4 1.0) + (glutWireCube 1.002) + (glEnable GL_LIGHTING) + + (glFlush) + (glutSwapBuffers) ) + +(glutMainLoop) diff --git a/Task/Draw-a-cuboid/Prolog/draw-a-cuboid.pro b/Task/Draw-a-cuboid/Prolog/draw-a-cuboid.pro new file mode 100644 index 0000000000..daa785cf74 --- /dev/null +++ b/Task/Draw-a-cuboid/Prolog/draw-a-cuboid.pro @@ -0,0 +1,78 @@ +cuboid(D1,D2,D3) :- + W is D1 * 50, + H is D2 * 50, + D is D3 * 50, + + new(C, window(cuboid)), + + % compute the size of the window + Width is W + ceiling(sqrt(H * 48)) + 50, + Height is H + ceiling(sqrt(H * 48)) + 50, + send(C, size, new(_,size(Width,Height))), + + %compute the top-left corner of the front face of the cuboid + PX is 25, + PY is 25 + ceiling(sqrt(H * 48)), + + % colors of the faces + new(C1, colour(@default, 65535, 0, 0)), + new(C2, colour(@default, 0, 65535, 0)), + new(C3, colour(@default, 0, 0, 65535)), + + % the front face + new(B1, box(W, H)), + send(B1, fill_pattern, C1), + send(C, display,B1, point(PX, PY)), + + % the top face + new(B2, hpara(point(PX,PY), W, D, C2)), + send(C, display, B2), + + % the left face + PX1 is PX + W, + new(B3, vpara(point(PX1,PY), H, D, C3)), + send(C, display, B3), + + send(C, open). + + + +:- pce_begin_class(hpara, path, "drawing of a horizontal parallelogram"). + +initialise(P, Pos, Width, Hight, Color) :-> + send(P, send_super, initialise), + send(P, append, Pos), + H is ceiling(sqrt(Hight * 48)), + get(Pos, x, X), + get(Pos, y, Y), + X1 is X + H, + Y1 is Y - H, + send(P, append, point(X1, Y1)), + X2 is X1 + Width, + send(P, append, point(X2, Y1)), + X3 is X2 - H, + send(P, append, point(X3, Pos?y)), + send(P, append, Pos), + send(P, fill_pattern, Color). + +:- pce_end_class. + +:- pce_begin_class(vpara, path, "drawing of a vertical parallelogram"). + +initialise(P, Pos, Hight, Depth, Color) :-> + send(P, send_super, initialise), + send(P, append, Pos), + H is ceiling(sqrt(Depth * 48)), + get(Pos, x, X), + get(Pos, y, Y), + X1 is X + H, + Y1 is Y - H, + send(P, append, point(X1, Y1)), + Y2 is Y1 + Hight, + send(P, append, point(X1, Y2)), + Y3 is Y2 + H, + send(P, append, point(X, Y3)), + send(P, append, Pos), + send(P, fill_pattern, Color). + +:- pce_end_class. diff --git a/Task/Draw-a-cuboid/Python/draw-a-cuboid.py b/Task/Draw-a-cuboid/Python/draw-a-cuboid.py new file mode 100644 index 0000000000..419dba074e --- /dev/null +++ b/Task/Draw-a-cuboid/Python/draw-a-cuboid.py @@ -0,0 +1,26 @@ +def _pr(t, x, y, z): + txt = '\n'.join(''.join(t[(n,m)] for n in range(3+x+z)).rstrip() + for m in reversed(range(3+y+z))) + return txt + +def cuboid(x,y,z): + t = {(n,m):' ' for n in range(3+x+z) for m in range(3+y+z)} + xrow = ['+'] + ['%i' % (i % 10) for i in range(x)] + ['+'] + for i,ch in enumerate(xrow): + t[(i,0)] = t[(i,1+y)] = t[(1+z+i,2+y+z)] = ch + if _debug: print(_pr(t, x, y, z)) + ycol = ['+'] + ['%i' % (j % 10) for j in range(y)] + ['+'] + for j,ch in enumerate(ycol): + t[(0,j)] = t[(x+1,j)] = t[(2+x+z,1+z+j)] = ch + zdepth = ['+'] + ['%i' % (k % 10) for k in range(z)] + ['+'] + if _debug: print(_pr(t, x, y, z)) + for k,ch in enumerate(zdepth): + t[(k,1+y+k)] = t[(1+x+k,1+y+k)] = t[(1+x+k,k)] = ch + + return _pr(t, x, y, z) + + +_debug = False +if __name__ == '__main__': + for dim in ((2,3,4), (3,4,2), (4,2,3)): + print("CUBOID%r" % (dim,), cuboid(*dim), sep='\n') diff --git a/Task/Draw-a-cuboid/REXX/draw-a-cuboid.rexx b/Task/Draw-a-cuboid/REXX/draw-a-cuboid.rexx new file mode 100644 index 0000000000..750bc117a6 --- /dev/null +++ b/Task/Draw-a-cuboid/REXX/draw-a-cuboid.rexx @@ -0,0 +1,20 @@ +/*REXX program to draw a cuboid (dimensions must be positive integers).*/ +parse arg x y z indent . /*x,y,z dimensions, indentation.*/ +x=p(x 1); y=p(y x); z=p(z y); indent=p(indent 0) + + call sayer y+2 , , "+-" + do j=1 for y; call sayer y-j+2, j-1, "/ |" ; end + call sayer , y , "+-|" + do z-1; call sayer , y , "| |" ; end + call sayer , y , "| +" + do j=1 for y; call sayer , y-j, "| /" ; end + call sayer , , "+-" + +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────P subroutjne────────────────────────*/ +p: return word(arg(1),1) /*pick the first word in the list*/ +/*──────────────────────────────────SAYER subroutjne────────────────────*/ +sayer: parse arg times,a,_ /*get the arguments specified. */ +say left('',indent)right(left(_,1),pick1(times 1)) || , + copies(substr(_,2,1),4*x)left(_,1)right(substr(_,3,1),pick1(a 0)+1) +return diff --git a/Task/Draw-a-cuboid/Tcl/draw-a-cuboid-1.tcl b/Task/Draw-a-cuboid/Tcl/draw-a-cuboid-1.tcl new file mode 100644 index 0000000000..0fbe8e8853 --- /dev/null +++ b/Task/Draw-a-cuboid/Tcl/draw-a-cuboid-1.tcl @@ -0,0 +1,79 @@ +package require Tcl 8.5 +package require Tk +package require math::linearalgebra +package require math::constants + +# Helper for constructing a rectangular face in 3D +proc face {px1 py1 pz1 px2 py2 pz2 px3 py3 pz3 px4 py4 pz4 color} { + set centroidX [expr {($px1+$px2+$px3+$px4)/4.0}] + set centroidY [expr {($py1+$py2+$py3+$py4)/4.0}] + set centroidZ [expr {($pz1+$pz2+$pz3+$pz4)/4.0}] + list [list \ + [list [expr {double($px1)}] [expr {double($py1)}] [expr {double($pz1)}]] \ + [list [expr {double($px2)}] [expr {double($py2)}] [expr {double($pz2)}]] \ + [list [expr {double($px3)}] [expr {double($py3)}] [expr {double($pz3)}]] \ + [list [expr {double($px4)}] [expr {double($py4)}] [expr {double($pz4)}]]] \ + [list $centroidX $centroidY $centroidZ] \ + $color +} + +# How to make a cuboid of given size at the origin +proc makeCuboid {size} { + lassign $size x y z + list \ + [face 0 0 0 0 $y 0 $x $y 0 $x 0 0 "#800000"] \ + [face 0 0 0 0 $y 0 0 $y $z 0 0 $z "#ff8080"] \ + [face 0 0 0 $x 0 0 $x 0 $z 0 0 $z "#000080"] \ + [face $x 0 0 $x $y 0 $x $y $z $x 0 $z "#008000"] \ + [face 0 $y 0 $x $y 0 $x $y $z 0 $y $z "#80ff80"] \ + [face 0 0 $z $x 0 $z $x $y $z 0 $y $z "#8080ff"] +} + +# Project a shape onto a surface (Tk canvas); assumes that the shape's faces +# are simple and non-intersecting (i.e., it sorts by centroid z-order). +proc drawShape {surface shape} { + global projection + lassign $projection pmat poff + lassign $poff px py pz + foreach side $shape { + lassign $side points centroid color + set pc [::math::linearalgebra::matmul $pmat $centroid] + lappend sorting [list [expr {[lindex $pc 2]+$pz}] $points $color] + } + foreach side [lsort -real -decreasing -index 0 $sorting] { + lassign $side sortCriterion points color + set plotpoints {} + foreach p $points { + set p [::math::linearalgebra::matmul $pmat $p] + lappend plotpoints \ + [expr {[lindex $p 0]+$px}] [expr {[lindex $p 1]+$py}] + } + $surface create poly $plotpoints -outline {} -fill $color + } +} + +# How to construct the projection transform. +# This is instead of using a hokey hard-coded version +namespace eval transform { + namespace import ::math::linearalgebra::* + ::math::constants::constants pi + proc make {angle scale offset} { + variable pi + set c [expr {cos($angle*$pi/180)}] + set s [expr {sin($angle*$pi/180)}] + set ms [expr {-$s}] + set rotX [list {1.0 0.0 0.0} [list 0.0 $c $ms] [list 0.0 $s $c]] + set rotY [list [list $c 0.0 $s] {0.0 1.0 0.0} [list $ms 0.0 $c]] + set rotZ [list [list $c $s 0.0] [list $ms $c 0.0] {0.0 0.0 1.0}] + set mat [scale $scale [mkIdentity 3]] + set mat [matmul [matmul [matmul $mat $rotX] $rotY] $rotZ] + return [list $mat $offset] + } +} +### End of definitions + +# Put the pieces together +pack [canvas .c -width 400 -height 400] +set cuboid [makeCuboid {2 3 4}] +set projection [transform::make 15 50 {100 100 100}] +drawShape .c $cuboid diff --git a/Task/Draw-a-cuboid/Tcl/draw-a-cuboid-2.tcl b/Task/Draw-a-cuboid/Tcl/draw-a-cuboid-2.tcl new file mode 100644 index 0000000000..80aa2ee802 --- /dev/null +++ b/Task/Draw-a-cuboid/Tcl/draw-a-cuboid-2.tcl @@ -0,0 +1,11 @@ +pack [canvas .c -width 400 -height 400] +set cuboid [makeCuboid {2 3 4}] +wm protocol . WM_DELETE_WINDOW { exit } +while 1 { + incr i + .c delete all + set projection [transform::make $i 40 {150 150 100}] + drawShape .c $cuboid + update + after 50 +} diff --git a/Task/Draw-a-sphere/0DESCRIPTION b/Task/Draw-a-sphere/0DESCRIPTION new file mode 100644 index 0000000000..bf434c8e38 --- /dev/null +++ b/Task/Draw-a-sphere/0DESCRIPTION @@ -0,0 +1 @@ +The task is to draw a sphere. The sphere can be represented graphically, or in ascii art, depending on the language capabilities. Either static or rotational projection is acceptable for this task. diff --git a/Task/Draw-a-sphere/1META.yaml b/Task/Draw-a-sphere/1META.yaml new file mode 100644 index 0000000000..ca818300c2 --- /dev/null +++ b/Task/Draw-a-sphere/1META.yaml @@ -0,0 +1,3 @@ +--- +requires: +- Graphics diff --git a/Task/Draw-a-sphere/Ada/draw-a-sphere.ada b/Task/Draw-a-sphere/Ada/draw-a-sphere.ada new file mode 100644 index 0000000000..71fd30cd84 --- /dev/null +++ b/Task/Draw-a-sphere/Ada/draw-a-sphere.ada @@ -0,0 +1,30 @@ +with Glib; use Glib; +with Cairo; use Cairo; +with Cairo.Png; use Cairo.Png; +with Cairo.Pattern; use Cairo.Pattern; +with Cairo.Image_Surface; use Cairo.Image_Surface; +with Ada.Numerics; + +procedure Sphere is + subtype Dub is Glib.Gdouble; + + Surface : Cairo_Surface; + Cr : Cairo_Context; + Pat : Cairo_Pattern; + Status_Out : Cairo_Status; + M_Pi : constant Dub := Dub (Ada.Numerics.Pi); + +begin + Surface := Create (Cairo_Format_ARGB32, 512, 512); + Cr := Create (Surface); + Pat := + Cairo.Pattern.Create_Radial (230.4, 204.8, 51.1, 204.8, 204.8, 256.0); + Cairo.Pattern.Add_Color_Stop_Rgba (Pat, 0.0, 1.0, 1.0, 1.0, 1.0); + Cairo.Pattern.Add_Color_Stop_Rgba (Pat, 1.0, 0.0, 0.0, 0.0, 1.0); + Cairo.Set_Source (Cr, Pat); + Cairo.Arc (Cr, 256.0, 256.0, 153.6, 0.0, 2.0 * M_Pi); + Cairo.Fill (Cr); + Cairo.Pattern.Destroy (Pat); + Status_Out := Write_To_Png (Surface, "SphereAda.png"); + pragma Assert (Status_Out = Cairo_Status_Success); +end Sphere; diff --git a/Task/Draw-a-sphere/BASIC/draw-a-sphere-1.bas b/Task/Draw-a-sphere/BASIC/draw-a-sphere-1.bas new file mode 100644 index 0000000000..72b4b0d8a8 --- /dev/null +++ b/Task/Draw-a-sphere/BASIC/draw-a-sphere-1.bas @@ -0,0 +1,19 @@ +SCREEN 13 ' enter high-color graphic mode + +' sets palette colors B/N +FOR i = 0 TO 255 + PALETTE 255 - i, INT(i / 4) + INT(i / 4) * 256 + INT(i / 4) * 65536 +NEXT i +PALETTE 0, 0 + +' draw the sphere +FOR i = 255 TO 0 STEP -1 + x = 50 + i / 3 + y = 99 + CIRCLE (x, y), i / 3, i + PAINT (x, y), i +NEXT i + +' wait until keypress +DO: LOOP WHILE INKEY$ = "" +END diff --git a/Task/Draw-a-sphere/BASIC/draw-a-sphere-2.bas b/Task/Draw-a-sphere/BASIC/draw-a-sphere-2.bas new file mode 100644 index 0000000000..7729ff31ca --- /dev/null +++ b/Task/Draw-a-sphere/BASIC/draw-a-sphere-2.bas @@ -0,0 +1 @@ +MAKE OBJECT SPHERE 1,1 diff --git a/Task/Draw-a-sphere/BBC-BASIC/draw-a-sphere.bbc b/Task/Draw-a-sphere/BBC-BASIC/draw-a-sphere.bbc new file mode 100644 index 0000000000..f5a4e0987c --- /dev/null +++ b/Task/Draw-a-sphere/BBC-BASIC/draw-a-sphere.bbc @@ -0,0 +1,117 @@ + MODE 8 + INSTALL @lib$+"D3DLIB" + D3DTS_VIEW = 2 + D3DTS_PROJECTION = 3 + D3DRS_SPECULARENABLE = 29 + + SYS "LoadLibrary", @lib$+"D3DX8BBC.DLL" TO d3dx% + IF d3dx%=0 ERROR 100, "Couldn't load D3DX8BBC.DLL" + SYS "GetProcAddress", d3dx%, "D3DXCreateSphere" TO `D3DXCreateSphere` + SYS "GetProcAddress", d3dx%, "D3DXMatrixLookAtLH" TO `D3DXMatrixLookAtLH` + SYS "GetProcAddress", d3dx%, "D3DXMatrixPerspectiveFovLH" TO `D3DXMatrixPerspectiveFovLH` + + DIM eyepos%(2), lookat%(2), up%(2), mat%(3,3) + + DIM D3Dlight8{Type%, Diffuse{r%,g%,b%,a%}, Specular{r%,g%,b%,a%}, \ + \ Ambient{r%,g%,b%,a%}, Position{x%,y%,z%}, Direction{x%,y%,z%}, \ + \ Range%, Falloff%, Attenuation0%, Attenuation1%, Attenuation2%, \ + \ Theta%, Phi%} + + DIM D3Dmaterial8{Diffuse{r%,g%,b%,a%}, Ambient{r%,g%,b%,a%}, \ + \ Specular{r%,g%,b%,a%}, Emissive{r%,g%,b%,a%}, Power%} + + DIM D3Dbasemesh8{QueryInterface%, Addref%, Release%, \ + \ DrawSubset%, GetNumFaces%, GetNumVertices%, GetFVF%, \ + \ GetDeclaration%, GetOptions%, GetDevice%, \ + \ CloneMeshFVF%, CloneMesh%, GetVertexBuffer%, GetIndexBuffer%, \ + \ LockVertexBuffer%, UnlockVertexBuffer%, LockIndexBuffer%, \ + \ UnlockIndexBuffer%, GetAttributeTable%} + + DIM D3Ddevice8{QueryInterface%, AddRef%, Release%, TestCooperativeLevel%, \ + \ GetAvailableTextureMem%, ResourceManagerDiscardBytes%, GetDirect3D%, \ + \ GetDeviceCaps%, GetDisplayMode%, GetCreationParameters%, SetCursorProperties%, \ + \ SetCursorPosition%, ShowCursor%, CreateAdditionalSwapChain%, Reset%, \ + \ Present%, GetBackBuffer%, GetRasterStatus%, SetGammaRamp%, GetGammaRamp%, \ + \ CreateTexture%, CreateVolumeTexture%, CreateCubeTexture%, CreateVertexBuffer%, \ + \ CreateIndexBuffer%, CreateRenderTarget%, CreateDepthStencilSurface%, \ + \ CreateImageSurface%, CopyRects%, UpdateTexture%, GetFrontBuffer%, \ + \ SetRenderTarget%, GetRenderTarget%, GetDepthStencilSurface%, BeginScene%, \ + \ EndScene%, Clear%, SetTransform%, GetTransform%, MultiplyTransform%, \ + \ SetViewport%, GetViewport%, SetMaterial%, GetMaterial%, SetLight%, GetLight%, \ + \ LightEnable%, GetLightEnable%, SetClipPlane%, GetClipPlane%, SetRenderState%, \ + \ GetRenderState%, BeginStateBlock%, EndStateBlock%, ApplyStateBlock%, \ + \ CaptureStateBlock%, DeleteStateBlock%, CreateStateBlock%, SetClipStatus%, \ + \ GetClipStatus%, GetTexture%, SetTexture%, GetTextureStageState%, \ + \ SetTextureStageState%, ValidateDevice%, GetInfo%, SetPaletteEntries%, \ + \ GetPaletteEntries%, SetCurrentTexturePalette%, GetCurrentTexturePalette%, \ + \ DrawPrimitive%, DrawIndexedPrimitive%, DrawPrimitiveUP%, \ + \ DrawIndexedPrimitiveUP%, ProcessVertices%, CreateVertexShader%, \ + \ SetVertexShader%, GetVertexShader%, DeleteVertexShader%, \ + \ SetVertexShaderConstant%, GetVertexShaderConstant%, GetVertexShaderDeclaration%, \ + \ GetVertexShaderFunction%, SetStreamSource%, GetStreamSource%, SetIndices%, \ + \ GetIndices%, CreatePixelShader%, SetPixelShader%, GetPixelShader%, \ + \ DeletePixelShader%, SetPixelShaderConstant%, GetPixelShaderConstant%, \ + \ GetPixelShaderFunction%, DrawRectPatch%, DrawTriPatch%, DeletePatch%} + + pDevice%=FN_initd3d(@hwnd%, 1, 1) + IF pDevice%=0 ERROR 100, "Couldn't create Direct3D8 device" + !(^D3Ddevice8{}+4) = !pDevice% + + SYS `D3DXCreateSphere`, pDevice%, FN_f4(1), 50, 50, ^meshSphere%, 0 + IF meshSphere% = 0 ERROR 100, "D3DXCreateSphere failed" + !(^D3Dbasemesh8{}+4) = !meshSphere% + + REM. Point-source light: + D3Dlight8.Type%=1 : REM. point source + D3Dlight8.Diffuse.r% = FN_f4(1) + D3Dlight8.Diffuse.g% = FN_f4(1) + D3Dlight8.Diffuse.b% = FN_f4(1) + D3Dlight8.Specular.r% = FN_f4(1) + D3Dlight8.Specular.g% = FN_f4(1) + D3Dlight8.Specular.b% = FN_f4(1) + D3Dlight8.Position.x% = FN_f4(2) + D3Dlight8.Position.y% = FN_f4(1) + D3Dlight8.Position.z% = FN_f4(4) + D3Dlight8.Range% = FN_f4(10) + D3Dlight8.Attenuation0% = FN_f4(1) + + REM. Material: + D3Dmaterial8.Diffuse.r% = FN_f4(0.2) + D3Dmaterial8.Diffuse.g% = FN_f4(0.6) + D3Dmaterial8.Diffuse.b% = FN_f4(1.0) + D3Dmaterial8.Specular.r% = FN_f4(0.4) + D3Dmaterial8.Specular.g% = FN_f4(0.4) + D3Dmaterial8.Specular.b% = FN_f4(0.4) + D3Dmaterial8.Power% = FN_f4(100) + + fovy = RAD(30) + aspect = 5/4 + znear = 1 + zfar = 1000 + bkgnd% = &7F7F7F + eyepos%() = 0, 0, FN_f4(6) + lookat%() = 0, 0, 0 + up%() = 0, FN_f4(1), 0 + + SYS D3Ddevice8.Clear%, pDevice%, 0, 0, 3, bkgnd%, FN_f4(1), 0 + SYS D3Ddevice8.BeginScene%, pDevice% + SYS D3Ddevice8.SetLight%, pDevice%, 0, D3Dlight8{} + SYS D3Ddevice8.LightEnable%, pDevice%, 0, 1 + SYS D3Ddevice8.SetMaterial%, pDevice%, D3Dmaterial8{} + SYS D3Ddevice8.SetRenderState%, pDevice%, D3DRS_SPECULARENABLE, 1 + + SYS `D3DXMatrixLookAtLH`, ^mat%(0,0), ^eyepos%(0), ^lookat%(0), ^up%(0) + SYS D3Ddevice8.SetTransform%, pDevice%, D3DTS_VIEW, ^mat%(0,0) + + SYS `D3DXMatrixPerspectiveFovLH`, ^mat%(0,0), FN_f4(fovy), \ + \ FN_f4(aspect), FN_f4(znear), FN_f4(zfar) + SYS D3Ddevice8.SetTransform%, pDevice%, D3DTS_PROJECTION, ^mat%(0,0) + + SYS D3Dbasemesh8.DrawSubset%, meshSphere%, 0 + SYS D3Ddevice8.EndScene%, pDevice% + SYS D3Ddevice8.Present%, pDevice%, 0, 0, 0, 0 + + SYS D3Ddevice8.Release%, pDevice% + SYS D3Dbasemesh8.Release%, meshSphere% + SYS "FreeLibrary", d3dx% + END diff --git a/Task/Draw-a-sphere/Brlcad/draw-a-sphere.brlcad b/Task/Draw-a-sphere/Brlcad/draw-a-sphere.brlcad new file mode 100644 index 0000000000..f0c5517375 --- /dev/null +++ b/Task/Draw-a-sphere/Brlcad/draw-a-sphere.brlcad @@ -0,0 +1,3 @@ +opendb balls.g y # Create a database to hold our shapes +units cm # Set the unit of measure +in ball.s sph 0 0 0 3 # Create a sphere of radius 3 cm named ball.s with its centre at 0,0,0 diff --git a/Task/Draw-a-sphere/C/draw-a-sphere-1.c b/Task/Draw-a-sphere/C/draw-a-sphere-1.c new file mode 100644 index 0000000000..a0ce72fe6d --- /dev/null +++ b/Task/Draw-a-sphere/C/draw-a-sphere-1.c @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include + +const char *shades = ".:!*oe&#%@"; + +double light[3] = { 30, 30, -50 }; +void normalize(double * v) +{ + double len = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + v[0] /= len; v[1] /= len; v[2] /= len; +} + +double dot(double *x, double *y) +{ + double d = x[0]*y[0] + x[1]*y[1] + x[2]*y[2]; + return d < 0 ? -d : 0; +} + +void draw_sphere(double R, double k, double ambient) +{ + int i, j, intensity; + double b; + double vec[3], x, y; + for (i = floor(-R); i <= ceil(R); i++) { + x = i + .5; + for (j = floor(-2 * R); j <= ceil(2 * R); j++) { + y = j / 2. + .5; + if (x * x + y * y <= R * R) { + vec[0] = x; + vec[1] = y; + vec[2] = sqrt(R * R - x * x - y * y); + normalize(vec); + b = pow(dot(light, vec), k) + ambient; + intensity = (1 - b) * (sizeof(shades) - 1); + if (intensity < 0) intensity = 0; + if (intensity >= sizeof(shades) - 1) + intensity = sizeof(shades) - 2; + putchar(shades[intensity]); + } else + putchar(' '); + } + putchar('\n'); + } +} + + +int main() +{ + normalize(light); + draw_sphere(20, 4, .1); + draw_sphere(10, 2, .4); + + return 0; +} diff --git a/Task/Draw-a-sphere/C/draw-a-sphere-2.c b/Task/Draw-a-sphere/C/draw-a-sphere-2.c new file mode 100644 index 0000000000..0f0664360a --- /dev/null +++ b/Task/Draw-a-sphere/C/draw-a-sphere-2.c @@ -0,0 +1,61 @@ + #############%%%% + ##&&eeeeeeeeee&&&&&&&####%%%%%%%% + &&eeooooooooooooooeeeee&&&&######%%%%%%%% + eeoo**************oooooooeeee&&&&####%%%%%%%% + &&oo**!!!!!!::!!!!!!!!****oooooee&&&&######%%%%%%%%%% + eeoo!!!!::::::::::::::!!!!*****ooeeee&&&&####%%%%%%%%%%%% + ee**!!::::............::::!!!!***ooooeeee&&######%%%%%%%%%%%% + &&oo!!::..................::!!!!*****ooeeee&&&&####%%%%%%%%%%%%%% + oo!!::....................::::!!*****ooeeee&&&&####%%%%%%%%%%%%%% + ee**!!::....................::::!!*****ooeeee&&&&####%%%%%%%%%%%%%%%% + &&oo!!::......................::::!!*****ooeeee&&&&######%%%%%%%%%%%%%%%% + ee**!!::......................::::!!*****ooeeee&&&&######%%%%%%%%%%%%%%%% + ##oo**!!::......................::!!!!*****ooeeee&&&&####%%%%%%%%%%%%%%%%%%%% + &&oo**::::....................::::!!!!***ooooeeee&&&&####%%%%%%%%%%%%%%%%%%%% + eeoo**!!::..................::::!!!!*****ooooee&&&&######%%%%%%%%%%%%%%%%%%%% + eeoo**!!::................::::!!!!****oooooeeee&&&&######%%%%%%%%%%%%%%%%%%%% +#eeoo**!!::::............::::!!!!!!****oooeeee&&&&&&######%%%%%%%%%%%%%%%%%%%%%% +#eeoo**!!!!::::::::::::::::!!!!!!****oooooeeee&&&&######%%%%%%%%%%%%%%%%%%%%%%%% +#eeoooo**!!!!!!::::::::!!!!!!******ooooeeeee&&&&&&######%%%%%%%%%%%%%%%%%%%%%%%% +#&&eeoo****!!!!!!!!!!!!!!!!******ooooeeeee&&&&&&######%%%%%%%%%%%%%%%%%%%%%%%%%% +#&&eeoooo********************ooooooeeee&&&&&&&######%%%%%%%%%%%%%%%%%%%%%%%%%%%% +#&&&&eeoooooo************ooooooeeeeee&&&&&&&########%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%##&&eeeeeeooooooooooooooooooeeeeee&&&&&&&########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%####&&&&eeeeeeeeeeeeeeeeeeeeee&&&&&&&&#########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%##&&&&&&eeeeeeeeeeeeeeee&&&&&&&&&&#########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%######&&&&&&&&&&&&&&&&&&&&&&&&###########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%########&&&&&&&&&&&&&&############%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%##############################%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%######################%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%####%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%% + + ::..:::::!!** + .............::!!**oo + ...................::!!**ooee + .......................::!!ooeeee + .......................::!!**ooee + .........................::!!**ooeeee + .........................::!!**ooeeee +:.........................::!!**ooeeeeee +........................::!!**ooooeeeeee +:.......................::!!**ooeeeeeeee +:.....................::!!****ooeeeeeeee +!::................:::!!****ooeeeeeeeeee +*!!::..........::::!!!****ooooeeeeeeeeee + **!!::::::::::!!!!*****ooooeeeeeeeeee + oo**!!!!!!!!!!*******ooooeeeeeeeeeeee + oooo********oooooooeeeeeeeeeeeeee + eeeeooooooooooeeeeeeeeeeeeeeeeeee + eeeeeeeeeeeeeeeeeeeeeeeeeeeee + eeeeeeeeeeeeeeeeeeeee + eeeeeeeeeeeee diff --git a/Task/Draw-a-sphere/C/draw-a-sphere-3.c b/Task/Draw-a-sphere/C/draw-a-sphere-3.c new file mode 100644 index 0000000000..dc31435dd2 --- /dev/null +++ b/Task/Draw-a-sphere/C/draw-a-sphere-3.c @@ -0,0 +1,162 @@ +#include +#include +#include + +#define MAXD 8 +int g[] = { -1, 1, -1, 1 }; +/* Perlin-like noise */ +inline void +hashed(int *data, int *out, int len) { +# define ror(a, d) ((a << (d)) | (a >> (32 - d))) + register unsigned int h = 0x12345678, tmp; + unsigned int *d = (void*)data; + int i = len; + + while (i--) { + tmp = *d++; + h += ror(h, 15) ^ ror(tmp, 5); + } + + h ^= ror(h, 7); + h += ror(h, 23); + h ^= ror(h, 19); + h += ror(h, 11); + h ^= ror(h, 13); + h += ror(h, 17); +# undef ror + for (i = len; i--; ) { + out[i] = g[h & 3]; + h >>= 2; + } +} + +double scale[MAXD], scale_u[MAXD]; +void noise_init() +{ + int i; + for (i = 1; i < MAXD; i++) { + scale[i] = 1 / (1 + sqrt(i + 1)); + scale_u[i] = scale[i] / sqrt(i + 1); + } +} + +double noise(double *x, int d) +{ +# define sum(s, x) for (s = 0, j = 0; j < d; j++) s += x + register int i, j; + int n[MAXD], o[MAXD], g[MAXD], tmp; + double s, r, t, w, ret, u[MAXD]; + + sum(s, x[j]); + s *= scale[d]; + + for (i = 0; i < d; i++) { + o[i] = i; + t = x[i] + s; + u[i] = t - (n[i] = floor(t)); + } + o[d] = 0; + + for (i = 0; i < d - 1; i++) + for (j = i; j < d; j++) + if (u[o[i]] < u[o[j]]) + tmp = o[i], o[i] = o[j], o[j] = tmp; + + ret = w = 0, r = 1; + for (s = 0, j = 0; j < d; j++) s += n[j]; + s *= scale_u[d]; + + for (i = 0; i <= d; i++) { + for (j = 0; j < d; j++) + u[j] = x[j] + s - n[j]; + + for (t = (d + 1.) / (2 * d), j = 0; j < d; j++) { + t -= u[j] * u[j]; + if (t <= 0) break; + } + + if (t >= 0) { + r = 0; + hashed(n, g, d); + for (j = 0; j < d; j++) + if (g[j]) r += (g[j] == 1 ? u[j] : -u[j]); + t *= t; + ret += r * t * t; + } + + if (i < d) { + n[o[i]]++; + s += scale_u[d]; + } + } + return ret * (d * d); +} + +double get_noise2(double x, double y) +{ + int i, ws; + double r = 0, v[2]; + + for (i = 1, ws = 0; i <= 128; i <<= 1) { + v[0] = x * i, v[1] = y * i; + r += noise(v, 2); + ws ++; + } + r /= ws; + return r; +} + +double get_noise3(double x, double y, double z) +{ + int i, ws; + double r = 0, v[3], w; + + for (i = 1, ws = 0; i <= 32; i <<= 1) { + v[0] = x * i, v[1] = y * i, v[2] = z * i; + w = 1./sqrt(i); + r += noise(v, 3) * w; + ws += w; + } + return r / ws; +} + + +int main(int c, char** v) +{ + unsigned char pix[256 * 256], *p; + int i, j; + double x, y, z, w; + FILE *fp; + + noise_init(); + + for (p = pix, i = 0; i < 256 * 256; i++) *p++ = 0; + + for (p = pix, i = 0; i < 256; i++) { + y = (i - 128) / 125.; + for (j = 0; j < 256; j++, p++) { + x = (j - 128) / 125.; + *p = (get_noise2(i/256., j/256.) + 1) / 6 * i; + + z = 1- x*x - y*y; + if (z < 0) continue; + + z = sqrt(z); + + w = get_noise3(x, y, z); + + w = (w + 1) / 2; + w *= (1 + x - y + z) / 3.5; + if (w < 0) w = 0; + + *p = w * 255; + } + } + + fp = fopen("out.pgm", "w+"); + fprintf(fp, "P5\n256 256\n255\n"); + fwrite(pix, 1, 256 * 256, fp); + fclose(fp); + + return 0; +} diff --git a/Task/Draw-a-sphere/D/draw-a-sphere.d b/Task/Draw-a-sphere/D/draw-a-sphere.d new file mode 100644 index 0000000000..828ae554e7 --- /dev/null +++ b/Task/Draw-a-sphere/D/draw-a-sphere.d @@ -0,0 +1,39 @@ +import std.stdio, std.math, std.algorithm, std.numeric; + +alias double[3] V3; +V3 light = [30, 30, -50]; + +void normalize(ref V3 v) pure { + v[] /= dotProduct(v, v) ^^ 0.5; +} + +double dot(in ref V3 x, in ref V3 y) pure nothrow { + immutable double d = dotProduct(x, y); + return d < 0 ? -d : 0; +} + +void drawSphere(in double R, in double k, in double ambient) { + enum shades = ".:!*oe&#%@"; + foreach (int i; cast(int)floor(-R) .. cast(int)ceil(R) + 1) { + immutable double x = i + 0.5; + foreach (int j; cast(int)floor(-2*R)..cast(int)ceil(2*R)+1){ + immutable double y = j / 2. + 0.5; + if (x ^^ 2 + y ^^ 2 <= R ^^ 2) { + V3 vec = [x, y, (R^^2 - x^^2 - y^^2) ^^ 0.5]; + vec.normalize(); + immutable double b = dot(light, vec) ^^ k + ambient; + int intensity = cast(int)((1-b) * (shades.length-1)); + intensity = min(shades.length-1, max(intensity, 0)); + putchar(shades[intensity]); + } else + putchar(' '); + } + putchar('\n'); + } +} + +void main() { + light.normalize(); + drawSphere(20, 4, 0.1); + drawSphere(10, 2, 0.4); +} diff --git a/Task/Draw-a-sphere/DWScript/draw-a-sphere.dwscript b/Task/Draw-a-sphere/DWScript/draw-a-sphere.dwscript new file mode 100644 index 0000000000..b0d66b43ed --- /dev/null +++ b/Task/Draw-a-sphere/DWScript/draw-a-sphere.dwscript @@ -0,0 +1,55 @@ +type + TFloat3 = array[0..2] of Float; + +var + light : TFloat3 = [ 30, 30, -50 ]; + +procedure normalize(var v : TFloat3); +var + len: Float; +begin + len := sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + v[0] /= len; + v[1] /= len; + v[2] /= len; +end; + +function dot(x, y : TFloat3) : Float; +begin + Result := x[0]*y[0] + x[1]*y[1] + x[2]*y[2]; + if Result<0 then + Result:=-Result + else Result:=0; +end; + +procedure drawSphere(R, k, ambient : Float); +var + vec : TFloat3; + x, y, b : Float; + i, j, size, intensity : Integer; +begin + size:=Trunc(Ceil(R)-Floor(-R)+1); + PrintLn('P2'); + PrintLn(IntToStr(size)+' '+IntToStr(size)); + PrintLn('255'); + for i := Floor(-R) to Ceil(R) do begin + x := i + 0.5; + for j := Floor(-R) to Ceil(R) do begin + y := j + 0.5; + if (x * x + y * y <= R * R) then begin + vec[0] := x; + vec[1] := y; + vec[2] := sqrt(R * R - x * x - y * y); + normalize(vec); + b := Power(dot(light, vec), k) + ambient; + intensity := ClampInt( Round(b*255), 0, 255); + Print(intensity); + Print(' ') + end else Print('0 '); + end; + PrintLn(''); + end; +end; + +normalize(light); +drawSphere(19, 4, 0.1); diff --git a/Task/Draw-a-sphere/Delphi/draw-a-sphere.delphi b/Task/Draw-a-sphere/Delphi/draw-a-sphere.delphi new file mode 100644 index 0000000000..bf8e6a2d22 --- /dev/null +++ b/Task/Draw-a-sphere/Delphi/draw-a-sphere.delphi @@ -0,0 +1,70 @@ +program DrawASphere; + +{$APPTYPE CONSOLE} + +uses + SysUtils, + Math; + +type + TDouble3 = array[0..2] of Double; + TChar10 = array[0..9] of Char; + +var + shades: TChar10 = ('.', ':', '!', '*', 'o', 'e', '&', '#', '%', '@'); + light: TDouble3 = (30, 30, -50 ); + + procedure normalize(var v: TDouble3); + var + len: Double; + begin + len:= sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + v[0] := v[0] / len; + v[1] := v[1] / len; + v[2] := v[2] / len; + end; + + function dot(x, y: TDouble3): Double; + begin + Result:= x[0]*y[0] + x[1]*y[1] + x[2]*y[2]; + Result:= IfThen(Result < 0, -Result, 0 ); + end; + + procedure drawSphere(R, k, ambient: Double); + var + vec: TDouble3; + x, y, b: Double; + i, j, + intensity: Integer; + begin + for i:= Floor(-R) to Ceil(R) do + begin + x := i + 0.5; + for j:= Floor(-2*R) to Ceil(2 * R) do + begin + y:= j / 2 + 0.5; + if(x * x + y * y <= R * R) then + begin + vec[0]:= x; + vec[1]:= y; + vec[2]:= sqrt(R * R - x * x - y * y); + normalize(vec); + b:= Power(dot(light, vec), k) + ambient; + intensity:= IfThen(b <= 0, + Length(shades) - 2, + Trunc(max( (1 - b) * (Length(shades) - 1), 0 ))); + Write(shades[intensity]); + end + else + Write(' '); + end; + Writeln; + end; + end; + +begin + normalize(light); + drawSphere(19, 4, 0.1); + drawSphere(10, 2, 0.4); + Readln; +end. diff --git a/Task/Draw-a-sphere/Go/draw-a-sphere.go b/Task/Draw-a-sphere/Go/draw-a-sphere.go new file mode 100644 index 0000000000..32a31cb389 --- /dev/null +++ b/Task/Draw-a-sphere/Go/draw-a-sphere.go @@ -0,0 +1,68 @@ +package main + +import ( + "fmt" + "image" + "image/color" + "image/png" + "math" + "os" +) + +type vector [3]float64 + +func normalize(v *vector) { + invLen := 1 / math.Sqrt(dot(v, v)) + v[0] *= invLen + v[1] *= invLen + v[2] *= invLen +} + +func dot(x, y *vector) float64 { + return x[0]*y[0] + x[1]*y[1] + x[2]*y[2] +} + +func drawSphere(r int, k, amb float64, dir *vector) *image.Gray { + w, h := r*4, r*3 + img := image.NewGray(image.Rect(-w/2, -h/2, w/2, h/2)) + vec := new(vector) + for x := -r; x < r; x++ { + for y := -r; y < r; y++ { + if z := r*r - x*x - y*y; z >= 0 { + vec[0] = float64(x) + vec[1] = float64(y) + vec[2] = math.Sqrt(float64(z)) + normalize(vec) + s := dot(dir, vec) + if s < 0 { + s = 0 + } + lum := 255 * (math.Pow(s, k) + amb) / (1 + amb) + if lum < 0 { + lum = 0 + } else if lum > 255 { + lum = 255 + } + img.SetGray(x, y, color.Gray{uint8(lum)}) + } + } + } + return img +} + +func main() { + dir := &vector{-30, -30, 50} + normalize(dir) + img := drawSphere(200, 1.5, .2, dir) + f, err := os.Create("sphere.png") + if err != nil { + fmt.Println(err) + return + } + if err = png.Encode(f, img); err != nil { + fmt.Println(err) + } + if err = f.Close(); err != nil { + fmt.Println(err) + } +} diff --git a/Task/Draw-a-sphere/Haskell/draw-a-sphere-1.hs b/Task/Draw-a-sphere/Haskell/draw-a-sphere-1.hs new file mode 100644 index 0000000000..6d9838af20 --- /dev/null +++ b/Task/Draw-a-sphere/Haskell/draw-a-sphere-1.hs @@ -0,0 +1,48 @@ +import Graphics.Rendering.OpenGL.GL +import Graphics.UI.GLUT.Objects +import Graphics.UI.GLUT + +setProjection :: IO () +setProjection = do + matrixMode $= Projection + ortho (-1) 1 (-1) 1 0 (-1) + +grey1,grey9,red,white :: Color4 GLfloat +grey1 = Color4 0.1 0.1 0.1 1 +grey9 = Color4 0.9 0.9 0.9 1 +red = Color4 1 0 0 1 +white = Color4 1 1 1 1 + +setLights :: IO () +setLights = do + let l = Light 0 + ambient l $= grey1 + diffuse l $= white + specular l $= white + position l $= Vertex4 (-4) 4 3 (0 :: GLfloat) + light l $= Enabled + lighting $= Enabled + +setMaterial :: IO () +setMaterial = do + materialAmbient Front $= grey1 + materialDiffuse Front $= red + materialSpecular Front $= grey9 + materialShininess Front $= (32 :: GLfloat) + +display :: IO() +display = do + clear [ColorBuffer] + renderObject Solid $ Sphere' 0.8 64 64 + swapBuffers + +main :: IO() +main = do + _ <- getArgsAndInitialize + _ <- createWindow "Sphere" + clearColor $= Color4 0.0 0.0 0.0 0.0 + setProjection + setLights + setMaterial + displayCallback $= display + mainLoop diff --git a/Task/Draw-a-sphere/Haskell/draw-a-sphere-2.hs b/Task/Draw-a-sphere/Haskell/draw-a-sphere-2.hs new file mode 100644 index 0000000000..f21c6176f2 --- /dev/null +++ b/Task/Draw-a-sphere/Haskell/draw-a-sphere-2.hs @@ -0,0 +1,7 @@ +procedure main() +W := open("Demo", "gl", "size=400,400", "bg=black") | stop("can't open window!") +WAttrib(W, "slices=40", "rings=40", "light0=on, ambient white; diffuse gold; specular gold; position 5, 0, 0" ) +Fg(W, "emission blue") +DrawSphere(W, 0, 0, -5, 1) +Event(W) +end diff --git a/Task/Draw-a-sphere/Java/draw-a-sphere.java b/Task/Draw-a-sphere/Java/draw-a-sphere.java new file mode 100644 index 0000000000..54f3d95019 --- /dev/null +++ b/Task/Draw-a-sphere/Java/draw-a-sphere.java @@ -0,0 +1,43 @@ +public class Sphere{ + static char[] shades = {'.', ':', '!', '*', 'o', 'e', '&', '#', '%', '@'}; + + static double[] light = { 30, 30, -50 }; + private static void normalize(double[] v){ + double len = Math.sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + v[0] /= len; v[1] /= len; v[2] /= len; + } + + private static double dot(double[] x, double[] y){ + double d = x[0]*y[0] + x[1]*y[1] + x[2]*y[2]; + return d < 0 ? -d : 0; + } + + public static void drawSphere(double R, double k, double ambient){ + double[] vec = new double[3]; + for(int i = (int)Math.floor(-R); i <= (int)Math.ceil(R); i++){ + double x = i + .5; + for(int j = (int)Math.floor(-2 * R); j <= (int)Math.ceil(2 * R); j++){ + double y = j / 2. + .5; + if(x * x + y * y <= R * R) { + vec[0] = x; + vec[1] = y; + vec[2] = Math.sqrt(R * R - x * x - y * y); + normalize(vec); + double b = Math.pow(dot(light, vec), k) + ambient; + int intensity = (b <= 0) ? + shades.length - 2 : + (int)Math.max((1 - b) * (shades.length - 1), 0); + System.out.print(shades[intensity]); + } else + System.out.print(' '); + } + System.out.println(); + } + } + + public static void main(String[] args){ + normalize(light); + drawSphere(20, 4, .1); + drawSphere(10, 2, .4); + } +} diff --git a/Task/Draw-a-sphere/Lua/draw-a-sphere.lua b/Task/Draw-a-sphere/Lua/draw-a-sphere.lua new file mode 100644 index 0000000000..45097fce72 --- /dev/null +++ b/Task/Draw-a-sphere/Lua/draw-a-sphere.lua @@ -0,0 +1,37 @@ +require ("math") + +shades = {'.', ':', '!', '*', 'o', 'e', '&', '#', '%', '@'} + +function normalize (vec) + len = math.sqrt(vec[1]^2 + vec[2]^2 + vec[3]^2) + return {vec[1]/len, vec[2]/len, vec[3]/len} +end + +light = normalize{30, 30, -50} + +function dot (vec1, vec2) + d = vec1[1]*vec2[1] + vec1[2]*vec2[2] + vec1[3]*vec2[3] + return d < 0 and -d or 0 +end + +function draw_sphere (radius, k, ambient) + for i = math.floor(-radius),-math.floor(-radius) do + x = i + .5 + local line = '' + for j = math.floor(-2*radius),-math.floor(-2*radius) do + y = j / 2 + .5 + if x^2 + y^2 <= radius^2 then + vec = normalize{x, y, math.sqrt(radius^2 - x^2 - y^2)} + b = dot(light,vec) ^ k + ambient + intensity = math.floor ((1 - b) * #shades) + line = line .. (shades[intensity] or shades[1]) + else + line = line .. ' ' + end + end + print (line) + end +end + +draw_sphere (20, 4, 0.1) +draw_sphere (10, 2, 0.4) diff --git a/Task/Draw-a-sphere/PicoLisp/draw-a-sphere-1.l b/Task/Draw-a-sphere/PicoLisp/draw-a-sphere-1.l new file mode 100644 index 0000000000..11f8123081 --- /dev/null +++ b/Task/Draw-a-sphere/PicoLisp/draw-a-sphere-1.l @@ -0,0 +1,26 @@ +(load "@lib/openGl.l") + +(glutInit) +(glutInitDisplayMode (| GLUT_RGBA GLUT_DOUBLE GLUT_ALPHA GLUT_DEPTH)) +(glutInitWindowSize 400 400) +(glutCreateWindow "Sphere") + +(glEnable GL_LIGHTING) +(glEnable GL_LIGHT0) +(glLightiv GL_LIGHT0 GL_POSITION (10 10 -10 0)) + +(glEnable GL_COLOR_MATERIAL) +(glColorMaterial GL_FRONT_AND_BACK GL_AMBIENT_AND_DIFFUSE) + +(glClearColor 0.3 0.3 0.5 0) +(glColor4f 0.0 0.8 0.0 1.0) + +(displayPrg + (glClear (| GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) + (glutSolidSphere 0.9 40 32) + (glFlush) + (glutSwapBuffers) ) + +# Exit upon mouse click +(mouseFunc '((Btn State X Y) (bye))) +(glutMainLoop) diff --git a/Task/Draw-a-sphere/PicoLisp/draw-a-sphere-2.l b/Task/Draw-a-sphere/PicoLisp/draw-a-sphere-2.l new file mode 100644 index 0000000000..955726c9dd --- /dev/null +++ b/Task/Draw-a-sphere/PicoLisp/draw-a-sphere-2.l @@ -0,0 +1,60 @@ +(scl 24) + +(setq *Shades + (list "." ":" "!" "*" "o" "e" "&" "#" "%" "@")) + +(setq *Light + (list 30.0 30.0 -50.0)) + +(de normalize (V) + (let Len + (sqrt + (sum + (quote (X) + (** X 2)) + V)) + (mapcar + (quote (X) + (*/ X 1.0 Len)) + V))) + +(de dot (X Y) + (let D (sum (quote (A B) (*/ A B 1.0)) X Y) + (if (< D 0) (- D) 0))) + +(de floor (N) + (* 1.0 (*/ (- N 0.5) 1.0))) + +(de ceil (N) + (* 1.0 (*/ (+ N 0.5) 1.0))) + +(de drawSphere (R K Ambient) + (let Vec NIL + (for (I (floor (- R)) (<= I (ceil R)) (+ I 1.0)) + (let X (+ I 0.5) + (for (J (floor (* -2 R)) (<= J (ceil (* 2 R))) (+ J 1.0)) + (let Y (+ (/ J 2) 0.5) + (if (<= (+ (*/ X X 1.0) (*/ Y Y 1.0)) (*/ R R 1.0)) + (prog + (setq Vec + (list X Y + (sqrt + (* 1.0 + (- (*/ R R 1.0) + (*/ X X 1.0) + (*/ Y Y 1.0)))))) + (setq Vec (normalize Vec)) + (let (B NIL + Intensity NIL) + (setq B (+ (/ (** (dot *Light Vec) K) (** 1.0 (- K 1))) Ambient)) + (setq Intensity + (if (<= B 0) + (- (length *Shades) 2) + (max (format (round (*/ (- 1.0 B) (* (- (length *Shades) 1) 1.0) 1.0) 0)) 0))) + (prin (nth *Shades (+ Intensity 1) 1)))) + (prin " ")))) + (prinl))))) + +(setq *Light (normalize *Light)) +(drawSphere 20.0 4 0.1) +(drawSphere 10.0 2 0.4) diff --git a/Task/Draw-a-sphere/Python/draw-a-sphere-1.py b/Task/Draw-a-sphere/Python/draw-a-sphere-1.py new file mode 100644 index 0000000000..4c1a32050d --- /dev/null +++ b/Task/Draw-a-sphere/Python/draw-a-sphere-1.py @@ -0,0 +1,32 @@ +import math + +shades = ('.',':','!','*','o','e','&','#','%','@') + +def normalize(v): + len = math.sqrt(v[0]**2 + v[1]**2 + v[2]**2) + return (v[0]/len, v[1]/len, v[2]/len) + +def dot(x,y): + d = x[0]*y[0] + x[1]*y[1] + x[2]*y[2] + return -d if d < 0 else 0 + +def draw_sphere(r, k, ambient, light): + for i in range(int(math.floor(-r)),int(math.ceil(r)+1)): + x = i + 0.5 + line = '' + + for j in range(int(math.floor(-2*r)),int(math.ceil(2*r)+1)): + y = j/2 + 0.5 + if x*x + y*y <= r*r: + vec = normalize((x,y,math.sqrt(r*r - x*x - y*y))) + b = dot(light,vec)**k + ambient + intensity = int((1-b)*(len(shades)-1)) + line += shades[intensity] if 0 <= intensity < len(shades) else shades[0] + else: + line += ' ' + + print(line) + +light = normalize((30,30,-50)) +draw_sphere(20,4,0.1, light) +draw_sphere(10,2,0.4, light) diff --git a/Task/Draw-a-sphere/Python/draw-a-sphere-2.py b/Task/Draw-a-sphere/Python/draw-a-sphere-2.py new file mode 100644 index 0000000000..aac759dfff --- /dev/null +++ b/Task/Draw-a-sphere/Python/draw-a-sphere-2.py @@ -0,0 +1,777 @@ +import pygame +from pygame.locals import * +import time +import sys +import random +import math +class Tricubic: + def __init__(self,pts): + self.coefficients = [] + for plane in pts: + planecoeffs = [] + for line in plane: + p = (line[3]-line[2])-(line[0]-line[1]) + q = (line[0]-line[1])-p + r = line[2]-line[0] + s = line[1] + planecoeffs.append([p,q,r,s]) + self.coefficients.append(planecoeff) + def Eval(at): + return Misc.Cubic([CoeffBicubic(coeffs[0],d),CoeffBicubic(coeffs[1],d),CoeffBicubic(coeffs[2],d),CoeffBicubic(coeffs[3],d)],d.z) + def CoeffCubic(coeffs,d): + return (coeffs[0]*(d.x**3))+(coeffs[1]*(d.x**2))+(coeffs[2]*d.x)+coeffs[3] + def CoeffBicubic(coeffs,d): + return Misc.Cubic([CoeffCubic(coeffs[0],d),CoeffCubic(coeffs[1],d),CoeffCubic(coeffs[2],d),CoeffCubic(coeffs[3],d)],d.y) +class Misc: + def LinePara(line,t): + return Vector3.Add(line[0],Vector3.Scale(Vector3.Subtract(line[1],line[0]),t)) + def LUR(at,above): + look = at.Unit() + right = Vector3.Cross(look,above).Unit() + up = Vector3.Scale(Vector3.Cross(look,right),-1) + return [look,up,right] + def LinePlane(line,triangle,cp=True): + try: + u = Vector3.Subtract(triangle.points[1].point,triangle.points[0]) + v = Vector3.Subtract(triangle.points[2],triangle.points[0]) + n = Vector3.Cross(u,v) + r = (Vector3.Dot(n,Vector3.Subtract(triangle.points[0],line.start))/Vector3.Dot(n,line.direction)) + if stp: + point = Vector3.Add(Vector3.Scale(line.direction,r),line.start) + w = Vector3.Subtract(point,triangle.points[0]) + udv = Vector3.Dot(u,v) + wdv = Vector3.Dot(w,v) + vdv = Vector3.Dot(v,v) + wdu = Vector3.Dot(w,u) + udu = Vector3.Dot(u,u) + denominator = (udv**2)-(udu*vdv) + s = ((udv*wdv)-(vdv*wdu))/denominator + t = ((udv*wdu)-(udu*wdv))/denominator + return [r,Vector2(s,t),point] + print('hooray') + else: + return [r] + except: + return None + def Cubic(pts,d): + p = (pts[3]-pts[2])-(pts[0]-pts[1]) + q = (pts[0]-pts[1])-p + r = pts[2]-pts[0] + s = pts[1] + return (p*(d**3))+(q*(d**2))+(r*d)+s + def Bicubic(pts,d): + return Misc.Cubic([Misc.Cubic(pts[0],d.x),Misc.Cubic(pts[1],d.x),Misc.Cubic(pts[2],d.x),Misc.Cubic(pts[3],d.x)],d.y) + def Tricubic(pts,d): + return Misc.Cubic([Misc.Bicubic(pts[0],d),Misc.Bicubic(pts[1],d),Misc.Bicubic(pts[2],d),Misc.Bicubic(pts[3],d)],d.z) + def Quadcubic(pts,d): + return Misc.Cubic([Misc.Tricubic(pts[0],d),Misc.Tricubic(pts[1],d),Misc.Tricubic(pts[2],d),Misc.Tricubic(pts[3],d)],d.w) + def Linear(pts,d): + return (pts[2]*d)+(pts[1]*(1-d)) + def Bilinear(pts,d): + return Misc.Linear([0,Misc.Linear(pts[1],d.x),Misc.Linear(pts[2],d.x)],d.y) + def Trilinear(pts,d): + return Misc.Linear([0,Misc.Bilinear(pts[1],d),Misc.Bilinear(pts[2],d)],d.z) + def LP2(line,triangle,cp=True): + try: + bla = triangle.points[1] + bla = triangle.points[0] + u = Vector3.Subtract(triangle.points[1].point,triangle.points[0].point) + v = Vector3.Subtract(triangle.points[2].point,triangle.points[0].point) + n = Vector3.Cross(u,v) + d = Vector3.Subtract(line[1],line[0]) + r = (Vector3.Dot(n,Vector3.Subtract(triangle.points[0].point,line[0]))/Vector3.Dot(n,d)) + if cp: + point = Vector3.Add(Vector3.Scale(d,r),line[0]) + w = Vector3.Subtract(point,triangle.points[0].point) + udv = Vector3.Dot(u,v) + wdv = Vector3.Dot(w,v) + vdv = Vector3.Dot(v,v) + wdu = Vector3.Dot(w,u) + udu = Vector3.Dot(u,u) + denominator = (udv**2)-(udu*vdv) + s = ((udv*wdv)-(vdv*wdu))/denominator + t = ((udv*wdu)-(udu*wdv))/denominator + return (r,Vector2(s,t),point) + else: + return (r) + except: + return None + def Phong(normal,viewer,light,material,term): + # light (vector_to,diffuse,specular) + # material (ambient,diffuse,specular,shininess) + n = normal.Unit() + v = viewer.Unit() + l = light[0].Unit() + ldn = Vector3.Dot(l,n) + #print(ldn) + val = 0 + if ldn > 0: + val += material[1][term]*ldn*light[1][term] + rdv = Vector3.Dot(Vector3.Subtract(Vector3.Scale(n,2*ldn),l),v) + if rdv > 0: + val += (material[2][term]*(rdv**material[3])*light[2][term]) + #print(val) + return val + def Lighting(ambient,normal,viewer,lights,material,term): + # lights [(vector_to,diffuse,specular)] + # material (ambient,diffuse,specular,shininess) + val = material[0][term]*ambient[term] + for light in lights: + val += Misc.Phong(normal,viewer,light,material,term) + return val + def Lighting2(start,direction,ambient,intersect,triangle,lights): + coord = intersect[1] + val = Color.Add(Color.Multiply(ambient,Color.Multiply(triangle.material.color['ambient'],triangle.Map('ambient',coord))), + Color.Multiply(triangle.material.color['glow'],triangle.Map('glow',coord))) + for light in lights: + for n in range(3): + val[n] += Misc.Phong(triangle.InterpolatedNormal(coord), + Vector3.Scale(direction,-1), + (light.To(intersect[2]),light.Diffuse(intersect[2]),light.Specular(intersect[2])), + (Color(), + Color.Multiply(triangle.material.color['diffuse'],triangle.Map('diffuse',coord)), + Color.Multiply(triangle.material.color['specular'],triangle.Map('specular',coord)), + triangle.material.shiny),n) + return val + def Ray(start,direction,scene,color=True,sector=None): + intersect = None + intersected = None + col = None + for triangle in scene.triangles: + possible = True + if sector != None: + possible = False + for point in triangle.points: + if not(point.sector.x < sector.x): + possible = True + if possible: + possible = False + for point in triangle.points: + if not(point.sector.x > sector.x): + possible = True + if possible: + possible = False + for point in triangle.points: + if not(point.sector.y < sector.y): + possible = True + if possible: + possible = False + for point in triangle.points: + if not(point.sector.y > sector.y): + possible = True + possible = True + if possible: + tmp = Misc.LP2([start,Vector3.Add(start,direction)],triangle,color) + write = False + if type(tmp) == type(5.1): + tmp = None + if (tmp != None): + if (intersect == None): + if (tmp[0] > 0) and (tmp[1].x >= 0) and (tmp[1].y >= 0) and (tmp[1].x+tmp[1].y <= 1): + write = True + elif (tmp[0] > 0) and (tmp[0] < intersect[0]) and (tmp[1].x >= 0) and (tmp[1].y >= 0) and (tmp[1].x+tmp[1].y <= 1): + write = True + if write: + intersect = tmp + intersected = triangle + if color and (intersect != None): + applicable = [] + for light in scene.lights: + block = Misc.Ray(intersect[2],light.To(intersect[2]),scene,False) + if block == None: + applicable.append(light) + elif light.location != None: + if Vector3.Subtract(light.location,intersect[2]).Magnitude() < block[0]: + applicable.append(light) + col = Misc.Lighting2(start,direction,scene.ambient,intersect,intersected,applicable) + return (intersect,col) + else: + return intersect +class DirLight: + def __init__(self,direction,diffuse,specular): + self.location = None + self.direction = direction.Unit() + self.diffuse = diffuse + self.specular = specular + def To(self,frm): + return Vector3.Scale(self.direction,-1) + def Diffuse(self,to): + return self.diffuse + def Specular(self,to): + return self.specular +class Material: + def __init__(self): + self.color = {'ambient':Color(1,1,1), + 'diffuse':Color(1,1,1), + 'specular':Color(1,1,1), + 'glow':Color(1,1,1)} + self.maps = {'ambient':Map(), + 'diffuse':Map(), + 'specular':Map(), + 'glow':Map(), + 'bump':Map()} + self.shiny = 10 +class Map: + def __init__(self,surface=None): + self.surface = surface + if self.surface != None: + self.width = self.surface.get_width() + self.height = self.surface.get_height() + def __getitem__(self,index): + if self.surface == None: + return Color(1,1,1) + else: + try: + return Color.From255(self.surface.get_at((int(index.x*(self.width-1)),int(index.y*(self.height-1))))) + except: + return Color(0,0,1) +class Color: + def __init__(self,r=0,g=0,b=0): + self.r = r + self.g = g + self.b = b + def __getitem__(self,index): + if index == 0: + return self.r + elif index == 1: + return self.g + elif index == 2: + return self.b + def __setitem__(self,index,value): + if index == 0: + self.r = value + elif index == 1: + self.g = value + elif index == 2: + self.b = value + def Multiply(A,B): + return Color(A.r*B.r,A.g*B.g,A.b*B.b) + def Add(A,B): + return Color(A.r+B.r,A.g+B.g,A.b+B.b) + def From255(A): + return Color(A.r/255,A.g/255,A.b/255) +class Vertex: + def __init__(self,point,normal,maps): + self.bpoint = point + self.bnormal = normal + self.maps = maps + for name in ['ambient','diffuse','specular','glow','bump']: + try: + bla = self.maps[name] + except: + self.maps[name] = Vector2() + self.sector = None + def Transform(self,points,norms): + self.point = Matrix2.Multiply(self.bpoint.Horizontal(),points).Vectorize() + self.normal = Matrix2.Multiply(self.bnormal.Horizontal(),norms).Vectorize() +class Triangle: + def __init__(self,vertices,material=Material()): + self.points = vertices + self.material = material + def Map(self,name,coord): + pts = [] + for n in range(3): + pts.append(self.points[n].maps[name]) + loc = Vector2.Add(pts[0], + Vector2.Add(Vector2.Scale(Vector2.Subtract(pts[1],pts[0]),coord.x), + Vector2.Scale(Vector2.Subtract(pts[2],pts[0]),coord.y))) + #print(loc.x,loc.y) + return self.material.maps[name][loc] + def InterpolatedNormal(self,coord): + return Vector3.Add(Vector3.Scale(self.points[0].normal,1-coord.x-coord.y), + Vector3.Add(Vector3.Scale(self.points[1].normal,coord.x),Vector3.Scale(self.points[2].normal,coord.y))).Unit() +class Line: + def __init__(self,A,B=None,direction=None): + self.start = A + if B != None: + self.direction = Vector3.Subtract(B,A).Unit() + elif direction != None: + self.direction = direction + else: + raise RuntimeError('Neither B nor direction are specified') +class Scene: + def __init__(self): + self.triangles = [] + self.vertices = [] + self.lights = [] + self.exterior = [] + self.ambient = 0 +class Matrix2: + def __init__(self,data=[[]]): + self.FromData(data) + def __getitem__(self,index): + return self.data[index[1]][index[0]] + def __setitem__(self,index,value): + self.data[index[1]][index[0]]=value + def Dimension(self): + self.rows = len(self.data) + self.cols = len(self.data[0]) + def FromData(self,data): + self.data = data + length=len(data[0]) + for row in data: + if len(row)!=length: + self.data=None + raise RuntimeError('Data rows are not of uniform length.') + self.Dimension() + def Multiply(A,B): + if A.cols!=B.rows: + raise RuntimeError('Column count of Matrix2 \"A\" does not match row count of Matrix2 \"B\".') + matrix = Matrix2.Empty(B.cols,A.rows) + x=0 + while x 1: + light = 1 + elif light < 0: + light = 0 + coloring.append(round(255*light)) + screen.set_at((x,height-y),pygame.Color(coloring[0],coloring[1],coloring[2])) + pygame.display.update() +pygame.image.save(screen,"PythonSphere.png") +while True: + for event in pygame.event.get(): + if event.type == QUIT: + pygame.quit() + sys.exit() + if event.type == KEYDOWN: + pass diff --git a/Task/Draw-a-sphere/REXX/draw-a-sphere.rexx b/Task/Draw-a-sphere/REXX/draw-a-sphere.rexx new file mode 100644 index 0000000000..512006fc08 --- /dev/null +++ b/Task/Draw-a-sphere/REXX/draw-a-sphere.rexx @@ -0,0 +1,39 @@ +/*REXX program to express a lighted sphere with simple chars for shading*/ +call drawSphere 19, 4, 2/10 +call drawSphere 10, 2, 4/10 +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────drawSphere subroutine───────────────*/ +drawSphere: procedure; parse arg r, k, ambient +if 1=='f1'x then shading='.:!*oe&#%@' /*for EBCDIC machs.*/ + else shading='·:!ºoe@░▒▓' /*for ASCI machines*/ + lightSource = '30 30 -50' /*the light source.*/ +parse value norm(lightSource) with s1 s2 s3 /*normalize light S*/ +sLen=length(shading); sLen1=sLen-1; rr=r*r + + do i=floor(-r) to ceil(r) ; x= i+.5; xx=x**2; aLine= + do j=floor(-2*r) to ceil(2*r); y=j/2+.5; yy=y**2 + if xx+yy<=rr then do + parse value norm(x y sqrt(rr-xx-yy)) with v1 v2 v3 + dot=s1*v1 + s2*v2 + s3*v3 + if dot>0 then dot=0 + b=abs(dot)**k + ambient + if b<=0 then brite=sLenm1 + else brite=trunc( max( (1-b) * sLen1, 0) ) + aLine=aLine || substr(shading,brite+1,1) + end + else aLine=aLine' ' + end /*j*/ + say strip(aLine,'trailing') + end /*i*/ +return +/*─────────────────────────────────────"1-liner" subroutines────────────*/ +ceil: procedure; parse arg x; _=trunc(x); return _ + (x>0) * (x\=_) +floor: procedure; parse arg x; _=trunc(x); return _ - (x<0) * (x\=_) +norm: parse arg _1 _2 _3; _=sqrt(_1*_1+_2*_2+_3*_3); return _1/_ _2/_ _3/_ +sqrt: procedure; parse arg x; if x=0 then return 0; return .sqrt(x)/1 +.sqrt: 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 by -1 to 0; if m.k>11 then numeric digits m.k; g=.5*(g+x/g);end + return g +.sqrtGuess: numeric form; m.=11; p=d+d%4+2; v=format(x,2,1,,0) 'E0' + parse var v g 'E' _ .; return g*.5'E'_%2 diff --git a/Task/Draw-a-sphere/Racket/draw-a-sphere.rkt b/Task/Draw-a-sphere/Racket/draw-a-sphere.rkt new file mode 100644 index 0000000000..a983114bb4 --- /dev/null +++ b/Task/Draw-a-sphere/Racket/draw-a-sphere.rkt @@ -0,0 +1,4 @@ +#lang typed/racket + +(require plot/typed) +(plot3d (polar3d (λ (θ ρ) 1)) #:altitude 25) diff --git a/Task/Draw-a-sphere/Ruby/draw-a-sphere.rb b/Task/Draw-a-sphere/Ruby/draw-a-sphere.rb new file mode 100644 index 0000000000..ab5f23f50c --- /dev/null +++ b/Task/Draw-a-sphere/Ruby/draw-a-sphere.rb @@ -0,0 +1,28 @@ +Shoes.app :width => 500, :height => 500, :resizable => false do + image 400, 470, :top => 30, :left => 50 do + nostroke + fill "#127" + image :top => 230, :left => 0 do + oval 70, 130, 260, 40 + blur 30 + end + oval 10, 10, 380, 380 + image :top => 0, :left => 0 do + fill "#46D" + oval 30, 30, 338, 338 + blur 10 + end + fill gradient(rgb(1.0, 1.0, 1.0, 0.7), rgb(1.0, 1.0, 1.0, 0.0)) + oval 80, 14, 240, 176 + image :top => 0, :left => 0 do + fill "#79F" + oval 134, 134, 130, 130 + blur 40 + end + image :top => 150, :left => 40, :width => 320, :height => 260 do + fill gradient(rgb(0.7, 0.9, 1.0, 0.0), rgb(0.7, 0.9, 1.0, 0.6)) + oval 60, 60, 200, 136 + blur 20 + end + end +end diff --git a/Task/Draw-a-sphere/Smalltalk/draw-a-sphere.st b/Task/Draw-a-sphere/Smalltalk/draw-a-sphere.st new file mode 100644 index 0000000000..77dd960451 --- /dev/null +++ b/Task/Draw-a-sphere/Smalltalk/draw-a-sphere.st @@ -0,0 +1,63 @@ +Point3D := + Point subclass:#Point3D + instanceVariableNames:'z' + classVariableNames:'' + poolDictionaries:'' + category:'' + inEnvironment:nil. + +Point3D compile:'z ^ z'. +Point3D compile:'z:v z := v'. + +normalize := [:v | |invLen| + invLen := 1 / (dot value:v value:v) sqrt. + v x: v x * invLen. + v y: v y * invLen. + v z: v z * invLen. +]. + +dot := [:a :b | + (a x * b x) + (a y * b y) + (a z * b z) +]. + +drawSphere := [:r :k :amb :dir | + |w h imh vec img| + + w := r*4. h := r*3. + img := Image width:w height:h depth:8. + img photometric:#blackIs0; createPixelStore. + vec := Point3D new. + 0-r to:r do:[:x | + 0-r to:r do:[:y | + |z s lum| + (z := (r*r) - (x*x) - (y*y)) >= 0 ifTrue:[ + vec x: x. + vec y: y. + vec z: z sqrt. + normalize value:vec. + s := dot value:dir value:vec. + s < 0 ifTrue:[ s := 0 ]. + lum := 255 * ((s raisedTo: k) + amb) / (1 + amb). + lum < 0 ifTrue:[ + lum := 0 + ] ifFalse:[ lum > 255 ifTrue:[ + lum := 255 + ]]. + img atX:(x+(w//2)) y:(y+(h//2)) put:(Color greyByte:lum). + ] + ] + ]. + img +]. + +main := [ + |dir img| + + dir := Point3D new x:-30; y:-30; z:50; yourself. + normalize value:dir. + img := drawSphere value: 100 value: 1.5 value: 0.2 value: dir. + img displayOn:(View new extent:400@400; openAndWait). + img saveOn:'sphere.png'. +]. + +main value. diff --git a/Task/Draw-a-sphere/Tcl/draw-a-sphere.tcl b/Task/Draw-a-sphere/Tcl/draw-a-sphere.tcl new file mode 100644 index 0000000000..aa3d780efc --- /dev/null +++ b/Task/Draw-a-sphere/Tcl/draw-a-sphere.tcl @@ -0,0 +1,9 @@ +proc grey {n} {format "#%2.2x%2.2x%2.2x" $n $n $n} + +pack [canvas .c -height 400 -width 640 -background white] + +for {set i 0} {$i < 255} {incr i} { + set h [grey $i] + .c create arc [expr {100+$i/5}] [expr {50+$i/5}] [expr {400-$i/1.5}] [expr {350-$i/1.5}] \ + -start 0 -extent 359 -fill $h -outline $h} +} diff --git a/Task/Dutch-national-flag-problem/0DESCRIPTION b/Task/Dutch-national-flag-problem/0DESCRIPTION new file mode 100644 index 0000000000..1d35506cad --- /dev/null +++ b/Task/Dutch-national-flag-problem/0DESCRIPTION @@ -0,0 +1,12 @@ +The Dutch national flag is composed of three coloured bands in the order red then white and lastly blue. The problem posed by [[wp:Edsger Dijkstra|Edsger Dijkstra]] is: +:Given a number of red, blue and white balls in random order, arrange them in the order of the colours Dutch national flag. +When the problem was first posed, Dijkstra then went on to successively refine a solution, minimising the number of swaps and the number of times the colour of a ball needed to determined and restricting the balls to end in an array, ... + +;This task is to: +# Generate a randomized order of balls ''ensuring that they are not in the order of the Dutch national flag''. +# Sort the balls in a way idiomatic to your language. +# Check the sorted balls ''are'' in the order of the Dutch national flag. + +;Cf. +* [[wp:Dutch national flag problem|Dutch national flag problem]] +* [https://www.google.co.uk/search?rlz=1C1DSGK_enGB472GB472&sugexp=chrome,mod=8&sourceid=chrome&ie=UTF-8&q=Dutch+national+flag+problem#hl=en&rlz=1C1DSGK_enGB472GB472&sclient=psy-ab&q=Probabilistic+analysis+of+algorithms+for+the+Dutch+national+flag+problem&oq=Probabilistic+analysis+of+algorithms+for+the+Dutch+national+flag+problem&gs_l=serp.3...60754.61818.1.62736.1.1.0.0.0.0.72.72.1.1.0...0.0.Pw3RGungndU&psj=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&fp=c33d18147f5082cc&biw=1395&bih=951 Probabilistic analysis of algorithms for the Dutch national flag problem] by Wei-Mei Chen. (pdf) diff --git a/Task/Dutch-national-flag-problem/Ada/dutch-national-flag-problem.ada b/Task/Dutch-national-flag-problem/Ada/dutch-national-flag-problem.ada new file mode 100644 index 0000000000..a440340c96 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Ada/dutch-national-flag-problem.ada @@ -0,0 +1,99 @@ +with Ada.Text_IO, Ada.Numerics.Discrete_Random, Ada.Command_Line; + +procedure Dutch_National_Flag is + + type Colour_Type is (Red, White, Blue); + + Number: Positive range 2 .. Positive'Last := + Positive'Value(Ada.Command_Line.Argument(1)); + -- no sorting if the Number of balls is less than 2 + + type Balls is array(1 .. Number) of Colour_Type; + + function Is_Sorted(B: Balls) return Boolean is + -- checks if balls are in order + begin + for I in Balls'First .. Balls'Last-1 loop + if B(I) > B(I+1) then + return False; + end if; + end loop; + return True; + end Is_Sorted; + + function Random_Balls return Balls is + -- generates an array of random balls, ensuring they are not in order + package Random_Colour is new Ada.Numerics.Discrete_Random(Colour_Type); + Gen: Random_Colour.Generator; + B: Balls; + begin + Random_Colour.Reset(Gen); + loop + for I in Balls'Range loop + B(I) := Random_Colour.Random(Gen); + end loop; + exit when (not Is_Sorted(B)); + -- ... ensuring they are not in order + end loop; + return B; + end Random_Balls; + + procedure Print(Message: String; B: Balls) is + begin + Ada.Text_IO.Put(Message); + for I in B'Range loop + Ada.Text_IO.Put(Colour_Type'Image(B(I))); + if I < B'Last then + Ada.Text_IO.Put(", "); + else + Ada.Text_IO.New_Line; + end if; + end loop; + end Print; + + procedure Sort(Bls: in out Balls) is + -- sort Bls in O(1) time + + Cnt: array(Colour_Type) of Natural := (Red => 0, White => 0, Blue => 0); + Col: Colour_Type; + + procedure Move_Colour_To_Top(Bls: in out Balls; + Colour: Colour_Type; + Start: Positive; + Count: Natural) is + This: Positive := Start; + Tmp: Colour_Type; + begin + for N in Start .. Start+Count-1 loop + while Bls(This) /= Colour loop + This := This + 1; + end loop; -- This is the first index >= N with B(This) = Colour + Tmp := Bls(N); Bls(N) := Bls(This); Bls(This) := Tmp; -- swap + This := This + 1; + end loop; + end Move_Colour_To_Top; + + begin + for Ball in Balls'Range loop + -- count how often each colour is found + Col := Bls(Ball); + Cnt(Col) := Cnt(Col) + 1; + end loop; + Move_Colour_To_Top(Bls, Red, Start => 1, Count => Cnt(Red)); + Move_Colour_To_Top(Bls, White, Start => 1+Cnt(Red), Count => Cnt(White)); + -- all the remaining balls are blue + end Sort; + + A: Balls := Random_Balls; + +begin + Print("Original Order: ", A); + + pragma Assert(not Is_Sorted(A)); -- Check if A is unsorted + + Sort(A); -- A = ((Red**Cnt(Red)= & (White**Cnt(White)) & (Blue**Cnt(Blue))) + + pragma Assert(Is_Sorted(A)); -- Check if A is actually sorted + + Print("After Sorting: ", A); +end Dutch_National_Flag; diff --git a/Task/Dutch-national-flag-problem/AutoIt/dutch-national-flag-problem.autoit b/Task/Dutch-national-flag-problem/AutoIt/dutch-national-flag-problem.autoit new file mode 100644 index 0000000000..e78043a6c2 --- /dev/null +++ b/Task/Dutch-national-flag-problem/AutoIt/dutch-national-flag-problem.autoit @@ -0,0 +1,24 @@ +#include +Dutch_Flag(50) +Func Dutch_Flag($arrayitems) + Local $avArray[$arrayitems] + For $i = 0 To UBound($avArray) - 1 + $avArray[$i] = Random(1, 3, 1) + Next + Local $low = 2, $high = 3, $i = 0 + Local $arraypos = -1 + Local $p = UBound($avArray) - 1 + While $i < $p + if $avArray[$i] < $low Then + $arraypos += 1 + _ArraySwap($avArray[$i], $avArray[$arraypos]) + $i += 1 + ElseIf $avArray[$i] >= $high Then + _ArraySwap($avArray[$i], $avArray[$p]) + $p -= 1 + Else + $i += 1 + EndIf + WEnd + _ArrayDisplay($avArray) +EndFunc ;==>Dutch_Flag diff --git a/Task/Dutch-national-flag-problem/BBC-BASIC/dutch-national-flag-problem.bbc b/Task/Dutch-national-flag-problem/BBC-BASIC/dutch-national-flag-problem.bbc new file mode 100644 index 0000000000..42d4554cbc --- /dev/null +++ b/Task/Dutch-national-flag-problem/BBC-BASIC/dutch-national-flag-problem.bbc @@ -0,0 +1,38 @@ + INSTALL @lib$+"SORTLIB" + Sort% = FN_sortinit(0,0) + + nBalls% = 12 + DIM Balls$(nBalls%-1), Weight%(nBalls%-1), DutchFlag$(2) + DutchFlag$() = "Red ", "White ", "Blue " + + REM. Generate random list of balls, ensuring not sorted: + REPEAT + prev% = 0 : sorted% = TRUE + FOR ball% = 0 TO nBalls%-1 + index% = RND(3) - 1 + Balls$(ball%) = DutchFlag$(index%) + IF index% < prev% THEN sorted% = FALSE + prev% = index% + NEXT + UNTIL NOT sorted% + PRINT "Random list: " SUM(Balls$()) + + REM. Assign Dutch Flag weightings to ball colours: + DutchFlag$ = SUM(DutchFlag$()) + FOR ball% = 0 TO nBalls%-1 + Weight%(ball%) = INSTR(DutchFlag$, Balls$(ball%)) + NEXT + + REM. Sort into Dutch Flag colour sequence: + C% = nBalls% + CALL Sort%, Weight%(0), Balls$(0) + PRINT "Sorted list: " SUM(Balls$()) + + REM Final check: + prev% = 0 : sorted% = TRUE + FOR ball% = 0 TO nBalls%-1 + weight% = INSTR(DutchFlag$, Balls$(ball%)) + IF weight% < prev% THEN sorted% = FALSE + prev% = weight% + NEXT + IF NOT sorted% PRINT "Error: Balls are not in correct order!" diff --git a/Task/Dutch-national-flag-problem/C++/dutch-national-flag-problem.cpp b/Task/Dutch-national-flag-problem/C++/dutch-national-flag-problem.cpp new file mode 100644 index 0000000000..958bbc7e55 --- /dev/null +++ b/Task/Dutch-national-flag-problem/C++/dutch-national-flag-problem.cpp @@ -0,0 +1,41 @@ +#include +#include + +// Dutch national flag problem +template +void dnf_partition(BidIt first, BidIt last, const T& low, const T& high) +{ + for (BidIt next = first; next != last; ) { + if (*next < low) { + std::iter_swap(first++, next++); + } else if (!(*next < high)) { + std::iter_swap(next, --last); + } else { + ++next; + } + } +} + +enum Colors { RED, WHITE, BLUE }; + +void print(const Colors *balls, size_t size) +{ + static const char *label[] = { "red", "white", "blue" }; + + std::cout << "Balls:"; + for (size_t i = 0; i < size; ++i) { + std::cout << ' ' << label[balls[i]]; + } + std::cout << "\nSorted: " << std::boolalpha << std::is_sorted(balls, balls + size) << '\n'; +} + +int main() +{ + Colors balls[] = { RED, WHITE, BLUE, RED, WHITE, BLUE, RED, WHITE, BLUE }; + + std::random_shuffle(balls, balls + 9); + print(balls, 9); + + dnf_partition(balls, balls + 9, WHITE, BLUE); + print(balls, 9); +} diff --git a/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-1.d b/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-1.d new file mode 100644 index 0000000000..3c40cddb56 --- /dev/null +++ b/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-1.d @@ -0,0 +1,31 @@ +import std.stdio, std.random, std.algorithm, std.traits, std.array; + +enum DutchColors { red, white, blue } + +void dutchNationalFlagSort(DutchColors[] items) pure nothrow { + int lo, mid, hi = items.length - 1; + + while (mid <= hi) + final switch (items[mid]) { + case DutchColors.red: + swap(items[lo++], items[mid++]); + break; + case DutchColors.white: + mid++; + break; + case DutchColors.blue: + swap(items[mid], items[hi--]); + break; + } +} + +void main() { + DutchColors[12] balls; + foreach (ref ball; balls) + ball = [EnumMembers!DutchColors][uniform(0, $)]; + + writeln("Original Ball order:\n", balls); + balls.dutchNationalFlagSort(); + writeln("\nSorted Ball Order:\n", balls); + assert(balls[].isSorted(), "Balls not sorted"); +} diff --git a/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-2.d b/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-2.d new file mode 100644 index 0000000000..03a077347b --- /dev/null +++ b/Task/Dutch-national-flag-problem/D/dutch-national-flag-problem-2.d @@ -0,0 +1,72 @@ +import std.stdio, std.random, std.algorithm, std.range, + std.array, std.traits; + +/* +This implementation has less requirements, it works with just +a Bidirectional Range instead of a Random Access Range. + +(Comments modified from "Notes on Programming" by Alexander + Stepanov.) + + Let us assume that somehow we managed to solve the problem up + to some middle point s: + + 0000001111?????22222222 + ^ ^ ^ + f s l (first, second, last) + + If s points to an item with value 0 (red) we swap it with an + element pointed at by f and advance both f and s. + If s refers to an item 1 (white) we just advance s. + If s refers to an item 2 (blue) we swap elements + pointed by l and s and we decrement l. + +In D/Phobos we use Ranges, that are like pairs of iterators. +So 'secondLast' represents the s and l iterators, and the 'first' +range contains f plus an unused end. + +secondLast represents the inclusive range of items not yet seen. +When it's empty, the algorithm has finished. + +Loop variant: in each iteration of the for loop the length of +secondLast decreases by 1. So the algorithm terminates. +*/ +void dutchNationalFlagSort(Range, T)(Range secondLast, + in T lowVal, in T highVal) +pure nothrow if (isBidirectionalRange!Range && + hasSwappableElements!Range && + is(ElementType!Range == T)) { + for (auto first = secondLast; !secondLast.empty; ) + if (secondLast.front == lowVal) { + swap(first.front, secondLast.front); + first.popFront(); + secondLast.popFront(); + } else if (secondLast.front == highVal) { + swap(secondLast.front, secondLast.back); + secondLast.popBack(); + } else + secondLast.popFront(); +} + +void main() { + enum DutchColors { red, white, blue } + DutchColors[12] balls; + foreach (ref ball; balls) + ball = [EnumMembers!DutchColors][uniform(0, $)]; + + writeln("Original Ball order:\n", balls); + balls[].dutchNationalFlagSort(DutchColors.red, + DutchColors.blue); + writeln("\nSorted Ball Order:\n", balls); + assert(balls[].isSorted(), "Balls not sorted"); + + // More tests: + foreach (i; 0 .. 100_000) { + int n = uniform(0, balls.length); + foreach (ref ball; balls[0 .. n]) + ball = [EnumMembers!DutchColors][uniform(0, $)]; + balls[0 .. n].dutchNationalFlagSort(DutchColors.red, + DutchColors.blue); + assert(balls[0 .. n].isSorted()); + } +} diff --git a/Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-1.erl b/Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-1.erl new file mode 100644 index 0000000000..53fef5d216 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-1.erl @@ -0,0 +1,26 @@ +-module(dutch). +-export([random_balls/1, is_dutch/1, dutch/1]). + +ball(red) -> 1; +ball(white) -> 2; +ball(blue) -> 3. + +random_ball() -> lists:nth(random:uniform(3), [red, white, blue]). + +random_balls(N) -> random_balls(N,[]). +random_balls(0,L) -> L; +random_balls(N,L) when N > 0 -> + B = random_ball(), + random_balls(N-1, [B|L]). + +is_dutch([]) -> true; +is_dutch([_]) -> true; +is_dutch([B|[H|L]]) -> (ball(B) < ball(H)) and is_dutch([H|L]); +is_dutch(_) -> false. + +dutch(L) -> dutch([],[],[],L). + +dutch(R, W, B, []) -> R ++ W ++ B; +dutch(R, W, B, [red | L]) -> dutch([red|R], W, B, L); +dutch(R, W, B, [white | L]) -> dutch(R, [white|W], B, L); +dutch(R, W, B, [blue | L]) -> dutch(R, W, [blue|B], L). diff --git a/Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-2.erl b/Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-2.erl new file mode 100644 index 0000000000..be6319d029 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Erlang/dutch-national-flag-problem-2.erl @@ -0,0 +1,6 @@ +main(_) -> + L = random_balls(10), + case is_dutch(L) of + true -> io:format("The random sequence ~p is already in the order of the Dutch flag!~n", [L]); + false -> io:format("The starting random sequence is ~p;~nThe ordered sequence is ~p.~n", [L, dutch(L)]) + end. diff --git a/Task/Dutch-national-flag-problem/Go/dutch-national-flag-problem.go b/Task/Dutch-national-flag-problem/Go/dutch-national-flag-problem.go new file mode 100644 index 0000000000..6a5023bf6e --- /dev/null +++ b/Task/Dutch-national-flag-problem/Go/dutch-national-flag-problem.go @@ -0,0 +1,88 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +// constants define order of colors in Dutch national flag +const ( + red = iota + white + blue + nColors +) + +// zero object of type is valid red ball. +type ball struct { + color int +} + +// order of balls based on DNF +func (b1 ball) lt(b2 ball) bool { + return b1.color < b2.color +} + +// type for arbitrary ordering of balls +type ordering []ball + +// predicate tells if balls are ordered by DNF +func (o ordering) ordered() bool { + var b0 ball + for _, b := range o { + if b.lt(b0) { + return false + } + b0 = b + } + return true +} + +func init() { + rand.Seed(time.Now().Unix()) +} + +// constructor returns new ordering of balls which is randomized but +// guaranteed to be not in DNF order. function panics for n < 2. +func outOfOrder(n int) ordering { + if n < 2 { + panic(fmt.Sprintf("%d invalid", n)) + } + r := make(ordering, n) + for { + for i, _ := range r { + r[i].color = rand.Intn(nColors) + } + if !r.ordered() { + break + } + } + return r +} + +// O(n) algorithm +// http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Flag/ +func (a ordering) sort3() { + lo, mid, hi := 0, 0, len(a)-1 + for mid <= hi { + switch a[mid].color { + case red: + a[lo], a[mid] = a[mid], a[lo] + lo++ + mid++ + case white: + mid++ + default: + a[mid], a[hi] = a[hi], a[mid] + hi-- + } + } +} + +func main() { + f := outOfOrder(12) + fmt.Println(f) + f.sort3() + fmt.Println(f) +} diff --git a/Task/Dutch-national-flag-problem/Haskell/dutch-national-flag-problem-1.hs b/Task/Dutch-national-flag-problem/Haskell/dutch-national-flag-problem-1.hs new file mode 100644 index 0000000000..dea45f3f41 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Haskell/dutch-national-flag-problem-1.hs @@ -0,0 +1,26 @@ +import Data.List (sort) +import System.Random (randomRIO) +import System.IO.Unsafe (unsafePerformIO) + +data Color = Red | White | Blue deriving (Show, Eq, Ord, Enum) + +dutch :: [Color] -> [Color] +dutch = sort + +isDutch :: [Color] -> Bool +isDutch x = x == dutch x + +randomBalls :: Int -> [Color] +randomBalls 0 = [] +randomBalls n = toEnum (unsafePerformIO (randomRIO (fromEnum Red, + fromEnum Blue))) : randomBalls (n - 1) + +main :: IO () +main = do + let a = randomBalls 20 + case isDutch a of + True -> putStrLn $ "The random sequence " ++ show a ++ + " is already in the order of the Dutch national flag!" + False -> do + putStrLn $ "The starting random sequence is " ++ show a ++ "\n" + putStrLn $ "The ordered sequence is " ++ show (dutch a) diff --git a/Task/Dutch-national-flag-problem/Haskell/dutch-national-flag-problem-2.hs b/Task/Dutch-national-flag-problem/Haskell/dutch-national-flag-problem-2.hs new file mode 100644 index 0000000000..190db5ad30 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Haskell/dutch-national-flag-problem-2.hs @@ -0,0 +1,23 @@ +import Data.List (sort) + +inorder n = and $ zipWith (<=) n (tail n) -- or use Data.List.Ordered + +mk012 :: Int -> Int -> [Int] -- definitely unordered +mk012 n = (++[0]).(2:).map (`mod` 3).take n.frr where + -- frr = Fast Rubbish Randoms + frr n = r:frr r where r = n * 7 + 13 + +dutch1 n = (filter (==0) n)++(filter (==1) n)++(filter (==2) n) + +dutch2 n = tric [] [] [] n where -- scan list once; it *may* help + tric a b c [] = a++b++c + tric a b c (x:xs) = case x of + 0 -> tric (x:a) b c xs + 1 -> tric a (x:b) c xs + 2 -> tric a b (x:c) xs + +main = do -- 3 methods, comment/uncomment each for speed comparisons +-- print $ inorder $ sort s -- O(n log n) +-- print $ inorder $ dutch1 s -- O(n) + print $ inorder $ dutch2 s -- O(n) + where s = mk012 10000000 42 diff --git a/Task/Dutch-national-flag-problem/PicoLisp/dutch-national-flag-problem.l b/Task/Dutch-national-flag-problem/PicoLisp/dutch-national-flag-problem.l new file mode 100644 index 0000000000..4f226bd6ba --- /dev/null +++ b/Task/Dutch-national-flag-problem/PicoLisp/dutch-national-flag-problem.l @@ -0,0 +1,13 @@ +(def 'Colors + (list + (def 'RED 1) + (def 'WHITE 2) + (def 'BLUE 3) ) ) + +(let (L (make (do 9 (link (get Colors (rand 1 3))))) S (by val sort L)) + (prin "Original balls ") + (print L) + (prinl (unless (= L S) " not sorted")) + (prin "Sorted balls ") + (print S) + (prinl " are sorted") ) diff --git a/Task/Dutch-national-flag-problem/Prolog/dutch-national-flag-problem-1.pro b/Task/Dutch-national-flag-problem/Prolog/dutch-national-flag-problem-1.pro new file mode 100644 index 0000000000..f58dbff8b1 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Prolog/dutch-national-flag-problem-1.pro @@ -0,0 +1,59 @@ +dutch_flag(N) :- + length(L, N), + repeat, + maplist(init,L), + \+is_dutch_flag(L) , + writeln(L), + test_sorted(L), + sort_dutch_flag(L, TmpFlag), + append(TmpFlag, Flag), + writeln(Flag), + test_sorted(Flag). + + +sort_dutch_flag([], [[], [], []]). + +sort_dutch_flag([blue | T], [R, W, [blue|B]]) :- + sort_dutch_flag(T, [R, W, B]). + +sort_dutch_flag([red | T], [[red|R], W, B]) :- + sort_dutch_flag(T, [R, W, B]). + + +sort_dutch_flag([white | T], [R, [white | W], B]) :- + sort_dutch_flag(T, [R, W, B]). + + +init(C) :- + R is random(3), + nth0(R, [blue, red, white], C). + + +test_sorted(Flag) :- + ( is_dutch_flag(Flag) + -> write('it is a dutch flag') + ; write('it is not a dutch flag')), + nl,nl. + +% First color must be red +is_dutch_flag([red | T]) :- + is_dutch_flag_red(T). + + +is_dutch_flag_red([red|T]) :- + is_dutch_flag_red(T); + % second color must be white + T = [white | T1], + is_dutch_flag_white(T1). + + +is_dutch_flag_white([white | T]) :- + is_dutch_flag_white(T); + % last one must be blue + T = [blue | T1], + is_dutch_flag_blue(T1). + +is_dutch_flag_blue([blue | T]) :- + is_dutch_flag_blue(T). + +is_dutch_flag_blue([]). diff --git a/Task/Dutch-national-flag-problem/Prolog/dutch-national-flag-problem-2.pro b/Task/Dutch-national-flag-problem/Prolog/dutch-national-flag-problem-2.pro new file mode 100644 index 0000000000..ad5818c629 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Prolog/dutch-national-flag-problem-2.pro @@ -0,0 +1,62 @@ +dutch_flag(N) :- + length(L, N), + + % create the list to sort + repeat, + maplist(init,L), + \+is_dutch_flag(L) , + writeln(L), + test_sorted(L), + + foldl(\X^Y^Z^(Y = [Red, White, Blue], + ( X = blue + -> append_dl(Blue, [X|U]-U, Blue1), + Z = [Red, White, Blue1] + ; X = red + -> append_dl(Red, [X|U]-U, Red1), + Z = [Red1, White, Blue] + ; append_dl(White, [X|U]-U, White1), + Z = [Red, White1, Blue])), + L, [R-R, W-W, B-B], [R1, W1, B1]), + append_dl(R1, W1, B1, Flag-[]), + write(Flag), nl, + test_sorted(Flag). + +% append lists in O(1) +append_dl(A-B, B-C, A-C). +append_dl(A-B, B-C, C-D, A-D). + + +init(C) :- + R is random(3), + nth0(R, [blue, red, white], C). + + +test_sorted(Flag) :- + ( is_dutch_flag(Flag) + -> write('it is a dutch flag') + ; write('it is not a dutch flag')), + nl,nl. + +% First color must be red +is_dutch_flag([red | T]) :- + is_dutch_flag_red(T). + + +is_dutch_flag_red([red|T]) :- + is_dutch_flag_red(T); + % second color must be white + T = [white | T1], + is_dutch_flag_white(T1). + + +is_dutch_flag_white([white | T]) :- + is_dutch_flag_white(T); + % last one must be blue + T = [blue | T1], + is_dutch_flag_blue(T1). + +is_dutch_flag_blue([blue | T]) :- + is_dutch_flag_blue(T). + +is_dutch_flag_blue([]). diff --git a/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-1.py b/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-1.py new file mode 100644 index 0000000000..1c5da32a07 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-1.py @@ -0,0 +1,35 @@ +import random + +colours_in_order = 'Red White Blue'.split() + +def dutch_flag_sort(items, order=colours_in_order): + 'return sort of items using the given order' + reverse_index = dict((x,i) for i,x in enumerate(order)) + return sorted(items, key=lambda x: reverse_index[x]) + +def dutch_flag_check(items, order=colours_in_order): + 'Return True if each item of items is in the given order' + reverse_index = dict((x,i) for i,x in enumerate(order)) + order_of_items = [reverse_index[item] for item in items] + return all(x <= y for x, y in zip(order_of_items, order_of_items[1:])) + +def random_balls(mx=5): + 'Select from 1 to mx balls of each colour, randomly' + balls = sum([[colour] * random.randint(1, mx) + for colour in colours_in_order], []) + random.shuffle(balls) + return balls + +def main(): + # Ensure we start unsorted + while True: + balls = random_balls() + if not dutch_flag_check(balls): + break + print("Original Ball order:", balls) + sorted_balls = dutch_flag_sort(balls) + print("Sorted Ball Order:", sorted_balls) + assert dutch_flag_check(sorted_balls), 'Whoops. Not sorted!' + +if __name__ == '__main__': + main() diff --git a/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-2.py b/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-2.py new file mode 100644 index 0000000000..b266ca29bb --- /dev/null +++ b/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-2.py @@ -0,0 +1,5 @@ +from itertools import chain +def dutch_flag_sort2(items, order=colours_in_order): + 'return summed filter of items using the given order' + return list(chain.from_iterable(filter(lambda c: c==colour, items) + for colour in order)) diff --git a/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-3.py b/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-3.py new file mode 100644 index 0000000000..7261409950 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-3.py @@ -0,0 +1,3 @@ +def dutch_flag_sort2(items, order=colours_in_order): + 'return summed filter of items using the given order' + return [c for colour in order for c in items if c==colour] diff --git a/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-4.py b/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-4.py new file mode 100644 index 0000000000..7b43796c72 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-4.py @@ -0,0 +1,3 @@ +def dutch_flag_sort3(items, order=colours_in_order): + 'counts each colour to construct flag' + return sum([[colour] * items.count(colour) for colour in order], []) diff --git a/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-5.py b/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-5.py new file mode 100644 index 0000000000..9ca58308a4 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Python/dutch-national-flag-problem-5.py @@ -0,0 +1,50 @@ +import random + +colours_in_order = 'Red White Blue'.split() + +def dutch_flag_sort(items): + '''\ + In-place sort of list items using the given order. + Python idiom is to return None when argument is modified in-place + + O(n)? Algorithm from Go language implementation of + http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Flag/''' + + lo, mid, hi = 0, 0, len(items)-1 + while mid <= hi: + colour = items[mid] + if colour == 'Red': + items[lo], items[mid] = items[mid], items[lo] + lo += 1 + mid += 1 + elif colour == 'White': + mid += 1 + else: + items[mid], items[hi] = items[hi], items[mid] + hi -= 1 + +def dutch_flag_check(items, order=colours_in_order): + 'Return True if each item of items is in the given order' + order_of_items = [order.index(item) for item in items] + return all(x <= y for x, y in zip(order_of_items, order_of_items[1:])) + +def random_balls(mx=5): + 'Select from 1 to mx balls of each colour, randomly' + balls = sum(([[colour] * random.randint(1, mx) + for colour in colours_in_order]), []) + random.shuffle(balls) + return balls + +def main(): + # Ensure we start unsorted + while 1: + balls = random_balls() + if not dutch_flag_check(balls): + break + print("Original Ball order:", balls) + dutch_flag_sort(balls) + print("Sorted Ball Order:", balls) + assert dutch_flag_check(balls), 'Whoops. Not sorted!' + +if __name__ == '__main__': + main() diff --git a/Task/Dutch-national-flag-problem/REXX/dutch-national-flag-problem-1.rexx b/Task/Dutch-national-flag-problem/REXX/dutch-national-flag-problem-1.rexx new file mode 100644 index 0000000000..2597757634 --- /dev/null +++ b/Task/Dutch-national-flag-problem/REXX/dutch-national-flag-problem-1.rexx @@ -0,0 +1,33 @@ +/*REXX pgm to reorder a set of random colored balls into a correct order*/ +/*which is the order of colors on the Dutch flag: red, white, blue. */ + +parse arg N colors /*get user args from command line*/ +if N=',' | N='' then N=15 /*use default number of balls. */ +if N='' then N=15 /*use default number of balls. */ +if colors='' then colors=space('red white blue') /*use default colors.*/ +Ncolors=words(colors) /*count the number of colors. */ +@=word(colors,Ncolors) word(colors,1) /*ensure balls aren't in order. */ + + do g=3 to N /*generate a random # of balls. */ + @=@ word(colors,random(1,Ncolors)) + end /*g*/ + +say 'number of colored balls generated = ' N ; say +say 'original ball order:' +say @ ; say +$=; do j=1 for Ncolors; ; _=word(colors,j) + $=$ copies(_' ',countWords(_,@)) + end /*j*/ +say ' sorted ball order:' +say space($); say + + do k=2 to N /*ensure the balls are in order. */ + if wordpos(word($,k),colors)>=wordpos(word($,k-1),colors) then iterate + say "The list of sorted balls isn't in proper order!"; exit 13 + end /*k*/ + +say ' sorted ball list has been confirmed as being sorted correctly.' +exit /*stick a fork in it, we're done.* +/*──────────────────────────────────COUNTWORDS subroutine───────────────*/ +countWords: procedure; parse arg ?,hay; s=1 + do r=0 until _==0; _=wordpos(?,hay,s); s=_+1; end; return r diff --git a/Task/Dutch-national-flag-problem/REXX/dutch-national-flag-problem-2.rexx b/Task/Dutch-national-flag-problem/REXX/dutch-national-flag-problem-2.rexx new file mode 100644 index 0000000000..6b6b44a706 --- /dev/null +++ b/Task/Dutch-national-flag-problem/REXX/dutch-national-flag-problem-2.rexx @@ -0,0 +1,30 @@ +/*REXX pgm to reorder a set of random colored balls into a correct order*/ +/*which is the order of colors on the Dutch flag: red, white, blue. */ + +parse arg N colors . /*get user args from command line*/ +if N==',' | N=='' then N=15 /*use default number of balls. */ +if colors='' then colors='RWB' /*default: R=red, W=white, B=blue*/ +Ncolors=length(colors) /*count the number of colors. */ +@=right(colors,1)left(colors,1) /*ensure balls aren't in order. */ + + do g=3 to N /*generate a random # of balls. */ + @=@ || substr(colors,random(1,Ncolors),1) + end /*g*/ + +say 'number of colored balls generated = ' N ; say +say 'original ball order:' +say @ ; say +$=; do j=1 for Ncolors; _=substr(colors,j,1) + #=length(@)-length(space(translate(@,,_),0)) + $=$||copies(_,#) + end /*j*/ +say ' sorted ball order:' +say $; say + + do k=2 to N /*ensure the balls are in order. */ + if pos(substr($,k,1),colors)>=pos(substr($,k-1,1),colors) then iterate + say "The list of sorted balls isn't in proper order!"; exit 13 + end /*k*/ + +say ' sorted ball list has been confirmed as being sorted correctly.' + /*stick a fork in it, we're done.*/ diff --git a/Task/Dutch-national-flag-problem/Ruby/dutch-national-flag-problem-1.rb b/Task/Dutch-national-flag-problem/Ruby/dutch-national-flag-problem-1.rb new file mode 100644 index 0000000000..102bb597c3 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Ruby/dutch-national-flag-problem-1.rb @@ -0,0 +1,60 @@ +module Dutch + # Could use a class for the balls, but that's a little heavy. + # We'll just use symbols. + + # List of colors, in order + Symbols = [:red, :white, :blue] + + # Reverse map from symbol to numeric value + Values = Hash[Symbols.each_with_index.to_a] + + # Pick a color at random + def self.random_ball + Symbols[rand 3] + end + + # But we will use a custom subclass of Array for the list of balls + class Balls < Array + + # Generate a given-sized list of random balls + def self.random(n) + self.new(n.times.map { Dutch.random_ball }) + end + + # Test to see if the list is already in order + def dutch? + return true if length < 2 + Values[self[0]] < Values[self[1]] && slice(1..-1).dutch? + end + + # Traditional in-place sort + def dutch! + lo = -1 + hi = length + i = 0 + while i < hi do + case self[i] + when :red + lo += 1 + self[lo], self[i] = self[i], self[lo] + i += 1 + when :white + i += 1 + when :blue + hi -= 1 + self[hi], self[i] = self[i], self[hi] + end + end + self + end + + # Recursive, non-self-modifying version + def dutch(acc = { :red => 0, :white => 0, :blue => 0}) + return self.class.new( + Symbols.map { |c| [c] * acc[c] }.inject(&:+) + ) if length == 0 + acc[first]+=1 + return slice(1..-1).dutch( acc ) + end + end +end diff --git a/Task/Dutch-national-flag-problem/Ruby/dutch-national-flag-problem-2.rb b/Task/Dutch-national-flag-problem/Ruby/dutch-national-flag-problem-2.rb new file mode 100644 index 0000000000..3efd4e95b5 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Ruby/dutch-national-flag-problem-2.rb @@ -0,0 +1,9 @@ +balls = nil +while balls.nil? or balls.dutch? do + balls = Dutch::Balls.random 8 +end +puts "Start: #{balls}" +puts "Sorted: #{balls.dutch}" +puts "Intact: #{balls}" +puts "In-place: #{balls.dutch!}" +puts "Modified: #{balls}" diff --git a/Task/Dutch-national-flag-problem/Tcl/dutch-national-flag-problem.tcl b/Task/Dutch-national-flag-problem/Tcl/dutch-national-flag-problem.tcl new file mode 100644 index 0000000000..52cf7ad47a --- /dev/null +++ b/Task/Dutch-national-flag-problem/Tcl/dutch-national-flag-problem.tcl @@ -0,0 +1,30 @@ +# The comparison function +proc dutchflagcompare {a b} { + set colors {red white blue} + return [expr {[lsearch $colors $a] - [lsearch $colors $b]}] +} + +# The test function (evil shimmer of list to string!) +proc isFlagSorted lst { + expr {![regexp {blue.*(white|red)} $lst] && ![regexp {white.*red} $lst]} +} + +# A ball generator +proc generateBalls n { + for {set i 0} {$i<$n} {incr i} { + lappend result [lindex {red white blue} [expr {int(rand()*3)}]] + } + return $result +} + +# Do the challenge with 20 balls +set balls [generateBalls 20] +if {[isFlagSorted $balls]} { + error "already a sorted flag" +} +set sorted [lsort -command dutchflagcompare $balls] +if {[isFlagSorted $sorted]} { + puts "Sorted the flag\n$sorted" +} else { + puts "sort failed\n$sorted" +} diff --git a/Task/Dynamic-variable-names/0DESCRIPTION b/Task/Dynamic-variable-names/0DESCRIPTION new file mode 100644 index 0000000000..ea830b64cd --- /dev/null +++ b/Task/Dynamic-variable-names/0DESCRIPTION @@ -0,0 +1,4 @@ +Create a variable with a user-defined name. The variable name should ''not'' be written in the program text, but should be taken from the user dynamically. + +;See also +* [[Eval in environment]] is a similar task. diff --git a/Task/Dynamic-variable-names/1META.yaml b/Task/Dynamic-variable-names/1META.yaml new file mode 100644 index 0000000000..f6d82c59ad --- /dev/null +++ b/Task/Dynamic-variable-names/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming environment operations diff --git a/Task/Dynamic-variable-names/AutoHotkey/dynamic-variable-names.ahk b/Task/Dynamic-variable-names/AutoHotkey/dynamic-variable-names.ahk new file mode 100644 index 0000000000..b047173abb --- /dev/null +++ b/Task/Dynamic-variable-names/AutoHotkey/dynamic-variable-names.ahk @@ -0,0 +1,4 @@ +InputBox, Dynamic, Variable Name +%Dynamic% = hello +ListVars +MsgBox % %dynamic% ; says hello diff --git a/Task/Dynamic-variable-names/BASIC/dynamic-variable-names.bas b/Task/Dynamic-variable-names/BASIC/dynamic-variable-names.bas new file mode 100644 index 0000000000..ae49f5cfcf --- /dev/null +++ b/Task/Dynamic-variable-names/BASIC/dynamic-variable-names.bas @@ -0,0 +1,2 @@ +10 INPUT "Enter a variable name", v$ +20 KEYIN "LET "+v$+"=42" diff --git a/Task/Dynamic-variable-names/BBC-BASIC/dynamic-variable-names.bbc b/Task/Dynamic-variable-names/BBC-BASIC/dynamic-variable-names.bbc new file mode 100644 index 0000000000..a23e735f25 --- /dev/null +++ b/Task/Dynamic-variable-names/BBC-BASIC/dynamic-variable-names.bbc @@ -0,0 +1,7 @@ + INPUT "Enter a variable name: " name$ + INPUT "Enter a numeric value: " numeric$ + dummy% = EVAL("FNassign("+name$+","+numeric$+")") + PRINT "Variable " name$ " now has the value "; EVAL(name$) + END + + DEF FNassign(RETURN n, v) : n = v : = 0 diff --git a/Task/Dynamic-variable-names/Batch-File/dynamic-variable-names.bat b/Task/Dynamic-variable-names/Batch-File/dynamic-variable-names.bat new file mode 100644 index 0000000000..cb2c8a212e --- /dev/null +++ b/Task/Dynamic-variable-names/Batch-File/dynamic-variable-names.bat @@ -0,0 +1,14 @@ +@echo off +setlocal enableDelayedExpansion + +set /p "name=Enter a variable name: " +set /p "value=Enter a value: " + +::Create the variable and set its value +set "%name%=%value%" + +::Display the value without delayed expansion +call echo %name%=%%%name%%% + +::Display the value using delayed expansion +echo %name%=!%name%! diff --git a/Task/Dynamic-variable-names/Bracmat/dynamic-variable-names.bracmat b/Task/Dynamic-variable-names/Bracmat/dynamic-variable-names.bracmat new file mode 100644 index 0000000000..0e2b0db968 --- /dev/null +++ b/Task/Dynamic-variable-names/Bracmat/dynamic-variable-names.bracmat @@ -0,0 +1,9 @@ +( put$"Enter a variable name: " +& get$:?name +& whl + ' ( put$"Enter a numeric value: " + & get$:?numeric:~# + ) +& !numeric:?!name +& put$(str$("Variable " !name " now has the value " !!name \n)) +); diff --git a/Task/Dynamic-variable-names/Clojure/dynamic-variable-names.clj b/Task/Dynamic-variable-names/Clojure/dynamic-variable-names.clj new file mode 100644 index 0000000000..7753e7b5bd --- /dev/null +++ b/Task/Dynamic-variable-names/Clojure/dynamic-variable-names.clj @@ -0,0 +1 @@ +(eval `(def ~(symbol (read)) 42)) diff --git a/Task/Dynamic-variable-names/Common-Lisp/dynamic-variable-names-1.lisp b/Task/Dynamic-variable-names/Common-Lisp/dynamic-variable-names-1.lisp new file mode 100644 index 0000000000..a425deaa40 --- /dev/null +++ b/Task/Dynamic-variable-names/Common-Lisp/dynamic-variable-names-1.lisp @@ -0,0 +1,6 @@ +(defun rc-create-variable (name initial-value) + "Create a global variable whose name is NAME in the current package and which is bound to INITIAL-VALUE." + (let ((symbol (intern name))) + (proclaim `(special ,symbol)) + (setf (symbol-value symbol) initial-value) + symbol)) diff --git a/Task/Dynamic-variable-names/Common-Lisp/dynamic-variable-names-2.lisp b/Task/Dynamic-variable-names/Common-Lisp/dynamic-variable-names-2.lisp new file mode 100644 index 0000000000..4def18d4bb --- /dev/null +++ b/Task/Dynamic-variable-names/Common-Lisp/dynamic-variable-names-2.lisp @@ -0,0 +1,5 @@ +CL-USER> (rc-create-variable "GREETING" "hello") +GREETING + +CL-USER> (print greeting) +"hello" diff --git a/Task/Dynamic-variable-names/E/dynamic-variable-names.e b/Task/Dynamic-variable-names/E/dynamic-variable-names.e new file mode 100644 index 0000000000..a02b4d17bd --- /dev/null +++ b/Task/Dynamic-variable-names/E/dynamic-variable-names.e @@ -0,0 +1,27 @@ +def makeNounExpr := + +def dynVarName(name) { + def variable := makeNounExpr(null, name, null) + + return e`{ + + def a := 1 + def b := 2 + def c := 3 + + { + def $variable := "BOO!" + [a, b, c] + } + + }`.eval(safeScope) +} + +? dynVarName("foo") +# value: [1, 2, 3] + +? dynVarName("b") +# value: [1, "BOO!", 3] + +? dynVarName("c") +# value: [1, 2, "BOO!"] diff --git a/Task/Dynamic-variable-names/Forth/dynamic-variable-names.fth b/Task/Dynamic-variable-names/Forth/dynamic-variable-names.fth new file mode 100644 index 0000000000..f742ce7b21 --- /dev/null +++ b/Task/Dynamic-variable-names/Forth/dynamic-variable-names.fth @@ -0,0 +1,3 @@ +s" VARIABLE " pad swap move +." Variable name: " pad 9 + 80 accept +pad swap 9 + evaluate diff --git a/Task/Dynamic-variable-names/Haskell/dynamic-variable-names.hs b/Task/Dynamic-variable-names/Haskell/dynamic-variable-names.hs new file mode 100644 index 0000000000..0926e381a5 --- /dev/null +++ b/Task/Dynamic-variable-names/Haskell/dynamic-variable-names.hs @@ -0,0 +1,6 @@ +data Var a = Var String a deriving Show +main = do + putStrLn "please enter you variable name" + vName <- getLine + let var = Var vName 42 + putStrLn $ "this is your variable: " ++ show var diff --git a/Task/Dynamic-variable-names/JavaScript/dynamic-variable-names.js b/Task/Dynamic-variable-names/JavaScript/dynamic-variable-names.js new file mode 100644 index 0000000000..5efd70a90e --- /dev/null +++ b/Task/Dynamic-variable-names/JavaScript/dynamic-variable-names.js @@ -0,0 +1,3 @@ +var varname = 'foo'; // pretend a user input that +var value = 42; +eval('var ' + varname + '=' + value); diff --git a/Task/Dynamic-variable-names/Lua/dynamic-variable-names.lua b/Task/Dynamic-variable-names/Lua/dynamic-variable-names.lua new file mode 100644 index 0000000000..b72107734f --- /dev/null +++ b/Task/Dynamic-variable-names/Lua/dynamic-variable-names.lua @@ -0,0 +1 @@ +_G[io.read()] = 5 --puts 5 in a global variable named by the user diff --git a/Task/Dynamic-variable-names/PHP/dynamic-variable-names.php b/Task/Dynamic-variable-names/PHP/dynamic-variable-names.php new file mode 100644 index 0000000000..7de3d8aa2d --- /dev/null +++ b/Task/Dynamic-variable-names/PHP/dynamic-variable-names.php @@ -0,0 +1,5 @@ + diff --git a/Task/Dynamic-variable-names/Perl/dynamic-variable-names-1.pl b/Task/Dynamic-variable-names/Perl/dynamic-variable-names-1.pl new file mode 100644 index 0000000000..f4aed491b3 --- /dev/null +++ b/Task/Dynamic-variable-names/Perl/dynamic-variable-names-1.pl @@ -0,0 +1,7 @@ +print "Enter a variable name: "; +$varname = ; # type in "foo" on standard input +chomp($varname); +$$varname = 42; # when you try to dereference a string, it will be + # treated as a "symbolic reference", where they + # take the string as the name of the variable +print "$foo\n"; # prints "42" diff --git a/Task/Dynamic-variable-names/Perl/dynamic-variable-names-2.pl b/Task/Dynamic-variable-names/Perl/dynamic-variable-names-2.pl new file mode 100644 index 0000000000..0f1ebe6a7a --- /dev/null +++ b/Task/Dynamic-variable-names/Perl/dynamic-variable-names-2.pl @@ -0,0 +1,9 @@ +use strict; + +print "Enter a variable name: "; +my $foo; +my $varname = ; # type in "foo" on standard input +chomp($varname); +my $varref = eval('\$' . $varname); +$$varref = 42; +print "$foo\n"; # prints "42" diff --git a/Task/Dynamic-variable-names/PicoLisp/dynamic-variable-names.l b/Task/Dynamic-variable-names/PicoLisp/dynamic-variable-names.l new file mode 100644 index 0000000000..4127896005 --- /dev/null +++ b/Task/Dynamic-variable-names/PicoLisp/dynamic-variable-names.l @@ -0,0 +1,6 @@ +(de userVariable () + (prin "Enter a variable name: ") + (let Var (line T) # Read transient symbol + (prin "Enter a value: ") + (set Var (read)) # Set symbol's value + (println 'Variable Var 'Value (val Var)) ) ) # Print them diff --git a/Task/Dynamic-variable-names/Python/dynamic-variable-names-1.py b/Task/Dynamic-variable-names/Python/dynamic-variable-names-1.py new file mode 100644 index 0000000000..be27f14a68 --- /dev/null +++ b/Task/Dynamic-variable-names/Python/dynamic-variable-names-1.py @@ -0,0 +1,5 @@ +>>> name = raw_input("Enter a variable name: ") +Enter a variable name: X +>>> globals()[name] = 42 +>>> X +42 diff --git a/Task/Dynamic-variable-names/Python/dynamic-variable-names-2.py b/Task/Dynamic-variable-names/Python/dynamic-variable-names-2.py new file mode 100644 index 0000000000..909a2cb0c5 --- /dev/null +++ b/Task/Dynamic-variable-names/Python/dynamic-variable-names-2.py @@ -0,0 +1,5 @@ +>>> name = input("Enter a variable name: ") +Enter a variable name: X +>>> globals()[name] = 42 +>>> X +42 diff --git a/Task/Dynamic-variable-names/R/dynamic-variable-names.r b/Task/Dynamic-variable-names/R/dynamic-variable-names.r new file mode 100644 index 0000000000..fea8d1de72 --- /dev/null +++ b/Task/Dynamic-variable-names/R/dynamic-variable-names.r @@ -0,0 +1,10 @@ +# Read the name in from a command prompt +varname <- readline("Please name your variable >") +# Make sure the name is valid for a variable +varname <- make.names(varname) +message(paste("The variable being assigned is '", varname, "'")) +# Assign the variable (with value 42) into the user workspace (global environment) +assign(varname, 42) +#Check that the value has been assigned ok +ls(pattern=varname) +get(varname) diff --git a/Task/Dynamic-variable-names/REXX/dynamic-variable-names.rexx b/Task/Dynamic-variable-names/REXX/dynamic-variable-names.rexx new file mode 100644 index 0000000000..e6ddbdd209 --- /dev/null +++ b/Task/Dynamic-variable-names/REXX/dynamic-variable-names.rexx @@ -0,0 +1,7 @@ +/*REXX program to show use of dynamic variable names. */ + +parse arg new value +say 'Arguments as they were entered via the command line =' new value +say +call value new,value +say 'The newly assigned value (as per the VALUE bif)------' new value(new) diff --git a/Task/Dynamic-variable-names/Ruby/dynamic-variable-names.rb b/Task/Dynamic-variable-names/Ruby/dynamic-variable-names.rb new file mode 100644 index 0000000000..ed9005babd --- /dev/null +++ b/Task/Dynamic-variable-names/Ruby/dynamic-variable-names.rb @@ -0,0 +1,4 @@ +p "Enter a variable name" +x = gets.chomp! +instance_variable_set "@" + x, 42 +p "The value of #{x} is #{instance_variable_get "@" + x}" diff --git a/Task/Dynamic-variable-names/Scheme/dynamic-variable-names.ss b/Task/Dynamic-variable-names/Scheme/dynamic-variable-names.ss new file mode 100644 index 0000000000..ee9ab8fc66 --- /dev/null +++ b/Task/Dynamic-variable-names/Scheme/dynamic-variable-names.ss @@ -0,0 +1,8 @@ +=> (define (create-variable name initial-val) + (eval `(define ,name ,initial-val) (interaction-environment))) + +=> (create-variable (read) 50) + hello +50 diff --git a/Task/Dynamic-variable-names/Smalltalk/dynamic-variable-names.st b/Task/Dynamic-variable-names/Smalltalk/dynamic-variable-names.st new file mode 100644 index 0000000000..efd1979d35 --- /dev/null +++ b/Task/Dynamic-variable-names/Smalltalk/dynamic-variable-names.st @@ -0,0 +1,9 @@ +| varName | +varName := FillInTheBlankMorph + request: 'Enter a variable name'. +Compiler + evaluate: '| ', varName, ' | ', varName, ' := 42. + Transcript + show: ''value of ', varName, '''; + show: '' is ''; + show: ', varName. diff --git a/Task/Dynamic-variable-names/Tcl/dynamic-variable-names-1.tcl b/Task/Dynamic-variable-names/Tcl/dynamic-variable-names-1.tcl new file mode 100644 index 0000000000..d0d6d14e8e --- /dev/null +++ b/Task/Dynamic-variable-names/Tcl/dynamic-variable-names-1.tcl @@ -0,0 +1,4 @@ +puts "Enter a variable name:" +gets stdin varname +set $varname 42 +puts "I have set variable $varname to [set $varname]" diff --git a/Task/Dynamic-variable-names/Tcl/dynamic-variable-names-2.tcl b/Task/Dynamic-variable-names/Tcl/dynamic-variable-names-2.tcl new file mode 100644 index 0000000000..806971bfbd --- /dev/null +++ b/Task/Dynamic-variable-names/Tcl/dynamic-variable-names-2.tcl @@ -0,0 +1,4 @@ +puts -nonewline "Enter an element name: "; flush stdout +gets stdin elemname +set ary($elemname) [expr int(rand()*100)] +puts "I have set element $elemname to $ary($elemname)" diff --git a/Task/Dynamic-variable-names/Tcl/dynamic-variable-names-3.tcl b/Task/Dynamic-variable-names/Tcl/dynamic-variable-names-3.tcl new file mode 100644 index 0000000000..8f4ce1ef8f --- /dev/null +++ b/Task/Dynamic-variable-names/Tcl/dynamic-variable-names-3.tcl @@ -0,0 +1,5 @@ +puts -nonewline "Enter a variable name: "; flush stdout +gets stdin varname +upvar 0 $varname v; # The ‘0’ for “current scope” +set v [expr int(rand()*100)] +puts "I have set variable $varname to $v (see for yourself: [set $varname])" diff --git a/Task/Echo-server/0DESCRIPTION b/Task/Echo-server/0DESCRIPTION new file mode 100644 index 0000000000..47951228ec --- /dev/null +++ b/Task/Echo-server/0DESCRIPTION @@ -0,0 +1,5 @@ +Create a network service that sits on TCP port 12321, which accepts connections on that port, and which echoes complete lines (using a carriage-return/line-feed sequence as line separator) back to clients. No error handling is required. For the purposes of testing, it is only necessary to support connections from localhost (127.0.0.1 or perhaps ::1). Logging of connection information to standard output is recommended. + +The implementation must be able to handle simultaneous connections from multiple clients. A multi-threaded or multi-process solution may be used. Each connection must be able to echo more than a single line. + +The implementation must not stop responding to other clients if one client sends a partial line or stops reading responses. diff --git a/Task/Echo-server/1META.yaml b/Task/Echo-server/1META.yaml new file mode 100644 index 0000000000..688669690e --- /dev/null +++ b/Task/Echo-server/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Networking and Web Interaction diff --git a/Task/Echo-server/Ada/echo-server.ada b/Task/Echo-server/Ada/echo-server.ada new file mode 100644 index 0000000000..b390f0f1d8 --- /dev/null +++ b/Task/Echo-server/Ada/echo-server.ada @@ -0,0 +1,38 @@ +with Ada.Text_IO; +with Ada.IO_Exceptions; +with GNAT.Sockets; +procedure Echo_Server is + Receiver : GNAT.Sockets.Socket_Type; + Connection : GNAT.Sockets.Socket_Type; + Client : GNAT.Sockets.Sock_Addr_Type; + Channel : GNAT.Sockets.Stream_Access; +begin + GNAT.Sockets.Create_Socket (Socket => Receiver); + GNAT.Sockets.Set_Socket_Option + (Socket => Receiver, + Option => (Name => GNAT.Sockets.Reuse_Address, Enabled => True)); + GNAT.Sockets.Bind_Socket + (Socket => Receiver, + Address => (Family => GNAT.Sockets.Family_Inet, + Addr => GNAT.Sockets.Inet_Addr ("127.0.0.1"), + Port => 12321)); + GNAT.Sockets.Listen_Socket (Socket => Receiver); + loop + GNAT.Sockets.Accept_Socket + (Server => Receiver, + Socket => Connection, + Address => Client); + Ada.Text_IO.Put_Line + ("Client connected from " & GNAT.Sockets.Image (Client)); + Channel := GNAT.Sockets.Stream (Connection); + begin + loop + Character'Output (Channel, Character'Input (Channel)); + end loop; + exception + when Ada.IO_Exceptions.End_Error => + null; + end; + GNAT.Sockets.Close_Socket (Connection); + end loop; +end Echo_Server; diff --git a/Task/Echo-server/AutoHotkey/echo-server.ahk b/Task/Echo-server/AutoHotkey/echo-server.ahk new file mode 100644 index 0000000000..bd5a0a7f2b --- /dev/null +++ b/Task/Echo-server/AutoHotkey/echo-server.ahk @@ -0,0 +1,200 @@ +#SingleInstance Force +Network_Port = 12321 +Network_Address = 127.0.0.1 + +NewData := false +DataReceived = +Gosub Connection_Init +return + +Connection_Init: +OnExit, ExitSub +socket := PrepareForIncomingConnection(Network_Address, Network_Port) +if socket = -1 + ExitApp + +Process, Exist +DetectHiddenWindows On +ScriptMainWindowId := WinExist("ahk_class AutoHotkey ahk_pid " . ErrorLevel) +DetectHiddenWindows Off + +NotificationMsg = 0x5555 +OnMessage(NotificationMsg, "ReceiveData") + +ExitMsg = 0x6666 +OnMessage(ExitMsg, "ExitData") + +FD_READ = 1 +FD_CLOSE = 32 +FD_CONNECT = 20 + +if DllCall("Ws2_32\WSAAsyncSelect", "UInt", socket, + "UInt", ScriptMainWindowId, "UInt", ExitMsg, "Int", FD_CLOSE) +{ + msgbox, closed +} + +if DllCall("Ws2_32\WSAAsyncSelect", "UInt", socket, + "UInt", ScriptMainWindowId, "UInt", NotificationMsg, "Int", + FD_READ|FD_CONNECT) +{ + MsgBox % "WSAAsyncSelect() indicated Winsock error " + . DllCall("Ws2_32\WSAGetLastError") + DllCall("Ws2_32\WSAAsyncSelect", "UInt", socket, + "UInt", ScriptMainWindowId, "UInt", ExitMsg, "Int", FD_CLOSE) + ExitApp +} + +SetTimer, NewConnectionCheck, 500 +return + +PrepareForIncomingConnection(IPAddress, Port) +{ + VarSetCapacity(wsaData, 32) + result := DllCall("Ws2_32\WSAStartup", "UShort", 0x0002, "UInt", &wsaData) + if ErrorLevel + { + MsgBox % "WSAStartup() could not be called due to error %ErrorLevel%. " + . "Winsock 2.0 or higher is required." + return -1 + } + if result + { + MsgBox % "WSAStartup() indicated Winsock error " + . DllCall("Ws2_32\WSAGetLastError") + return -1 + } + AF_INET = 2 + SOCK_STREAM = 1 + IPPROTO_TCP = 6 + socket := DllCall("Ws2_32\socket", "Int", AF_INET, + "Int", SOCK_STREAM, "Int", IPPROTO_TCP) + if socket = -1 + { + MsgBox % "socket() indicated Winsock error " + . DllCall("Ws2_32\WSAGetLastError") + return -1 + } + SizeOfSocketAddress = 16 + VarSetCapacity(SocketAddress, SizeOfSocketAddress) + InsertInteger(2, SocketAddress, 0, AF_INET) + InsertInteger(DllCall("Ws2_32\htons", "UShort", Port), SocketAddress, 2, 2) + InsertInteger(DllCall("Ws2_32\inet_addr", "Str", IPAddress), + SocketAddress, 4, 4) + if DllCall("Ws2_32\bind", "UInt", socket, + "UInt", &SocketAddress, "Int", SizeOfSocketAddress) + { + MsgBox % "bind() indicated Winsock error " + . DllCall("Ws2_32\WSAGetLastError") . "?" + return -1 + } + if DllCall("Ws2_32\listen", "UInt", socket, "UInt", "SOMAXCONN") + { + MsgBox % "LISTEN() indicated Winsock error " + . DllCall("Ws2_32\WSAGetLastError") . "?" + return -1 + } + return socket +} + +ReceiveData(wParam, lParam) +{ + global DataReceived + global NewData + global mydata + global ConnectionList + socket := wParam + ReceivedDataSize = 4096 + Loop + { + VarSetCapacity(ReceivedData, ReceivedDataSize, 0) + ReceivedDataLength := DllCall("Ws2_32\recv", "UInt", + socket, "Str", ReceivedData, "Int", ReceivedDataSize, "Int", 0) + if ReceivedDataLength = 0 + { + StringReplace, ConnectionList, ConnectionList, %socket%`n + DllCall("Ws2_32\closesocket", "UInt", socket) + } + if ReceivedDataLength = -1 + { + WinsockError := DllCall("Ws2_32\WSAGetLastError") + if WinsockError = 10035 + { + DataReceived = %TempDataReceived% + NewData := true + return 1 + } + if WinsockError <> 10054 + { + MsgBox % "recv() indicated Winsock error " . WinsockError + StringReplace, ConnectionList, ConnectionList, %socket%`n + DllCall("Ws2_32\closesocket", "UInt", socket) + } + } + mydata := ReceivedData + gosub myreceive + if (A_Index = 1) + TempDataReceived = + TempDataReceived = %TempDataReceived%%ReceivedData% + } + return 1 +} + +ExitData(wParam, lParam) +{ + global ConnectionList + socket := wParam + ReceivedDataSize = 16 + VarSetCapacity(ReceivedData, ReceivedDataSize, 0) + ReceivedDataLength := DllCall("Ws2_32\recv", "UInt", socket, + "Str", ReceivedData, "Int", ReceivedDataSize, "Int", 0) + StringReplace, ConnectionList, ConnectionList, %socket%`n + DllCall("Ws2_32\closesocket", "UInt", socket) + return 1 +} + +SendData(wParam,SendData) +{ + SendDataSize := VarSetCapacity(SendData) + SendDataSize += 1 + Loop, parse, wParam, `n + { + If A_LoopField = + Continue + socket := A_LoopField + sendret := DllCall("Ws2_32\send", "UInt", socket, + "Str", SendData, "Int", SendDatasize, "Int", 0) + } +} + + +InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4) +{ + Loop %pSize% + DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, + "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF) +} + +NewConnectionCheck: +ConnectionCheck := DllCall("Ws2_32\accept", "UInt", socket, + "UInt", &SocketAddress, "Int", SizeOfSocketAddress) +if ConnectionCheck > 1 + ConnectionList = %ConnectionList%%ConnectionCheck%`n +Return + +SendProcedure: +If ConnectionList <> +{ + SendText = %A_Hour%:%A_Min%:%A_Sec% + SendData(ConnectionList,SendText) +} +Return + +myreceive: + TrayTip, server, %mydata%, ,16 + return + +GuiClose: +ExitSub: +DllCall("Ws2_32\WSACleanup") +ExitApp diff --git a/Task/Echo-server/BBC-BASIC/echo-server.bbc b/Task/Echo-server/BBC-BASIC/echo-server.bbc new file mode 100644 index 0000000000..c403ced0ed --- /dev/null +++ b/Task/Echo-server/BBC-BASIC/echo-server.bbc @@ -0,0 +1,54 @@ + INSTALL @lib$+"SOCKLIB" + PROC_initsockets + + maxSess% = 8 + DIM sock%(maxSess%-1), rcvd$(maxSess%-1), Buffer% 255 + + ON ERROR PRINT REPORT$ : PROC_exitsockets : END + ON CLOSE PROC_exitsockets : QUIT + + crlf$ = CHR$13 + CHR$10 + port$ = "12321" + host$ = FN_gethostname + PRINT "Host name is " host$ + + listen% = FN_tcplisten(host$, port$) + PRINT "Listening on port ";port$ + + REPEAT + socket% = FN_check_connection(listen%) + IF socket% THEN + FOR i% = 0 TO maxSess%-1 + IF sock%(i%) = 0 THEN + sock%(i%) = socket% + rcvd$(i%) = "" + PRINT "Connection on socket "; sock%(i%) " opened" + EXIT FOR + ENDIF + NEXT i% + listen% = FN_tcplisten(host$, port$) + ENDIF + + FOR i% = 0 TO maxSess%-1 + IF sock%(i%) THEN + res% = FN_readsocket(sock%(i%), Buffer%, 256) + IF res% >= 0 THEN + Buffer%?res% = 0 + rcvd$(i%) += $$Buffer% + crlf% = INSTR(rcvd$(i%), crlf$) + IF crlf% THEN + echo$ = LEFT$(rcvd$(i%), crlf%-1) + res% = FN_writelinesocket(sock%(i%), echo$) + rcvd$(i%) = MID$(rcvd$(i%), crlf%+2) + ENDIF + ELSE + PROC_closesocket(sock%(i%)) + PRINT "Connection on socket " ; sock%(i%) " closed" + sock%(i%) = 0 + ENDIF + ENDIF + NEXT i% + + WAIT 0 + UNTIL FALSE + END diff --git a/Task/Echo-server/C/echo-server.c b/Task/Echo-server/C/echo-server.c new file mode 100644 index 0000000000..7d23ec1d0f --- /dev/null +++ b/Task/Echo-server/C/echo-server.c @@ -0,0 +1,118 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_ENQUEUED 20 +#define BUF_LEN 256 +#define PORT_STR "12321" + +/* ------------------------------------------------------------ */ +/* How to clean up after dead child processes */ +/* ------------------------------------------------------------ */ + +void wait_for_zombie(int s) +{ + while(waitpid(-1, NULL, WNOHANG) > 0) ; +} + +/* ------------------------------------------------------------ */ +/* Core of implementation of a child process */ +/* ------------------------------------------------------------ */ + +void echo_lines(int csock) +{ + char buf[BUF_LEN]; + int r; + + while( (r = read(csock, buf, BUF_LEN)) > 0 ) { + (void)write(csock, buf, r); + } + exit(EXIT_SUCCESS); +} + +/* ------------------------------------------------------------ */ +/* Core of implementation of the parent process */ +/* ------------------------------------------------------------ */ + +void take_connections_forever(int ssock) +{ + for(;;) { + struct sockaddr addr; + socklen_t addr_size = sizeof(addr); + int csock; + + /* Block until we take one connection to the server socket */ + csock = accept(ssock, &addr, &addr_size); + + /* If it was a successful connection, spawn a worker process to service it */ + if ( csock == -1 ) { + perror("accept"); + } else if ( fork() == 0 ) { + close(ssock); + echo_lines(csock); + } else { + close(csock); + } + } +} + +/* ------------------------------------------------------------ */ +/* The server process's one-off setup code */ +/* ------------------------------------------------------------ */ + +int main() +{ + struct addrinfo hints, *res; + struct sigaction sa; + int sock; + + /* Look up the address to bind to */ + memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_PASSIVE; + if ( getaddrinfo(NULL, PORT_STR, &hints, &res) != 0 ) { + perror("getaddrinfo"); + exit(EXIT_FAILURE); + } + + /* Make a socket */ + if ( (sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1 ) { + perror("socket"); + exit(EXIT_FAILURE); + } + + /* Arrange to clean up child processes (the workers) */ + sa.sa_handler = wait_for_zombie; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + if ( sigaction(SIGCHLD, &sa, NULL) == -1 ) { + perror("sigaction"); + exit(EXIT_FAILURE); + } + + /* Associate the socket with its address */ + if ( bind(sock, res->ai_addr, res->ai_addrlen) != 0 ) { + perror("bind"); + exit(EXIT_FAILURE); + } + + freeaddrinfo(res); + + /* State that we've opened a server socket and are listening for connections */ + if ( listen(sock, MAX_ENQUEUED) != 0 ) { + perror("listen"); + exit(EXIT_FAILURE); + } + + /* Serve the listening socket until killed */ + take_connections_forever(sock); + return EXIT_SUCCESS; +} diff --git a/Task/Echo-server/Clojure/echo-server.clj b/Task/Echo-server/Clojure/echo-server.clj new file mode 100644 index 0000000000..b4c2d3c9d5 --- /dev/null +++ b/Task/Echo-server/Clojure/echo-server.clj @@ -0,0 +1,7 @@ +(use '[clojure.contrib.server-socket :only (create-server)]) +(use '[clojure.contrib.duck-streams :only (read-lines write-lines)]) + +(defn echo [input output] + (write-lines (java.io.PrintWriter. output true) (read-lines input))) + +(create-server 12321 echo) diff --git a/Task/Echo-server/CoffeeScript/echo-server.coffee b/Task/Echo-server/CoffeeScript/echo-server.coffee new file mode 100644 index 0000000000..d7349ef1fe --- /dev/null +++ b/Task/Echo-server/CoffeeScript/echo-server.coffee @@ -0,0 +1,17 @@ +net = require("net") +server = net.createServer (conn) -> + console.log "Connection from #{conn.remoteAddress} on port #{conn.remotePort}" + conn.setEncoding "utf8" + buffer = "" + conn.on "data", (data) -> + i = 0 + + while i <= data.length + char = data.charAt(i) + buffer += char + if char is "\n" + conn.write buffer + buffer = "" + i++ + +server.listen 12321, "localhost" diff --git a/Task/Echo-server/Common-Lisp/echo-server-1.lisp b/Task/Echo-server/Common-Lisp/echo-server-1.lisp new file mode 100644 index 0000000000..c293267904 --- /dev/null +++ b/Task/Echo-server/Common-Lisp/echo-server-1.lisp @@ -0,0 +1,47 @@ +(defvar *clients* '() + "This is a list of (socket :input status) which is used with +`socket:socket-status' to test for data ready on a socket.") + +(defun echo-server (port) + "Listen on `port' for new client connections and for data arriving on +any existing client connections" + (let ((server (socket:socket-server port))) + (format t "Echo service listening on port ~a:~d~%" + (socket:socket-server-host server) + (socket:socket-server-port server)) + (unwind-protect + (loop + (when (socket:socket-status server 0 1) + (echo-accept-client (socket:socket-accept server + :external-format :dos + :buffered t))) + (when *clients* + (socket:socket-status *clients* 0 1) + (mapcar #'(lambda (client) + (when (eq :input (cddr client)) + (echo-service-client (car client))) + (when (eq :eof (cddr client)) + (echo-close-client (car client)))) *clients*))) + (socket-server-close server)))) + +(defun echo-accept-client (socket) + "Accept a new client connection and add it to the watch list." + (multiple-value-bind + (host port) (socket:socket-stream-peer socket) + (format t "Connect from ~a:~d~%" host port)) + (push (list socket :input nil) *clients*)) + +(defun echo-service-client (socket) + (let ((line (read-line socket nil nil))) + (princ line socket) + (finish-output socket))) + +(defun echo-close-client (socket) + "Close a client connection and remove it from the watch list." + (multiple-value-bind + (host port) (socket:socket-stream-peer socket) + (format t "Closing connection from ~a:~d~%" host port)) + (close socket) + (setq *clients* (remove socket *clients* :key #'car))) + +(echo-server 12321) diff --git a/Task/Echo-server/Common-Lisp/echo-server-2.lisp b/Task/Echo-server/Common-Lisp/echo-server-2.lisp new file mode 100644 index 0000000000..eea7bebb51 --- /dev/null +++ b/Task/Echo-server/Common-Lisp/echo-server-2.lisp @@ -0,0 +1,38 @@ +(defpackage :echo + (:use :cl :usocket :cl-actors) + (:import-from :cl-actors #:self)) +(in-package :echo) + +(defun read-line-no-hang (stream) + "Reads a line from stream. Returns a partial line rather than hanging." + (apply #'values + (loop for char = (read-char-no-hang stream nil :eof) + until (or (null char) (eq :eof char) (char= #\newline char)) + collect char into str + finally (return (list (when str (coerce str 'string)) char))))) + +(defactor tcp-server (server handler connections) (message) + (loop for ready in (wait-for-input (cons server connections) :ready-only t) + do (if (typep ready 'stream-server-usocket) + (push (socket-accept server) connections) + (multiple-value-bind (line last-char) (read-line-no-hang (socket-stream ready)) + (when (eq last-char :eof) + (delete ready connections) + (socket-close ready)) + (send handler ready line)))) + (send self nil) + next) + +(defactor echo-handler (stream) (socket input) + (format stream "~a~%" input) + (format (socket-stream socket) input) + next) + +(defparameter +port+ 12321) +(defparameter *handler* (echo-handler :stream *standard-input*) + "Accepts and deals with socket messages.") +(defparameter *server* + (tcp-server :server (socket-listen "127.0.0.1" +port+) + :handler *handler*) + "Listens on the specified address+port. Passes socket input to specified handler.") +(send *server* :ping) ;; get the server started diff --git a/Task/Echo-server/Common-Lisp/echo-server-3.lisp b/Task/Echo-server/Common-Lisp/echo-server-3.lisp new file mode 100644 index 0000000000..d0c17bfeff --- /dev/null +++ b/Task/Echo-server/Common-Lisp/echo-server-3.lisp @@ -0,0 +1,22 @@ +(defactor tcp-naive-client (sock) (message) + (format (socket-stream sock) message) + (force-output (socket-stream sock)) + next) + +(defparameter *client* (tcp-naive-client :sock (socket-connect "127.0.0.1" +port+))) + +(send *client* "test~%test") +;; should print +;; test +;; test + +(send *client* "test") +;; should print +;; test + +(defparameter *client2* (tcp-naive-client :sock (socket-connect "127.0.0.1" +port+))) + +(send *client2* "woo!") +;; should print +;; woo! +;; despite the fact that *client* isn't reading anything, and didn't terminate its last message with a newline diff --git a/Task/Echo-server/D/echo-server-1.d b/Task/Echo-server/D/echo-server-1.d new file mode 100644 index 0000000000..bdcb1dfc13 --- /dev/null +++ b/Task/Echo-server/D/echo-server-1.d @@ -0,0 +1,20 @@ +import std.array, std.socket; + +void main() { + auto listener = new TcpSocket; + assert(listener.isAlive); + listener.bind(new InternetAddress(12321)); + listener.listen(10); + + Socket currSock; + uint bytesRead; + ubyte[1] buff; + + while (true) { + currSock = listener.accept(); + while ((bytesRead = currSock.receive(buff)) > 0) + currSock.send(buff); + currSock.close(); + buff.clear(); + } +} diff --git a/Task/Echo-server/D/echo-server-2.d b/Task/Echo-server/D/echo-server-2.d new file mode 100644 index 0000000000..ba55a4ee6e --- /dev/null +++ b/Task/Echo-server/D/echo-server-2.d @@ -0,0 +1,109 @@ +import std.stdio, std.socket, std.array; + +void main() { + enum ushort port = 7; + enum int backlog = 10; + enum int max_connections = 60; + enum BUFFER_SIZE = 16; + + auto listener = new TcpSocket; + assert(listener.isAlive); + listener.bind(new InternetAddress(port)); + listener.listen(backlog); + debug writeln("Listening on port ", port); + + // Room for listener. + auto sset = new SocketSet(max_connections + 1); + + Socket[] sockets; + char[BUFFER_SIZE] buf; + + for (;; sset.reset()) { + sset.add(listener); + foreach (each; sockets) + sset.add(each); + + // Update socket set with only those sockets that have data + // avaliable for reading. Options are for read, write, + // and error. + Socket.select(sset, null, null); + + // Read the data from each socket remaining, and handle + // the request. + for (int i = 0; ; i++) { +NEXT: + if (i == sockets.length) + break; + if (sset.isSet(sockets[i])) { + int read = sockets[i].receive(buf); + if (Socket.ERROR == read) { + debug writeln("Connection error."); + goto SOCK_DOWN; + } else if (read == 0) { + debug { + try { + // If the connection closed due to an + // error, remoteAddress() could fail. + writefln("Connection from %s closed.", + sockets[i].remoteAddress() + .toString()); + } catch (SocketException) { + writeln("Connection closed."); + } + } +SOCK_DOWN: + sockets[i].close(); //Release socket resources now. + + // Remove from socket from sockets, and id from + // threads. + if (i != sockets.length - 1) + sockets[i] = sockets.back; + sockets.length--; + debug writeln("\tTotal connections: ", + sockets.length); + goto NEXT; // -i- is still the NEXT index. + } else { + debug + writefln("Received %d bytes from %s:" + ~ "\n-----\n%s\n-----", + read, + sockets[i].remoteAddress().toString(), + buf[0 .. read]); + + // Echo what was sent. + sockets[i].send(buf[0 .. read]); + } + } + } + + // Connection request. + if (sset.isSet(listener)) { + Socket sn; + try { + if (sockets.length < max_connections) { + sn = listener.accept(); + debug writefln("Connection from %s established.", + sn.remoteAddress().toString()); + assert(sn.isAlive); + assert(listener.isAlive); + sockets ~= sn; + debug writefln("\tTotal connections: %d", + sockets.length); + } else { + sn = listener.accept(); + debug writefln("Rejected connection from %s;" + ~ " too many connections.", + sn.remoteAddress().toString()); + assert(sn.isAlive); + sn.close(); + assert(!sn.isAlive); + assert(listener.isAlive); + } + } catch (Exception e) { + debug writefln("Error accepting: %s", e.toString()); + if (sn) + sn.close(); + } + } + } +} diff --git a/Task/Echo-server/Delphi/echo-server.delphi b/Task/Echo-server/Delphi/echo-server.delphi new file mode 100644 index 0000000000..ff10e033b3 --- /dev/null +++ b/Task/Echo-server/Delphi/echo-server.delphi @@ -0,0 +1,58 @@ +program EchoServer; + +{$APPTYPE CONSOLE} + +uses SysUtils, IdContext, IdTCPServer; + +type + TEchoServer = class + private + FTCPServer: TIdTCPServer; + public + constructor Create; + destructor Destroy; override; + procedure TCPServerExecute(AContext: TIdContext); + end; + +constructor TEchoServer.Create; +begin + FTCPServer := TIdTCPServer.Create(nil); + FTCPServer.DefaultPort := 12321; + FTCPServer.OnExecute := TCPServerExecute; + FTCPServer.Active := True; +end; + +destructor TEchoServer.Destroy; +begin + FTCPServer.Active := False; + FTCPServer.Free; + inherited Destroy; +end; + +procedure TEchoServer.TCPServerExecute(AContext: TIdContext); +var + lCmdLine: string; +begin + lCmdLine := AContext.Connection.IOHandler.ReadLn; + Writeln('>' + lCmdLine); + AContext.Connection.IOHandler.Writeln('>' + lCmdLine); + + if SameText(lCmdLine, 'QUIT') then + begin + AContext.Connection.IOHandler.Writeln('Disconnecting'); + AContext.Connection.Disconnect; + end; +end; + +var + lEchoServer: TEchoServer; +begin + lEchoServer := TEchoServer.Create; + try + Writeln('Delphi Echo Server'); + Writeln('Press Enter to quit'); + Readln; + finally + lEchoServer.Free; + end; +end. diff --git a/Task/Echo-server/Erlang/echo-server.erl b/Task/Echo-server/Erlang/echo-server.erl new file mode 100644 index 0000000000..325b2b7020 --- /dev/null +++ b/Task/Echo-server/Erlang/echo-server.erl @@ -0,0 +1,23 @@ +-module(echo). +-export([start/0]). + +start() -> + spawn(fun () -> {ok, Sock} = gen_tcp:listen(12321, [{packet, line}]), + echo_loop(Sock) + end). + +echo_loop(Sock) -> + {ok, Conn} = gen_tcp:accept(Sock), + io:format("Got connection: ~p~n", [Conn]), + Handler = spawn(fun () -> handle(Conn) end), + gen_tcp:controlling_process(Conn, Handler), + echo_loop(Sock). + +handle(Conn) -> + receive + {tcp, Conn, Data} -> + gen_tcp:send(Conn, Data), + handle(Conn); + {tcp_closed, Conn} -> + io:format("Connection closed: ~p~n", [Conn]) + end. diff --git a/Task/Echo-server/Forth/echo-server.fth b/Task/Echo-server/Forth/echo-server.fth new file mode 100644 index 0000000000..f4ad39410e --- /dev/null +++ b/Task/Echo-server/Forth/echo-server.fth @@ -0,0 +1,30 @@ +include unix/socket.fs + +128 constant size + +: (echo) ( sock buf -- sock buf ) + begin + cr ." waiting..." + 2dup 2dup size read-socket nip + dup 0> + while + ." got: " 2dup type + rot write-socket + repeat + drop drop drop ; + +create buf size allot + +: echo-server ( port -- ) + cr ." Listening on " dup . + create-server + dup 4 listen + begin + dup accept-socket + cr ." Connection!" + buf ['] (echo) catch + cr ." Disconnected (" . ." )" + drop close-socket + again ; + +12321 echo-server diff --git a/Task/Echo-server/Go/echo-server.go b/Task/Echo-server/Go/echo-server.go new file mode 100644 index 0000000000..cf38848568 --- /dev/null +++ b/Task/Echo-server/Go/echo-server.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "net" + "bufio" +) + +func echo(s net.Conn, i int) { + fmt.Printf("%d: %v <-> %v\n", i, s.LocalAddr(), s.RemoteAddr()) + b := bufio.NewReader(s) + for { + line, e := b.ReadBytes('\n') + if e != nil { + break + } + s.Write(line) + } + fmt.Printf("%d: closed\n", i) +} + +func main() { + l, e := net.Listen("tcp", ":12321") + for i := 0; e == nil; i++ { + var s net.Conn + s, e = l.Accept() + go echo(s, i) + } +} diff --git a/Task/Echo-server/Haskell/echo-server.hs b/Task/Echo-server/Haskell/echo-server.hs new file mode 100644 index 0000000000..d2e99d7e0a --- /dev/null +++ b/Task/Echo-server/Haskell/echo-server.hs @@ -0,0 +1,25 @@ +module Main where +import Network (withSocketsDo, accept, listenOn, sClose, PortID(PortNumber)) +import Control.Monad (forever) +import System.IO (hGetLine, hPutStrLn, hFlush, hClose) +import System.IO.Error (isEOFError) +import Control.Concurrent (forkIO) +import Control.Exception (bracket) + +-- For convenience in testing, ensure that the listen socket is closed if the main loop is aborted +withListenOn port body = bracket (listenOn port) sClose body + +echo (handle, host, port) = catch (forever doOneLine) stop where + doOneLine = do line <- hGetLine handle + print (host, port, init line) + hPutStrLn handle line + hFlush handle + stop error = do putStrLn $ "Closed connection from " ++ show (host, port) ++ " due to " ++ show error + hClose handle + +main = withSocketsDo $ + withListenOn (PortNumber 12321) $ \listener -> + forever $ do + acc@(_, host, port) <- accept listener + putStrLn $ "Accepted connection from " ++ show (host, port) + forkIO (echo acc) diff --git a/Task/Echo-server/Java/echo-server.java b/Task/Echo-server/Java/echo-server.java new file mode 100644 index 0000000000..12522c6f3d --- /dev/null +++ b/Task/Echo-server/Java/echo-server.java @@ -0,0 +1,78 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.ServerSocket; +import java.net.Socket; + +public class EchoServer { + ServerSocket serverSocket; + public EchoServer(){ + } + + public void start() { + try { + serverSocket = new ServerSocket(12321); + while(true){ + Thread clientThread = new Thread(new ClientHandler(serverSocket.accept())); + clientThread.start(); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + System.out.println("closing server socket"); + serverSocket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + } + + public static void main(String[] args) { + EchoServer es = new EchoServer(); + es.start(); + } +} + +class ClientHandler implements Runnable { + private static int numConnections; + private int connectionId = 0; + Socket clientSocket; + + public ClientHandler(Socket s) { + connectionId = numConnections++; + System.out.println("handling connection, #" + connectionId); + clientSocket = s; + } + + public void run() { + PrintWriter out = null; + BufferedReader in = null; + try { + out = new PrintWriter(clientSocket.getOutputStream(), true); + in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); + String inputLine, outputLine; + while((inputLine = in.readLine()) != null){ + outputLine = inputLine; + System.out.println("recieved: " + outputLine); + out.write(outputLine+"\n"); + out.flush(); + if (outputLine.equals("exit")) + break; + } + } catch(Exception e) { + e.printStackTrace(); + } finally { + out.close(); + try { + in.close(); + clientSocket.close(); + System.out.println("closing connection, #" + connectionId); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/Task/Echo-server/JavaScript/echo-server.js b/Task/Echo-server/JavaScript/echo-server.js new file mode 100644 index 0000000000..d332377de6 --- /dev/null +++ b/Task/Echo-server/JavaScript/echo-server.js @@ -0,0 +1,20 @@ +var net = require('net'); + +var server = net.createServer(function(conn) { + console.log("Connection from " + conn.remoteAddress + " on port " + conn.remotePort); + conn.setEncoding("utf8"); + var buffer = ""; + + conn.on("data", function(data) { + for(var i = 0; i <= data.length; i++) { + var char = data.charAt(i); + buffer += char; + if(char == "\n") { + conn.write(buffer); + buffer = ""; + } + } + }); +}); + +server.listen(12321, "localhost"); diff --git a/Task/Echo-server/PHP/echo-server.php b/Task/Echo-server/PHP/echo-server.php new file mode 100644 index 0000000000..86f302604e --- /dev/null +++ b/Task/Echo-server/PHP/echo-server.php @@ -0,0 +1,31 @@ +$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP); +socket_bind($socket, '127.0.0.1', 12321); +socket_listen($socket); + +$client_count = 0; +while (true){ + if (($client = socket_accept($socket)) === false) continue; + $client_count++; + + $client_name = 'Unknown'; + socket_getpeername($client, $client_name); + echo "Client {$client_count} ({$client_name}) connected\n"; + $pid = pcntl_fork(); + if($pid == -1) die('Could not fork'); + if($pid){ + pcntl_waitpid(-1, $status, WNOHANG); + continue; + } + + //In a child process + while(true){ + if($input = socket_read($client, 1024)){ + socket_write($client, $input); + } else { + socket_shutdown($client); + socket_close($client); + echo "Client {$client_count} ({$client_name}) disconnected\n"; + exit(); + } + } +} diff --git a/Task/Echo-server/Perl/echo-server-1.pl b/Task/Echo-server/Perl/echo-server-1.pl new file mode 100644 index 0000000000..d93bed97f2 --- /dev/null +++ b/Task/Echo-server/Perl/echo-server-1.pl @@ -0,0 +1,29 @@ +use IO::Socket; +my $use_fork = 1; + +my $sock = new IO::Socket::INET ( + LocalHost => '127.0.0.1', + LocalPort => '12321', + Proto => 'tcp', + Listen => 1, # maximum queued connections + Reuse => 1, + ) + or die "socket: $!"; # no newline, so perl appends stuff + +$SIG{CHLD} = 'IGNORE' if $use_fork; # let perl deal with zombies + +print "listening...\n"; +while (1) { + # declare $con 'my' so it's closed by parent every loop + my $con = $sock->accept() + or die "accept: $!"; + fork and next if $use_fork; # following are for child only + + print "incoming..\n"; + print $con $_ while(<$con>); # read each line and write back + print "done\n"; + + last if $use_fork; # if not forking, loop +} + +# child will reach here and close its copy of $sock before exit diff --git a/Task/Echo-server/Perl/echo-server-2.pl b/Task/Echo-server/Perl/echo-server-2.pl new file mode 100644 index 0000000000..f998f16f4e --- /dev/null +++ b/Task/Echo-server/Perl/echo-server-2.pl @@ -0,0 +1,6 @@ +package Echo; +use base 'Net::Server::Fork'; +sub process_request { + print while ; +} +Echo->run(port => 12321, log_level => 3); diff --git a/Task/Echo-server/Perl/echo-server-3.pl b/Task/Echo-server/Perl/echo-server-3.pl new file mode 100644 index 0000000000..5262a0e951 --- /dev/null +++ b/Task/Echo-server/Perl/echo-server-3.pl @@ -0,0 +1,6 @@ +package Echo; +use base 'Net::Server::PreFork'; +sub process_request { + print while ; +} +Echo->run(port => 12321, log_level => 3); diff --git a/Task/Echo-server/PicoLisp/echo-server.l b/Task/Echo-server/PicoLisp/echo-server.l new file mode 100644 index 0000000000..7708999b9d --- /dev/null +++ b/Task/Echo-server/PicoLisp/echo-server.l @@ -0,0 +1,16 @@ +(setq Port (port 12321)) + +(loop + (setq Sock (listen Port)) # Listen + (NIL (fork) (close Port)) # Accepted + (close Sock) ) # Parent: Close socket and continue + +# Child: +(prinl (stamp) " -- (Pid " *Pid ") Client connected from " *Adr) + +(in Sock + (until (eof) # Echo lines + (out Sock (prinl (line))) ) ) + +(prinl (stamp) " -- (Pid " *Pid ") Client disconnected") +(bye) # Terminate child diff --git a/Task/Echo-server/Python/echo-server.py b/Task/Echo-server/Python/echo-server.py new file mode 100644 index 0000000000..f1eddf14bb --- /dev/null +++ b/Task/Echo-server/Python/echo-server.py @@ -0,0 +1,33 @@ +import SocketServer + +HOST = "localhost" +PORT = 12321 + +# this server uses ThreadingMixIn - one thread per connection +# replace with ForkMixIn to spawn a new process per connection + +class EchoServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): + # no need to override anything - default behavior is just fine + pass + +class EchoRequestHandler(SocketServer.StreamRequestHandler): + """ + Handles one connection to the client. + """ + def handle(self): + print "connection from %s" % self.client_address[0] + while True: + line = self.rfile.readline() + if not line: break + print "%s wrote: %s" % (self.client_address[0], line.rstrip()) + self.wfile.write(line) + print "%s disconnected" % self.client_address[0] + + +# Create the server +server = EchoServer((HOST, PORT), EchoRequestHandler) + +# Activate the server; this will keep running until you +# interrupt the program with Ctrl-C +print "server listening on %s:%s" % server.server_address +server.serve_forever() diff --git a/Task/Echo-server/Racket/echo-server.rkt b/Task/Echo-server/Racket/echo-server.rkt new file mode 100644 index 0000000000..ebfc8c3e03 --- /dev/null +++ b/Task/Echo-server/Racket/echo-server.rkt @@ -0,0 +1,8 @@ +#lang racket + +(define listener (tcp-listen 12321)) +(let echo-server () + (define-values (in out) (tcp-accept listener)) + (thread (λ () (copy-port in out) + (close-output-port out))) + (echo-server)) diff --git a/Task/Echo-server/Ruby/echo-server-1.rb b/Task/Echo-server/Ruby/echo-server-1.rb new file mode 100644 index 0000000000..9f4d746b6c --- /dev/null +++ b/Task/Echo-server/Ruby/echo-server-1.rb @@ -0,0 +1,20 @@ +require 'socket' +server = TCPServer.new(12321) + +while (connection = server.accept) + Thread.new(connection) do |conn| + port, host = conn.peeraddr[1,2] + client = "#{host}:#{port}" + puts "#{client} is connected" + begin + loop do + line = conn.readline + puts "#{client} says: #{line}" + conn.puts(line) + end + rescue EOFError + conn.close + puts "#{client} has disconnected" + end + end +end diff --git a/Task/Echo-server/Ruby/echo-server-2.rb b/Task/Echo-server/Ruby/echo-server-2.rb new file mode 100644 index 0000000000..706cb04c64 --- /dev/null +++ b/Task/Echo-server/Ruby/echo-server-2.rb @@ -0,0 +1,18 @@ +require 'socket' + +Socket.tcp_server_loop(12321) do |conn, addr| + Thread.new do + client = "#{addr.ip_address}:#{addr.ip_port}" + puts "#{client} is connected" + begin + loop do + line = conn.readline + puts "#{client} says: #{line}" + conn.puts(line) + end + rescue EOFError + conn.close + puts "#{client} has disconnected" + end + end +end diff --git a/Task/Echo-server/Scheme/echo-server.ss b/Task/Echo-server/Scheme/echo-server.ss new file mode 100644 index 0000000000..faeb8f3cec --- /dev/null +++ b/Task/Echo-server/Scheme/echo-server.ss @@ -0,0 +1,41 @@ +; Needed in Guile for read-line +(use-modules (ice-9 rdelim)) + +; Variable used to hold child PID returned from forking +(define child #f) + +; Start listening on port 12321 for connections from any address +(let ((s (socket PF_INET SOCK_STREAM 0))) + (setsockopt s SOL_SOCKET SO_REUSEADDR 1) + (bind s AF_INET INADDR_ANY 12321) + (listen s 5) ; Queue size of 5 + + (simple-format #t "Listening for clients in pid: ~S" (getpid)) + (newline) + +; Wait for connections forever + (while #t + (let* ((client-connection (accept s)) + (client-details (cdr client-connection)) + (client (car client-connection))) +; Once something connects fork + (set! child (primitive-fork)) + (if (zero? child) + (begin +; Then have child fork to avoid zombie children (grandchildren aren't our responsibility) + (set! child (primitive-fork)) + (if (zero? child) + (begin +; Display some connection details + (simple-format #t "Got new client connection: ~S" client-details) + (newline) + (simple-format #t "Client address: ~S" + (gethostbyaddr (sockaddr:addr client-details))) + (newline) +; Wait for input from client and then echo the input back forever (or until client quits) + (do ((line (read-line client)(read-line client))) ((zero? 1)) + (display line client)(newline client)))) +; Child exits after spawning grandchild. + (primitive-exit)) +; Parent waits for child to finish spawning grandchild + (waitpid child))))) diff --git a/Task/Echo-server/Tcl/echo-server-1.tcl b/Task/Echo-server/Tcl/echo-server-1.tcl new file mode 100644 index 0000000000..1802760f80 --- /dev/null +++ b/Task/Echo-server/Tcl/echo-server-1.tcl @@ -0,0 +1,21 @@ +# How to handle an incoming new connection +proc acceptEcho {chan host port} { + puts "opened connection from $host:$port" + fconfigure $chan -blocking 0 -buffering line -translation crlf + fileevent $chan readable [list echo $chan $host $port] +} + +# How to handle an incoming message on a connection +proc echo {chan host port} { + if {[gets $chan line] >= 0} { + puts $chan $line + } elseif {[eof $chan]} { + close $chan + puts "closed connection from $host:$port" + } + # Other conditions causing a short read need no action +} + +# Make the server socket and wait for connections +socket -server acceptEcho -myaddr localhost 12321 +vwait forever diff --git a/Task/Echo-server/Tcl/echo-server-2.tcl b/Task/Echo-server/Tcl/echo-server-2.tcl new file mode 100644 index 0000000000..5e346535fa --- /dev/null +++ b/Task/Echo-server/Tcl/echo-server-2.tcl @@ -0,0 +1,16 @@ +# How to handle an incoming new connection +proc acceptEcho {chan host port} { + puts "opened connection from $host:$port" + fconfigure $chan -translation binary -buffering none + fcopy $chan $chan -command [list done $chan $host $port] +} + +# Called to finalize the connection +proc done {chan host port args} { + puts "closed connection from $host:$port" + close $chan +} + +# Make the server socket and wait for connections +socket -server acceptEcho -myaddr localhost 12321 +vwait forever diff --git a/Task/Element-wise-operations/0DESCRIPTION b/Task/Element-wise-operations/0DESCRIPTION new file mode 100644 index 0000000000..6bd891c04e --- /dev/null +++ b/Task/Element-wise-operations/0DESCRIPTION @@ -0,0 +1,3 @@ +Similar to [[Matrix multiplication]] and [[Matrix transposition]], the task is to implement basic element-wise matrix-matrix and scalar-matrix operations, which can be referred to in other, higher-order tasks. Implement addition, subtraction, multiplication, division and exponentiation. + +Extend the task if necessary to include additional basic operations, which should not require their own specialised task. diff --git a/Task/Element-wise-operations/1META.yaml b/Task/Element-wise-operations/1META.yaml new file mode 100644 index 0000000000..09f25b3b78 --- /dev/null +++ b/Task/Element-wise-operations/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Mathematics +note: Matrices diff --git a/Task/Element-wise-operations/ALGOL-68/element-wise-operations.alg b/Task/Element-wise-operations/ALGOL-68/element-wise-operations.alg new file mode 100644 index 0000000000..c79829ac2c --- /dev/null +++ b/Task/Element-wise-operations/ALGOL-68/element-wise-operations.alg @@ -0,0 +1,54 @@ +#!/usr/local/bin/a68g --script # + +MODE SCALAR = REAL; +FORMAT scalar fmt = $g(0, 2)$; + +MODE MATRIX = [3, 3]SCALAR; +FORMAT vector fmt = $"("n(2 UPB LOC MATRIX - 2 LWB LOC MATRIX)(f(scalar fmt)", ")f(scalar fmt)")"$; +FORMAT matrix fmt = $"("n(1 UPB LOC MATRIX - 1 LWB LOC MATRIX)(f(vector fmt)","l" ")f(vector fmt)")"$; + +PROC elementwise op = (PROC(SCALAR, SCALAR)SCALAR op, MATRIX a, UNION(SCALAR, MATRIX) b)MATRIX: ( + [LWB a:UPB a, 2 LWB a:2 UPB a]SCALAR out; + CASE b IN + (SCALAR b): + FOR i FROM LWB out TO UPB out DO + FOR j FROM 2 LWB out TO 2 UPB out DO + out[i, j]:=op(a[i, j], b) + OD + OD, + (MATRIX b): + FOR i FROM LWB out TO UPB out DO + FOR j FROM 2 LWB out TO 2 UPB out DO + out[i, j]:=op(a[i, j], b[i, j]) + OD + OD + ESAC; + out +); + +PROC plus = (SCALAR a, b)SCALAR: a+b, + minus = (SCALAR a, b)SCALAR: a-b, + times = (SCALAR a, b)SCALAR: a*b, + div = (SCALAR a, b)SCALAR: a/b, + pow = (SCALAR a, b)SCALAR: a**b; + +main:( + SCALAR scalar := 10; + MATRIX matrix = (( 7, 11, 13), + (17, 19, 23), + (29, 31, 37)); + + printf(($f(matrix fmt)";"l$, + elementwise op(plus, matrix, scalar), + elementwise op(minus, matrix, scalar), + elementwise op(times, matrix, scalar), + elementwise op(div, matrix, scalar), + elementwise op(pow, matrix, scalar), + + elementwise op(plus, matrix, matrix), + elementwise op(minus, matrix, matrix), + elementwise op(times, matrix, matrix), + elementwise op(div, matrix, matrix), + elementwise op(pow, matrix, matrix) + )) +) diff --git a/Task/Element-wise-operations/Ada/element-wise-operations-1.ada b/Task/Element-wise-operations/Ada/element-wise-operations-1.ada new file mode 100644 index 0000000000..4fad9f830d --- /dev/null +++ b/Task/Element-wise-operations/Ada/element-wise-operations-1.ada @@ -0,0 +1,31 @@ +with Ada.Text_IO, Matrix_Scalar; + +procedure Scalar_Ops is + + subtype T is Integer range 1 .. 3; + + package M is new Matrix_Scalar(T, T, Integer); + + -- the functions to solve the task + function "+" is new M.Func("+"); + function "-" is new M.Func("-"); + function "*" is new M.Func("*"); + function "/" is new M.Func("/"); + function "**" is new M.Func("**"); + function "mod" is new M.Func("mod"); + + -- for output purposes, we need a Matrix->String conversion + function Image is new M.Image(Integer'Image); + + A: M.Matrix := ((1,2,3),(4,5,6),(7,8,9)); -- something to begin with + +begin + Ada.Text_IO.Put_Line(" Initial M=" & Image(A)); + Ada.Text_IO.Put_Line(" M+2=" & Image(A+2)); + Ada.Text_IO.Put_Line(" M-2=" & Image(A-2)); + Ada.Text_IO.Put_Line(" M*2=" & Image(A*2)); + Ada.Text_IO.Put_Line(" M/2=" & Image(A/2)); + Ada.Text_IO.Put_Line(" square(M)=" & Image(A ** 2)); + Ada.Text_IO.Put_Line(" M mod 2=" & Image(A mod 2)); + Ada.Text_IO.Put_Line("(M*2) mod 3=" & Image((A*2) mod 3)); +end Scalar_Ops; diff --git a/Task/Element-wise-operations/Ada/element-wise-operations-2.ada b/Task/Element-wise-operations/Ada/element-wise-operations-2.ada new file mode 100644 index 0000000000..30a99210c7 --- /dev/null +++ b/Task/Element-wise-operations/Ada/element-wise-operations-2.ada @@ -0,0 +1,16 @@ +generic + type Rows is (<>); + type Cols is (<>); + type Num is private; +package Matrix_Scalar is + type Matrix is array(Rows, Cols) of Num; + + generic + with function F(L, R: Num) return Num; + function Func(Left: Matrix; Right: Num) return Matrix; + + generic + with function Image(N: Num) return String; + function Image(M: Matrix) return String; + +end Matrix_Scalar; diff --git a/Task/Element-wise-operations/Ada/element-wise-operations-3.ada b/Task/Element-wise-operations/Ada/element-wise-operations-3.ada new file mode 100644 index 0000000000..90878be9e6 --- /dev/null +++ b/Task/Element-wise-operations/Ada/element-wise-operations-3.ada @@ -0,0 +1,45 @@ +package body Matrix_Scalar is + + function Func(Left: Matrix; Right: Num) return Matrix is + Result: Matrix; + begin + for R in Rows loop + for C in Cols loop + Result(R,C) := F(Left(R,C), Right); + end loop; + end loop; + return Result; + end Func; + + function Image(M: Matrix) return String is + + function Img(R: Rows) return String is + + function I(C: Cols) return String is + S: String := Image(M(R,C)); + L: Positive := S'First; + begin + while S(L) = ' ' loop + L := L + 1; + end loop; + if C=Cols'Last then + return S(L .. S'Last); + else + return S(L .. S'Last) & "," & I(Cols'Succ(C)); + end if; + end I; + + Column: String := I(Cols'First); + begin + if R=Rows'Last then + return "(" & Column & ")"; + else + return "(" & Column & ")," & Img(Rows'Succ(R)); + end if; + end Img; + + begin + return("(" & Img(Rows'First) & ")"); + end Image; + +end Matrix_Scalar; diff --git a/Task/Element-wise-operations/BBC-BASIC/element-wise-operations.bbc b/Task/Element-wise-operations/BBC-BASIC/element-wise-operations.bbc new file mode 100644 index 0000000000..9c6a5cbfe1 --- /dev/null +++ b/Task/Element-wise-operations/BBC-BASIC/element-wise-operations.bbc @@ -0,0 +1,53 @@ + DIM a(1,2), b(1,2), c(1,2) + a() = 7, 8, 7, 4, 0, 9 : b() = 4, 5, 1, 6, 2, 1 + + REM Matrix-Matrix: + c() = a() + b() : PRINT FNshowmm(a(), "+", b(), c()) + c() = a() - b() : PRINT FNshowmm(a(), "-", b(), c()) + c() = a() * b() : PRINT FNshowmm(a(), "*", b(), c()) + c() = a() / b() : PRINT FNshowmm(a(), "/", b(), c()) + PROCpowmm(a(), b(), c()) : PRINT FNshowmm(a(), "^", b(), c()) ' + + REM Matrix-Scalar: + c() = a() + 3 : PRINT FNshowms(a(), "+", 3, c()) + c() = a() - 3 : PRINT FNshowms(a(), "-", 3, c()) + c() = a() * 3 : PRINT FNshowms(a(), "*", 3, c()) + c() = a() / 3 : PRINT FNshowms(a(), "/", 3, c()) + PROCpowms(a(), 3, c()) : PRINT FNshowms(a(), "^", 3, c()) + END + + DEF PROCpowmm(a(), b(), c()) + LOCAL i%, j% + FOR i% = 0 TO DIM(a(),1) + FOR j% = 0 TO DIM(a(),2) + c(i%,j%) = a(i%,j%) ^ b(i%,j%) + NEXT + NEXT + ENDPROC + + DEF PROCpowms(a(), b, c()) + LOCAL i%, j% + FOR i% = 0 TO DIM(a(),1) + FOR j% = 0 TO DIM(a(),2) + c(i%,j%) = a(i%,j%) ^ b + NEXT + NEXT + ENDPROC + + DEF FNshowmm(a(), op$, b(), c()) + = FNlist(a()) + " " + op$ + " " + FNlist(b()) + " = " + FNlist(c()) + + DEF FNshowms(a(), op$, b, c()) + = FNlist(a()) + " " + op$ + " " + STR$(b) + " = " + FNlist(c()) + + DEF FNlist(a()) + LOCAL i%, j%, a$ + a$ = "[" + FOR i% = 0 TO DIM(a(),1) + a$ += "[" + FOR j% = 0 TO DIM(a(),2) + a$ += STR$(a(i%,j%)) + ", " + NEXT + a$ = LEFT$(LEFT$(a$)) + "]" + NEXT + = a$ + "]" diff --git a/Task/Element-wise-operations/C/element-wise-operations.c b/Task/Element-wise-operations/C/element-wise-operations.c new file mode 100644 index 0000000000..4d3987af5e --- /dev/null +++ b/Task/Element-wise-operations/C/element-wise-operations.c @@ -0,0 +1,14 @@ +#include + +#define for_i for(i = 0; i < h; i++) +#define for_j for(j = 0; j < w; j++) +#define _M double** +#define OPM(name, _op_) \ + void eop_##name(_M a, _M b, _M c, int w, int h){int i,j;\ + for_i for_j c[i][j] = a[i][j] _op_ b[i][j];} +OPM(add, +);OPM(sub, -);OPM(mul, *);OPM(div, /); + +#define OPS(name, res) \ + void eop_s_##name(_M a, double s, _M b, int w, int h) {double x;int i,j;\ + for_i for_j {x = a[i][j]; b[i][j] = res;}} +OPS(mul, x*s);OPS(div, x/s);OPS(add, x+s);OPS(sub, x-s);OPS(pow, pow(x, s)); diff --git a/Task/Element-wise-operations/Clojure/element-wise-operations.clj b/Task/Element-wise-operations/Clojure/element-wise-operations.clj new file mode 100644 index 0000000000..0e55b3c889 --- /dev/null +++ b/Task/Element-wise-operations/Clojure/element-wise-operations.clj @@ -0,0 +1,8 @@ +(defn initial-mtx [i1 i2 value] + (vec (repeat i1 (vec (repeat i2 value))))) + +(defn operation [f mtx1 mtx2] + (if (vector? mtx1) + (vec (map #(vec (map f %1 %2)) mtx1 mtx2))) + (recur f (initial-mtx (count mtx2) (count (first mtx2)) mtx1) mtx2) + )) diff --git a/Task/Element-wise-operations/Common-Lisp/element-wise-operations-1.lisp b/Task/Element-wise-operations/Common-Lisp/element-wise-operations-1.lisp new file mode 100644 index 0000000000..d13a0e24f1 --- /dev/null +++ b/Task/Element-wise-operations/Common-Lisp/element-wise-operations-1.lisp @@ -0,0 +1,19 @@ +(defun element-wise-matrix (fn A B) + (let* ((len (array-total-size A)) + (m (car (array-dimensions A))) + (n (cadr (array-dimensions A))) + (C (make-array `(,m ,n) :initial-element 0.0d0))) + + (loop for i from 0 to (1- len) do + (setf (row-major-aref C i) + (funcall fn + (row-major-aref A i) + (row-major-aref B i)))) + C)) + +;; A.+B, A.-B, A.*B, A./B, A.^B. +(defun m+ (A B) (element-wise-matrix #'+ A B)) +(defun m- (A B) (element-wise-matrix #'- A B)) +(defun m* (A B) (element-wise-matrix #'* A B)) +(defun m/ (A B) (element-wise-matrix #'/ A B)) +(defun m^ (A B) (element-wise-matrix #'expt A B)) diff --git a/Task/Element-wise-operations/Common-Lisp/element-wise-operations-2.lisp b/Task/Element-wise-operations/Common-Lisp/element-wise-operations-2.lisp new file mode 100644 index 0000000000..856ee296f1 --- /dev/null +++ b/Task/Element-wise-operations/Common-Lisp/element-wise-operations-2.lisp @@ -0,0 +1,19 @@ +(defun element-wise-scalar (fn A c) + (let* ((len (array-total-size A)) + (m (car (array-dimensions A))) + (n (cadr (array-dimensions A))) + (B (make-array `(,m ,n) :initial-element 0.0d0))) + + (loop for i from 0 to (1- len) do + (setf (row-major-aref B i) + (funcall fn + (row-major-aref A i) + c))) + B)) + +;; c.+A, A.-c, c.*A, A./c, A.^c. +(defun .+ (c A) (element-wise-scalar #'+ A c)) +(defun .- (A c) (element-wise-scalar #'- A c)) +(defun .* (c A) (element-wise-scalar #'* A c)) +(defun ./ (A c) (element-wise-scalar #'/ A c)) +(defun .^ (A c) (element-wise-scalar #'expt A c)) diff --git a/Task/Element-wise-operations/D/element-wise-operations.d b/Task/Element-wise-operations/D/element-wise-operations.d new file mode 100644 index 0000000000..318f785e19 --- /dev/null +++ b/Task/Element-wise-operations/D/element-wise-operations.d @@ -0,0 +1,40 @@ +import std.stdio, std.algorithm, std.conv, std.string, + std.typetuple, std.traits; + +T[][] elementwise(string op, T, U)(in T[][] A, in U B) +@safe pure /*nothrow*/ +if (isNumeric!U || (isArray!U && isArray!(ForeachType!U) && + isNumeric!(ForeachType!(ForeachType!U)))) { + static if (!isNumeric!U) + assert(A.length == B.length); + if (!A.length) + return null; + auto R = new typeof(return)(A.length, A[0].length); + + foreach (r, row; A) + static if (isNumeric!U) { + R[r][] = mixin("row[] " ~ op ~ "B"); + } else { + assert(row.length == B[r].length); + R[r][] = mixin("row[] " ~ op ~ "B[r][]"); + } + + return R; +} + +string matRep(T)(in T[][] m) /*@safe pure nothrow*/ { + return "[" ~ join(map!text(m), ",\n ") ~ "]"; +} + +void main() { + const matrix = [[3, 5, 7], + [1, 2, 3], + [2, 4, 6]]; + const scalar = 2; + + foreach (op; TypeTuple!("+", "-", "*", "/", "^^")) { + writeln(op, ":"); + writeln(matRep(elementwise!op(matrix, scalar)), "\n"); + writeln(matRep(elementwise!op(matrix, matrix)), "\n"); + } +} diff --git a/Task/Element-wise-operations/Go/element-wise-operations-1.go b/Task/Element-wise-operations/Go/element-wise-operations-1.go new file mode 100644 index 0000000000..08ff2b32f6 --- /dev/null +++ b/Task/Element-wise-operations/Go/element-wise-operations-1.go @@ -0,0 +1,98 @@ +package main + +import ( + "fmt" + "math" +) + +type matrix [][]float64 +type binaryFunc64 func(float64, float64) float64 + +func like(m matrix) matrix { + cols := len(m[0]) + r := make([][]float64, len(m)) + all := make([]float64, len(m)*cols) + for i := range r { + r[i] = all[i*cols : (i+1)*cols] + } + return r +} + +func elementWiseMM(m1, m2 matrix, f binaryFunc64) matrix { + z := like(m1) + for rx, row := range m1 { + for cx, ele := range row { + z[rx][cx] = f(ele, m2[rx][cx]) + } + } + return z +} + +func elementWiseMS(m matrix, s float64, f binaryFunc64) matrix { + z := like(m) + for rx, row := range m { + for cx, ele := range row { + z[rx][cx] = f(ele, s) + } + } + return z +} + +func add(a, b float64) float64 { return a + b } +func sub(a, b float64) float64 { return a - b } +func mul(a, b float64) float64 { return a * b } +func div(a, b float64) float64 { return a / b } +func exp(a, b float64) float64 { return math.Pow(a, b) } + +func ewmmAdd(m1, m2 matrix) matrix { return elementWiseMM(m1, m2, add) } +func ewmmSub(m1, m2 matrix) matrix { return elementWiseMM(m1, m2, sub) } +func ewmmMul(m1, m2 matrix) matrix { return elementWiseMM(m1, m2, mul) } +func ewmmDiv(m1, m2 matrix) matrix { return elementWiseMM(m1, m2, div) } +func ewmmExp(m1, m2 matrix) matrix { return elementWiseMM(m1, m2, exp) } + +func ewmsAdd(m matrix, s float64) matrix { return elementWiseMS(m, s, add) } +func ewmsSub(m matrix, s float64) matrix { return elementWiseMS(m, s, sub) } +func ewmsMul(m matrix, s float64) matrix { return elementWiseMS(m, s, mul) } +func ewmsDiv(m matrix, s float64) matrix { return elementWiseMS(m, s, div) } +func ewmsExp(m matrix, s float64) matrix { return elementWiseMS(m, s, exp) } + +func main() { + m1 := matrix{{3, 1, 4}, {1, 5, 9}} + m2 := matrix{{2, 7, 1}, {8, 2, 8}} + fmt.Println("m1:") + m1.print() + fmt.Println("m2:") + m2.print() + fmt.Println("m1 + m2:") + ewmmAdd(m1, m2).print() + fmt.Println("m1 - m2:") + ewmmSub(m1, m2).print() + fmt.Println("m1 * m2:") + ewmmMul(m1, m2).print() + fmt.Println("m1 / m2:") + ewmmDiv(m1, m2).print() + fmt.Println("m1 ^ m2:") + ewmmExp(m1, m2).print() + s := .5 + fmt.Println("s:", s) + fmt.Println("m1 + s") + ewmsAdd(m1, s).print() + fmt.Println("m1 - s:") + ewmsSub(m1, s).print() + fmt.Println("m1 * s:") + ewmsMul(m1, s).print() + fmt.Println("m1 / s:") + ewmsDiv(m1, s).print() + fmt.Println("m1 ^ s:") + ewmsExp(m1, s).print() +} + +func (m matrix) print() { + const f = "%6.3f " + for _, r := range m { + for _, e := range r { + fmt.Printf(f, e) + } + fmt.Println() + } +} diff --git a/Task/Element-wise-operations/Go/element-wise-operations-2.go b/Task/Element-wise-operations/Go/element-wise-operations-2.go new file mode 100644 index 0000000000..670c898926 --- /dev/null +++ b/Task/Element-wise-operations/Go/element-wise-operations-2.go @@ -0,0 +1,91 @@ +package main + +import ( + "fmt" + "math" +) + +type matrix struct { + ele []float64 + stride int +} + +func matrixFromRows(rows [][]float64) *matrix { + if len(rows) == 0 { + return &matrix{nil, 0} + } + m := &matrix{make([]float64, len(rows)*len(rows[0])), len(rows[0])} + for rx, row := range rows { + copy(m.ele[rx*m.stride:(rx+1)*m.stride], row) + } + return m +} + +func like(m *matrix) *matrix { + return &matrix{make([]float64, len(m.ele)), m.stride} +} + +func (m *matrix) print(heading string) { + if heading > "" { + fmt.Print("\n", heading, "\n") + } + for e := 0; e < len(m.ele); e += m.stride { + fmt.Printf("%6.3f ", m.ele[e:e+m.stride]) + fmt.Println() + } +} + +type binaryFunc64 func(float64, float64) float64 + +func elementWiseMM(m1, m2 *matrix, f binaryFunc64) *matrix { + z := like(m1) + for i, m1e := range m1.ele { + z.ele[i] = f(m1e, m2.ele[i]) + } + return z +} + +func elementWiseMS(m *matrix, s float64, f binaryFunc64) *matrix { + z := like(m) + for i, e := range m.ele { + z.ele[i] = f(e, s) + } + return z +} + +func add(a, b float64) float64 { return a + b } +func sub(a, b float64) float64 { return a - b } +func mul(a, b float64) float64 { return a * b } +func div(a, b float64) float64 { return a / b } +func exp(a, b float64) float64 { return math.Pow(a, b) } + +func ewmmAdd(m1, m2 *matrix) *matrix { return elementWiseMM(m1, m2, add) } +func ewmmSub(m1, m2 *matrix) *matrix { return elementWiseMM(m1, m2, sub) } +func ewmmMul(m1, m2 *matrix) *matrix { return elementWiseMM(m1, m2, mul) } +func ewmmDiv(m1, m2 *matrix) *matrix { return elementWiseMM(m1, m2, div) } +func ewmmExp(m1, m2 *matrix) *matrix { return elementWiseMM(m1, m2, exp) } + +func ewmsAdd(m *matrix, s float64) *matrix { return elementWiseMS(m, s, add) } +func ewmsSub(m *matrix, s float64) *matrix { return elementWiseMS(m, s, sub) } +func ewmsMul(m *matrix, s float64) *matrix { return elementWiseMS(m, s, mul) } +func ewmsDiv(m *matrix, s float64) *matrix { return elementWiseMS(m, s, div) } +func ewmsExp(m *matrix, s float64) *matrix { return elementWiseMS(m, s, exp) } + +func main() { + m1 := matrixFromRows([][]float64{{3, 1, 4}, {1, 5, 9}}) + m2 := matrixFromRows([][]float64{{2, 7, 1}, {8, 2, 8}}) + m1.print("m1:") + m2.print("m2:") + ewmmAdd(m1, m2).print("m1 + m2:") + ewmmSub(m1, m2).print("m1 - m2:") + ewmmMul(m1, m2).print("m1 * m2:") + ewmmDiv(m1, m2).print("m1 / m2:") + ewmmExp(m1, m2).print("m1 ^ m2:") + s := .5 + fmt.Println("\ns:", s) + ewmsAdd(m1, s).print("m1 + s:") + ewmsSub(m1, s).print("m1 - s:") + ewmsMul(m1, s).print("m1 * s:") + ewmsDiv(m1, s).print("m1 / s:") + ewmsExp(m1, s).print("m1 ^ s:") +} diff --git a/Task/Element-wise-operations/Perl/element-wise-operations-1.pl b/Task/Element-wise-operations/Perl/element-wise-operations-1.pl new file mode 100644 index 0000000000..3ccfed80f9 --- /dev/null +++ b/Task/Element-wise-operations/Perl/element-wise-operations-1.pl @@ -0,0 +1,32 @@ +package Elementwise; + +use Exporter 'import'; + +use overload +'=' => sub { $_[0]->clone() }, +'+' => sub { $_[0]->add($_[1]) }, +'-' => sub { $_[0]->sub($_[1]) }, +'*' => sub { $_[0]->mul($_[1]) }, +'/' => sub { $_[0]->div($_[1]) }, +'**' => sub { $_[0]->exp($_[1]) }, +; + +sub new +{ + my ($class, $v) = @_; + return bless $v, $class; +} + +sub clone +{ + my @ret = @{$_[0]}; + return bless \@ret, ref($_[0]); +} + +sub add { new Elementwise ref($_[1]) ? [map { $_[0][$_] + $_[1][$_] } 0 .. $#{$_[0]} ] : [map { $_[0][$_] + $_[1] } 0 .. $#{$_[0]} ] } +sub sub { new Elementwise ref($_[1]) ? [map { $_[0][$_] - $_[1][$_] } 0 .. $#{$_[0]} ] : [map { $_[0][$_] - $_[1] } 0 .. $#{$_[0]} ] } +sub mul { new Elementwise ref($_[1]) ? [map { $_[0][$_] * $_[1][$_] } 0 .. $#{$_[0]} ] : [map { $_[0][$_] * $_[1] } 0 .. $#{$_[0]} ] } +sub div { new Elementwise ref($_[1]) ? [map { $_[0][$_] / $_[1][$_] } 0 .. $#{$_[0]} ] : [map { $_[0][$_] / $_[1] } 0 .. $#{$_[0]} ] } +sub exp { new Elementwise ref($_[1]) ? [map { $_[0][$_] ** $_[1][$_] } 0 .. $#{$_[0]} ] : [map { $_[0][$_] ** $_[1] } 0 .. $#{$_[0]} ] } + +1; diff --git a/Task/Element-wise-operations/Perl/element-wise-operations-2.pl b/Task/Element-wise-operations/Perl/element-wise-operations-2.pl new file mode 100644 index 0000000000..a78579b706 --- /dev/null +++ b/Task/Element-wise-operations/Perl/element-wise-operations-2.pl @@ -0,0 +1,23 @@ +use Elementwise; + +$a = new Elementwise [ + 1,2,3, + 4,5,6, + 7,8,9 +]; + +print << "_E"; +a @$a +a OP a ++ @{$a+$a} +- @{$a-$a} +* @{$a*$a} +/ @{$a/$a} +^ @{$a**$a} +a OP 5 ++ @{$a+5} +- @{$a-5} +* @{$a*5} +/ @{$a/5} +^ @{$a**5} +_E diff --git a/Task/Element-wise-operations/PicoLisp/element-wise-operations.l b/Task/Element-wise-operations/PicoLisp/element-wise-operations.l new file mode 100644 index 0000000000..cc0519cb5b --- /dev/null +++ b/Task/Element-wise-operations/PicoLisp/element-wise-operations.l @@ -0,0 +1,5 @@ +(de elementWiseMatrix (Fun Mat1 Mat2) + (mapcar '((L1 L2) (mapcar Fun L1 L2)) Mat1 Mat2) ) + +(de elementWiseScalar (Fun Mat Scalar) + (elementWiseMatrix Fun Mat (circ (circ Scalar))) ) diff --git a/Task/Element-wise-operations/Python/element-wise-operations.py b/Task/Element-wise-operations/Python/element-wise-operations.py new file mode 100644 index 0000000000..2a9c623aca --- /dev/null +++ b/Task/Element-wise-operations/Python/element-wise-operations.py @@ -0,0 +1,43 @@ +>>> import random +>>> from operator import add, sub, mul, floordiv +>>> from pprint import pprint as pp +>>> +>>> def ewise(matrix1, matrix2, op): + return [[op(e1,e2) for e1,e2 in zip(row1, row2)] for row1,row2 in zip(matrix1, matrix2)] + +>>> m,n = 3,4 # array dimensions +>>> a0 = [[random.randint(1,9) for y in range(n)] for x in range(m)] +>>> a1 = [[random.randint(1,9) for y in range(n)] for x in range(m)] +>>> pp(a0); pp(a1) +[[7, 8, 7, 4], [4, 9, 4, 1], [2, 3, 6, 4]] +[[4, 5, 1, 6], [6, 8, 3, 4], [2, 2, 6, 3]] +>>> pp(ewise(a0, a1, add)) +[[11, 13, 8, 10], [10, 17, 7, 5], [4, 5, 12, 7]] +>>> pp(ewise(a0, a1, sub)) +[[3, 3, 6, -2], [-2, 1, 1, -3], [0, 1, 0, 1]] +>>> pp(ewise(a0, a1, mul)) +[[28, 40, 7, 24], [24, 72, 12, 4], [4, 6, 36, 12]] +>>> pp(ewise(a0, a1, floordiv)) +[[1, 1, 7, 0], [0, 1, 1, 0], [1, 1, 1, 1]] +>>> pp(ewise(a0, a1, pow)) +[[2401, 32768, 7, 4096], [4096, 43046721, 64, 1], [4, 9, 46656, 64]] +>>> pp(ewise(a0, a1, lambda x, y:2*x - y)) +[[10, 11, 13, 2], [2, 10, 5, -2], [2, 4, 6, 5]] +>>> +>>> def s_ewise(scalar1, matrix1, op): + return [[op(scalar1, e1) for e1 in row1] for row1 in matrix1] + +>>> scalar = 10 +>>> a0 +[[7, 8, 7, 4], [4, 9, 4, 1], [2, 3, 6, 4]] +>>> for op in ( add, sub, mul, floordiv, pow, lambda x, y:2*x - y ): + print("%10s :" % op.__name__, s_ewise(scalar, a0, op)) + + + add : [[17, 18, 17, 14], [14, 19, 14, 11], [12, 13, 16, 14]] + sub : [[3, 2, 3, 6], [6, 1, 6, 9], [8, 7, 4, 6]] + mul : [[70, 80, 70, 40], [40, 90, 40, 10], [20, 30, 60, 40]] + floordiv : [[1, 1, 1, 2], [2, 1, 2, 10], [5, 3, 1, 2]] + pow : [[10000000, 100000000, 10000000, 10000], [10000, 1000000000, 10000, 10], [100, 1000, 1000000, 10000]] + : [[13, 12, 13, 16], [16, 11, 16, 19], [18, 17, 14, 16]] +>>> diff --git a/Task/Element-wise-operations/R/element-wise-operations.r b/Task/Element-wise-operations/R/element-wise-operations.r new file mode 100644 index 0000000000..0dd7cc8ab6 --- /dev/null +++ b/Task/Element-wise-operations/R/element-wise-operations.r @@ -0,0 +1,12 @@ +# create a 2-times-2 matrix +mat <- matrix(1:4, 2, 2) + +# matrix with scalar +mat + 2 +mat * 2 +mat ^ 2 + +# matrix with matrix +mat + mat +mat * mat +mat ^ mat diff --git a/Task/Element-wise-operations/REXX/element-wise-operations-1.rexx b/Task/Element-wise-operations/REXX/element-wise-operations-1.rexx new file mode 100644 index 0000000000..863b311151 --- /dev/null +++ b/Task/Element-wise-operations/REXX/element-wise-operations-1.rexx @@ -0,0 +1,32 @@ +/*REXX program multiplies two matrixes together, shows matrixes & result*/ +m=(1 2 3) (4 5 6) (7 8 9) +w=words(m); do k=1; if k*k>=w then leave; end /*k*/; rows=k; cols=k + +call showMat M, 'M matrix' +answer=matAdd(m, 2 ); call showMat answer, 'M matrix, added 2' +answer=matSub(m, 7 ); call showMat answer, 'M matrix, subtracted 7' +answer=matMul(m, 2.5); call showMat answer, 'M matrix, multiplied by 2½' +answer=matPow(m, 3 ); call showMat answer, 'M matrix, cubed' +answer=matDiv(m, 4 ); call showMat answer, 'M matrix, divided by 4' +answer=matIdv(m, 2 ); call showMat answer, 'M matrix, integer halved' +answer=matMod(m, 3 ); call showMat answer, 'M matrix, modulus 3' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────SHOWMAT subroutine──────────────────*/ +showMat: parse arg @, hdr; say +L=0; do j=1 for w; L=max(L,length(word(@,j))); end +say center(hdr, max(length(hdr)+4, cols*(L+1)+4), "─") +n=0 + do r =1 for rows; _= + do c=1 for cols; n=n+1; _=_ right(word(@,n),L); end; say _ + end +return +/*──────────────────────────────────one-liner subroutines───────────────*/ +matAdd: arg @,#; call mat#; do j=1 for w; !.j=!.j+#; end; return mat@() +matSub: arg @,#; call mat#; do j=1 for w; !.j=!.j-#; end; return mat@() +matMul: arg @,#; call mat#; do j=1 for w; !.j=!.j*#; end; return mat@() +matDiv: arg @,#; call mat#; do j=1 for w; !.j=!.j/#; end; return mat@() +matIdv: arg @,#; call mat#; do j=1 for w; !.j=!.j%#; end; return mat@() +matPow: arg @,#; call mat#; do j=1 for w; !.j=!.j**#; end; return mat@() +matMod: arg @,#; call mat#; do j=1 for w; !.j=!.j//#; end; return mat@() +mat#: w=words(@); do j=1 for w; !.j=word(@,j); end; return +mat@: @=!.1; do j=2 to w; @=@ !.j; end; return @ diff --git a/Task/Element-wise-operations/REXX/element-wise-operations-2.rexx b/Task/Element-wise-operations/REXX/element-wise-operations-2.rexx new file mode 100644 index 0000000000..a74deb01fc --- /dev/null +++ b/Task/Element-wise-operations/REXX/element-wise-operations-2.rexx @@ -0,0 +1,27 @@ +/*REXX program multiplies two matrixes together, shows matrixes & result*/ +m=(1 2 3) (4 5 6) (7 8 9) +w=words(m); do k=1; if k*k>=w then leave; end /*k*/; rows=k; cols=k + +call showMat M, 'M matrix' +ans=matOp(m, '+2' ); call showMat ans, 'M matrix, added 2' +ans=matOp(m, '-7' ); call showMat ans, 'M matrix, subtracted 7' +ans=matOp(m, '*2.5' ); call showMat ans, 'M matrix, multiplied by 2½' +ans=matOp(m, '**3' ); call showMat ans, 'M matrix, cubed' +ans=matOp(m, '/4' ); call showMat ans, 'M matrix, divided by 4' +ans=matOp(m, '%2' ); call showMat ans, 'M matrix, integer halved' +ans=matOp(m, '//3' ); call showMat ans, 'M matrix, modulus 3' +ans=matOp(m, '*3-1' ); call showMat ans, 'M matrix, tripled, less one' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────SHOWMAT subroutine──────────────────*/ +showMat: parse arg @, hdr; say +L=0; do j=1 for w; L=max(L,length(word(@,j))); end +say; say center(hdr,max(length(hdr)+4,cols*(L+1)+4),"─") +n=0 + do r =1 for rows; _= + do c=1 for cols; n=n+1; _=_ right(word(@,n),L); end; say _ + end +return +/*──────────────────────────────────one-liner subroutines───────────────*/ +matOp: arg @,#;call mat#; do j=1 for w; interpret '!.'j"=!."j #;end; return mat@() +mat#: w=words(@); do j=1 for w; !.j=word(@,j); end; return +mat@: @=!.1; do j=2 to w; @=@ !.j; end; return @ diff --git a/Task/Element-wise-operations/Tcl/element-wise-operations.tcl b/Task/Element-wise-operations/Tcl/element-wise-operations.tcl new file mode 100644 index 0000000000..f62e85d2d7 --- /dev/null +++ b/Task/Element-wise-operations/Tcl/element-wise-operations.tcl @@ -0,0 +1,40 @@ +package require Tcl 8.5 +proc alias {name args} {uplevel 1 [list interp alias {} $name {} {*}$args]} + +# Engine for elementwise operations between matrices +proc elementwiseMatMat {lambda A B} { + set C {} + foreach rA $A rB $B { + set rC {} + foreach vA $rA vB $rB { + lappend rC [apply $lambda $vA $vB] + } + lappend C $rC + } + return $C +} +# Lift some basic math ops +alias m+ elementwiseMatMat {{a b} {expr {$a+$b}}} +alias m- elementwiseMatMat {{a b} {expr {$a-$b}}} +alias m* elementwiseMatMat {{a b} {expr {$a*$b}}} +alias m/ elementwiseMatMat {{a b} {expr {$a/$b}}} +alias m** elementwiseMatMat {{a b} {expr {$a**$b}}} + +# Engine for elementwise operations between a matrix and a scalar +proc elementwiseMatSca {lambda A b} { + set C {} + foreach rA $A { + set rC {} + foreach vA $rA { + lappend rC [apply $lambda $vA $b] + } + lappend C $rC + } + return $C +} +# Lift some basic math ops +alias .+ elementwiseMatSca {{a b} {expr {$a+$b}}} +alias .- elementwiseMatSca {{a b} {expr {$a-$b}}} +alias .* elementwiseMatSca {{a b} {expr {$a*$b}}} +alias ./ elementwiseMatSca {{a b} {expr {$a/$b}}} +alias .** elementwiseMatSca {{a b} {expr {$a**$b}}} diff --git a/Task/Empty-directory/0DESCRIPTION b/Task/Empty-directory/0DESCRIPTION new file mode 100644 index 0000000000..283749e811 --- /dev/null +++ b/Task/Empty-directory/0DESCRIPTION @@ -0,0 +1,3 @@ +Starting with a path to some directory, determine whether the directory is empty. + +An empty directory contains no files nor subdirectories. With [[Unix]] or [[Windows]] systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other entries. diff --git a/Task/Empty-directory/Ada/empty-directory.ada b/Task/Empty-directory/Ada/empty-directory.ada new file mode 100644 index 0000000000..11275cd497 --- /dev/null +++ b/Task/Empty-directory/Ada/empty-directory.ada @@ -0,0 +1,24 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Directories; +procedure EmptyDir is + function Empty (path : String) return String is + use Ada.Directories; + result : String := "Is empty."; + procedure check (ent : Directory_Entry_Type) is begin + if Simple_Name (ent) /= "." and Simple_Name (ent) /= ".." then + Empty.result := "Not empty"; + end if; + end check; + begin + if not Exists (path) then return "Does not exist."; + elsif Kind (path) /= Directory then return "Not a Directory."; + end if; + Search (path, "", Process => check'Access); + return result; + end Empty; +begin + Put_Line (Empty (".")); + Put_Line (Empty ("./empty")); + Put_Line (Empty ("./emptydir.adb")); + Put_Line (Empty ("./foobar")); +end EmptyDir; diff --git a/Task/Empty-directory/BBC-BASIC/empty-directory.bbc b/Task/Empty-directory/BBC-BASIC/empty-directory.bbc new file mode 100644 index 0000000000..5d06e80a36 --- /dev/null +++ b/Task/Empty-directory/BBC-BASIC/empty-directory.bbc @@ -0,0 +1,17 @@ + IF FNisdirectoryempty("C:\") PRINT "C:\ is empty" ELSE PRINT "C:\ is not empty" + IF FNisdirectoryempty("C:\temp") PRINT "C:\temp is empty" ELSE PRINT "C:\temp is not empty" + END + + DEF FNisdirectoryempty(dir$) + LOCAL dir%, sh%, res% + DIM dir% LOCAL 317 + IF RIGHT$(dir$)<>"\" dir$ += "\" + SYS "FindFirstFile", dir$+"*", dir% TO sh% + IF sh% = -1 ERROR 100, "Directory doesn't exist" + res% = 1 + REPEAT + IF $$(dir%+44)<>"." IF $$(dir%+44)<>".." EXIT REPEAT + SYS "FindNextFile", sh%, dir% TO res% + UNTIL res% == 0 + SYS "FindClose", sh% + = (res% == 0) diff --git a/Task/Empty-directory/C/empty-directory.c b/Task/Empty-directory/C/empty-directory.c new file mode 100644 index 0000000000..42df8e4440 --- /dev/null +++ b/Task/Empty-directory/C/empty-directory.c @@ -0,0 +1,40 @@ +#include +#include +#include + +int dir_empty(const char *path) +{ + struct dirent *ent; + int ret = 1; + + DIR *d = opendir(path); + if (!d) { + fprintf(stderr, "%s: ", path); + perror(""); + return -1; + } + + while ((ent = readdir(d))) { + if (!strcmp(ent->d_name, ".") || !(strcmp(ent->d_name, ".."))) + continue; + ret = 0; + break; + } + + closedir(d); + return ret; +} + +int main(int c, char **v) +{ + int ret = 0, i; + if (c < 2) return -1; + + for (i = 1; i < c; i++) { + ret = dir_empty(v[i]); + if (ret >= 0) + printf("%s: %sempty\n", v[i], ret ? "" : "not "); + } + + return 0; +} diff --git a/Task/Empty-directory/CoffeeScript/empty-directory.coffee b/Task/Empty-directory/CoffeeScript/empty-directory.coffee new file mode 100644 index 0000000000..0e994471da --- /dev/null +++ b/Task/Empty-directory/CoffeeScript/empty-directory.coffee @@ -0,0 +1,7 @@ +fs = require 'fs' + +is_empty_dir = (dir) -> + throw Error "#{dir} is not a dir" unless fs.statSync(dir).isDirectory() + # readdirSync does not return . or .. + fns = fs.readdirSync dir + fns.length == 0 diff --git a/Task/Empty-directory/D/empty-directory.d b/Task/Empty-directory/D/empty-directory.d new file mode 100644 index 0000000000..71e1154caa --- /dev/null +++ b/Task/Empty-directory/D/empty-directory.d @@ -0,0 +1,12 @@ +import std.stdio, std.file; + +void main() { + auto dir = "somedir"; + writeln(dir ~ " is empty: ", dirEmpty(dir)); +} + +bool dirEmpty(string dirname) { + if (!exists(dirname) || !isDir(dirname)) + throw new Exception("dir not found: " ~ dirname); + return dirEntries(dirname, SpanMode.shallow).empty; +} diff --git a/Task/Empty-directory/Go/empty-directory.go b/Task/Empty-directory/Go/empty-directory.go new file mode 100644 index 0000000000..a154f5aa52 --- /dev/null +++ b/Task/Empty-directory/Go/empty-directory.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "io/ioutil" + "log" +) + +func main() { + empty, err := IsEmptyDir("/tmp") + if err != nil { + log.Fatalln(err) + } + if empty { + fmt.Printf("/tmp is empty\n") + } else { + fmt.Printf("/tmp is not empty\n") + } +} + +func IsEmptyDir(name string) (bool, error) { + entries, err := ioutil.ReadDir(name) + if err != nil { + return false, err + } + return len(entries) == 0, nil +} diff --git a/Task/Empty-directory/Haskell/empty-directory-1.hs b/Task/Empty-directory/Haskell/empty-directory-1.hs new file mode 100644 index 0000000000..fb6d463dc8 --- /dev/null +++ b/Task/Empty-directory/Haskell/empty-directory-1.hs @@ -0,0 +1,9 @@ +import System.Directory (getDirectoryContents) +import System.Environment (getArgs) + + +isEmpty x = getDirectoryContents x >>= return . f . (== [".", ".."]) + where f True = "Directory is empty" + f False = "Directory is not empty" + +main = getArgs >>= isEmpty . (!! 0) >>= putStrLn diff --git a/Task/Empty-directory/Haskell/empty-directory-2.hs b/Task/Empty-directory/Haskell/empty-directory-2.hs new file mode 100644 index 0000000000..6b56ce2aac --- /dev/null +++ b/Task/Empty-directory/Haskell/empty-directory-2.hs @@ -0,0 +1,5 @@ +$ mkdir 1 +$ ./isempty 1 +Directory is empty +$ ./isempty /usr/ +Directory is not empty diff --git a/Task/Empty-directory/Haskell/empty-directory-3.hs b/Task/Empty-directory/Haskell/empty-directory-3.hs new file mode 100644 index 0000000000..1a47cfefa5 --- /dev/null +++ b/Task/Empty-directory/Haskell/empty-directory-3.hs @@ -0,0 +1,15 @@ +procedure main() + every dir := "." | "./empty" do + write(dir, if isdirempty(dir) then " is empty" else " is not empty") +end + +procedure isdirempty(s) #: succeeds if directory s is empty (and a directory) +local d,f + if ( stat(s).mode ? ="d" ) & ( d := open(s) ) then { + while f := read(d) do + if f == ("."|"..") then next else fail + close(d) + return s + } + else stop(s," is not a directory or will not open") +end diff --git a/Task/Empty-directory/Java/empty-directory.java b/Task/Empty-directory/Java/empty-directory.java new file mode 100644 index 0000000000..0af0e6334c --- /dev/null +++ b/Task/Empty-directory/Java/empty-directory.java @@ -0,0 +1,5 @@ +import java.nio.file.Paths; +//... other class code here +public static boolean isEmptyDir(String dirName){ + return Paths.get(dirName).toFile().listFiles().length == 0; +} diff --git a/Task/Empty-directory/MATLAB/empty-directory.m b/Task/Empty-directory/MATLAB/empty-directory.m new file mode 100644 index 0000000000..07a0bcfe2a --- /dev/null +++ b/Task/Empty-directory/MATLAB/empty-directory.m @@ -0,0 +1,8 @@ + function x = isEmptyDirectory(p) + if isdir(p) + f = dir(p) + x = length(f)>2; + else + error('Error: %s is not a directory'); + end; + end; diff --git a/Task/Empty-directory/PHP/empty-directory.php b/Task/Empty-directory/PHP/empty-directory.php new file mode 100644 index 0000000000..fdb62f9896 --- /dev/null +++ b/Task/Empty-directory/PHP/empty-directory.php @@ -0,0 +1,16 @@ +$dir = 'path_here'; + +if(is_dir($dir)){ + //scandir grabs the contents of a directory and array_diff is being used to filter out .. and . + $list = array_diff(scandir($dir), array('..', '.')); + //now we can just use empty to check if the variable has any contents regardless of it's type + if(empty($list)){ + echo 'dir is empty'; + } + else{ + echo 'dir is not empty'; + } +} +else{ + echo 'not a directory'; +} diff --git a/Task/Empty-directory/Perl/empty-directory-1.pl b/Task/Empty-directory/Perl/empty-directory-1.pl new file mode 100644 index 0000000000..5fbef8286c --- /dev/null +++ b/Task/Empty-directory/Perl/empty-directory-1.pl @@ -0,0 +1 @@ +sub dir_is_empty {!<$_[0]/*>} diff --git a/Task/Empty-directory/Perl/empty-directory-2.pl b/Task/Empty-directory/Perl/empty-directory-2.pl new file mode 100644 index 0000000000..e07025bab5 --- /dev/null +++ b/Task/Empty-directory/Perl/empty-directory-2.pl @@ -0,0 +1,2 @@ +use IO::Dir; +sub dir_is_empty { !grep !/^\.{1,2}\z/, IO::Dir->new(@_)->read } diff --git a/Task/Empty-directory/PicoLisp/empty-directory.l b/Task/Empty-directory/PicoLisp/empty-directory.l new file mode 100644 index 0000000000..d9bceb9178 --- /dev/null +++ b/Task/Empty-directory/PicoLisp/empty-directory.l @@ -0,0 +1 @@ +(prinl "myDir is" (and (dir "myDir") " not") " empty") diff --git a/Task/Empty-directory/Python/empty-directory.py b/Task/Empty-directory/Python/empty-directory.py new file mode 100644 index 0000000000..7d6171a923 --- /dev/null +++ b/Task/Empty-directory/Python/empty-directory.py @@ -0,0 +1,5 @@ +import os; +if os.listdir(raw_input("directory")): + print "not empty" +else: + print "empty" diff --git a/Task/Empty-directory/Racket/empty-directory.rkt b/Task/Empty-directory/Racket/empty-directory.rkt new file mode 100644 index 0000000000..0bab4e5477 --- /dev/null +++ b/Task/Empty-directory/Racket/empty-directory.rkt @@ -0,0 +1,2 @@ +#lang racket +(empty? (directory-list "some-directory")) diff --git a/Task/Empty-directory/Ruby/empty-directory-1.rb b/Task/Empty-directory/Ruby/empty-directory-1.rb new file mode 100644 index 0000000000..892fad62a7 --- /dev/null +++ b/Task/Empty-directory/Ruby/empty-directory-1.rb @@ -0,0 +1,5 @@ +# Checks if a directory is empty, but raises SystemCallError +# if _path_ is not a directory. +def empty_dir?(path) + not Dir.foreach(path).detect {|f| f != '.' and f != '..'} +end diff --git a/Task/Empty-directory/Ruby/empty-directory-2.rb b/Task/Empty-directory/Ruby/empty-directory-2.rb new file mode 100644 index 0000000000..f9db3dc053 --- /dev/null +++ b/Task/Empty-directory/Ruby/empty-directory-2.rb @@ -0,0 +1,8 @@ +# Checks if a directory is empty, but raises SystemCallError +# if _path_ is not a directory. +def empty_dir?(path) + Dir.foreach(path) {|f| + return false if f != '.' and f != '..' + } + return true +end diff --git a/Task/Empty-directory/Scala/empty-directory.scala b/Task/Empty-directory/Scala/empty-directory.scala new file mode 100644 index 0000000000..baada84b34 --- /dev/null +++ b/Task/Empty-directory/Scala/empty-directory.scala @@ -0,0 +1,4 @@ +import java.io.File + +def isDirEmpty(file:File) : Boolean = + return file.exists && file.isDirectory && file.list.isEmpty diff --git a/Task/Empty-directory/Tcl/empty-directory.tcl b/Task/Empty-directory/Tcl/empty-directory.tcl new file mode 100644 index 0000000000..769f27dafd --- /dev/null +++ b/Task/Empty-directory/Tcl/empty-directory.tcl @@ -0,0 +1,6 @@ +proc isEmptyDir {dir} { + # Get list of _all_ files in directory + set filenames [glob -nocomplain -tails -directory $dir * .*] + # Check whether list is empty (after filtering specials) + expr {![llength [lsearch -all -not -regexp $filenames {^\.\.?$}]]} +} diff --git a/Task/Empty-program/0DESCRIPTION b/Task/Empty-program/0DESCRIPTION new file mode 100644 index 0000000000..7190f46e90 --- /dev/null +++ b/Task/Empty-program/0DESCRIPTION @@ -0,0 +1,3 @@ +In this task, the goal is to create the simplest possible program that is still considered "correct." + +=Programming Languages= diff --git a/Task/Empty-program/1META.yaml b/Task/Empty-program/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Empty-program/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Empty-program/ALGOL-68/empty-program-1.alg b/Task/Empty-program/ALGOL-68/empty-program-1.alg new file mode 100644 index 0000000000..54bcf30465 --- /dev/null +++ b/Task/Empty-program/ALGOL-68/empty-program-1.alg @@ -0,0 +1 @@ +~ diff --git a/Task/Empty-program/ALGOL-68/empty-program-2.alg b/Task/Empty-program/ALGOL-68/empty-program-2.alg new file mode 100644 index 0000000000..cc2ecb636e --- /dev/null +++ b/Task/Empty-program/ALGOL-68/empty-program-2.alg @@ -0,0 +1 @@ +SKIP diff --git a/Task/Empty-program/AWK/empty-program.awk b/Task/Empty-program/AWK/empty-program.awk new file mode 100644 index 0000000000..3ae9c11c87 --- /dev/null +++ b/Task/Empty-program/AWK/empty-program.awk @@ -0,0 +1 @@ + 1 diff --git a/Task/Empty-program/Ada/empty-program.ada b/Task/Empty-program/Ada/empty-program.ada new file mode 100644 index 0000000000..ee2b929476 --- /dev/null +++ b/Task/Empty-program/Ada/empty-program.ada @@ -0,0 +1,4 @@ +procedure Empty is +begin + null; +end; diff --git a/Task/Empty-program/Agena/empty-program.agena b/Task/Empty-program/Agena/empty-program.agena new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/AmigaE/empty-program.amiga b/Task/Empty-program/AmigaE/empty-program.amiga new file mode 100644 index 0000000000..137abc2b6a --- /dev/null +++ b/Task/Empty-program/AmigaE/empty-program.amiga @@ -0,0 +1,2 @@ +PROC main() +ENDPROC diff --git a/Task/Empty-program/AppleScript/empty-program.applescript b/Task/Empty-program/AppleScript/empty-program.applescript new file mode 100644 index 0000000000..a09c86384f --- /dev/null +++ b/Task/Empty-program/AppleScript/empty-program.applescript @@ -0,0 +1 @@ +return diff --git a/Task/Empty-program/Argile/empty-program.argile b/Task/Empty-program/Argile/empty-program.argile new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/AutoHotkey/empty-program.ahk b/Task/Empty-program/AutoHotkey/empty-program.ahk new file mode 100644 index 0000000000..71e77bdb21 --- /dev/null +++ b/Task/Empty-program/AutoHotkey/empty-program.ahk @@ -0,0 +1 @@ +#Persistent diff --git a/Task/Empty-program/AutoIt/empty-program.autoit b/Task/Empty-program/AutoIt/empty-program.autoit new file mode 100644 index 0000000000..059e4f3311 --- /dev/null +++ b/Task/Empty-program/AutoIt/empty-program.autoit @@ -0,0 +1 @@ +;nothing diff --git a/Task/Empty-program/BASIC/empty-program-1.bas b/Task/Empty-program/BASIC/empty-program-1.bas new file mode 100644 index 0000000000..a90900f0a9 --- /dev/null +++ b/Task/Empty-program/BASIC/empty-program-1.bas @@ -0,0 +1 @@ +10 END diff --git a/Task/Empty-program/BASIC/empty-program-2.bas b/Task/Empty-program/BASIC/empty-program-2.bas new file mode 100644 index 0000000000..f7081fdaea --- /dev/null +++ b/Task/Empty-program/BASIC/empty-program-2.bas @@ -0,0 +1 @@ +RUN diff --git a/Task/Empty-program/BBC-BASIC/empty-program.bbc b/Task/Empty-program/BBC-BASIC/empty-program.bbc new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Batch-File/empty-program-1.bat b/Task/Empty-program/Batch-File/empty-program-1.bat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Batch-File/empty-program-2.bat b/Task/Empty-program/Batch-File/empty-program-2.bat new file mode 100644 index 0000000000..9699d2b163 --- /dev/null +++ b/Task/Empty-program/Batch-File/empty-program-2.bat @@ -0,0 +1 @@ +REM diff --git a/Task/Empty-program/Bracmat/empty-program-1.bracmat b/Task/Empty-program/Bracmat/empty-program-1.bracmat new file mode 100644 index 0000000000..171013e5a4 --- /dev/null +++ b/Task/Empty-program/Bracmat/empty-program-1.bracmat @@ -0,0 +1,2 @@ +touch empty +bracmat 'get$empty' diff --git a/Task/Empty-program/Bracmat/empty-program-2.bracmat b/Task/Empty-program/Bracmat/empty-program-2.bracmat new file mode 100644 index 0000000000..cf1979138b --- /dev/null +++ b/Task/Empty-program/Bracmat/empty-program-2.bracmat @@ -0,0 +1,2 @@ +touch empty +bracmat get$empty diff --git a/Task/Empty-program/Bracmat/empty-program-3.bracmat b/Task/Empty-program/Bracmat/empty-program-3.bracmat new file mode 100644 index 0000000000..e48172f343 --- /dev/null +++ b/Task/Empty-program/Bracmat/empty-program-3.bracmat @@ -0,0 +1 @@ +bracmat '' diff --git a/Task/Empty-program/Bracmat/empty-program-4.bracmat b/Task/Empty-program/Bracmat/empty-program-4.bracmat new file mode 100644 index 0000000000..0e45927c1c --- /dev/null +++ b/Task/Empty-program/Bracmat/empty-program-4.bracmat @@ -0,0 +1 @@ +bracmat "" diff --git a/Task/Empty-program/Brlcad/empty-program.brlcad b/Task/Empty-program/Brlcad/empty-program.brlcad new file mode 100644 index 0000000000..2c9a76da0a --- /dev/null +++ b/Task/Empty-program/Brlcad/empty-program.brlcad @@ -0,0 +1 @@ +opendb empty.g y diff --git a/Task/Empty-program/C++/empty-program.cpp b/Task/Empty-program/C++/empty-program.cpp new file mode 100644 index 0000000000..705f51bc26 --- /dev/null +++ b/Task/Empty-program/C++/empty-program.cpp @@ -0,0 +1,11 @@ +int main ( int /*argc*/, char * * /*argv*/ ) +{ + // Unused arguments should not be named + // There are variations: + // 1: main ''may'' explicitly return a value + // (other non-void-returning C++ functions ''must'' do so, + // but there's a special exception for main that falling off it + // without an explicit return is equivalent to a "return 0;" at + // the end of the main function) + // 2: The arguments may be omitted entirely +} diff --git a/Task/Empty-program/C/empty-program-1.c b/Task/Empty-program/C/empty-program-1.c new file mode 100644 index 0000000000..9f0510be5a --- /dev/null +++ b/Task/Empty-program/C/empty-program-1.c @@ -0,0 +1,4 @@ +int main(int argc, char* argv[]) +{ + return 0; +} diff --git a/Task/Empty-program/C/empty-program-2.c b/Task/Empty-program/C/empty-program-2.c new file mode 100644 index 0000000000..1482f27e53 --- /dev/null +++ b/Task/Empty-program/C/empty-program-2.c @@ -0,0 +1,4 @@ +int main () +{ + return 0; +} diff --git a/Task/Empty-program/C/empty-program-3.c b/Task/Empty-program/C/empty-program-3.c new file mode 100644 index 0000000000..f73ad9f4fb --- /dev/null +++ b/Task/Empty-program/C/empty-program-3.c @@ -0,0 +1,3 @@ +main () { + return 0; +} diff --git a/Task/Empty-program/COBOL/empty-program.cobol b/Task/Empty-program/COBOL/empty-program.cobol new file mode 100644 index 0000000000..f371e9972d --- /dev/null +++ b/Task/Empty-program/COBOL/empty-program.cobol @@ -0,0 +1,2 @@ +Identification division. +Program-id. minimal. diff --git a/Task/Empty-program/Clean/empty-program.clean b/Task/Empty-program/Clean/empty-program.clean new file mode 100644 index 0000000000..dce4f5a048 --- /dev/null +++ b/Task/Empty-program/Clean/empty-program.clean @@ -0,0 +1,3 @@ +module Empty + +Start world = world diff --git a/Task/Empty-program/CoffeeScript/empty-program.coffee b/Task/Empty-program/CoffeeScript/empty-program.coffee new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/D/empty-program.d b/Task/Empty-program/D/empty-program.d new file mode 100644 index 0000000000..ab73b3a234 --- /dev/null +++ b/Task/Empty-program/D/empty-program.d @@ -0,0 +1 @@ +void main() {} diff --git a/Task/Empty-program/Dart/empty-program.dart b/Task/Empty-program/Dart/empty-program.dart new file mode 100644 index 0000000000..69c27338e7 --- /dev/null +++ b/Task/Empty-program/Dart/empty-program.dart @@ -0,0 +1,2 @@ +main() { +} diff --git a/Task/Empty-program/E/empty-program.e b/Task/Empty-program/E/empty-program.e new file mode 100644 index 0000000000..19765bd501 --- /dev/null +++ b/Task/Empty-program/E/empty-program.e @@ -0,0 +1 @@ +null diff --git a/Task/Empty-program/EGL/empty-program.egl b/Task/Empty-program/EGL/empty-program.egl new file mode 100644 index 0000000000..0866b53131 --- /dev/null +++ b/Task/Empty-program/EGL/empty-program.egl @@ -0,0 +1,6 @@ +package programs; + +program Empty_program type BasicProgram {} + function main() + end +end diff --git a/Task/Empty-program/Eiffel/empty-program.e b/Task/Empty-program/Eiffel/empty-program.e new file mode 100644 index 0000000000..21c928677e --- /dev/null +++ b/Task/Empty-program/Eiffel/empty-program.e @@ -0,0 +1,12 @@ +class + ROOT + +create + make + +feature + make + do + + end +end diff --git a/Task/Empty-program/Erlang/empty-program-1.erl b/Task/Empty-program/Erlang/empty-program-1.erl new file mode 100644 index 0000000000..877ff66013 --- /dev/null +++ b/Task/Empty-program/Erlang/empty-program-1.erl @@ -0,0 +1 @@ +-module(empty). diff --git a/Task/Empty-program/Erlang/empty-program-2.erl b/Task/Empty-program/Erlang/empty-program-2.erl new file mode 100644 index 0000000000..252cf4ea67 --- /dev/null +++ b/Task/Empty-program/Erlang/empty-program-2.erl @@ -0,0 +1 @@ +main(_) -> 1. diff --git a/Task/Empty-program/Euphoria/empty-program.euphoria b/Task/Empty-program/Euphoria/empty-program.euphoria new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Forth/empty-program-1.fth b/Task/Empty-program/Forth/empty-program-1.fth new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Forth/empty-program-2.fth b/Task/Empty-program/Forth/empty-program-2.fth new file mode 100644 index 0000000000..b023018cab --- /dev/null +++ b/Task/Empty-program/Forth/empty-program-2.fth @@ -0,0 +1 @@ +bye diff --git a/Task/Empty-program/Fortran/empty-program.f b/Task/Empty-program/Fortran/empty-program.f new file mode 100644 index 0000000000..33e0efa66e --- /dev/null +++ b/Task/Empty-program/Fortran/empty-program.f @@ -0,0 +1 @@ + end diff --git a/Task/Empty-program/Go/empty-program.go b/Task/Empty-program/Go/empty-program.go new file mode 100644 index 0000000000..792a5176a9 --- /dev/null +++ b/Task/Empty-program/Go/empty-program.go @@ -0,0 +1,2 @@ +package main +func main() { } diff --git a/Task/Empty-program/Haskell/empty-program-1.hs b/Task/Empty-program/Haskell/empty-program-1.hs new file mode 100644 index 0000000000..b3549c2fe3 --- /dev/null +++ b/Task/Empty-program/Haskell/empty-program-1.hs @@ -0,0 +1 @@ +main = return () diff --git a/Task/Empty-program/Haskell/empty-program-2.hs b/Task/Empty-program/Haskell/empty-program-2.hs new file mode 100644 index 0000000000..97b813fc9d --- /dev/null +++ b/Task/Empty-program/Haskell/empty-program-2.hs @@ -0,0 +1 @@ +module X where {} diff --git a/Task/Empty-program/Java/empty-program-1.java b/Task/Empty-program/Java/empty-program-1.java new file mode 100644 index 0000000000..f8d3c682cb --- /dev/null +++ b/Task/Empty-program/Java/empty-program-1.java @@ -0,0 +1,4 @@ +public class EmptyApplet extends java.applet.Applet { + @Override public void init() { + } +} diff --git a/Task/Empty-program/Java/empty-program-2.java b/Task/Empty-program/Java/empty-program-2.java new file mode 100644 index 0000000000..fe520ef19c --- /dev/null +++ b/Task/Empty-program/Java/empty-program-2.java @@ -0,0 +1,4 @@ +public class EmptyMainClass { + public static void main(String... args) { + } +} diff --git a/Task/Empty-program/Java/empty-program-3.java b/Task/Empty-program/Java/empty-program-3.java new file mode 100644 index 0000000000..ffeae32de6 --- /dev/null +++ b/Task/Empty-program/Java/empty-program-3.java @@ -0,0 +1 @@ +method(arg0, arg1, arg2, arg3) diff --git a/Task/Empty-program/Java/empty-program-4.java b/Task/Empty-program/Java/empty-program-4.java new file mode 100644 index 0000000000..aaa3c60cc5 --- /dev/null +++ b/Task/Empty-program/Java/empty-program-4.java @@ -0,0 +1,4 @@ +public class EmptyMainClass { + public static void main(String[] args) { + } +} diff --git a/Task/Empty-program/Java/empty-program-5.java b/Task/Empty-program/Java/empty-program-5.java new file mode 100644 index 0000000000..e82534ea79 --- /dev/null +++ b/Task/Empty-program/Java/empty-program-5.java @@ -0,0 +1,4 @@ +public class EmptyApplet extends java.applet.Applet { + public void init() { + } +} diff --git a/Task/Empty-program/LaTeX/empty-program.tex b/Task/Empty-program/LaTeX/empty-program.tex new file mode 100644 index 0000000000..26047ba6ac --- /dev/null +++ b/Task/Empty-program/LaTeX/empty-program.tex @@ -0,0 +1,3 @@ +\documentclass{article} +\begin{document} +\end{document} diff --git a/Task/Empty-program/Lua/empty-program.lua b/Task/Empty-program/Lua/empty-program.lua new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/MATLAB/empty-program.m b/Task/Empty-program/MATLAB/empty-program.m new file mode 100644 index 0000000000..8b86404911 --- /dev/null +++ b/Task/Empty-program/MATLAB/empty-program.m @@ -0,0 +1 @@ + function [varargout] = emptyprogram(varargin) diff --git a/Task/Empty-program/PIR/empty-program.pir b/Task/Empty-program/PIR/empty-program.pir new file mode 100644 index 0000000000..f27831f7e2 --- /dev/null +++ b/Task/Empty-program/PIR/empty-program.pir @@ -0,0 +1,2 @@ +.sub empty_program +.end diff --git a/Task/Empty-program/Perl/empty-program-1.pl b/Task/Empty-program/Perl/empty-program-1.pl new file mode 100644 index 0000000000..0dcc959fd8 --- /dev/null +++ b/Task/Empty-program/Perl/empty-program-1.pl @@ -0,0 +1,2 @@ +#!/usr/bin/perl +1; diff --git a/Task/Empty-program/Perl/empty-program-2.pl b/Task/Empty-program/Perl/empty-program-2.pl new file mode 100644 index 0000000000..cecf79c076 --- /dev/null +++ b/Task/Empty-program/Perl/empty-program-2.pl @@ -0,0 +1,2 @@ +#!/usr/bin/perl +exit; diff --git a/Task/Empty-program/Perl/empty-program-3.pl b/Task/Empty-program/Perl/empty-program-3.pl new file mode 100644 index 0000000000..57216f0412 --- /dev/null +++ b/Task/Empty-program/Perl/empty-program-3.pl @@ -0,0 +1,2 @@ +#!/usr/bin/perl +# A program without a body will work too diff --git a/Task/Empty-program/Perl/empty-program-4.pl b/Task/Empty-program/Perl/empty-program-4.pl new file mode 100644 index 0000000000..1f1c293970 --- /dev/null +++ b/Task/Empty-program/Perl/empty-program-4.pl @@ -0,0 +1 @@ +#!/usr/bin/perl diff --git a/Task/Empty-program/PicoLisp/empty-program.l b/Task/Empty-program/PicoLisp/empty-program.l new file mode 100644 index 0000000000..5741f0904f --- /dev/null +++ b/Task/Empty-program/PicoLisp/empty-program.l @@ -0,0 +1 @@ +(de foo ()) diff --git a/Task/Empty-program/REXX/empty-program-1.rexx b/Task/Empty-program/REXX/empty-program-1.rexx new file mode 100644 index 0000000000..40a8c178f1 --- /dev/null +++ b/Task/Empty-program/REXX/empty-program-1.rexx @@ -0,0 +1 @@ +/* empty */ diff --git a/Task/Empty-program/REXX/empty-program-2.rexx b/Task/Empty-program/REXX/empty-program-2.rexx new file mode 100644 index 0000000000..9d6f459ad8 --- /dev/null +++ b/Task/Empty-program/REXX/empty-program-2.rexx @@ -0,0 +1 @@ +/**/ diff --git a/Task/Empty-program/REXX/empty-program-3.rexx b/Task/Empty-program/REXX/empty-program-3.rexx new file mode 100644 index 0000000000..0bc8e7f4b9 --- /dev/null +++ b/Task/Empty-program/REXX/empty-program-3.rexx @@ -0,0 +1 @@ +/* REXX */ diff --git a/Task/Empty-program/Racket/empty-program.rkt b/Task/Empty-program/Racket/empty-program.rkt new file mode 100644 index 0000000000..6f1f7b4de3 --- /dev/null +++ b/Task/Empty-program/Racket/empty-program.rkt @@ -0,0 +1 @@ +#lang racket diff --git a/Task/Empty-program/Ruby/empty-program.rb b/Task/Empty-program/Ruby/empty-program.rb new file mode 100644 index 0000000000..49ffd26f77 --- /dev/null +++ b/Task/Empty-program/Ruby/empty-program.rb @@ -0,0 +1 @@ +#!/usr/bin/env ruby diff --git a/Task/Empty-program/Scala/empty-program.scala b/Task/Empty-program/Scala/empty-program.scala new file mode 100644 index 0000000000..dac604d3c4 --- /dev/null +++ b/Task/Empty-program/Scala/empty-program.scala @@ -0,0 +1,3 @@ +object emptyProgram { + def main(args: Array[String]) {} +} diff --git a/Task/Empty-program/Scheme/empty-program.ss b/Task/Empty-program/Scheme/empty-program.ss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Smalltalk/empty-program.st b/Task/Empty-program/Smalltalk/empty-program.st new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/Task/Empty-program/Smalltalk/empty-program.st @@ -0,0 +1 @@ +[] diff --git a/Task/Empty-program/Tcl/empty-program.tcl b/Task/Empty-program/Tcl/empty-program.tcl new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-string/0DESCRIPTION b/Task/Empty-string/0DESCRIPTION new file mode 100644 index 0000000000..633767e476 --- /dev/null +++ b/Task/Empty-string/0DESCRIPTION @@ -0,0 +1,10 @@ +Languages may have features for dealing specifically with empty strings (those containing no characters). + +The task is to: + +* Demonstrate how to assign an empty string to a variable. + +* Demonstrate how to check that a string is empty. +* Demonstrate how to check that a string is not empty. + +[[Category:String manipulation]] diff --git a/Task/Empty-string/ACL2/empty-string.acl2 b/Task/Empty-string/ACL2/empty-string.acl2 new file mode 100644 index 0000000000..8644c52bb1 --- /dev/null +++ b/Task/Empty-string/ACL2/empty-string.acl2 @@ -0,0 +1 @@ +(= (length str) 0) diff --git a/Task/Empty-string/AWK/empty-string.awk b/Task/Empty-string/AWK/empty-string.awk new file mode 100644 index 0000000000..d62f534c70 --- /dev/null +++ b/Task/Empty-string/AWK/empty-string.awk @@ -0,0 +1,16 @@ +#!/usr/bin/awk -f +BEGIN { + # Demonstrate how to assign an empty string to a variable. + a=""; + b="XYZ"; + print "a = ",a; + print "b = ",b; + print "length(a)=",length(a); + print "length(b)=",length(b); + # Demonstrate how to check that a string is empty. + print "Is a empty ?",length(a)==0; + print "Is a not empty ?",length(a)!=0; + # Demonstrate how to check that a string is not empty. + print "Is b empty ?",length(b)==0; + print "Is b not empty ?",length(b)!=0; +} diff --git a/Task/Empty-string/Ada/empty-string.ada b/Task/Empty-string/Ada/empty-string.ada new file mode 100644 index 0000000000..6371df796e --- /dev/null +++ b/Task/Empty-string/Ada/empty-string.ada @@ -0,0 +1,15 @@ +procedure Empty_String is + + function Is_Empty(S: String) return Boolean is + begin + return S = ""; -- test that S is empty + end Is_Empty; + + Empty: String := ""; -- Assign empty string + XXXXX: String := "Not Empty"; + +begin + if (not Is_Empty(Empty)) or Is_Empty(XXXXX) then + raise Program_Error with "something went wrong very very badly!!!"; + end if; +end Empty_String; diff --git a/Task/Empty-string/AutoHotkey/empty-string.ahk b/Task/Empty-string/AutoHotkey/empty-string.ahk new file mode 100644 index 0000000000..5f9c62e1eb --- /dev/null +++ b/Task/Empty-string/AutoHotkey/empty-string.ahk @@ -0,0 +1,20 @@ +;; Traditional +; Assign an empty string: +var = +; Check that a string is empty: +If var = + MsgBox the var is empty +; Check that a string is not empty +If var != + Msgbox the var is not empty + + +;; Expression mode: +; Assign an empty string: +var := "" +; Check that a string is empty: +If (var = "") + MsgBox the var is empty +; Check that a string is not empty +If (var != "") + Msgbox the var is not empty diff --git a/Task/Empty-string/BASIC/empty-string.bas b/Task/Empty-string/BASIC/empty-string.bas new file mode 100644 index 0000000000..12d6da5e6e --- /dev/null +++ b/Task/Empty-string/BASIC/empty-string.bas @@ -0,0 +1,4 @@ +10 LET A$="" +20 IF A$="" THEN PRINT "THE STRING IS EMPTY" +30 IF A$<>"" THEN PRINT "THE STRING IS NOT EMPTY" +40 END diff --git a/Task/Empty-string/BBC-BASIC/empty-string.bbc b/Task/Empty-string/BBC-BASIC/empty-string.bbc new file mode 100644 index 0000000000..1ea4761f87 --- /dev/null +++ b/Task/Empty-string/BBC-BASIC/empty-string.bbc @@ -0,0 +1,8 @@ + REM assign an empty string to a variable: + var$ = "" + + REM Check that a string is empty: + IF var$ = "" THEN PRINT "String is empty" + + REM Check that a string is not empty: + IF var$ <> "" THEN PRINT "String is not empty" diff --git a/Task/Empty-string/Bracmat/empty-string.bracmat b/Task/Empty-string/Bracmat/empty-string.bracmat new file mode 100644 index 0000000000..ad9dbd4328 --- /dev/null +++ b/Task/Empty-string/Bracmat/empty-string.bracmat @@ -0,0 +1,9 @@ +( :?a +& (b=) +& abra:?c +& (d=cadabra) +& !a: { a is empty string } +& !b: { b is also empty string } +& !c:~ { c is not an empty string } +& !d:~ { neither is d an empty string } +) diff --git a/Task/Empty-string/C++/empty-string.cpp b/Task/Empty-string/C++/empty-string.cpp new file mode 100644 index 0000000000..d0a9ebb601 --- /dev/null +++ b/Task/Empty-string/C++/empty-string.cpp @@ -0,0 +1,11 @@ +#include + +// ... + +std::string str; // a string object for an empty string + +if (str.empty()) { ... } // to test if string is empty + +// we could also use the following +if (str.length() == 0) { ... } +if (str == "") { ... } diff --git a/Task/Empty-string/C-sharp/empty-string.cs b/Task/Empty-string/C-sharp/empty-string.cs new file mode 100644 index 0000000000..a02bd0e2d1 --- /dev/null +++ b/Task/Empty-string/C-sharp/empty-string.cs @@ -0,0 +1,9 @@ +using System; + +class Program { + static void Main (string[] args) { + string example = string.Empty; + if (string.IsNullOrEmpty(example)) { } + if (!string.IsNullOrEmpty(example)) { } + } +} diff --git a/Task/Empty-string/C/empty-string.c b/Task/Empty-string/C/empty-string.c new file mode 100644 index 0000000000..4a5bc179ce --- /dev/null +++ b/Task/Empty-string/C/empty-string.c @@ -0,0 +1,10 @@ +/* assign an empty string */ +const char *str = ""; +/* to test a null string */ +if (str) { ... } +/* to test if string is empty */ +if (str[0] == '\0') { ... } +/* or equivalently use strlen function */ +if (strlen(str) == 0) { ... } +/* or compare to a known empty string, same thing. "== 0" means strings are equal */ +if (strcmp(str, "") == 0) { ... } diff --git a/Task/Empty-string/Clojure/empty-string.clj b/Task/Empty-string/Clojure/empty-string.clj new file mode 100644 index 0000000000..c1ea276b96 --- /dev/null +++ b/Task/Empty-string/Clojure/empty-string.clj @@ -0,0 +1,6 @@ +(def x "") ;x is "globally" declared to be the empty string +(let [x ""] + ;x is bound to the empty string within the let + ) +(= x "") ;true if x is the empty string +(not= x "") ;true if x is not the empty string diff --git a/Task/Empty-string/CoffeeScript/empty-string.coffee b/Task/Empty-string/CoffeeScript/empty-string.coffee new file mode 100644 index 0000000000..5c5ae7e09e --- /dev/null +++ b/Task/Empty-string/CoffeeScript/empty-string.coffee @@ -0,0 +1,12 @@ +isEmptyString = (s) -> + # Returns true iff s is an empty string. + # (This returns false for non-strings as well.) + return true if s instanceof String and s.length == 0 + s == '' + +empties = ["", '', new String()] +non_empties = [new String('yo'), 'foo', {}] +console.log (isEmptyString(v) for v in empties) # [true, true, true] +console.log (isEmptyString(v) for v in non_empties) # [false, false, false] +console.log (s = '') == "" # true +console.log new String() == '' # false, due to underlying JavaScript's distinction between objects and primitives diff --git a/Task/Empty-string/Common-Lisp/empty-string.lisp b/Task/Empty-string/Common-Lisp/empty-string.lisp new file mode 100644 index 0000000000..c80c2bfc81 --- /dev/null +++ b/Task/Empty-string/Common-Lisp/empty-string.lisp @@ -0,0 +1,4 @@ +(defparameter *s* "") ;; Binds dynamic variable *S* to the empty string "" +(let ((s "")) ;; Binds the lexical variable S to the empty string "" + (= (length s) 0) ;; Check if the string is empty + (> (length s) 0)) ;; Check if length of string is over 0 (that is: non-empty) diff --git a/Task/Empty-string/D/empty-string.d b/Task/Empty-string/D/empty-string.d new file mode 100644 index 0000000000..056e4e44cc --- /dev/null +++ b/Task/Empty-string/D/empty-string.d @@ -0,0 +1,27 @@ +import std.array; + +bool isEmptyNotNull(in string s) pure nothrow @safe { + return s is ""; +} + +void main(){ + string s1 = null; + string s2 = ""; + + // the content is the same + assert(!s1.length); + assert(!s2.length); + assert(s1 == "" && s1 == null); + assert(s2 == "" && s2 == null); + assert(s1 == s2); + + // but they don't point to the same memory region + assert(s1 is null && s1 !is ""); + assert(s2 is "" && s2 !is null); + assert(s1 !is s2); + assert(s1.ptr == null); + assert(*s2.ptr == '\0'); // D string literals are \0 terminated + + assert(s1.empty); + assert(s2.isEmptyNotNull()); +} diff --git a/Task/Empty-string/DWScript/empty-string.dwscript b/Task/Empty-string/DWScript/empty-string.dwscript new file mode 100644 index 0000000000..f942faa25d --- /dev/null +++ b/Task/Empty-string/DWScript/empty-string.dwscript @@ -0,0 +1,11 @@ +var s : String; + +s := ''; // assign an empty string (can also use "") + +if s = '' then + PrintLn('empty'); + +s := 'hello'; + +if s <> '' then + PrintLn('not empty'); diff --git a/Task/Empty-string/Delphi/empty-string.delphi b/Task/Empty-string/Delphi/empty-string.delphi new file mode 100644 index 0000000000..8c35e243b2 --- /dev/null +++ b/Task/Empty-string/Delphi/empty-string.delphi @@ -0,0 +1,20 @@ +program EmptyString; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +function StringIsEmpty(const aString: string): Boolean; +begin + Result := aString = ''; +end; + +var + s: string; +begin + s := ''; + Writeln(StringIsEmpty(s)); // True + + s := 'abc'; + Writeln(StringIsEmpty(s)); // False +end. diff --git a/Task/Empty-string/Erlang/empty-string.erl b/Task/Empty-string/Erlang/empty-string.erl new file mode 100644 index 0000000000..060a39d0f9 --- /dev/null +++ b/Task/Empty-string/Erlang/empty-string.erl @@ -0,0 +1,8 @@ +1> S = "". % erlang strings are actually lists, so the empty string is the same as the empty list []. +[] +2> length(S). +0 +3> case S of [] -> empty; [H|T] -> not_empty end. +empty +4> case "aoeu" of [] -> empty; [H|T] -> not_empty end. +not_empty diff --git a/Task/Empty-string/Euphoria/empty-string.euphoria b/Task/Empty-string/Euphoria/empty-string.euphoria new file mode 100644 index 0000000000..3fbd3a6bdc --- /dev/null +++ b/Task/Empty-string/Euphoria/empty-string.euphoria @@ -0,0 +1,15 @@ +sequence s + +-- assign an empty string +s = "" + +-- another way to assign an empty string +s = {} -- "" and {} are equivalent + +if not length(s) then + -- string is empty +end if + +if length(s) then + -- string is not empty +end if diff --git a/Task/Empty-string/Forth/empty-string.fth b/Task/Empty-string/Forth/empty-string.fth new file mode 100644 index 0000000000..e7dbbac5bb --- /dev/null +++ b/Task/Empty-string/Forth/empty-string.fth @@ -0,0 +1,3 @@ +: empty? ( c-addr u -- ? ) nip 0= ; + +s" " dup . empty? . \ 0 -1 diff --git a/Task/Empty-string/Go/empty-string.go b/Task/Empty-string/Go/empty-string.go new file mode 100644 index 0000000000..0f9f6f7541 --- /dev/null +++ b/Task/Empty-string/Go/empty-string.go @@ -0,0 +1,8 @@ +// assign empty string to a variable +s = "" + +// check that string is empty +s == "" + +// check that string is not empty +s > "" diff --git a/Task/Empty-string/Haskell/empty-string.hs b/Task/Empty-string/Haskell/empty-string.hs new file mode 100644 index 0000000000..4e504b697c --- /dev/null +++ b/Task/Empty-string/Haskell/empty-string.hs @@ -0,0 +1,10 @@ +import Control.Monad + +-- In Haskell strings are just lists (of characters), so we can use the function +-- 'null', which applies to all lists. We don't want to use the length, since +-- Haskell allows infinite lists. + +main = do + let s = "" + when (null s) (putStrLn "Empty.") + when (not $ null s) (putStrLn "Not empty.") diff --git a/Task/Empty-string/Java/empty-string.java b/Task/Empty-string/Java/empty-string.java new file mode 100644 index 0000000000..62f711746e --- /dev/null +++ b/Task/Empty-string/Java/empty-string.java @@ -0,0 +1,6 @@ +String s = ""; +if(s != null && s.isEmpty()){//optionally, instead of "s.isEmpty()": "s.length() == 0" or "s.equals("")" + System.out.println("s is empty"); +}else{ + System.out.println("s is not empty"); +} diff --git a/Task/Empty-string/Lua/empty-string.lua b/Task/Empty-string/Lua/empty-string.lua new file mode 100644 index 0000000000..151c97cfa1 --- /dev/null +++ b/Task/Empty-string/Lua/empty-string.lua @@ -0,0 +1,11 @@ +str = "" -- create empty string + +-- test for empty string +if str == "" then + print "The string is empty" +end + +-- test for nonempty string +if str ~= "" then + print "The string is not empty" +end diff --git a/Task/Empty-string/MATLAB/empty-string.m b/Task/Empty-string/MATLAB/empty-string.m new file mode 100644 index 0000000000..8213f7fbd9 --- /dev/null +++ b/Task/Empty-string/MATLAB/empty-string.m @@ -0,0 +1,8 @@ + % Demonstrate how to assign an empty string to a variable. + str = ''; + % Demonstrate how to check that a string is empty. + isempty(str) + (length(str)==0) + % Demonstrate how to check that a string is not empty. + ~isempty(str) + (length(str)>0) diff --git a/Task/Empty-string/PHP/empty-string.php b/Task/Empty-string/PHP/empty-string.php new file mode 100644 index 0000000000..1f9c50a078 --- /dev/null +++ b/Task/Empty-string/PHP/empty-string.php @@ -0,0 +1,16 @@ + 0) cat('Not empty\n') diff --git a/Task/Empty-string/REXX/empty-string.rexx b/Task/Empty-string/REXX/empty-string.rexx new file mode 100644 index 0000000000..69cbc1a417 --- /dev/null +++ b/Task/Empty-string/REXX/empty-string.rexx @@ -0,0 +1,40 @@ +/*REXX: how to assign an empty string & then check for empty/not-empty.*/ + +/*─────────────── 3 simple wats to assign an empty string to a variable.*/ +auk='' /*uses two single quotes or apostrophies. */ +ide="" /*uses two quotes, sometimes called a double quote.*/ +doe= /*... nothing at all. */ + +/*─────────────── assigning multiple null values to vars, 2 methods are:*/ +ram=0 +parse var ram . emu pug yak nit moa owl pas jay koi ern ewe fae gar hob + /*where the value of zero is skipped, the rest set to null,*/ + /*which is the next value AFTER the value of RAM (nothing).*/ + + /*───or─── (with less clutter ─── or more, ... perception).*/ +parse value 0 with . ant ape ant imp fly tui paa elo dab cub bat ayu + /*where the value of zero is skipped, the rest set to null,*/ + /*which is the next value AFTER the 0 (zero): nothing. */ + +/*─────────────── how to check that a string is empty, several methods: */ +if cat=='' then say "the feline is not here." +if pig=="" then say 'no ham today' +if length(gnu)==0 then say "the wildebeast is empty & hungry." +if length(ips)=0 then say "checking with == instead of = is faster" +if length(hub)<1 then method = "obtuse, don't do as I do ..." + +nit='' /*assign an empty string to a lice egg.*/ +if cow==nit then say 'the cow has no milk today.' + +/*─────────────── how to check that a string isn't empty, several ways: */ +if dog\=='' then say "the dogs are out!" + /*most REXXes support the "not" character. */ +if fox¬=='' then say "and the fox is in the henhouse." +if length(rat)>0 then say "the rat is singing" /*ugly way to test.*/ + +if elk=='' then nop; else say "long way for an elk to be tested." + +if length(eel)\==0 then fish=eel /*fast compare, quick.*/ +if length(cod)\=0 then fish=cod /*not-so-fast compare.*/ + +/*────────────────────────── anyway, as they say: "choose your poison." */ diff --git a/Task/Empty-string/Racket/empty-string.rkt b/Task/Empty-string/Racket/empty-string.rkt new file mode 100644 index 0000000000..0a653c7bef --- /dev/null +++ b/Task/Empty-string/Racket/empty-string.rkt @@ -0,0 +1,5 @@ +#lang racket + +(define empty-string "") +(define (string-null? s) (string=? "" s)) +(define (string-not-null? s) (string 0 +s[/./m] diff --git a/Task/Empty-string/Ruby/empty-string-4.rb b/Task/Empty-string/Ruby/empty-string-4.rb new file mode 100644 index 0000000000..8b8cfc945c --- /dev/null +++ b/Task/Empty-string/Ruby/empty-string-4.rb @@ -0,0 +1 @@ +if s then puts "not empty" end # This code is wrong! diff --git a/Task/Empty-string/Scala/empty-string.scala b/Task/Empty-string/Scala/empty-string.scala new file mode 100644 index 0000000000..2e92099b18 --- /dev/null +++ b/Task/Empty-string/Scala/empty-string.scala @@ -0,0 +1,10 @@ +// assign empty string to a variable +val s="" +// check that string is empty +s.isEmpty // true +s=="" // true +s.size==0 // true +// check that string is not empty +s.nonEmpty // false +s!="" // false +s.size>0 // false diff --git a/Task/Empty-string/Scheme/empty-string.ss b/Task/Empty-string/Scheme/empty-string.ss new file mode 100644 index 0000000000..e57161dd22 --- /dev/null +++ b/Task/Empty-string/Scheme/empty-string.ss @@ -0,0 +1,3 @@ +(define empty-string "") +(define (string-null? s) (string=? "" s)) +(define (string-not-null? s) (string diff --git a/Task/Enforced-immutability/ACL2/enforced-immutability.acl2 b/Task/Enforced-immutability/ACL2/enforced-immutability.acl2 new file mode 100644 index 0000000000..461896ed85 --- /dev/null +++ b/Task/Enforced-immutability/ACL2/enforced-immutability.acl2 @@ -0,0 +1 @@ +(defconst *pi-approx* 22/7) diff --git a/Task/Enforced-immutability/ALGOL-68/enforced-immutability.alg b/Task/Enforced-immutability/ALGOL-68/enforced-immutability.alg new file mode 100644 index 0000000000..3c0597e061 --- /dev/null +++ b/Task/Enforced-immutability/ALGOL-68/enforced-immutability.alg @@ -0,0 +1,4 @@ +INT max allowed = 20; +REAL pi = 3.1415 9265; # pi is constant that the compiler will enforce # +REF REAL var = LOC REAL; # var is a constant pointer to a local REAL address # +var := pi # constant pointer var has the REAL value referenced assigned pi # diff --git a/Task/Enforced-immutability/Ada/enforced-immutability.ada b/Task/Enforced-immutability/Ada/enforced-immutability.ada new file mode 100644 index 0000000000..e8dc2be0d7 --- /dev/null +++ b/Task/Enforced-immutability/Ada/enforced-immutability.ada @@ -0,0 +1,2 @@ +Foo : constant := 42; +Foo : constant Blahtype := Blahvalue; diff --git a/Task/Enforced-immutability/AutoHotkey/enforced-immutability.ahk b/Task/Enforced-immutability/AutoHotkey/enforced-immutability.ahk new file mode 100644 index 0000000000..d3f61f1aca --- /dev/null +++ b/Task/Enforced-immutability/AutoHotkey/enforced-immutability.ahk @@ -0,0 +1,23 @@ +MyData := new FinalBox("Immutable data") +MsgBox % "MyData.Data = " MyData.Data +MyData.Data := "This will fail to set" +MsgBox % "MyData.Data = " MyData.Data + +Class FinalBox { + __New(FinalValue) { + ObjInsert(this, "proxy",{Data:FinalValue}) + } +; override the built-in methods: + __Get(k) { + return, this["proxy",k] + } + __Set(p*) { + return + } + Insert(p*) { + return + } + Remove(p*) { + return + } +} diff --git a/Task/Enforced-immutability/BASIC/enforced-immutability-1.bas b/Task/Enforced-immutability/BASIC/enforced-immutability-1.bas new file mode 100644 index 0000000000..e9f50032f5 --- /dev/null +++ b/Task/Enforced-immutability/BASIC/enforced-immutability-1.bas @@ -0,0 +1 @@ +CONST x = 1 diff --git a/Task/Enforced-immutability/BASIC/enforced-immutability-2.bas b/Task/Enforced-immutability/BASIC/enforced-immutability-2.bas new file mode 100644 index 0000000000..96839ba126 --- /dev/null +++ b/Task/Enforced-immutability/BASIC/enforced-immutability-2.bas @@ -0,0 +1 @@ +#define x 1 diff --git a/Task/Enforced-immutability/BBC-BASIC/enforced-immutability.bbc b/Task/Enforced-immutability/BBC-BASIC/enforced-immutability.bbc new file mode 100644 index 0000000000..d08f0b4b7e --- /dev/null +++ b/Task/Enforced-immutability/BBC-BASIC/enforced-immutability.bbc @@ -0,0 +1,3 @@ + DEF FNconst = 2.71828182845905 + PRINT FNconst + FNconst = 1.234 : REM Reports 'Syntax error' diff --git a/Task/Enforced-immutability/C++/enforced-immutability-1.cpp b/Task/Enforced-immutability/C++/enforced-immutability-1.cpp new file mode 100644 index 0000000000..549670c6c3 --- /dev/null +++ b/Task/Enforced-immutability/C++/enforced-immutability-1.cpp @@ -0,0 +1,22 @@ +#include + +class MyOtherClass +{ +public: + const int m_x; + MyOtherClass(const int initX = 0) : m_x(initX) { } + +}; + +int main() +{ + MyOtherClass mocA, mocB(7); + + std::cout << mocA.m_x << std::endl; // displays 0, the default value given for MyOtherClass's constructor. + std::cout << mocB.m_x << std::endl; // displays 7, the value we provided for the constructor for mocB. + + // Uncomment this, and the compile will fail; m_x is a const member. + // mocB.m_x = 99; + + return 0; +} diff --git a/Task/Enforced-immutability/C++/enforced-immutability-2.cpp b/Task/Enforced-immutability/C++/enforced-immutability-2.cpp new file mode 100644 index 0000000000..a7d4af2f31 --- /dev/null +++ b/Task/Enforced-immutability/C++/enforced-immutability-2.cpp @@ -0,0 +1,11 @@ +class MyClass +{ +private: + int x; + +public: + int getX() const + { + return x; + } +}; diff --git a/Task/Enforced-immutability/C/enforced-immutability-1.c b/Task/Enforced-immutability/C/enforced-immutability-1.c new file mode 100644 index 0000000000..f31d3a4cf7 --- /dev/null +++ b/Task/Enforced-immutability/C/enforced-immutability-1.c @@ -0,0 +1,3 @@ +#define PI 3.14159265358979323 +#define MINSIZE 10 +#define MAXSIZE 100 diff --git a/Task/Enforced-immutability/C/enforced-immutability-2.c b/Task/Enforced-immutability/C/enforced-immutability-2.c new file mode 100644 index 0000000000..9e0bbdc398 --- /dev/null +++ b/Task/Enforced-immutability/C/enforced-immutability-2.c @@ -0,0 +1,19 @@ +const char foo = 'a'; +const double pi = 3.14159; +const double minsize = 10; +const double maxsize = 10; + +// On pointers +const int * ptrToConst; // The value is constant, but the pointer may change. +int const * ptrToConst; // The value is constant, but the pointer may change. (Identical to the above.) +int * const constPtr; // The pointer is constant, but the value may change. +int const * const constPtrToConst; // Both the pointer and value are constant. + +// On parameters +int main(const int argc, // note that here, the "const", applied to the integer argument itself, + // is kind of pointless, as arguments are passed by value, so + // it does not affect any code outside of the function + const char** argv) +{ + /* ... */ +} diff --git a/Task/Enforced-immutability/Clojure/enforced-immutability.clj b/Task/Enforced-immutability/Clojure/enforced-immutability.clj new file mode 100644 index 0000000000..183211c2ff --- /dev/null +++ b/Task/Enforced-immutability/Clojure/enforced-immutability.clj @@ -0,0 +1,6 @@ +user> (def d [1 2 3 4 5]) ; immutable vector +#'user/d +user> (assoc d 3 7) +[1 2 3 7 5] +user> d +[1 2 3 4 5] diff --git a/Task/Enforced-immutability/D/enforced-immutability.d b/Task/Enforced-immutability/D/enforced-immutability.d new file mode 100644 index 0000000000..bdca425738 --- /dev/null +++ b/Task/Enforced-immutability/D/enforced-immutability.d @@ -0,0 +1,67 @@ +import std.random; + +// enum allows to define manifest (compile-time) constants: +int sqr(int x) { return x ^^ 2; } +enum int x = 5; +enum y = sqr(5); // Forces Compile-Time Function Evaluation (CTFE). + +// enums are compile-time constants: +enum MyEnum { A, B, C } + + +// immutable defines values that can't change: +immutable double pi = 3.1415; + + +// A module-level immutable storage class variable that's not +// explicitly initialized can be initialized by its constructor, +// otherwise its value is the default initializer during its life-time. + +immutable int z; + +static this() { + z = uniform(0, 100); // Run-time inizialization. +} + +class Test1 { + immutable int w; + + this() { + w = uniform(0, 100); // Run-time inizialization. + } +} + + +// The items array can't be immutable here. +// "in" is short for "const scope": +void foo(const scope int[] items) { + // items is constant here. + // items[0] = 100; // Cannot modify const expression. +} + + +struct Test2 { + int x_; // Mutable. + @property int x() { return this.x_; } +} + +// Unlike C++, D const and immutable are transitive. +// And there is also "inout". See D docs. + +void main() { + int[] data = [10, 20, 30]; + foo(data); + data[0] = 100; // But data is mutable here. + + // Currently manifest constants like arrays and associative arrays + // are copied in-place every time they are used: + enum array = [1, 2, 3]; + foo(array); + + auto t = Test2(100); + auto x2 = t.x; // Reading x is allowed. + assert(x2 == 100); + + // Not allowed, the setter property is missing: + // t.x = 10; // Error: not a property t.x +} diff --git a/Task/Enforced-immutability/Delphi/enforced-immutability.delphi b/Task/Enforced-immutability/Delphi/enforced-immutability.delphi new file mode 100644 index 0000000000..cbf422c8af --- /dev/null +++ b/Task/Enforced-immutability/Delphi/enforced-immutability.delphi @@ -0,0 +1,3 @@ +const + STR1 = 'abc'; // regular constant + STR2: string = 'def'; // typed constant diff --git a/Task/Enforced-immutability/E/enforced-immutability-1.e b/Task/Enforced-immutability/E/enforced-immutability-1.e new file mode 100644 index 0000000000..6fc30b4f7e --- /dev/null +++ b/Task/Enforced-immutability/E/enforced-immutability-1.e @@ -0,0 +1,3 @@ +def x := 1 + +x := 2 # this is an error diff --git a/Task/Enforced-immutability/E/enforced-immutability-2.e b/Task/Enforced-immutability/E/enforced-immutability-2.e new file mode 100644 index 0000000000..455c76c1c1 --- /dev/null +++ b/Task/Enforced-immutability/E/enforced-immutability-2.e @@ -0,0 +1,5 @@ +var y := 1 + +def things :DeepFrozen := [&x, 2, 3] # This is OK + +def funnyThings :DeepFrozen := [&y, 2, 3] # Error: y's slot is not immutable diff --git a/Task/Enforced-immutability/Ela/enforced-immutability-1.ela b/Task/Enforced-immutability/Ela/enforced-immutability-1.ela new file mode 100644 index 0000000000..3f0e72d0a2 --- /dev/null +++ b/Task/Enforced-immutability/Ela/enforced-immutability-1.ela @@ -0,0 +1,2 @@ +open cell +r = ref 0 diff --git a/Task/Enforced-immutability/Ela/enforced-immutability-2.ela b/Task/Enforced-immutability/Ela/enforced-immutability-2.ela new file mode 100644 index 0000000000..e22da4fde8 --- /dev/null +++ b/Task/Enforced-immutability/Ela/enforced-immutability-2.ela @@ -0,0 +1 @@ +mutate r 1 diff --git a/Task/Enforced-immutability/Ela/enforced-immutability-3.ela b/Task/Enforced-immutability/Ela/enforced-immutability-3.ela new file mode 100644 index 0000000000..3142b0db05 --- /dev/null +++ b/Task/Enforced-immutability/Ela/enforced-immutability-3.ela @@ -0,0 +1 @@ +valueof r diff --git a/Task/Enforced-immutability/Erlang/enforced-immutability-1.erl b/Task/Enforced-immutability/Erlang/enforced-immutability-1.erl new file mode 100644 index 0000000000..3f69e14888 --- /dev/null +++ b/Task/Enforced-immutability/Erlang/enforced-immutability-1.erl @@ -0,0 +1,2 @@ +X = 10, +X = 20. diff --git a/Task/Enforced-immutability/Erlang/enforced-immutability-2.erl b/Task/Enforced-immutability/Erlang/enforced-immutability-2.erl new file mode 100644 index 0000000000..93c9c11bdb --- /dev/null +++ b/Task/Enforced-immutability/Erlang/enforced-immutability-2.erl @@ -0,0 +1,2 @@ +X = 10, +X = 10. diff --git a/Task/Enforced-immutability/Euphoria/enforced-immutability.euphoria b/Task/Enforced-immutability/Euphoria/enforced-immutability.euphoria new file mode 100644 index 0000000000..4cf5113cb5 --- /dev/null +++ b/Task/Enforced-immutability/Euphoria/enforced-immutability.euphoria @@ -0,0 +1,3 @@ +constant n = 1 +constant s = {1,2,3} +constant str = "immutable string" diff --git a/Task/Enforced-immutability/Go/enforced-immutability.go b/Task/Enforced-immutability/Go/enforced-immutability.go new file mode 100644 index 0000000000..8d172b40d2 --- /dev/null +++ b/Task/Enforced-immutability/Go/enforced-immutability.go @@ -0,0 +1,6 @@ +package main + +func main() { + s := "immutable" + s[0] = 'a' +} diff --git a/Task/Enforced-immutability/Haskell/enforced-immutability.hs b/Task/Enforced-immutability/Haskell/enforced-immutability.hs new file mode 100644 index 0000000000..3b815c04a2 --- /dev/null +++ b/Task/Enforced-immutability/Haskell/enforced-immutability.hs @@ -0,0 +1,2 @@ +pi = 3.14159 +msg = "Hello World" diff --git a/Task/Enforced-immutability/Java/enforced-immutability-1.java b/Task/Enforced-immutability/Java/enforced-immutability-1.java new file mode 100644 index 0000000000..a35e258ecf --- /dev/null +++ b/Task/Enforced-immutability/Java/enforced-immutability-1.java @@ -0,0 +1,4 @@ +final int immutableInt = 4; +int mutableInt = 4; +mutableInt = 6; //this is fine +immutableInt = 6; //this is an error diff --git a/Task/Enforced-immutability/Java/enforced-immutability-2.java b/Task/Enforced-immutability/Java/enforced-immutability-2.java new file mode 100644 index 0000000000..0cc2424754 --- /dev/null +++ b/Task/Enforced-immutability/Java/enforced-immutability-2.java @@ -0,0 +1,5 @@ +final String immutableString = "test"; +immutableString = new String("anotherTest"); //this is an error +final StringBuffer immutableBuffer = new StringBuffer(); +immutableBuffer.append("a"); //this is fine and it changes the state of the object +immutableBuffer = new StringBuffer("a"); //this is an error diff --git a/Task/Enforced-immutability/Java/enforced-immutability-3.java b/Task/Enforced-immutability/Java/enforced-immutability-3.java new file mode 100644 index 0000000000..f63bb79639 --- /dev/null +++ b/Task/Enforced-immutability/Java/enforced-immutability-3.java @@ -0,0 +1,25 @@ +public class Immute{ + private final int num; + private final String word; + private final StringBuffer buff; //still mutable inside this class, but there is no access outside this class + + public Immute(int num){ + this.num = num; + word = num + ""; + buff = new StringBuffer("test" + word); + } + + public int getNum(){ + return num; + } + + public String getWord(){ + return word; //String objects are immutable so passing the object back directly won't harm anything + } + + public StringBuffer getBuff(){ + return new StringBuffer(buff); + //using "return buff" here compromises immutability, but copying the object via the constructor makes it ok + } + //no "set" methods are given +} diff --git a/Task/Enforced-immutability/JavaScript/enforced-immutability.js b/Task/Enforced-immutability/JavaScript/enforced-immutability.js new file mode 100644 index 0000000000..cc808e8939 --- /dev/null +++ b/Task/Enforced-immutability/JavaScript/enforced-immutability.js @@ -0,0 +1,2 @@ +const pi = 3.1415; +const msg = "Hello World"; diff --git a/Task/Enforced-immutability/PHP/enforced-immutability-1.php b/Task/Enforced-immutability/PHP/enforced-immutability-1.php new file mode 100644 index 0000000000..351c46b33a --- /dev/null +++ b/Task/Enforced-immutability/PHP/enforced-immutability-1.php @@ -0,0 +1,2 @@ +define("PI", 3.14159265358); +define("MSG", "Hello World"); diff --git a/Task/Enforced-immutability/PHP/enforced-immutability-2.php b/Task/Enforced-immutability/PHP/enforced-immutability-2.php new file mode 100644 index 0000000000..cd799a6eca --- /dev/null +++ b/Task/Enforced-immutability/PHP/enforced-immutability-2.php @@ -0,0 +1,2 @@ +const PI = 3.14159265358; +const MSG = "Hello World"; diff --git a/Task/Enforced-immutability/Perl/enforced-immutability-1.pl b/Task/Enforced-immutability/Perl/enforced-immutability-1.pl new file mode 100644 index 0000000000..05ae52b780 --- /dev/null +++ b/Task/Enforced-immutability/Perl/enforced-immutability-1.pl @@ -0,0 +1,2 @@ +use constant PI => 3.14159; +use constant MSG => "Hello World"; diff --git a/Task/Enforced-immutability/Perl/enforced-immutability-2.pl b/Task/Enforced-immutability/Perl/enforced-immutability-2.pl new file mode 100644 index 0000000000..e9f989dbba --- /dev/null +++ b/Task/Enforced-immutability/Perl/enforced-immutability-2.pl @@ -0,0 +1,11 @@ +use Readonly; + +Readonly::Scalar my $pi => 3.14159; +Readonly::Scalar my $msg => "Hello World"; + +Readonly::Array my @arr => (1, 2, 3, 4, 5); +Readonly::Hash my %hash => ( + "a" => 1, + "b" => 2, + "c" => 3 +); diff --git a/Task/Enforced-immutability/PicoLisp/enforced-immutability-1.l b/Task/Enforced-immutability/PicoLisp/enforced-immutability-1.l new file mode 100644 index 0000000000..1daddfd555 --- /dev/null +++ b/Task/Enforced-immutability/PicoLisp/enforced-immutability-1.l @@ -0,0 +1,5 @@ +: (de pi () 4) +-> pi + +: (pi) +-> 4 diff --git a/Task/Enforced-immutability/PicoLisp/enforced-immutability-2.l b/Task/Enforced-immutability/PicoLisp/enforced-immutability-2.l new file mode 100644 index 0000000000..a8c4c3de8a --- /dev/null +++ b/Task/Enforced-immutability/PicoLisp/enforced-immutability-2.l @@ -0,0 +1,5 @@ +: (set (cdr pi) 3) +-> 3 + +: (pi) +-> 3 diff --git a/Task/Enforced-immutability/Python/enforced-immutability-1.py b/Task/Enforced-immutability/Python/enforced-immutability-1.py new file mode 100644 index 0000000000..0715eea0c6 --- /dev/null +++ b/Task/Enforced-immutability/Python/enforced-immutability-1.py @@ -0,0 +1,7 @@ +>>> s = "Hello" +>>> s[0] = "h" + +Traceback (most recent call last): + File "", line 1, in + s[0] = "h" +TypeError: 'str' object does not support item assignment diff --git a/Task/Enforced-immutability/Python/enforced-immutability-2.py b/Task/Enforced-immutability/Python/enforced-immutability-2.py new file mode 100644 index 0000000000..b51e957539 --- /dev/null +++ b/Task/Enforced-immutability/Python/enforced-immutability-2.py @@ -0,0 +1,26 @@ +>>> class Immut(object): + def __setattr__(self, *args): + raise TypeError( + "'Immut' object does not support item assignment") + + __delattr__ = __setattr__ + + def __repr__(self): + return str(self.value) + + def __init__(self, value): + # assign to the un-assignable the hard way. + super(Immut, self).__setattr__("value", value) + +>>> im = Immut(123) +>>> im +123 +>>> im.value = 124 + +Traceback (most recent call last): + File "", line 1, in + del a.value + File "", line 4, in __setattr__ + "'Immut' object does not support item assignment") +TypeError: 'Immut' object does not support item assignment +>>> diff --git a/Task/Enforced-immutability/Ruby/enforced-immutability.rb b/Task/Enforced-immutability/Ruby/enforced-immutability.rb new file mode 100644 index 0000000000..ef80ed163b --- /dev/null +++ b/Task/Enforced-immutability/Ruby/enforced-immutability.rb @@ -0,0 +1,2 @@ +msg = "Hello World" +msg.freeze diff --git a/Task/Enforced-immutability/Scala/enforced-immutability.scala b/Task/Enforced-immutability/Scala/enforced-immutability.scala new file mode 100644 index 0000000000..48b04bf3b1 --- /dev/null +++ b/Task/Enforced-immutability/Scala/enforced-immutability.scala @@ -0,0 +1,2 @@ +val pi = 3.14159 +val msg = "Hello World" diff --git a/Task/Enforced-immutability/Tcl/enforced-immutability-1.tcl b/Task/Enforced-immutability/Tcl/enforced-immutability-1.tcl new file mode 100644 index 0000000000..831a608bfa --- /dev/null +++ b/Task/Enforced-immutability/Tcl/enforced-immutability-1.tcl @@ -0,0 +1,10 @@ +proc constant {varName {value ""}} { + upvar 1 $varName var + # Allow application of immutability to an existing variable, e.g., a procedure argument + if {[llength [info frame 0]] == 2} {set value $var} else {set var $value} + trace add variable var write [list apply {{val v1 v2 op} { + upvar 1 $v1 var + set var $val; # Restore to what it should be + return -code error "immutable" + }} $value] +} diff --git a/Task/Enforced-immutability/Tcl/enforced-immutability-2.tcl b/Task/Enforced-immutability/Tcl/enforced-immutability-2.tcl new file mode 100644 index 0000000000..c11599e262 --- /dev/null +++ b/Task/Enforced-immutability/Tcl/enforced-immutability-2.tcl @@ -0,0 +1,7 @@ +% constant pi 3.14159 +% puts "pi=$pi" +pi=3.14159 +% set pi 3; # Only in Indiana :-) +can't set "pi": immutable +% puts "pi is still $pi" +pi is still 3.14159 diff --git a/Task/Entropy/D/entropy.d b/Task/Entropy/D/entropy.d new file mode 100644 index 0000000000..b65b725195 --- /dev/null +++ b/Task/Entropy/D/entropy.d @@ -0,0 +1,15 @@ +import std.stdio, std.algorithm, std.math; + +double entropy(T)(T[] s) +/*pure nothrow*/ if (__traits(compiles, sort(s))) { + return s + .sort() + .group + .map!(g => g[1] / cast(double)s.length) + .map!(p => -p * log2(p)) + .reduce!q{a + b}; +} + +void main() { + "1223334444"d.dup.entropy.writeln; +} diff --git a/Task/Entropy/Euler-Math-Toolbox/entropy.euler b/Task/Entropy/Euler-Math-Toolbox/entropy.euler new file mode 100644 index 0000000000..75a740c5d6 --- /dev/null +++ b/Task/Entropy/Euler-Math-Toolbox/entropy.euler @@ -0,0 +1,8 @@ +>function entropy (s) ... +$ v=strtochar(s); +$ m=getmultiplicities(unique(v),v); +$ m=m/sum(m); +$ return sum(-m*logbase(m,2)) +$endfunction +>entropy("1223334444") + 1.84643934467 diff --git a/Task/Enumerations/0DESCRIPTION b/Task/Enumerations/0DESCRIPTION new file mode 100644 index 0000000000..061c6929e9 --- /dev/null +++ b/Task/Enumerations/0DESCRIPTION @@ -0,0 +1 @@ +Create an enumeration of constants with and without explicit values. diff --git a/Task/Enumerations/1META.yaml b/Task/Enumerations/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Enumerations/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Enumerations/ACL2/enumerations.acl2 b/Task/Enumerations/ACL2/enumerations.acl2 new file mode 100644 index 0000000000..2d36c3fb9a --- /dev/null +++ b/Task/Enumerations/ACL2/enumerations.acl2 @@ -0,0 +1,22 @@ +(defun symbol-to-constant (sym) + (intern (concatenate 'string "*" (symbol-name sym) "*") + "ACL2")) + +(defmacro enum-with-vals (symbol value &rest args) + (if (endp args) + `(defconst ,(symbol-to-constant symbol) ,value) + `(progn (defconst ,(symbol-to-constant symbol) ,value) + (enum-with-vals ,@args)))) + +(defun interleave-with-nats-r (xs i) + (if (endp xs) + nil + (cons (first xs) + (cons i (interleave-with-nats-r (rest xs) + (1+ i)))))) + +(defun interleave-with-nats (xs) + (interleave-with-nats-r xs 0)) + +(defmacro enum (&rest symbols) + `(enum-with-vals ,@(interleave-with-nats symbols))) diff --git a/Task/Enumerations/ALGOL-68/enumerations-1.alg b/Task/Enumerations/ALGOL-68/enumerations-1.alg new file mode 100644 index 0000000000..d91b64237e --- /dev/null +++ b/Task/Enumerations/ALGOL-68/enumerations-1.alg @@ -0,0 +1,13 @@ +BEGIN # example 1 # + MODE FRUIT = INT; + FRUIT apple = 1, banana = 2, cherry = 4; + FRUIT x := cherry; + CASE x IN + print(("It is an apple #",x, new line)), + print(("It is a banana #",x, new line)), + SKIP, # 3 not defined # + print(("It is a cherry #",x, new line)) + OUT + SKIP # other values # + ESAC +END; diff --git a/Task/Enumerations/ALGOL-68/enumerations-2.alg b/Task/Enumerations/ALGOL-68/enumerations-2.alg new file mode 100644 index 0000000000..ca7fa5463a --- /dev/null +++ b/Task/Enumerations/ALGOL-68/enumerations-2.alg @@ -0,0 +1,24 @@ +BEGIN # example 2 # + MODE ENUM = [0]CHAR; # something with minimal size # + MODE APPLE = STRUCT(ENUM apple), BANANA = STRUCT(ENUM banana), CHERRY = STRUCT(ENUM cherry); + MODE FRUIT = UNION(APPLE, BANANA, CHERRY); + + OP REPR = (FRUIT f)STRING: + CASE f IN + (APPLE):"Apple", + (BANANA):"Banana", + (CHERRY):"Cherry" + OUT + "?" # uninitalised # + ESAC; + + FRUIT x := LOC CHERRY; + + CASE x IN + (APPLE):print(("It is an ",REPR x, new line)), + (BANANA):print(("It is a ",REPR x, new line)), + (CHERRY):print(("It is a ",REPR x, new line)) + OUT + SKIP # uninitialised FRUIT # + ESAC +END diff --git a/Task/Enumerations/AWK/enumerations.awk b/Task/Enumerations/AWK/enumerations.awk new file mode 100644 index 0000000000..b7458e10d4 --- /dev/null +++ b/Task/Enumerations/AWK/enumerations.awk @@ -0,0 +1,3 @@ +fruit["apple"]=1; fruit["banana"]=2; fruit["cherry"]=3 +fruit[1]="apple"; fruit[2]="banana"; fruit[3]="cherry" +i=0; apple=++i; banana=++i; cherry=++i; diff --git a/Task/Enumerations/Ada/enumerations.ada b/Task/Enumerations/Ada/enumerations.ada new file mode 100644 index 0000000000..02c8ce5529 --- /dev/null +++ b/Task/Enumerations/Ada/enumerations.ada @@ -0,0 +1,2 @@ +type Fruit is (apple, banana, cherry); -- No specification of the representation value; +for Fruit use (apple => 1, banana => 2, cherry => 4); -- specification of the representation values diff --git a/Task/Enumerations/AmigaE/enumerations.amiga b/Task/Enumerations/AmigaE/enumerations.amiga new file mode 100644 index 0000000000..91c116d17c --- /dev/null +++ b/Task/Enumerations/AmigaE/enumerations.amiga @@ -0,0 +1,7 @@ +ENUM APPLE, BANANA, CHERRY + +PROC main() + DEF x + ForAll({x}, [APPLE, BANANA, CHERRY], + `WriteF('\d\n', x)) +ENDPROC diff --git a/Task/Enumerations/AutoHotkey/enumerations.ahk b/Task/Enumerations/AutoHotkey/enumerations.ahk new file mode 100644 index 0000000000..bd1def3930 --- /dev/null +++ b/Task/Enumerations/AutoHotkey/enumerations.ahk @@ -0,0 +1,3 @@ +fruit_%apple% = 0 +fruit_%banana% = 1 +fruit_%cherry% = 2 diff --git a/Task/Enumerations/BASIC/enumerations.bas b/Task/Enumerations/BASIC/enumerations.bas new file mode 100644 index 0000000000..c7f1056a8c --- /dev/null +++ b/Task/Enumerations/BASIC/enumerations.bas @@ -0,0 +1,16 @@ +REM Impossible. Can only be faked with arrays of strings. +OPTION BASE 1 +DIM SHARED fruitsName$(1 to 3) +DIM SHARED fruitsVal%( 1 to 3) +fruitsName$[1] = "apple" +fruitsName$[2] = "banana" +fruitsName$[3] = "cherry" +fruitsVal%[1] = 1 +fruitsVal%[2] = 2 +fruitsVal%[3] = 3 + +REM OR GLOBAL CONSTANTS +DIM SHARED apple%, banana%, cherry% +apple% = 1 +banana% = 2 +cherry% = 3 diff --git a/Task/Enumerations/C++/enumerations.cpp b/Task/Enumerations/C++/enumerations.cpp new file mode 100644 index 0000000000..a1e54174db --- /dev/null +++ b/Task/Enumerations/C++/enumerations.cpp @@ -0,0 +1,3 @@ +enum fruits { apple, banana, cherry }; + +enum fruits { apple = 0, banana = 1, cherry = 2 }; diff --git a/Task/Enumerations/C/enumerations.c b/Task/Enumerations/C/enumerations.c new file mode 100644 index 0000000000..a1e54174db --- /dev/null +++ b/Task/Enumerations/C/enumerations.c @@ -0,0 +1,3 @@ +enum fruits { apple, banana, cherry }; + +enum fruits { apple = 0, banana = 1, cherry = 2 }; diff --git a/Task/Enumerations/Clojure/enumerations.clj b/Task/Enumerations/Clojure/enumerations.clj new file mode 100644 index 0000000000..3952761a56 --- /dev/null +++ b/Task/Enumerations/Clojure/enumerations.clj @@ -0,0 +1,11 @@ +; a set of keywords +(def fruits #{:apple :banana :cherry}) + +; a predicate to test "fruit" membership +(defn fruit? [x] (contains? fruits x)) + +; if you need a value associated with each fruit +(def fruit-value (zipmap fruits (iterate inc 1))) + +(println (fruit? :apple)) +(println (fruit-value :banana)) diff --git a/Task/Enumerations/Common-Lisp/enumerations-1.lisp b/Task/Enumerations/Common-Lisp/enumerations-1.lisp new file mode 100644 index 0000000000..331052c0f4 --- /dev/null +++ b/Task/Enumerations/Common-Lisp/enumerations-1.lisp @@ -0,0 +1,8 @@ +;; symbol to number +(defconstant +apple+ 0) +(defconstant +banana+ 1) +(defconstant +cherry+ 2) + +;; number to symbol +(defun index-fruit (i) + (aref #(+apple+ +banana+ +cherry+) i)) diff --git a/Task/Enumerations/Common-Lisp/enumerations-2.lisp b/Task/Enumerations/Common-Lisp/enumerations-2.lisp new file mode 100644 index 0000000000..f00b35a54c --- /dev/null +++ b/Task/Enumerations/Common-Lisp/enumerations-2.lisp @@ -0,0 +1,2 @@ +(deftype fruit () + '(member +apple+ +banana+ +cherry+)) diff --git a/Task/Enumerations/D/enumerations.d b/Task/Enumerations/D/enumerations.d new file mode 100644 index 0000000000..934b8914d7 --- /dev/null +++ b/Task/Enumerations/D/enumerations.d @@ -0,0 +1,17 @@ +// Anonymous +enum { APPLE, BANANA, CHERRY } + +// Named (commonlu used enum in D) (uint) +enum Fruits1 { apple, banana, cherry } + +// Named with specified values (uint) +enum Fruits2 { apple = 0, banana = 10, cherry = 20 } + +// Named, typed and with specified values +enum Fruits3 : ubyte { apple = 0, banana = 100, cherry = 200 } + +void main() { + static assert(CHERRY == 2); + int f1 = Fruits2.banana; // No error + // Fruits2 f2 = 1; // Compilation error +} diff --git a/Task/Enumerations/DWScript/enumerations.dwscript b/Task/Enumerations/DWScript/enumerations.dwscript new file mode 100644 index 0000000000..fe6bc08978 --- /dev/null +++ b/Task/Enumerations/DWScript/enumerations.dwscript @@ -0,0 +1,2 @@ +type TFruit = (Apple, Banana, Cherry); +type TApe = (Gorilla = 0, Chimpanzee = 1, Orangutan = 5); diff --git a/Task/Enumerations/Delphi/enumerations.delphi b/Task/Enumerations/Delphi/enumerations.delphi new file mode 100644 index 0000000000..a8b5ea899b --- /dev/null +++ b/Task/Enumerations/Delphi/enumerations.delphi @@ -0,0 +1,4 @@ +type + TFruit = (Apple, Banana, Cherry); + + TApe = (Gorilla = 0, Chimpanzee = 1, Orangutan = 5); diff --git a/Task/Enumerations/E/enumerations-1.e b/Task/Enumerations/E/enumerations-1.e new file mode 100644 index 0000000000..9a3ef020b0 --- /dev/null +++ b/Task/Enumerations/E/enumerations-1.e @@ -0,0 +1,3 @@ +def apple { to value() { return 0 } } +def banana { to value() { return 1 } } +def cherry { to value() { return 2 } } diff --git a/Task/Enumerations/E/enumerations-2.e b/Task/Enumerations/E/enumerations-2.e new file mode 100644 index 0000000000..c5ef378d75 --- /dev/null +++ b/Task/Enumerations/E/enumerations-2.e @@ -0,0 +1,6 @@ +interface Fruit guards FruitStamp {} +def apple implements FruitStamp {} +def banana implements FruitStamp {} +def cherry implements FruitStamp {} + +def eat(fruit :Fruit) { ... } diff --git a/Task/Enumerations/E/enumerations-3.e b/Task/Enumerations/E/enumerations-3.e new file mode 100644 index 0000000000..e7be67cff9 --- /dev/null +++ b/Task/Enumerations/E/enumerations-3.e @@ -0,0 +1,4 @@ +def [Fruit, [=> apple, => banana, => cherry]] := makeEnumeration() + +def [Fruit, [=> apple, => banana, => cherry]] := + makeEnumeration(0, ["apple", "banana", "cherry"]) diff --git a/Task/Enumerations/EGL/enumerations-1.egl b/Task/Enumerations/EGL/enumerations-1.egl new file mode 100644 index 0000000000..852e2caa36 --- /dev/null +++ b/Task/Enumerations/EGL/enumerations-1.egl @@ -0,0 +1,27 @@ +// Without explicit values +enumeration FruitsKind + APPLE, + BANANA, + CHERRY +end + +program EnumerationTest + + function main() + whatFruitAmI(FruitsKind.CHERRY); + end + + function whatFruitAmI(fruit FruitsKind) + case (fruit) + when(FruitsKind.APPLE) + syslib.writestdout("You're an apple."); + when(FruitsKind.BANANA) + syslib.writestdout("You're a banana."); + when(FruitsKind.CHERRY) + syslib.writestdout("You're a cherry."); + otherwise + syslib.writestdout("I'm not sure what you are."); + end + end + +end diff --git a/Task/Enumerations/EGL/enumerations-2.egl b/Task/Enumerations/EGL/enumerations-2.egl new file mode 100644 index 0000000000..b1c388444c --- /dev/null +++ b/Task/Enumerations/EGL/enumerations-2.egl @@ -0,0 +1,27 @@ +// With explicit values +library FruitsKind type BasicLibrary {} + const APPLE int = 0; + const BANANA int = 1; + const CHERRY int = 2; +end + +program EnumerationTest + + function main() + whatFruitAmI(FruitsKind.CHERRY); + end + + function whatFruitAmI(fruit int in) + case (fruit) + when(FruitsKind.APPLE) + syslib.writestdout("You're an apple."); + when(FruitsKind.BANANA) + syslib.writestdout("You're a banana."); + when(FruitsKind.CHERRY) + syslib.writestdout("You're a cherry."); + otherwise + syslib.writestdout("I'm not sure what you are."); + end + end + +end diff --git a/Task/Enumerations/Forth/enumerations-1.fth b/Task/Enumerations/Forth/enumerations-1.fth new file mode 100644 index 0000000000..2b981e7147 --- /dev/null +++ b/Task/Enumerations/Forth/enumerations-1.fth @@ -0,0 +1,4 @@ +0 CONSTANT apple +1 CONSTANT banana +2 CONSTANT cherry +... diff --git a/Task/Enumerations/Forth/enumerations-2.fth b/Task/Enumerations/Forth/enumerations-2.fth new file mode 100644 index 0000000000..6d8ad729b1 --- /dev/null +++ b/Task/Enumerations/Forth/enumerations-2.fth @@ -0,0 +1 @@ +: ENUM ( n -- n+1 ) DUP CONSTANT 1+ ; diff --git a/Task/Enumerations/Forth/enumerations-3.fth b/Task/Enumerations/Forth/enumerations-3.fth new file mode 100644 index 0000000000..015e3be723 --- /dev/null +++ b/Task/Enumerations/Forth/enumerations-3.fth @@ -0,0 +1 @@ +0 ENUM APPLE ENUM BANANA ENUM CHERRY DROP diff --git a/Task/Enumerations/Forth/enumerations-4.fth b/Task/Enumerations/Forth/enumerations-4.fth new file mode 100644 index 0000000000..e6a3ac9482 --- /dev/null +++ b/Task/Enumerations/Forth/enumerations-4.fth @@ -0,0 +1 @@ +0 ENUM FIRST ENUM SECOND ... CONSTANT LAST diff --git a/Task/Enumerations/Forth/enumerations-5.fth b/Task/Enumerations/Forth/enumerations-5.fth new file mode 100644 index 0000000000..f4008872ff --- /dev/null +++ b/Task/Enumerations/Forth/enumerations-5.fth @@ -0,0 +1,2 @@ +: SIZED-ENUM ( n s -- n+s ) OVER CONSTANT + ; +: CELL-ENUM ( n -- n+cell ) CELL SIZED-ENUM ; diff --git a/Task/Enumerations/Forth/enumerations-6.fth b/Task/Enumerations/Forth/enumerations-6.fth new file mode 100644 index 0000000000..54eb80e5df --- /dev/null +++ b/Task/Enumerations/Forth/enumerations-6.fth @@ -0,0 +1,6 @@ +0 ENUM FIRST \ value = 0 +CELL-ENUM SECOND \ value = 1 +ENUM THIRD \ value = 5 +3 SIZED-ENUM FOURTH \ value = 6 +ENUM FIFTH \ value = 9 +CONSTANT SIXTH \ value = 10 diff --git a/Task/Enumerations/Forth/enumerations-7.fth b/Task/Enumerations/Forth/enumerations-7.fth new file mode 100644 index 0000000000..d01ff34a08 --- /dev/null +++ b/Task/Enumerations/Forth/enumerations-7.fth @@ -0,0 +1,4 @@ +: CONSTANTS ( n -- ) 0 DO I CONSTANT LOOP ; + +\ resistor digit colors +10 CONSTANTS black brown red orange yellow green blue violet gray white diff --git a/Task/Enumerations/Fortran/enumerations-1.f b/Task/Enumerations/Fortran/enumerations-1.f new file mode 100644 index 0000000000..71b3e84855 --- /dev/null +++ b/Task/Enumerations/Fortran/enumerations-1.f @@ -0,0 +1,4 @@ +enum, bind(c) + enumerator :: one=1, two, three, four, five + enumerator :: six, seven, nine=9 +end enum diff --git a/Task/Enumerations/Fortran/enumerations-2.f b/Task/Enumerations/Fortran/enumerations-2.f new file mode 100644 index 0000000000..886e7ed814 --- /dev/null +++ b/Task/Enumerations/Fortran/enumerations-2.f @@ -0,0 +1,3 @@ +enum, bind(c) :: nametype + enumerator :: one=1, two, three +end enum nametype diff --git a/Task/Enumerations/Go/enumerations-1.go b/Task/Enumerations/Go/enumerations-1.go new file mode 100644 index 0000000000..56f02cc2ed --- /dev/null +++ b/Task/Enumerations/Go/enumerations-1.go @@ -0,0 +1,5 @@ +const ( + apple = iota + banana + cherry +) diff --git a/Task/Enumerations/Go/enumerations-2.go b/Task/Enumerations/Go/enumerations-2.go new file mode 100644 index 0000000000..774d58cda0 --- /dev/null +++ b/Task/Enumerations/Go/enumerations-2.go @@ -0,0 +1,5 @@ +const ( + apple = 0 + banana = 1 + cherry = 2 +) diff --git a/Task/Enumerations/Haskell/enumerations.hs b/Task/Enumerations/Haskell/enumerations.hs new file mode 100644 index 0000000000..9875c2ea98 --- /dev/null +++ b/Task/Enumerations/Haskell/enumerations.hs @@ -0,0 +1 @@ +data Fruit = Apple | Banana | Cherry deriving Enum diff --git a/Task/Enumerations/Java/enumerations-1.java b/Task/Enumerations/Java/enumerations-1.java new file mode 100644 index 0000000000..b14e3b204d --- /dev/null +++ b/Task/Enumerations/Java/enumerations-1.java @@ -0,0 +1,3 @@ +enum Fruits{ + APPLE, BANANA, CHERRY +} diff --git a/Task/Enumerations/Java/enumerations-2.java b/Task/Enumerations/Java/enumerations-2.java new file mode 100644 index 0000000000..632054e1c7 --- /dev/null +++ b/Task/Enumerations/Java/enumerations-2.java @@ -0,0 +1,6 @@ +enum Fruits{ + APPLE(0), BANANA(1), CHERRY(2) + private final int value; + fruits(int value) { this.value = value; } + public int value() { return value; } +} diff --git a/Task/Enumerations/JavaScript/enumerations.js b/Task/Enumerations/JavaScript/enumerations.js new file mode 100644 index 0000000000..d647e1d8c0 --- /dev/null +++ b/Task/Enumerations/JavaScript/enumerations.js @@ -0,0 +1 @@ +var fruits = { apple : 0, banana : 1, cherry : 2 }; diff --git a/Task/Enumerations/Lua/enumerations-1.lua b/Task/Enumerations/Lua/enumerations-1.lua new file mode 100644 index 0000000000..dea61a22ea --- /dev/null +++ b/Task/Enumerations/Lua/enumerations-1.lua @@ -0,0 +1 @@ +local fruit = {apple = 0, banana = 1, cherry = 2} diff --git a/Task/Enumerations/Lua/enumerations-2.lua b/Task/Enumerations/Lua/enumerations-2.lua new file mode 100644 index 0000000000..ac4a855dd1 --- /dev/null +++ b/Task/Enumerations/Lua/enumerations-2.lua @@ -0,0 +1 @@ +local apple, banana, cherry = 0,1,2 diff --git a/Task/Enumerations/MATLAB/enumerations.m b/Task/Enumerations/MATLAB/enumerations.m new file mode 100644 index 0000000000..1b9cf091e8 --- /dev/null +++ b/Task/Enumerations/MATLAB/enumerations.m @@ -0,0 +1,5 @@ +stuff = {'apple', [1 2 3], 'cherry',1+2i} + +stuff = + + 'apple' [1x3 double] 'cherry' [1.000000000000000 + 2.000000000000000i] diff --git a/Task/Enumerations/PHP/enumerations.php b/Task/Enumerations/PHP/enumerations.php new file mode 100644 index 0000000000..c3cf06a66c --- /dev/null +++ b/Task/Enumerations/PHP/enumerations.php @@ -0,0 +1,18 @@ +// Using an array/hash +$fruits = array( "apple", "banana", "cherry" ); +$fruits = array( "apple" => 0, "banana" => 1, "cherry" => 2 ); + +// If you are inside a class scope +class Fruit { + const APPLE = 0; + const BANANA = 1; + const CHERRY = 2; +} + +// Then you can access them as such +$value = Fruit::APPLE; + +// Or, you can do it using define() +define("FRUIT_APPLE", 0); +define("FRUIT_BANANA", 1); +define("FRUIT_CHERRY", 2); diff --git a/Task/Enumerations/Perl/enumerations.pl b/Task/Enumerations/Perl/enumerations.pl new file mode 100644 index 0000000000..2d891937c8 --- /dev/null +++ b/Task/Enumerations/Perl/enumerations.pl @@ -0,0 +1,5 @@ +# Using an array +my @fruits = qw(apple banana cherry); + +# Using a hash +my %fruits = ( apple => 0, banana => 1, cherry => 2 ); diff --git a/Task/Enumerations/PicoLisp/enumerations-1.l b/Task/Enumerations/PicoLisp/enumerations-1.l new file mode 100644 index 0000000000..d371254903 --- /dev/null +++ b/Task/Enumerations/PicoLisp/enumerations-1.l @@ -0,0 +1,2 @@ +(de enum "Args" + (mapc def "Args" (range 1 (length "Args"))) ) diff --git a/Task/Enumerations/PicoLisp/enumerations-2.l b/Task/Enumerations/PicoLisp/enumerations-2.l new file mode 100644 index 0000000000..bf0973d3d6 --- /dev/null +++ b/Task/Enumerations/PicoLisp/enumerations-2.l @@ -0,0 +1,2 @@ +: (enum A B C D E F) +-> F diff --git a/Task/Enumerations/Python/enumerations-1.py b/Task/Enumerations/Python/enumerations-1.py new file mode 100644 index 0000000000..5b33ed298e --- /dev/null +++ b/Task/Enumerations/Python/enumerations-1.py @@ -0,0 +1 @@ +FIRST_NAME, LAST_NAME, PHONE = range(3) diff --git a/Task/Enumerations/Python/enumerations-2.py b/Task/Enumerations/Python/enumerations-2.py new file mode 100644 index 0000000000..d24c6cc086 --- /dev/null +++ b/Task/Enumerations/Python/enumerations-2.py @@ -0,0 +1 @@ +vars().update((key,val) for val,key in enumerate(("FIRST_NAME","LAST_NAME","PHONE"))) diff --git a/Task/Enumerations/R/enumerations.r b/Task/Enumerations/R/enumerations.r new file mode 100644 index 0000000000..8c1c5b09f6 --- /dev/null +++ b/Task/Enumerations/R/enumerations.r @@ -0,0 +1,3 @@ + factor(c("apple", "banana", "cherry")) +# [1] apple banana cherry +# Levels: apple banana cherry diff --git a/Task/Enumerations/REXX/enumerations.rexx b/Task/Enumerations/REXX/enumerations.rexx new file mode 100644 index 0000000000..a874a4be47 --- /dev/null +++ b/Task/Enumerations/REXX/enumerations.rexx @@ -0,0 +1,50 @@ +/*REXX program to illustrate enumeration of constants via stemmed arrays*/ +fruit.=0 /*the default for all "FRUITS." */ +fruit.apple = 65 +fruit.cherry = 4 +fruit.kiwi = 12 +fruit.peach = 48 +fruit.plum = 50 +fruit.raspberry = 17 +fruit.tomato = 8000 +fruit.ugli = 2 +fruit.watermelon = 0.5 /*could also specify: 1/2 */ + + /*A partial list of some fruits (below). */ + /* [↓] This is one method of using a list. */ +FruitList='apple apricot avocado banana bilberry blackberry blackcurrent blueberry baobab boysenberry breadfruit cantalope cherry chilli chokecherry citront', + 'coconut cranberry cucumber current date dragonfruit durian eggplant elderberry fig feijoa gac gooseberry grape grapefruit guava honeydew huckleberry jackfruit', + 'jambul juneberry kiwi kumquat lemon lime lingenberry loquat lychee mandarine mango mangosteen netarine orange papaya passionfruit peach pear persimmon', + 'physalis pineapple pitaya pomegranate pomelo plum pumpkin rambutan raspberry redcurrent satsuma squash strawberry tangerine tomato ugli watermelon zucchini' +/*┌────────────────────────────────────────────────────────────────────┐ + │ Spoiler alert: sex is discussed below: PG-13. Most berries don't │ + │ have "berry" in their name. A berry is a simple fruit produced │ + │ from a single ovary. Some true berries are: pomegranate, guava, │ + │ eggplant, tomato, chilli, pumpkin, cucumber, melon, and citruses. │ + │ Blueberry is a false berry, blackberry is an aggregate fruit, │ + │ and strawberry is an accessory fruit. Most nuts are fruits. │ + │ The following aren't true nuts: almond, cashew, coconut, │ + │ macadamia, peanut, pecan, pistachio, and walnut. │ + └────────────────────────────────────────────────────────────────────┘*/ + /* [↓] due to a Central America blight in 1922.*/ +if fruit.banana=0 then say "Yes! We have no bananas today." /*(sic)*/ +if fruit.kiwi \=0 then say "We gots" fruit.kiwi "hairy fruit." /*(sic)*/ +if fruit.peach\=0 then say "We gots" fruit.peach "fuzzy fruit." /*(sic)*/ +maxL = length(' fruit ') +maxQ = length(' quantity ') +say + do pass=1 for 2 /*first pass finds the maximums. */ + do j=1 for words(FruitList) + f=word(FruitList,j) /*get a fruit name from the list.*/ + q=value('FRUIT.'f) + if pass==1 then do /*widest fruit name and quantity.*/ + maxL=max(maxL,length(f)) /*longest fruit name*/ + maxQ=max(maxQ,length(q)) /*widest fruit quant*/ + iterate /*j*/ + end + if j==1 then say center('fruit',maxL) center('quantity',maxQ) + if j==1 then say copies('─',maxL) copies('─',maxQ) + if q\=0 then say right(f,maxL) right(q,maxQ) + end /*j*/ + end /*pass*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Enumerations/Ruby/enumerations.rb b/Task/Enumerations/Ruby/enumerations.rb new file mode 100644 index 0000000000..f47963cfd0 --- /dev/null +++ b/Task/Enumerations/Ruby/enumerations.rb @@ -0,0 +1,5 @@ +module Fruits +APPLE = 0 +BANANA = 1 +CHERRY = 2 +end diff --git a/Task/Enumerations/Scala/enumerations-1.scala b/Task/Enumerations/Scala/enumerations-1.scala new file mode 100644 index 0000000000..4d0a34dbd8 --- /dev/null +++ b/Task/Enumerations/Scala/enumerations-1.scala @@ -0,0 +1,4 @@ +sealed abstract class Fruit +case object Apple extends Fruit +case object Banana extends Fruit +case object Cherry extends Fruit diff --git a/Task/Enumerations/Scala/enumerations-2.scala b/Task/Enumerations/Scala/enumerations-2.scala new file mode 100644 index 0000000000..98907b3d33 --- /dev/null +++ b/Task/Enumerations/Scala/enumerations-2.scala @@ -0,0 +1,3 @@ +object Fruit extends Enumeration { + val Apple, Banana, Cherry = Value +} diff --git a/Task/Enumerations/Scheme/enumerations.ss b/Task/Enumerations/Scheme/enumerations.ss new file mode 100644 index 0000000000..4ef9d76f52 --- /dev/null +++ b/Task/Enumerations/Scheme/enumerations.ss @@ -0,0 +1,8 @@ +(define apple 0) +(define banana 1) +(define cherry 2) + +(define (fruit? atom) + (or (equal? 'apple atom) + (equal? 'banana atom) + (equal? 'cherry atom))) diff --git a/Task/Enumerations/Tcl/enumerations-1.tcl b/Task/Enumerations/Tcl/enumerations-1.tcl new file mode 100644 index 0000000000..cc31327a81 --- /dev/null +++ b/Task/Enumerations/Tcl/enumerations-1.tcl @@ -0,0 +1,4 @@ +proc enumerate {name values} { + interp alias {} $name: {} lsearch $values + interp alias {} $name@ {} lindex $values +} diff --git a/Task/Enumerations/Tcl/enumerations-2.tcl b/Task/Enumerations/Tcl/enumerations-2.tcl new file mode 100644 index 0000000000..c4be499f3f --- /dev/null +++ b/Task/Enumerations/Tcl/enumerations-2.tcl @@ -0,0 +1,6 @@ +enumerate fruit {apple blueberry cherry date elderberry} + +fruit: date +# ==> prints "3" +fruit@ 2 +# ==> prints "cherry" diff --git a/Task/Equilibrium-index/0DESCRIPTION b/Task/Equilibrium-index/0DESCRIPTION new file mode 100644 index 0000000000..fb6a8b8778 --- /dev/null +++ b/Task/Equilibrium-index/0DESCRIPTION @@ -0,0 +1,24 @@ +An equilibrium index of a sequence is an index into the sequence such that the sum of elements at lower indices is equal to the sum of elements at higher indices. For example, in a sequence A: + +: A_0 = -7 +: A_1 = 1 +: A_2 = 5 +: A_3 = 2 +: A_4 = -4 +: A_5 = 3 +: A_6 = 0 + +3 is an equilibrium index, because: + +: A_0 + A_1 + A_2 = A_4 + A_5 + A_6 + +6 is also an equilibrium index, because: + +: A_0 + A_1 + A_2 + A_3 + A_4 + A_5 = 0 + +(sum of zero elements is zero) + +7 is not an equilibrium index, because it is not a valid index of sequence A. + +Write a function that, given a sequence, returns its equilibrium indices (if any). +Assume that the sequence may be very long. diff --git a/Task/Equilibrium-index/ALGOL-68/equilibrium-index.alg b/Task/Equilibrium-index/ALGOL-68/equilibrium-index.alg new file mode 100644 index 0000000000..561838edea --- /dev/null +++ b/Task/Equilibrium-index/ALGOL-68/equilibrium-index.alg @@ -0,0 +1,25 @@ +MODE YIELDINT = PROC(INT)VOID; + +PROC gen equilibrium index = ([]INT arr, YIELDINT yield)VOID: +( + INT sum := 0; + FOR i FROM LWB arr TO UPB arr DO + sum +:= arr[i] + OD; + + INT left:=0, right:=sum; + FOR i FROM LWB arr TO UPB arr DO + right -:= arr[i]; + IF left = right THEN yield(i) FI; + left +:= arr[i] + OD +); + +test:( + []INT arr = []INT(-7, 1, 5, 2, -4, 3, 0)[@0]; +# FOR INT index IN # gen equilibrium index(arr, # ) DO ( # +## (INT index)VOID: + print(index) +# OD # ); + print(new line) +) diff --git a/Task/Equilibrium-index/Ada/equilibrium-index-1.ada b/Task/Equilibrium-index/Ada/equilibrium-index-1.ada new file mode 100644 index 0000000000..a98ba69b21 --- /dev/null +++ b/Task/Equilibrium-index/Ada/equilibrium-index-1.ada @@ -0,0 +1,18 @@ +with Ada.Containers.Vectors; + +generic + type Index_Type is range <>; + type Element_Type is private; + Zero : Element_Type; + with function "+" (Left, Right : Element_Type) return Element_Type is <>; + with function "-" (Left, Right : Element_Type) return Element_Type is <>; + with function "=" (Left, Right : Element_Type) return Boolean is <>; + type Array_Type is private; + with function Element (From : Array_Type; Key : Index_Type) return Element_Type is <>; +package Equilibrium is + package Index_Vectors is new Ada.Containers.Vectors + (Index_Type => Positive, Element_Type => Index_Type); + + function Get_Indices (From : Array_Type) return Index_Vectors.Vector; + +end Equilibrium; diff --git a/Task/Equilibrium-index/Ada/equilibrium-index-2.ada b/Task/Equilibrium-index/Ada/equilibrium-index-2.ada new file mode 100644 index 0000000000..6bf14fd9be --- /dev/null +++ b/Task/Equilibrium-index/Ada/equilibrium-index-2.ada @@ -0,0 +1,20 @@ +package body Equilibrium is + + function Get_Indices (From : Array_Type) return Index_Vectors.Vector is + Result : Index_Vectors.Vector; + Right_Sum, Left_Sum : Element_Type := Zero; + begin + for Index in Index_Type'Range loop + Right_Sum := Right_Sum + Element (From, Index); + end loop; + for Index in Index_Type'Range loop + Right_Sum := Right_Sum - Element (From, Index); + if Left_Sum = Right_Sum then + Index_Vectors.Append (Result, Index); + end if; + Left_Sum := Left_Sum + Element (From, Index); + end loop; + return Result; + end Get_Indices; + +end Equilibrium; diff --git a/Task/Equilibrium-index/Ada/equilibrium-index-3.ada b/Task/Equilibrium-index/Ada/equilibrium-index-3.ada new file mode 100644 index 0000000000..662359350a --- /dev/null +++ b/Task/Equilibrium-index/Ada/equilibrium-index-3.ada @@ -0,0 +1,52 @@ +with Ada.Text_IO; +with Equilibrium; +with Ada.Containers.Vectors; + +procedure Main is + subtype Index_Type is Positive range 1 .. 7; + package Vectors is new Ada.Containers.Vectors + (Element_Type => Integer, Index_Type => Index_Type); + type Plain_Array is array (Index_Type) of Integer; + function Element (From : Plain_Array; Key : Index_Type) return Integer is + begin + return From (Key); + end Element; + + package Vector_Equilibrium is new Equilibrium + (Index_Type => Index_Type, + Element_Type => Integer, + Zero => 0, + Array_Type => Vectors.Vector, + Element => Vectors.Element); + package Array_Equilibrium is new Equilibrium + (Index_Type => Index_Type, + Element_Type => Integer, + Zero => 0, + Array_Type => Plain_Array); + + My_Vector : Vectors.Vector; + My_Array : Plain_Array := (-7, 1, 5, 2, -4, 3, 0); + Vector_Result : Vector_Equilibrium.Index_Vectors.Vector; + Array_Result : Array_Equilibrium.Index_Vectors.Vector := + Array_Equilibrium.Get_Indices (My_Array); +begin + Vectors.Append (My_Vector, -7); + Vectors.Append (My_Vector, 1); + Vectors.Append (My_Vector, 5); + Vectors.Append (My_Vector, 2); + Vectors.Append (My_Vector, -4); + Vectors.Append (My_Vector, 3); + Vectors.Append (My_Vector, 0); + Vector_Result := Vector_Equilibrium.Get_Indices (My_Vector); + Ada.Text_IO.Put_Line ("Results:"); + Ada.Text_IO.Put ("Array: "); + for I in Array_Result.First_Index .. Array_Result.Last_Index loop + Ada.Text_IO.Put (Integer'Image (Array_Equilibrium.Index_Vectors.Element (Array_Result, I))); + end loop; + Ada.Text_IO.New_Line; + Ada.Text_IO.Put ("Vector: "); + for I in Vector_Result.First_Index .. Vector_Result.Last_Index loop + Ada.Text_IO.Put (Integer'Image (Vector_Equilibrium.Index_Vectors.Element (Vector_Result, I))); + end loop; + Ada.Text_IO.New_Line; +end Main; diff --git a/Task/Equilibrium-index/Ada/equilibrium-index-4.ada b/Task/Equilibrium-index/Ada/equilibrium-index-4.ada new file mode 100644 index 0000000000..e3281ddc9f --- /dev/null +++ b/Task/Equilibrium-index/Ada/equilibrium-index-4.ada @@ -0,0 +1,68 @@ +with Ada.Text_IO; + +procedure Equilibrium is + + type Integer_Sequence is array (Positive range <>) of Integer; + function Seq_Img (From : Integer_Sequence) return String is + begin + if From'First /= From'Last then + return " " & Integer'Image (From (From'First)) & + Seq_Img (From (From'First + 1 .. From'Last)); + else + return " " & Integer'Image (From (From'First)); + end if; + end Seq_Img; + + type Boolean_Sequence is array (Positive range <>) of Boolean; + function Seq_Img (From : Boolean_Sequence) return String is + begin + if From'First > From'Last then + return ""; + end if; + if From (From'First) then + return Integer'Image (From'First) & + Seq_Img (From (From'First + 1 .. From'Last)); + else + return Seq_Img (From (From'First + 1 .. From'Last)); + end if; + end Seq_Img; + + function Get_Indices (From : Integer_Sequence) return Boolean_Sequence is + Result : Boolean_Sequence (From'Range) := (others => False); + Left_Sum, Right_Sum : Integer := 0; + begin + for Index in From'Range loop + Right_Sum := Right_Sum + From (Index); + end loop; + for Index in From'Range loop + Right_Sum := Right_Sum - From (Index); + Result (Index) := Left_Sum = Right_Sum; + Left_Sum := Left_Sum + From (Index); + end loop; + return Result; + end Get_Indices; + + X1 : Integer_Sequence := (-7, 1, 5, 2, -4, 3, 0); + X1_Result : Boolean_Sequence := Get_Indices (X1); + X2 : Integer_Sequence := ( 2, 4, 6); + X2_Result : Boolean_Sequence := Get_Indices (X2); + X3 : Integer_Sequence := ( 2, 9, 2); + X3_Result : Boolean_Sequence := Get_Indices (X3); + X4 : Integer_Sequence := ( 1, -1, 1, -1, 1 ,-1, 1); + X4_Result : Boolean_Sequence := Get_Indices (X4); + +begin + Ada.Text_IO.Put_Line ("Results:"); + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line ("X1:" & Seq_Img (X1)); + Ada.Text_IO.Put_Line ("Eqs:" & Seq_Img (X1_Result)); + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line ("X2:" & Seq_Img (X2)); + Ada.Text_IO.Put_Line ("Eqs:" & Seq_Img (X2_Result)); + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line ("X3:" & Seq_Img (X3)); + Ada.Text_IO.Put_Line ("Eqs:" & Seq_Img (X3_Result)); + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line ("X4:" & Seq_Img (X4)); + Ada.Text_IO.Put_Line ("Eqs:" & Seq_Img (X4_Result)); +end Equilibrium; diff --git a/Task/Equilibrium-index/BBC-BASIC/equilibrium-index.bbc b/Task/Equilibrium-index/BBC-BASIC/equilibrium-index.bbc new file mode 100644 index 0000000000..8271145321 --- /dev/null +++ b/Task/Equilibrium-index/BBC-BASIC/equilibrium-index.bbc @@ -0,0 +1,13 @@ + DIM list(6) + list() = -7, 1, 5, 2, -4, 3, 0 + PRINT "Equilibrium indices are " FNequilibrium(list()) + END + + DEF FNequilibrium(l()) + LOCAL i%, r, s, e$ + s = SUM(l()) + FOR i% = 0 TO DIM(l(),1) + IF r = s - r - l(i%) THEN e$ += STR$(i%) + "," + r += l(i%) + NEXT + = LEFT$(e$) diff --git a/Task/Equilibrium-index/C++/equilibrium-index.cpp b/Task/Equilibrium-index/C++/equilibrium-index.cpp new file mode 100644 index 0000000000..df631bee44 --- /dev/null +++ b/Task/Equilibrium-index/C++/equilibrium-index.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include + +template +std::vector equilibrium(T first, T last) +{ + typedef typename std::iterator_traits::value_type value_t; + + value_t left = 0; + value_t right = std::accumulate(first, last, value_t(0)); + std::vector result; + + for (size_t index = 0; first != last; ++first, ++index) + { + right -= *first; + if (left == right) + { + result.push_back(index); + } + left += *first; + } + return result; +} + +template +void print(const T& value) +{ + std::cout << value << "\n"; +} + +int main() +{ + const int data[] = { -7, 1, 5, 2, -4, 3, 0 }; + + std::vector indices(equilibrium(data, data + 7)); + + std::for_each(indices.begin(), indices.end(), print); +} diff --git a/Task/Equilibrium-index/C/equilibrium-index.c b/Task/Equilibrium-index/C/equilibrium-index.c new file mode 100644 index 0000000000..a97fed8674 --- /dev/null +++ b/Task/Equilibrium-index/C/equilibrium-index.c @@ -0,0 +1,44 @@ +#include +#include + +int list[] = {-7, 1, 5, 2, -4, 3, 0}; + +int eq_idx(int *a, int len, int **ret) +{ + int i, sum, s, cnt; + /* alloc long enough: if we can afford the original list, + * we should be able to afford to this. Beats a potential + * million realloc() calls. Even if memory is a real concern, + * there's no garantee the result is shorter than the input anyway */ + cnt = s = sum = 0; + *ret = malloc(sizeof(int) * len); + + for (i = 0; i < len; i++) + sum += a[i]; + + for (i = 0; i < len; i++) { + if (s * 2 + a[i] == sum) { + (*ret)[cnt] = i; + cnt++; + } + s += a[i]; + } + + /* uncouraged way to use realloc since it can leak memory, for example */ + *ret = realloc(*ret, cnt * sizeof(int)); + + return cnt; +} + +int main() +{ + int i, cnt, *idx; + cnt = eq_idx(list, sizeof(list) / sizeof(int), &idx); + + printf("Found:"); + for (i = 0; i < cnt; i++) + printf(" %d", idx[i]); + printf("\n"); + + return 0; +} diff --git a/Task/Equilibrium-index/Clojure/equilibrium-index.clj b/Task/Equilibrium-index/Clojure/equilibrium-index.clj new file mode 100644 index 0000000000..ee5b465ab2 --- /dev/null +++ b/Task/Equilibrium-index/Clojure/equilibrium-index.clj @@ -0,0 +1,8 @@ +(defn equilibrium [lst] + (loop [acc '(), i 0, left 0, right (apply + lst), lst lst] + (if (empty? lst) + (reverse acc) + (let [[x & xs] lst + right (- right x) + acc (if (= left right) (cons i acc) acc)] + (recur acc (inc i) (+ left x) right xs))))) diff --git a/Task/Equilibrium-index/D/equilibrium-index-1.d b/Task/Equilibrium-index/D/equilibrium-index-1.d new file mode 100644 index 0000000000..cef1498686 --- /dev/null +++ b/Task/Equilibrium-index/D/equilibrium-index-1.d @@ -0,0 +1,10 @@ +import std.stdio, std.algorithm, std.range, std.functional; + +auto equilibrium(Range)(Range r) /*pure nothrow*/ { + alias S = curry!(reduce!q{a + b}, 0); // sum + return r.length.iota().filter!(i => S(r[0..i]) == S(r[i+1..$]))(); +} + +void main() { + writeln(equilibrium([-7, 1, 5, 2, -4, 3, 0])); +} diff --git a/Task/Equilibrium-index/D/equilibrium-index-2.d b/Task/Equilibrium-index/D/equilibrium-index-2.d new file mode 100644 index 0000000000..2be7f1fa35 --- /dev/null +++ b/Task/Equilibrium-index/D/equilibrium-index-2.d @@ -0,0 +1,18 @@ +import std.stdio, std.algorithm; + +size_t[] equilibrium(T)(in T[] items) @safe pure /*nothrow*/ { + size_t[] result; + T left = 0, right = reduce!q{a + b}(cast(T)0, items); + + foreach (i, e; items) { + right -= e; + if (right == left) + result ~= i; + left += e; + } + return result; +} + +void main() { + writeln(equilibrium([-7, 1, 5, 2, -4, 3, 0])); +} diff --git a/Task/Equilibrium-index/Euphoria/equilibrium-index.euphoria b/Task/Equilibrium-index/Euphoria/equilibrium-index.euphoria new file mode 100644 index 0000000000..100313d632 --- /dev/null +++ b/Task/Equilibrium-index/Euphoria/equilibrium-index.euphoria @@ -0,0 +1,20 @@ +function equilibrium(sequence s) + integer lower_sum, higher_sum + sequence indices + lower_sum = 0 + higher_sum = 0 + for i = 1 to length(s) do + higher_sum += s[i] + end for + indices = {} + for i = 1 to length(s) do + higher_sum -= s[i] + if lower_sum = higher_sum then + indices &= i + end if + lower_sum += s[i] + end for + return indices +end function + +? equilibrium({-7,1,5,2,-4,3,0}) diff --git a/Task/Equilibrium-index/Fortran/equilibrium-index.f b/Task/Equilibrium-index/Fortran/equilibrium-index.f new file mode 100644 index 0000000000..dcc21b6a4a --- /dev/null +++ b/Task/Equilibrium-index/Fortran/equilibrium-index.f @@ -0,0 +1,19 @@ +program Equilibrium + implicit none + + integer :: array(7) = (/ -7, 1, 5, 2, -4, 3, 0 /) + + call equil_index(array) + +contains + +subroutine equil_index(a) + integer, intent(in) :: a(:) + integer :: i + + do i = 1, size(a) + if(sum(a(1:i-1)) == sum(a(i+1:size(a)))) write(*,*) i + end do + +end subroutine +end program diff --git a/Task/Equilibrium-index/Go/equilibrium-index.go b/Task/Equilibrium-index/Go/equilibrium-index.go new file mode 100644 index 0000000000..070df09a7c --- /dev/null +++ b/Task/Equilibrium-index/Go/equilibrium-index.go @@ -0,0 +1,36 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +func main() { + fmt.Println(ex([]int32{-7, 1, 5, 2, -4, 3, 0})) + + // sequence of 1,000,000 random numbers, with values + // chosen so that it will be likely to have a couple + // of equalibrium indexes. + rand.Seed(time.Now().UnixNano()) + verylong := make([]int32, 1e6) + for i := range verylong { + verylong[i] = rand.Int31n(1001) - 500 + } + fmt.Println(ex(verylong)) +} + +func ex(s []int32) (eq []int) { + var r, l int64 + for _, el := range s { + r += int64(el) + } + for i, el := range s { + r -= int64(el) + if l == r { + eq = append(eq, i) + } + l += int64(el) + } + return +} diff --git a/Task/Equilibrium-index/Haskell/equilibrium-index-1.hs b/Task/Equilibrium-index/Haskell/equilibrium-index-1.hs new file mode 100644 index 0000000000..60bf4b9421 --- /dev/null +++ b/Task/Equilibrium-index/Haskell/equilibrium-index-1.hs @@ -0,0 +1,11 @@ +import Data.List +import Control.Monad +import Control.Arrow +import System.Random + +equilibr xs = elemIndices True. map (uncurry((.sum).(==). sum)). + takeWhile(not.null.snd) $ map (flip (liftM2 (&&&) take (drop. pred)) xs) [1..] + +langeSliert = + replicateM 2000 (randomRIO (-15,15) :: IO Int) + >>= print. equilibr diff --git a/Task/Equilibrium-index/Haskell/equilibrium-index-2.hs b/Task/Equilibrium-index/Haskell/equilibrium-index-2.hs new file mode 100644 index 0000000000..dc2f15961a --- /dev/null +++ b/Task/Equilibrium-index/Haskell/equilibrium-index-2.hs @@ -0,0 +1,2 @@ +*Main> equilibr [-7, 1, 5, 2, -4, 3, 0] +[3,6] diff --git a/Task/Equilibrium-index/Haskell/equilibrium-index-3.hs b/Task/Equilibrium-index/Haskell/equilibrium-index-3.hs new file mode 100644 index 0000000000..01f9a45638 --- /dev/null +++ b/Task/Equilibrium-index/Haskell/equilibrium-index-3.hs @@ -0,0 +1,2 @@ +*Main> langeSliert +[231,245,259,265,382,1480,1611,1612] diff --git a/Task/Equilibrium-index/Java/equilibrium-index.java b/Task/Equilibrium-index/Java/equilibrium-index.java new file mode 100644 index 0000000000..8d341ec86d --- /dev/null +++ b/Task/Equilibrium-index/Java/equilibrium-index.java @@ -0,0 +1,20 @@ +import java.util.Arrays; + +public class Equlibrium { + private static int[] sequence = {-7, 1, 5, 2, -4, 3, 0}; + + public static void main(String[] args) { + System.out.println("Equilibrium indices of " + Arrays.toString(sequence)+":"); + for (int i = 0; i < sequence.length; i++) { + int sum = 0; + for (int j = 0; j < sequence.length; j++) { + if (j < i) + sum += sequence[j]; + if (j > i) + sum -= sequence[j]; + } + if (sum == 0) + System.out.println(i); + } + } +} diff --git a/Task/Equilibrium-index/MATLAB/equilibrium-index-1.m b/Task/Equilibrium-index/MATLAB/equilibrium-index-1.m new file mode 100644 index 0000000000..ab76555bf2 --- /dev/null +++ b/Task/Equilibrium-index/MATLAB/equilibrium-index-1.m @@ -0,0 +1,11 @@ +function indicies = equilibriumIndex(list) + + indicies = []; + + for i = (1:numel(list)) + if ( sum(-list(1:i)) == sum(-list(i:end)) ) + indicies = [indicies i]; + end + end + +end diff --git a/Task/Equilibrium-index/MATLAB/equilibrium-index-2.m b/Task/Equilibrium-index/MATLAB/equilibrium-index-2.m new file mode 100644 index 0000000000..e2ce8c7bde --- /dev/null +++ b/Task/Equilibrium-index/MATLAB/equilibrium-index-2.m @@ -0,0 +1,5 @@ +>> equilibriumIndex([-7 1 5 2 -4 3 0]) + +ans = + + 4 7 diff --git a/Task/Equilibrium-index/PHP/equilibrium-index.php b/Task/Equilibrium-index/PHP/equilibrium-index.php new file mode 100644 index 0000000000..f9e0b7b2a0 --- /dev/null +++ b/Task/Equilibrium-index/PHP/equilibrium-index.php @@ -0,0 +1,18 @@ + $value){ + $right -= $value; + if($left == $right) $equilibriums[] = $key; + $left += $value; + } + return $equilibriums; +} + +echo "# results:\n"; +foreach (getEquilibriums($arr) as $r) echo "$r, "; +?> diff --git a/Task/Equilibrium-index/Perl/equilibrium-index.pl b/Task/Equilibrium-index/Perl/equilibrium-index.pl new file mode 100644 index 0000000000..b507e92c81 --- /dev/null +++ b/Task/Equilibrium-index/Perl/equilibrium-index.pl @@ -0,0 +1,15 @@ +sub eq_index { + my ( $i, $sum, %sums ) = ( 0, 0 ); + + for (@_) { + push @{ $sums{ $sum * 2 + $_ } }, $i++; + $sum += $_; + } + + return join ' ', @{ $sums{$sum} || [] }, "\n"; +} + +print eq_index qw( -7 1 5 2 -4 3 0 ); # 3 6 +print eq_index qw( 2 4 6 ); # (no eq point) +print eq_index qw( 2 9 2 ); # 1 +print eq_index qw( 1 -1 1 -1 1 -1 1 ); # 0 1 2 3 4 5 6 diff --git a/Task/Equilibrium-index/PicoLisp/equilibrium-index.l b/Task/Equilibrium-index/PicoLisp/equilibrium-index.l new file mode 100644 index 0000000000..65d9f7673b --- /dev/null +++ b/Task/Equilibrium-index/PicoLisp/equilibrium-index.l @@ -0,0 +1,6 @@ +(de equilibria (Lst) + (make + (let Sum 0 + (for ((I . L) Lst L (cdr L)) + (and (= Sum (sum prog (cdr L))) (link I)) + (inc 'Sum (car L)) ) ) ) ) diff --git a/Task/Equilibrium-index/Python/equilibrium-index-1.py b/Task/Equilibrium-index/Python/equilibrium-index-1.py new file mode 100644 index 0000000000..ed05d5d496 --- /dev/null +++ b/Task/Equilibrium-index/Python/equilibrium-index-1.py @@ -0,0 +1,9 @@ +def eqindex2Pass(data): + "Two pass" + suml, sumr, ddelayed = 0, sum(data), 0 + for i, d in enumerate(data): + suml += ddelayed + sumr -= d + ddelayed = d + if suml == sumr: + yield i diff --git a/Task/Equilibrium-index/Python/equilibrium-index-2.py b/Task/Equilibrium-index/Python/equilibrium-index-2.py new file mode 100644 index 0000000000..a110d3fc1e --- /dev/null +++ b/Task/Equilibrium-index/Python/equilibrium-index-2.py @@ -0,0 +1,6 @@ +def eqindexMultiPass(data): + "Multi pass" + for i in range(len(data)): + suml, sumr = sum(data[:i]), sum(data[i+1:]) + if suml == sumr: + yield i diff --git a/Task/Equilibrium-index/Python/equilibrium-index-3.py b/Task/Equilibrium-index/Python/equilibrium-index-3.py new file mode 100644 index 0000000000..fd0b6794e6 --- /dev/null +++ b/Task/Equilibrium-index/Python/equilibrium-index-3.py @@ -0,0 +1,4 @@ +def eqindexMultiPass(s): + return [i for i in xrange(len(s)) if sum(s[:i]) == sum(s[i+1:])] + +print eqindexMultiPass([-7, 1, 5, 2, -4, 3, 0]) diff --git a/Task/Equilibrium-index/Python/equilibrium-index-4.py b/Task/Equilibrium-index/Python/equilibrium-index-4.py new file mode 100644 index 0000000000..8c0d76bbc4 --- /dev/null +++ b/Task/Equilibrium-index/Python/equilibrium-index-4.py @@ -0,0 +1,9 @@ +from collections import defaultdict + +def eqindex1Pass(data): + "One pass" + l, h = 0, defaultdict(list) + for i, c in enumerate(data): + l += c + h[l * 2 - c].append(i) + return h[l] diff --git a/Task/Equilibrium-index/Python/equilibrium-index-5.py b/Task/Equilibrium-index/Python/equilibrium-index-5.py new file mode 100644 index 0000000000..215564b7c8 --- /dev/null +++ b/Task/Equilibrium-index/Python/equilibrium-index-5.py @@ -0,0 +1,10 @@ +f = (eqindex2Pass, eqindexMultiPass, eqindex1Pass) +d = ([-7, 1, 5, 2, -4, 3, 0], + [2, 4, 6], + [2, 9, 2], + [1, -1, 1, -1, 1, -1, 1]) + +for data in d: + print("d = %r" % data) + for func in f: + print(" %16s(d) -> %r" % (func.__name__, list(func(data)))) diff --git a/Task/Equilibrium-index/REXX/equilibrium-index.rexx b/Task/Equilibrium-index/REXX/equilibrium-index.rexx new file mode 100644 index 0000000000..9d3378c2ac --- /dev/null +++ b/Task/Equilibrium-index/REXX/equilibrium-index.rexx @@ -0,0 +1,33 @@ +/*REXX program finds the equalibrium index for an numeric array (list).*/ +parse arg x /*get the array's numbers. */ +say ' array list: ' x /*echo the array list to screen. */ +say /* ... and a blank line. */ +k=0 /*needed for array list counter. */ + do j=0 /*start J at 1 for 1-based arrays*/ + k=k+1 /*bump counter of array numbers. */ + _=word(x,k) /*get the number from the list. */ + if _=='' then leave /*if null, then we are done. */ + A.j=_ /*define the array element. */ + end /*j*/ +j=j-1 /*fudge DO index for the real cnt*/ +ans=equalibriumIndex(0,j) /*calculate the equalibrium Index*/ +@indexes='indices'; if ans==1 then @indexes='index' /*singular adj.*/ +say 'equalibrium' @indexes": " ans /*show equalibrium index/indices.*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────EQUALIBRIUMINDEX subroutine─────────*/ +equalibriumIndex: procedure expose A. /*have the array A. be exposed.*/ +parse arg start,many /*start is most likely 0 or 1 */ +q= /*equalibrium indexes (so far). */ + do e=start to many /*find various sums (top/bot). */ + sumB=0 /*sum of bottom part of a list. */ + do b=start to e-1 /*add the bottom part of a list. */ + sumB=sumB + A.b /*add this array element to sumB.*/ + end /*b*/ + sumT=0 /*sum of top part of a list. */ + do t=e+1 to many /*add the top part of a list. */ + sumT=sumT + A.t /*add this array element to sumT.*/ + end /*t*/ + + if sumB=sumT then q=q e /*if both sums equal, found one. */ + end /*e*/ +return strip(q) /*return the equalibrium list. */ diff --git a/Task/Equilibrium-index/Ruby/equilibrium-index-1.rb b/Task/Equilibrium-index/Ruby/equilibrium-index-1.rb new file mode 100644 index 0000000000..5b6a619090 --- /dev/null +++ b/Task/Equilibrium-index/Ruby/equilibrium-index-1.rb @@ -0,0 +1,7 @@ +def eq_indicies *list + len = list.size + + (0...len).select do |i| + list[0, i].inject(0, &:+) == list[i + 1, len - i - 1].inject(0, &:+) + end +end diff --git a/Task/Equilibrium-index/Ruby/equilibrium-index-2.rb b/Task/Equilibrium-index/Ruby/equilibrium-index-2.rb new file mode 100644 index 0000000000..5f8bae7822 --- /dev/null +++ b/Task/Equilibrium-index/Ruby/equilibrium-index-2.rb @@ -0,0 +1,14 @@ +def eq_indicies *list + final = list.size - 1 + result = [] + list.empty? and return result + + helper = lambda do |left, current, right, index| + left == right and result << index # Push index to result? + index == final and return # Terminate recursion? + new = list[index + 1] + helper.call(left + current, new, right - new, index + 1) + end + helper.call 0, list.first, list.inject(&:+) - list.first, 0 + return result +end diff --git a/Task/Equilibrium-index/Ruby/equilibrium-index-3.rb b/Task/Equilibrium-index/Ruby/equilibrium-index-3.rb new file mode 100644 index 0000000000..46a9a80516 --- /dev/null +++ b/Task/Equilibrium-index/Ruby/equilibrium-index-3.rb @@ -0,0 +1,14 @@ +def eq_indicies *list + left, right = 0, list.inject(0, &:+) + equilibrium_indicies = [] + + list.each_with_index do |val, i| + right -= val + + equilibrium_indicies << i if right == left + + left += val + end + + equilibrium_indicies +end diff --git a/Task/Equilibrium-index/Tcl/equilibrium-index-1.tcl b/Task/Equilibrium-index/Tcl/equilibrium-index-1.tcl new file mode 100644 index 0000000000..93f9af12c8 --- /dev/null +++ b/Task/Equilibrium-index/Tcl/equilibrium-index-1.tcl @@ -0,0 +1,16 @@ +proc listEquilibria {list} { + set after 0 + foreach item $list {incr after $item} + set result {} + set idx 0 + set before 0 + foreach item $list { + incr after [expr {-$item}] + if {$after == $before} { + lappend result $idx + } + incr before $item + incr idx + } + return $result +} diff --git a/Task/Equilibrium-index/Tcl/equilibrium-index-2.tcl b/Task/Equilibrium-index/Tcl/equilibrium-index-2.tcl new file mode 100644 index 0000000000..1976221cf0 --- /dev/null +++ b/Task/Equilibrium-index/Tcl/equilibrium-index-2.tcl @@ -0,0 +1,2 @@ +set testData {-7 1 5 2 -4 3 0} +puts Equilibria=[join [listEquilibria $testData] ", "] diff --git a/Task/Ethiopian-multiplication/0DESCRIPTION b/Task/Ethiopian-multiplication/0DESCRIPTION new file mode 100644 index 0000000000..02d4279ee7 --- /dev/null +++ b/Task/Ethiopian-multiplication/0DESCRIPTION @@ -0,0 +1,51 @@ +A method of multiplying integers using only addition, doubling, and halving. + +'''Method:'''
+# Take two numbers to be multiplied and write them down at the top of two columns. +# In the left-hand column repeatedly halve the last number, discarding any remainders, and write the result below the last in the same column, until you write a value of 1. +# In the right-hand column repeatedly double the last number and write the result below. stop when you add a result in the same row as where the left hand column shows 1. +# Examine the table produced and discard any row where the value in the left column is even. +# Sum the values in the right-hand column that remain to produce the result of multiplying the original two numbers together + +'''For example:''' 17 × 34 + 17 34 +Halving the first column: + 17 34 + 8 + 4 + 2 + 1 +Doubling the second column: + 17 34 + 8 68 + 4 136 + 2 272 + 1 544 +Strike-out rows whose first cell is even: + 17 34 + 8 68 + 4 136 + 2 272 + 1 544 +Sum the remaining numbers in the right-hand column: + 17 34 + 8 -- + 4 --- + 2 --- + 1 544 + ==== + 578 +So 17 multiplied by 34, by the Ethiopian method is 578. + +The task is to '''define three named functions'''/methods/procedures/subroutines: +# one to '''halve an integer''', +# one to '''double an integer''', and +# one to '''state if an integer is even'''. +Use these functions to '''create a function that does Ethiopian multiplication'''. + +'''References''' +*[http://www.bbc.co.uk/learningzone/clips/ethiopian-multiplication-explained/11232.html Ethiopian multiplication explained] (Video) +*[http://www.youtube.com/watch?v=Nc4yrFXw20Q A Night Of Numbers - Go Forth And Multiply] (Video) +*[http://www.ncetm.org.uk/blogs/3064 Ethiopian multiplication] +*[http://www.bbc.co.uk/dna/h2g2/A22808126 Russian Peasant Multiplication] +*[http://thedailywtf.com/Articles/Programming-Praxis-Russian-Peasant-Multiplication.aspx Programming Praxis: Russian Peasant Multiplication] diff --git a/Task/Ethiopian-multiplication/1META.yaml b/Task/Ethiopian-multiplication/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Ethiopian-multiplication/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Ethiopian-multiplication/ACL2/ethiopian-multiplication.acl2 b/Task/Ethiopian-multiplication/ACL2/ethiopian-multiplication.acl2 new file mode 100644 index 0000000000..b2abefd208 --- /dev/null +++ b/Task/Ethiopian-multiplication/ACL2/ethiopian-multiplication.acl2 @@ -0,0 +1,18 @@ +(include-book "arithmetic-3/top" :dir :system) + +(defun halve (x) + (floor x 2)) + +(defun double (x) + (* x 2)) + +(defun is-even (x) + (evenp x)) + +(defun multiply (x y) + (if (zp (1- x)) + y + (+ (if (is-even x) + 0 + y) + (multiply (halve x) (double y))))) diff --git a/Task/Ethiopian-multiplication/ALGOL-68/ethiopian-multiplication.alg b/Task/Ethiopian-multiplication/ALGOL-68/ethiopian-multiplication.alg new file mode 100644 index 0000000000..6f6eb368fc --- /dev/null +++ b/Task/Ethiopian-multiplication/ALGOL-68/ethiopian-multiplication.alg @@ -0,0 +1,29 @@ +PROC halve = (REF INT x)VOID: x := ABS(BIN x SHR 1); +PROC doublit = (REF INT x)VOID: x := ABS(BIN x SHL 1); +PROC iseven = (#CONST# INT x)BOOL: NOT ODD x; + +PROC ethiopian = (INT in plier, + INT in plicand, #CONST# BOOL tutor)INT: +( + INT plier := in plier, plicand := in plicand; + INT result:=0; + + IF tutor THEN + printf(($"ethiopian multiplication of "g(0)," by "g(0)l$, plier, plicand)) FI; + + WHILE plier >= 1 DO + IF iseven(plier) THEN + IF tutor THEN printf(($" "4d," "6d" struck"l$, plier, plicand)) FI + ELSE + IF tutor THEN printf(($" "4d," "6d" kept"l$, plier, plicand)) FI; + result +:= plicand + FI; + halve(plier); doublit(plicand) + OD; + result +); + +main: +( + printf(($g(0)l$, ethiopian(17, 34, TRUE))) +) diff --git a/Task/Ethiopian-multiplication/AWK/ethiopian-multiplication.awk b/Task/Ethiopian-multiplication/AWK/ethiopian-multiplication.awk new file mode 100644 index 0000000000..7df9a7b855 --- /dev/null +++ b/Task/Ethiopian-multiplication/AWK/ethiopian-multiplication.awk @@ -0,0 +1,31 @@ +function halve(x) +{ + return int(x/2) +} + +function double(x) +{ + return x*2 +} + +function iseven(x) +{ + return x%2 == 0 +} + +function ethiopian(plier, plicand) +{ + r = 0 + while(plier >= 1) { + if ( !iseven(plier) ) { + r += plicand + } + plier = halve(plier) + plicand = double(plicand) + } + return r +} + +BEGIN { + print ethiopian(17, 34) +} diff --git a/Task/Ethiopian-multiplication/ActionScript/ethiopian-multiplication-1.as b/Task/Ethiopian-multiplication/ActionScript/ethiopian-multiplication-1.as new file mode 100644 index 0000000000..d76c91f540 --- /dev/null +++ b/Task/Ethiopian-multiplication/ActionScript/ethiopian-multiplication-1.as @@ -0,0 +1,31 @@ +function Divide(a:Number):Number { + return ((a-(a%2))/2); +} +function Multiply(a:Number):Number { + return (a *= 2); +} +function isEven(a:Number):Boolean { + if (a%2 == 0) { + return (true); + } else { + return (false); + } +} +function Ethiopian(left:Number, right:Number) { + var r:Number = 0; + trace(left+" "+right); + while (left != 1) { + var State:String = "Keep"; + if (isEven(Divide(left))) { + State = "Strike"; + } + trace(Divide(left)+" "+Multiply(right)+" "+State); + left = Divide(left); + right = Multiply(right); + if (State == "Keep") { + r += right; + } + } + trace("="+" "+r); +} +} diff --git a/Task/Ethiopian-multiplication/ActionScript/ethiopian-multiplication-2.as b/Task/Ethiopian-multiplication/ActionScript/ethiopian-multiplication-2.as new file mode 100644 index 0000000000..501920d2ee --- /dev/null +++ b/Task/Ethiopian-multiplication/ActionScript/ethiopian-multiplication-2.as @@ -0,0 +1,6 @@ +17 34 +8 68 Strike +4 136 Strike +2 272 Strike +1 544 Keep += 578 diff --git a/Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-1.ada b/Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-1.ada new file mode 100644 index 0000000000..0a202f89f3 --- /dev/null +++ b/Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-1.ada @@ -0,0 +1,3 @@ +package Ethiopian is + function Multiply(Left, Right : Integer) return Integer; +end Ethiopian; diff --git a/Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-2.ada b/Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-2.ada new file mode 100644 index 0000000000..5fd786e3cc --- /dev/null +++ b/Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-2.ada @@ -0,0 +1,31 @@ +package body Ethiopian is + function Is_Even(Item : Integer) return Boolean is + begin + return Item mod 2 = 0; + end Is_Even; + + function Double(Item : Integer) return Integer is + begin + return Item * 2; + end Double; + + function Half(Item : Integer) return Integer is + begin + return Item / 2; + end Half; + + function Multiply(Left, Right : Integer) return Integer is + Temp : Integer := 0; + Plier : Integer := Left; + Plicand : Integer := Right; + begin + while Plier >= 1 loop + if not Is_Even(Plier) then + Temp := Temp + Plicand; + end if; + Plier := Half(Plier); + Plicand := Double(Plicand); + end loop; + return Temp; + end Multiply; +end Ethiopian; diff --git a/Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-3.ada b/Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-3.ada new file mode 100644 index 0000000000..5e992b8709 --- /dev/null +++ b/Task/Ethiopian-multiplication/Ada/ethiopian-multiplication-3.ada @@ -0,0 +1,11 @@ +with Ethiopian; use Ethiopian; +with Ada.Text_Io; use Ada.Text_Io; + +procedure Ethiopian_Test is + First : Integer := 17; + Second : Integer := 34; +begin + Put_Line(Integer'Image(First) & " times " & + Integer'Image(Second) & " = " & + Integer'Image(Multiply(First, Second))); +end Ethiopian_Test; diff --git a/Task/Ethiopian-multiplication/AutoHotkey/ethiopian-multiplication.ahk b/Task/Ethiopian-multiplication/AutoHotkey/ethiopian-multiplication.ahk new file mode 100644 index 0000000000..ca683175df --- /dev/null +++ b/Task/Ethiopian-multiplication/AutoHotkey/ethiopian-multiplication.ahk @@ -0,0 +1,30 @@ +MsgBox % Ethiopian(17, 34) "`n" Ethiopian2(17, 34) + +; func definitions: +half( x ) { + return x >> 1 +} + +double( x ) { + return x << 1 +} + +isEven( x ) { + return x & 1 == 0 +} + +Ethiopian( a, b ) { + r := 0 + While (a >= 1) { + if !isEven(a) + r += b + a := half(a) + b := double(b) + } + return r +} + +; or a recursive function: +Ethiopian2( a, b, r = 0 ) { ;omit r param on initial call + return a==1 ? r+b : Ethiopian2( half(a), double(b), !isEven(a) ? r+b : r ) +} diff --git a/Task/Ethiopian-multiplication/AutoIt/ethiopian-multiplication.autoit b/Task/Ethiopian-multiplication/AutoIt/ethiopian-multiplication.autoit new file mode 100644 index 0000000000..f08b6574ac --- /dev/null +++ b/Task/Ethiopian-multiplication/AutoIt/ethiopian-multiplication.autoit @@ -0,0 +1,39 @@ +Func Halve($x) + Return Int($x/2) +EndFunc + +Func Double($x) + Return ($x*2) +EndFunc + +Func IsEven($x) + Return (Mod($x,2) == 0) +EndFunc + +; this version also supports negative parameters +Func Ethiopian($nPlier, $nPlicand, $bTutor = True) + Local $nResult = 0 + If ($nPlier < 0) Then + $nPlier =- $nPlier + $nPlicand =- $nPlicand + ElseIf ($nPlicand > 0) And ($nPlier > $nPlicand) Then + $nPlier = $nPlicand + $nPlicand = $nPlier + EndIf + If $bTutor Then _ + ConsoleWrite(StringFormat("Ethiopian multiplication of %d by %d...\n", $nPlier, $nPlicand)) + While ($nPlier >= 1) + If Not IsEven($nPlier) Then + $nResult += $nPlicand + If $bTutor Then ConsoleWrite(StringFormat("%d\t%d\tKeep\n", $nPlier, $nPlicand)) + Else + If $bTutor Then ConsoleWrite(StringFormat("%d\t%d\tStrike\n", $nPlier, $nPlicand)) + EndIf + $nPlier = Halve($nPlier) + $nPlicand = Double($nPlicand) + WEnd + If $bTutor Then ConsoleWrite(StringFormat("Answer = %d\n", $nResult)) + Return $nResult +EndFunc + +MsgBox(0, "Ethiopian multiplication of 17 by 34", Ethiopian(17, 34) ) diff --git a/Task/Ethiopian-multiplication/BASIC/ethiopian-multiplication.bas b/Task/Ethiopian-multiplication/BASIC/ethiopian-multiplication.bas new file mode 100644 index 0000000000..ba019dedce --- /dev/null +++ b/Task/Ethiopian-multiplication/BASIC/ethiopian-multiplication.bas @@ -0,0 +1,35 @@ +DECLARE FUNCTION half% (a AS INTEGER) +DECLARE FUNCTION doub% (a AS INTEGER) +DECLARE FUNCTION isEven% (a AS INTEGER) + +DIM x AS INTEGER, y AS INTEGER, outP AS INTEGER + +x = 17 +y = 34 + +DO + PRINT x, + IF NOT (isEven(x)) THEN + outP = outP + y + PRINT y + ELSE + PRINT + END IF + IF x < 2 THEN EXIT DO + x = half(x) + y = doub(y) +LOOP + +PRINT " =", outP + +FUNCTION doub% (a AS INTEGER) + doub% = a * 2 +END FUNCTION + +FUNCTION half% (a AS INTEGER) + half% = a \ 2 +END FUNCTION + +FUNCTION isEven% (a AS INTEGER) + isEven% = (a MOD 2) - 1 +END FUNCTION diff --git a/Task/Ethiopian-multiplication/BBC-BASIC/ethiopian-multiplication.bbc b/Task/Ethiopian-multiplication/BBC-BASIC/ethiopian-multiplication.bbc new file mode 100644 index 0000000000..58c6c595f3 --- /dev/null +++ b/Task/Ethiopian-multiplication/BBC-BASIC/ethiopian-multiplication.bbc @@ -0,0 +1,22 @@ + x% = 17 + y% = 34 + + REPEAT + IF NOT FNeven(x%) THEN + p% += y% + PRINT x%, y% + ELSE + PRINT x%, " ---" + ENDIF + x% = FNhalve(x%) + y% = FNdouble(y%) + UNTIL x% = 0 + PRINT " " , " ===" + PRINT " " , p% + END + + DEF FNdouble(A%) = A% * 2 + + DEF FNhalve(A%) = A% DIV 2 + + DEF FNeven(A%) = ((A% AND 1) = 0) diff --git a/Task/Ethiopian-multiplication/C++/ethiopian-multiplication.cpp b/Task/Ethiopian-multiplication/C++/ethiopian-multiplication.cpp new file mode 100644 index 0000000000..3ac433c472 --- /dev/null +++ b/Task/Ethiopian-multiplication/C++/ethiopian-multiplication.cpp @@ -0,0 +1,54 @@ +template +struct Half +{ + enum { Result = N >> 1 }; +}; + +template +struct Double +{ + enum { Result = N << 1 }; +}; + +template +struct IsEven +{ + static const bool Result = (N & 1) == 0; +}; + +template +struct EthiopianMultiplication +{ + template + struct AddIfNot + { + enum { Result = Plier + RunningTotal }; + }; + template + struct AddIfNot + { + enum { Result = RunningTotal }; + }; + + template + struct Loop + { + enum { Result = Loop::Result, Double::Result, + AddIfNot::Result, Plicand, RunningTotal >::Result >::Result }; + }; + template + struct Loop <0, Plicand, RunningTotal> + { + enum { Result = RunningTotal }; + }; + + enum { Result = Loop::Result }; +}; + +#include + +int main(int, char **) +{ + std::cout << EthiopianMultiplication<17, 54>::Result << std::endl; + return 0; +} diff --git a/Task/Ethiopian-multiplication/C/ethiopian-multiplication.c b/Task/Ethiopian-multiplication/C/ethiopian-multiplication.c new file mode 100644 index 0000000000..a7eddd0e8a --- /dev/null +++ b/Task/Ethiopian-multiplication/C/ethiopian-multiplication.c @@ -0,0 +1,32 @@ +#include +#include + +void halve(int *x) { *x >>= 1; } +void doublit(int *x) { *x <<= 1; } +bool iseven(const int x) { return (x & 1) == 0; } + +int ethiopian(int plier, + int plicand, const bool tutor) +{ + int result=0; + + if (tutor) + printf("ethiopian multiplication of %d by %d\n", plier, plicand); + + while(plier >= 1) { + if ( iseven(plier) ) { + if (tutor) printf("%4d %6d struck\n", plier, plicand); + } else { + if (tutor) printf("%4d %6d kept\n", plier, plicand); + result += plicand; + } + halve(&plier); doublit(&plicand); + } + return result; +} + +int main() +{ + printf("%d\n", ethiopian(17, 34, true)); + return 0; +} diff --git a/Task/Ethiopian-multiplication/COBOL/ethiopian-multiplication.cobol b/Task/Ethiopian-multiplication/COBOL/ethiopian-multiplication.cobol new file mode 100644 index 0000000000..8def6c7746 --- /dev/null +++ b/Task/Ethiopian-multiplication/COBOL/ethiopian-multiplication.cobol @@ -0,0 +1,93 @@ + *>* Ethiopian multiplication + + IDENTIFICATION DIVISION. + PROGRAM-ID. ethiopian-multiplication. + DATA DIVISION. + LOCAL-STORAGE SECTION. + 01 l PICTURE 9(10) VALUE 17. + 01 r PICTURE 9(10) VALUE 34. + 01 ethiopian-multiply PICTURE 9(20). + 01 product PICTURE 9(20). + PROCEDURE DIVISION. + CALL "ethiopian-multiply" USING + BY CONTENT l, BY CONTENT r, + BY REFERENCE ethiopian-multiply + END-CALL + DISPLAY ethiopian-multiply END-DISPLAY + MULTIPLY l BY r GIVING product END-MULTIPLY + DISPLAY product END-DISPLAY + STOP RUN. + END PROGRAM ethiopian-multiplication. + + IDENTIFICATION DIVISION. + PROGRAM-ID. ethiopian-multiply. + DATA DIVISION. + LOCAL-STORAGE SECTION. + 01 evenp PICTURE 9. + 88 even VALUE 1. + 88 odd VALUE 0. + LINKAGE SECTION. + 01 l PICTURE 9(10). + 01 r PICTURE 9(10). + 01 product PICTURE 9(20) VALUE ZERO. + PROCEDURE DIVISION using l, r, product. + MOVE ZEROES TO product + PERFORM UNTIL l EQUAL ZERO + CALL "evenp" USING + BY CONTENT l, + BY REFERENCE evenp + END-CALL + IF odd + ADD r TO product GIVING product END-ADD + END-IF + CALL "halve" USING + BY CONTENT l, + BY REFERENCE l + END-CALL + CALL "twice" USING + BY CONTENT r, + BY REFERENCE r + END-CALL + END-PERFORM + GOBACK. + END PROGRAM ethiopian-multiply. + + IDENTIFICATION DIVISION. + PROGRAM-ID. halve. + DATA DIVISION. + LOCAL-STORAGE SECTION. + LINKAGE SECTION. + 01 n PICTURE 9(10). + 01 m PICTURE 9(10). + PROCEDURE DIVISION USING n, m. + DIVIDE n BY 2 GIVING m END-DIVIDE + GOBACK. + END PROGRAM halve. + + IDENTIFICATION DIVISION. + PROGRAM-ID. twice. + DATA DIVISION. + LOCAL-STORAGE SECTION. + LINKAGE SECTION. + 01 n PICTURE 9(10). + 01 m PICTURE 9(10). + PROCEDURE DIVISION USING n, m. + MULTIPLY n by 2 GIVING m END-MULTIPLY + GOBACK. + END PROGRAM twice. + + IDENTIFICATION DIVISION. + PROGRAM-ID. evenp. + DATA DIVISION. + LOCAL-STORAGE SECTION. + 01 q PICTURE 9(10). + LINKAGE SECTION. + 01 n PICTURE 9(10). + 01 m PICTURE 9(1). + 88 even VALUE 1. + 88 odd VALUE 0. + PROCEDURE DIVISION USING n, m. + DIVIDE n BY 2 GIVING q REMAINDER m END-DIVIDE + SUBTRACT m FROM 1 GIVING m END-SUBTRACT + GOBACK. + END PROGRAM evenp. diff --git a/Task/Ethiopian-multiplication/Clojure/ethiopian-multiplication.clj b/Task/Ethiopian-multiplication/Clojure/ethiopian-multiplication.clj new file mode 100644 index 0000000000..72bc7a5b08 --- /dev/null +++ b/Task/Ethiopian-multiplication/Clojure/ethiopian-multiplication.clj @@ -0,0 +1,25 @@ +(defn halve [n] + (bit-shift-right n 1)) + +(defn twice [n] ; 'double' is taken + (bit-shift-left n 1)) + +(defn even [n] ; 'even?' is the standard fn + (zero? (bit-and n 1))) + +(defn emult [x y] + (reduce + + (map second + (filter #(not (even (first %))) ; a.k.a. 'odd?' + (take-while #(pos? (first %)) + (map vector + (iterate halve x) + (iterate twice y))))))) + +(defn emult2 [x y] + (loop [a x, b y, r 0] + (if (= a 1) + (+ r b) + (if (even a) + (recur (halve a) (twice b) r) + (recur (halve a) (twice b) (+ r b)))))) diff --git a/Task/Ethiopian-multiplication/CoffeeScript/ethiopian-multiplication.coffee b/Task/Ethiopian-multiplication/CoffeeScript/ethiopian-multiplication.coffee new file mode 100644 index 0000000000..33ed4a6c73 --- /dev/null +++ b/Task/Ethiopian-multiplication/CoffeeScript/ethiopian-multiplication.coffee @@ -0,0 +1,17 @@ +halve = (n) -> Math.floor n / 2 +double = (n) -> n * 2 +is_even = (n) -> n % 2 == 0 + +multiply = (a, b) -> + prod = 0 + while a > 0 + prod += b if !is_even a + a = halve a + b = double b + prod + +# tests +do -> + for i in [0..100] + for j in [0..100] + throw Error("broken for #{i} * #{j}") if multiply(i,j) != i * j diff --git a/Task/Ethiopian-multiplication/ColdFusion/ethiopian-multiplication-1.cfm b/Task/Ethiopian-multiplication/ColdFusion/ethiopian-multiplication-1.cfm new file mode 100644 index 0000000000..b52fa89c42 --- /dev/null +++ b/Task/Ethiopian-multiplication/ColdFusion/ethiopian-multiplication-1.cfm @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#ethiopian(17,34)# diff --git a/Task/Ethiopian-multiplication/ColdFusion/ethiopian-multiplication-2.cfm b/Task/Ethiopian-multiplication/ColdFusion/ethiopian-multiplication-2.cfm new file mode 100644 index 0000000000..26f548b904 --- /dev/null +++ b/Task/Ethiopian-multiplication/ColdFusion/ethiopian-multiplication-2.cfm @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +Ethiopian multiplication of #Number_A# and #Number_B#... +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
#Number_A##Number_B##Action#
+ +...equals #Result# + +
diff --git a/Task/Ethiopian-multiplication/Common-Lisp/ethiopian-multiplication.lisp b/Task/Ethiopian-multiplication/Common-Lisp/ethiopian-multiplication.lisp new file mode 100644 index 0000000000..3353991ec1 --- /dev/null +++ b/Task/Ethiopian-multiplication/Common-Lisp/ethiopian-multiplication.lisp @@ -0,0 +1,8 @@ +(defun ethiopian-multiply (l r) + (flet ((halve (n) (floor n 2)) + (double (n) (* n 2)) + (even-p (n) (zerop (mod n 2)))) + (do ((product 0 (if (even-p l) product (+ product r))) + (l l (halve l)) + (r r (double r))) + ((zerop l) product)))) diff --git a/Task/Ethiopian-multiplication/D/ethiopian-multiplication.d b/Task/Ethiopian-multiplication/D/ethiopian-multiplication.d new file mode 100644 index 0000000000..9a5b80af63 --- /dev/null +++ b/Task/Ethiopian-multiplication/D/ethiopian-multiplication.d @@ -0,0 +1,30 @@ +import std.stdio; + +int ethiopian(int n1, int n2) pure nothrow +in { + assert(n1 >= 0, "muliplier cannot be negative"); +} body { + static int doubleNum(in int n) pure nothrow { return n * 2; } + static int halveNum(in int n) pure nothrow { return n / 2; } + static bool isEven(in int n) pure nothrow { return !(n & 1); } + + int result; + while (n1 >= 1) { + if (!isEven(n1)) + result += n2; + n1 = halveNum(n1); + n2 = doubleNum(n2); + } + + return result; +} + +unittest { + assert(ethiopian(77, 54) == 77 * 54); + assert(ethiopian(8, 923) == 8 * 923); + assert(ethiopian(64, -4) == 64 * -4); +} + +void main() { + writeln("17 ethiopian 34 is ", ethiopian(17, 34)); +} diff --git a/Task/Ethiopian-multiplication/E/ethiopian-multiplication.e b/Task/Ethiopian-multiplication/E/ethiopian-multiplication.e new file mode 100644 index 0000000000..31f9630c63 --- /dev/null +++ b/Task/Ethiopian-multiplication/E/ethiopian-multiplication.e @@ -0,0 +1,13 @@ +def halve(&x) { x //= 2 } +def double(&x) { x *= 2 } +def even(x) { return x %% 2 <=> 0 } + +def multiply(var a, var b) { + var ab := 0 + while (a > 0) { + if (!even(a)) { ab += b } + halve(&a) + double(&b) + } + return ab +} diff --git a/Task/Ethiopian-multiplication/Ela/ethiopian-multiplication.ela b/Task/Ethiopian-multiplication/Ela/ethiopian-multiplication.ela new file mode 100644 index 0000000000..0f865a5183 --- /dev/null +++ b/Task/Ethiopian-multiplication/Ela/ethiopian-multiplication.ela @@ -0,0 +1,8 @@ +open list number + +halve x = x `div` 2 +double = (2*) + +ethiopicmult a b = sum <| map snd <| filter (odd << fst) <| zip + (takeWhile (>=1) <| iterate halve a) + (iterate double b) diff --git a/Task/Ethiopian-multiplication/Erlang/ethiopian-multiplication.erl b/Task/Ethiopian-multiplication/Erlang/ethiopian-multiplication.erl new file mode 100644 index 0000000000..4e9d31f9cb --- /dev/null +++ b/Task/Ethiopian-multiplication/Erlang/ethiopian-multiplication.erl @@ -0,0 +1,25 @@ +-module(ethopian). +-export([multiply/2]). + +halve(N) -> + N div 2. + +double(N) -> + N * 2. + +even(N) -> + (N rem 2) == 0. + +multiply(LHS,RHS) when is_integer(Lhs) and Lhs > 0 and + is_integer(Rhs) and Rhs > 0 -> + multiply(LHS,RHS,0). + +multiply(1,RHS,Acc) -> + RHS+Acc; +multiply(LHS,RHS,Acc) -> + case even(LHS) of + true -> + multiply(halve(LHS),double(RHS),Acc); + false -> + multiply(halve(LHS),double(RHS),Acc+RHS) + end. diff --git a/Task/Ethiopian-multiplication/Euphoria/ethiopian-multiplication.euphoria b/Task/Ethiopian-multiplication/Euphoria/ethiopian-multiplication.euphoria new file mode 100644 index 0000000000..020c498654 --- /dev/null +++ b/Task/Ethiopian-multiplication/Euphoria/ethiopian-multiplication.euphoria @@ -0,0 +1,31 @@ +function emHalf(integer n) + return floor(n/2) +end function + +function emDouble(integer n) + return n*2 +end function + +function emIsEven(integer n) + return (remainder(n,2) = 0) +end function + +function emMultiply(integer a, integer b) + integer sum + sum = 0 + while (a) do + if (not emIsEven(a)) then sum += b end if + a = emHalf(a) + b = emDouble(b) + end while + + return sum +end function + +---------------------------------------------------------------- +-- runtime + +printf(1,"emMultiply(%d,%d) = %d\n",{17,34,emMultiply(17,34)}) + +printf(1,"\nPress Any Key\n",{}) +while (get_key() = -1) do end while diff --git a/Task/Ethiopian-multiplication/Forth/ethiopian-multiplication.fth b/Task/Ethiopian-multiplication/Forth/ethiopian-multiplication.fth new file mode 100644 index 0000000000..e25a6b001c --- /dev/null +++ b/Task/Ethiopian-multiplication/Forth/ethiopian-multiplication.fth @@ -0,0 +1,4 @@ +: e* ( x y -- x*y ) + dup 0= if nip exit then + over 2* over 2/ recurse + swap 1 and if + else nip then ; diff --git a/Task/Ethiopian-multiplication/Fortran/ethiopian-multiplication.f b/Task/Ethiopian-multiplication/Fortran/ethiopian-multiplication.f new file mode 100644 index 0000000000..9814c9af96 --- /dev/null +++ b/Task/Ethiopian-multiplication/Fortran/ethiopian-multiplication.f @@ -0,0 +1,58 @@ +program EthiopicMult + implicit none + + print *, ethiopic(17, 34, .true.) + +contains + + subroutine halve(v) + integer, intent(inout) :: v + v = int(v / 2) + end subroutine halve + + subroutine doublit(v) + integer, intent(inout) :: v + v = v * 2 + end subroutine doublit + + function iseven(x) + logical :: iseven + integer, intent(in) :: x + iseven = mod(x, 2) == 0 + end function iseven + + function ethiopic(multiplier, multiplicand, tutorialized) result(r) + integer :: r + integer, intent(in) :: multiplier, multiplicand + logical, intent(in), optional :: tutorialized + + integer :: plier, plicand + logical :: tutor + + plier = multiplier + plicand = multiplicand + + if ( .not. present(tutorialized) ) then + tutor = .false. + else + tutor = tutorialized + endif + + r = 0 + + if ( tutor ) write(*, '(A, I0, A, I0)') "ethiopian multiplication of ", plier, " by ", plicand + + do while(plier >= 1) + if ( iseven(plier) ) then + if (tutor) write(*, '(I4, " ", I6, A)') plier, plicand, " struck" + else + if (tutor) write(*, '(I4, " ", I6, A)') plier, plicand, " kept" + r = r + plicand + endif + call halve(plier) + call doublit(plicand) + end do + + end function ethiopic + +end program EthiopicMult diff --git a/Task/Ethiopian-multiplication/Go/ethiopian-multiplication.go b/Task/Ethiopian-multiplication/Go/ethiopian-multiplication.go new file mode 100644 index 0000000000..1d5cf977f8 --- /dev/null +++ b/Task/Ethiopian-multiplication/Go/ethiopian-multiplication.go @@ -0,0 +1,22 @@ +package main + +import "fmt" + +func halve(i int) int { return i/2 } + +func double(i int) int { return i*2 } + +func isEven(i int) bool { return i%2 == 0 } + +func ethMulti(i, j int) (r int) { + for ; i > 0; i, j = halve(i), double(j) { + if !isEven(i) { + r += j + } + } + return +} + +func main() { + fmt.Printf("17 ethiopian 34 = %d\n", ethMulti(17, 34)) +} diff --git a/Task/Ethiopian-multiplication/Haskell/ethiopian-multiplication.hs b/Task/Ethiopian-multiplication/Haskell/ethiopian-multiplication.hs new file mode 100644 index 0000000000..c941f9b00d --- /dev/null +++ b/Task/Ethiopian-multiplication/Haskell/ethiopian-multiplication.hs @@ -0,0 +1,15 @@ +import Prelude hiding (odd) + +halve, double :: Integral a => a -> a +halve = (`div` 2) +double = (2 *) + +odd :: Integral a => a -> Bool +odd = (== 1) . (`mod` 2) + +ethiopicmult :: Integral a => a -> a -> a +ethiopicmult a b = sum $ map snd $ filter (odd . fst) $ zip + (takeWhile (>= 1) $ iterate halve a) + (iterate double b) + +main = print $ ethiopicmult 17 34 == 17 * 34 diff --git a/Task/Ethiopian-multiplication/Java/ethiopian-multiplication-1.java b/Task/Ethiopian-multiplication/Java/ethiopian-multiplication-1.java new file mode 100644 index 0000000000..3d1689cbca --- /dev/null +++ b/Task/Ethiopian-multiplication/Java/ethiopian-multiplication-1.java @@ -0,0 +1,41 @@ +import java.util.HashMap; +import java.util.Map; +import java.util.Scanner; +public class Mult{ + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + int first = sc.nextInt(); + int second = sc.nextInt(); + + if(first < 0){ + first = -first; + second = -second; + } + + Map columns = new HashMap(); + columns.put(first, second); + int sum = isEven(first)? 0 : second; + do{ + first = halveInt(first); + second = doubleInt(second); + columns.put(first, second); + if(!isEven(first)){ + sum += second; + } + }while(first > 1); + + System.out.println(sum); + } + + public static int doubleInt(int doubleMe){ + return doubleMe << 1; //shift left + } + + public static int halveInt(int halveMe){ + return halveMe >>> 1; //shift right + } + + public static boolean isEven(int num){ + return (num & 1) == 0; + } +} diff --git a/Task/Ethiopian-multiplication/Java/ethiopian-multiplication-2.java b/Task/Ethiopian-multiplication/Java/ethiopian-multiplication-2.java new file mode 100644 index 0000000000..6ee318fe29 --- /dev/null +++ b/Task/Ethiopian-multiplication/Java/ethiopian-multiplication-2.java @@ -0,0 +1,51 @@ +/** + * This method will use ethiopian styled multiplication. + * @param a Any non-negative integer. + * @param b Any integer. + * @result a multiplied by b + */ +public static int ethiopianMultiply(int a, int b) { + if(a==0 || b==0) { + return 0; + } + int result = 0; + while(a>=1) { + if(!isEven(a)) { + result+=b; + } + b = doubleInt(b); + a = halveInt(a); + } + return result; +} + +/** + * This method is an improved version that will use + * ethiopian styled multiplication, and also + * supports negative parameters. + * @param a Any integer. + * @param b Any integer. + * @result a multiplied by b + */ +public static int ethiopianMultiplyWithImprovement(int a, int b) { + if(a==0 || b==0) { + return 0; + } + if(a<0) { + a=-a; + b=-b; + } else if(b>0 && a>b) { + int tmp = a; + a = b; + b = tmp; + } + int result = 0; + while(a>=1) { + if(!isEven(a)) { + result+=b; + } + b = doubleInt(b); + a = halveInt(a); + } + return result; +} diff --git a/Task/Ethiopian-multiplication/Java/ethiopian-multiplication-3.java b/Task/Ethiopian-multiplication/Java/ethiopian-multiplication-3.java new file mode 100644 index 0000000000..8e618a5121 --- /dev/null +++ b/Task/Ethiopian-multiplication/Java/ethiopian-multiplication-3.java @@ -0,0 +1,27 @@ +var eth = { + + halve : function ( n ){ return Math.floor(n/2); }, + double: function ( n ){ return 2*n; }, + isEven: function ( n ){ return n%2 === 0); }, + + mult: function ( a , b ){ + var sum = 0, a = [a], b = [b]; + + while ( a[0] !== 1 ){ + a.unshift( eth.halve( a[0] ) ); + b.unshift( eth.double( b[0] ) ); + } + + for( var i = a.length - 1; i > 0 ; i -= 1 ){ + + if( !eth.isEven( a[i] ) ){ + sum += b[i]; + } + } + + return sum + b[0]; + + } +} + +// eth.mult(17,34) returns 578 diff --git a/Task/Ethiopian-multiplication/Lua/ethiopian-multiplication.lua b/Task/Ethiopian-multiplication/Lua/ethiopian-multiplication.lua new file mode 100644 index 0000000000..f38c55d805 --- /dev/null +++ b/Task/Ethiopian-multiplication/Lua/ethiopian-multiplication.lua @@ -0,0 +1,28 @@ +function halve(a) + return a/2 +end + +function double(a) + return a*2 +end + +function isEven(a) + return a%2 == 0 +end + +function ethiopian(x, y) + local result = 0 + + while (x >= 1) do + if not isEven(x) then + result = result + y + end + + x = math.floor(halve(x)) + y = double(y) + end + + return result; +end + +print(ethiopian(17, 34)) diff --git a/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-1.m b/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-1.m new file mode 100644 index 0000000000..2763913400 --- /dev/null +++ b/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-1.m @@ -0,0 +1,5 @@ +function result = halveInt(number) + + result = idivide(number,2,'floor'); + +end diff --git a/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-2.m b/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-2.m new file mode 100644 index 0000000000..49d5337c3e --- /dev/null +++ b/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-2.m @@ -0,0 +1,5 @@ +function result = doubleInt(number) + + result = times(2,number); + +end diff --git a/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-3.m b/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-3.m new file mode 100644 index 0000000000..6063634b2a --- /dev/null +++ b/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-3.m @@ -0,0 +1,6 @@ +%Returns a logical 1 if the number is even, 0 otherwise. +function trueFalse = isEven(number) + + trueFalse = logical( mod(number,2)==0 ); + +end diff --git a/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-4.m b/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-4.m new file mode 100644 index 0000000000..9bb3029804 --- /dev/null +++ b/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-4.m @@ -0,0 +1,15 @@ +function answer = ethiopianMultiplication(multiplicand,multiplier) + + %Generate columns + while multiplicand(end)>1 + multiplicand(end+1,1) = halveInt( multiplicand(end) ); + multiplier(end+1,1) = doubleInt( multiplier(end) ); + end + + %Strike out appropriate rows + multiplier( isEven(multiplicand) ) = []; + + %Generate answer + answer = sum(multiplier); + +end diff --git a/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-5.m b/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-5.m new file mode 100644 index 0000000000..f14c100f2f --- /dev/null +++ b/Task/Ethiopian-multiplication/MATLAB/ethiopian-multiplication-5.m @@ -0,0 +1,5 @@ +ethiopianMultiplication( int32(17),int32(34) ) + +ans = + + 578 diff --git a/Task/Ethiopian-multiplication/PHP/ethiopian-multiplication-1.php b/Task/Ethiopian-multiplication/PHP/ethiopian-multiplication-1.php new file mode 100644 index 0000000000..70d1db4e61 --- /dev/null +++ b/Task/Ethiopian-multiplication/PHP/ethiopian-multiplication-1.php @@ -0,0 +1,33 @@ += 1) { + if ( !iseven($plier) ) $r += $plicand; + if ($tutor) + echo "$plier, $plicand ", (iseven($plier) ? "struck" : "kept"), "\n"; + $plier = halve($plier); + $plicand = double($plicand); + } + return $r; +} + +echo ethiopicmult(17, 34, true), "\n"; + +?> diff --git a/Task/Ethiopian-multiplication/PHP/ethiopian-multiplication-2.php b/Task/Ethiopian-multiplication/PHP/ethiopian-multiplication-2.php new file mode 100644 index 0000000000..624f39af49 --- /dev/null +++ b/Task/Ethiopian-multiplication/PHP/ethiopian-multiplication-2.php @@ -0,0 +1,46 @@ += 1){ + $this->sum_result($x, $y); + $x = $this->half_num($x); + $y = $this->double_num($y); + } + } + + protected function half_num($x){ + return floor($x/2); + } + + protected function double_num($y){ + return $y*2; + } + + protected function not_even($n){ + return $n%2 != 0 ? true : false; + } + + protected function sum_result($x, $y){ + if($this->not_even($x)){ + $this->result += $y; + } + } + + protected function get_result(){ + return $this->result; + } + + static public function init($x, $y){ + $init = new ethiopian_multiply($x, $y); + return $init->get_result(); + } + +} + +echo ethiopian_multiply::init(17, 34); + +?> diff --git a/Task/Ethiopian-multiplication/Perl/ethiopian-multiplication.pl b/Task/Ethiopian-multiplication/Perl/ethiopian-multiplication.pl new file mode 100644 index 0000000000..9ffe136ab9 --- /dev/null +++ b/Task/Ethiopian-multiplication/Perl/ethiopian-multiplication.pl @@ -0,0 +1,24 @@ +use strict; + +sub halve { int((shift) / 2); } +sub double { (shift) * 2; } +sub iseven { ((shift) & 1) == 0; } + +sub ethiopicmult +{ + my ($plier, $plicand, $tutor) = @_; + print "ethiopic multiplication of $plier and $plicand\n" if $tutor; + my $r = 0; + while ($plier >= 1) + { + $r += $plicand unless iseven($plier); + if ($tutor) { + print "$plier, $plicand ", (iseven($plier) ? " struck" : " kept"), "\n"; + } + $plier = halve($plier); + $plicand = double($plicand); + } + return $r; +} + +print ethiopicmult(17,34, 1), "\n"; diff --git a/Task/Ethiopian-multiplication/PicoLisp/ethiopian-multiplication.l b/Task/Ethiopian-multiplication/PicoLisp/ethiopian-multiplication.l new file mode 100644 index 0000000000..09465cfbed --- /dev/null +++ b/Task/Ethiopian-multiplication/PicoLisp/ethiopian-multiplication.l @@ -0,0 +1,17 @@ +(de halve (N) + (/ N 2) ) + +(de double (N) + (* N 2) ) + +(de even? (N) + (not (bit? 1 N)) ) + +(de ethiopian (X Y) + (let R 0 + (while (>= X 1) + (or (even? X) (inc 'R Y)) + (setq + X (halve X) + Y (double Y) ) ) + R ) ) diff --git a/Task/Ethiopian-multiplication/Python/ethiopian-multiplication-1.py b/Task/Ethiopian-multiplication/Python/ethiopian-multiplication-1.py new file mode 100644 index 0000000000..812da2bff4 --- /dev/null +++ b/Task/Ethiopian-multiplication/Python/ethiopian-multiplication-1.py @@ -0,0 +1,28 @@ +tutor = True + +def halve(x): + return x//2 + +def double(x): + return x*2 + +def even(x): + return not x % 2 + +def ethiopian(multiplier, multiplicand): + if tutor: + print( "Ethiopian multiplication of %i and %i" % + (multiplier, multiplicand) ) + result = 0 + while multiplier >= 1: + if even(multiplier): + if tutor: print( "%4i %6i STRUCK" % + (multiplier, multiplicand) ) + else: + if tutor: print( "%4i %6i KEPT" % + (multiplier, multiplicand) ) + result += multiplicand + multiplier = halve(multiplier) + multiplicand = double(multiplicand) + if tutor: print() + return result diff --git a/Task/Ethiopian-multiplication/Python/ethiopian-multiplication-2.py b/Task/Ethiopian-multiplication/Python/ethiopian-multiplication-2.py new file mode 100644 index 0000000000..9ea46ef90a --- /dev/null +++ b/Task/Ethiopian-multiplication/Python/ethiopian-multiplication-2.py @@ -0,0 +1,14 @@ +halve = lambda x: x // 2 +double = lambda x: x*2 +even = lambda x: not x % 2 + +def ethiopian(multiplier, multiplicand): + result = 0 + + while multiplier >= 1: + if not even(multiplier): + result += multiplicand + multiplier = halve(multiplier) + multiplicand = double(multiplicand) + + return result diff --git a/Task/Ethiopian-multiplication/Python/ethiopian-multiplication-3.py b/Task/Ethiopian-multiplication/Python/ethiopian-multiplication-3.py new file mode 100644 index 0000000000..91717e8ec2 --- /dev/null +++ b/Task/Ethiopian-multiplication/Python/ethiopian-multiplication-3.py @@ -0,0 +1,42 @@ +tutor = True + +from itertools import izip, takewhile + +def iterate(function, arg): + while 1: + yield arg + arg = function(arg) + +def halve(x): return x // 2 +def double(x): return x * 2 +def even(x): return x % 2 == 0 + +def show_heading(multiplier, multiplicand): + print "Multiplying %d by %d" % (multiplier, multiplicand), + print "using Ethiopian multiplication:" + print + +TABLE_FORMAT = "%8s %8s %8s %8s %8s" + +def show_table(table): + for p, q in table: + print TABLE_FORMAT % (p, q, "->", + p, q if not even(p) else "-" * len(str(q))) + +def show_result(result): + print TABLE_FORMAT % ('', '', '', '', "=" * (len(str(result)) + 1)) + print TABLE_FORMAT % ('', '', '', '', result) + +def ethiopian(multiplier, multiplicand): + def column1(x): return takewhile(lambda v: v >= 1, iterate(halve, x)) + def column2(x): return iterate(double, x) + def rows(x, y): return izip(column1(x), column2(y)) + table = rows(multiplier, multiplicand) + if tutor: + table = list(table) + show_heading(multiplier, multiplicand) + show_table(table) + result = sum(q for p, q in table if not even(p)) + if tutor: + show_result(result) + return result diff --git a/Task/Ethiopian-multiplication/R/ethiopian-multiplication.r b/Task/Ethiopian-multiplication/R/ethiopian-multiplication.r new file mode 100644 index 0000000000..1fbb7a3718 --- /dev/null +++ b/Task/Ethiopian-multiplication/R/ethiopian-multiplication.r @@ -0,0 +1,19 @@ +halve <- function(a) floor(a/2) +double <- function(a) a*2 +iseven <- function(a) (a%%2)==0 + +ethiopicmult <- function(plier, plicand, tutor=FALSE) { + if (tutor) { cat("ethiopic multiplication of", plier, "and", plicand, "\n") } + result <- 0 + while(plier >= 1) { + if (!iseven(plier)) { result <- result + plicand } + if (tutor) { + cat(plier, ", ", plicand, " ", ifelse(iseven(plier), "struck", "kept"), "\n", sep="") + } + plier <- halve(plier) + plicand <- double(plicand) + } + result +} + +print(ethiopicmult(17, 34, TRUE)) diff --git a/Task/Ethiopian-multiplication/REXX/ethiopian-multiplication.rexx b/Task/Ethiopian-multiplication/REXX/ethiopian-multiplication.rexx new file mode 100644 index 0000000000..1d9ecf5570 --- /dev/null +++ b/Task/Ethiopian-multiplication/REXX/ethiopian-multiplication.rexx @@ -0,0 +1,30 @@ +/*REXX program multiplies 2 integers by Ethiopian/Russian peasant method*/ +numeric digits 1000 /*handle very large integers. */ +parse arg a b . /*handles zeroes & negative ints.*/ + /*A & B should be checked if ints*/ +say 'a=' a +say 'b=' b +say 'product=' emult(a,b) +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────EMULT subroutine────────────────────*/ +emult: procedure; parse arg x 1 ox,y +prod=0 + do while x\==0 + if \iseven(x) then prod=prod+y + x=halve(x) + y=double(y) + end +return prod*sign(ox) +/*──────────────────────────────────subroutines─────────────────────────*/ +halve: return arg(1)%2 +double: return arg(1)*2 +iseven: return arg(1)//2==0 + + /*Note: the above procedures don't modify (or define) any */ + /*local variables, so there is no need to specify PROCEDURE */ + + /*REXX allows multiple definitions, only the 1st one is used. */ + /*Three different argument names (methodologies?) are shown. */ +halve: procedure; parse arg ?; return ?%2 +double: procedure; parse arg x; return x+x +iseven: procedure; parse arg _; return _//2 == 0 diff --git a/Task/Ethiopian-multiplication/Ruby/ethiopian-multiplication-1.rb b/Task/Ethiopian-multiplication/Ruby/ethiopian-multiplication-1.rb new file mode 100644 index 0000000000..84c2352b52 --- /dev/null +++ b/Task/Ethiopian-multiplication/Ruby/ethiopian-multiplication-1.rb @@ -0,0 +1,26 @@ +def even(x); x.even?; end +def halve(x); x/2; end +def double(x); x*2; end + +# iterative +def ethopian_multiply(a, b) + product = 0 + while a >= 1 + p [a, b, even(a) ? "STRIKE" : "KEEP"] if $DEBUG + product += b if not even(a) + a = halve(a) + b = double(b) + end + product +end + +# recursive +def rec_ethopian_multiply(a, b) + return 0 if a < 1 + p [a, b, even(a) ? "STRIKE" : "KEEP"] if $DEBUG + (even(a) ? 0 : b) + rec_ethopian_multiply(halve(a), double(b)) +end + +$DEBUG = true # $DEBUG also set to true if "-d" option given +a, b = 20, 5 +puts "#{a} * #{b} = #{ethopian_multiply(a,b)}"; puts diff --git a/Task/Ethiopian-multiplication/Ruby/ethiopian-multiplication-2.rb b/Task/Ethiopian-multiplication/Ruby/ethiopian-multiplication-2.rb new file mode 100644 index 0000000000..4b9b4c947c --- /dev/null +++ b/Task/Ethiopian-multiplication/Ruby/ethiopian-multiplication-2.rb @@ -0,0 +1,15 @@ +require 'test/unit' +class EthiopianTests < Test::Unit::TestCase + def test_iter1; assert_equal(578, ethopian_multiply(17,34)); end + def test_iter2; assert_equal(100, ethopian_multiply(20,5)); end + def test_iter3; assert_equal(5, ethopian_multiply(5,1)); end + def test_iter4; assert_equal(5, ethopian_multiply(1,5)); end + def test_iter5; assert_equal(0, ethopian_multiply(5,0)); end + def test_iter6; assert_equal(0, ethopian_multiply(0,5)); end + def test_rec1; assert_equal(578, rec_ethopian_multiply(17,34)); end + def test_rec2; assert_equal(100, rec_ethopian_multiply(20,5)); end + def test_rec3; assert_equal(5, rec_ethopian_multiply(5,1)); end + def test_rec4; assert_equal(5, rec_ethopian_multiply(1,5)); end + def test_rec5; assert_equal(0, rec_ethopian_multiply(5,0)); end + def test_rec6; assert_equal(0, rec_ethopian_multiply(0,5)); end +end diff --git a/Task/Ethiopian-multiplication/SNUSP/ethiopian-multiplication.snusp b/Task/Ethiopian-multiplication/SNUSP/ethiopian-multiplication.snusp new file mode 100644 index 0000000000..1ec9afa6a2 --- /dev/null +++ b/Task/Ethiopian-multiplication/SNUSP/ethiopian-multiplication.snusp @@ -0,0 +1,11 @@ + /==!/==atoi==@@@-@-----# + | | /-\ /recurse\ #/?\ zero +$>,@/>,@/?\<=zero=!\?/<=print==!\@\>?!\@/<@\.!\-/ + < @ # | \=/ \=itoa=@@@+@+++++# + /==\ \===?!/===-?\>>+# halve ! /+ !/+ !/+ !/+ \ mod10 +# ! @ | #>>\?-<+>/ /<+> -\!?-\!?-\!?-\!?-\! +/-<+>\ > ? />+<<++>-\ \?!\-?!\-?!\-?!\-?!\-?/\ div10 +?down? | \-<<+<-/ | \=<<-/ | | +\=======\!@>============/!/ diff --git a/Task/Ethiopian-multiplication/Scala/ethiopian-multiplication.scala b/Task/Ethiopian-multiplication/Scala/ethiopian-multiplication.scala new file mode 100644 index 0000000000..b6891a249a --- /dev/null +++ b/Task/Ethiopian-multiplication/Scala/ethiopian-multiplication.scala @@ -0,0 +1,24 @@ +def ethiopian(i:Int, j:Int):Int= + pairIterator(i,j).filter(x=> !isEven(x._1)).map(x=>x._2).foldLeft(0){(x,y)=>x+y} + +def ethiopian2(i:Int, j:Int):Int= + pairIterator(i,j).map(x=>if(isEven(x._1)) 0 else x._2).foldLeft(0){(x,y)=>x+y} + +def ethiopian3(i:Int, j:Int):Int= +{ + var res=0; + for((h,d) <- pairIterator(i,j) if !isEven(h)) res+=d; + res +} + +def isEven(x:Int)=(x&1)==0 +def halve(x:Int)=x>>>1 +def double(x:Int)=x<<1 + +// generates pairs of values (halve,double) +def pairIterator(x:Int, y:Int)=new Iterator[(Int, Int)] +{ + var i=(x, y) + def hasNext=i._1>0 + def next={val r=i; i=(halve(i._1), double(i._2)); r} +} diff --git a/Task/Ethiopian-multiplication/Scheme/ethiopian-multiplication.ss b/Task/Ethiopian-multiplication/Scheme/ethiopian-multiplication.ss new file mode 100644 index 0000000000..b3f57093b4 --- /dev/null +++ b/Task/Ethiopian-multiplication/Scheme/ethiopian-multiplication.ss @@ -0,0 +1,16 @@ +(define (halve num) + (quotient num 2)) + +(define (double num) + (* num 2)) + +(define (*mul-eth plier plicand acc) + (cond ((zero? plier) acc) + ((even? plier) (*mul-eth (halve plier) (double plicand) acc)) + (else (*mul-eth (halve plier) (double plicand) (+ acc plicand))))) + +(define (mul-eth plier plicand) + (*mul-eth plier plicand 0)) + +(display (mul-eth 17 34)) +(newline) diff --git a/Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-1.st b/Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-1.st new file mode 100644 index 0000000000..2d25a1a5cf --- /dev/null +++ b/Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-1.st @@ -0,0 +1,32 @@ +Number extend [ + double [ ^ self * 2 ] + halve [ ^ self // 2 ] + ethiopianMultiplyBy: aNumber withTutor: tutor [ + |result multiplier multiplicand| + multiplier := self. + multiplicand := aNumber. + tutor ifTrue: [ ('ethiopian multiplication of %1 and %2' % + { multiplier. multiplicand }) displayNl ]. + result := 0. + [ multiplier >= 1 ] + whileTrue: [ + multiplier even ifFalse: [ + result := result + multiplicand. + tutor ifTrue: [ + ('%1, %2 kept' % { multiplier. multiplicand }) + displayNl + ] + ] + ifTrue: [ + tutor ifTrue: [ + ('%1, %2 struck' % { multiplier. multiplicand }) + displayNl + ] + ]. + multiplier := multiplier halve. + multiplicand := multiplicand double. + ]. + ^result + ] + ethiopianMultiplyBy: aNumber [ ^ self ethiopianMultiplyBy: aNumber withTutor: false ] +]. diff --git a/Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-2.st b/Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-2.st new file mode 100644 index 0000000000..f70da404b7 --- /dev/null +++ b/Task/Ethiopian-multiplication/Smalltalk/ethiopian-multiplication-2.st @@ -0,0 +1 @@ +(17 ethiopianMultiplyBy: 34 withTutor: true) displayNl. diff --git a/Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-1.tcl b/Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-1.tcl new file mode 100644 index 0000000000..5f594c4172 --- /dev/null +++ b/Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-1.tcl @@ -0,0 +1,30 @@ +# This is how to declare functions - the mathematical entities - as opposed to procedures +proc function {name arguments body} { + uplevel 1 [list proc tcl::mathfunc::$name $arguments [list expr $body]] +} + +function double n {$n * 2} +function halve n {$n / 2} +function even n {($n & 1) == 0} +function mult {a b} { + $a < 1 ? 0 : + even($a) ? [logmult STRUCK] + mult(halve($a), double($b)) + : [logmult KEPT] + mult(halve($a), double($b)) + $b +} + +# Wrapper to set up the logging +proc ethiopianMultiply {a b {tutor false}} { + if {$tutor} { + set wa [expr {[string length $a]+1}] + set wb [expr {$wa+[string length $b]-1}] + puts stderr "Ethiopian multiplication of $a and $b" + interp alias {} logmult {} apply {{wa wb msg} { + upvar 1 a a b b + puts stderr [format "%*d %*d %s" $wa $a $wb $b $msg] + return 0 + }} $wa $wb + } else { + proc logmult args {return 0} + } + return [expr {mult($a,$b)}] +} diff --git a/Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-2.tcl b/Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-2.tcl new file mode 100644 index 0000000000..3e70267c19 --- /dev/null +++ b/Task/Ethiopian-multiplication/Tcl/ethiopian-multiplication-2.tcl @@ -0,0 +1 @@ +puts "17 * 34 = [ethiopianMultiply 17 34 true]" diff --git a/Task/Euler-method/0DESCRIPTION b/Task/Euler-method/0DESCRIPTION new file mode 100644 index 0000000000..f9a88d9255 --- /dev/null +++ b/Task/Euler-method/0DESCRIPTION @@ -0,0 +1,50 @@ +Euler's method numerically approximates solutions of first-order ordinary differential equations (ODEs) with a given initial value. It is an explicit method for solving initial value problems (IVPs), as described in [[wp:Euler method|the wikipedia page]]. +The ODE has to be provided in the following form: + +:\frac{dy(t)}{dt} = f(t,y(t)) + +with an initial value + +:y(t_0) = y_0 + +To get a numeric solution, we replace the derivative on the LHS with a finite difference approximation: + +:\frac{dy(t)}{dt} \approx \frac{y(t+h)-y(t)}{h} + +then solve for y(t+h): + +:y(t+h) \approx y(t) + h \, \frac{dy(t)}{dt} + +which is the same as + +:y(t+h) \approx y(t) + h \, f(t,y(t)) + +The iterative solution rule is then: + +:y_{n+1} = y_n + h \, f(t_n, y_n) + +h is the step size, the most relevant parameter for accuracy of the solution. A smaller step size increases accuracy but also the computation cost, so it has always has to be hand-picked according to the problem at hand. + +'''Example: Newton's Cooling Law''' + +Newton's cooling law describes how an object of initial temperature T(t_0) = T_0 cools down in an environment of temperature T_R : + +:\frac{dT(t)}{dt} = -k \, \Delta T + +or + +:\frac{dT(t)}{dt} = -k \, (T(t) - T_R) + +It says that the cooling rate \frac{dT(t)}{dt} of the object is proportional to the current temperature difference \Delta T = (T(t) - T_R) to the surrounding environment. + +The analytical solution, which we will compare to the numerical approximation, is + +:T(t) = T_R + (T_0 - T_R) \; e^{-k t} + +'''Task''' + +The task is to implement a routine of Euler's method and then to use it to solve the given example of Newton's cooling law with it for three different step sizes of 2 s, 5 s and 10 s and to compare with the analytical solution. +The initial temperature T_0 shall be 100 °C, the room temperature T_R 20 °C, and the cooling constant k 0.07. The time interval to calculate shall be from 0 s to 100 s. + +A reference solution ([[#Common Lisp|Common Lisp]]) can be seen below. We see that bigger step sizes lead to reduced approximation accuracy. +[[Image:Euler_Method_Newton_Cooling.png|center|750px]] diff --git a/Task/Euler-method/1META.yaml b/Task/Euler-method/1META.yaml new file mode 100644 index 0000000000..8d1c0603c8 --- /dev/null +++ b/Task/Euler-method/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Mathematical operations diff --git a/Task/Euler-method/ALGOL-68/euler-method.alg b/Task/Euler-method/ALGOL-68/euler-method.alg new file mode 100644 index 0000000000..e54e8ec008 --- /dev/null +++ b/Task/Euler-method/ALGOL-68/euler-method.alg @@ -0,0 +1,24 @@ +# +Approximates y(t) in y'(t)=f(t,y) with y(a)=y0 and +t=a..b and the step size h. +# +PROC euler = (PROC(REAL,REAL)REAL f, REAL y0, a, b, h)REAL: ( + REAL y := y0, + t := a; + WHILE t < b DO + printf(($g(-6,3)": "g(-7,3)l$, t, y)); + y +:= h * f(t, y); + t +:= h + OD; + printf($"done"l$); + y +); + +# Example: Newton's cooling law # +PROC newton cooling law = (REAL time, t)REAL: ( + -0.07 * (t - 20) +); + +main: ( + euler(newton cooling law, 100, 0, 100, 10) +) diff --git a/Task/Euler-method/Ada/euler-method-1.ada b/Task/Euler-method/Ada/euler-method-1.ada new file mode 100644 index 0000000000..6e8d6f7912 --- /dev/null +++ b/Task/Euler-method/Ada/euler-method-1.ada @@ -0,0 +1,11 @@ +generic + type Number is digits <>; +package Euler is + type Waveform is array (Integer range <>) of Number; + function Solve + ( F : not null access function (T, Y : Number) return Number; + Y0 : Number; + T0, T1 : Number; + N : Positive + ) return Waveform; +end Euler; diff --git a/Task/Euler-method/Ada/euler-method-2.ada b/Task/Euler-method/Ada/euler-method-2.ada new file mode 100644 index 0000000000..bb9fa22195 --- /dev/null +++ b/Task/Euler-method/Ada/euler-method-2.ada @@ -0,0 +1,17 @@ +package body Euler is + function Solve + ( F : not null access function (T, Y : Number) return Number; + Y0 : Number; + T0, T1 : Number; + N : Positive + ) return Waveform is + dT : constant Number := (T1 - T0) / Number (N); + begin + return Y : Waveform (0..N) do + Y (0) := Y0; + for I in 1..Y'Last loop + Y (I) := Y (I - 1) + dT * F (T0 + dT * Number (I - 1), Y (I - 1)); + end loop; + end return; + end Solve; +end Euler; diff --git a/Task/Euler-method/Ada/euler-method-3.ada b/Task/Euler-method/Ada/euler-method-3.ada new file mode 100644 index 0000000000..c9bf292f59 --- /dev/null +++ b/Task/Euler-method/Ada/euler-method-3.ada @@ -0,0 +1,18 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Euler; + +procedure Test_Euler_Method is + package Float_Euler is new Euler (Float); + use Float_Euler; + + function Newton_Cooling_Law (T, Y : Float) return Float is + begin + return -0.07 * (Y - 20.0); + end Newton_Cooling_Law; + + Y : Waveform := Solve (Newton_Cooling_Law'Access, 100.0, 0.0, 100.0, 10); +begin + for I in Y'Range loop + Put_Line (Integer'Image (10 * I) & ":" & Float'Image (Y (I))); + end loop; +end Test_Euler_Method; diff --git a/Task/Euler-method/BBC-BASIC/euler-method.bbc b/Task/Euler-method/BBC-BASIC/euler-method.bbc new file mode 100644 index 0000000000..432f76c6ac --- /dev/null +++ b/Task/Euler-method/BBC-BASIC/euler-method.bbc @@ -0,0 +1,15 @@ + PROCeuler("-0.07*(y-20)", 100, 0, 100, 2) + PROCeuler("-0.07*(y-20)", 100, 0, 100, 5) + PROCeuler("-0.07*(y-20)", 100, 0, 100, 10) + END + + DEF PROCeuler(df$, y, a, b, s) + LOCAL t, @% + @% = &2030A + t = a + WHILE t <= b + PRINT t, y + y += s * EVAL(df$) + t += s + ENDWHILE + ENDPROC diff --git a/Task/Euler-method/C++/euler-method.cpp b/Task/Euler-method/C++/euler-method.cpp new file mode 100644 index 0000000000..2c2b300923 --- /dev/null +++ b/Task/Euler-method/C++/euler-method.cpp @@ -0,0 +1,32 @@ +#include +#include + +typedef double F(double,double); + +/* +Approximates y(t) in y'(t)=f(t,y) with y(a)=y0 and +t=a..b and the step size h. +*/ +void euler(F f, double y0, double a, double b, double h) +{ + double y = y0; + for (double t = a; t < b; t += h) + { + std::cout << std::fixed << std::setprecision(3) << t << " " << y << "\n"; + y += h * f(t, y); + } + std::cout << "done\n"; +} + +// Example: Newton's cooling law +double newtonCoolingLaw(double, double t) +{ + return -0.07 * (t - 20); +} + +int main() +{ + euler(newtonCoolingLaw, 100, 0, 100, 2); + euler(newtonCoolingLaw, 100, 0, 100, 5); + euler(newtonCoolingLaw, 100, 0, 100, 10); +} diff --git a/Task/Euler-method/C-sharp/euler-method.cs b/Task/Euler-method/C-sharp/euler-method.cs new file mode 100644 index 0000000000..9b7d1f041f --- /dev/null +++ b/Task/Euler-method/C-sharp/euler-method.cs @@ -0,0 +1,38 @@ +using System; + +namespace prog +{ + class MainClass + { + const float T0 = 100f; + const float TR = 20f; + const float k = 0.07f; + readonly static float[] delta_t = {2.0f,5.0f,10.0f}; + const int n = 100; + + public delegate float func(float t); + static float NewtonCooling(float t) + { + return -k * (t-TR); + } + + public static void Main (string[] args) + { + func f = new func(NewtonCooling); + for(int i=0; i +#include + +typedef double (*deriv_f)(double, double); +#define FMT " %7.3f" + +void ivp_euler(deriv_f f, double y, int step, int end_t) +{ + int t = 0; + + printf(" Step %2d: ", (int)step); + do { + if (t % 10 == 0) printf(FMT, y); + y += step * f(t, y); + } while ((t += step) <= end_t); + printf("\n"); +} + +void analytic() +{ + double t; + printf(" Time: "); + for (t = 0; t <= 100; t += 10) printf(" %7g", t); + printf("\nAnalytic: "); + + for (t = 0; t <= 100; t += 10) + printf(FMT, 20 + 80 * exp(-0.07 * t)); + printf("\n"); +} + +double cooling(double t, double temp) +{ + return -0.07 * (temp - 20); +} + +int main() +{ + analytic(); + ivp_euler(cooling, 100, 2, 100); + ivp_euler(cooling, 100, 5, 100); + ivp_euler(cooling, 100, 10, 100); + + return 0; +} diff --git a/Task/Euler-method/C/euler-method-2.c b/Task/Euler-method/C/euler-method-2.c new file mode 100644 index 0000000000..6abf7edb0b --- /dev/null +++ b/Task/Euler-method/C/euler-method-2.c @@ -0,0 +1,5 @@ + Time: 0 10 20 30 40 50 60 70 80 90 100 +Analytic: 100.000 59.727 39.728 29.797 24.865 22.416 21.200 20.596 20.296 20.147 20.073 + Step 2: 100.000 57.634 37.704 28.328 23.918 21.843 20.867 20.408 20.192 20.090 20.042 + Step 5: 100.000 53.800 34.280 26.034 22.549 21.077 20.455 20.192 20.081 20.034 20.014 + Step 10: 100.000 44.000 27.200 22.160 20.648 20.194 20.058 20.017 20.005 20.002 20.000 diff --git a/Task/Euler-method/Clay/euler-method.clay b/Task/Euler-method/Clay/euler-method.clay new file mode 100644 index 0000000000..dac4949969 --- /dev/null +++ b/Task/Euler-method/Clay/euler-method.clay @@ -0,0 +1,16 @@ +import printer.formatter as pf; + +euler(f, y, a, b, h) { + while (a < b) { + println(pf.rightAligned(2, a), " ", y); + a += h; + y += h * f(y); + } +} + +main() { + for (i in [2.0, 5.0, 10.0]) { + println("\nFor delta = ", i, ":"); + euler((temp) => -0.07 * (temp - 20), 100.0, 0.0, 100.0, i); + } +} diff --git a/Task/Euler-method/Common-Lisp/euler-method.lisp b/Task/Euler-method/Common-Lisp/euler-method.lisp new file mode 100644 index 0000000000..1c4fcd1101 --- /dev/null +++ b/Task/Euler-method/Common-Lisp/euler-method.lisp @@ -0,0 +1,26 @@ +;; 't' usually means "true" in CL, but we need 't' here for time/temperature. +(defconstant true 'cl:t) +(shadow 't) + + +;; Approximates y(t) in y'(t)=f(t,y) with y(a)=y0 and t=a..b and the step size h. +(defun euler (f y0 a b h) + + ;; Set the initial values and increments of the iteration variables. + (do ((t a (incf t h)) + (y y0 (incf y (* h (funcall f t y))))) + + ;; End the iteration when t reaches the end b of the time interval. + ((>= t b) 'DONE) + + ;; Print t and y(t) at every step of the do loop. + (format true "~6,3F ~6,3F~%" t y))) + + +;; Example: Newton's cooling law, f(t,T) = -0.07*(T-20) +(defun newton-cooling (time T) (* -0.07 (- T 20))) + +;; Generate the data for all three step sizes (2,5 and 10). +(euler #'newton-cooling 100 0 100 2) +(euler #'newton-cooling 100 0 100 5) +(euler #'newton-cooling 100 0 100 10) diff --git a/Task/Euler-method/D/euler-method.d b/Task/Euler-method/D/euler-method.d new file mode 100644 index 0000000000..e88bc47a46 --- /dev/null +++ b/Task/Euler-method/D/euler-method.d @@ -0,0 +1,26 @@ +import std.stdio, std.range; + +/** +Approximates y(t) in y'(t)=f(t,y) with y(a)=y0 and +t=a..b and the step size h. +*/ +void euler(F)(in F f, in double y0, + in double a, in double b, in double h) { + double y = y0; + foreach (t; iota(a, b, h)) { + writefln("%.3f %.3f", t, y); + y += h * f(t, y); + } + writeln("done"); +} + +void main() { + /// Example: Newton's cooling law + static newtonCoolingLaw(in double time, in double t) { + return -0.07 * (t - 20); + } + + euler(&newtonCoolingLaw, 100, 0, 100, 2); + euler(&newtonCoolingLaw, 100, 0, 100, 5); + euler(&newtonCoolingLaw, 100, 0, 100, 10); +} diff --git a/Task/Euler-method/Euler-Math-Toolbox/euler-method.euler b/Task/Euler-method/Euler-Math-Toolbox/euler-method.euler new file mode 100644 index 0000000000..9cd1d565fb --- /dev/null +++ b/Task/Euler-method/Euler-Math-Toolbox/euler-method.euler @@ -0,0 +1,21 @@ +>function dgleuler (f,x,y0) ... +$ y=zeros(size(x)); y[1]=y0; +$ for i=2 to cols(y); +$ y[i]=y[i-1]+f(x[i-1],y[i-1])*(x[i]-x[i-1]); +$ end; +$ return y; +$endfunction +>function f(x,y) := -k*(y-TR) +>k=0.07; TR=20; TS=100; +>x=0:1:100; dgleuler("f",x,TS)[-1] + 20.0564137335 +>x=0:2:100; dgleuler("f",x,TS)[-1] + 20.0424631834 +>TR+(TS-TR)*exp(-k*TS) + 20.0729505572 +>x=0:5:100; plot2d(x,dgleuler("f",x,TS)); ... +> plot2d(x,TR+(TS-TR)*exp(-k*x),>add,color=red); +>ode("f",x,TS)[-1] // Euler default solver LSODA + 20.0729505568 +>adaptiverunge("f",x,TS)[-1] // Adaptive Runge Method + 20.0729505572 diff --git a/Task/Euler-method/Fortran/euler-method.f b/Task/Euler-method/Fortran/euler-method.f new file mode 100644 index 0000000000..71c1352aff --- /dev/null +++ b/Task/Euler-method/Fortran/euler-method.f @@ -0,0 +1,57 @@ +program euler_method +use iso_fortran_env, only: real64 +implicit none + +abstract interface + ! a derivative dy/dt as function of y and t + function derivative(y, t) + use iso_fortran_env, only: real64 + real(real64) :: derivative + real(real64), intent(in) :: t, y + end function +end interface + +real(real64), parameter :: T_0 = 100, T_room = 20, k = 0.07, a = 0, b = 100, & + h(3) = [2.0, 5.0, 10.0] + +integer :: i + +! loop over all step sizes +do i = 1, 3 + call euler(newton_cooling, T_0, a, b, h(i)) +end do + +contains + +! Approximates y(t) in y'(t) = f(y, t) with y(a) = y0 and t = a..b and the +! step size h. +subroutine euler(f, y0, a, b, h) + procedure(derivative) :: f + real(real64), intent(in) :: y0, a, b, h + real(real64) :: t, y + + if (a > b) return + if (h <= 0) stop "negative step size" + + print '("# h = ", F0.3)', h + + y = y0 + t = a + + do + print *, t, y + t = t + h + if (t > b) return + y = y + h * f(y, t) + end do +end subroutine + + +! Example: Newton's cooling law, f(T, _) = -k*(T - T_room) +function newton_cooling(T, unused) result(dTdt) + real(real64) :: dTdt + real(real64), intent(in) :: T, unused + dTdt = -k * (T - T_room) +end function + +end program diff --git a/Task/Euler-method/Go/euler-method.go b/Task/Euler-method/Go/euler-method.go new file mode 100644 index 0000000000..d4dea3c138 --- /dev/null +++ b/Task/Euler-method/Go/euler-method.go @@ -0,0 +1,68 @@ +package main + +import ( + "fmt" + "math" +) + +// fdy is a type for function f used in Euler's method. +type fdy func(float64, float64) float64 + +// eulerStep computes a single new value using Euler's method. +// Note that step size h is a parameter, so a variable step size +// could be used. +func eulerStep(f fdy, x, y, h float64) float64 { + return y + h*f(x, y) +} + +// Definition of cooling rate. Note that this has general utility and +// is not specific to use in Euler's method. + +// newCoolingRate returns a function that computes cooling rate +// for a given cooling rate constant k. +func newCoolingRate(k float64) func(float64) float64 { + return func(deltaTemp float64) float64 { + return -k * deltaTemp + } +} + +// newTempFunc returns a function that computes the analytical solution +// of cooling rate integrated over time. +func newTempFunc(k, ambientTemp, initialTemp float64) func(float64) float64 { + return func(time float64) float64 { + return ambientTemp + (initialTemp-ambientTemp)*math.Exp(-k*time) + } +} + +// newCoolingRateDy returns a function of the kind needed for Euler's method. +// That is, a function representing dy(x, y(x)). +// +// Parameters to newCoolingRateDy are cooling constant k and ambient +// temperature. +func newCoolingRateDy(k, ambientTemp float64) fdy { + crf := newCoolingRate(k) + // note that result is dependent only on the object temperature. + // there are no additional dependencies on time, so the x parameter + // provided by eulerStep is unused. + return func(_, objectTemp float64) float64 { + return crf(objectTemp - ambientTemp) + } +} + +func main() { + k := .07 + tempRoom := 20. + tempObject := 100. + fcr := newCoolingRateDy(k, tempRoom) + analytic := newTempFunc(k, tempRoom, tempObject) + for _, deltaTime := range []float64{2, 5, 10} { + fmt.Printf("Step size = %.1f\n", deltaTime) + fmt.Println(" Time Euler's Analytic") + temp := tempObject + for time := 0.; time <= 100; time += deltaTime { + fmt.Printf("%5.1f %7.3f %7.3f\n", time, temp, analytic(time)) + temp = eulerStep(fcr, time, temp, deltaTime) + } + fmt.Println() + } +} diff --git a/Task/Euler-method/Haskell/euler-method.hs b/Task/Euler-method/Haskell/euler-method.hs new file mode 100644 index 0000000000..bf0cf7f6a7 --- /dev/null +++ b/Task/Euler-method/Haskell/euler-method.hs @@ -0,0 +1,15 @@ +import Text.Printf + +euler :: (Num a, Ord a) => (a -> a -> a) -> a -> a -> a -> a -> [(a,a)] +euler f y0 a b h = + (a, y0) : + if a < b + then euler f (y0 + (f a y0) * h) (a + h) b h + else [] + +newtonCooling :: Double -> Double -> Double +newtonCooling _ t = -0.07 * (t - 20) + +main = do + mapM_ (uncurry $ printf "%6.3f %6.3f\n") $ euler newtonCooling 100 0 100 10 + putStrLn "DONE" diff --git a/Task/Euler-method/Java/euler-method.java b/Task/Euler-method/Java/euler-method.java new file mode 100644 index 0000000000..9b29d16ac9 --- /dev/null +++ b/Task/Euler-method/Java/euler-method.java @@ -0,0 +1,33 @@ +public class Euler { + private static void euler (Callable f, double y0, int a, int b, int h) { + int t = a; + double y = y0; + while (t < b) { + System.out.println ("" + t + " " + y); + t += h; + y += h * f.compute (t, y); + } + System.out.println ("DONE"); + } + + public static void main (String[] args) { + Callable cooling = new Cooling (); + int[] steps = {2, 5, 10}; + for (int stepSize : steps) { + System.out.println ("Step size: " + stepSize); + euler (cooling, 100.0, 0, 100, stepSize); + } + } +} + +// interface used so we can plug in alternative functions to Euler +interface Callable { + public double compute (int time, double t); +} + +// class to implement the newton cooling equation +class Cooling implements Callable { + public double compute (int time, double t) { + return -0.07 * (t - 20); + } +} diff --git a/Task/Euler-method/Lua/euler-method.lua b/Task/Euler-method/Lua/euler-method.lua new file mode 100644 index 0000000000..bd34fd6cc1 --- /dev/null +++ b/Task/Euler-method/Lua/euler-method.lua @@ -0,0 +1,22 @@ +T0 = 100 +TR = 20 +k = 0.07 +delta_t = { 2, 5, 10 } +n = 100 + +NewtonCooling = function( t ) return -k * ( t - TR ) end + + +function Euler( f, y0, n, h ) + local y = y0 + for x = 0, n, h do + print( "", x, y ) + y = y + h * f( y ) + end +end + + +for i = 1, #delta_t do + print( "delta_t = ", delta_t[i] ) + Euler( NewtonCooling, T0, n, delta_t[i] ) +end diff --git a/Task/Euler-method/Perl/euler-method.pl b/Task/Euler-method/Perl/euler-method.pl new file mode 100644 index 0000000000..b951982425 --- /dev/null +++ b/Task/Euler-method/Perl/euler-method.pl @@ -0,0 +1,32 @@ +sub euler_method { + my ($t0, $t1, $k, $step_size) = @_; + my @results = ( [0, $t0] ); + + for (my $s = $step_size; $s <= 100; $s += $step_size) { + $t0 -= ($t0 - $t1) * $k * $step_size; + push @results, [$s, $t0]; + } + + return @results; +} + +sub analytical { + my ($t0, $t1, $k, $time) = @_; + return ($t0 - $t1) * exp(-$time * $k) + $t1 +} + +my ($T0, $T1, $k) = (100, 20, .07); +my @r2 = grep { $_->[0] % 10 == 0 } euler_method($T0, $T1, $k, 2); +my @r5 = grep { $_->[0] % 10 == 0 } euler_method($T0, $T1, $k, 5); +my @r10 = grep { $_->[0] % 10 == 0 } euler_method($T0, $T1, $k, 10); + +print "Time\t 2 err(%) 5 err(%) 10 err(%) Analytic\n", "-" x 76, "\n"; +for (0 .. $#r2) { + my $an = analytical($T0, $T1, $k, $r2[$_][0]); + printf "%4d\t".("%9.3f" x 7)."\n", + $r2 [$_][0], + $r2 [$_][1], ($r2 [$_][1] / $an) * 100 - 100, + $r5 [$_][1], ($r5 [$_][1] / $an) * 100 - 100, + $r10[$_][1], ($r10[$_][1] / $an) * 100 - 100, + $an; +} diff --git a/Task/Euler-method/PicoLisp/euler-method.l b/Task/Euler-method/PicoLisp/euler-method.l new file mode 100644 index 0000000000..e9558fc218 --- /dev/null +++ b/Task/Euler-method/PicoLisp/euler-method.l @@ -0,0 +1,14 @@ +(load "@lib/math.l") + +(de euler (F Y A B H) + (while (> B A) + (prinl (round A) " " (round Y)) + (inc 'Y (*/ H (F A Y) 1.0)) + (inc 'A H) ) ) + +(de newtonCoolingLaw (A B) + (*/ -0.07 (- B 20.) 1.0) ) + +(euler newtonCoolingLaw 100.0 0 100.0 2.0) +(euler newtonCoolingLaw 100.0 0 100.0 5.0) +(euler newtonCoolingLaw 100.0 0 100.0 10.0) diff --git a/Task/Euler-method/Python/euler-method.py b/Task/Euler-method/Python/euler-method.py new file mode 100644 index 0000000000..0b70ae4a33 --- /dev/null +++ b/Task/Euler-method/Python/euler-method.py @@ -0,0 +1,11 @@ +def euler(f,y0,a,b,h): + t,y = a,y0 + while t < b: + print "%6.3f %6.3f" % (t,y) + t += h + y += h * f(t,y) + +def newtoncooling(time, temp): + return -0.07 * (temp - 20) + +euler(newtoncooling,100,0,100,10) diff --git a/Task/Euler-method/Ruby/euler-method.rb b/Task/Euler-method/Ruby/euler-method.rb new file mode 100644 index 0000000000..7199aa2d72 --- /dev/null +++ b/Task/Euler-method/Ruby/euler-method.rb @@ -0,0 +1,10 @@ +def euler(y0,a,b,h, &block) + t,y = a,y0 + while t < b + puts "%6.3f %6.3f" % [t,y] + t += h + y += h * block.call(t,y) + end +end + +euler(100,0,100,10) {|time, temp| -0.07 * (temp - 20) } diff --git a/Task/Euler-method/Scala/euler-method.scala b/Task/Euler-method/Scala/euler-method.scala new file mode 100644 index 0000000000..e3a5c025d5 --- /dev/null +++ b/Task/Euler-method/Scala/euler-method.scala @@ -0,0 +1,29 @@ +object App{ + + def main(args : Array[String]) = { + + def cooling( step : Int ) = { + eulerStep( (step , y) => {-0.07 * (y - 20)} , + 100.0,0,100,step) + } + cooling(10) + cooling(5) + cooling(2) + } + def eulerStep( func : (Int,Double) => Double,y0 : Double, + begin : Int, end : Int , step : Int) = { + + println("Step size: %s".format(step)) + + var current : Int = begin + var y : Double = y0 + while( current <= end){ + println( "%d %.5f".format(current,y)) + current += step + y += step * func(current,y) + } + + println("DONE") + } + +} diff --git a/Task/Euler-method/Tcl/euler-method-1.tcl b/Task/Euler-method/Tcl/euler-method-1.tcl new file mode 100644 index 0000000000..6073ea9839 --- /dev/null +++ b/Task/Euler-method/Tcl/euler-method-1.tcl @@ -0,0 +1,9 @@ +proc euler {f y0 a b h} { + puts "computing $f over \[$a..$b\], step $h" + set y [expr {double($y0)}] + for {set t [expr {double($a)}]} {$t < $b} {set t [expr {$t + $h}]} { + puts [format "%.3f\t%.3f" $t $y] + set y [expr {$y + $h * double([$f $t $y])}] + } + puts "done" +} diff --git a/Task/Euler-method/Tcl/euler-method-2.tcl b/Task/Euler-method/Tcl/euler-method-2.tcl new file mode 100644 index 0000000000..23325d7a41 --- /dev/null +++ b/Task/Euler-method/Tcl/euler-method-2.tcl @@ -0,0 +1,7 @@ +proc newtonCoolingLaw {time temp} { + expr {-0.07 * ($temp - 20)} +} + +euler newtonCoolingLaw 100 0 100 2 +euler newtonCoolingLaw 100 0 100 5 +euler newtonCoolingLaw 100 0 100 10 diff --git a/Task/Evaluate-binomial-coefficients/0DESCRIPTION b/Task/Evaluate-binomial-coefficients/0DESCRIPTION new file mode 100644 index 0000000000..baaf21a714 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/0DESCRIPTION @@ -0,0 +1,6 @@ +This programming task, is to calculate ANY binomial coefficient. + +However, it has to be able to output \binom{5}{3}, which is 10. + +This formula is recommended: +: \binom{n}{k} = \frac{n!}{(n-k)!k!} = \frac{n(n-1)(n-2)\ldots(n-k+1)}{k(k-1)(k-2)\ldots 1} diff --git a/Task/Evaluate-binomial-coefficients/1META.yaml b/Task/Evaluate-binomial-coefficients/1META.yaml new file mode 100644 index 0000000000..8d1c0603c8 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Mathematical operations diff --git a/Task/Evaluate-binomial-coefficients/ACL2/evaluate-binomial-coefficients.acl2 b/Task/Evaluate-binomial-coefficients/ACL2/evaluate-binomial-coefficients.acl2 new file mode 100644 index 0000000000..5e6b3c4401 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/ACL2/evaluate-binomial-coefficients.acl2 @@ -0,0 +1,7 @@ +(defun fac (n) + (if (zp n) + 1 + (* n (fac (1- n))))) + +(defun binom (n k) + (/ (fac n) (* (fac (- n k)) (fac k))) diff --git a/Task/Evaluate-binomial-coefficients/ALGOL-68/evaluate-binomial-coefficients.alg b/Task/Evaluate-binomial-coefficients/ALGOL-68/evaluate-binomial-coefficients.alg new file mode 100644 index 0000000000..e3542eb3c0 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/ALGOL-68/evaluate-binomial-coefficients.alg @@ -0,0 +1,25 @@ +PROC factorial = (INT n)INT: +( + INT result; + + result := 1; + FOR i TO n DO + result *:= i + OD; + + result +); + +PROC choose = (INT n, INT k)INT: +( + INT result; + +# Note: code can be optimised here as k < n # + result := factorial(n) OVER (factorial(k) * factorial(n - k)); + + result +); + +test:( + print((choose(5, 3), new line)) +) diff --git a/Task/Evaluate-binomial-coefficients/Ada/evaluate-binomial-coefficients.ada b/Task/Evaluate-binomial-coefficients/Ada/evaluate-binomial-coefficients.ada new file mode 100644 index 0000000000..e9fb0b57a6 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Ada/evaluate-binomial-coefficients.ada @@ -0,0 +1,27 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure Test_Binomial is + function Binomial (N, K : Natural) return Natural is + Result : Natural := 1; + M : Natural; + begin + if N < K then + raise Constraint_Error; + end if; + if K > N/2 then -- Use symmetry + M := N - K; + else + M := K; + end if; + for I in 1..M loop + Result := Result * (N - M + I) / I; + end loop; + return Result; + end Binomial; +begin + for N in 0..17 loop + for K in 0..N loop + Put (Integer'Image (Binomial (N, K))); + end loop; + New_Line; + end loop; +end Test_Binomial; diff --git a/Task/Evaluate-binomial-coefficients/AppleScript/evaluate-binomial-coefficients.applescript b/Task/Evaluate-binomial-coefficients/AppleScript/evaluate-binomial-coefficients.applescript new file mode 100644 index 0000000000..e610f56665 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/AppleScript/evaluate-binomial-coefficients.applescript @@ -0,0 +1,17 @@ +set n to 5 +set k to 3 + +on calculateFactorial(val) + set partial_factorial to 1 as integer + repeat with i from 1 to val + set factorial to i * partial_factorial + set partial_factorial to factorial + end repeat + return factorial +end calculateFactorial + +set n_factorial to calculateFactorial(n) +set k_factorial to calculateFactorial(k) +set n_minus_k_factorial to calculateFactorial(n - k) + +return n_factorial / (n_minus_k_factorial) * 1 / (k_factorial) as integer diff --git a/Task/Evaluate-binomial-coefficients/AutoHotkey/evaluate-binomial-coefficients.ahk b/Task/Evaluate-binomial-coefficients/AutoHotkey/evaluate-binomial-coefficients.ahk new file mode 100644 index 0000000000..5e1590fa8a --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/AutoHotkey/evaluate-binomial-coefficients.ahk @@ -0,0 +1,12 @@ +MsgBox, % Round(BinomialCoefficient(5, 3)) + +;--------------------------------------------------------------------------- +BinomialCoefficient(n, k) { +;--------------------------------------------------------------------------- + r := 1 + Loop, % k < n - k ? k : n - k { + r *= n - A_Index + 1 + r /= A_Index + } + Return, r +} diff --git a/Task/Evaluate-binomial-coefficients/BBC-BASIC/evaluate-binomial-coefficients.bbc b/Task/Evaluate-binomial-coefficients/BBC-BASIC/evaluate-binomial-coefficients.bbc new file mode 100644 index 0000000000..2202c322d1 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/BBC-BASIC/evaluate-binomial-coefficients.bbc @@ -0,0 +1,20 @@ + @%=&1010 + + PRINT "Binomial (5,3) = "; FNbinomial(5, 3) + PRINT "Binomial (100,2) = "; FNbinomial(100, 2) + PRINT "Binomial (33,17) = "; FNbinomial(33, 17) + END + + DEF FNbinomial(N%, K%) + LOCAL R%, D% + R% = 1 : D% = N% - K% + IF D% > K% THEN K% = D% : D% = N% - K% + WHILE N% > K% + R% *= N% + N% -= 1 + WHILE D% > 1 AND (R% MOD D%) = 0 + R% /= D% + D% -= 1 + ENDWHILE + ENDWHILE + = R% diff --git a/Task/Evaluate-binomial-coefficients/Bracmat/evaluate-binomial-coefficients.bracmat b/Task/Evaluate-binomial-coefficients/Bracmat/evaluate-binomial-coefficients.bracmat new file mode 100644 index 0000000000..9d7fabb56a --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Bracmat/evaluate-binomial-coefficients.bracmat @@ -0,0 +1,16 @@ +(binomial= + n k coef +. !arg:(?n,?k) + & (!n+-1*!k:0 + & !coef*!n*!k^-1:?coef + & !k+-1:?k + & !n+-1:?n + ) + & !coef +); + +binomial$(5,3) +10 diff --git a/Task/Evaluate-binomial-coefficients/Burlesque/evaluate-binomial-coefficients.blq b/Task/Evaluate-binomial-coefficients/Burlesque/evaluate-binomial-coefficients.blq new file mode 100644 index 0000000000..70abc47863 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Burlesque/evaluate-binomial-coefficients.blq @@ -0,0 +1,2 @@ +blsq ) 5 3nr +10 diff --git a/Task/Evaluate-binomial-coefficients/C++/evaluate-binomial-coefficients-1.cpp b/Task/Evaluate-binomial-coefficients/C++/evaluate-binomial-coefficients-1.cpp new file mode 100644 index 0000000000..17ce2ba2d2 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/C++/evaluate-binomial-coefficients-1.cpp @@ -0,0 +1,23 @@ +double Factorial(double nValue) + { + double result = nValue; + double result_next; + double pc = nValue; + do + { + result_next = result*(pc-1); + result = result_next; + pc--; + }while(pc>2); + nValue = result; + return nValue; + } + +double EvaluateBinomialCoefficient(double nValue, double nValue2) + { + double result; + if(nValue2 == 1)return nValue; + result = (Factorial(nValue))/(Factorial(nValue2)*Factorial((nValue - nValue2))); + nValue2 = result; + return nValue2; + } diff --git a/Task/Evaluate-binomial-coefficients/C++/evaluate-binomial-coefficients-2.cpp b/Task/Evaluate-binomial-coefficients/C++/evaluate-binomial-coefficients-2.cpp new file mode 100644 index 0000000000..bd8910a815 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/C++/evaluate-binomial-coefficients-2.cpp @@ -0,0 +1,5 @@ +int main() +{ + cout<<"The Binomial Coefficient of 5, and 3, is equal to: "<< EvaluateBinomialCoefficient(5,3); + cin.get(); +} diff --git a/Task/Evaluate-binomial-coefficients/C/evaluate-binomial-coefficients-1.c b/Task/Evaluate-binomial-coefficients/C/evaluate-binomial-coefficients-1.c new file mode 100644 index 0000000000..24ab611dda --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/C/evaluate-binomial-coefficients-1.c @@ -0,0 +1,27 @@ +#include +#include + +typedef unsigned long ULONG; + +ULONG binomial(ULONG n, ULONG k) +{ + ULONG r = 1, d = n - k; + + /* choose the smaller of k and n - k */ + if (d > k) { k = d; d = n - k; } + + while (n > k) { + if (r >= UINT_MAX / n) return 0; /* overflown */ + r *= n--; + + /* divide (n - k)! as soon as we can to delay overflows */ + while (d > 1 && !(r % d)) r /= d--; + } + return r; +} + +int main() +{ + printf("%lu\n", binomial(5, 3)); + return 0; +} diff --git a/Task/Evaluate-binomial-coefficients/C/evaluate-binomial-coefficients-2.c b/Task/Evaluate-binomial-coefficients/C/evaluate-binomial-coefficients-2.c new file mode 100644 index 0000000000..f599e28b8a --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/C/evaluate-binomial-coefficients-2.c @@ -0,0 +1 @@ +10 diff --git a/Task/Evaluate-binomial-coefficients/Clojure/evaluate-binomial-coefficients.clj b/Task/Evaluate-binomial-coefficients/Clojure/evaluate-binomial-coefficients.clj new file mode 100644 index 0000000000..4dc266d0a8 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Clojure/evaluate-binomial-coefficients.clj @@ -0,0 +1,3 @@ +(defn binomial-coefficient [n k] + (let [rprod (fn [a b] (reduce * (range a (inc b))))] + (/ (rprod (- n k -1) n) (rprod 1 k)))) diff --git a/Task/Evaluate-binomial-coefficients/CoffeeScript/evaluate-binomial-coefficients-1.coffee b/Task/Evaluate-binomial-coefficients/CoffeeScript/evaluate-binomial-coefficients-1.coffee new file mode 100644 index 0000000000..025c550049 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/CoffeeScript/evaluate-binomial-coefficients-1.coffee @@ -0,0 +1,9 @@ +binomial_coefficient = (n, k) -> + result = 1 + for i in [0...k] + result *= (n - i) / (i + 1) + result + +n = 5 +for k in [0..n] + console.log "binomial_coefficient(#{n}, #{k}) = #{binomial_coefficient(n,k)}" diff --git a/Task/Evaluate-binomial-coefficients/CoffeeScript/evaluate-binomial-coefficients-2.coffee b/Task/Evaluate-binomial-coefficients/CoffeeScript/evaluate-binomial-coefficients-2.coffee new file mode 100644 index 0000000000..7e836aac52 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/CoffeeScript/evaluate-binomial-coefficients-2.coffee @@ -0,0 +1,7 @@ +> coffee binomial.coffee +binomial_coefficient(5, 0) = 1 +binomial_coefficient(5, 1) = 5 +binomial_coefficient(5, 2) = 10 +binomial_coefficient(5, 3) = 10 +binomial_coefficient(5, 4) = 5 +binomial_coefficient(5, 5) = 1 diff --git a/Task/Evaluate-binomial-coefficients/Common-Lisp/evaluate-binomial-coefficients.lisp b/Task/Evaluate-binomial-coefficients/Common-Lisp/evaluate-binomial-coefficients.lisp new file mode 100644 index 0000000000..eaf5ea5916 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Common-Lisp/evaluate-binomial-coefficients.lisp @@ -0,0 +1,5 @@ +(defun choose (n k) + (labels ((prod-enum (s e) + (do ((i s (1+ i)) (r 1 (* i r))) ((> i e) r))) + (fact (n) (prod-enum 1 n))) + (/ (prod-enum (- (1+ n) k) n) (fact k)))) diff --git a/Task/Evaluate-binomial-coefficients/D/evaluate-binomial-coefficients.d b/Task/Evaluate-binomial-coefficients/D/evaluate-binomial-coefficients.d new file mode 100644 index 0000000000..21a486d431 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/D/evaluate-binomial-coefficients.d @@ -0,0 +1,16 @@ +import std.stdio, std.bigint; + +T binomial(T)(/*in*/ T n, T k) /*pure nothrow*/ { + if (k > (n / 2)) + k = n - k; + T bc = 1; + foreach (T i; cast(T)2 .. k + 1) + bc = (bc * (n - k + i)) / i; + return bc; +} + +void main() { + foreach (d; [[5, 3], [100, 2], [100, 98]]) + writefln("(%3d %3d) = %s", d[0], d[1], binomial(d[0], d[1])); + writeln("(100 50) = ", binomial(BigInt(100), BigInt(50))); +} diff --git a/Task/Evaluate-binomial-coefficients/Delphi/evaluate-binomial-coefficients.delphi b/Task/Evaluate-binomial-coefficients/Delphi/evaluate-binomial-coefficients.delphi new file mode 100644 index 0000000000..5e500010a6 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Delphi/evaluate-binomial-coefficients.delphi @@ -0,0 +1,28 @@ +program Binomial; + +{$APPTYPE CONSOLE} + +function BinomialCoff(N, K: Cardinal): Cardinal; +var + L: Cardinal; + +begin + if N < K then + Result:= 0 // Error + else begin + if K > N - K then + K:= N - K; // Optimization + Result:= 1; + L:= 0; + while L < K do begin + Result:= Result * (N - L); + Inc(L); + Result:= Result div L; + end; + end; +end; + +begin + Writeln('C(5,3) is ', BinomialCoff(5, 3)); + ReadLn; +end. diff --git a/Task/Evaluate-binomial-coefficients/Erlang/evaluate-binomial-coefficients.erl b/Task/Evaluate-binomial-coefficients/Erlang/evaluate-binomial-coefficients.erl new file mode 100644 index 0000000000..28ee826aad --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Erlang/evaluate-binomial-coefficients.erl @@ -0,0 +1,7 @@ +choose(N, K) when is_integer(N), is_integer(K), (N >= 0), (K >= 0), (N >= K) -> + choose(N, K, 1, 1). + +choose(N, K, K, Acc) -> + (Acc * (N-K+1)) div K; +choose(N, K, I, Acc) -> + choose(N, K, I+1, (Acc * (N-I+1)) div I). diff --git a/Task/Evaluate-binomial-coefficients/Forth/evaluate-binomial-coefficients.fth b/Task/Evaluate-binomial-coefficients/Forth/evaluate-binomial-coefficients.fth new file mode 100644 index 0000000000..04ddbcf95c --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Forth/evaluate-binomial-coefficients.fth @@ -0,0 +1,4 @@ +: choose ( n k -- nCk ) 1 swap 0 ?do over i - i 1+ */ loop nip ; + + 5 3 choose . \ 10 +33 17 choose . \ 1166803110 diff --git a/Task/Evaluate-binomial-coefficients/Fortran/evaluate-binomial-coefficients-1.f b/Task/Evaluate-binomial-coefficients/Fortran/evaluate-binomial-coefficients-1.f new file mode 100644 index 0000000000..de43ce23b8 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Fortran/evaluate-binomial-coefficients-1.f @@ -0,0 +1,31 @@ +program test_choose + + implicit none + + write (*, '(i0)') choose (5, 3) + +contains + + function factorial (n) result (res) + + implicit none + integer, intent (in) :: n + integer :: res + integer :: i + + res = product ((/(i, i = 1, n)/)) + + end function factorial + + function choose (n, k) result (res) + + implicit none + integer, intent (in) :: n + integer, intent (in) :: k + integer :: res + + res = factorial (n) / (factorial (k) * factorial (n - k)) + + end function choose + +end program test_choose diff --git a/Task/Evaluate-binomial-coefficients/Fortran/evaluate-binomial-coefficients-2.f b/Task/Evaluate-binomial-coefficients/Fortran/evaluate-binomial-coefficients-2.f new file mode 100644 index 0000000000..f599e28b8a --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Fortran/evaluate-binomial-coefficients-2.f @@ -0,0 +1 @@ +10 diff --git a/Task/Evaluate-binomial-coefficients/Go/evaluate-binomial-coefficients.go b/Task/Evaluate-binomial-coefficients/Go/evaluate-binomial-coefficients.go new file mode 100644 index 0000000000..4d8d7c580c --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Go/evaluate-binomial-coefficients.go @@ -0,0 +1,7 @@ +package main +import "fmt" +import "math/big" + +func main() { + fmt.Println(new(big.Int).Binomial(5, 3)) +} diff --git a/Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-1.hs b/Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-1.hs new file mode 100644 index 0000000000..268c5ce0ec --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-1.hs @@ -0,0 +1,2 @@ +choose :: (Integral a) => a -> a -> a +choose n k = product [k+1..n] `div` product [1..n-k] diff --git a/Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-2.hs b/Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-2.hs new file mode 100644 index 0000000000..fa5ae73f64 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-2.hs @@ -0,0 +1,2 @@ +> 5 `choose` 3 +10 diff --git a/Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-3.hs b/Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-3.hs new file mode 100644 index 0000000000..589baa6f1e --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Haskell/evaluate-binomial-coefficients-3.hs @@ -0,0 +1,2 @@ +choose :: (Integral a) => a -> a -> a +choose n k = foldl (\z i -> (z * (n-i+1)) `div` i) 1 [1..k] diff --git a/Task/Evaluate-binomial-coefficients/Java/evaluate-binomial-coefficients-1.java b/Task/Evaluate-binomial-coefficients/Java/evaluate-binomial-coefficients-1.java new file mode 100644 index 0000000000..61720ea8a6 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Java/evaluate-binomial-coefficients-1.java @@ -0,0 +1,17 @@ +public class Binom { + + static long combinations(int n, int k) { + long coeff = 1; + for (int i = n - k + 1; i <= n; i++) { + coeff *= i; + } + for (int i = 1; i <= k; i++) { + coeff /= i; + } + return coeff; + } + + public static void main(String[] args){ + System.out.println(combinations(5, 3)); + } +} diff --git a/Task/Evaluate-binomial-coefficients/Java/evaluate-binomial-coefficients-2.java b/Task/Evaluate-binomial-coefficients/Java/evaluate-binomial-coefficients-2.java new file mode 100644 index 0000000000..33cc125459 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Java/evaluate-binomial-coefficients-2.java @@ -0,0 +1,13 @@ +public class Binom { + public static double binomCoeff(double n, double k) { + double result = 1; + for (int i = 1; i < k + 1; i++) { + result *= (n - i + 1) / i; + } + return result; + } + + public static void main(String[] args) { + System.out.println(binomCoeff(5, 3)); + } +} diff --git a/Task/Evaluate-binomial-coefficients/JavaScript/evaluate-binomial-coefficients.js b/Task/Evaluate-binomial-coefficients/JavaScript/evaluate-binomial-coefficients.js new file mode 100644 index 0000000000..8e7b4fdfda --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/JavaScript/evaluate-binomial-coefficients.js @@ -0,0 +1,7 @@ +function binom(n, k) { + var coeff = 1; + for (var i = n-k+1; i <= n; i++) coeff *= i; + for (var i = 1; i <= k; i++) coeff /= i; + return coeff; +} +print(binom(5,3)); diff --git a/Task/Evaluate-binomial-coefficients/Lua/evaluate-binomial-coefficients.lua b/Task/Evaluate-binomial-coefficients/Lua/evaluate-binomial-coefficients.lua new file mode 100644 index 0000000000..8699861077 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Lua/evaluate-binomial-coefficients.lua @@ -0,0 +1,11 @@ +function Binomial( n, k ) + if k > n then return nil end + if k > n/2 then k = n - k end -- (n k) = (n n-k) + + numer, denom = 1, 1 + for i = 1, k do + numer = numer * ( n - i + 1 ) + denom = denom * i + end + return numer / denom +end diff --git a/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-1.m b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-1.m new file mode 100644 index 0000000000..13d4f94c69 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-1.m @@ -0,0 +1,3 @@ +>> nchoosek(5,3) +ans = + 10 diff --git a/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-2.m b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-2.m new file mode 100644 index 0000000000..cc030058a9 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-2.m @@ -0,0 +1,4 @@ +function r = binomcoeff1(n,k) + r = diag(rot90(pascal(n+1))); % vector of all binomial coefficients for order n + r = r(k); +end; diff --git a/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-3.m b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-3.m new file mode 100644 index 0000000000..8cd26c666f --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-3.m @@ -0,0 +1,3 @@ +function r = binomcoeff2(n,k) + prod((n-k+1:n)./(1:k)) +end; diff --git a/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-4.m b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-4.m new file mode 100644 index 0000000000..de208e317f --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-4.m @@ -0,0 +1,4 @@ +function r = binomcoeff3(n,k) + m = pascal(max(n-k,k)+1); + r = m(n-k+1,k+1); +end; diff --git a/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-5.m b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-5.m new file mode 100644 index 0000000000..3b0692db26 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-5.m @@ -0,0 +1,21 @@ +function coefficients = binomialCoeff(n,k) + + coefficients = zeros(numel(n),numel(k)); %Preallocate memory + + columns = (1:numel(k)); %Preallocate row and column counters + rows = (1:numel(n)); + + %Iterate over every row and column. The rows represent the n number, + %and the columns represent the k number. If n is ever greater than k, + %the nchoosek function will throw an error. So, we test to make sure + %it isn't, if it is then we leave that entry in the coefficients matrix + %zero. Which makes sense combinatorically. + for row = rows + for col = columns + if k(col) <= n(row) + coefficients(row,col) = nchoosek(n(row),k(col)); + end + end + end + +end %binomialCoeff diff --git a/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-6.m b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-6.m new file mode 100644 index 0000000000..dad5e8c27a --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/MATLAB/evaluate-binomial-coefficients-6.m @@ -0,0 +1,40 @@ +>> binomialCoeff((0:5),(0:5)) + +ans = + + 1 0 0 0 0 0 + 1 1 0 0 0 0 + 1 2 1 0 0 0 + 1 3 3 1 0 0 + 1 4 6 4 1 0 + 1 5 10 10 5 1 + +>> binomialCoeff([1 0 3 2],(0:3)) + +ans = + + 1 1 0 0 + 1 0 0 0 + 1 3 3 1 + 1 2 1 0 + +>> binomialCoeff(3,(0:3)) + +ans = + + 1 3 3 1 + +>> binomialCoeff((0:3),2) + +ans = + + 0 + 0 + 1 + 3 + +>> binomialCoeff(5,3) + +ans = + + 10 diff --git a/Task/Evaluate-binomial-coefficients/PHP/evaluate-binomial-coefficients-1.php b/Task/Evaluate-binomial-coefficients/PHP/evaluate-binomial-coefficients-1.php new file mode 100644 index 0000000000..4ca6022c56 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/PHP/evaluate-binomial-coefficients-1.php @@ -0,0 +1,10 @@ +1;$f*=$val--); + return $f; +} +$binomial_coefficient=factorial($n)/(factorial($k)*factorial($n-$k)); +echo $binomial_coefficient; +?> diff --git a/Task/Evaluate-binomial-coefficients/PHP/evaluate-binomial-coefficients-2.php b/Task/Evaluate-binomial-coefficients/PHP/evaluate-binomial-coefficients-2.php new file mode 100644 index 0000000000..32ecf00eb0 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/PHP/evaluate-binomial-coefficients-2.php @@ -0,0 +1,8 @@ +function binomial_coefficient($n, $k) { + if ($k == 0) return 1; + $result = 1; + foreach (range(0, $k - 1) as $i) { + $result *= ($n - $i) / ($i + 1); + } + return $result; +} diff --git a/Task/Evaluate-binomial-coefficients/Perl/evaluate-binomial-coefficients.pl b/Task/Evaluate-binomial-coefficients/Perl/evaluate-binomial-coefficients.pl new file mode 100644 index 0000000000..05b018bf4d --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Perl/evaluate-binomial-coefficients.pl @@ -0,0 +1,8 @@ +sub binomial { + use bigint; + my ($r, $n, $k) = (1, @_); + for (1 .. $k) { $r *= $n + 1 - $_, $r /= $_ } + $r; +} + +print binomial(30, 13); diff --git a/Task/Evaluate-binomial-coefficients/PicoLisp/evaluate-binomial-coefficients.l b/Task/Evaluate-binomial-coefficients/PicoLisp/evaluate-binomial-coefficients.l new file mode 100644 index 0000000000..2b817128ee --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/PicoLisp/evaluate-binomial-coefficients.l @@ -0,0 +1,3 @@ +(de binomial (N K) + (let f '((N) (apply * (range 1 N))) + (/ (f N) (* (f (- N K)) (f K))) ) ) diff --git a/Task/Evaluate-binomial-coefficients/Python/evaluate-binomial-coefficients-1.py b/Task/Evaluate-binomial-coefficients/Python/evaluate-binomial-coefficients-1.py new file mode 100644 index 0000000000..eb139e4622 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Python/evaluate-binomial-coefficients-1.py @@ -0,0 +1,8 @@ +def binomialCoeff(n, k): + result = 1 + for i in range(1, k+1): + result = result * (n-i+1) / i + return result + +if __name__ == "__main__": + print(binomialCoeff(5, 3)) diff --git a/Task/Evaluate-binomial-coefficients/Python/evaluate-binomial-coefficients-2.py b/Task/Evaluate-binomial-coefficients/Python/evaluate-binomial-coefficients-2.py new file mode 100644 index 0000000000..a8b3aa1a2b --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Python/evaluate-binomial-coefficients-2.py @@ -0,0 +1,17 @@ +from operator import mul +def comb(n,r): + ''' calculate nCr - the binomial coefficient + >>> comb(3,2) + 3 + >>> comb(9,4) + 126 + >>> comb(9,6) + 84 + >>> comb(20,14) + 38760 + ''' + + if r > n-r: # for smaller intermediate values + r = n-r + return int( reduce( mul, range((n-r+1), n+1), 1) / + reduce( mul, range(1,r+1), 1) ) diff --git a/Task/Evaluate-binomial-coefficients/R/evaluate-binomial-coefficients-1.r b/Task/Evaluate-binomial-coefficients/R/evaluate-binomial-coefficients-1.r new file mode 100644 index 0000000000..77351d6616 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/R/evaluate-binomial-coefficients-1.r @@ -0,0 +1 @@ +choose(5,3) diff --git a/Task/Evaluate-binomial-coefficients/R/evaluate-binomial-coefficients-2.r b/Task/Evaluate-binomial-coefficients/R/evaluate-binomial-coefficients-2.r new file mode 100644 index 0000000000..715a58cc3b --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/R/evaluate-binomial-coefficients-2.r @@ -0,0 +1 @@ +[1] 10 diff --git a/Task/Evaluate-binomial-coefficients/REXX/evaluate-binomial-coefficients.rexx b/Task/Evaluate-binomial-coefficients/REXX/evaluate-binomial-coefficients.rexx new file mode 100644 index 0000000000..9b757625f0 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/REXX/evaluate-binomial-coefficients.rexx @@ -0,0 +1,12 @@ +/*REXX program calculates binomial coefficients (aka, combinations). */ + +numeric digits 100000 +parse arg n k . +say 'combinations('n","k') =' comb(n,k) +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────COMB subroutine─────────────────────*/ +comb: procedure; parse arg x,y; return fact(x) / (fact(x-y) * fact(y)) + +/*──────────────────────────────────FACT subroutine─────────────────────*/ +fact: procedure; parse arg z; !=1; do j=2 to z; !=!*j; end; return ! diff --git a/Task/Evaluate-binomial-coefficients/Racket/evaluate-binomial-coefficients.rkt b/Task/Evaluate-binomial-coefficients/Racket/evaluate-binomial-coefficients.rkt new file mode 100644 index 0000000000..e0d7894c8f --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Racket/evaluate-binomial-coefficients.rkt @@ -0,0 +1,3 @@ +#lang racket +(require math) +(binomial 10 5) diff --git a/Task/Evaluate-binomial-coefficients/Ruby/evaluate-binomial-coefficients-1.rb b/Task/Evaluate-binomial-coefficients/Ruby/evaluate-binomial-coefficients-1.rb new file mode 100644 index 0000000000..373c24f12b --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Ruby/evaluate-binomial-coefficients-1.rb @@ -0,0 +1,13 @@ +class Integer + # binomial coefficient: n C k + def choose(k) + # n!/(n-k)! + pTop = (self-k+1 .. self).inject(1, &:*) + # k! + pBottom = (2 .. k).inject(1, &:*) + pTop / pBottom + end +end + +p 5.choose(3) +p 60.choose(30) diff --git a/Task/Evaluate-binomial-coefficients/Ruby/evaluate-binomial-coefficients-2.rb b/Task/Evaluate-binomial-coefficients/Ruby/evaluate-binomial-coefficients-2.rb new file mode 100644 index 0000000000..1ccdc7814f --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Ruby/evaluate-binomial-coefficients-2.rb @@ -0,0 +1,3 @@ +def c n, r + (0...r).inject(1) do |m,i| (m * (n - i)) / (i + 1) end +end diff --git a/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-1.scala b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-1.scala new file mode 100644 index 0000000000..795192fa36 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-1.scala @@ -0,0 +1,11 @@ +object Binomial { + def main(args: Array[String]): Unit = { + val n=5 + val k=3 + val result=binomialCoefficient(n,k) + println("The Binomial Coefficient of %d and %d equals %d.".format(n, k, result)) + } + + def binomialCoefficient(n:Int, k:Int)=fact(n) / (fact(k) * fact(n-k)) + def fact(n:Int):Int=if (n==0) 1 else n*fact(n-1) +} diff --git a/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-2.scala b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-2.scala new file mode 100644 index 0000000000..96ed2661b5 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-2.scala @@ -0,0 +1 @@ +The Binomial Coefficient of 5 and 3 equals 10. diff --git a/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-3.scala b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-3.scala new file mode 100644 index 0000000000..c7b522d493 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-3.scala @@ -0,0 +1,8 @@ +object Binomial extends App { + def binomialCoefficient(n: Int, k: Int) = + (BigInt(n - k + 1) to n).product / + (BigInt(1) to k).product + + val Array(n, k) = args.map(_.toInt) + println("The Binomial Coefficient of %d and %d equals %,3d.".format(n, k, binomialCoefficient(n, k))) +} diff --git a/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-4.scala b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-4.scala new file mode 100644 index 0000000000..28da26ccbf --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-4.scala @@ -0,0 +1,2 @@ +java Binomial 100 30 +The Binomial Coefficient of 100 and 30 equals 29,372,339,821,610,944,823,963,760. diff --git a/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-5.scala b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-5.scala new file mode 100644 index 0000000000..7d60043fd9 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-5.scala @@ -0,0 +1,6 @@ + def bico(n: Long, k: Long): Long = (n, k) match { + case (n, 0) => 1 + case (0, k) => 0 + case (n, k) => bico(n - 1, k - 1) + bico(n - 1, k) + } + println("bico(5,3) = " + bico(5, 3)) diff --git a/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-6.scala b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-6.scala new file mode 100644 index 0000000000..3cdcdec3e1 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Scala/evaluate-binomial-coefficients-6.scala @@ -0,0 +1 @@ +bico(5,3) = 10 diff --git a/Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-1.ss b/Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-1.ss new file mode 100644 index 0000000000..7cb1067ef0 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-1.ss @@ -0,0 +1,12 @@ +(define (factorial n) + (define (*factorial n acc) + (if (zero? n) + acc + (*factorial (- n 1) (* acc n)))) + (*factorial n 1)) + +(define (choose n k) + (/ (factorial n) (* (factorial k) (factorial (- n k))))) + +(display (choose 5 3)) +(newline) diff --git a/Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-2.ss b/Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-2.ss new file mode 100644 index 0000000000..f599e28b8a --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Scheme/evaluate-binomial-coefficients-2.ss @@ -0,0 +1 @@ +10 diff --git a/Task/Evaluate-binomial-coefficients/Tcl/evaluate-binomial-coefficients-1.tcl b/Task/Evaluate-binomial-coefficients/Tcl/evaluate-binomial-coefficients-1.tcl new file mode 100644 index 0000000000..f2cc4f36ad --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Tcl/evaluate-binomial-coefficients-1.tcl @@ -0,0 +1,17 @@ +package require Tcl 8.5 +proc binom {n k} { + # Compute the top half of the division; this is n!/(n-k)! + set pTop 1 + for {set i $n} {$i > $n - $k} {incr i -1} { + set pTop [expr {$pTop * $i}] + } + + # Compute the bottom half of the division; this is k! + set pBottom 1 + for {set i $k} {$i > 1} {incr i -1} { + set pBottom [expr {$pBottom * $i}] + } + + # Integer arithmetic divide is correct here; the factors always cancel out + return [expr {$pTop / $pBottom}] +} diff --git a/Task/Evaluate-binomial-coefficients/Tcl/evaluate-binomial-coefficients-2.tcl b/Task/Evaluate-binomial-coefficients/Tcl/evaluate-binomial-coefficients-2.tcl new file mode 100644 index 0000000000..32ff38f076 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Tcl/evaluate-binomial-coefficients-2.tcl @@ -0,0 +1,2 @@ +puts "5_C_3 = [binom 5 3]" +puts "60_C_30 = [binom 60 30]" diff --git a/Task/Even-or-odd/0815/even-or-odd.0815 b/Task/Even-or-odd/0815/even-or-odd.0815 new file mode 100644 index 0000000000..a7b17dcdbe --- /dev/null +++ b/Task/Even-or-odd/0815/even-or-odd.0815 @@ -0,0 +1,2 @@ +}:s:|=<:2:x~#:e:=/~%~<:20:~$=<:73:x<:69:~$~$~<:20:~$=^:o:<:65: +x<:76:=$=$~$<:6E:~$<:a:~$^:s:}:o:<:6F:x<:64:x~$~$$<:a:~$^:s: diff --git a/Task/Even-or-odd/0DESCRIPTION b/Task/Even-or-odd/0DESCRIPTION new file mode 100644 index 0000000000..f5dc4f4be0 --- /dev/null +++ b/Task/Even-or-odd/0DESCRIPTION @@ -0,0 +1,10 @@ +Test whether an integer is even or odd. + +There is more than one way to solve this task: + +* Use the even and odd predicates, if the language provides them. +* Check the least significant digit. With binary integers, ''i [[bitwise operations|bitwise-and]] 1'' equals 0 [[wikt:iff|iff]] ''i'' is even, or equals 1 iff ''i'' is odd. +* Divide ''i'' by 2. The remainder equals 0 iff ''i'' is even. The remainder equals +1 or -1 iff ''i'' is odd. +* Use modular congruences: +** ''i'' ≡ 0 (mod 2) iff ''i'' is even. +** ''i'' ≡ 1 (mod 2) iff ''i'' is odd. diff --git a/Task/Even-or-odd/AWK/even-or-odd.awk b/Task/Even-or-odd/AWK/even-or-odd.awk new file mode 100644 index 0000000000..b67052d73b --- /dev/null +++ b/Task/Even-or-odd/AWK/even-or-odd.awk @@ -0,0 +1,7 @@ +function isodd(x) { + return (x%2)!=0; +} + +function iseven(x) { + return (x%2)==0; +} diff --git a/Task/Even-or-odd/Ada/even-or-odd.ada b/Task/Even-or-odd/Ada/even-or-odd.ada new file mode 100644 index 0000000000..e3cf2a03cb --- /dev/null +++ b/Task/Even-or-odd/Ada/even-or-odd.ada @@ -0,0 +1,15 @@ +-- Ada has bitwise operators in package Interfaces, +-- but they work with Interfaces.Unsigned_*** types only. +-- Use rem or mod for Integer types, and let the compiler +-- optimize it. +declare + N : Integer := 5; +begin + if N rem 2 = 0 then + Put_Line ("Even number"); + elseif N rem 2 /= 0 then + Put_Line ("Odd number"); + else + Put_Line ("Something went really wrong!"); + end if; +end; diff --git a/Task/Even-or-odd/AutoHotkey/even-or-odd.ahk b/Task/Even-or-odd/AutoHotkey/even-or-odd.ahk new file mode 100644 index 0000000000..03b664a440 --- /dev/null +++ b/Task/Even-or-odd/AutoHotkey/even-or-odd.ahk @@ -0,0 +1,5 @@ +if ( int & 1 ){ + ; do odd stuff +}else{ + ; do even stuff +} diff --git a/Task/Even-or-odd/BASIC/even-or-odd.bas b/Task/Even-or-odd/BASIC/even-or-odd.bas new file mode 100644 index 0000000000..bb29b4f56b --- /dev/null +++ b/Task/Even-or-odd/BASIC/even-or-odd.bas @@ -0,0 +1,4 @@ +10 INPUT "ENTER A NUMBER: ";N +20 IF N/2 <> INT(N/2) THEN PRINT "THE NUMBER IS ODD":GOTO 40 +30 PRINT "THE NUMBER IS EVEN" +40 END diff --git a/Task/Even-or-odd/BBC-BASIC/even-or-odd.bbc b/Task/Even-or-odd/BBC-BASIC/even-or-odd.bbc new file mode 100644 index 0000000000..c46727f99a --- /dev/null +++ b/Task/Even-or-odd/BBC-BASIC/even-or-odd.bbc @@ -0,0 +1,13 @@ +=={{header|BBC BASIC}}== +{{works with|BBC BASIC for Windows}} + IF FNisodd%(14) PRINT "14 is odd" ELSE PRINT "14 is even" + IF FNisodd%(15) PRINT "15 is odd" ELSE PRINT "15 is even" + IF FNisodd#(9876543210#) PRINT "9876543210 is odd" ELSE PRINT "9876543210 is even" + IF FNisodd#(9876543211#) PRINT "9876543211 is odd" ELSE PRINT "9876543211 is even" + END + + REM Works for -2^31 <= n% < 2^31 + DEF FNisodd%(n%) = (n% AND 1) <> 0 + + REM Works for -2^53 <= n# <= 2^53 + DEF FNisodd#(n#) = n# <> 2 * INT(n# / 2) diff --git a/Task/Even-or-odd/Bracmat/even-or-odd.bracmat b/Task/Even-or-odd/Bracmat/even-or-odd.bracmat new file mode 100644 index 0000000000..e33ebbe11d --- /dev/null +++ b/Task/Even-or-odd/Bracmat/even-or-odd.bracmat @@ -0,0 +1,29 @@ +( ( even + = + . @( !arg + : ? + [-2 + ( 0 + | 2 + | 4 + | 6 + | 8 + ) + ) + ) +& (odd=.~(even$!arg)) +& ( eventest + = + . out + $ (!arg is (even$!arg&|not) even) + ) +& ( oddtest + = + . out + $ (!arg is (odd$!arg&|not) odd) + ) +& eventest$5556 +& oddtest$5556 +& eventest$857234098750432987502398457089435 +& oddtest$857234098750432987502398457089435 +) diff --git a/Task/Even-or-odd/Brainf---/even-or-odd-1.bf b/Task/Even-or-odd/Brainf---/even-or-odd-1.bf new file mode 100644 index 0000000000..ac99e4eda4 --- /dev/null +++ b/Task/Even-or-odd/Brainf---/even-or-odd-1.bf @@ -0,0 +1,8 @@ +,[>,----------] Read until newline +++< Get a 2 and move into position +[->-[>+>>]> Do +[+[-<+>]>+>>] divmod +<<<<<] magic +>[-]<++++++++ Clear and get an 8 +[>++++++<-] to get a 48 +>[>+<-]>. to get n % 2 to ASCII and print diff --git a/Task/Even-or-odd/Brainf---/even-or-odd-2.bf b/Task/Even-or-odd/Brainf---/even-or-odd-2.bf new file mode 100644 index 0000000000..8b95e4a854 --- /dev/null +++ b/Task/Even-or-odd/Brainf---/even-or-odd-2.bf @@ -0,0 +1 @@ +,[>,----------]<[--] diff --git a/Task/Even-or-odd/Burlesque/even-or-odd.blq b/Task/Even-or-odd/Burlesque/even-or-odd.blq new file mode 100644 index 0000000000..87dec5d194 --- /dev/null +++ b/Task/Even-or-odd/Burlesque/even-or-odd.blq @@ -0,0 +1 @@ +2.% diff --git a/Task/Even-or-odd/C++/even-or-odd.cpp b/Task/Even-or-odd/C++/even-or-odd.cpp new file mode 100644 index 0000000000..9ade0cfe0c --- /dev/null +++ b/Task/Even-or-odd/C++/even-or-odd.cpp @@ -0,0 +1,6 @@ +bool isEven(int Value){ + if((x % 2) == 0){ + return true; + } + return false; +} diff --git a/Task/Even-or-odd/C/even-or-odd-1.c b/Task/Even-or-odd/C/even-or-odd-1.c new file mode 100644 index 0000000000..ba9b3466de --- /dev/null +++ b/Task/Even-or-odd/C/even-or-odd-1.c @@ -0,0 +1,5 @@ +if (x & 1) { + /* x is odd */ +} else { + /* or not */ +} diff --git a/Task/Even-or-odd/C/even-or-odd-2.c b/Task/Even-or-odd/C/even-or-odd-2.c new file mode 100644 index 0000000000..5fe3d84570 --- /dev/null +++ b/Task/Even-or-odd/C/even-or-odd-2.c @@ -0,0 +1,4 @@ +mpz_t x; +... +if (mpz_even_p(x)) { /* x is even */ } +if (mpz_odd_p(x)) { /* x is odd */ } diff --git a/Task/Even-or-odd/Clojure/even-or-odd.clj b/Task/Even-or-odd/Clojure/even-or-odd.clj new file mode 100644 index 0000000000..75d0ec88bc --- /dev/null +++ b/Task/Even-or-odd/Clojure/even-or-odd.clj @@ -0,0 +1,2 @@ +(if (even? some-var) (do-even-stuff)) +(if (odd? some-var) (do-odd-stuff)) diff --git a/Task/Even-or-odd/Common-Lisp/even-or-odd.lisp b/Task/Even-or-odd/Common-Lisp/even-or-odd.lisp new file mode 100644 index 0000000000..a1f5a14c7d --- /dev/null +++ b/Task/Even-or-odd/Common-Lisp/even-or-odd.lisp @@ -0,0 +1,2 @@ +(if (evenp some-var) (do-even-stuff)) +(if (oddp some-other-var) (do-odd-stuff)) diff --git a/Task/Even-or-odd/D/even-or-odd.d b/Task/Even-or-odd/D/even-or-odd.d new file mode 100644 index 0000000000..c934cb72fd --- /dev/null +++ b/Task/Even-or-odd/D/even-or-odd.d @@ -0,0 +1,6 @@ +import std.stdio, std.bigint; + +void main() { + foreach (i; -5 .. 6) + writeln(i, " ", i & 1, " ", i % 2, " ", BigInt(i) % 2); +} diff --git a/Task/Even-or-odd/DWScript/even-or-odd-1.dwscript b/Task/Even-or-odd/DWScript/even-or-odd-1.dwscript new file mode 100644 index 0000000000..759383d1f3 --- /dev/null +++ b/Task/Even-or-odd/DWScript/even-or-odd-1.dwscript @@ -0,0 +1 @@ +var isOdd := Odd(i); diff --git a/Task/Even-or-odd/DWScript/even-or-odd-2.dwscript b/Task/Even-or-odd/DWScript/even-or-odd-2.dwscript new file mode 100644 index 0000000000..1c62a2df09 --- /dev/null +++ b/Task/Even-or-odd/DWScript/even-or-odd-2.dwscript @@ -0,0 +1 @@ +var isOdd := (i and 1)<>0; diff --git a/Task/Even-or-odd/DWScript/even-or-odd-3.dwscript b/Task/Even-or-odd/DWScript/even-or-odd-3.dwscript new file mode 100644 index 0000000000..b346f23133 --- /dev/null +++ b/Task/Even-or-odd/DWScript/even-or-odd-3.dwscript @@ -0,0 +1 @@ +var isOdd := (i mod 2)=1; diff --git a/Task/Even-or-odd/Euphoria/even-or-odd.euphoria b/Task/Even-or-odd/Euphoria/even-or-odd.euphoria new file mode 100644 index 0000000000..eb78d6f363 --- /dev/null +++ b/Task/Even-or-odd/Euphoria/even-or-odd.euphoria @@ -0,0 +1,5 @@ +include std/math.e + +for i = 1 to 10 do + ? {i, is_even(i)} +end for diff --git a/Task/Even-or-odd/Forth/even-or-odd.fth b/Task/Even-or-odd/Forth/even-or-odd.fth new file mode 100644 index 0000000000..8cd1ec52d2 --- /dev/null +++ b/Task/Even-or-odd/Forth/even-or-odd.fth @@ -0,0 +1 @@ +: odd? ( n -- ? ) 1 and ; diff --git a/Task/Even-or-odd/Go/even-or-odd.go b/Task/Even-or-odd/Go/even-or-odd.go new file mode 100644 index 0000000000..2115b2e474 --- /dev/null +++ b/Task/Even-or-odd/Go/even-or-odd.go @@ -0,0 +1,48 @@ +package main + +import ( + "fmt" + "math/big" +) + +func main() { + test(-2) + test(-1) + test(0) + test(1) + test(2) + testBig("-222222222222222222222222222222222222") + testBig("-1") + testBig("0") + testBig("1") + testBig("222222222222222222222222222222222222") +} + +func test(n int) { + fmt.Printf("Testing integer %3d: ", n) + // & 1 is a good way to test + if n&1 == 0 { + fmt.Print("even ") + } else { + fmt.Print(" odd ") + } + // Careful when using %: negative n % 2 returns -1. So, the code below + // works, but can be broken by someone thinking they can reverse the + // test by testing n % 2 == 1. The valid reverse test is n % 2 != 0. + if n%2 == 0 { + fmt.Println("even") + } else { + fmt.Println(" odd") + } +} + +func testBig(s string) { + b, _ := new(big.Int).SetString(s, 10) + fmt.Printf("Testing big integer %v: ", b) + // the Bit function is the only sensible test for big ints. + if b.Bit(0) == 0 { + fmt.Println("even") + } else { + fmt.Println("odd") + } +} diff --git a/Task/Even-or-odd/Haskell/even-or-odd.hs b/Task/Even-or-odd/Haskell/even-or-odd.hs new file mode 100644 index 0000000000..06fcc77e9c --- /dev/null +++ b/Task/Even-or-odd/Haskell/even-or-odd.hs @@ -0,0 +1,8 @@ +Prelude> even 5 +False +Prelude> even 42 +True +Prelude> odd 5 +True +Prelude> odd 42 +False diff --git a/Task/Even-or-odd/Java/even-or-odd-1.java b/Task/Even-or-odd/Java/even-or-odd-1.java new file mode 100644 index 0000000000..7bb1aecc1e --- /dev/null +++ b/Task/Even-or-odd/Java/even-or-odd-1.java @@ -0,0 +1,3 @@ +public static boolean isEven(int i){ + return (i & 1) == 0; +} diff --git a/Task/Even-or-odd/Java/even-or-odd-2.java b/Task/Even-or-odd/Java/even-or-odd-2.java new file mode 100644 index 0000000000..efb6a8327f --- /dev/null +++ b/Task/Even-or-odd/Java/even-or-odd-2.java @@ -0,0 +1,3 @@ +public static boolean isEven(int i){ + return (i % 2) == 0; +} diff --git a/Task/Even-or-odd/Java/even-or-odd-3.java b/Task/Even-or-odd/Java/even-or-odd-3.java new file mode 100644 index 0000000000..1b684a623b --- /dev/null +++ b/Task/Even-or-odd/Java/even-or-odd-3.java @@ -0,0 +1,3 @@ +public static boolean isEven(BigInteger i){ + return i.and(BigInteger.ONE).equals(BigInteger.ZERO); +} diff --git a/Task/Even-or-odd/Java/even-or-odd-4.java b/Task/Even-or-odd/Java/even-or-odd-4.java new file mode 100644 index 0000000000..4f14958f0f --- /dev/null +++ b/Task/Even-or-odd/Java/even-or-odd-4.java @@ -0,0 +1,3 @@ +public static boolean isEven(BigInteger i){ + return !i.testBit(0); +} diff --git a/Task/Even-or-odd/Java/even-or-odd-5.java b/Task/Even-or-odd/Java/even-or-odd-5.java new file mode 100644 index 0000000000..0063e90220 --- /dev/null +++ b/Task/Even-or-odd/Java/even-or-odd-5.java @@ -0,0 +1,3 @@ +public static boolean isEven(BigInteger i){ + return i.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO); +} diff --git a/Task/Even-or-odd/JavaScript/even-or-odd.js b/Task/Even-or-odd/JavaScript/even-or-odd.js new file mode 100644 index 0000000000..0c4efc81d1 --- /dev/null +++ b/Task/Even-or-odd/JavaScript/even-or-odd.js @@ -0,0 +1,3 @@ +function isEven( i ) { + return i % 2 === 0; +} diff --git a/Task/Even-or-odd/Lua/even-or-odd.lua b/Task/Even-or-odd/Lua/even-or-odd.lua new file mode 100644 index 0000000000..684411e954 --- /dev/null +++ b/Task/Even-or-odd/Lua/even-or-odd.lua @@ -0,0 +1,9 @@ +-- test for even number +if n % 2 == 0 then + print "The number is even" +end + +-- test for odd number +if not (n % 2 == 0) then + print "The number is odd" +end diff --git a/Task/Even-or-odd/MATLAB/even-or-odd-1.m b/Task/Even-or-odd/MATLAB/even-or-odd-1.m new file mode 100644 index 0000000000..92bcf2f65a --- /dev/null +++ b/Task/Even-or-odd/MATLAB/even-or-odd-1.m @@ -0,0 +1,2 @@ + isOdd = logical(bitand(N,1)); + isEven = ~logical(bitand(N,1)); diff --git a/Task/Even-or-odd/MATLAB/even-or-odd-2.m b/Task/Even-or-odd/MATLAB/even-or-odd-2.m new file mode 100644 index 0000000000..6892c693f6 --- /dev/null +++ b/Task/Even-or-odd/MATLAB/even-or-odd-2.m @@ -0,0 +1,2 @@ + isOdd = logical(rem(N,2)); + isEven = ~logical(rem(N,2)); diff --git a/Task/Even-or-odd/MATLAB/even-or-odd-3.m b/Task/Even-or-odd/MATLAB/even-or-odd-3.m new file mode 100644 index 0000000000..0ab26c6771 --- /dev/null +++ b/Task/Even-or-odd/MATLAB/even-or-odd-3.m @@ -0,0 +1,2 @@ + isOdd = logical(mod(N,2)); + isEven = ~logical(mod(N,2)); diff --git a/Task/Even-or-odd/PHP/even-or-odd.php b/Task/Even-or-odd/PHP/even-or-odd.php new file mode 100644 index 0000000000..356b70f2ca --- /dev/null +++ b/Task/Even-or-odd/PHP/even-or-odd.php @@ -0,0 +1,7 @@ +// using bitwise and to check least significant digit +echo (2 & 1) ? 'odd' : 'even'; +echo (3 & 1) ? 'odd' : 'even'; + +// using modulo +echo (3 % 2) ? 'odd' : 'even'; +echo (4 % 2) ? 'odd' : 'even'; diff --git a/Task/Even-or-odd/Perl/even-or-odd-1.pl b/Task/Even-or-odd/Perl/even-or-odd-1.pl new file mode 100644 index 0000000000..197c8ae741 --- /dev/null +++ b/Task/Even-or-odd/Perl/even-or-odd-1.pl @@ -0,0 +1,3 @@ +for(0..10){ + print "$_ is ", qw(even odd)[$_ % 2],"\n"; +} diff --git a/Task/Even-or-odd/Perl/even-or-odd-2.pl b/Task/Even-or-odd/Perl/even-or-odd-2.pl new file mode 100644 index 0000000000..e1a19f2314 --- /dev/null +++ b/Task/Even-or-odd/Perl/even-or-odd-2.pl @@ -0,0 +1 @@ +print 6 % 2 ? 'odd' : 'even'; # prints even diff --git a/Task/Even-or-odd/PicoLisp/even-or-odd.l b/Task/Even-or-odd/PicoLisp/even-or-odd.l new file mode 100644 index 0000000000..807cb48db0 --- /dev/null +++ b/Task/Even-or-odd/PicoLisp/even-or-odd.l @@ -0,0 +1,5 @@ +: (bit? 1 3) +-> 1 # Odd + +: (bit? 1 4) +-> NIL # Even diff --git a/Task/Even-or-odd/Python/even-or-odd-1.py b/Task/Even-or-odd/Python/even-or-odd-1.py new file mode 100644 index 0000000000..7acc62ff42 --- /dev/null +++ b/Task/Even-or-odd/Python/even-or-odd-1.py @@ -0,0 +1,9 @@ +>>> def is_odd(i): return bool(i & 1) + +>>> def is_even(i): return not is_odd(i) + +>>> [(j, is_odd(j)) for j in range(10)] +[(0, False), (1, True), (2, False), (3, True), (4, False), (5, True), (6, False), (7, True), (8, False), (9, True)] +>>> [(j, is_even(j)) for j in range(10)] +[(0, True), (1, False), (2, True), (3, False), (4, True), (5, False), (6, True), (7, False), (8, True), (9, False)] +>>> diff --git a/Task/Even-or-odd/Python/even-or-odd-2.py b/Task/Even-or-odd/Python/even-or-odd-2.py new file mode 100644 index 0000000000..1f9c345dfa --- /dev/null +++ b/Task/Even-or-odd/Python/even-or-odd-2.py @@ -0,0 +1,8 @@ +>> def is_even(i): + return (i % 2) == 0 + +>>> is_even(1) +False +>>> is_even(2) +True +>>> diff --git a/Task/Even-or-odd/R/even-or-odd.r b/Task/Even-or-odd/R/even-or-odd.r new file mode 100644 index 0000000000..f56891f9a8 --- /dev/null +++ b/Task/Even-or-odd/R/even-or-odd.r @@ -0,0 +1,5 @@ +is.even <- function(x) !is.odd(x) + +is.odd <- function(x) intToBits(x)[1] == 1 +#or +is.odd <- function(x) x %% 2 == 1 diff --git a/Task/Even-or-odd/REXX/even-or-odd.rexx b/Task/Even-or-odd/REXX/even-or-odd.rexx new file mode 100644 index 0000000000..86e258fc39 --- /dev/null +++ b/Task/Even-or-odd/REXX/even-or-odd.rexx @@ -0,0 +1,31 @@ +/*REXX program displays if an integer is even or odd. */ +numeric digits 1000 /*handle most big 'uns from the CL*/ +parse arg x _ . /*get arg(s) from the command line*/ +if x=='' then call terr 'no input' +if _\=='' | arg()\==1 then call terr 'too many arguments:' arg(1) +if \datatype(x,'N') then call terr x "isn't numeric" +if \datatype(x,'W') then call terr x "isn't an integer" +y=abs(x) /*just in case X is negative, */ + /*(modulus of neg # might be -1), */ +/*══════════════════════════════════════════════════════════════════════*/ + say center('test using modulo method',40,'─') +if y//2 then say x 'is odd' + else say x 'is even' +/*══════════════════════════════════════════════════════════════════════*/ +say; say center('test rightmost digit for evenness',40,'─') +_=right(y,1) +if pos(_,02468)==0 then say x 'is odd' + else say x 'is even' +/*══════════════════════════════════════════════════════════════════════*/ +say; say center('test rightmost digit for oddness',40,'─') +if pos(right(y,1),13579)==0 then say x 'is even' + else say x 'is odd' +/*══════════════════════════════════════════════════════════════════════*/ +say; say center('test rightmost (binary) bit',40,'─') + /*Note: some REXX's don't have a D2B bif.*/ +if right(x2b(d2x(y)),1) then say x 'is odd' + else say x 'is even' +/*══════════════════════════════════════════════════════════════════════*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────TERR subroutine─────────────────────*/ +terr: say; say '***error!***'; say; say arg(1); say; exit 13 diff --git a/Task/Even-or-odd/Racket/even-or-odd-1.rkt b/Task/Even-or-odd/Racket/even-or-odd-1.rkt new file mode 100644 index 0000000000..1e8cc90aa1 --- /dev/null +++ b/Task/Even-or-odd/Racket/even-or-odd-1.rkt @@ -0,0 +1,4 @@ +(even? 6) ; -> true +(even? 5) ; -> false +(odd? 6) ; -> false +(odd? 5) ; -> true diff --git a/Task/Even-or-odd/Racket/even-or-odd-2.rkt b/Task/Even-or-odd/Racket/even-or-odd-2.rkt new file mode 100644 index 0000000000..b3a7a9ff16 --- /dev/null +++ b/Task/Even-or-odd/Racket/even-or-odd-2.rkt @@ -0,0 +1,5 @@ +(define (my-even? x) + (= (modulo x 2) 0)) + +(define (my-odd? x) + (= (modulo x 2) 1)) diff --git a/Task/Even-or-odd/Ruby/even-or-odd-1.rb b/Task/Even-or-odd/Ruby/even-or-odd-1.rb new file mode 100644 index 0000000000..0c7b5082c6 --- /dev/null +++ b/Task/Even-or-odd/Ruby/even-or-odd-1.rb @@ -0,0 +1,4 @@ +print "evens: " +p -5.upto(5).select {|n| n.even?} +print "odds: " +p -5.upto(5).select {|n| n.odd?} diff --git a/Task/Even-or-odd/Ruby/even-or-odd-2.rb b/Task/Even-or-odd/Ruby/even-or-odd-2.rb new file mode 100644 index 0000000000..1a784108d3 --- /dev/null +++ b/Task/Even-or-odd/Ruby/even-or-odd-2.rb @@ -0,0 +1,10 @@ +n & 1 == 0 +quotient, remainder = n.divmod(2); remainder == 0 + +# The next way only works when n.to_f/2 is exact. +# If Float is IEEE double, then -2**53 .. 2**53 must include n. +n.to_f/2 == n/2 + +# You can use the bracket operator to access the i'th bit +# of a Fixnum or Bignum (i = 0 means least significant bit) +n[0].zero? diff --git a/Task/Even-or-odd/SNUSP/even-or-odd.snusp b/Task/Even-or-odd/SNUSP/even-or-odd.snusp new file mode 100644 index 0000000000..26b6f6bbeb --- /dev/null +++ b/Task/Even-or-odd/SNUSP/even-or-odd.snusp @@ -0,0 +1,3 @@ +$====!/?\==even# + - - +#odd==\?/ diff --git a/Task/Even-or-odd/Scala/even-or-odd-1.scala b/Task/Even-or-odd/Scala/even-or-odd-1.scala new file mode 100644 index 0000000000..25b7e05224 --- /dev/null +++ b/Task/Even-or-odd/Scala/even-or-odd-1.scala @@ -0,0 +1,2 @@ +def isEven( v:Int ) : Boolean = v % 2 == 0 +def isOdd( v:Int ) : Boolean = v % 2 != 0 diff --git a/Task/Even-or-odd/Scala/even-or-odd-2.scala b/Task/Even-or-odd/Scala/even-or-odd-2.scala new file mode 100644 index 0000000000..bcf4e5773b --- /dev/null +++ b/Task/Even-or-odd/Scala/even-or-odd-2.scala @@ -0,0 +1,2 @@ +def isEven( v:Number ) : Boolean = v.longValue % 2 == 0 +def isOdd( v:Number ) : Boolean = v.longValue % 2 != 0 diff --git a/Task/Even-or-odd/Scheme/even-or-odd.ss b/Task/Even-or-odd/Scheme/even-or-odd.ss new file mode 100644 index 0000000000..816163d5e1 --- /dev/null +++ b/Task/Even-or-odd/Scheme/even-or-odd.ss @@ -0,0 +1,8 @@ +> (even? 5) +#f +> (even? 42) +#t +> (odd? 5) +#t +> (odd? 42) +#f diff --git a/Task/Even-or-odd/Tcl/even-or-odd.tcl b/Task/Even-or-odd/Tcl/even-or-odd.tcl new file mode 100644 index 0000000000..5ba9bc5cb9 --- /dev/null +++ b/Task/Even-or-odd/Tcl/even-or-odd.tcl @@ -0,0 +1,9 @@ +package require Tcl 8.5 + +# Bitwise test is the most efficient +proc tcl::mathfunc::isOdd x { expr {$x & 1} } +proc tcl::mathfunc::isEven x { expr {!($x & 1)} } + +puts " # O E" +puts 24:[expr isOdd(24)],[expr isEven(24)] +puts 49:[expr isOdd(49)],[expr isEven(49)] diff --git a/Task/Events/0DESCRIPTION b/Task/Events/0DESCRIPTION new file mode 100644 index 0000000000..b57e88cd98 --- /dev/null +++ b/Task/Events/0DESCRIPTION @@ -0,0 +1,23 @@ +'''Event''' is a synchronization object. An event has two states ''signaled'' and ''reset''. A [[task]] may await for the event to enter the desired state, usually the ''signaled'' state. It is released once the state is entered. Releasing waiting tasks is called ''event notification''. Programmatically controlled events can be set by a [[task]] into one of its states. + +In [[concurrent programming]] event also refers to a notification that some state has been reached through an asynchronous activity. The source of the event can be: + +* ''internal'', from another [[task]], programmatically; +* ''external'', from the hardware, such as user input, timer, etc. Signaling an event from the hardware is accomplished by means of hardware [[interrupts]]. + +Event is a low-level synchronization mechanism. It neither identify the state that caused it signaled, nor the source of, nor who is the subject of notification. Events augmented by data and/or publisher-subscriber schemes are often referred as '''messages''', '''signals''' etc. + +In the context of general programming '''event-driven architecture''' refers to a design that deploy events in order to synchronize [[task]]s with the asynchronous activities they must be aware of. The opposite approach is '''polling''' sometimes called '''busy waiting''', when the synchronization is achieved by an explicit periodic querying the state of the activity. As the name suggests busy waiting consumes system resources even when the external activity does not change its state. + +Event-driven architectures are widely used in GUI design and SCADA systems. They are flexible and have relatively short response times. At the same time event-driven architectures suffer to the problems related to their unpredictability. They face [[race condition]], deadlocking, live locks and priority inversion. For this reason [[real-time computing|real-time]] systems tend to polling schemes, trading performance for predictability in the worst case scenario. + +=Variants of events= + +==Manual-reset event== +This event changes its state by an explicit request of a [[task]]. I.e. once signaled it remains in this state until it will be explicitly reset. + +==Pulse event== +A pulse event when signaled releases all [[task]]s awaiting it and then is automatically reset. + +=Sample implementations / APIs= +Show how a manual-reset event can be implemented in the language or else use an API to a library that provides events. Write a program that waits 1s and then signals the event to a [[task]] waiting for the event. diff --git a/Task/Events/1META.yaml b/Task/Events/1META.yaml new file mode 100644 index 0000000000..d2f44cc2b9 --- /dev/null +++ b/Task/Events/1META.yaml @@ -0,0 +1,6 @@ +--- +category: +- Encyclopedia +note: Concurrency +requires: +- Concurrency diff --git a/Task/Events/Ada/events-1.ada b/Task/Events/Ada/events-1.ada new file mode 100644 index 0000000000..67eaa7761e --- /dev/null +++ b/Task/Events/Ada/events-1.ada @@ -0,0 +1,7 @@ +protected type Event is + procedure Signal; + procedure Reset; + entry Wait; +private + Fired : Boolean := False; +end Event; diff --git a/Task/Events/Ada/events-2.ada b/Task/Events/Ada/events-2.ada new file mode 100644 index 0000000000..dbf09d88df --- /dev/null +++ b/Task/Events/Ada/events-2.ada @@ -0,0 +1,14 @@ +protected body Event is + procedure Signal is + begin + Fired := True; + end Signal; + procedure Reset is + begin + Fired := False; + end Reset; + entry Wait when Fired is + begin + null; + end Wait; +end Event; diff --git a/Task/Events/Ada/events-3.ada b/Task/Events/Ada/events-3.ada new file mode 100644 index 0000000000..62b742e568 --- /dev/null +++ b/Task/Events/Ada/events-3.ada @@ -0,0 +1,18 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Events is + -- Place the event implementation here + X : Event; + + task A; + task body A is + begin + Put_Line ("A is waiting for X"); + X.Wait; + Put_Line ("A received X"); + end A; +begin + delay 1.0; + Put_Line ("Signal X"); + X.Signal; +end Test_Events; diff --git a/Task/Events/AutoHotkey/events.ahk b/Task/Events/AutoHotkey/events.ahk new file mode 100644 index 0000000000..479a318ca4 --- /dev/null +++ b/Task/Events/AutoHotkey/events.ahk @@ -0,0 +1,11 @@ +SetTimer, internal, 1000 +Return + +internal: ; fire on a timer + TrayTip, internal, internal event!`npress F2 for external event + SetTimer, internal, off +Return + +F2:: ; external event: fire on F2 key press + TrayTip, external, f2 key pressed +Return diff --git a/Task/Events/BBC-BASIC/events-1.bbc b/Task/Events/BBC-BASIC/events-1.bbc new file mode 100644 index 0000000000..8de97ae0ff --- /dev/null +++ b/Task/Events/BBC-BASIC/events-1.bbc @@ -0,0 +1,17 @@ + INSTALL @lib$+"TIMERLIB" + WAIT_TIMEOUT = 258 + + SYS "CreateEvent", 0, 1, 0, 0 TO hEvent% + + timerID% = FN_ontimer(1000, PROCelapsed, 0) + + PRINT "Waiting for event..." + REPEAT + SYS "WaitForSingleObject", hEvent%, 1 TO res% + UNTIL res% <> WAIT_TIMEOUT + PRINT "Event signalled" + END + + DEF PROCelapsed + SYS "SetEvent", hEvent% + ENDPROC diff --git a/Task/Events/BBC-BASIC/events-2.bbc b/Task/Events/BBC-BASIC/events-2.bbc new file mode 100644 index 0000000000..030a802d5a --- /dev/null +++ b/Task/Events/BBC-BASIC/events-2.bbc @@ -0,0 +1,16 @@ + INSTALL @lib$+"TIMERLIB" + + Event% = FALSE + + timerID% = FN_ontimer(1000, PROCelapsed, 0) + + PRINT "Waiting for event..." + REPEAT + WAIT 0 + UNTIL Event% + PRINT "Event signalled" + END + + DEF PROCelapsed + Event% = TRUE + ENDPROC diff --git a/Task/Events/C/events.c b/Task/Events/C/events.c new file mode 100644 index 0000000000..1164230363 --- /dev/null +++ b/Task/Events/C/events.c @@ -0,0 +1,19 @@ +#include +#include + +int main() +{ + int p[2]; + pipe(p); + if (fork()) { + close(p[0]); + sleep(1); + write(p[1], p, 1); + wait(0); + } else { + close(p[1]); + read(p[0], p + 1, 1); + puts("received signal from pipe"); + } + return 0; +} diff --git a/Task/Events/Delphi/events.delphi b/Task/Events/Delphi/events.delphi new file mode 100644 index 0000000000..f13ee85015 --- /dev/null +++ b/Task/Events/Delphi/events.delphi @@ -0,0 +1,54 @@ +program Events; + +{$APPTYPE CONSOLE} + +uses + SysUtils, Classes, Windows; + +type + TWaitThread = class(TThread) + private + FEvent: THandle; + public + procedure Sync; + procedure Execute; override; + constructor Create(const aEvent: THandle); reintroduce; + end; + +{ TWaitThread } + +constructor TWaitThread.Create(const aEvent: THandle); +begin + inherited Create(False); + FEvent := aEvent; +end; + +procedure TWaitThread.Execute; +var + res: Cardinal; +begin + res := WaitForSingleObject(FEvent, INFINITE); + if res = 0 then + Synchronize(Sync); +end; + +procedure TWaitThread.Sync; +begin + Writeln(DateTimeToStr(Now)); +end; + +var + event: THandle; + +begin + Writeln(DateTimeToStr(Now)); + event := CreateEvent(nil, False, False, 'Event'); + with TWaitThread.Create(event) do + try + Sleep(1000); + SetEvent(event) + finally + Free; + end; + Readln; +end. diff --git a/Task/Events/E/events-1.e b/Task/Events/E/events-1.e new file mode 100644 index 0000000000..c4fcf505b7 --- /dev/null +++ b/Task/Events/E/events-1.e @@ -0,0 +1,24 @@ +def makeEvent() { + def [var fired, var firer] := Ref.promise() + + def event { + to signal() { + firer.resolveRace(null) # all current and future wait()s will resolve + } + to reset() { + if (firer.isDone()) { # ignore multiple resets. If we didn't, then + # reset() wait() reset() signal() would never + # resolve that wait(). + # create all fresh state + def [p, r] := Ref.promise() + fired := p + firer := r + } + } + to wait() { + return fired + } + } + + return event +} diff --git a/Task/Events/E/events-2.e b/Task/Events/E/events-2.e new file mode 100644 index 0000000000..47ca37611c --- /dev/null +++ b/Task/Events/E/events-2.e @@ -0,0 +1,16 @@ +def e := makeEvent() + +{ + when (e.wait()) -> { + println("[2] Received event.") + } + println("[2] Waiting for event...") +} + +{ + timer.whenPast(timer.now() + 1000, def _() { + println("[1] Signaling event.") + e.signal() + }) + println("[1] Waiting 1 second...") +} diff --git a/Task/Events/Erlang/events-1.erl b/Task/Events/Erlang/events-1.erl new file mode 100644 index 0000000000..859631ff3d --- /dev/null +++ b/Task/Events/Erlang/events-1.erl @@ -0,0 +1,22 @@ +-module(events). +-compile(export_all). + +log(Msg) -> + {H,M,S} = erlang:time(), + io:fwrite("~2.B:~2.B:~2.B => ~s~n",[H,M,S,Msg]). + +task() -> + log("Task start"), + receive + go -> ok + end, + log("Task resumed"). + +main() -> + log("Program start"), + P = spawn(?MODULE,task,[]), + log("Program sleeping"), + timer:sleep(1000), + log("Program signalling event"), + P ! go, + timer:sleep(100). diff --git a/Task/Events/Erlang/events-2.erl b/Task/Events/Erlang/events-2.erl new file mode 100644 index 0000000000..5fff40a808 --- /dev/null +++ b/Task/Events/Erlang/events-2.erl @@ -0,0 +1,7 @@ +66> events:main(). + 0: 0:57 => Program start + 0: 0:57 => Program sleeping + 0: 0:57 => Task start + 0: 0:58 => Program signalling event + 0: 0:58 => Task resumed +ok diff --git a/Task/Events/Go/events.go b/Task/Events/Go/events.go new file mode 100644 index 0000000000..96ca7a6c74 --- /dev/null +++ b/Task/Events/Go/events.go @@ -0,0 +1,23 @@ +package main + +import ( + "log" + "os" + "time" +) + +func main() { + l := log.New(os.Stdout, "", log.Ltime | log.Lmicroseconds) + l.Println("program start") + event := make(chan int) + go func() { + l.Println("task start") + <-event + l.Println("event reset by task") + }() + l.Println("program sleeping") + time.Sleep(1 * time.Second) + l.Println("program signaling event") + event <- 0 + time.Sleep(100 * time.Millisecond) +} diff --git a/Task/Events/Haskell/events-1.hs b/Task/Events/Haskell/events-1.hs new file mode 100644 index 0000000000..30e80fa953 --- /dev/null +++ b/Task/Events/Haskell/events-1.hs @@ -0,0 +1,11 @@ +import Control.Concurrent (threadDelay, forkIO) +import Control.Concurrent.SampleVar + +-- An Event is defined as a SampleVar with no data. +-- http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent-SampleVar.html +newtype Event = Event (SampleVar ()) + +newEvent = fmap Event (newEmptySampleVar) +signalEvent (Event sv) = writeSampleVar sv () +resetEvent (Event sv) = emptySampleVar sv +waitEvent (Event sv) = readSampleVar sv diff --git a/Task/Events/Haskell/events-2.hs b/Task/Events/Haskell/events-2.hs new file mode 100644 index 0000000000..48cf81e7a0 --- /dev/null +++ b/Task/Events/Haskell/events-2.hs @@ -0,0 +1,11 @@ +main = do e <- newEvent + forkIO (waitTask e) + putStrLn "[1] Waiting 1 second..." + threadDelay 1000000 {- µs -} + putStrLn "[1] Signaling event." + signalEvent e + threadDelay 1000000 {- µs -} -- defer program exit for reception + +waitTask e = do putStrLn "[2] Waiting for event..." + waitEvent e + putStrLn "[2] Received event." diff --git a/Task/Events/JavaScript/events-1.js b/Task/Events/JavaScript/events-1.js new file mode 100644 index 0000000000..1a37920f9d --- /dev/null +++ b/Task/Events/JavaScript/events-1.js @@ -0,0 +1,10 @@ +YUI().use('event-custom', function(Y) { + // add a custom event: + Y.on('my:event', function () { + alert("Event fired"); + }); + // fire the event after one second: + setTimeout(function () { + Y.fire('my:event'); + }, 1000); +}); diff --git a/Task/Events/JavaScript/events-2.js b/Task/Events/JavaScript/events-2.js new file mode 100644 index 0000000000..00cb258115 --- /dev/null +++ b/Task/Events/JavaScript/events-2.js @@ -0,0 +1,10 @@ +YUI().use('node-event-simulate', function(Y) { + // add a click event handler to a DOM node with id "button": + Y.one("#button").on("click", function (e) { + alert("Button clicked"); + }); + // simulate the click after one second: + setTimeout(function () { + Y.one("#button").simulate("click"); + }, 1000); +}); diff --git a/Task/Events/Perl/events-1.pl b/Task/Events/Perl/events-1.pl new file mode 100644 index 0000000000..914165f3e9 --- /dev/null +++ b/Task/Events/Perl/events-1.pl @@ -0,0 +1,31 @@ +use AnyEvent; + +# a new condition with a callback: +my $quit = AnyEvent->condvar( + cb => sub { + warn "Bye!\n"; + } +); + +# a new timer, starts after 2s and repeats every 0.25s: +my $counter = 1; +my $hi = AnyEvent->timer( + after => 2, + interval => 0.25, + cb => sub { + warn "Hi!\n"; + # flag the condition as ready after 4 times: + $quit->send if ++$counter > 4; + } +); + +# another timer, runs the callback once after 1s: +my $hello = AnyEvent->timer( + after => 1, + cb => sub { + warn "Hello world!\n"; + } +); + +# wait for the $quit condition to be ready: +$quit->recv(); diff --git a/Task/Events/Perl/events-2.pl b/Task/Events/Perl/events-2.pl new file mode 100644 index 0000000000..09678c38dc --- /dev/null +++ b/Task/Events/Perl/events-2.pl @@ -0,0 +1,15 @@ +use AnyEvent; + +my $quit = AE::cv sub { warn "Bye!\n" }; + +my $counter = 1; +my $hi = AE::timer 2, 0.25, sub { + warn "Hi!\n"; + $quit->send if ++$counter > 4; +}; + +my $hello = AE::timer 1, 0, sub { + warn "Hello world!\n"; +}; + +$quit->recv; diff --git a/Task/Events/PicoLisp/events.l b/Task/Events/PicoLisp/events.l new file mode 100644 index 0000000000..f54d2aafff --- /dev/null +++ b/Task/Events/PicoLisp/events.l @@ -0,0 +1,3 @@ +(alarm 1 + (prinl "Exit in 4 seconds") + (alarm 4 (bye)) ) diff --git a/Task/Events/Tcl/events-1.tcl b/Task/Events/Tcl/events-1.tcl new file mode 100644 index 0000000000..f4e779e7a7 --- /dev/null +++ b/Task/Events/Tcl/events-1.tcl @@ -0,0 +1,54 @@ +# Simple task framework built from coroutines +proc pause ms { + after $ms [info coroutine];yield +} +proc task {name script} { + coroutine $name apply [list {} \ + "set ::tasks(\[info coro]) 1;$script;unset ::tasks(\[info coro])"] +} +proc waitForTasksToFinish {} { + global tasks + while {[array size tasks]} { + vwait tasks + } +} + +# Make an Ada-like event class +oo::class create Event { + variable waiting fired + constructor {} { + set waiting {} + set fired 0 + } + method wait {} { + while {!$fired} { + lappend waiting [info coroutine] + yield + } + } + method signal {} { + set wake $waiting + set waiting {} + set fired 1 + foreach task $wake { + $task + } + } + method reset {} { + set fired 0 + } +} + +# Execute the example +Event create X +task A { + puts "waiting for event" + X wait + puts "received event" +} +task B { + pause 1000 + puts "signalling X" + X signal +} +waitForTasksToFinish diff --git a/Task/Events/Tcl/events-2.tcl b/Task/Events/Tcl/events-2.tcl new file mode 100644 index 0000000000..c743ff4d8c --- /dev/null +++ b/Task/Events/Tcl/events-2.tcl @@ -0,0 +1,4 @@ +after 1000 set X signalled +puts "waiting for event" +vwait X +puts "received event" diff --git a/Task/Evolutionary-algorithm/0DESCRIPTION b/Task/Evolutionary-algorithm/0DESCRIPTION new file mode 100644 index 0000000000..d0672513eb --- /dev/null +++ b/Task/Evolutionary-algorithm/0DESCRIPTION @@ -0,0 +1,13 @@ +Starting with: +* The target string: "METHINKS IT IS LIKE A WEASEL". +* An array of random characters chosen from the set of upper-case letters together with the space, and of the same length as the target string. (Call it the parent). +* A fitness function that computes the ‘closeness’ of its argument to the target string. +* A mutate function that given a string and a mutation rate returns a copy of the string, with some characters probably mutated. +* While the parent is not yet the target: +:* copy the parent C times, each time allowing some random probability that another character might be substituted using mutate. +:* Assess the fitness of the parent and all the copies to the target and make the most fit string the new parent, discarding the others. +:* repeat until the parent converges, (hopefully), to the target. + +Cf: [[wp:Weasel_program#Weasel_algorithm|Weasel algorithm]] and [[wp:Evolutionary algorithm|Evolutionary algorithm]] + +Note: to aid comparison, try and ensure the variables and functions mentioned in the task description appear in solutions diff --git a/Task/Evolutionary-algorithm/ALGOL-68/evolutionary-algorithm.alg b/Task/Evolutionary-algorithm/ALGOL-68/evolutionary-algorithm.alg new file mode 100644 index 0000000000..a3cf92424b --- /dev/null +++ b/Task/Evolutionary-algorithm/ALGOL-68/evolutionary-algorithm.alg @@ -0,0 +1,70 @@ +STRING target := "METHINKS IT IS LIKE A WEASEL"; + +PROC fitness = (STRING tstrg)REAL: +( + INT sum := 0; + FOR i FROM LWB tstrg TO UPB tstrg DO + sum +:= ABS(ABS target[i] - ABS tstrg[i]) + OD; + # fitness := # 100.0*exp(-sum/10.0) +); + +PROC rand char = CHAR: +( + #STATIC# []CHAR ucchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; + # rand char := # ucchars[ENTIER (random*UPB ucchars)+1] +); + +PROC mutate = (REF STRING kid, parent, REAL mutate rate)VOID: +( + FOR i FROM LWB parent TO UPB parent DO + kid[i] := IF random < mutate rate THEN rand char ELSE parent[i] FI + OD +); + +PROC kewe = ( STRING parent, INT iters, REAL fits, REAL mrate)VOID: +( + printf(($"#"4d" fitness: "g(-6,2)"% "g(-6,4)" '"g"'"l$, iters, fits, mrate, parent)) +); + +PROC evolve = VOID: +( + FLEX[UPB target]CHAR parent; + REAL fits; + [100]FLEX[UPB target]CHAR kid; + INT iters := 0; + kid[LWB kid] := LOC[UPB target]CHAR; + REAL mutate rate; + + # initialize # + FOR i FROM LWB parent TO UPB parent DO + parent[i] := rand char + OD; + + fits := fitness(parent); + WHILE fits < 100.0 DO + INT j; + REAL kf; + mutate rate := 1.0 - exp(- (100.0 - fits)/400.0); + FOR j FROM LWB kid TO UPB kid DO + mutate(kid[j], parent, mutate rate) + OD; + FOR j FROM LWB kid TO UPB kid DO + kf := fitness(kid[j]); + IF fits < kf THEN + fits := kf; + parent := kid[j] + FI + OD; + IF iters MOD 100 = 0 THEN + kewe( parent, iters, fits, mutate rate ) + FI; + iters+:=1 + OD; + kewe( parent, iters, fits, mutate rate ) +); + +main: +( + evolve +) diff --git a/Task/Evolutionary-algorithm/Ada/evolutionary-algorithm.ada b/Task/Evolutionary-algorithm/Ada/evolutionary-algorithm.ada new file mode 100644 index 0000000000..3c5c58c97d --- /dev/null +++ b/Task/Evolutionary-algorithm/Ada/evolutionary-algorithm.ada @@ -0,0 +1,124 @@ +with Ada.Text_IO; +with Ada.Numerics.Discrete_Random; +with Ada.Numerics.Float_Random; +with Ada.Strings.Fixed; +with Ada.Strings.Maps; + +procedure Evolution is + + -- only upper case characters allowed, and space, which uses '@' in + -- internal representation (allowing subtype of Character). + subtype DNA_Char is Character range '@' .. 'Z'; + + -- DNA string is as long as target string. + subtype DNA_String is String (1 .. 28); + + -- target string translated to DNA_Char string + Target : constant DNA_String := "METHINKS@IT@IS@LIKE@A@WEASEL"; + + -- calculate the 'closeness' to the target DNA. + -- it returns a number >= 0 that describes how many chars are correct. + -- can be improved much to make evolution better, but keep simple for + -- this example. + function Fitness (DNA : DNA_String) return Natural is + Result : Natural := 0; + begin + for Position in DNA'Range loop + if DNA (Position) = Target (Position) then + Result := Result + 1; + end if; + end loop; + return Result; + end Fitness; + + -- output the DNA using the mapping + procedure Output_DNA (DNA : DNA_String; Prefix : String := "") is + use Ada.Strings.Maps; + Output_Map : Character_Mapping; + begin + Output_Map := To_Mapping + (From => To_Sequence (To_Set (('@'))), + To => To_Sequence (To_Set ((' ')))); + Ada.Text_IO.Put (Prefix); + Ada.Text_IO.Put (Ada.Strings.Fixed.Translate (DNA, Output_Map)); + Ada.Text_IO.Put_Line (", fitness: " & Integer'Image (Fitness (DNA))); + end Output_DNA; + + -- DNA_Char is a discrete type, use Ada RNG + package Random_Char is new Ada.Numerics.Discrete_Random (DNA_Char); + DNA_Generator : Random_Char.Generator; + + -- need generator for floating type, too + Float_Generator : Ada.Numerics.Float_Random.Generator; + + -- returns a mutated copy of the parent, applying the given mutation rate + function Mutate (Parent : DNA_String; + Mutation_Rate : Float) + return DNA_String + is + Result : DNA_String := Parent; + begin + for Position in Result'Range loop + if Ada.Numerics.Float_Random.Random (Float_Generator) <= Mutation_Rate + then + Result (Position) := Random_Char.Random (DNA_Generator); + end if; + end loop; + return Result; + end Mutate; + + -- genetic algorithm to evolve the string + -- could be made a function returning the final string + procedure Evolve (Child_Count : Positive := 100; + Mutation_Rate : Float := 0.2) + is + type Child_Array is array (1 .. Child_Count) of DNA_String; + + -- determine the fittest of the candidates + function Fittest (Candidates : Child_Array) return DNA_String is + The_Fittest : DNA_String := Candidates (1); + begin + for Candidate in Candidates'Range loop + if Fitness (Candidates (Candidate)) > Fitness (The_Fittest) + then + The_Fittest := Candidates (Candidate); + end if; + end loop; + return The_Fittest; + end Fittest; + + Parent, Next_Parent : DNA_String; + Children : Child_Array; + Loop_Counter : Positive := 1; + begin + -- initialize Parent + for Position in Parent'Range loop + Parent (Position) := Random_Char.Random (DNA_Generator); + end loop; + Output_DNA (Parent, "First: "); + while Parent /= Target loop + -- mutation loop + for Child in Children'Range loop + Children (Child) := Mutate (Parent, Mutation_Rate); + end loop; + Next_Parent := Fittest (Children); + -- don't allow weaker children as the parent + if Fitness (Next_Parent) > Fitness (Parent) then + Parent := Next_Parent; + end if; + -- output every 20th generation + if Loop_Counter mod 20 = 0 then + Output_DNA (Parent, Integer'Image (Loop_Counter) & ": "); + end if; + Loop_Counter := Loop_Counter + 1; + end loop; + Output_DNA (Parent, "Final (" & Integer'Image (Loop_Counter) & "): "); + end Evolve; + +begin + -- initialize the random number generators + Random_Char.Reset (DNA_Generator); + Ada.Numerics.Float_Random.Reset (Float_Generator); + -- evolve! + Evolve; +end Evolution; diff --git a/Task/Evolutionary-algorithm/AutoHotkey/evolutionary-algorithm.ahk b/Task/Evolutionary-algorithm/AutoHotkey/evolutionary-algorithm.ahk new file mode 100644 index 0000000000..003524e349 --- /dev/null +++ b/Task/Evolutionary-algorithm/AutoHotkey/evolutionary-algorithm.ahk @@ -0,0 +1,56 @@ +output := "" +target := "METHINKS IT IS LIKE A WEASEL" +targetLen := StrLen(target) +Loop, 26 + possibilities_%A_Index% := Chr(A_Index+64) ; A-Z +possibilities_27 := " " +C := 100 + +parent := "" +Loop, %targetLen% +{ + Random, randomNum, 1, 27 + parent .= possibilities_%randomNum% +} + +Loop, +{ + If (target = parent) + Break + If (Mod(A_Index,10) = 0) + output .= A_Index ": " parent ", fitness: " fitness(parent, target) "`n" + bestFit := 0 + Loop, %C% + If ((fitness := fitness(spawn := mutate(parent), target)) > bestFit) + bestSpawn := spawn , bestFit := fitness + parent := bestFit > fitness(parent, target) ? bestSpawn : parent + iter := A_Index +} +output .= parent ", " iter +MsgBox, % output +ExitApp + +mutate(parent) { + local output, replaceChar, newChar + output := "" + Loop, %targetLen% + { + Random, replaceChar, 0, 9 + If (replaceChar != 0) + output .= SubStr(parent, A_Index, 1) + else + { + Random, newChar, 1, 27 + output .= possibilities_%newChar% + } + } + Return output +} + +fitness(string, target) { + totalFit := 0 + Loop, % StrLen(string) + If (SubStr(string, A_Index, 1) = SubStr(target, A_Index, 1)) + totalFit++ + Return totalFit +} diff --git a/Task/Evolutionary-algorithm/BBC-BASIC/evolutionary-algorithm.bbc b/Task/Evolutionary-algorithm/BBC-BASIC/evolutionary-algorithm.bbc new file mode 100644 index 0000000000..a88ea94cb0 --- /dev/null +++ b/Task/Evolutionary-algorithm/BBC-BASIC/evolutionary-algorithm.bbc @@ -0,0 +1,39 @@ + target$ = "METHINKS IT IS LIKE A WEASEL" + parent$ = "IU RFSGJABGOLYWF XSMFXNIABKT" + mutation_rate = 0.5 + children% = 10 + + DIM child$(children%) + + REPEAT + bestfitness = 0 + bestindex% = 0 + FOR index% = 1 TO children% + child$(index%) = FNmutate(parent$, mutation_rate) + fitness = FNfitness(target$, child$(index%)) + IF fitness > bestfitness THEN + bestfitness = fitness + bestindex% = index% + ENDIF + NEXT index% + + parent$ = child$(bestindex%) + PRINT parent$ + UNTIL parent$ = target$ + END + + DEF FNfitness(text$, ref$) + LOCAL I%, F% + FOR I% = 1 TO LEN(text$) + IF MID$(text$, I%, 1) = MID$(ref$, I%, 1) THEN F% += 1 + NEXT + = F% / LEN(text$) + + DEF FNmutate(text$, rate) + LOCAL C% + IF rate > RND(1) THEN + C% = 63+RND(27) + IF C% = 64 C% = 32 + MID$(text$, RND(LEN(text$)), 1) = CHR$(C%) + ENDIF + = text$ diff --git a/Task/Evolutionary-algorithm/C++/evolutionary-algorithm.cpp b/Task/Evolutionary-algorithm/C++/evolutionary-algorithm.cpp new file mode 100644 index 0000000000..064eb7329f --- /dev/null +++ b/Task/Evolutionary-algorithm/C++/evolutionary-algorithm.cpp @@ -0,0 +1,110 @@ +#include +#include +#include +#include +#include +#include + +std::string allowed_chars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + +// class selection contains the fitness function, encapsulates the +// target string and allows access to it's length. The class is only +// there for access control, therefore everything is static. The +// string target isn't defined in the function because that way the +// length couldn't be accessed outside. +class selection +{ +public: + // this function returns 0 for the destination string, and a + // negative fitness for a non-matching string. The fitness is + // calculated as the negated sum of the circular distances of the + // string letters with the destination letters. + static int fitness(std::string candidate) + { + assert(target.length() == candidate.length()); + + int fitness_so_far = 0; + + for (int i = 0; i < target.length(); ++i) + { + int target_pos = allowed_chars.find(target[i]); + int candidate_pos = allowed_chars.find(candidate[i]); + int diff = std::abs(target_pos - candidate_pos); + fitness_so_far -= std::min(diff, int(allowed_chars.length()) - diff); + } + + return fitness_so_far; + } + + // get the target string length + static int target_length() { return target.length(); } +private: + static std::string target; +}; + +std::string selection::target = "METHINKS IT IS LIKE A WEASEL"; + +// helper function: cyclically move a character through allowed_chars +void move_char(char& c, int distance) +{ + while (distance < 0) + distance += allowed_chars.length(); + int char_pos = allowed_chars.find(c); + c = allowed_chars[(char_pos + distance) % allowed_chars.length()]; +} + +// mutate the string by moving the characters by a small random +// distance with the given probability +std::string mutate(std::string parent, double mutation_rate) +{ + for (int i = 0; i < parent.length(); ++i) + if (std::rand()/(RAND_MAX + 1.0) < mutation_rate) + { + int distance = std::rand() % 3 + 1; + if(std::rand()%2 == 0) + move_char(parent[i], distance); + else + move_char(parent[i], -distance); + } + return parent; +} + +// helper function: tell if the first argument is less fit than the +// second +bool less_fit(std::string const& s1, std::string const& s2) +{ + return selection::fitness(s1) < selection::fitness(s2); +} + +int main() +{ + int const C = 100; + + std::srand(time(0)); + + std::string parent; + for (int i = 0; i < selection::target_length(); ++i) + { + parent += allowed_chars[std::rand() % allowed_chars.length()]; + } + + int const initial_fitness = selection::fitness(parent); + + for(int fitness = initial_fitness; + fitness < 0; + fitness = selection::fitness(parent)) + { + std::cout << parent << ": " << fitness << "\n"; + double const mutation_rate = 0.02 + (0.9*fitness)/initial_fitness; + typedef std::vector childvec; + childvec childs; + childs.reserve(C+1); + + childs.push_back(parent); + for (int i = 0; i < C; ++i) + childs.push_back(mutate(parent, mutation_rate)); + + parent = *std::max_element(childs.begin(), childs.end(), less_fit); + } + std::cout << "final string: " << parent << "\n"; +} diff --git a/Task/Evolutionary-algorithm/C/evolutionary-algorithm-1.c b/Task/Evolutionary-algorithm/C/evolutionary-algorithm-1.c new file mode 100644 index 0000000000..1cf726bc37 --- /dev/null +++ b/Task/Evolutionary-algorithm/C/evolutionary-algorithm-1.c @@ -0,0 +1,67 @@ +#include +#include +#include + +const char target[] = "METHINKS IT IS LIKE A WEASEL"; +const char tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; + +#define CHOICE (sizeof(tbl) - 1) +#define MUTATE 15 +#define COPIES 30 + +/* returns random integer from 0 to n - 1 */ +int irand(int n) +{ + int r, rand_max = RAND_MAX - (RAND_MAX % n); + while((r = rand()) >= rand_max); + return r / (rand_max / n); +} + +/* number of different chars between a and b */ +int unfitness(const char *a, const char *b) +{ + int i, sum = 0; + for (i = 0; a[i]; i++) + sum += (a[i] != b[i]); + return sum; +} + +/* each char of b has 1/MUTATE chance of differing from a */ +void mutate(const char *a, char *b) +{ + int i; + for (i = 0; a[i]; i++) + b[i] = irand(MUTATE) ? a[i] : tbl[irand(CHOICE)]; + + b[i] = '\0'; +} + +int main() +{ + int i, best_i, unfit, best, iters = 0; + char specimen[COPIES][sizeof(target) / sizeof(char)]; + + /* init rand string */ + for (i = 0; target[i]; i++) + specimen[0][i] = tbl[irand(CHOICE)]; + specimen[0][i] = 0; + + do { + for (i = 1; i < COPIES; i++) + mutate(specimen[0], specimen[i]); + + /* find best fitting string */ + for (best_i = i = 0; i < COPIES; i++) { + unfit = unfitness(target, specimen[i]); + if(unfit < best || !i) { + best = unfit; + best_i = i; + } + } + + if (best_i) strcpy(specimen[0], specimen[best_i]); + printf("iter %d, score %d: %s\n", iters++, best, specimen[0]); + } while (best); + + return 0; +} diff --git a/Task/Evolutionary-algorithm/C/evolutionary-algorithm-2.c b/Task/Evolutionary-algorithm/C/evolutionary-algorithm-2.c new file mode 100644 index 0000000000..bcf99aa844 --- /dev/null +++ b/Task/Evolutionary-algorithm/C/evolutionary-algorithm-2.c @@ -0,0 +1,8 @@ +iter 0, score 26: WKVVYFJUHOMQJNZYRTEQAGDVXKYC +iter 1, score 25: WKVVTFJUHOMQJN YRTEQAGDVSKXC +iter 2, score 25: WKVVTFJUHOMQJN YRTEQAGDVSKXC +iter 3, score 24: WKVVTFJUHOMQJN YRTEQAGDVAKFC +... +iter 221, score 1: METHINKSHIT IS LIKE A WEASEL +iter 222, score 1: METHINKSHIT IS LIKE A WEASEL +iter 223, score 0: METHINKS IT IS LIKE A WEASEL diff --git a/Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-1.clj b/Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-1.clj new file mode 100644 index 0000000000..f1e01bec1e --- /dev/null +++ b/Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-1.clj @@ -0,0 +1,7 @@ +(def c 100) ;number of children in each generation +(def p 0.05) ;mutation probability + +(def target "METHINKS IT IS LIKE A WEASEL") +(def tsize (count target)) + +(def alphabet " ABCDEFGHIJLKLMNOPQRSTUVWXYZ") diff --git a/Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-2.clj b/Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-2.clj new file mode 100644 index 0000000000..8395bd757b --- /dev/null +++ b/Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-2.clj @@ -0,0 +1,5 @@ +(defn fitness [s] (count (filter true? (map = s target)))) +(defn perfectly-fit? [s] (= (fitness s) tsize)) + +(defn randc [] (rand-nth alphabet)) +(defn mutate [s] (map #(if (< (rand) p) (randc) %) s)) diff --git a/Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-3.clj b/Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-3.clj new file mode 100644 index 0000000000..da93165a34 --- /dev/null +++ b/Task/Evolutionary-algorithm/Clojure/evolutionary-algorithm-3.clj @@ -0,0 +1,6 @@ +(loop [generation 1, parent (repeatedly tsize randc)] + (println generation, (apply str parent), (fitness parent)) + (if-not (perfectly-fit? parent) + (let [children (repeatedly c #(mutate parent)) + fittest (apply max-key fitness parent children)] + (recur (inc generation), fittest)))) diff --git a/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-1.lisp b/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-1.lisp new file mode 100644 index 0000000000..0ca92cac0d --- /dev/null +++ b/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-1.lisp @@ -0,0 +1,39 @@ +(defun fitness (string target) + "Closeness of string to target; lower number is better" + (loop for c1 across string + for c2 across target + count (char/= c1 c2))) + +(defun mutate (string chars p) + "Mutate each character of string with probablity p using characters from chars" + (dotimes (n (length string)) + (when (< (random 1.0) p) + (setf (aref string n) (aref chars (random (length chars)))))) + string) + +(defun random-string (chars length) + "Generate a new random string consisting of letters from char and specified length" + (do ((n 0 (1+ n)) + (str (make-string length))) + ((= n length) str) + (setf (aref str n) (aref chars (random (length chars)))))) + +(defun evolve-string (target string chars c p) + "Generate new mutant strings, and choose the most fit string" + (let ((mutated-strs (list string))) + (dotimes (n c) + (push (mutate (copy-seq string) chars p) mutated-strs)) + (reduce #'(lambda (s0 s1) + (if (< (fitness s0 target) + (fitness s1 target)) + s0 + s1)) + mutated-strs))) + +(defun evolve-gens (target c p) + (let ((chars " ABCDEFGHIJKLMNOPQRSTUVWXYZ")) + (do ((parent (random-string chars (length target)) + (evolve-string target parent chars c p)) + (n 0 (1+ n))) + ((string= target parent) (format t "Generation ~A: ~S~%" n parent)) + (format t "Generation ~A: ~S~%" n parent)))) diff --git a/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-2.lisp b/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-2.lisp new file mode 100644 index 0000000000..0d38dbc62d --- /dev/null +++ b/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-2.lisp @@ -0,0 +1,23 @@ +(defun unfit (s1 s2) + (loop for a across s1 + for b across s2 count(char/= a b))) + +(defun mutate (str alp n) ; n: number of chars to mutate + (let ((out (copy-seq str))) + (dotimes (i n) (setf (char out (random (length str))) + (char alp (random (length alp))))) + out)) + +(defun evolve (changes alpha target) + (loop for gen from 1 + with f2 with s2 + with str = (mutate target alpha 100) + with fit = (unfit target str) + while (plusp fit) do + (setf s2 (mutate str alpha changes) + f2 (unfit target s2)) + (when (> fit f2) + (setf str s2 fit f2) + (format t "~5d: ~a (~d)~%" gen str fit)))) + +(evolve 1 " ABCDEFGHIJKLMNOPQRSTUVWXYZ" "METHINKS IT IS LIKE A WEASEL") diff --git a/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-3.lisp b/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-3.lisp new file mode 100644 index 0000000000..525e841050 --- /dev/null +++ b/Task/Evolutionary-algorithm/Common-Lisp/evolutionary-algorithm-3.lisp @@ -0,0 +1,27 @@ + 44: DYZTOREXDML ZCEUCSHRVHBEPGJE (26) + 57: DYZTOREXDIL ZCEUCSHRVHBEPGJE (25) + 83: DYZTOREX IL ZCEUCSHRVHBEPGJE (24) + 95: MYZTOREX IL ZCEUCSHRVHBEPGJE (23) + 186: MYZTOREX IL ZCEUISHRVHBEPGJE (22) + 208: MYZTOREX IL ZCEUISH VHBEPGJE (21) + 228: MYZTOREX IL ZCEUISH VHBEPGEE (20) + 329: MYZTOREX IL ZCEUIKH VHBEPGEE (19) + 330: MYTTOREX IL ZCEUIKH VHBEPGEE (18) + 354: MYTHOREX IL ZCEUIKH VHBEPGEE (17) + 365: MYTHOREX IL ICEUIKH VHBEPGEE (16) + 380: MYTHOREX IL ISEUIKH VHBEPGEE (15) + 393: METHOREX IL ISEUIKH VHBEPGEE (14) + 407: METHORKX IL ISEUIKH VHBEPGEE (13) + 443: METHORKX IL ISEUIKH VHBEPSEE (12) + 455: METHORKX IL ISEUIKE VHBEPSEE (11) + 477: METHIRKX IL ISEUIKE VHBEPSEE (10) + 526: METHIRKS IL ISEUIKE VHBEPSEE (9) + 673: METHIRKS IL ISEUIKE VHBEPSEL (8) + 800: METHINKS IL ISEUIKE VHBEPSEL (7) + 875: METHINKS IL ISEUIKE AHBEPSEL (6) + 941: METHINKS IL ISEUIKE AHBEASEL (5) + 1175: METHINKS IT ISEUIKE AHBEASEL (4) + 1214: METHINKS IT ISELIKE AHBEASEL (3) + 1220: METHINKS IT IS LIKE AHBEASEL (2) + 1358: METHINKS IT IS LIKE AHWEASEL (1) + 2610: METHINKS IT IS LIKE A WEASEL (0) diff --git a/Task/Evolutionary-algorithm/D/evolutionary-algorithm-1.d b/Task/Evolutionary-algorithm/D/evolutionary-algorithm-1.d new file mode 100644 index 0000000000..d03e58f6d3 --- /dev/null +++ b/Task/Evolutionary-algorithm/D/evolutionary-algorithm-1.d @@ -0,0 +1,33 @@ +import std.stdio, std.random, std.algorithm, std.range, std.ascii; + +void evolve(string target, double prob=0.05, int C=100) { + auto chars = uppercase ~ " "; + char rndCh() { return chars[uniform(0, $)]; } + void mutate(char[] parent, char[] child) { + foreach (i, ref c; child) + c = uniform(0.0, 1.0) < prob ? rndCh() : parent[i]; + } + int fitness(char[] subject, string target) { + return count!q{ a[0] != a[1] }(zip(subject, target)); + } + auto parent= map!(i => rndCh())(target).array(); + auto best = parent.dup; + auto child = new char[target.length]; + int currDist = fitness(parent, target); + for (int gen; currDist > 0; gen++) { + foreach (_; 0 .. C) { + mutate(parent, child); + int dist = fitness(child, target); + if (dist < currDist) { + currDist = dist; + best[] = child[]; + } + } + parent = best; + writefln("Generation %2s, dist=%2s: %s", gen, currDist, best); + } +} + +void main() { + evolve("METHINKS IT IS LIKE A WEASEL"); +} diff --git a/Task/Evolutionary-algorithm/D/evolutionary-algorithm-2.d b/Task/Evolutionary-algorithm/D/evolutionary-algorithm-2.d new file mode 100644 index 0000000000..442301370f --- /dev/null +++ b/Task/Evolutionary-algorithm/D/evolutionary-algorithm-2.d @@ -0,0 +1,19 @@ +import std.stdio, std.random, std.algorithm, std.range; + +enum target = "METHINKS IT IS LIKE A WEASEL"d; +enum C = 100; // Number of children in each generation. +enum P = 0.05; // Mutation probability. +auto alphabet = " ABCDEFGHIJLKLMNOPQRSTUVWXYZ"d.dup; +const fitness = (dchar[] s) => count!"a[0] != a[1]"(zip(s, target)); +const rndc = () => alphabet[uniform(0, $)]; +const mutate = (dchar[] s) => + s.map!(a => uniform(0., 1.) < P ? rndc() : a)().array(); + +void main() { + auto parent = target.length.iota().map!(_ => rndc())().array(); + for (int gen = 1; parent != target; gen++) { + auto offs = parent.repeat(C).map!mutate().array(); + parent = offs.minPos!((a, b) => fitness(a) < fitness(b))()[0]; + writefln("Gen %2d, dist=%2d: %s", gen, fitness(parent), parent); + } +} diff --git a/Task/Evolutionary-algorithm/E/evolutionary-algorithm.e b/Task/Evolutionary-algorithm/E/evolutionary-algorithm.e new file mode 100644 index 0000000000..63ac0e23bd --- /dev/null +++ b/Task/Evolutionary-algorithm/E/evolutionary-algorithm.e @@ -0,0 +1,44 @@ +pragma.syntax("0.9") +pragma.enable("accumulator") + +def target := "METHINKS IT IS LIKE A WEASEL" +def alphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ " +def C := 100 +def RATE := 0.05 + +def randomCharString() { + return E.toString(alphabet[entropy.nextInt(alphabet.size())]) +} + +def fitness(string) { + return accum 0 for i => ch in string { + _ + (ch == target[i]).pick(1, 0) + } +} + +def mutate(string, rate) { + return accum "" for i => ch in string { + _ + (entropy.nextDouble() < rate).pick(randomCharString(), E.toString(ch)) + } +} + +def weasel() { + var parent := accum "" for _ in 1..(target.size()) { _ + randomCharString() } + var generation := 0 + + while (parent != target) { + println(`$generation $parent`) + def copies := accum [] for _ in 1..C { _.with(mutate(parent, RATE)) } + var best := parent + for c in copies { + if (fitness(c) > fitness(best)) { + best := c + } + } + parent := best + generation += 1 + } + println(`$generation $parent`) +} + +weasel() diff --git a/Task/Evolutionary-algorithm/Erlang/evolutionary-algorithm.erl b/Task/Evolutionary-algorithm/Erlang/evolutionary-algorithm.erl new file mode 100644 index 0000000000..58ad7d0237 --- /dev/null +++ b/Task/Evolutionary-algorithm/Erlang/evolutionary-algorithm.erl @@ -0,0 +1,60 @@ +-module(evolution). +-export([run/0]). + +-define(MUTATE, 0.05). +-define(POPULATION, 100). +-define(TARGET, "METHINKS IT IS LIKE A WEASEL"). +-define(MAX_GENERATIONS, 1000). + +run() -> evolve_gens(). + +evolve_gens() -> + Initial = random_string(length(?TARGET)), + evolve_gens(Initial,0,fitness(Initial)). +evolve_gens(Parent,Generation,0) -> + io:format("Generation[~w]: Achieved the target: ~s~n",[Generation,Parent]); +evolve_gens(Parent,Generation,_Fitness) when Generation == ?MAX_GENERATIONS -> + io:format("Reached Max Generations~nFinal string is ~s~n",[Parent]); +evolve_gens(Parent,Generation,Fitness) -> + io:format("Generation[~w]: ~s, Fitness: ~w~n", + [Generation,Parent,Fitness]), + Child = evolve_string(Parent), + evolve_gens(Child,Generation+1,fitness(Child)). + +fitness(String) -> fitness(String, ?TARGET). +fitness([],[]) -> 0; +fitness([H|Rest],[H|Target]) -> fitness(Rest,Target); +fitness([_H|Rest],[_T|Target]) -> 1+fitness(Rest,Target). + +mutate(String) -> mutate(String,[]). +mutate([],Acc) -> lists:reverse(Acc); +mutate([H|T],Acc) -> + case random:uniform() < ?MUTATE of + true -> + mutate(T,[random_character()|Acc]); + false -> + mutate(T,[H|Acc]) + end. + +evolve_string(String) -> + evolve_string(String,?TARGET,?POPULATION,String). +evolve_string(_,_,0,Child) -> Child; +evolve_string(Parent,Target,Population,Best_Child) -> + Child = mutate(Parent), + case fitness(Child) < fitness(Best_Child) of + true -> + evolve_string(Parent,Target,Population-1,Child); + false -> + evolve_string(Parent,Target,Population-1,Best_Child) + end. + +random_character() -> + case random:uniform(27)-1 of + 26 -> $ ; + R -> $A+R + end. + +random_string(Length) -> random_string(Length,[]). +random_string(0,Acc) -> Acc; +random_string(N,Acc) when N > 0 -> + random_string(N-1,[random_character()|Acc]). diff --git a/Task/Evolutionary-algorithm/Euphoria/evolutionary-algorithm.euphoria b/Task/Evolutionary-algorithm/Euphoria/evolutionary-algorithm.euphoria new file mode 100644 index 0000000000..fde7d484df --- /dev/null +++ b/Task/Evolutionary-algorithm/Euphoria/evolutionary-algorithm.euphoria @@ -0,0 +1,51 @@ +constant table = "ABCDEFGHIJKLMNOPQRSTUVWXYZ " +function random_generation(integer len) + sequence s + s = rand(repeat(length(table),len)) + for i = 1 to len do + s[i] = table[s[i]] + end for + return s +end function + +function mutate(sequence s, integer n) + for i = 1 to length(s) do + if rand(n) = 1 then + s[i] = table[rand(length(table))] + end if + end for + return s +end function + +function fitness(sequence probe, sequence target) + atom sum + sum = 0 + for i = 1 to length(target) do + sum += power(find(target[i], table) - find(probe[i], table), 2) + end for + return sqrt(sum/length(target)) +end function + +constant target = "METHINKS IT IS LIKE A WEASEL", C = 30, MUTATE = 15 +sequence parent, specimen +integer iter, best +atom fit, best_fit +parent = random_generation(length(target)) +iter = 0 +while not equal(parent,target) do + best_fit = fitness(parent, target) + printf(1,"Iteration: %3d, \"%s\", deviation %g\n", {iter, parent, best_fit}) + specimen = repeat(parent,C+1) + best = C+1 + for i = 1 to C do + specimen[i] = mutate(specimen[i], MUTATE) + fit = fitness(specimen[i], target) + if fit < best_fit then + best_fit = fit + best = i + end if + end for + parent = specimen[best] + iter += 1 +end while +printf(1,"Finally, \"%s\"\n",{parent}) diff --git a/Task/Evolutionary-algorithm/Forth/evolutionary-algorithm.fth b/Task/Evolutionary-algorithm/Forth/evolutionary-algorithm.fth new file mode 100644 index 0000000000..953c9fd18c --- /dev/null +++ b/Task/Evolutionary-algorithm/Forth/evolutionary-algorithm.fth @@ -0,0 +1,73 @@ +include lib/choose.4th + \ target string +s" METHINKS IT IS LIKE A WEASEL" sconstant target + +27 constant /charset \ size of characterset +29 constant /target \ size of target string +32 constant #copies \ number of offspring + +/target string charset \ characterset +/target string this-generation \ current generation and offspring +/target #copies [*] string new-generation + +:this new-generation does> swap /target chars * + ; + \ generate a mutation +: mutation charset /charset choose chars + c@ ; + \ print the current candidate +: .candidate ( n1 n2 -- n1 f) + ." Generation " over 2 .r ." : " this-generation count type cr /target -1 [+] = +; \ test a candidate on + \ THE NUMBER of correct genes +: test-candidate ( a -- a n) + dup target 0 >r >r ( a1 a2) + begin ( a1 a2) + r@ ( a1 a2 n) + while ( a1 a2) + over c@ over c@ = ( a1 a2 n) + r> r> rot if 1+ then >r 1- >r ( a1 a2) + char+ swap char+ swap ( a1+1 a2+1) + repeat ( a1+1 a2+1) + drop drop r> drop r> ( a n) +; + \ find the best candidate +: get-candidate ( -- n) + #copies 0 >r >r ( --) + begin ( --) + r@ ( n) + while ( --) + r@ 1- new-generation ( a) + test-candidate r'@ over < ( a n f) + if swap count this-generation place r> 1- swap r> drop >r >r + else drop drop r> 1- >r then ( --) + repeat ( --) + r> drop r> ( n) +; + \ generate a new candidate +: make-candidate ( a --) + dup charset count rot place ( a1) + this-generation target >r ( a1 a2 a3) + begin ( a1 a2 a3) + r@ ( a1 a2 a3 n) + while ( a1 a2 a3) + over c@ over c@ = ( a1 a2 a3 f) + swap >r >r over r> ( a1 a2 a1 f) + if over c@ else mutation then ( a1 a2 a1 c) + swap c! r> r> 1- >r ( a1 a2 a3) + char+ rot char+ rot char+ rot ( a1+1 a2+1 a3+1) + repeat ( a1+1 a2+1 a3+1) + drop drop drop r> drop ( --) +; + \ make a whole new generation +: make-generation #copies 0 do i new-generation make-candidate loop ; + \ weasel program +: weasel + s" ABCDEFGHIJKLMNOPQRSTUVWXYZ " 2dup + charset place \ initialize the characterset + this-generation place 0 \ initialize the first generation + begin \ start the program + 1+ make-generation \ make a new generation + get-candidate .candidate \ select the best candidate + until drop \ stop when we've found perfection +; + +weasel diff --git a/Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-1.f b/Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-1.f new file mode 100644 index 0000000000..e16722f652 --- /dev/null +++ b/Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-1.f @@ -0,0 +1,135 @@ + !*************************************************************************************************** + module evolve_routines + !*************************************************************************************************** + implicit none + + !the target string: + character(len=*),parameter :: targ = 'METHINKS IT IS LIKE A WEASEL' + + contains + !*************************************************************************************************** + + !******************************************************************** + pure elemental function fitness(member) result(n) + !******************************************************************** + ! The fitness function. The lower the value, the better the match. + ! It is zero if they are identical. + !******************************************************************** + + implicit none + integer :: n + character(len=*),intent(in) :: member + + integer :: i + + n=0 + do i=1,len(targ) + n = n + abs( ichar(targ(i:i)) - ichar(member(i:i)) ) + end do + + !******************************************************************** + end function fitness + !******************************************************************** + + !******************************************************************** + pure elemental subroutine mutate(member,factor) + !******************************************************************** + ! mutate a member of the population. + !******************************************************************** + + implicit none + character(len=*),intent(inout) :: member !population member + real,intent(in) :: factor !mutation factor + + integer,parameter :: n_chars = 27 !number of characters in set + character(len=n_chars),parameter :: chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' + + real :: rnd_val + integer :: i,j,n + + n = len(member) + + do i=1,n + rnd_val = rand() + if (rnd_val<=factor) then !mutate this element + rnd_val = rand() + j = int(rnd_val*n_chars)+1 !an integer between 1 and n_chars + member(i:i) = chars(j:j) + end if + end do + + !******************************************************************** + end subroutine mutate + !******************************************************************** + + !*************************************************************************************************** + end module evolve_routines + !*************************************************************************************************** + + !*************************************************************************************************** + program evolve + !*************************************************************************************************** + ! The main program + !*************************************************************************************************** + use evolve_routines + + implicit none + + !Tuning parameters: + integer,parameter :: seed = 12345 !random number generator seed + integer,parameter :: max_iter = 10000 !maximum number of iterations + integer,parameter :: population_size = 200 !size of the population + real,parameter :: factor = 0.04 ![0,1] mutation factor + integer,parameter :: iprint = 5 !print every iprint iterations + + !local variables: + integer :: i,iter + integer,dimension(1) :: i_best + character(len=len(targ)),dimension(population_size) :: population + + !initialize random number generator: + call srand(seed) + + !create initial population: + ! [the first element of the population will hold the best member] + population(1) = 'PACQXJB CQPWEYKSVDCIOUPKUOJY' !initial guess + iter=0 + + write(*,'(A10,A30,A10)') 'iter','best','fitness' + write(*,'(I10,A30,I10)') iter,population(1),fitness(population(1)) + + do + + iter = iter + 1 !iteration counter + + !write the iteration: + if (mod(iter,iprint)==0) write(*,'(I10,A30,I10)') iter,population(1),fitness(population(1)) + + !check exit conditions: + if ( iter>max_iter .or. fitness(population(1))==0 ) exit + + !copy best member and mutate: + population = population(1) + do i=2,population_size + call mutate(population(i),factor) + end do + + !select the new best population member: + ! [the best has the lowest value] + i_best = minloc(fitness(population)) + population(1) = population(i_best(1)) + + end do + + !write the last iteration: + if (mod(iter,iprint)/=0) write(*,'(I10,A30,I10)') iter,population(1),fitness(population(1)) + + if (iter>max_iter) then + write(*,*) 'No solution found.' + else + write(*,*) 'Solution found.' + end if + + !*************************************************************************************************** + end program evolve + !*************************************************************************************************** diff --git a/Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-2.f b/Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-2.f new file mode 100644 index 0000000000..b55ef295ae --- /dev/null +++ b/Task/Evolutionary-algorithm/Fortran/evolutionary-algorithm-2.f @@ -0,0 +1,17 @@ + iter best fitness + 0 PACQXJB CQPWEYKSVDCIOUPKUOJY 459 + 5 PACDXJBRCQP EYKSVDK OAPKGOJY 278 + 10 PAPDJJBOCQP EYCDKDK A PHGQJF 177 + 15 PAUDJJBO FP FY VKBL A PEGQJF 100 + 20 PEUDJMOO KP FY IKLD A YECQJF 57 + 25 PEUHJMOT KU FS IKLD A YECQJL 35 + 30 PEUHJMIT KU GS LKJD A YEAQFL 23 + 35 MERHJMIT KT IS LHJD A YEASFL 15 + 40 MERHJMKS IT IS LIJD A WEASFL 7 + 45 MERHINKS IT IS LIJD A WEASFL 5 + 50 MERHINKS IT IS LIJD A WEASEL 4 + 55 MERHINKS IT IS LIKD A WEASEL 3 + 60 MESHINKS IT IS LIKD A WEASEL 2 + 65 MESHINKS IT IS LIKD A WEASEL 2 + 70 MESHINKS IT IS LIKE A WEASEL 1 + 75 METHINKS IT IS LIKE A WEASEL 0 diff --git a/Task/Evolutionary-algorithm/Go/evolutionary-algorithm.go b/Task/Evolutionary-algorithm/Go/evolutionary-algorithm.go new file mode 100644 index 0000000000..8b71ea3576 --- /dev/null +++ b/Task/Evolutionary-algorithm/Go/evolutionary-algorithm.go @@ -0,0 +1,65 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +var target = []byte("METHINKS IT IS LIKE A WEASEL") +var set = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZ ") +var parent []byte + +func init() { + rand.Seed(time.Now().UnixNano()) + parent = make([]byte, len(target)) + for i := range parent { + parent[i] = set[rand.Intn(len(set))] + } +} + +// fitness: 0 is perfect fit. greater numbers indicate worse fit. +func fitness(a []byte) (h int) { + // (hamming distance) + for i, tc := range target { + if a[i] != tc { + h++ + } + } + return +} + +// set m to mutation of p, with each character of p mutated with probability r +func mutate(p, m []byte, r float64) { + for i, ch := range p { + if rand.Float64() < r { + m[i] = set[rand.Intn(len(set))] + } else { + m[i] = ch + } + } +} + +func main() { + const c = 20 // number of times to copy and mutate parent + + copies := make([][]byte, c) + for i := range copies { + copies[i] = make([]byte, len(parent)) + } + + fmt.Println(string(parent)) + for best := fitness(parent); best > 0; { + for _, cp := range copies { + mutate(parent, cp, .05) + } + for _, cp := range copies { + fm := fitness(cp) + if fm < best { + best = fm + copy(parent, cp) + fmt.Println(string(parent)) + } + } + } +} diff --git a/Task/Evolutionary-algorithm/Haskell/evolutionary-algorithm-1.hs b/Task/Evolutionary-algorithm/Haskell/evolutionary-algorithm-1.hs new file mode 100644 index 0000000000..f882f52fa4 --- /dev/null +++ b/Task/Evolutionary-algorithm/Haskell/evolutionary-algorithm-1.hs @@ -0,0 +1,48 @@ +import System.Random +import Control.Monad +import Data.List +import Data.Ord +import Data.Array + +showNum :: (Num a) => Int -> a -> String +showNum w = until ((>w-1).length) (' ':) . show + +replace :: Int -> a -> [a] -> [a] +replace n c ls = take (n-1) ls ++ [c] ++ drop n ls + +target = "METHINKS IT IS LIKE A WEASEL" +pfit = length target +mutateRate = 20 +popsize = 100 +charSet = listArray (0,26) $ ' ': ['A'..'Z'] :: Array Int Char + +fitness = length . filter id . zipWith (==) target + +printRes i g = putStrLn $ + "gen:" ++ showNum 4 i ++ " " + ++ "fitn:" ++ showNum 4 (round $ 100 * fromIntegral s / fromIntegral pfit ) ++ "% " + ++ show g + where s = fitness g + +mutate :: [Char] -> Int -> IO [Char] +mutate g mr = do + let r = length g + chances <- replicateM r $ randomRIO (1,mr) + let pos = elemIndices 1 chances + chrs <- replicateM (length pos) $ randomRIO (bounds charSet) + let nchrs = map (charSet!) chrs + return $ foldl (\ng (p,c) -> replace (p+1) c ng) g (zip pos nchrs) + +evolve :: [Char] -> Int -> Int -> IO () +evolve parent gen mr = do + when ((gen-1) `mod` 20 == 0) $ printRes (gen-1) parent + children <- replicateM popsize (mutate parent mr) + let child = maximumBy (comparing fitness) (parent:children) + if fitness child == pfit then printRes gen child + else evolve child (succ gen) mr + +main = do + let r = length target + genes <- replicateM r $ randomRIO (bounds charSet) + let parent = map (charSet!) genes + evolve parent 1 mutateRate diff --git a/Task/Evolutionary-algorithm/Haskell/evolutionary-algorithm-2.hs b/Task/Evolutionary-algorithm/Haskell/evolutionary-algorithm-2.hs new file mode 100644 index 0000000000..b6fa3062d2 --- /dev/null +++ b/Task/Evolutionary-algorithm/Haskell/evolutionary-algorithm-2.hs @@ -0,0 +1,36 @@ +import System +import Random +import Data.List +import Data.Ord +import Data.Array +import Control.Monad +import Control.Arrow + +target = "METHINKS IT IS LIKE A WEASEL" +mutateRate = 0.1 +popSize = 100 +printEvery = 10 + +alphabet = listArray (0,26) (' ':['A'..'Z']) + +randomChar = (randomRIO (0,26) :: IO Int) >>= return . (alphabet !) + +origin = mapM createChar target + where createChar c = randomChar + +fitness = length . filter id . zipWith (==) target + +mutate = mapM mutateChar + where mutateChar c = do + r <- randomRIO (0.0,1.0) :: IO Double + if r < mutateRate then randomChar else return c + +converge n parent = do + if n`mod`printEvery == 0 then putStrLn fmtd else return () + if target == parent + then putStrLn $ "\nFinal: " ++ fmtd + else mapM mutate (replicate (popSize-1) parent) >>= + converge (n+1) . fst . maximumBy (comparing snd) . map (id &&& fitness) . (parent:) + where fmtd = parent ++ ": " ++ show (fitness parent) ++ " (" ++ show n ++ ")" + +main = origin >>= converge 0 diff --git a/Task/Evolutionary-algorithm/Java/evolutionary-algorithm.java b/Task/Evolutionary-algorithm/Java/evolutionary-algorithm.java new file mode 100644 index 0000000000..1bd3c0b035 --- /dev/null +++ b/Task/Evolutionary-algorithm/Java/evolutionary-algorithm.java @@ -0,0 +1,58 @@ +import java.util.Random; + +public class EvoAlgo { + static final String target = "METHINKS IT IS LIKE A WEASEL"; + static final char[] possibilities = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ".toCharArray(); + static int C = 100; //number of spawn per generation + static double minMutateRate = 0.09; + static int perfectFitness = target.length(); + private static String parent; + static Random rand = new Random(); + + private static int fitness(String trial){ + int retVal = 0; + for(int i = 0;i < trial.length(); i++){ + if (trial.charAt(i) == target.charAt(i)) retVal++; + } + return retVal; + } + + private static double newMutateRate(){ + return (((double)perfectFitness - fitness(parent)) / perfectFitness * (1 - minMutateRate)); + } + + private static String mutate(String parent, double rate){ + String retVal = ""; + for(int i = 0;i < parent.length(); i++){ + retVal += (rand.nextDouble() <= rate) ? + possibilities[rand.nextInt(possibilities.length)]: + parent.charAt(i); + } + return retVal; + } + + public static void main(String[] args){ + parent = mutate(target, 1); + int iter = 0; + while(!target.equals(parent)){ + double rate = newMutateRate(); + iter++; + if(iter % 100 == 0){ + System.out.println(iter +": "+parent+ ", fitness: "+fitness(parent)+", rate: "+rate); + } + String bestSpawn = null; + int bestFit = 0; + for(int i = 0; i < C; i++){ + String spawn = mutate(parent, rate); + int fitness = fitness(spawn); + if(fitness > bestFit){ + bestSpawn = spawn; + bestFit = fitness; + } + } + parent = bestFit > fitness(parent) ? bestSpawn : parent; + } + System.out.println(parent+", "+iter); + } + +} diff --git a/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm.js b/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm.js new file mode 100644 index 0000000000..42c57caec0 --- /dev/null +++ b/Task/Evolutionary-algorithm/JavaScript/evolutionary-algorithm.js @@ -0,0 +1,230 @@ +// ------------------------------------- Cross-browser Compatibility ------------------------------------- + +/* Compatibility code to reduce an array + * Source: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Reduce + */ +if (!Array.prototype.reduce) { + Array.prototype.reduce = function (fun /*, initialValue */ ) { + "use strict"; + + if (this === void 0 || this === null) throw new TypeError(); + + var t = Object(this); + var len = t.length >>> 0; + if (typeof fun !== "function") throw new TypeError(); + + // no value to return if no initial value and an empty array + if (len == 0 && arguments.length == 1) throw new TypeError(); + + var k = 0; + var accumulator; + if (arguments.length >= 2) { + accumulator = arguments[1]; + } else { + do { + if (k in t) { + accumulator = t[k++]; + break; + } + + // if array contains no values, no initial value to return + if (++k >= len) throw new TypeError(); + } + while (true); + } + + while (k < len) { + if (k in t) accumulator = fun.call(undefined, accumulator, t[k], k, t); + k++; + } + + return accumulator; + }; +} + +/* Compatibility code to map an array + * Source: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Map + */ +if (!Array.prototype.map) { + Array.prototype.map = function (fun /*, thisp */ ) { + "use strict"; + + if (this === void 0 || this === null) throw new TypeError(); + + var t = Object(this); + var len = t.length >>> 0; + if (typeof fun !== "function") throw new TypeError(); + + var res = new Array(len); + var thisp = arguments[1]; + for (var i = 0; i < len; i++) { + if (i in t) res[i] = fun.call(thisp, t[i], i, t); + } + + return res; + }; +} + +/* ------------------------------------- Generator ------------------------------------- + * Generates a fixed length gene sequence via a gene strategy object. + * The gene strategy object must have two functions: + * - "create": returns create a new gene + * - "mutate(existingGene)": returns mutation of an existing gene + */ +function Generator(length, mutationRate, geneStrategy) { + this.size = length; + this.mutationRate = mutationRate; + this.geneStrategy = geneStrategy; +} + +Generator.prototype.spawn = function () { + var genes = [], + x; + for (x = 0; x < this.size; x += 1) { + genes.push(this.geneStrategy.create()); + } + return genes; +}; + +Generator.prototype.mutate = function (parent) { + return parent.map(function (char) { + if (Math.random() > this.mutationRate) { + return char; + } + return this.geneStrategy.mutate(char); + }, this); +}; + +/* ------------------------------------- Population ------------------------------------- + * Helper class that holds and spawns a new population. + */ +function Population(size, generator) { + this.size = size; + this.generator = generator; + + this.population = []; + // Build initial popuation; + for (var x = 0; x < this.size; x += 1) { + this.population.push(this.generator.spawn()); + } +} + +Population.prototype.spawn = function (parent) { + this.population = []; + for (var x = 0; x < this.size; x += 1) { + this.population.push(this.generator.mutate(parent)); + } +}; + +/* ------------------------------------- Evolver ------------------------------------- + * Attempts to converge a population based a fitness strategy object. + * The fitness strategy object must have three function + * - "score(individual)": returns a score for an individual. + * - "compare(scoreA, scoreB)": return true if scoreA is better (ie more fit) then scoreB + * - "done( score )": return true if score is acceptable (ie we have successfully converged). + */ +function Evolver(size, generator, fitness) { + this.done = false; + this.fitness = fitness; + this.population = new Population(size, generator); +} + +Evolver.prototype.getFittest = function () { + return this.population.population.reduce(function (best, individual) { + var currentScore = this.fitness.score(individual); + if (best === null || this.fitness.compare(currentScore, best.score)) { + return { + score: currentScore, + individual: individual + }; + } else { + return best; + } + }, null); +}; + +Evolver.prototype.doGeneration = function () { + this.fittest = this.getFittest(); + this.done = this.fitness.done(this.fittest.score); + if (!this.done) { + this.population.spawn(this.fittest.individual); + } +}; + +Evolver.prototype.run = function (onCheckpoint, checkPointFrequency) { + checkPointFrequency = checkPointFrequency || 10; // Default to Checkpoints every 10 generations + var generation = 0; + while (!this.done) { + this.doGeneration(); + if (generation % checkPointFrequency === 0) { + onCheckpoint(generation, this.fittest); + } + generation += 1; + } + onCheckpoint(generation, this.fittest); + return this.fittest; +}; + +// ------------------------------------- Exports ------------------------------------- +window.Generator = Generator; +window.Evolver = Evolver; + + +// helper utitlity to combine elements of two arrays. +Array.prototype.zip = function (b, func) { + var result = [], + max = Math.max(this.length, b.length), + x; + for (x = 0; x < max; x += 1) { + result.push(func(this[x], b[x])); + } + return result; +}; + +var target = "METHINKS IT IS LIKE A WEASEL", geneStrategy, fitness, target, generator, evolver, result; + +geneStrategy = { + // The allowed character set (as an array) + characterSet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ ".split(""), + + /* + Pick a random character from the characterSet + */ + create: function getRandomGene() { + var randomNumber = Math.floor(Math.random() * this.characterSet.length); + return this.characterSet[randomNumber]; + } +}; +geneStrategy.mutate = geneStrategy.create; // Our mutation stragtegy is to simply get a random gene +fitness = { + // The target (as an array of characters) + target: target.split(""), + equal: function (geneA, geneB) { + return (geneA === geneB ? 0 : 1); + }, + sum: function (runningTotal, value) { + return runningTotal + value; + }, + + /* + We give one point to for each corect letter + */ + score: function (genes) { + var diff = genes.zip(this.target, this.equal); // create an array of ones and zeros + return diff.reduce(this.sum, 0); // Sum the array values together. + }, + compare: function (scoreA, scoreB) { + return scoreA <= scoreB; // Lower scores are better + }, + done: function (score) { + return score === 0; // We have matched the target string. + } +}; + +generator = new Generator(target.length, 0.05, geneStrategy); +evolver = new Evolver(100, generator, fitness); + +function showProgress(generation, fittest) { + document.write("Generation: " + generation + ", Best: " + fittest.individual.join("") + ", fitness:" + fittest.score + "
"); +} +result = evolver.run(showProgress); diff --git a/Task/Evolutionary-algorithm/Lua/evolutionary-algorithm.lua b/Task/Evolutionary-algorithm/Lua/evolutionary-algorithm.lua new file mode 100644 index 0000000000..2d3d272d00 --- /dev/null +++ b/Task/Evolutionary-algorithm/Lua/evolutionary-algorithm.lua @@ -0,0 +1,52 @@ +local target = "METHINKS IT IS LIKE A WEASEL" +local alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ " +local c, p = 100, 0.06 + +local function fitness(s) + local score = #target + for i = 1,#target do + if s:sub(i,i) == target:sub(i,i) then score = score - 1 end + end + return score +end + +local function mutate(s, rate) + local result, idx = "" + for i = 1,#s do + if math.random() < rate then + idx = math.random(#alphabet) + result = result .. alphabet:sub(idx,idx) + else + result = result .. s:sub(i,i) + end + end + return result, fitness(result) +end + +local function randomString(len) + local result, idx = "" + for i = 1,len do + idx = math.random(#alphabet) + result = result .. alphabet:sub(idx,idx) + end + return result +end + +local function printStep(step, s, fit) + print(string.format("%04d: ", step) .. s .. " [" .. fit .."]") +end + +math.randomseed(os.time()) +local parent = randomString(#target) +printStep(0, parent, fitness(parent)) + +local step = 0 +while parent ~= target do + local bestFitness, bestChild, child, fitness = #target + 1 + for i = 1,c do + child, fitness = mutate(parent, p) + if fitness < bestFitness then bestFitness, bestChild = fitness, child end + end + parent, step = bestChild, step + 1 + printStep(step, parent, bestFitness) +end diff --git a/Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-1.m b/Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-1.m new file mode 100644 index 0000000000..51b781b739 --- /dev/null +++ b/Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-1.m @@ -0,0 +1,220 @@ +%This class impliments a string that mutates to a target +classdef EvolutionaryAlgorithm + + properties + + target; + parent; + children = {}; + validAlphabet; + + %Constants + numChildrenPerIteration; + maxIterations; + mutationRate; + + end + + methods + + %Class constructor + function family = EvolutionaryAlgorithm(target,mutationRate,numChildren,maxIterations) + + family.validAlphabet = char([32 (65:90)]); %Space char and A-Z + family.target = target; + family.children = cell(numChildren,1); + family.numChildrenPerIteration = numChildren; + family.maxIterations = maxIterations; + family.mutationRate = mutationRate; + initialize(family); + + end %class constructor + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %Helper functions and class get/set functions + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + %setAlphabet() - sets the valid alphabet for the current instance + %of the EvolutionaryAlgorithm class. + function setAlphabet(family,alphabet) + + if(ischar(alphabet)) + family.validAlphabet = alphabet; + + %Makes change permanent + assignin('caller',inputname(1),family); + else + error 'New alphabet must be a string or character array'; + end + + end + + %setTarget() - sets the target for the current instance + %of the EvolutionaryAlgorithm class. + function setTarget(family,target) + + if(ischar(target)) + family.target = target; + + %Makes change permanent + assignin('caller',inputname(1),family); + else + error 'New target must be a string or character array'; + end + + end + + %setMutationRate() - sets the mutation rate for the current instance + %of the EvolutionaryAlgorithm class. + function setMutationRate(family,mutationRate) + + if(isnumeric(mutationRate)) + family.mutationRate = mutationRate; + + %Makes change permanent + assignin('caller',inputname(1),family); + else + error 'New mutation rate must be a double precision number'; + end + + end + + %setMaxIterations() - sets the maximum number of iterations during + %evolution for the current instance of the EvolutionaryAlgorithm class. + function setMaxIterations(family,maxIterations) + + if(isnumeric(maxIterations)) + family.maxIterations = maxIterations; + + %Makes change permanent + assignin('caller',inputname(1),family); + else + error 'New maximum amount of iterations must be a double precision number'; + end + + end + + %display() - overrides the built-in MATLAB display() function, to + %display the important class variables + function display(family) + disp([sprintf('Target: %s\n',family.target)... + sprintf('Parent: %s\n',family.parent)... + sprintf('Valid Alphabet: %s\n',family.validAlphabet)... + sprintf('Number of Children: %d\n',family.numChildrenPerIteration)... + sprintf('Mutation Rate [0,1]: %d\n',family.mutationRate)... + sprintf('Maximum Iterations: %d\n',family.maxIterations)]); + end + + %disp() - overrides the built-in MATLAB disp() function, to + %display the important class variables + function disp(family) + display(family); + end + + %randAlphabetElement() - Generates a random character from the + %valid alphabet for the current instance of the class. + function elements = randAlphabetElements(family,numChars) + + %Sample the valid alphabet randomly from the uniform + %distribution + N = length(family.validAlphabet); + choices = ceil(N*rand(1,numChars)); + + elements = family.validAlphabet(choices); + + end + + %initialize() - Sets the parent to a random string of length equal + %to the length of the target + function parent = initialize(family) + + family.parent = randAlphabetElements(family,length(family.target)); + parent = family.parent; + + %Makes changes to the instance of EvolutionaryAlgorithm permanent + assignin('caller',inputname(1),family); + + end %initialize + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %Functions required by task specification + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + %mutate() - generates children from the parent and mutates them + function mutate(family) + + sizeParent = length(family.parent); + + %Generate mutatant children sequentially + for child = (1:family.numChildrenPerIteration) + + parentCopy = family.parent; + + for charIndex = (1:sizeParent) + if (rand(1) < family.mutationRate) + parentCopy(charIndex) = randAlphabetElements(family,1); + end + end + + family.children{child} = parentCopy; + + end + + %Makes changes to the instance of EvolutionaryAlgorithm permanent + assignin('caller',inputname(1),family); + + end %mutate + + %fitness() - Computes the Hamming distance between the target + %string and the string input as the familyMember argument + function theFitness = fitness(family,familyMember) + + if not(ischar(familyMember)) + error 'The second argument must be a string'; + end + + theFitness = sum(family.target == familyMember); + end + + %evolve() - evolves the family until the target is reached or it + %exceeds the maximum amount of iterations + function [iteration,mostFitFitness] = evolve(family) + + iteration = 0; + mostFitFitness = 0; + targetFitness = fitness(family,family.target); + + disp(['Target fitness is ' num2str(targetFitness)]); + + while (mostFitFitness < targetFitness) && (iteration < family.maxIterations) + + iteration = iteration + 1; + + mutate(family); + + parentFitness = fitness(family,family.parent); + mostFit = family.parent; + mostFitFitness = parentFitness; + + for child = (1:family.numChildrenPerIteration) + + childFitness = fitness(family,family.children{child}); + if childFitness > mostFitFitness + mostFit = family.children{child}; + mostFitFitness = childFitness; + end + + end + + family.parent = mostFit; + disp([num2str(iteration) ': ' mostFit ' - Fitness: ' num2str(mostFitFitness)]); + + end + + %Makes changes to the instance of EvolutionaryAlgorithm permanent + assignin('caller',inputname(1),family); + + end %evolve + + end %methods +end %classdef diff --git a/Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-2.m b/Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-2.m new file mode 100644 index 0000000000..5cc087acf1 --- /dev/null +++ b/Task/Evolutionary-algorithm/MATLAB/evolutionary-algorithm-2.m @@ -0,0 +1,27 @@ +>> instance = EvolutionaryAlgorithm('METHINKS IT IS LIKE A WEASEL',.08,50,1000) +Target: METHINKS IT IS LIKE A WEASEL +Parent: UVEOCXXFBGDCSFNMJQNWTPJ PCVA +Valid Alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ +Number of Children: 50 +Mutation Rate [0,1]: 8.000000e-002 +Maximum Iterations: 1000 + +>> evolve(instance); +Target fitness is 28 +1: MVEOCXXFBYD SFCMJQNWTPM PCVA - Fitness: 2 +2: MEEOCXXFBYD SFCMJQNWTPM PCVA - Fitness: 3 +3: MEEHCXXFBYD SFCMJXNWTPM ECVA - Fitness: 4 +4: MEEHCXXFBYD SFCMJXNWTPM ECVA - Fitness: 4 +5: METHCXAFBYD SFCMJXNWXPMARPVA - Fitness: 5 +6: METHCXAFBYDFSFCMJXNWX MARSVA - Fitness: 6 +7: METHCXKFBYDFBFCQJXNWX MATSVA - Fitness: 7 +8: METHCXKFBYDFBF QJXNWX MATSVA - Fitness: 8 +9: METHCXKFBYDFBF QJXNWX MATSVA - Fitness: 8 +10: METHCXKFUYDFBF QJXNWX MITSEA - Fitness: 9 +20: METHIXKF YTBOF LIKN G MIOSEI - Fitness: 16 +30: METHIXKS YTCOF LIKN A MIOSEL - Fitness: 19 +40: METHIXKS YTCIF LIKN A MEUSEL - Fitness: 21 +50: METHIXKS YT IS LIKE A PEUSEL - Fitness: 24 +100: METHIXKS YT IS LIKE A WEASEL - Fitness: 26 +150: METHINKS YT IS LIKE A WEASEL - Fitness: 27 +195: METHINKS IT IS LIKE A WEASEL - Fitness: 28 diff --git a/Task/Evolutionary-algorithm/Perl/evolutionary-algorithm.pl b/Task/Evolutionary-algorithm/Perl/evolutionary-algorithm.pl new file mode 100644 index 0000000000..78c889d675 --- /dev/null +++ b/Task/Evolutionary-algorithm/Perl/evolutionary-algorithm.pl @@ -0,0 +1,45 @@ +use List::Util 'reduce'; +use List::MoreUtils 'false'; + +### Generally useful declarations + +sub randElm + {$_[int rand @_]} + +sub minBy (&@) + {my $f = shift; + reduce {$f->($b) < $f->($a) ? $b : $a} @_;} + +sub zip + {@_ or return (); + for (my ($n, @a) = 0 ;; ++$n) + {my @row; + foreach (@_) + {$n < @$_ or return @a; + push @row, $_->[$n];} + push @a, \@row;}} + +### Task-specific declarations + +my $C = 100; +my $mutation_rate = .05; +my @target = split '', 'METHINKS IT IS LIKE A WEASEL'; +my @valid_chars = (' ', 'A' .. 'Z'); + +sub fitness + {false {$_->[0] eq $_->[1]} zip shift, \@target;} + +sub mutate + {my $rate = shift; + return [map {rand() < $rate ? randElm @valid_chars : $_} @{shift()}];} + +### Main loop + +my $parent = [map {randElm @valid_chars} @target]; + +while (fitness $parent) + {$parent = + minBy \&fitness, + map {mutate $mutation_rate, $parent} + 1 .. $C; + print @$parent, "\n";} diff --git a/Task/Evolutionary-algorithm/PicoLisp/evolutionary-algorithm.l b/Task/Evolutionary-algorithm/PicoLisp/evolutionary-algorithm.l new file mode 100644 index 0000000000..8e00e87a6a --- /dev/null +++ b/Task/Evolutionary-algorithm/PicoLisp/evolutionary-algorithm.l @@ -0,0 +1,37 @@ +(load "@lib/simul.l") + +(setq *Target (chop "METHINKS IT IS LIKE A WEASEL")) + +# Generate random character +(de randChar () + (if (=0 (rand 0 26)) + " " + (char (rand `(char "A") `(char "Z"))) ) ) + +# Fitness function (Hamming distance) +(de fitness (A) + (cnt = A *Target) ) + +# Genetic algorithm +(gen + (make # Parent population + (do 100 # C = 100 children + (link + (make + (do (length *Target) + (link (randChar)) ) ) ) ) ) + '((A) # Termination condition + (prinl (maxi fitness A)) # Print the fittest element + (member *Target A) ) # and check if solution is found + '((A B) # Recombination function + (mapcar + '((C D) (if (rand T) C D)) # Pick one of the chars + A B ) ) + '((A) # Mutation function + (mapcar + '((C) + (if (=0 (rand 0 10)) # With a proability of 10% + (randChar) # generate a new char, otherwise + C ) ) # return the current char + A ) ) + fitness ) # Selection function diff --git a/Task/Evolutionary-algorithm/Python/evolutionary-algorithm-1.py b/Task/Evolutionary-algorithm/Python/evolutionary-algorithm-1.py new file mode 100644 index 0000000000..e2502eb9c4 --- /dev/null +++ b/Task/Evolutionary-algorithm/Python/evolutionary-algorithm-1.py @@ -0,0 +1,35 @@ +from string import ascii_uppercase +from random import choice, random + +target = list("METHINKS IT IS LIKE A WEASEL") +charset = ascii_uppercase + ' ' +parent = [choice(charset) for _ in range(len(target))] +minmutaterate = .09 +C = range(100) + +perfectfitness = float(len(target)) +def fitness(trial): + 'Sum of matching chars by position' + return sum(t==h for t,h in zip(trial, target)) + +def mutaterate(): + 'Less mutation the closer the fit of the parent' + return 1-((perfectfitness - fitness(parent)) / perfectfitness * (1 - minmutaterate)) + +def mutate(parent, rate): + return [(ch if random() <= rate else choice(charset)) for ch in parent] + +def que(): + '(from the favourite saying of Manuel in Fawlty Towers)' + print ("#%-4i, fitness: %4.1f%%, '%s'" % + (iterations, fitness(parent)*100./perfectfitness, ''.join(parent))) + +iterations = 0 +while parent != target: + rate = mutaterate() + iterations += 1 + if iterations % 100 == 0: que() + copies = [ mutate(parent, rate) for _ in C ] + [parent] + parent = max(copies, key=fitness) +print () +que() diff --git a/Task/Evolutionary-algorithm/Python/evolutionary-algorithm-2.py b/Task/Evolutionary-algorithm/Python/evolutionary-algorithm-2.py new file mode 100644 index 0000000000..19745bc435 --- /dev/null +++ b/Task/Evolutionary-algorithm/Python/evolutionary-algorithm-2.py @@ -0,0 +1,21 @@ +from random import choice, random + +target = list("METHINKS IT IS LIKE A WEASEL") +alphabet = " ABCDEFGHIJLKLMNOPQRSTUVWXYZ" +p = 0.05 # mutation probability +c = 100 # number of children in each generation + +def neg_fitness(trial): + return sum(t != h for t,h in zip(trial, target)) + +def mutate(parent): + return [(choice(alphabet) if random() < p else ch) for ch in parent] + +parent = [choice(alphabet) for _ in xrange(len(target))] +i = 0 +print "%3d" % i, "".join(parent) +while parent != target: + copies = (mutate(parent) for _ in xrange(c)) + parent = min(copies, key=neg_fitness) + print "%3d" % i, "".join(parent) + i += 1 diff --git a/Task/Evolutionary-algorithm/R/evolutionary-algorithm.r b/Task/Evolutionary-algorithm/R/evolutionary-algorithm.r new file mode 100644 index 0000000000..8c589dabd7 --- /dev/null +++ b/Task/Evolutionary-algorithm/R/evolutionary-algorithm.r @@ -0,0 +1,52 @@ +set.seed(1234, kind="Mersenne-Twister") + +## Easier if the string is a character vector +target <- unlist(strsplit("METHINKS IT IS LIKE A WEASEL", "")) + +charset <- c(LETTERS, " ") +parent <- sample(charset, length(target), replace=TRUE) + +mutaterate <- 0.01 + +## Number of offspring in each generation +C <- 100 + +## Hamming distance between strings normalized by string length is used +## as the fitness function. +fitness <- function(parent, target) { + sum(parent == target) / length(target) +} + +mutate <- function(parent, rate, charset) { + p <- runif(length(parent)) + nMutants <- sum(p < rate) + if (nMutants) { + parent[ p < rate ] <- sample(charset, nMutants, replace=TRUE) + } + parent +} + +evolve <- function(parent, mutate, fitness, C, mutaterate, charset) { + children <- replicate(C, mutate(parent, mutaterate, charset), + simplify=FALSE) + children <- c(list(parent), children) + children[[which.max(sapply(children, fitness, target=target))]] +} + +.printGen <- function(parent, target, gen) { + cat(format(i, width=3), + formatC(fitness(parent, target), digits=2, format="f"), + paste(parent, collapse=""), "\n") +} + +i <- 0 +.printGen(parent, target, i) +while ( ! all(parent == target)) { + i <- i + 1 + parent <- evolve(parent, mutate, fitness, C, mutaterate, charset) + + if (i %% 20 == 0) { + .printGen(parent, target, i) + } +} +.printGen(parent, target, i) diff --git a/Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-1.rexx b/Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-1.rexx new file mode 100644 index 0000000000..56e274a750 --- /dev/null +++ b/Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-1.rexx @@ -0,0 +1,54 @@ +/* Weasel.rex - Me thinks thou art a weasel. - G,M.D. - 2/25/2011 */ +arg C M +/* C is the number of children parent produces each generation. */ +/* M is the mutation rate of each gene (character) */ + +call initialize +generation = 0 +do until parent = target + most_fitness = fitness(parent) + most_fit = parent + do C + child = mutate(parent, M) + child_fitness = fitness(child) + if child_fitness > most_fitness then + do + most_fitness = child_fitness + most_fit = child + say "Generation" generation": most fit='"most_fit"', fitness="left(most_fitness,4) + end + end + parent = most_fit + generation = generation + 1 +end +exit + +initialize: + target = "METHINKS IT IS LIKE A WEASEL" + alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ " + c_length_target = length(target) + parent = mutate(copies(" ", c_length_target), 1.0) + do i = 1 to c_length_target + target_ch.i = substr(target,i,1) + end +return + +fitness: procedure expose target_ch. c_length_target + arg parm_string + fitness = 0 + do i_target = 1 to c_length_target + if substr(parm_string,i_target,1) = target_ch.i_target then + fitness = fitness + 1 + end +return fitness + +mutate:procedure expose alphabet +arg string, parm_mutation_rate + result = "" + do istr = 1 to length(string) + if random(1,1000)/1000 <= parm_mutation_rate then + result = result || substr(alphabet,random(1,length(alphabet)),1) + else + result = result || substr(string,istr,1) + end +return result diff --git a/Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-2.rexx b/Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-2.rexx new file mode 100644 index 0000000000..ed71bb9879 --- /dev/null +++ b/Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-2.rexx @@ -0,0 +1,35 @@ +/*REXX program demonstrates an evolutionary algorithm (using mutation).*/ +parse arg children MR seed . /*get options (maybe) from C.L. */ +if children=='' then children = 10 /*# of children produced each gen*/ +if MR =='' then MR = '4%' /*the char Mutation Rate each gen*/ +if right(MR,1)=='%' then MR=strip(MR,,'%')/100 /*expressed as %? Adjust*/ +if seed\=='' then call random ,,seed /*allow the runs to be repeatable*/ +abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' ; Labc=length(abc) +target= 'METHINKS IT IS LIKE A WEASEL' ; Ltar=length(target) +parent= mutate( left('',Ltar), 1) /*gen rand str,same length as tar*/ +say center('target string',Ltar,'─') "children" 'mutationRate' +say target center(children,8) center((MR*100/1)'%',12) ; say +say center('new string',Ltar,'─') "closeness" 'generation' + + do gen=0 until parent==target; close=fitness(parent) + almost=parent + do children; child=mutate(parent,MR) + _=fitness(child); if _<=close then iterate + close=_; almost=child + say almost right(close,9) right(gen,10) + end /*children*/ + parent=almost + end /*gen*/ +exit /*stick a fork in it, we're done.*/ +/*───────────────────────────────────FITNESS subroutine─────────────────*/ +fitness: parse arg x; hit=0; do k=1 for Ltar + hit=hit+(substr(x,k,1)==substr(target,k,1)) + end /*k*/ +return hit +/*───────────────────────────────────MUTATE subroutine──────────────────*/ +mutate: parse arg x,rate,? /*set ? to a null, x=string. */ + do j=1 for Ltar; r=random(1,100000) + if .00001*r<=rate then ?=? || substr(abc,r//Labc+1,1) + else ?=? || substr(x,j,1) + end /*j*/ +return ? diff --git a/Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-3.rexx b/Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-3.rexx new file mode 100644 index 0000000000..d7f21be771 --- /dev/null +++ b/Task/Evolutionary-algorithm/REXX/evolutionary-algorithm-3.rexx @@ -0,0 +1,45 @@ +/*REXX program demonstrates an evolutionary algorithm (using mutation).*/ +parse arg children MR seed . /*get options (maybe) from C.L. */ +if children=='' then children = 10 /*# of children produced each gen*/ +if MR =='' then MR = "4%" /*the char Mutation Rate each gen*/ +if right(MR,1)=='%' then MR=strip(MR,,"%")/100 /*expressed as %? Adjust*/ +if seed\=='' then call random ,,seed /*allow the runs to be repeatable*/ +abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' ; Labc=length(abc) + + do i=0 for Labc /*define array (faster compare), */ + A.i=substr(abc, i+1, 1) /* it's better than picking out a*/ + end /*i*/ /* byte from a character string. */ + +target= 'METHINKS IT IS LIKE A WEASEL' ; Ltar=length(target) + + do i=1 for Ltar /*define array (faster compare), */ + T.i=substr(target, i, 1) /*it's better than a byte-by-byte*/ + end /*i*/ /*compare using character strings*/ + +parent= mutate( left('', Ltar), 1) /*gen rand str,same length as tar*/ +say center('target string', Ltar, '─') "children" 'mutationRate' +say target center(children, 8) center((MR*100/1)'%', 12) ; say +say center('new string', Ltar, '─') "closeness" 'generation' + + do gen=0 until parent==target; close=fitness(parent) + almost=parent + do children; child=mutate(parent, MR) + _=fitness(child); if _<=close then iterate + close=_; almost=child + say almost right(close, 9) right(gen, 10) + end /*children*/ + parent=almost + end /*gen*/ +exit /*stick a fork in it, we're done.*/ +/*───────────────────────────────────FITNESS subroutine─────────────────*/ +fitness: parse arg x; hit=0; do k=1 for Ltar + hit=hit + (substr(x,k,1) == T.k) + end /*k*/ +return hit +/*───────────────────────────────────MUTATE subroutine──────────────────*/ +mutate: parse arg x,rate,? /*set ? to a null, x=string. */ + do j=1 for Ltar; r=random(1, 100000) + if .00001*r<=rate then do; _=r//Labc; ?=? || A._; end + else ?=? || substr(x,j,1) + end /*j*/ +return ? diff --git a/Task/Evolutionary-algorithm/Ruby/evolutionary-algorithm.rb b/Task/Evolutionary-algorithm/Ruby/evolutionary-algorithm.rb new file mode 100644 index 0000000000..c5f0685498 --- /dev/null +++ b/Task/Evolutionary-algorithm/Ruby/evolutionary-algorithm.rb @@ -0,0 +1,40 @@ +@target = "METHINKS IT IS LIKE A WEASEL" +Charset = " ABCDEFGHIJKLMNOPQRSTUVWXYZ" +Max_mutate_rate = 0.91 +C = 100 + +def random_char; Charset[rand Charset.length].chr; end + +def fitness(candidate) + sum = 0 + candidate.chars.zip(@target.chars) {|x,y| sum += (x[0].ord - y[0].ord).abs} + 100.0 * Math.exp(Float(sum) / -10.0) +end + +def mutation_rate(candidate) + 1.0 - Math.exp( -(100.0 - fitness(candidate)) / 400.0) +end + +def mutate(parent, rate) + parent.each_char.collect {|ch| rand <= rate ? random_char : ch}.join +end + +def log(iteration, rate, parent) + puts "%4d %.2f %5.1f %s" % [iteration, rate, fitness(parent), parent] +end + +iteration = 0 +parent = Array.new(@target.length) {random_char}.join +prev = "" + +while parent != @target + iteration += 1 + rate = mutation_rate(parent) + if prev != parent + log iteration, rate, parent + prev = parent + end + copies = [parent] + Array.new(C) {mutate(parent, rate)} + parent = copies.max_by {|c| fitness(c)} +end +log iteration, rate, parent diff --git a/Task/Evolutionary-algorithm/Scala/evolutionary-algorithm.scala b/Task/Evolutionary-algorithm/Scala/evolutionary-algorithm.scala new file mode 100644 index 0000000000..f218de6b25 --- /dev/null +++ b/Task/Evolutionary-algorithm/Scala/evolutionary-algorithm.scala @@ -0,0 +1,37 @@ +import scala.annotation.tailrec + +case class LearnerParams(target:String,rate:Double,C:Int) + +val chars = ('A' to 'Z') ++ List(' ') +val randgen = new scala.util.Random +def randchar = { + val charnum = randgen.nextInt(chars.size) + chars(charnum) +} + +class RichTraversable[T](t: Traversable[T]) { + def maxBy[B](fn: T => B)(implicit ord: Ordering[B]) = t.max(ord on fn) + def minBy[B](fn: T => B)(implicit ord: Ordering[B]) = t.min(ord on fn) +} + +implicit def toRichTraversable[T](t: Traversable[T]) = new RichTraversable(t) + +def fitness(candidate:String)(implicit params:LearnerParams) = + (candidate zip params.target).map { case (a,b) => if (a==b) 1 else 0 }.sum + +def mutate(initial:String)(implicit params:LearnerParams) = + initial.map{ samechar => if(randgen.nextDouble < params.rate) randchar else samechar } + +@tailrec +def evolve(generation:Int, initial:String)(implicit params:LearnerParams){ + import params._ + printf("Generation: %3d %s\n",generation, initial) + if(initial == target) return () + val candidates = for (number <- 1 to C) yield mutate(initial) + val next = candidates.maxBy(fitness) + evolve(generation+1,next) +} + +implicit val params = LearnerParams("METHINKS IT IS LIKE A WEASEL",0.01,100) +val initial = (1 to params.target.size) map(x => randchar) mkString +evolve(0,initial) diff --git a/Task/Evolutionary-algorithm/Smalltalk/evolutionary-algorithm.st b/Task/Evolutionary-algorithm/Smalltalk/evolutionary-algorithm.st new file mode 100644 index 0000000000..6b729b34db --- /dev/null +++ b/Task/Evolutionary-algorithm/Smalltalk/evolutionary-algorithm.st @@ -0,0 +1,116 @@ +Object subclass: Evolution [ + |target parent mutateRate c alphabet fitness| + + Evolution class >> newWithRate: rate andTarget: aTarget [ + |r| r := super new. + ^r initWithRate: rate andTarget: aTarget. + ] + + initWithRate: rate andTarget: aTarget [ + target := aTarget. + self mutationRate: rate. + self maxCount: 100. + self defaultAlphabet. + self changeParent. + self fitness: (self defaultFitness). + ^self + ] + + defaultFitness [ + ^ [:p :t | + |t1 t2 s| + t1 := p asOrderedCollection. + t2 := t asOrderedCollection. + s := 0. + t2 do: [:e| (e == (t1 removeFirst)) ifTrue: [ s:=s+1 ] ]. + s / (target size) + ] + ] + + defaultAlphabet [ alphabet := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' asOrderedCollection. ] + + maxCount: anInteger [ c := anInteger ] + + mutationRate: aFloat [ mutateRate := aFloat ] + + changeParent [ + parent := self generateStringOfLength: (target size) withAlphabet: alphabet. + ^ parent. + ] + + generateStringOfLength: len withAlphabet: ab [ + |r| + r := String new. + 1 to: len do: [ :i | + r := r , ((ab at: (Random between: 1 and: (ab size))) asString) + ]. + ^r + ] + + fitness: aBlock [ fitness := aBlock ] + + randomCollection: d [ + |r| r := OrderedCollection new. + 1 to: d do: [:i| + r add: (Random next) + ]. + ^r + ] + + mutate [ + |r p nmutants s| + r := parent copy. + p := self randomCollection: (r size). + nmutants := (p select: [ :e | (e < mutateRate)]) size. + (nmutants > 0) + ifTrue: [ |t| + s := (self generateStringOfLength: nmutants withAlphabet: alphabet) asOrderedCollection. + t := 1. + (p collect: [ :e | e < mutateRate ]) do: [ :v | + v ifTrue: [ r at: t put: (s removeFirst) ]. + t := t + 1. + ] + ]. + ^r + ] + + evolve [ + |children es mi mv| + es := self getEvolutionStatus. + children := OrderedCollection new. + 1 to: c do: [ :i | + children add: (self mutate) + ]. + children add: es. + mi := children size. + mv := fitness value: es value: target. + children doWithIndex: [:e :i| + (fitness value: e value: target) > mv + ifTrue: [ mi := i. mv := fitness value: e value: target ] + ]. + parent := children at: mi. + ^es "returns the parent, not the evolution" + ] + + printgen: i [ + ('%1 %2 "%3"' % {i . (fitness value: parent value: target) . parent }) displayNl + ] + + evoluted [ ^ target = parent ] + getEvolutionStatus [ ^ parent ] + +]. + +|organism j| + +organism := Evolution newWithRate: 0.01 andTarget: 'METHINKS IT IS LIKE A WEASEL'. + +j := 0. +[ organism evoluted ] + whileFalse: [ + j := j + 1. + organism evolve. + ((j rem: 20) = 0) ifTrue: [ organism printgen: j ] + ]. + +organism getEvolutionStatus displayNl. diff --git a/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-1.tcl b/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-1.tcl new file mode 100644 index 0000000000..30d954617d --- /dev/null +++ b/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-1.tcl @@ -0,0 +1,55 @@ +package require Tcl 8.5 + +# A function to select a random character from an argument string +proc tcl::mathfunc::randchar s { + string index $s [expr {int([string length $s]*rand())}] +} + +# Set up the initial variables +set target "METHINKS IT IS LIKE A WEASEL" +set charset "ABCDEFGHIJKLMNOPQRSTUVWXYZ " +set parent [subst [regsub -all . $target {[expr {randchar($charset)}]}]] +set MaxMutateRate 0.91 +set C 100 + +# Work with parent and target as lists of characters so iteration is more efficient +set target [split $target {}] +set parent [split $parent {}] + +# Generate the fitness *ratio* +proc fitness s { + global target + set count 0 + foreach c1 $s c2 $target { + if {$c1 eq $c2} {incr count} + } + return [expr {$count/double([llength $target])}] +} +# This generates the converse of the Python version; logically saner naming +proc mutateRate {parent} { + expr {(1.0-[fitness $parent]) * $::MaxMutateRate} +} +proc mutate {rate} { + global charset parent + foreach c $parent { + lappend result [expr {rand() <= $rate ? randchar($charset) : $c}] + } + return $result +} +proc que {} { + global iterations parent + puts [format "#%-4i, fitness %4.1f%%, '%s'" \ + $iterations [expr {[fitness $parent]*100}] [join $parent {}]] +} + +while {$parent ne $target} { + set rate [mutateRate $parent] + if {!([incr iterations] % 100)} que + set copies [list [list $parent [fitness $parent]]] + for {set i 0} {$i < $C} {incr i} { + lappend copies [list [set copy [mutate $rate]] [fitness $copy]] + } + set parent [lindex [lsort -real -decreasing -index 1 $copies] 0 0] +} +puts "" +que diff --git a/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-2.tcl b/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-2.tcl new file mode 100644 index 0000000000..0a794b47c6 --- /dev/null +++ b/Task/Evolutionary-algorithm/Tcl/evolutionary-algorithm-2.tcl @@ -0,0 +1,70 @@ +package require Tcl 8.5 +proc tcl::mathfunc::randchar {} { + # A function to select a random character + set charset "ABCDEFGHIJKLMNOPQRSTUVWXYZ " + string index $charset [expr {int([string length $charset] * rand())}] +} +set target "METHINKS IT IS LIKE A WEASEL" +set initial [subst [regsub -all . $target {[expr randchar()]}]] +set MaxMutateRate 0.91 +set C 100 + +# A place-wise equality function defined over two lists (assumed equal length) +proc fitnessByEquality {target s} { + set count 0 + foreach c1 $s c2 $target { + if {$c1 eq $c2} {incr count} + } + return [expr {$count / double([llength $target])}] +} +# Generate the fitness *ratio* by place-wise equality with the target string +interp alias {} fitness {} fitnessByEquality [split $target {}] + +# This generates the converse of the Python version; logically saner naming +proc mutationRate {individual} { + global MaxMutateRate + expr {(1.0-[fitness $individual]) * $MaxMutateRate} +} + +# Mutate a string at a particular rate (per character) +proc mutate {parent rate} { + foreach c $parent { + lappend child [expr {rand() <= $rate ? randchar() : $c}] + } + return $child +} + +# Pretty printer +proc prettyPrint {iterations parent} { + puts [format "#%-4i, fitness %5.1f%%, '%s'" $iterations \ + [expr {[fitness $parent]*100}] [join $parent {}]] +} + +# The evolutionary algorithm itself +proc evolve {initialString} { + global C + + # Work with the parent as a list; the operations are more efficient + set parent [split $initialString {}] + + for {set iterations 0} {[fitness $parent] < 1} {incr iterations} { + set rate [mutationRate $parent] + + if {$iterations % 100 == 0} { + prettyPrint $iterations $parent + } + + set copies [list [list $parent [fitness $parent]]] + for {set i 0} {$i < $C} {incr i} { + lappend copies [list \ + [set copy [mutate $parent $rate]] [fitness $copy]] + } + set parent [lindex [lsort -real -decreasing -index 1 $copies] 0 0] + } + puts "" + prettyPrint $iterations $parent + + return [join $parent {}] +} + +evolve $initial diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/0DESCRIPTION b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/0DESCRIPTION new file mode 100644 index 0000000000..103f4e8562 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/0DESCRIPTION @@ -0,0 +1,8 @@ +Show how to create a user-defined exception and show how to catch an exception raised from several nested calls away. + +# Create two user-defined exceptions, U0 and U1. +# Have function foo call function bar twice. +# Have function bar call function baz. +# Arrange for function baz to raise, or throw exception U0 on its first call, then exception U1 on its second. +# Function foo should catch only exception U0, not U1. +Show/describe what happens when the program is run. diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/ALGOL-68/exceptions-catch-an-exception-thrown-in-a-nested-call.alg b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/ALGOL-68/exceptions-catch-an-exception-thrown-in-a-nested-call.alg new file mode 100644 index 0000000000..74594e5c1d --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/ALGOL-68/exceptions-catch-an-exception-thrown-in-a-nested-call.alg @@ -0,0 +1,56 @@ +MODE OBJ = STRUCT( + INT value, + STRUCT( + STRING message, + FLEX[0]STRING args, + PROC(REF OBJ)BOOL u0, u1 + ) exception +); + +PROC on u0 = (REF OBJ self, PROC (REF OBJ) BOOL mended)VOID: + u0 OF exception OF self := mended; + +PROC on u1 = (REF OBJ self, PROC (REF OBJ) BOOL mended)VOID: + u1 OF exception OF self := mended; + +PRIO INIT = 1, RAISE = 1; + +OP INIT = (REF OBJ self, INT value)REF OBJ: ( + value OF self := value; + u0 OF exception OF self := u1 OF exception OF self := (REF OBJ skip)BOOL: FALSE; + args OF exception OF self := message OF exception OF self := "OBJ Exception"; + self +); + +OP RAISE = (REF OBJ self, PROC (REF OBJ) BOOL mended)VOID: + IF NOT mended(self) THEN + put(stand error, (message OF exception OF self+" not caught - stop", new line)); + stop + FI; + +PROC (REF OBJ)VOID bar, baz; # early declaration is required by the ALGOL 68RS subset language # + +PROC foo := VOID:( + FOR value FROM 0 TO 1 DO + REF OBJ i = LOC OBJ INIT value; + on u0(i, (REF OBJ skip)BOOL: (GO TO except u0; SKIP )); + bar(i); + GO TO end on u0; + except u0: + print(("Function foo caught exception u0", new line)); + end on u0: SKIP + OD +); + +# PROC # bar := (REF OBJ i)VOID:( + baz(i) # Nest those calls # +); + +# PROC # baz := (REF OBJ i)VOID: + IF value OF i = 0 THEN + i RAISE u0 OF exception OF i + ELSE + i RAISE u1 OF exception OF i + FI; + +foo diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ada/exceptions-catch-an-exception-thrown-in-a-nested-call.ada b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ada/exceptions-catch-an-exception-thrown-in-a-nested-call.ada new file mode 100644 index 0000000000..9b99ba8768 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ada/exceptions-catch-an-exception-thrown-in-a-nested-call.ada @@ -0,0 +1,31 @@ +with Ada.Text_Io; use Ada.Text_Io; + +procedure Exceptions_From_Nested_Calls is + U0 : exception; + U1 : exception; + Baz_Count : Natural := 0; + procedure Baz is + begin + Baz_Count := Baz_Count + 1; + if Baz_Count = 1 then + raise U0; + else + raise U1; + end if; + end Baz; + procedure Bar is + begin + Baz; + end Bar; + procedure Foo is + begin + Bar; + exception + when U0 => + Put_Line("Procedure Foo caught exception U0"); + end Foo; +begin + for I in 1..2 loop + Foo; + end loop; +end Exceptions_From_Nested_Calls; diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/AutoHotkey/exceptions-catch-an-exception-thrown-in-a-nested-call-1.ahk b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/AutoHotkey/exceptions-catch-an-exception-thrown-in-a-nested-call-1.ahk new file mode 100644 index 0000000000..fb2990c146 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/AutoHotkey/exceptions-catch-an-exception-thrown-in-a-nested-call-1.ahk @@ -0,0 +1,24 @@ +global U0 := Exception("First Exception") +global U1 := Exception("Second Exception") + +foo() + +foo(){ + try + bar() + catch e + MsgBox % "An exception was raised: " e.Message + bar() +} + +bar(){ + baz() +} + +baz(){ + static calls := 0 + if ( ++calls = 1 ) + throw U0 + else if ( calls = 2 ) + throw U1 +} diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/AutoHotkey/exceptions-catch-an-exception-thrown-in-a-nested-call-2.ahk b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/AutoHotkey/exceptions-catch-an-exception-thrown-in-a-nested-call-2.ahk new file mode 100644 index 0000000000..66c517aff1 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/AutoHotkey/exceptions-catch-an-exception-thrown-in-a-nested-call-2.ahk @@ -0,0 +1,30 @@ +foo() +Return + +foo() +{ + bar(0) + If InStr(ErrorLevel, "U0") + MsgBox caught error: U0 + bar(1) + If InStr(ErrorLevel, "U0") + MsgBox caught error: U0 +} + +bar(i) +{ + StringReplace, ErrorLevel, ErrorLevel, baz_error, , All ; clear baz_error(s) + If !baz(i) + ErrorLevel .= "baz_error" ; add baz_error to errorstack +} + +baz(i) +{ + StringReplace, ErrorLevel, ErrorLevel, U1, , All ; clear U1 errors + StringReplace, ErrorLevel, ErrorLevel, U0, , All ; clear U0 errors + If i + ErrorLevel .= "U1" ; add U1 errors to errorstack + Else + ErrorLevel .= "U0" + Return 1 +} diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/BBC-BASIC/exceptions-catch-an-exception-thrown-in-a-nested-call.bbc b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/BBC-BASIC/exceptions-catch-an-exception-thrown-in-a-nested-call.bbc new file mode 100644 index 0000000000..5f1b9ea0f5 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/BBC-BASIC/exceptions-catch-an-exception-thrown-in-a-nested-call.bbc @@ -0,0 +1,26 @@ + REM Allocate error numbers: + U0& = 123 + U1& = 124 + + PROCfoo + END + + DEF PROCfoo + ON ERROR LOCAL IF ERR = U0& THEN PRINT "Exception U0 caught in foo" ELSE \ + \ RESTORE ERROR : ERROR ERR, REPORT$ + PROCbar + PROCbar + ENDPROC + + DEF PROCbar + PROCbaz + ENDPROC + + DEF PROCbaz + PRIVATE called% + called% += 1 + CASE called% OF + WHEN 1: ERROR U0&, "Exception U0 thrown" + WHEN 2: ERROR U1&, "Exception U1 thrown" + ENDCASE + ENDPROC diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C++/exceptions-catch-an-exception-thrown-in-a-nested-call.cpp b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C++/exceptions-catch-an-exception-thrown-in-a-nested-call.cpp new file mode 100644 index 0000000000..126b52986f --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C++/exceptions-catch-an-exception-thrown-in-a-nested-call.cpp @@ -0,0 +1,28 @@ +#include +class U0 {}; +class U1 {}; + +void baz(int i) +{ + if (!i) throw U0(); + else throw U1(); +} +void bar(int i) { baz(i); } + +void foo() +{ + for (int i = 0; i < 2; i++) + { + try { + bar(i); + } catch(U0 e) { + std::cout<< "Exception U0 caught\n"; + } + } +} + +int main() { + foo(); + std::cout<< "Should never get here!\n"; + return 0; +} diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C/exceptions-catch-an-exception-thrown-in-a-nested-call-1.c b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C/exceptions-catch-an-exception-thrown-in-a-nested-call-1.c new file mode 100644 index 0000000000..5d2618f99b --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C/exceptions-catch-an-exception-thrown-in-a-nested-call-1.c @@ -0,0 +1,73 @@ +#include +#include +#include +#include + +#define try push_handler(); if (!exc_string) +#define catch(e) pop_handler(e); for (; exc_string; exc_string = 0) + +ucontext_t *exc; +int exc_depth = 0; +int exc_alloc = 0; +const char * exc_string; + +void throw(const char *str) +{ + exc_string = str; + setcontext(exc + exc_depth - 1); +} + +void push_handler() +{ + exc_string = 0; + if (exc_alloc <= exc_depth) { + exc_alloc += 16; + exc = realloc(exc, sizeof(ucontext_t) * exc_alloc); + } + getcontext(exc + exc_depth++); +} + +void pop_handler(const char *e) +{ + exc_depth --; + if (exc_string && strcmp(e, exc_string)) { + if (exc_depth > 0) + throw(exc_string); + fprintf(stderr, "Fatal: unhandled exception %s\n", exc_string); + exit(1); + } +} + +/* try out the exception system */ + +void baz() { + static int count = 0; + switch (count++) { + case 0: throw("U0"); + case 1: throw("U1"); + case 2: throw("U2"); + } +} + +void foo() +{ + printf(" foo: calling baz\n"); + try { baz(); } + catch("U0") { + printf(" foo: got exception U0; handled and dandy\n"); + } + + printf(" foo: finished\n"); +} + +int main() { + int i; + for (i = 0; i < 3; i++) { + printf("main: calling foo: %d\n", i); + try { foo(); } + catch("U1") { + printf("main: Someone threw U1; handled and dandy\n"); + } + } + return 0; +} diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C/exceptions-catch-an-exception-thrown-in-a-nested-call-2.c b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C/exceptions-catch-an-exception-thrown-in-a-nested-call-2.c new file mode 100644 index 0000000000..6361d8dee7 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/C/exceptions-catch-an-exception-thrown-in-a-nested-call-2.c @@ -0,0 +1,10 @@ +main: calling foo: 0 + foo: calling baz + foo: got exception U0; handled and dandy + foo: finished +main: calling foo: 1 + foo: calling baz +main: Someone threw U1; handled and dandy +main: calling foo: 2 + foo: calling baz +Unhandled exception U2 diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Common-Lisp/exceptions-catch-an-exception-thrown-in-a-nested-call-1.lisp b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Common-Lisp/exceptions-catch-an-exception-thrown-in-a-nested-call-1.lisp new file mode 100644 index 0000000000..ade2d1a9fe --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Common-Lisp/exceptions-catch-an-exception-thrown-in-a-nested-call-1.lisp @@ -0,0 +1,18 @@ +(define-condition user-condition-1 (error) ()) +(define-condition user-condition-2 (error) ()) + +(defun foo () + (dolist (type '(user-condition-1 user-condition-2)) + (handler-case + (bar type) + (user-condition-1 (c) + (format t "~&foo: Caught: ~A~%" c))))) + +(defun bar (type) + (baz type)) + +(defun baz (type) + (error type)) ; shortcut for (error (make-condition type)) + +(trace foo bar baz) +(foo) diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Common-Lisp/exceptions-catch-an-exception-thrown-in-a-nested-call-2.lisp b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Common-Lisp/exceptions-catch-an-exception-thrown-in-a-nested-call-2.lisp new file mode 100644 index 0000000000..3e277c115c --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Common-Lisp/exceptions-catch-an-exception-thrown-in-a-nested-call-2.lisp @@ -0,0 +1,6 @@ + 0: (FOO) + 1: (BAR USER-CONDITION-1) + 2: (BAZ USER-CONDITION-1) +foo: Caught: Condition USER-CONDITION-1 was signalled. + 1: (BAR USER-CONDITION-2) + 2: (BAZ USER-CONDITION-2) diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/D/exceptions-catch-an-exception-thrown-in-a-nested-call.d b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/D/exceptions-catch-an-exception-thrown-in-a-nested-call.d new file mode 100644 index 0000000000..c37801b3d5 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/D/exceptions-catch-an-exception-thrown-in-a-nested-call.d @@ -0,0 +1,34 @@ +import std.stdio; + +class U0 : Exception { + this() nothrow { super("U0 error message"); } +} + +class U1 : Exception { + this() nothrow { super("U1 error message"); } +} + +void foo(in int i) pure { + if (i) + throw new U1; + else + throw new U0; +} + +void bar(in int i) pure { + foo(i); +} + +void baz() { + foreach (i; 0 .. 2) { + try { + bar(i); + } catch (U0 e) { + writeln("Exception U0 caught"); + } + } +} + +void main() { + baz(); +} diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/DWScript/exceptions-catch-an-exception-thrown-in-a-nested-call.dwscript b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/DWScript/exceptions-catch-an-exception-thrown-in-a-nested-call.dwscript new file mode 100644 index 0000000000..dd6c220986 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/DWScript/exceptions-catch-an-exception-thrown-in-a-nested-call.dwscript @@ -0,0 +1,30 @@ +type Exception1 = class (Exception) end; +type Exception2 = class (Exception) end; + +procedure Baz(i : Integer); +begin + if i=0 then + raise new Exception1('Error message 1') + else raise new Exception2('Error message 2'); +end; + +procedure Bar(i : Integer); +begin + Baz(i); +end; + +procedure Foo; +var + i : Integer; +begin + for i:=0 to 2 do begin + try + Bar(i); + except + on E : Exception1 do + PrintLn(E.ClassName+' caught'); + end; + end; +end; + +Foo; diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Delphi/exceptions-catch-an-exception-thrown-in-a-nested-call.delphi b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Delphi/exceptions-catch-an-exception-thrown-in-a-nested-call.delphi new file mode 100644 index 0000000000..a66a14ba87 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Delphi/exceptions-catch-an-exception-thrown-in-a-nested-call.delphi @@ -0,0 +1,43 @@ +program ExceptionsInNestedCall; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +type + U0 = class(Exception) + end; + U1 = class(Exception) + end; + +procedure Baz(i: Integer); +begin + if i = 0 then + raise U0.Create('U0 Error message') + else + raise U1.Create('U1 Error message'); +end; + +procedure Bar(i: Integer); +begin + Baz(i); +end; + +procedure Foo; +var + i: Integer; +begin + for i := 0 to 1 do + begin + try + Bar(i); + except + on E: U0 do + Writeln('Exception ' + E.ClassName + ' caught'); + end; + end; +end; + +begin + Foo; +end. diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/EGL/exceptions-catch-an-exception-thrown-in-a-nested-call.egl b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/EGL/exceptions-catch-an-exception-thrown-in-a-nested-call.egl new file mode 100644 index 0000000000..0db53e0c37 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/EGL/exceptions-catch-an-exception-thrown-in-a-nested-call.egl @@ -0,0 +1,35 @@ +record U0 type Exception +end + +record U1 type Exception +end + +program Exceptions + + function main() + foo(); + end + + function foo() + try + bar(); + onException(ex U0) + SysLib.writeStdout("Caught a U0 with message: '" :: ex.message :: "'"); + end + bar(); + end + + function bar() + baz(); + end + + firstBazCall boolean = true; + function baz() + if(firstBazCall) + firstBazCall = false; + throw new U0{message = "This is the U0 exception"}; + else + throw new U1{message = "This is the U1 exception"}; + end + end +end diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Eiffel/exceptions-catch-an-exception-thrown-in-a-nested-call.e b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Eiffel/exceptions-catch-an-exception-thrown-in-a-nested-call.e new file mode 100644 index 0000000000..b05fbd438f --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Eiffel/exceptions-catch-an-exception-thrown-in-a-nested-call.e @@ -0,0 +1,38 @@ +class MAIN + inherit EXCEPTIONS + + creation foo + +feature {ANY} + baz_calls: INTEGER + + feature foo is + do + Current.bar + rescue + if is_developer_exception_of_name("U0") then + baz_calls := 1 + print("Caught U0 exception.%N") + retry + end + if is_developer_exception then + print("Won't catch ") + print(developer_exception_name) + print(" exception...%N") + end + end + + feature bar is + do + Current.baz + end + + feature baz is + do + if baz_calls = 0 then + raise("U0") + else + raise("U1") + end + end +end diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Go/exceptions-catch-an-exception-thrown-in-a-nested-call.go b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Go/exceptions-catch-an-exception-thrown-in-a-nested-call.go new file mode 100644 index 0000000000..96f63f9cd6 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Go/exceptions-catch-an-exception-thrown-in-a-nested-call.go @@ -0,0 +1,103 @@ +// Outline for a try/catch-like exception mechanism in Go +// +// As all Go programmers should know, the Go authors are sharply critical of +// the try/catch idiom and consider it bad practice in general. +// See http://golang.org/doc/go_faq.html#exceptions + +package main + +import ( + "fmt" + "runtime" + "strings" +) + +// trace is for pretty output for the Rosetta Code task. +// It would have no place in a practical program. +func trace(s string) { + nc := runtime.Callers(2, cs) + f := runtime.FuncForPC(cs[0]) + fmt.Print(strings.Repeat(" ", nc-3), f.Name()[5:], ": ", s, "\n") +} + +var cs = make([]uintptr, 10) + +type exception struct { + name string + handler func() +} + +// try implents the try/catch-like exception mechanism. It takes a function +// to be called, and a list of exceptions to catch during the function call. +// Note that for this simple example, f has no parameters. In a practical +// program it might, of course. In this case, the signature of try would +// have to be modified to take these parameters and then supply them to f +// when it calls f. +func try(f func(), exs []exception) { + trace("start") + defer func() { + if pv := recover(); pv != nil { + trace("Panic mode!") + if px, ok := pv.(exception); ok { + for _, ex := range exs { + if ex.name == px.name { + trace("handling exception") + px.handler() + trace("panic over") + return + } + } + } + trace("can't recover this one!") + panic(pv) + } + }() + f() + trace("complete") +} + +func main() { + trace("start") + foo() + trace("complete") +} + +// u0, u1 declared at package level so they can be accessed by any function. +var u0, u1 exception + +// foo. Note that function literals u0, u1 here in the lexical scope +// of foo serve the purpose of catch blocks of other languages. +// Passing u0 to try serves the purpose of the catch condition. +// While try(bar... reads much like the try statement of other languages, +// this try is an ordinary function. foo is passing bar into try, +// not calling it directly. +func foo() { + trace("start") + u0 = exception{"U0", func() { trace("U0 handled") }} + u1 = exception{"U1", func() { trace("U1 handled") }} + try(bar, []exception{u0}) + try(bar, []exception{u0}) + trace("complete") +} + +func bar() { + trace("start") + baz() + trace("complete") +} + +var bazCall int + +func baz() { + trace("start") + bazCall++ + switch bazCall { + case 1: + trace("panicking with execption U0") + panic(u0) + case 2: + trace("panicking with execption U1") + panic(u1) + } + trace("complete") +} diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Haskell/exceptions-catch-an-exception-thrown-in-a-nested-call-1.hs b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Haskell/exceptions-catch-an-exception-thrown-in-a-nested-call-1.hs new file mode 100644 index 0000000000..3059d46848 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Haskell/exceptions-catch-an-exception-thrown-in-a-nested-call-1.hs @@ -0,0 +1,38 @@ +import Control.Monad.Error +import Control.Monad.Trans (lift) + +-- Our "user-defined exception" tpe +data MyError = U0 | U1 | Other deriving (Eq, Read, Show) + +-- Required for any error type +instance Error MyError where + noMsg = Other + strMsg _ = Other + +-- Throwing and catching exceptions implies that we are working in a monad. In +-- this case, we use ErrorT to support our user-defined exceptions, wrapping +-- IO to be able to report the happenings. ('lift' converts ErrorT e IO a +-- actions into IO a actions.) + +foo = do lift (putStrLn "foo") + mapM_ (\toThrow -> bar toThrow -- the protected call + `catchError` \caught -> -- the catch operation + -- ↓ what to do with it + case caught of U0 -> lift (putStrLn "foo caught U0") + _ -> throwError caught) + [U0, U1] -- the two exceptions to throw + + +bar toThrow = do lift (putStrLn " bar") + baz toThrow + +baz toThrow = do lift (putStrLn " baz") + throwError toThrow + +-- We cannot use exceptions without at some outer level choosing what to do +-- if an exception propagates all the way up. Here we just print the exception +-- if there was one. +main = do result <- runErrorT foo + case result of + Left e -> putStrLn ("Caught error at top level: " ++ show e) + Right v -> putStrLn ("Return value: " ++ show v) diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Haskell/exceptions-catch-an-exception-thrown-in-a-nested-call-2.hs b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Haskell/exceptions-catch-an-exception-thrown-in-a-nested-call-2.hs new file mode 100644 index 0000000000..5dea3c04c4 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Haskell/exceptions-catch-an-exception-thrown-in-a-nested-call-2.hs @@ -0,0 +1,45 @@ +import Exceptions + +class U0 : Exception() + method getMessage() + return "U0: " || (\message | "unknown") + end +end + +class U1 : Exception() + method getMessage() + return "U1: " || (\message | "unknown") + end +end + +procedure main() + # (Because Exceptions are not built into Unicon, uncaught + # exceptions are ignored. This clause will catch any + # exceptions not caught farther down in the code.) + case Try().call{ foo() } of { + Try().catch(): { + ex := Try().getException() + write(ex.getMessage(), ":\n", ex.getLocation()) + } + } +end + +procedure foo() + every 1|2 do { + case Try().call{ bar() } of { + Try().catch("U0"): { + ex := Try().getException() + write(ex.getMessage(), ":\n", ex.getLocation()) + } + } + } +end + +procedure bar() + return baz() +end + +procedure baz() + initial U0().throw("First exception") + U1().throw("Second exception") +end diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Java/exceptions-catch-an-exception-thrown-in-a-nested-call.java b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Java/exceptions-catch-an-exception-thrown-in-a-nested-call.java new file mode 100644 index 0000000000..f0ab1bf523 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Java/exceptions-catch-an-exception-thrown-in-a-nested-call.java @@ -0,0 +1,29 @@ +class U0 extends Exception { } +class U1 extends Exception { } + +public class ExceptionsTest { + public static void foo() throws U1 { + for (int i = 0; i <= 1; i++) { + try { + bar(i); + } catch (U0 e) { + System.out.println("Function foo caught exception U0"); + } + } + } + + public static void bar(int i) throws U0, U1 { + baz(i); // Nest those calls + } + + public static void baz(int i) throws U0, U1 { + if (i == 0) + throw new U0(); + else + throw new U1(); + } + + public static void main(String[] args) throws U1 { + foo(); + } +} diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/JavaScript/exceptions-catch-an-exception-thrown-in-a-nested-call.js b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/JavaScript/exceptions-catch-an-exception-thrown-in-a-nested-call.js new file mode 100644 index 0000000000..c07322248b --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/JavaScript/exceptions-catch-an-exception-thrown-in-a-nested-call.js @@ -0,0 +1,35 @@ +function U() {} +U.prototype.toString = function(){return this.className;} + +function U0() { + this.className = arguments.callee.name; +} +U0.prototype = new U(); + +function U1() { + this.className = arguments.callee.name; +} +U1.prototype = new U(); + +function foo() { + for (var i = 1; i <= 2; i++) { + try { + bar(); + } + catch(e if e instanceof U0) { + print("caught exception " + e); + } + } +} + +function bar() { + baz(); +} + +function baz() { + // during the first call, redefine the function for subsequent calls + baz = function() {throw(new U1());} + throw(new U0()); +} + +foo(); diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Lua/exceptions-catch-an-exception-thrown-in-a-nested-call.lua b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Lua/exceptions-catch-an-exception-thrown-in-a-nested-call.lua new file mode 100644 index 0000000000..11ba6d7a61 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Lua/exceptions-catch-an-exception-thrown-in-a-nested-call.lua @@ -0,0 +1,33 @@ +local baz_counter=1 +function baz() + if baz_counter==1 then + baz_counter=baz_counter+1 + error("U0",3)--3 sends it down the call stack. + elseif baz_counter==2 then + error("U1",3)--3 sends it down the call stack. + end +end + +function bar() + baz() +end + +function foo() + function callbar() + local no_err,result = pcall(bar) + --pcall is a protected call which catches errors. + if not no_err then + --If there are no errors, pcall returns true. + if not result:match("U0") then + --If the error is not a U0 error, rethrow it. + error(result,2) + --2 is the distance down the call stack to send + --the error. We want it to go back to the callbar() call. + end + end + end + callbar() + callbar() +end + +foo() diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/MATLAB/exceptions-catch-an-exception-thrown-in-a-nested-call-1.m b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/MATLAB/exceptions-catch-an-exception-thrown-in-a-nested-call-1.m new file mode 100644 index 0000000000..c456880946 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/MATLAB/exceptions-catch-an-exception-thrown-in-a-nested-call-1.m @@ -0,0 +1,31 @@ +function exceptionsCatchNestedCall() + function foo() + + try + bar(1); + bar(2); + catch + disp(lasterror); + rethrow(lasterror); + end + + end + + function bar(i) + baz(i); + end + + function baz(i) + switch i + case 1 + error('BAZ:U0','HAHAHAH'); + case 2 + error('BAZ:U1','AWWWW'); + otherwise + disp 'I can''t do that Dave.'; + end + end + + foo(); + +end diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/MATLAB/exceptions-catch-an-exception-thrown-in-a-nested-call-2.m b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/MATLAB/exceptions-catch-an-exception-thrown-in-a-nested-call-2.m new file mode 100644 index 0000000000..2f5fee12e9 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/MATLAB/exceptions-catch-an-exception-thrown-in-a-nested-call-2.m @@ -0,0 +1,10 @@ +>> exceptionsCatchNestedCall() + message: [1x177 char] + identifier: 'BAZ:U0' + stack: [4x1 struct] + +??? Error using ==> exceptionsCatchNestedCall>baz at 21 +HAHAHAH + +Error in ==> exceptionsCatchNestedCall at 29 + foo(); diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Perl/exceptions-catch-an-exception-thrown-in-a-nested-call.pl b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Perl/exceptions-catch-an-exception-thrown-in-a-nested-call.pl new file mode 100644 index 0000000000..aa6ca99a9b --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Perl/exceptions-catch-an-exception-thrown-in-a-nested-call.pl @@ -0,0 +1,18 @@ +sub foo { + foreach (0..1) { + eval { bar($_) }; + if ($@ =~ /U0/) { print "Function foo caught exception U0\n"; } + else { die; } # propagate the exception + } +} + +sub bar { + baz(@_); # Nest those calls +} + +sub baz { + my $i = shift; + die ($i ? "U1" : "U0"); +} + +foo(); diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/PicoLisp/exceptions-catch-an-exception-thrown-in-a-nested-call.l b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/PicoLisp/exceptions-catch-an-exception-thrown-in-a-nested-call.l new file mode 100644 index 0000000000..ce710803f9 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/PicoLisp/exceptions-catch-an-exception-thrown-in-a-nested-call.l @@ -0,0 +1,13 @@ +(de foo () + (for Tag '(U0 U1) + (catch 'U0 + (bar Tag) ) ) ) + +(de bar (Tag) + (baz Tag) ) + +(de baz (Tag) + (throw Tag) ) + +(mapc trace '(foo bar baz)) +(foo) diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Python/exceptions-catch-an-exception-thrown-in-a-nested-call.py b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Python/exceptions-catch-an-exception-thrown-in-a-nested-call.py new file mode 100644 index 0000000000..4769e92753 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Python/exceptions-catch-an-exception-thrown-in-a-nested-call.py @@ -0,0 +1,17 @@ +class U0(Exception): pass +class U1(Exception): pass + +def foo(): + for i in range(2): + try: + bar(i) + except U0: + print "Function foo caught exception U0" + +def bar(i): + baz(i) # Nest those calls + +def baz(i): + raise U1 if i else U0 + +foo() diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/R/exceptions-catch-an-exception-thrown-in-a-nested-call-1.r b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/R/exceptions-catch-an-exception-thrown-in-a-nested-call-1.r new file mode 100644 index 0000000000..f70ad3e5f1 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/R/exceptions-catch-an-exception-thrown-in-a-nested-call-1.r @@ -0,0 +1,15 @@ +number_of_calls_to_baz <- 0 + +foo <- function() +{ + for(i in 1:2) tryCatch(bar()) +} + +bar <- function() baz() + +baz <- function() +{ + e <- simpleError(ifelse(number_of_calls_to_baz > 0, "U1", "U0")) + assign("number_of_calls_to_baz", number_of_calls_to_baz + 1, envir=globalenv()) + stop(e) +} diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/R/exceptions-catch-an-exception-thrown-in-a-nested-call-2.r b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/R/exceptions-catch-an-exception-thrown-in-a-nested-call-2.r new file mode 100644 index 0000000000..46c5cb28eb --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/R/exceptions-catch-an-exception-thrown-in-a-nested-call-2.r @@ -0,0 +1,2 @@ +foo() # Error: U0 +traceback() diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-1.rb b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-1.rb new file mode 100644 index 0000000000..688d38e720 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-1.rb @@ -0,0 +1,25 @@ +def foo + begin + bar + rescue U0 + puts "captured exception U0" + end +end + +def bar + baz +end + +def baz + raise $bazcount == 1 ? U0 : U1 +end + +class U0 < Exception +end + +class U1 < Exception +end + +for $bazcount in [1, 2] + foo +end diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-2.rb b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-2.rb new file mode 100644 index 0000000000..f64c21a9b8 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-2.rb @@ -0,0 +1,3 @@ +for $bazcount in [1, 2] + foo +end diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-3.rb b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-3.rb new file mode 100644 index 0000000000..87e52f1840 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Ruby/exceptions-catch-an-exception-thrown-in-a-nested-call-3.rb @@ -0,0 +1 @@ +[1, 2].each {|$bazcount| foo} diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Smalltalk/exceptions-catch-an-exception-thrown-in-a-nested-call-1.st b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Smalltalk/exceptions-catch-an-exception-thrown-in-a-nested-call-1.st new file mode 100644 index 0000000000..bf2930ec44 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Smalltalk/exceptions-catch-an-exception-thrown-in-a-nested-call-1.st @@ -0,0 +1,30 @@ +| u0 u1 foo bar baz| + +u0 := Signal new. +u1 := Signal new. + +foo := [ + 2 timesRepeat:[ + [ bar value ] + on: u0 + do:[ 'u0 cought' printCR ] + ] + ]. + +bar := [ + baz value + ]. + +baz := [ + |alreadyCalled| + + [ + alreadyCalled isNil ifTrue:[ + alreadyCalled := true. u0 raise + ] ifFalse:[ + u1 raise + ] + ] + ] value. + +foo value diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Smalltalk/exceptions-catch-an-exception-thrown-in-a-nested-call-2.st b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Smalltalk/exceptions-catch-an-exception-thrown-in-a-nested-call-2.st new file mode 100644 index 0000000000..ce1d8cb1cb --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Smalltalk/exceptions-catch-an-exception-thrown-in-a-nested-call-2.st @@ -0,0 +1,43 @@ +Exception + subclass: #U0 + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'example'. + +Exception + subclass: #U1 + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'example'. + +Object + subclass: #CatchMeIfYouCan + instanceVariableNames:'bazAlreadyCalled' + classVariableNames:'' + poolDictionaries:'' + category:'example'. + +" CatchMeIfYouCan methods " + +foo + 2 timesRepeat:[ + [ self bar ] + on: U0 + do:[ 'U0 cought' printCR ] + ] + +bar + self baz + + +baz + bazAlreadyCalled isNil ifTrue:[ + bazAlreadyCalled := true. + U0 raise + ] ifFalse:[ + U1 raise + ] + +CatchMeIfYouCan new foo diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Tcl/exceptions-catch-an-exception-thrown-in-a-nested-call.tcl b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Tcl/exceptions-catch-an-exception-thrown-in-a-nested-call.tcl new file mode 100644 index 0000000000..e003f6fee5 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Tcl/exceptions-catch-an-exception-thrown-in-a-nested-call.tcl @@ -0,0 +1,26 @@ +package require Tcl 8.5 + +proc foo {} { + set code [catch {bar} ex options] + if {$code == 1} { + switch -exact -- $ex { + U0 {puts "caught exception U0"} + default {return -options $options $ex ;# re-raise exception} + } + } +} + +proc bar {} {baz} + +# create an alias to pass the initial exception U0 to the baz proc +interp alias {} baz {} _baz U0 + +proc _baz {exception} { + # re-set the alias so subsequent invocations will use exception U1 + interp alias {} baz {} _baz U1 + # throw + return -code error $exception +} + +foo +foo diff --git a/Task/Exceptions/0DESCRIPTION b/Task/Exceptions/0DESCRIPTION new file mode 100644 index 0000000000..8216313ff9 --- /dev/null +++ b/Task/Exceptions/0DESCRIPTION @@ -0,0 +1,4 @@ +{{Control Structures}} +This task is to give an example of an exception handling routine and to "throw" a new exception. + +Cf. [[Exceptions Through Nested Calls]] diff --git a/Task/Exceptions/1META.yaml b/Task/Exceptions/1META.yaml new file mode 100644 index 0000000000..8af673b2be --- /dev/null +++ b/Task/Exceptions/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Control Structures diff --git a/Task/Exceptions/ALGOL-68/exceptions-1.alg b/Task/Exceptions/ALGOL-68/exceptions-1.alg new file mode 100644 index 0000000000..05ec0d08bf --- /dev/null +++ b/Task/Exceptions/ALGOL-68/exceptions-1.alg @@ -0,0 +1,6 @@ +# a user defined object # +MODE OBJECTFOO = STRUCT ( PROC (REF OBJECTFOO)BOOL foo event mended, ... ); + +PROC on foo event = (REF OBJECTFOO foo, PROC (REF OBJECTFOO)BOOL foo event)VOID: ( + foo event mended OF foo := foo event +); diff --git a/Task/Exceptions/ALGOL-68/exceptions-2.alg b/Task/Exceptions/ALGOL-68/exceptions-2.alg new file mode 100644 index 0000000000..79bb2f0a40 --- /dev/null +++ b/Task/Exceptions/ALGOL-68/exceptions-2.alg @@ -0,0 +1,8 @@ +OBJECTFOO foo proxy := foo base; # event routines are specific to an foo # + +on foo event(foo proxy, raise foo event); + +WHILE TRUE DO + # now raise example foo event # + IF NOT (foo event mended OF foo proxy)(foo proxy) THEN undefined # trace back # FI +OD; diff --git a/Task/Exceptions/ALGOL-68/exceptions-3.alg b/Task/Exceptions/ALGOL-68/exceptions-3.alg new file mode 100644 index 0000000000..95130a1305 --- /dev/null +++ b/Task/Exceptions/ALGOL-68/exceptions-3.alg @@ -0,0 +1,5 @@ +... +except foo event: + IF ... THEN # Alas, cannot handle it here continue propagation of # + IF NOT (foo event mended OF foo base)(foo base) THEN undefined # trace back # FI + FI diff --git a/Task/Exceptions/ALGOL-68/exceptions-4.alg b/Task/Exceptions/ALGOL-68/exceptions-4.alg new file mode 100644 index 0000000000..adf1f894e3 --- /dev/null +++ b/Task/Exceptions/ALGOL-68/exceptions-4.alg @@ -0,0 +1,7 @@ +PROC raise foo event(REF OBJECTFOO foo)BOOL: + IF mend foo(foo) THEN + TRUE # continue # + ELSE + except foo event + FALSE # OR fall back to default event routine # + FI diff --git a/Task/Exceptions/Ada/exceptions-1.ada b/Task/Exceptions/Ada/exceptions-1.ada new file mode 100644 index 0000000000..b824436b7d --- /dev/null +++ b/Task/Exceptions/Ada/exceptions-1.ada @@ -0,0 +1 @@ +Foo_Error : exception; diff --git a/Task/Exceptions/Ada/exceptions-2.ada b/Task/Exceptions/Ada/exceptions-2.ada new file mode 100644 index 0000000000..f109f87ee9 --- /dev/null +++ b/Task/Exceptions/Ada/exceptions-2.ada @@ -0,0 +1,4 @@ +procedure Foo is +begin + raise Foo_Error; +end Foo; diff --git a/Task/Exceptions/Ada/exceptions-3.ada b/Task/Exceptions/Ada/exceptions-3.ada new file mode 100644 index 0000000000..a64a41c2d1 --- /dev/null +++ b/Task/Exceptions/Ada/exceptions-3.ada @@ -0,0 +1,6 @@ + ... +exception + when Foo_Error => + if ... then -- Alas, cannot handle it here, + raise; -- continue propagation of + end if; diff --git a/Task/Exceptions/Ada/exceptions-4.ada b/Task/Exceptions/Ada/exceptions-4.ada new file mode 100644 index 0000000000..63b20e3150 --- /dev/null +++ b/Task/Exceptions/Ada/exceptions-4.ada @@ -0,0 +1,9 @@ +procedure Call_Foo is +begin + Foo; +exception + when Foo_Error => + ... -- do something + when others => + ... -- this catches all other exceptions +end Call_Foo; diff --git a/Task/Exceptions/Ada/exceptions-5.ada b/Task/Exceptions/Ada/exceptions-5.ada new file mode 100644 index 0000000000..5724bb5522 --- /dev/null +++ b/Task/Exceptions/Ada/exceptions-5.ada @@ -0,0 +1,12 @@ +with Ada.Exceptions; use Ada.Exceptions; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Main is +begin + ... + Raise_Exception (Foo_Error'Identity, "This is the exception message"); + .. +exception + when Error : others => + Put_Line ("Something is wrong here" & Exception_Information (Error)); +end Main; diff --git a/Task/Exceptions/Aikido/exceptions-1.aikido b/Task/Exceptions/Aikido/exceptions-1.aikido new file mode 100644 index 0000000000..f69c9728e7 --- /dev/null +++ b/Task/Exceptions/Aikido/exceptions-1.aikido @@ -0,0 +1,6 @@ +try { + var lines = readfile ("input.txt") + process (lines) +} catch (e) { + do_somthing(e) +} diff --git a/Task/Exceptions/Aikido/exceptions-2.aikido b/Task/Exceptions/Aikido/exceptions-2.aikido new file mode 100644 index 0000000000..38f459bacb --- /dev/null +++ b/Task/Exceptions/Aikido/exceptions-2.aikido @@ -0,0 +1,7 @@ +if (error) { + throw "Error" +} + +if (something) { + throw new MyException (errorcode, a, b) +} diff --git a/Task/Exceptions/AppleScript/exceptions-1.applescript b/Task/Exceptions/AppleScript/exceptions-1.applescript new file mode 100644 index 0000000000..c9d32c1703 --- /dev/null +++ b/Task/Exceptions/AppleScript/exceptions-1.applescript @@ -0,0 +1,4 @@ +try + set num to 1 / 0 + --do something that might throw an error +end try diff --git a/Task/Exceptions/AppleScript/exceptions-2.applescript b/Task/Exceptions/AppleScript/exceptions-2.applescript new file mode 100644 index 0000000000..a28427d5f5 --- /dev/null +++ b/Task/Exceptions/AppleScript/exceptions-2.applescript @@ -0,0 +1,7 @@ +try + set num to 1 / 0 + --do something that might throw an error +on error errMess number errNum + --errMess and number errNum are optional + display alert "Error # " & errNum & return & errMess +end try diff --git a/Task/Exceptions/AppleScript/exceptions-3.applescript b/Task/Exceptions/AppleScript/exceptions-3.applescript new file mode 100644 index 0000000000..af988876f1 --- /dev/null +++ b/Task/Exceptions/AppleScript/exceptions-3.applescript @@ -0,0 +1 @@ +error "Error message." number 2000 diff --git a/Task/Exceptions/AutoHotkey/exceptions-1.ahk b/Task/Exceptions/AutoHotkey/exceptions-1.ahk new file mode 100644 index 0000000000..3940122d29 --- /dev/null +++ b/Task/Exceptions/AutoHotkey/exceptions-1.ahk @@ -0,0 +1,8 @@ +try + BadlyCodedFunc() +catch e + MsgBox % "Error in " e.What ", which was called at line " e.Line + +BadlyCodedFunc() { + throw Exception("Fail", -1) +} diff --git a/Task/Exceptions/AutoHotkey/exceptions-2.ahk b/Task/Exceptions/AutoHotkey/exceptions-2.ahk new file mode 100644 index 0000000000..bfec6426a3 --- /dev/null +++ b/Task/Exceptions/AutoHotkey/exceptions-2.ahk @@ -0,0 +1,12 @@ +foo() +If ErrorLevel + Msgbox calling foo failed with: %ErrorLevel% + +foo() +{ + If success + Return + Else + ErrorLevel = foo_error + Return +} diff --git a/Task/Exceptions/BBC-BASIC/exceptions.bbc b/Task/Exceptions/BBC-BASIC/exceptions.bbc new file mode 100644 index 0000000000..e6a9d8e3c0 --- /dev/null +++ b/Task/Exceptions/BBC-BASIC/exceptions.bbc @@ -0,0 +1,10 @@ + ON ERROR PROCerror(ERR, REPORT$) : END + + ERROR 100, "User-generated exception" + END + + DEF PROCerror(er%, rpt$) + PRINT "Exception occurred" + PRINT "Error number was " ; er% + PRINT "Error string was " rpt$ + ENDPROC diff --git a/Task/Exceptions/C++/exceptions-1.cpp b/Task/Exceptions/C++/exceptions-1.cpp new file mode 100644 index 0000000000..f336536ded --- /dev/null +++ b/Task/Exceptions/C++/exceptions-1.cpp @@ -0,0 +1,4 @@ +struct MyException +{ + // data with info about exception +}; diff --git a/Task/Exceptions/C++/exceptions-2.cpp b/Task/Exceptions/C++/exceptions-2.cpp new file mode 100644 index 0000000000..99854c5688 --- /dev/null +++ b/Task/Exceptions/C++/exceptions-2.cpp @@ -0,0 +1,5 @@ +#include +struct MyException: std::exception +{ + char const* what() const throw() { return "description"; } +} diff --git a/Task/Exceptions/C++/exceptions-3.cpp b/Task/Exceptions/C++/exceptions-3.cpp new file mode 100644 index 0000000000..bb6c1620ff --- /dev/null +++ b/Task/Exceptions/C++/exceptions-3.cpp @@ -0,0 +1,17 @@ +// this function can throw any type of exception +void foo() +{ + throw MyException(); +} + +// this function can only throw the types of exceptions that are listed +void foo2() throw(MyException) +{ + throw MyException(); +} + +// this function turns any exceptions other than MyException into std::bad_exception +void foo3() throw(MyException, std::bad_exception) +{ + throw MyException(); +} diff --git a/Task/Exceptions/C++/exceptions-4.cpp b/Task/Exceptions/C++/exceptions-4.cpp new file mode 100644 index 0000000000..4f043aff98 --- /dev/null +++ b/Task/Exceptions/C++/exceptions-4.cpp @@ -0,0 +1,17 @@ +try { + foo(); +} +catch (MyException &exc) +{ + // handle exceptions of type MyException and derived +} +catch (std::exception &exc) +{ + // handle exceptions derived from std::exception, which were not handled by above catches + // e.g. + std::cerr << exc.what() << std::endl; +} +catch (...) +{ + // handle any type of exception not handled by above catches +} diff --git a/Task/Exceptions/C/exceptions-1.c b/Task/Exceptions/C/exceptions-1.c new file mode 100644 index 0000000000..55435a4679 --- /dev/null +++ b/Task/Exceptions/C/exceptions-1.c @@ -0,0 +1,27 @@ +#include + +enum { MY_EXCEPTION = 1 }; /* any non-zero number */ + +jmp_buf env; + +void foo() +{ + longjmp(env, MY_EXCEPTION); /* throw MY_EXCEPTION */ +} + +void call_foo() +{ + switch (setjmp(env)) { + case 0: /* try */ + foo(); + break; + case MY_EXCEPTION: /* catch MY_EXCEPTION */ + /* handle exceptions of type MY_EXCEPTION */ + break; + default: + /* handle any type of exception not handled by above catches */ + /* note: if this "default" section is not included, that would be equivalent to a blank "default" section */ + /* i.e. any exception not caught above would be caught and ignored */ + /* there is no way to "let the exception through" */ + } +} diff --git a/Task/Exceptions/C/exceptions-2.c b/Task/Exceptions/C/exceptions-2.c new file mode 100644 index 0000000000..be88f964b7 --- /dev/null +++ b/Task/Exceptions/C/exceptions-2.c @@ -0,0 +1,82 @@ +#include +#include +#include + +enum exceptions { + EXCEPTION_1 = 1, + EXCEPTION_2, + EXCEPTION_3 +}; + + +#define throw(exception) do { \ + if (exp) \ + longjmp(*exp, exception); \ + printf("uncaught exception %d\n", exception); \ + exit(exception); \ + } while (0) + +#define try(block, catch_block) \ +{ \ + jmp_buf *exception_outer = exp; \ + jmp_buf exception_inner; \ + exp = &exception_inner; \ + int exception = setjmp(*exp); \ + if (!exception) { \ + do block while(0); \ + exp = exception_outer; \ + } else { \ + exp = exception_outer; \ + switch(exception) { \ + catch_block \ + default: \ + throw(exception); \ + } \ + } \ +} + +#define catch(exception, block) \ + case exception: do block while (0); break; + + +#define throws jmp_buf* exp + +// define a throwing function +void g(throws) { + printf("g !\n"); + throw(EXCEPTION_1); + printf("shouldnt b here\n"); +} + +void h(throws, int a) +{ + printf("h %d!\n", a); + throw(EXCEPTION_2); +} + +void f(throws) { + try({ + g(exp); // call g with intention to catch exceptions + }, + catch(EXCEPTION_1, { + printf("exception 1\n"); + h(exp, 50); // will throw exception 2 inside this catch block + })) +} + +int main(int argc, char* argv[]) +{ + throws = NULL; // define exception stack base + try({ + f(exp); + }, + catch(EXCEPTION_2, { + printf("exception 2\n"); + }) + catch(EXCEPTION_3, { + printf("exception 3\n"); + })) + + h(exp, 60); // will result in "uncaught exception" + return 0; +} diff --git a/Task/Exceptions/Clojure/exceptions.clj b/Task/Exceptions/Clojure/exceptions.clj new file mode 100644 index 0000000000..92b4aa39e9 --- /dev/null +++ b/Task/Exceptions/Clojure/exceptions.clj @@ -0,0 +1,8 @@ +(try + (if (> (rand) 0.5) + (throw (RuntimeException. "oops!")) + (println "see this half the time") + (catch RuntimeException e + (println e) + (finally + (println "always see this")) diff --git a/Task/Exceptions/ColdFusion/exceptions-1.cfm b/Task/Exceptions/ColdFusion/exceptions-1.cfm new file mode 100644 index 0000000000..4d073a9835 --- /dev/null +++ b/Task/Exceptions/ColdFusion/exceptions-1.cfm @@ -0,0 +1,5 @@ +try { + foo(); +} catch (Any e) { + // handle exception e +} diff --git a/Task/Exceptions/ColdFusion/exceptions-2.cfm b/Task/Exceptions/ColdFusion/exceptions-2.cfm new file mode 100644 index 0000000000..4a97c292f9 --- /dev/null +++ b/Task/Exceptions/ColdFusion/exceptions-2.cfm @@ -0,0 +1,4 @@ + + + + diff --git a/Task/Exceptions/Common-Lisp/exceptions.lisp b/Task/Exceptions/Common-Lisp/exceptions.lisp new file mode 100644 index 0000000000..14562f55f2 --- /dev/null +++ b/Task/Exceptions/Common-Lisp/exceptions.lisp @@ -0,0 +1,14 @@ +(define-condition unexpected-odd-number (error) + ((number :reader number :initarg :number)) + (:report (lambda (condition stream) + (format stream "Unexpected odd number: ~w." + (number condition))))) + +(defun get-number (&aux (n (random 100))) + (if (not (oddp n)) n + (error 'unexpected-odd-number :number n))) + +(defun get-even-number () + (handler-case (get-number) + (unexpected-odd-number (condition) + (1+ (number condition))))) diff --git a/Task/Exceptions/D/exceptions.d b/Task/Exceptions/D/exceptions.d new file mode 100644 index 0000000000..e52248494a --- /dev/null +++ b/Task/Exceptions/D/exceptions.d @@ -0,0 +1,35 @@ +import std.stdio; + +/// Throw Exceptions +/// Stack traces are generated compiling with the -g switch. +void test1() { + throw new Exception("Sample Exception"); +} + +/// Catch Exceptions +void test2() { + try { + test1(); + } catch (Exception ex) { + writeln(ex); + throw ex; // rethrow + } +} + +/// Ways to implement finally +void test3() { + try test2(); + finally writeln("test3 finally"); +} + +/// Or also with scope guards +void test4() { + scope(exit) writeln("Test4 done"); + scope(failure) writeln("Test4 exited by exception"); + scope(success) writeln("Test4 exited by return or function end"); + test2(); +} + +void main() { + test4(); +} diff --git a/Task/Exceptions/DWScript/exceptions-1.dwscript b/Task/Exceptions/DWScript/exceptions-1.dwscript new file mode 100644 index 0000000000..9021b413bc --- /dev/null +++ b/Task/Exceptions/DWScript/exceptions-1.dwscript @@ -0,0 +1,4 @@ +procedure Test; +begin + raise Exception.Create('Sample Exception'); +end; diff --git a/Task/Exceptions/DWScript/exceptions-2.dwscript b/Task/Exceptions/DWScript/exceptions-2.dwscript new file mode 100644 index 0000000000..2be14156a2 --- /dev/null +++ b/Task/Exceptions/DWScript/exceptions-2.dwscript @@ -0,0 +1,11 @@ +procedure Test2; +begin + try + test; + except + on E: Exception do begin // Filter by exception class + PrintLn(E.Message); // Showing exception message + raise; // Rethrowing + end; + end; +end; diff --git a/Task/Exceptions/DWScript/exceptions-3.dwscript b/Task/Exceptions/DWScript/exceptions-3.dwscript new file mode 100644 index 0000000000..b7f385c3ef --- /dev/null +++ b/Task/Exceptions/DWScript/exceptions-3.dwscript @@ -0,0 +1,8 @@ +procedure Test3; +begin + try + test2; + finally + PrintLn('Test3 finally'); + end; +end; diff --git a/Task/Exceptions/Delphi/exceptions-1.delphi b/Task/Exceptions/Delphi/exceptions-1.delphi new file mode 100644 index 0000000000..dfc0f26d5f --- /dev/null +++ b/Task/Exceptions/Delphi/exceptions-1.delphi @@ -0,0 +1,4 @@ +procedure test; +begin + raise Exception.Create('Sample Exception'); +end; diff --git a/Task/Exceptions/Delphi/exceptions-2.delphi b/Task/Exceptions/Delphi/exceptions-2.delphi new file mode 100644 index 0000000000..85670ccc76 --- /dev/null +++ b/Task/Exceptions/Delphi/exceptions-2.delphi @@ -0,0 +1,9 @@ +procedure test2; +begin + try + test; + except + ShowMessage(Exception(ExceptObject).Message); // Showing exception message + raise; // Rethrowing + end; +end; diff --git a/Task/Exceptions/Delphi/exceptions-3.delphi b/Task/Exceptions/Delphi/exceptions-3.delphi new file mode 100644 index 0000000000..0ae5067b3a --- /dev/null +++ b/Task/Exceptions/Delphi/exceptions-3.delphi @@ -0,0 +1,8 @@ +procedure test3; +begin + try + test2; + finally + ShowMessage('test3 finally'); + end; +end; diff --git a/Task/Exceptions/E/exceptions-1.e b/Task/Exceptions/E/exceptions-1.e new file mode 100644 index 0000000000..b7981d1269 --- /dev/null +++ b/Task/Exceptions/E/exceptions-1.e @@ -0,0 +1,15 @@ +def nameOf(arg :int) { + if (arg == 43) { + return "Bob" + } else { + throw("Who?") + } +} + +def catching(arg) { + try { + return ["ok", nameOf(arg)] + } catch exceptionObj { + return ["notok", exceptionObj] + } +} diff --git a/Task/Exceptions/E/exceptions-2.e b/Task/Exceptions/E/exceptions-2.e new file mode 100644 index 0000000000..4d6efc6aa7 --- /dev/null +++ b/Task/Exceptions/E/exceptions-2.e @@ -0,0 +1,8 @@ +? catching(42) +# value: ["not ok", problem: Who?] + +? catching(43) +# value: ["ok", "Bob"] + +? catching(45.7) +# value: ["not ok", problem: the float64 45.7 doesn't coerce to an int] diff --git a/Task/Exceptions/E/exceptions-3.e b/Task/Exceptions/E/exceptions-3.e new file mode 100644 index 0000000000..884131cd04 --- /dev/null +++ b/Task/Exceptions/E/exceptions-3.e @@ -0,0 +1,15 @@ +def nameOf(arg :int, ejector) { + if (arg == 43) { + return "Bob" + } else { + ejector("Who?") + } +} + +def catching(arg) { + escape unnamed { + return ["ok", nameOf(arg, unnamed)] + } catch exceptionObj { + return ["notok", exceptionObj] + } +} diff --git a/Task/Exceptions/E/exceptions-4.e b/Task/Exceptions/E/exceptions-4.e new file mode 100644 index 0000000000..19df1f0a4f --- /dev/null +++ b/Task/Exceptions/E/exceptions-4.e @@ -0,0 +1,8 @@ +? catching(42) +# value: ["not ok", problem: Who?] + +? catching(43) +# value: ["ok", "Bob"] + +? catching(45.7) +# problem: the float64 45.7 doesn't coerce to an int diff --git a/Task/Exceptions/E/exceptions-5.e b/Task/Exceptions/E/exceptions-5.e new file mode 100644 index 0000000000..2352735e6d --- /dev/null +++ b/Task/Exceptions/E/exceptions-5.e @@ -0,0 +1,11 @@ +var nameTable := null +def nameOf(arg :int, ejector) { + if (nameTable == null) { + nameTable := .parseFile() + } + if (nameTable.maps(arg)) { + return nameTable[arg] + } else { + ejector(makeNotFoundException("Who?")) + } +} diff --git a/Task/Exceptions/Forth/exceptions-1.fth b/Task/Exceptions/Forth/exceptions-1.fth new file mode 100644 index 0000000000..7f320b7b1a --- /dev/null +++ b/Task/Exceptions/Forth/exceptions-1.fth @@ -0,0 +1,2 @@ +: f ( -- ) 1 throw ." f " ; \ will throw a "1" +: g ( -- ) 0 throw ." g " ; \ does not throw diff --git a/Task/Exceptions/Forth/exceptions-2.fth b/Task/Exceptions/Forth/exceptions-2.fth new file mode 100644 index 0000000000..a1ab21a353 --- /dev/null +++ b/Task/Exceptions/Forth/exceptions-2.fth @@ -0,0 +1,4 @@ +: report ( n -- ) ?dup if ." caught " . else ." no throw" then ; +: test ( -- ) + ['] f catch report + ['] g catch report ; diff --git a/Task/Exceptions/Forth/exceptions-3.fth b/Task/Exceptions/Forth/exceptions-3.fth new file mode 100644 index 0000000000..5c76348b43 --- /dev/null +++ b/Task/Exceptions/Forth/exceptions-3.fth @@ -0,0 +1,2 @@ +cr test +'''caught 1 g no throw ok''' diff --git a/Task/Exceptions/Forth/exceptions-4.fth b/Task/Exceptions/Forth/exceptions-4.fth new file mode 100644 index 0000000000..29740a844b --- /dev/null +++ b/Task/Exceptions/Forth/exceptions-4.fth @@ -0,0 +1 @@ +10 ['] myfun catch if drop then diff --git a/Task/Exceptions/Go/exceptions.go b/Task/Exceptions/Go/exceptions.go new file mode 100644 index 0000000000..1472eacc57 --- /dev/null +++ b/Task/Exceptions/Go/exceptions.go @@ -0,0 +1,19 @@ +package main + +import "fmt" + +func foo() { + fmt.Println("let's foo...") + defer func() { + if err := recover(); err != nil { + fmt.Printf("Error: %v\n", err) + } + }() + panic("FAIL!") + fmt.Println("there's no point in going on.") +} + +func main() { + foo() + fmt.Println("glad that's over.") +} diff --git a/Task/Exceptions/Haskell/exceptions-1.hs b/Task/Exceptions/Haskell/exceptions-1.hs new file mode 100644 index 0000000000..05c45d63f3 --- /dev/null +++ b/Task/Exceptions/Haskell/exceptions-1.hs @@ -0,0 +1,2 @@ +do {- ... -} + throwIO SomeException diff --git a/Task/Exceptions/Haskell/exceptions-2.hs b/Task/Exceptions/Haskell/exceptions-2.hs new file mode 100644 index 0000000000..50893da4e9 --- /dev/null +++ b/Task/Exceptions/Haskell/exceptions-2.hs @@ -0,0 +1,2 @@ +if condition then 3 +else throw SomeException diff --git a/Task/Exceptions/Haskell/exceptions-3.hs b/Task/Exceptions/Haskell/exceptions-3.hs new file mode 100644 index 0000000000..4629aebbea --- /dev/null +++ b/Task/Exceptions/Haskell/exceptions-3.hs @@ -0,0 +1,2 @@ +if condition then 3 +else throwDyn myException diff --git a/Task/Exceptions/Haskell/exceptions-4.hs b/Task/Exceptions/Haskell/exceptions-4.hs new file mode 100644 index 0000000000..6dde2b8e04 --- /dev/null +++ b/Task/Exceptions/Haskell/exceptions-4.hs @@ -0,0 +1,4 @@ +do + {- do IO computations here -} +`catch` \ex -> do + {- handle exception "ex" here -} diff --git a/Task/Exceptions/Haskell/exceptions-5.hs b/Task/Exceptions/Haskell/exceptions-5.hs new file mode 100644 index 0000000000..d34b68d62b --- /dev/null +++ b/Task/Exceptions/Haskell/exceptions-5.hs @@ -0,0 +1,4 @@ +do + {- do IO computations here -} +`catchDyn` \ex -> do + {- handle exception "ex" here -} diff --git a/Task/Exceptions/Haskell/exceptions-6.hs b/Task/Exceptions/Haskell/exceptions-6.hs new file mode 100644 index 0000000000..c588571f84 --- /dev/null +++ b/Task/Exceptions/Haskell/exceptions-6.hs @@ -0,0 +1,17 @@ +import Exceptions + +procedure main(A) + every i := !A do { + case Try().call{ write(g(i)) } of { + Try().catch(): { + x := Try().getException() + write(x.getMessage(), ":\n", x.getLocation()) + } + } + } +end + +procedure g(i) + if numeric(i) = 3 then Exception().throw("bad value of "||i) + return i +end diff --git a/Task/Exceptions/Java/exceptions-1.java b/Task/Exceptions/Java/exceptions-1.java new file mode 100644 index 0000000000..d3a831ba54 --- /dev/null +++ b/Task/Exceptions/Java/exceptions-1.java @@ -0,0 +1,7 @@ +//Checked exception +public class MyException extends Exception { + //Put specific info in here +} + +//Unchecked exception +public class MyRuntimeException extends RuntimeException {} diff --git a/Task/Exceptions/Java/exceptions-2.java b/Task/Exceptions/Java/exceptions-2.java new file mode 100644 index 0000000000..8cb584207d --- /dev/null +++ b/Task/Exceptions/Java/exceptions-2.java @@ -0,0 +1,7 @@ +public void fooChecked() throws MyException { + throw new MyException(); +} + +public void fooUnchecked() { + throw new MyRuntimeException(); +} diff --git a/Task/Exceptions/Java/exceptions-3.java b/Task/Exceptions/Java/exceptions-3.java new file mode 100644 index 0000000000..f6b7d26901 --- /dev/null +++ b/Task/Exceptions/Java/exceptions-3.java @@ -0,0 +1,15 @@ +try { + fooChecked(); +} +catch(MyException exc) { + //Catch only your specified type of exception +} +catch(Exception exc) { + //Catch any non-system error exception +} +catch(Throwable exc) { + //Catch everything including system errors (not recommended) +} +finally { + //This code is always executed after exiting the try block +} diff --git a/Task/Exceptions/Java/exceptions-4.java b/Task/Exceptions/Java/exceptions-4.java new file mode 100644 index 0000000000..257efd6ef1 --- /dev/null +++ b/Task/Exceptions/Java/exceptions-4.java @@ -0,0 +1,13 @@ +public void foo() throws UnsupportedDataTypeException{ + try{ + throwsNumberFormatException(); + //the following methods throw exceptions which extend IOException + throwsUnsupportedDataTypeException(); + throwsFileNotFoundException(); + }catch(FileNotFoundException | NumberFormatException ex){ + //deal with these two Exceptions without duplicating code + }catch(IOException e){ + //deal with the UnsupportedDataTypeException as well as any other unchecked IOExceptions + throw e; + } +} diff --git a/Task/Exceptions/JavaScript/exceptions-1.js b/Task/Exceptions/JavaScript/exceptions-1.js new file mode 100644 index 0000000000..518045f3b6 --- /dev/null +++ b/Task/Exceptions/JavaScript/exceptions-1.js @@ -0,0 +1,3 @@ +function doStuff() { + throw new Error('Not implemented!'); +} diff --git a/Task/Exceptions/JavaScript/exceptions-2.js b/Task/Exceptions/JavaScript/exceptions-2.js new file mode 100644 index 0000000000..fdaf6836df --- /dev/null +++ b/Task/Exceptions/JavaScript/exceptions-2.js @@ -0,0 +1,9 @@ +try { + element.attachEvent('onclick', doStuff); +} +catch(e if e instanceof TypeError) { + element.addEventListener('click', doStuff, false); +} +finally { + eventSetup = true; +} diff --git a/Task/Exceptions/Lua/exceptions-1.lua b/Task/Exceptions/Lua/exceptions-1.lua new file mode 100644 index 0000000000..58a87889d2 --- /dev/null +++ b/Task/Exceptions/Lua/exceptions-1.lua @@ -0,0 +1 @@ +error("Something bad happened!") diff --git a/Task/Exceptions/Lua/exceptions-2.lua b/Task/Exceptions/Lua/exceptions-2.lua new file mode 100644 index 0000000000..9590ae5df0 --- /dev/null +++ b/Task/Exceptions/Lua/exceptions-2.lua @@ -0,0 +1,11 @@ +function throw_error() + error("Whoops") + -- won't ever appear, due to previous error() call + return "hello!" +end + +-- 'status' is false if 'throw_error' threw an error +-- otherwise, when everything went well, it will be true. +-- 'errmsg' contains the error message, plus filename and line number of where the error occured +status, errmsg = pcall(throw_error) +print("errmsg = ", errmsg) diff --git a/Task/Exceptions/Lua/exceptions-3.lua b/Task/Exceptions/Lua/exceptions-3.lua new file mode 100644 index 0000000000..b2db587ba0 --- /dev/null +++ b/Task/Exceptions/Lua/exceptions-3.lua @@ -0,0 +1,8 @@ +function throw_error_with_argment(argument) + error(string.format("Whoops! argument = %s", argument)) + -- won't ever appear, due to previous error() call + return "hello!" +end + +status, errmsg = pcall(throw_error_with_argment, "foobar 123") +print("errmsg = ", errmsg) diff --git a/Task/Exceptions/Lua/exceptions-4.lua b/Task/Exceptions/Lua/exceptions-4.lua new file mode 100644 index 0000000000..f182968d75 --- /dev/null +++ b/Task/Exceptions/Lua/exceptions-4.lua @@ -0,0 +1,6 @@ +function throw_error_with_argment(argument) + return "hello!" +end + +status, errmsg = pcall(throw_error_with_argment, "foobar 123") +print("errmsg = ", errmsg) diff --git a/Task/Exceptions/MATLAB/exceptions.m b/Task/Exceptions/MATLAB/exceptions.m new file mode 100644 index 0000000000..6177d401a3 --- /dev/null +++ b/Task/Exceptions/MATLAB/exceptions.m @@ -0,0 +1,2 @@ +>> error 'Help' +??? Help diff --git a/Task/Exceptions/PHP/exceptions-1.php b/Task/Exceptions/PHP/exceptions-1.php new file mode 100644 index 0000000000..2319a8f713 --- /dev/null +++ b/Task/Exceptions/PHP/exceptions-1.php @@ -0,0 +1,4 @@ +class MyException extends Exception +{ + // Custom exception attributes & methods +} diff --git a/Task/Exceptions/PHP/exceptions-2.php b/Task/Exceptions/PHP/exceptions-2.php new file mode 100644 index 0000000000..4581ab8634 --- /dev/null +++ b/Task/Exceptions/PHP/exceptions-2.php @@ -0,0 +1,4 @@ +function throwsException() +{ + throw new Exception('Exception message'); +} diff --git a/Task/Exceptions/PHP/exceptions-3.php b/Task/Exceptions/PHP/exceptions-3.php new file mode 100644 index 0000000000..862e64e18b --- /dev/null +++ b/Task/Exceptions/PHP/exceptions-3.php @@ -0,0 +1,5 @@ +try { + throwsException(); +} catch (Exception $e) { + echo 'Caught exception: ' . $e->getMessage(); +} diff --git a/Task/Exceptions/Perl/exceptions-1.pl b/Task/Exceptions/Perl/exceptions-1.pl new file mode 100644 index 0000000000..92861b04de --- /dev/null +++ b/Task/Exceptions/Perl/exceptions-1.pl @@ -0,0 +1,11 @@ +# throw an exception +die "Danger, danger, Will Robinson!"; + +# catch an exception and show it +eval { + die "this could go wrong mightily"; +}; +print $@ if $@; + +# rethrow +die $@; diff --git a/Task/Exceptions/Perl/exceptions-2.pl b/Task/Exceptions/Perl/exceptions-2.pl new file mode 100644 index 0000000000..a5538c6f3f --- /dev/null +++ b/Task/Exceptions/Perl/exceptions-2.pl @@ -0,0 +1,2 @@ +# throw an exception +die "Danger, danger, Will Robinson!"; diff --git a/Task/Exceptions/Perl/exceptions-3.pl b/Task/Exceptions/Perl/exceptions-3.pl new file mode 100644 index 0000000000..5aca910d41 --- /dev/null +++ b/Task/Exceptions/Perl/exceptions-3.pl @@ -0,0 +1,6 @@ +# catch an exception and show it +try { + die "this could go wrong mightily"; +} catch { + print; +}; diff --git a/Task/Exceptions/Perl/exceptions-4.pl b/Task/Exceptions/Perl/exceptions-4.pl new file mode 100644 index 0000000000..b203694115 --- /dev/null +++ b/Task/Exceptions/Perl/exceptions-4.pl @@ -0,0 +1,2 @@ +# rethrow (inside of catch) +die $_; diff --git a/Task/Exceptions/PicoLisp/exceptions.l b/Task/Exceptions/PicoLisp/exceptions.l new file mode 100644 index 0000000000..15a1bd921b --- /dev/null +++ b/Task/Exceptions/PicoLisp/exceptions.l @@ -0,0 +1,4 @@ +(catch 'thisLabel # Catch this label + (println 1) # Do some processing (print '1') + (throw 'thisLabel 2) # Abort processing and return '2' + (println 3) ) # This is never reached diff --git a/Task/Exceptions/Python/exceptions-1.py b/Task/Exceptions/Python/exceptions-1.py new file mode 100644 index 0000000000..ca1e49f09b --- /dev/null +++ b/Task/Exceptions/Python/exceptions-1.py @@ -0,0 +1,4 @@ +import exceptions +class SillyError(exceptions.Exception): + def __init__(self,args=None): + self.args=args diff --git a/Task/Exceptions/Python/exceptions-2.py b/Task/Exceptions/Python/exceptions-2.py new file mode 100644 index 0000000000..aca0b7a3eb --- /dev/null +++ b/Task/Exceptions/Python/exceptions-2.py @@ -0,0 +1,2 @@ +class MyInvalidArgument(ValueError): + pass diff --git a/Task/Exceptions/Python/exceptions-3.py b/Task/Exceptions/Python/exceptions-3.py new file mode 100644 index 0000000000..1f3c44a535 --- /dev/null +++ b/Task/Exceptions/Python/exceptions-3.py @@ -0,0 +1,2 @@ +def spam(): + raise SillyError # equivalent to raise SillyError() diff --git a/Task/Exceptions/Python/exceptions-4.py b/Task/Exceptions/Python/exceptions-4.py new file mode 100644 index 0000000000..568018c831 --- /dev/null +++ b/Task/Exceptions/Python/exceptions-4.py @@ -0,0 +1,2 @@ +def spam(): + raise SillyError, 'egg' # equivalent to raise SillyError('egg') diff --git a/Task/Exceptions/Python/exceptions-5.py b/Task/Exceptions/Python/exceptions-5.py new file mode 100644 index 0000000000..a589050754 --- /dev/null +++ b/Task/Exceptions/Python/exceptions-5.py @@ -0,0 +1,2 @@ +def spam(): + raise SillyError('egg') diff --git a/Task/Exceptions/Python/exceptions-6.py b/Task/Exceptions/Python/exceptions-6.py new file mode 100644 index 0000000000..8cca7c6d94 --- /dev/null +++ b/Task/Exceptions/Python/exceptions-6.py @@ -0,0 +1,10 @@ +try: + foo() +except SillyError, se: + print se.args + bar() +else: + # no exception occurred + quux() +finally: + baz() diff --git a/Task/Exceptions/Python/exceptions-7.py b/Task/Exceptions/Python/exceptions-7.py new file mode 100644 index 0000000000..f6eca23e59 --- /dev/null +++ b/Task/Exceptions/Python/exceptions-7.py @@ -0,0 +1,10 @@ +try: + foo() +except SillyError as se: + print(se.args) + bar() +else: + # no exception occurred + quux() +finally: + baz() diff --git a/Task/Exceptions/R/exceptions-1.r b/Task/Exceptions/R/exceptions-1.r new file mode 100644 index 0000000000..0acb39a360 --- /dev/null +++ b/Task/Exceptions/R/exceptions-1.r @@ -0,0 +1 @@ +e <- simpleError("This is a simpleError") diff --git a/Task/Exceptions/R/exceptions-2.r b/Task/Exceptions/R/exceptions-2.r new file mode 100644 index 0000000000..a1611d105e --- /dev/null +++ b/Task/Exceptions/R/exceptions-2.r @@ -0,0 +1,2 @@ +stop("An error has occured") +stop(e) #where e is a simpleError, as above diff --git a/Task/Exceptions/R/exceptions-3.r b/Task/Exceptions/R/exceptions-3.r new file mode 100644 index 0000000000..2421c887a9 --- /dev/null +++ b/Task/Exceptions/R/exceptions-3.r @@ -0,0 +1,13 @@ +tryCatch( + { + if(runif(1) > 0.5) + { + message("This doesn't throw an error") + } else + { + stop("This is an error") + } + }, + error = function(e) message(paste("An error occured", e$message, sep = ": ")), + finally = message("This is called whether or not an exception occured") +) diff --git a/Task/Exceptions/Racket/exceptions.rkt b/Task/Exceptions/Racket/exceptions.rkt new file mode 100644 index 0000000000..f6b1955f0a --- /dev/null +++ b/Task/Exceptions/Racket/exceptions.rkt @@ -0,0 +1,13 @@ +#lang racket + +;; define a new exception type +(struct exn:my-exception exn ()) + +;; handler that prints the message ("Hi!") +(define (handler exn) + (displayln (exn-message exn))) + +;; install exception handlers +(with-handlers ([exn:my-exception? handler]) + ;; raise the exception + (raise (exn:my-exception "Hi!" (current-continuation-marks)))) diff --git a/Task/Exceptions/Ruby/exceptions-1.rb b/Task/Exceptions/Ruby/exceptions-1.rb new file mode 100644 index 0000000000..e88cb27423 --- /dev/null +++ b/Task/Exceptions/Ruby/exceptions-1.rb @@ -0,0 +1,3 @@ +# define an exception +class SillyError < Exception +end diff --git a/Task/Exceptions/Ruby/exceptions-2.rb b/Task/Exceptions/Ruby/exceptions-2.rb new file mode 100644 index 0000000000..2f83edc1a8 --- /dev/null +++ b/Task/Exceptions/Ruby/exceptions-2.rb @@ -0,0 +1,2 @@ +class MyInvalidArgument < ArgumentError +end diff --git a/Task/Exceptions/Ruby/exceptions-3.rb b/Task/Exceptions/Ruby/exceptions-3.rb new file mode 100644 index 0000000000..095a04a5a4 --- /dev/null +++ b/Task/Exceptions/Ruby/exceptions-3.rb @@ -0,0 +1,11 @@ +# raise (throw) an exception +def spam + raise SillyError, 'egg' +end + +# rescue (catch) an exception +begin + spam +rescue SillyError => se + puts se # writes 'egg' to stdout +end diff --git a/Task/Exceptions/Ruby/exceptions-4.rb b/Task/Exceptions/Ruby/exceptions-4.rb new file mode 100644 index 0000000000..d1c7c71675 --- /dev/null +++ b/Task/Exceptions/Ruby/exceptions-4.rb @@ -0,0 +1,15 @@ +begin + foo +rescue ArgumentError => e + # rescues a MyInvalidArgument or any other ArgumentError + bar +rescue => e + # rescues a StandardError + quack +else + # runs if no exception occurred + quux +ensure + # always runs + baz +end diff --git a/Task/Exceptions/Ruby/exceptions-5.rb b/Task/Exceptions/Ruby/exceptions-5.rb new file mode 100644 index 0000000000..ffc2fb2a19 --- /dev/null +++ b/Task/Exceptions/Ruby/exceptions-5.rb @@ -0,0 +1,2 @@ +# short way to rescue any StandardError +quotient = 1 / 0 rescue "sorry" diff --git a/Task/Exceptions/Ruby/exceptions-6.rb b/Task/Exceptions/Ruby/exceptions-6.rb new file mode 100644 index 0000000000..e09a9a3945 --- /dev/null +++ b/Task/Exceptions/Ruby/exceptions-6.rb @@ -0,0 +1,7 @@ +def foo + throw :done +end + +catch :done do + foo +end diff --git a/Task/Exceptions/Scheme/exceptions.ss b/Task/Exceptions/Scheme/exceptions.ss new file mode 100644 index 0000000000..6e1e9778d8 --- /dev/null +++ b/Task/Exceptions/Scheme/exceptions.ss @@ -0,0 +1,22 @@ +(define (me-errors xx exception) + (if (even? xx) + xx + (exception))) + +;example that does nothing special on exception +(call/cc + (lambda (exception) + (me-errors 222 exception) + (display "I guess everything is alright"))) + +;example that laments oddness on exception +(call/cc + (lambda (all-ok) ;used to "jump" over exception handling + + (call/cc + (lambda (exception-handle) + (me-errors 333 exception-handle) + (display "I guess everything is alright") + (all-ok))) + + (display "oh my god it is ODD!"))) diff --git a/Task/Exceptions/Smalltalk/exceptions-1.st b/Task/Exceptions/Smalltalk/exceptions-1.st new file mode 100644 index 0000000000..8e308c673f --- /dev/null +++ b/Task/Exceptions/Smalltalk/exceptions-1.st @@ -0,0 +1,5 @@ +"exec" "gst" "-f" "$0" "$0" "$*" +"exit" + +Transcript show: 'Throwing yawp'; cr. +self error: 'Yawp!'. diff --git a/Task/Exceptions/Smalltalk/exceptions-2.st b/Task/Exceptions/Smalltalk/exceptions-2.st new file mode 100644 index 0000000000..d9e063cdd7 --- /dev/null +++ b/Task/Exceptions/Smalltalk/exceptions-2.st @@ -0,0 +1,7 @@ +$ ./yawp.st +Throwing yawp +Object: nil error: Yawp! +Error(Exception)>>signal (AnsiExcept.st:216) +Error(Exception)>>signal: (AnsiExcept.st:226) +UndefinedObject(Object)>>error: (AnsiExcept.st:1565) +UndefinedObject>>executeStatements (yawp.st:5) diff --git a/Task/Exceptions/Smalltalk/exceptions-3.st b/Task/Exceptions/Smalltalk/exceptions-3.st new file mode 100644 index 0000000000..5615554832 --- /dev/null +++ b/Task/Exceptions/Smalltalk/exceptions-3.st @@ -0,0 +1,9 @@ +"exec" "gst" "-f" "$0" "$0" "$*" +"exit" + +[ + Transcript show: 'Throwing yawp'; cr. + self error: 'Yawp!'. +] on: Error do: [ :e | + Transcript show: 'Caught yawp'; cr. +]. diff --git a/Task/Exceptions/Smalltalk/exceptions-4.st b/Task/Exceptions/Smalltalk/exceptions-4.st new file mode 100644 index 0000000000..ab71965e97 --- /dev/null +++ b/Task/Exceptions/Smalltalk/exceptions-4.st @@ -0,0 +1,3 @@ +$ ./yawp.st +Throwing yawp +Caught yawp diff --git a/Task/Exceptions/Tcl/exceptions.tcl b/Task/Exceptions/Tcl/exceptions.tcl new file mode 100644 index 0000000000..684aa94737 --- /dev/null +++ b/Task/Exceptions/Tcl/exceptions.tcl @@ -0,0 +1,15 @@ +package require Tcl 8.5 + +# Throw +proc e {args} { + error "error message" "error message for stack trace" {errorCode list} +} + +# Catch and rethrow +proc f {} { + if {[catch {e 1 2 3 4} errMsg options] != 0} { + return -options $options $errMsg + } +} + +f diff --git a/Task/Executable-library/0DESCRIPTION b/Task/Executable-library/0DESCRIPTION new file mode 100644 index 0000000000..f8e3bb4ac8 --- /dev/null +++ b/Task/Executable-library/0DESCRIPTION @@ -0,0 +1,18 @@ +The general idea behind an executable library is to create a library that when used as a library does one thing; but has the ability to be run directly via command line. Thus the API comes with a CLI in the very same source code file. + +'''Task detail''' + +* Create a library/module/dll/shared object/... for a programming language that contains a function/method called hailstone that is a function taking a positive integer and returns the [[Hailstone sequence]] for that number. + +* The library, when executed directly should satisfy the remaining requirements of the [[Hailstone sequence]] task: +:: 2. Use the routine to show that the hailstone sequence for the number 27 has 112 elements starting with 27, 82, 41, 124 and ending with 8, 4, 2, 1 +:: 3. Show the number less than 100,000 which has the longest hailstone sequence together with that sequences length. + +* Create a second executable to calculate the following: +** Use the libraries hailstone function, in the standard manner, (or document how this use deviates from standard use of a library), together with extra code in this executable, to find the hailstone length returned most often for 1 ≤ n < 100,000. + +* Explain any extra setup/run steps needed to complete the task. + +'''Notes:''' +* It is assumed that for a language that overwhelmingly ships in a compiled form, such as C, the library must also be an executable and the compiled user of that library is to do so without changing the compiled library. I.e. the compile tool-chain is assumed ''not'' to be present in the runtime environment. +* Interpreters are present in the runtime environment. diff --git a/Task/Executable-library/Ada/executable-library-1.ada b/Task/Executable-library/Ada/executable-library-1.ada new file mode 100644 index 0000000000..2e1f4ab893 --- /dev/null +++ b/Task/Executable-library/Ada/executable-library-1.ada @@ -0,0 +1,4 @@ +package Parameter is + X: Natural := 0; + Y: Natural; +end Parameter; diff --git a/Task/Executable-library/Ada/executable-library-2.ada b/Task/Executable-library/Ada/executable-library-2.ada new file mode 100644 index 0000000000..5af651f272 --- /dev/null +++ b/Task/Executable-library/Ada/executable-library-2.ada @@ -0,0 +1,49 @@ +with Ada.Text_IO, Parameter, Hailstones; + +procedure Hailstone is + -- if Parameter.X > 0, the length of Hailstone(Parameter.X) + -- is computed and written into Parameter.Y + + -- if Parameter.X = 0, Hailstone(27) and N <= 100_000 with maximal + -- Hailstone(N) are computed and printed. + + procedure Show_Sequence(N: Natural) is + Seq: Hailstones.Integer_Sequence := Hailstones.Create_Sequence(N); + begin + Ada.Text_IO.Put("Hailstone(" & Integer'Image(N) & " ) = ("); + if Seq'Length < 8 then + for I in Seq'First .. Seq'Last-1 loop + Ada.Text_IO.Put(Integer'Image(Seq(I)) & ","); + end loop; + else + for I in Seq'First .. Seq'First+3 loop + Ada.Text_IO.Put(Integer'Image(Seq(I)) & ","); + end loop; + Ada.Text_IO.Put(" ...,"); + for I in Seq'Last-3 .. Seq'Last-1 loop + Ada.Text_IO.Put(Integer'Image(Seq(I)) &","); + end loop; + end if; + Ada.Text_IO.Put_Line(Integer'Image(Seq(Seq'Last)) & " ); Length: " & + Integer'Image(seq'Length)); + end Show_Sequence; +begin + if Parameter.X>0 then + Parameter.Y := Hailstones.Create_Sequence(Parameter.X)'Length; + else + Show_Sequence(27); + declare + Longest: Natural := 0; + Longest_Length: Natural := 0; + begin + for I in 2 .. 100_000 loop + if Hailstones.Create_Sequence(I)'Length > Longest_Length then + Longest := I; + Longest_Length := Hailstones.Create_Sequence(I)'Length; + end if; + end loop; + Ada.Text_IO.Put("Longest<=100_000: "); + Show_Sequence(Longest); + end; + end if; +end Hailstone; diff --git a/Task/Executable-library/Ada/executable-library-3.ada b/Task/Executable-library/Ada/executable-library-3.ada new file mode 100644 index 0000000000..80f26160dc --- /dev/null +++ b/Task/Executable-library/Ada/executable-library-3.ada @@ -0,0 +1 @@ +procedure Hailstone; diff --git a/Task/Executable-library/Ada/executable-library-4.ada b/Task/Executable-library/Ada/executable-library-4.ada new file mode 100644 index 0000000000..db9ed5974b --- /dev/null +++ b/Task/Executable-library/Ada/executable-library-4.ada @@ -0,0 +1,35 @@ +with Hailstone, Parameter, Ada.Text_IO; + +procedure Hailstone_Test is + Counts: array (1 .. 100_000) of Natural := (others => 0); + Max_Count: Natural := 0; + Most_Common: Positive := Counts'First; + Length: Natural renames Parameter.Y; + Sample: Natural := 0; +begin + for I in Counts'Range loop + Parameter.X := I; + Hailstone; -- compute the length of Hailstone(I) + Counts(Length) := Counts(Length)+1; + end loop; + for I in Counts'Range loop + if Counts(I) > Max_Count then + Max_Count := Counts(I); + Most_Common := I; + end if; + end loop; + Ada.Text_IO.Put_Line("Most frequent length:" + & Integer'Image(Most_Common) + & ";" & Integer'Image(Max_Count) + & " sequences of that length."); + for I in Counts'Range loop + Parameter.X := I; + Hailstone; -- compute the length of Hailstone(I) + if Length = Most_Common then + Sample := I; + exit; + end if; + end loop; + Ada.Text_IO.Put_Line("The first such sequence: Hailstone(" + & Integer'Image(Sample) & " )."); +end Hailstone_Test; diff --git a/Task/Executable-library/AutoHotkey/executable-library-1.ahk b/Task/Executable-library/AutoHotkey/executable-library-1.ahk new file mode 100644 index 0000000000..00ef170298 --- /dev/null +++ b/Task/Executable-library/AutoHotkey/executable-library-1.ahk @@ -0,0 +1,28 @@ +#NoEnv +SetBatchLines, -1 + +; Check if we're executed directly: +If (A_LineFile = A_ScriptFullPath){ + h27 := hailstone(27) + MsgBox % "Length of hailstone 27: " (m := h27.MaxIndex()) "`nStarts with " + . h27[1] ", " h27[2] ", " h27[3] ", " h27[4] + . "`nEnds with " + . h27[m-3] ", " h27[m-2] ", " h27[m-1] ", " h27[m] + + Loop 100000 + { + h := hailstone(A_Index) + If (h.MaxIndex() > m) + m := h.MaxIndex(), longest := A_Index + } + MsgBox % "Longest hailstone is that of " longest " with a length of " m "!" +} + + +hailstone(n){ + out := [n] + Loop + n := n & 1 ? n*3+1 : n//2, out.insert(n) + until n=1 + return out +} diff --git a/Task/Executable-library/AutoHotkey/executable-library-2.ahk b/Task/Executable-library/AutoHotkey/executable-library-2.ahk new file mode 100644 index 0000000000..ed2ec8d5d2 --- /dev/null +++ b/Task/Executable-library/AutoHotkey/executable-library-2.ahk @@ -0,0 +1,17 @@ +#NoEnv +#Include %A_ScriptDir%\hailstone.ahk +SetBatchLines -1 + +col := Object(), highestCount := 0 + +Loop 100000 +{ + length := hailstone(A_Index).MaxIndex() + if not col[length] + col[length] := 0 + col[length]++ +} +for length, count in col + if (count > highestCount) + highestCount := count, highestN := length +MsgBox % "the most common length was " highestN "; it occurred " highestCount " times." diff --git a/Task/Executable-library/BBC-BASIC/executable-library-1.bbc b/Task/Executable-library/BBC-BASIC/executable-library-1.bbc new file mode 100644 index 0000000000..b6036539dc --- /dev/null +++ b/Task/Executable-library/BBC-BASIC/executable-library-1.bbc @@ -0,0 +1,21 @@ + seqlen% = FNhailstone(27) + PRINT "Sequence length for 27 is "; seqlen% + maxlen% = 0 + FOR number% = 2 TO 100000 + seqlen% = FNhailstone(number%) + IF seqlen% > maxlen% THEN + maxlen% = seqlen% + maxnum% = number% + ENDIF + NEXT + PRINT "The number with the longest hailstone sequence is " ; maxnum% + PRINT "Its sequence length is " ; maxlen% + END + + DEF FNhailstone(N%) + LOCAL L% + WHILE N% <> 1 + IF N% AND 1 THEN N% = 3 * N% + 1 ELSE N% DIV= 2 + L% += 1 + ENDWHILE + = L% + 1 diff --git a/Task/Executable-library/BBC-BASIC/executable-library-2.bbc b/Task/Executable-library/BBC-BASIC/executable-library-2.bbc new file mode 100644 index 0000000000..67ede570c0 --- /dev/null +++ b/Task/Executable-library/BBC-BASIC/executable-library-2.bbc @@ -0,0 +1,18 @@ + INSTALL "HAILSTONE" + + DIM freq%(351) + FOR number% = 2 TO 100000 + seqlen% = FNhailstone(number%) + freq%(seqlen%) += 1 + NEXT + max% = 0 + FOR i% = 0 TO 351 + IF freq%(i%) > max% THEN + max% = freq%(i%) + mostcommon% = i% + ENDIF + NEXT + + PRINT "The most common sequence length is " ; mostcommon% + PRINT "It occurs " ; max% " times" + END diff --git a/Task/Executable-library/C/executable-library-1.c b/Task/Executable-library/C/executable-library-1.c new file mode 100644 index 0000000000..82c52a446a --- /dev/null +++ b/Task/Executable-library/C/executable-library-1.c @@ -0,0 +1,7 @@ +#ifndef HAILSTONE +#define HAILSTONE + +long hailstone(long, long**); +void free_sequence(long *); + +#endif/*HAILSTONE*/ diff --git a/Task/Executable-library/C/executable-library-2.c b/Task/Executable-library/C/executable-library-2.c new file mode 100644 index 0000000000..336ddcea54 --- /dev/null +++ b/Task/Executable-library/C/executable-library-2.c @@ -0,0 +1,44 @@ +#include +#include + +long hailstone(long n, long **seq) +{ + long len = 0, buf_len = 4; + if (seq) + *seq = malloc(sizeof(long) * buf_len); + + while (1) { + if (seq) { + if (len >= buf_len) { + buf_len *= 2; + *seq = realloc(*seq, sizeof(long) * buf_len); + } + (*seq)[len] = n; + } + len ++; + if (n == 1) break; + if (n & 1) n = 3 * n + 1; + else n >>= 1; + } + return len; +} + +void free_sequence(long * s) { free(s); } + +const char my_interp[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2"; +/* "ld-linux.so.2" should be whatever you use on your platform */ + +int hail_main() /* entry point when running along, see compiler command line */ +{ + long i, *seq; + + long len = hailstone(27, &seq); + printf("27 has %ld numbers in sequence:\n", len); + for (i = 0; i < len; i++) { + printf("%ld ", seq[i]); + } + printf("\n"); + free_sequence(seq); + + exit(0); +} diff --git a/Task/Executable-library/C/executable-library-3.c b/Task/Executable-library/C/executable-library-3.c new file mode 100644 index 0000000000..191b82a821 --- /dev/null +++ b/Task/Executable-library/C/executable-library-3.c @@ -0,0 +1,20 @@ +#include +#include "hailstone.h" + +int main() +{ + long i, longest, longest_i, len; + + longest = 0; + for (i = 1; i < 100000; i++) { + len = hailstone(i, 0); + if (len > longest) { + longest_i = i; + longest = len; + } + } + + printf("Longest sequence at %ld, length %ld\n", longest_i, longest); + + return 0; +} diff --git a/Task/Executable-library/Perl/executable-library-1.pl b/Task/Executable-library/Perl/executable-library-1.pl new file mode 100644 index 0000000000..bd1e373e03 --- /dev/null +++ b/Task/Executable-library/Perl/executable-library-1.pl @@ -0,0 +1,26 @@ +package Hailstone; + +sub seq { + my $x = shift; + $x == 1 ? (1) : ($x & 1)? ($x, seq($x * 3 + 1)) + : ($x, seq($x / 2)) +} + +my %cache = (1 => 1); +sub len { + my $x = shift; + $cache{$x} //= 1 + ( + $x & 1 ? len($x * 3 + 1) + : len($x / 2)) +} + +unless (caller) { + for (1 .. 100_000) { + my $l = len($_); + ($m, $len) = ($_, $l) if $l > $len; + } + print "seq of 27 - $cache{27} elements: @{[seq(27)]}\n"; + print "Longest sequence is for $m: $len\n"; +} + +1; diff --git a/Task/Executable-library/Perl/executable-library-2.pl b/Task/Executable-library/Perl/executable-library-2.pl new file mode 100644 index 0000000000..e2523bdf51 --- /dev/null +++ b/Task/Executable-library/Perl/executable-library-2.pl @@ -0,0 +1,11 @@ +use Hailstone; +use strict; +use warnings; + +my %seqs; +for (1 .. 100_000) { + $seqs{Hailstone::len($_)}++; +} + +my ($most_frequent) = sort {$seqs{$b} <=> $seqs{$a}} keys %seqs; +print "Most frequent length: $most_frequent ($seqs{$most_frequent} occurrences)\n"; diff --git a/Task/Executable-library/PicoLisp/executable-library-1.l b/Task/Executable-library/PicoLisp/executable-library-1.l new file mode 100644 index 0000000000..6fc9e0a513 --- /dev/null +++ b/Task/Executable-library/PicoLisp/executable-library-1.l @@ -0,0 +1,20 @@ +#!/usr/bin/picolisp /usr/lib/picolisp/lib.l + +(de hailstone (N) + (make + (until (= 1 (link N)) + (setq N + (if (bit? 1 N) + (inc (* N 3)) + (/ N 2) ) ) ) ) ) + +(de hailtest () + (let L (hailstone 27) + (test 112 (length L)) + (test (27 82 41 124) (head 4 L)) + (test (8 4 2 1) (tail 4 L)) ) + (let N (maxi '((N) (length (hailstone N))) (range 1 100000)) + (test 77031 N) + (test 351 (length (hailstone N))) ) + (println 'OK) + (bye) ) diff --git a/Task/Executable-library/PicoLisp/executable-library-2.l b/Task/Executable-library/PicoLisp/executable-library-2.l new file mode 100644 index 0000000000..a7dd3d92d9 --- /dev/null +++ b/Task/Executable-library/PicoLisp/executable-library-2.l @@ -0,0 +1,11 @@ +#!/usr/bin/picolisp /usr/lib/picolisp/lib.l + +(load "hailstone.l") + +(let Len NIL + (for N 100000 + (accu 'Len (length (hailstone N)) 1) ) + (let M (maxi cdr Len) + (prinl "The hailstone length returned most often is " (car M)) + (prinl "It is returned " (cdr M) " times") ) ) +(bye) diff --git a/Task/Executable-library/Python/executable-library-1.py b/Task/Executable-library/Python/executable-library-1.py new file mode 100644 index 0000000000..535e7e23ca --- /dev/null +++ b/Task/Executable-library/Python/executable-library-1.py @@ -0,0 +1,12 @@ +def hailstone(n): + seq = [n] + while n>1: + n = 3*n + 1 if n & 1 else n//2 + seq.append(n) + return seq + +if __name__ == '__main__': + h = hailstone(27) + assert len(h)==112 and h[:4]==[27, 82, 41, 124] and h[-4:]==[8, 4, 2, 1] + print("Maximum length %i was found for hailstone(%i) for numbers <100,000" % + max((len(hailstone(i)), i) for i in range(1,100000))) diff --git a/Task/Executable-library/Python/executable-library-2.py b/Task/Executable-library/Python/executable-library-2.py new file mode 100644 index 0000000000..440a8eb9de --- /dev/null +++ b/Task/Executable-library/Python/executable-library-2.py @@ -0,0 +1,13 @@ +from collections import Counter + +def function_length_frequency(func, hrange): + return Counter(len(func(n)) for n in hrange).most_common() + +if __name__ == '__main__': + from executable_hailstone_library import hailstone + + upto = 100000 + hlen, freq = function_length_frequency(hailstone, range(1, upto))[0] + print("The length of hailstone sequence that is most common for\n" + "hailstone(n) where 1<=n<%i, is %i. It occurs %i times." + % (upto, hlen, freq)) diff --git a/Task/Executable-library/REXX/executable-library-1.rexx b/Task/Executable-library/REXX/executable-library-1.rexx new file mode 100644 index 0000000000..7fcc402586 --- /dev/null +++ b/Task/Executable-library/REXX/executable-library-1.rexx @@ -0,0 +1,9 @@ +/*REXX program returns the hailstone (Collatz) sequence for any integer.*/ +numeric digits 20 /*ensure enough digits for mult. */ +parse arg n 1 s /*N & S assigned to the first arg*/ + do while n\==1 /*loop while N isn't unity. */ + if n//2 then n=n*3+1 /*if N is odd, calc: 3*n +1 */ + else n=n%2 /* " " " even, perform fast ÷ */ + s=s n /*build a sequence list (append).*/ + end /*while*/ +return s diff --git a/Task/Executable-library/REXX/executable-library-2.rexx b/Task/Executable-library/REXX/executable-library-2.rexx new file mode 100644 index 0000000000..b6bc0ef8ea --- /dev/null +++ b/Task/Executable-library/REXX/executable-library-2.rexx @@ -0,0 +1,16 @@ +/*REXX pgm tests a number and a range for hailstone (Collatz) sequences.*/ +parse arg x .; if x=='' then x=27 /*get the optional first argument*/ + +$=hailstone(x) /*═════════════task 2════════════*/ +#=words($) /*number of numbers in sequence. */ +say x 'has a hailstone sequence of' # 'and starts with: ' subword($,1,4), + ' and ends with:' subword($,#-3) +say +w=0; do j=1 for 99999 /*═════════════task 3════════════*/ + $=hailstone(j); #=words($) /*obtain the hailstone sequence. */ + if #<=w then iterate /*Not big 'nuff? Then keep going.*/ + bigJ=j; w=# /*remember what # has biggest HS.*/ + end /*j*/ + +say '(between 1──►99,999) ' bigJ 'has the longest hailstone sequence:' w + /*stick a fork in it, we're done.*/ diff --git a/Task/Executable-library/REXX/executable-library-3.rexx b/Task/Executable-library/REXX/executable-library-3.rexx new file mode 100644 index 0000000000..e5adcbb048 --- /dev/null +++ b/Task/Executable-library/REXX/executable-library-3.rexx @@ -0,0 +1,15 @@ +/*REXX pgm finds the most common (popular) hailstone sequence length. */ +parse arg z .; if z=='' then z=99999 /*get the optional first argument*/ +!.=0 +w=0; do j=1 for z /*═════════════task 4════════════*/ + #=words(hailstone(j)) /*obtain hailstone sequence count*/ + !.# = !.# + 1 /*add unity to popularity count. */ + end /*j*/ +occ=0; p=0 + do k=1 for z + if !.k>occ then do; occ=!.k; p=k; end + end /*p*/ + +say '(between 1──►'z") " p, +' is the most common hailstone sequence length (with' occ "occurrences)." + /*stick a fork in it, we're done.*/ diff --git a/Task/Executable-library/Ruby/executable-library-1.rb b/Task/Executable-library/Ruby/executable-library-1.rb new file mode 100644 index 0000000000..3a8c4902d0 --- /dev/null +++ b/Task/Executable-library/Ruby/executable-library-1.rb @@ -0,0 +1,26 @@ +# hailstone.rb +module Hailstone + module_function + def hailstone n + seq = [n] + until n == 1 + n = (n.even?) ? (n / 2) : (3 * n + 1) + seq << n + end + seq + end +end + +if __FILE__ == $0 + include Hailstone + + # for n = 27, show sequence length and first and last 4 elements + hs27 = hailstone 27 + p [hs27.length, hs27[0..3], hs27[-4..-1]] + + # find the longest sequence among n less than 100,000 + n, len = (1 ... 100_000) .collect {|n| + [n, hailstone(n).length]} .max_by {|n, len| len} + puts "#{n} has a hailstone sequence length of #{len}" + puts "the largest number in that sequence is #{hailstone(n).max}" +end diff --git a/Task/Executable-library/Ruby/executable-library-2.rb b/Task/Executable-library/Ruby/executable-library-2.rb new file mode 100644 index 0000000000..0555195e68 --- /dev/null +++ b/Task/Executable-library/Ruby/executable-library-2.rb @@ -0,0 +1,11 @@ +# hsfreq.rb +require 'hailstone' + +h = Hash.new(0) +last = 99_999 +(1..last).each {|n| h[Hailstone.hailstone(n).length] += 1} +length, count = h.max_by {|length, count| count} + +puts "Given the hailstone sequences from 1 to #{last}," +puts "the most common sequence length is #{length}," +puts "with #{count} such sequences." diff --git a/Task/Executable-library/Tcl/executable-library-1.tcl b/Task/Executable-library/Tcl/executable-library-1.tcl new file mode 100644 index 0000000000..b1bb7f30e5 --- /dev/null +++ b/Task/Executable-library/Tcl/executable-library-1.tcl @@ -0,0 +1,25 @@ +### In the file hailstone.tcl ### +package provide hailstone 1.0 + +proc hailstone n { + while 1 { + lappend seq $n + if {$n == 1} {return $seq} + set n [expr {$n & 1 ? $n*3+1 : $n/2}] + } +} + +# If directly executed, run demo code +if {[info script] eq $::argv0} { + set h27 [hailstone 27] + puts "h27 len=[llength $h27]" + puts "head4 = [lrange $h27 0 3]" + puts "tail4 = [lrange $h27 end-3 end]" + + set maxlen [set max 0] + for {set i 1} {$i<100000} {incr i} { + set l [llength [hailstone $i]] + if {$l>$maxlen} {set maxlen $l;set max $i} + } + puts "max is $max, with length $maxlen" +} diff --git a/Task/Executable-library/Tcl/executable-library-2.tcl b/Task/Executable-library/Tcl/executable-library-2.tcl new file mode 100644 index 0000000000..43d2393fed --- /dev/null +++ b/Task/Executable-library/Tcl/executable-library-2.tcl @@ -0,0 +1 @@ +pkg_mkIndex . diff --git a/Task/Executable-library/Tcl/executable-library-3.tcl b/Task/Executable-library/Tcl/executable-library-3.tcl new file mode 100644 index 0000000000..8a43715448 --- /dev/null +++ b/Task/Executable-library/Tcl/executable-library-3.tcl @@ -0,0 +1,16 @@ +#!/usr/bin/tclsh8.6 +package require Tcl 8.6 ;# For [lsort -stride] option +lappend auto_path . ;# Or wherever it is located +package require hailstone 1.0 + +# Construct a histogram of length frequencies +set histogram {} +for {set n 1} {$n < 100000} {incr n} { + dict incr histogram [llength [hailstone $n]] +} + +# Identify the most common length by sorting... +set sortedHist [lsort -decreasing -stride 2 -index 1 $histogram] +lassign $sortedHist mostCommonLength freq + +puts "most common length is $mostCommonLength, with frequency $freq" diff --git a/Task/Execute-HQ9+/0DESCRIPTION b/Task/Execute-HQ9+/0DESCRIPTION new file mode 100644 index 0000000000..880884e0fc --- /dev/null +++ b/Task/Execute-HQ9+/0DESCRIPTION @@ -0,0 +1 @@ +Implement a [[HQ9+]] interpreter or compiler for Rosetta Code. diff --git a/Task/Execute-HQ9+/AutoHotkey/execute-hq9+.ahk b/Task/Execute-HQ9+/AutoHotkey/execute-hq9+.ahk new file mode 100644 index 0000000000..46e54705e2 --- /dev/null +++ b/Task/Execute-HQ9+/AutoHotkey/execute-hq9+.ahk @@ -0,0 +1,28 @@ +; http://www.autohotkey.com/forum/viewtopic.php?p=356268#356268 + +testCode := "hq9+HqQ+Qq" + +MsgBox % RunHQ9Plus(testCode) + +;--------------------------------- + +RunHQ9Plus(input) +{ + Loop, Parse, input + If ( A_LoopField = "+" ) + acc++ + Else If ( A_LoopField = "H" ) + output .= "Hello, world!`n" + Else If ( A_LoopField = "Q" ) + output .= input "`n" + Else If ( A_LoopField = "9" ) + Loop, 99 + { + ; following 4 lines could be only 1 long line + output .= (99+1-A_Index) " bottles of beer on the wall`n" + output .= (99+1-A_Index) " bottles of beer`n" + output .= "Take one down, pass it around`n" + output .= (99-A_Index) " bottles of beer on the wall`n`n" + } + Return output +} diff --git a/Task/Execute-HQ9+/BBC-BASIC/execute-hq9+.bbc b/Task/Execute-HQ9+/BBC-BASIC/execute-hq9+.bbc new file mode 100644 index 0000000000..f0e8c2ebcc --- /dev/null +++ b/Task/Execute-HQ9+/BBC-BASIC/execute-hq9+.bbc @@ -0,0 +1,22 @@ + PROChq9plus("hq9+HqQ+Qq") + END + + DEF PROChq9plus(code$) + LOCAL accumulator%, i%, bottles% + FOR i% = 1 TO LEN(code$) + CASE MID$(code$, i%, 1) OF + WHEN "h","H": PRINT "Hello, world!" + WHEN "q","Q": PRINT code$ + WHEN "9": + bottles% = 99 + WHILE bottles% + PRINT ;bottles% " bottles of beer on the wall, "; + PRINT ;bottles% " bottles of beer," + bottles% -= 1 + PRINT "Take one down, pass it around, "; + PRINT ;bottles% " bottles of beer on the wall." + ENDWHILE + WHEN "+": accumulator% += 1 + ENDCASE + NEXT i% + ENDPROC diff --git a/Task/Execute-HQ9+/C++/execute-hq9+.cpp b/Task/Execute-HQ9+/C++/execute-hq9+.cpp new file mode 100644 index 0000000000..750742d3d9 --- /dev/null +++ b/Task/Execute-HQ9+/C++/execute-hq9+.cpp @@ -0,0 +1,34 @@ +void runCode(string code) +{ + int c_len = code.length(); + int accumulator, bottles; + for(int i=0;i 0 ); + break; + + case '+': + //Am I the only one finding this one weird? :o + accumulator++; + break; + } + } +}; diff --git a/Task/Execute-HQ9+/C-sharp/execute-hq9+.cs b/Task/Execute-HQ9+/C-sharp/execute-hq9+.cs new file mode 100644 index 0000000000..dd02a94161 --- /dev/null +++ b/Task/Execute-HQ9+/C-sharp/execute-hq9+.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +class Program +{ + static void RunCode(string code) + { + int accumulator = 0; + var opcodes = new Dictionary + { + {'H', () => Console.WriteLine("Hello, World!"))}, + {'Q', () => Console.WriteLine(code) }, + {'9', () => Console.WriteLine(Enumerable.Range(1,100).Reverse().Select(n => string.Format("{0} bottles of beer on the wall\n{0} bottles of beer\nTake one down, pass it around\n{1} bottles of beer on the wall\n", n, n-1)).Aggregate((a,b) => a + "\n" + b))}, + {'+', () => accumulator++ } + } + + foreach(var c in code) + opcodes[c](); + } +} diff --git a/Task/Execute-HQ9+/C/execute-hq9+.c b/Task/Execute-HQ9+/C/execute-hq9+.c new file mode 100644 index 0000000000..40f5028649 --- /dev/null +++ b/Task/Execute-HQ9+/C/execute-hq9+.c @@ -0,0 +1,34 @@ +void runCode(const char *code) +{ + int c_len = strlen(code); + int i, accumulator, bottles; + for(i=0;i 0 ); + break; + + case '+': + //Am I the only one finding this one weird? :o + accumulator++; + break; + } + } +}; diff --git a/Task/Execute-HQ9+/Clojure/execute-hq9+.clj b/Task/Execute-HQ9+/Clojure/execute-hq9+.clj new file mode 100644 index 0000000000..50d6921c57 --- /dev/null +++ b/Task/Execute-HQ9+/Clojure/execute-hq9+.clj @@ -0,0 +1,23 @@ +(ns anthony.random.hq9plus + (:require [clojure.string :as str])) + +(defn bottles [] + (loop [bottle 99] + (if (== bottle 0) + () + (do + (println (str bottle " bottles of beer on the wall")) + (println (str bottle " bottles of beer")) + (println "Take one down, pass it around") + (println (str bottle " bottles of beer on the wall")) + (recur (dec bottle)))))) + +(defn execute-hq9plus [& commands] + (let [accumulator (atom 0)] + (loop [pointer 0] + (condp = (nth commands pointer) + \H (println "Hello, world!") + \Q (println (str/join commands)) + \9 (bottles) + \+ (reset! accumulator (inc @accumulator))) + (if-not (= (inc pointer) (count commands)) (recur (inc pointer)))))) diff --git a/Task/Execute-HQ9+/D/execute-hq9+.d b/Task/Execute-HQ9+/D/execute-hq9+.d new file mode 100644 index 0000000000..47a1e12a65 --- /dev/null +++ b/Task/Execute-HQ9+/D/execute-hq9+.d @@ -0,0 +1,36 @@ +import std.stdio, std.string; + +void main(in string[] args) { + if (args.length != 2 || + args[1].length != args[1].countchars("hHqQ9+")) { + writeln("Not valid HQ9+ code."); + return; + } + + ulong accumulator; + foreach (immutable c; args[1]) { + final switch(c) { + case 'Q', 'q': + writeln(args[1]); + break; + case 'H', 'h': + writeln("Hello, world!"); + break; + case '9': + int bottles = 99; + while (bottles > 1) { + writeln(bottles, " bottles of beer on the wall,"); + writeln(bottles, " bottles of beer."); + writeln("Take one down, pass it around,"); + if (--bottles > 1) + writeln(bottles, + " bottles of beer on the wall.\n"); + } + writeln("1 bottle of beer on the wall.\n"); + break; + case '+': + accumulator++; + break; + } + } +} diff --git a/Task/Execute-HQ9+/DWScript/execute-hq9+.dwscript b/Task/Execute-HQ9+/DWScript/execute-hq9+.dwscript new file mode 100644 index 0000000000..d3ab5220d2 --- /dev/null +++ b/Task/Execute-HQ9+/DWScript/execute-hq9+.dwscript @@ -0,0 +1,28 @@ +procedure RunCode(code : String); +var + i : Integer; + accum, bottles : Integer; +begin + for i:=1 to Length(code) do begin + case code[i] of + 'Q', 'q' : PrintLn(code); + 'H', 'h' : PrintLn('Hello, world!'); + '9' : begin + bottles:=99; + while bottles>1 do begin + Print(bottles); PrintLn(' bottles of beer on the wall,'); + Print(bottles); PrintLn(' bottles of beer.'); + PrintLn('Take one down, pass it around,'); + Dec(bottles); + if bottles>1 then begin + Print(bottles); PrintLn(' bottles of beer on the wall.'#13#10); + end; + end; + PrintLn('1 bottle of beer on the wall.'); + end; + '+' : Inc(accum); + else + PrintLn('Syntax Error'); + end; + end; +end; diff --git a/Task/Execute-HQ9+/Ela/execute-hq9+-1.ela b/Task/Execute-HQ9+/Ela/execute-hq9+-1.ela new file mode 100644 index 0000000000..e1621e4380 --- /dev/null +++ b/Task/Execute-HQ9+/Ela/execute-hq9+-1.ela @@ -0,0 +1,21 @@ +open console char cell imperative + +eval src = eval' src + where eval' [] = () + eval' (x::xs) | be 'H' = h() `seq` eval' xs + | be 'Q' = q() `seq` eval' xs + | be '9' = n() `seq` eval' xs + | be '+' = p() `seq` eval' xs + | else = fail ("Unrecognized " ++ x) + where r = ref 0 + be c = upper x == c + h () = writen "Hello, world!" + q () = writen src + p () = r.+ + n () = bottles [99,98..1] + where bottles [] = () + bottles (x::xs) = rec write + (show x) " bottles of beer of the wall\r\n" + (show x) " bottles of beer\r\n" + "Take one down, pass it around\r\n" + `seq` bottles xs diff --git a/Task/Execute-HQ9+/Ela/execute-hq9+-2.ela b/Task/Execute-HQ9+/Ela/execute-hq9+-2.ela new file mode 100644 index 0000000000..032c5b5317 --- /dev/null +++ b/Task/Execute-HQ9+/Ela/execute-hq9+-2.ela @@ -0,0 +1,19 @@ +open list char + +eval src = eval' src 0 + where eval' [] a = [] + eval' (x::xs) a | be 'H' = h :: eval' xs a + | be 'Q' = q :: eval' xs a + | be '9' = force n :: eval' xs a + | be '+' = eval' xs (a+1) + | else = fail "Invalid instruction." + where be c = upper x == c + h = "Hello, world!" + q = src + n = (& bottles [99,98..1]) + where bottles [] = "" + bottles (x::xs) = + show x ++ " bottles of beer of the wall\r\n" + ++ show x ++ " bottles of beer\r\n" + ++ "Take one down, pass it around\r\n" + ++ bottles xs diff --git a/Task/Execute-HQ9+/Ela/execute-hq9+-3.ela b/Task/Execute-HQ9+/Ela/execute-hq9+-3.ela new file mode 100644 index 0000000000..d7234cffdb --- /dev/null +++ b/Task/Execute-HQ9+/Ela/execute-hq9+-3.ela @@ -0,0 +1,2 @@ +open console imperative +each writen <| eval "HQ9+" diff --git a/Task/Execute-HQ9+/Erlang/execute-hq9+.erl b/Task/Execute-HQ9+/Erlang/execute-hq9+.erl new file mode 100644 index 0000000000..4a27ef3e4a --- /dev/null +++ b/Task/Execute-HQ9+/Erlang/execute-hq9+.erl @@ -0,0 +1,56 @@ +% hq9+ Erlang implementation (JWL) +% http://www.erlang.org/ +-module(hq9p). +-export([main/1]). + +%% bottle helper routine +bottle(0) -> + io:format("No more bottles of beer "); + +bottle(1) -> + io:format("1 bottle of beer "); + +bottle(N) when N > 0 -> + io:format("~w bottles of beer ", [N]). + +%% Implementation of instructions +beer(0) -> + bottle(0), io:format("on the wall~n"), + bottle(0), io:format("on the wall~nGo to the store and buy some more~n"), + io:format("99 bottles of beer on the wall.~n"); + +beer(N) -> + bottle(N), io:format("on the wall~n"), + bottle(N), io:format("~nTake one down and pass it around~n"), + bottle(N-1), io:format("on the wall~n~n"), + beer(N-1). + +hello() -> + io:format("Hello world!~n", []). + +prog(Prog) -> + io:format("~s~n", [Prog]). + +inc(Acc) -> + Acc+1. + +%% Interpreter +execute(Instruction, Prog, Acc) -> + case Instruction of + $H -> hello(), Acc; + $Q -> prog(Prog), Acc; + $9 -> beer(99), Acc; + $+ -> inc(Acc); + _ -> io:format("Invalid instruction: ~c~n", [Instruction]), Acc + end. + +main([], _Prog, Acc) -> + Acc; + +main([Instruction | Rest], Prog, Acc) -> + NewAcc = execute(Instruction, Prog, Acc), + main(Rest, Prog, NewAcc). + +main(Prog) -> + Compiled = string:to_upper(Prog), + main(Compiled, Prog, 0). diff --git a/Task/Execute-HQ9+/Forth/execute-hq9+.fth b/Task/Execute-HQ9+/Forth/execute-hq9+.fth new file mode 100644 index 0000000000..d48dd69b68 --- /dev/null +++ b/Task/Execute-HQ9+/Forth/execute-hq9+.fth @@ -0,0 +1,11 @@ +variable accumulator +: H cr ." Hello, world!" ; +: Q cr 2dup type ; +: 9 99 verses ; \ http://rosettacode.org/wiki/99_Bottles_of_Beer#Forth +: + 1 accumulator +! ; + +: hq9+ ( "code" -- ) + parse-word 2dup bounds ?do + i 1 [ get-current literal ] search-wordlist + if execute else true abort" invalid HQ9+ instruction" + then loop 2drop ; diff --git a/Task/Execute-HQ9+/JavaScript/execute-hq9+.js b/Task/Execute-HQ9+/JavaScript/execute-hq9+.js new file mode 100644 index 0000000000..8b1c426e85 --- /dev/null +++ b/Task/Execute-HQ9+/JavaScript/execute-hq9+.js @@ -0,0 +1,23 @@ +function hq9plus(code) { + var out = ''; + var acc = 0; + + for (var i=0; i1; j--) { + out += j + " bottles of beer on the wall, " + j + " bottles of beer.\n"; + out += "Take one down and pass it around, " + (j-1) + " bottles of beer.\n\n"; + } + out += "1 bottle of beer on the wall, 1 bottle of beer.\n" + + "Take one down and pass it around, no more bottles of beer on the wall.\n\n" + + "No more bottles of beer on the wall, no more bottles of beer.\n" + + "Go to the store and buy some more, 99 bottles of beer on the wall.\n"; + break; + case '+': acc++; break; + } + } + return out; +} diff --git a/Task/Execute-HQ9+/PicoLisp/execute-hq9+.l b/Task/Execute-HQ9+/PicoLisp/execute-hq9+.l new file mode 100644 index 0000000000..81f1e5fcfe --- /dev/null +++ b/Task/Execute-HQ9+/PicoLisp/execute-hq9+.l @@ -0,0 +1,15 @@ +(de hq9+ (Code) + (let Accu 0 + (for C (chop Code) + (case C + ("H" (prinl "Hello, world")) + ("Q" (prinl Code)) + ("9" + (for (N 99 (gt0 N)) + (prinl N " bottles of beer on the wall") + (prinl N " bottles of beer") + (prinl "Take one down, pass it around") + (prinl (dec 'N) " bottles of beer on the wall") + (prinl) ) ) + ("+" (inc 'Accu)) ) ) + Accu ) ) diff --git a/Task/Execute-HQ9+/REXX/execute-hq9+.rexx b/Task/Execute-HQ9+/REXX/execute-hq9+.rexx new file mode 100644 index 0000000000..0b02b65ba3 --- /dev/null +++ b/Task/Execute-HQ9+/REXX/execute-hq9+.rexx @@ -0,0 +1,29 @@ +/*REXX program to implement the HQ9+ language.*/ parse arg pgm . +accumulator=0 + do instructions=1 for length(pgm); ?=substr(pgm,instructions,1) + select + when ?=='H' then say "hello, world" /*this salutation varies. */ + when ?=='Q' then do j=1 for sourceline(); say sourceline(j); end + when ?== 9 then call 99 + when ?=='+' then accumulator=accumulator+1 + otherwise say 'invalid HQ9+ instruction:' ? + end /*select*/ + end /*instructions*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────99 subroutine───────────────────────*/ +99: do j=99 by -1 to 1 + say j 'bottle's(j) "of beer the wall," + say j 'bottle's(j) "of beer." + say 'Take one down, pass it around,' + n=j-1 + if n==0 then n='no' /*cheating to use 0. */ + say n 'bottle's(j-1) "of beer the wall." + say + end +say 'No more bottles of beer on the wall,' /*finally, last verse.*/ +say 'no more bottles of beer.' +say 'Go to the store and buy some more,' +say '99 bottles of beer on the wall.' +return +/*──────────────────────────────────S subroutine────────────────────────*/ +s: if arg(1)==1 then return ''; return "s" /*a simple pluralizer.*/ diff --git a/Task/Execute-HQ9+/Scala/execute-hq9+.scala b/Task/Execute-HQ9+/Scala/execute-hq9+.scala new file mode 100644 index 0000000000..dd28b24d82 --- /dev/null +++ b/Task/Execute-HQ9+/Scala/execute-hq9+.scala @@ -0,0 +1,34 @@ +def hq9plus(code: String) : String = { + var out = "" + var acc = 0 + + def bottle(num: Int) : Unit = { + if (num > 1) { + out += num + " bottles of beer on the wall, " + num + " bottles of beer.\n" + out += "Take one down and pass it around, " + (num - 1) + " bottle" + + if (num > 2) out += "s" + + out += " of beer.\n\n" + bottle(num - 1) + } + else { + out += "1 bottle of beer on the wall, 1 bottle of beer.\n" + + "Take one down and pass it around, no more bottles of beer on the wall.\n\n" + + "No more bottles of beer on the wall, no more bottles of beer.\n" + + "Go to the store and buy some more, 99 bottles of beer on the wall.\n" + } + } + + def handle(char: Char) = char match { + case 'H' => out += "Hello world!\n" + case 'Q' => out += code + "\n" + case '+' => acc += 1 + case '9' => bottle(99) + } + + code.toList foreach handle + out +} + +println(hq9plus("HQ9+")) diff --git a/Task/Execute-a-system-command/0DESCRIPTION b/Task/Execute-a-system-command/0DESCRIPTION new file mode 100644 index 0000000000..151abce152 --- /dev/null +++ b/Task/Execute-a-system-command/0DESCRIPTION @@ -0,0 +1 @@ +In this task, the goal is to run either the ls (dir on Windows) system command, or the pause system command. diff --git a/Task/Execute-a-system-command/1META.yaml b/Task/Execute-a-system-command/1META.yaml new file mode 100644 index 0000000000..f6d82c59ad --- /dev/null +++ b/Task/Execute-a-system-command/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming environment operations diff --git a/Task/Execute-a-system-command/ALGOL-68/execute-a-system-command-1.alg b/Task/Execute-a-system-command/ALGOL-68/execute-a-system-command-1.alg new file mode 100644 index 0000000000..bf8b55bee0 --- /dev/null +++ b/Task/Execute-a-system-command/ALGOL-68/execute-a-system-command-1.alg @@ -0,0 +1 @@ +system("ls") diff --git a/Task/Execute-a-system-command/ALGOL-68/execute-a-system-command-2.alg b/Task/Execute-a-system-command/ALGOL-68/execute-a-system-command-2.alg new file mode 100644 index 0000000000..d0a8899bfc --- /dev/null +++ b/Task/Execute-a-system-command/ALGOL-68/execute-a-system-command-2.alg @@ -0,0 +1,5 @@ +OP ! = (STRING cmd)BOOL: system(cmd) = 0; + +IF ! "touch test.tmp" ANDF ( ! "ls test.tmp" ANDF ! "rm test.tmp" ) THEN + print (("test.tmp now gone!", new line)) +FI diff --git a/Task/Execute-a-system-command/AWK/execute-a-system-command.awk b/Task/Execute-a-system-command/AWK/execute-a-system-command.awk new file mode 100644 index 0000000000..87c981a1ed --- /dev/null +++ b/Task/Execute-a-system-command/AWK/execute-a-system-command.awk @@ -0,0 +1,3 @@ +BEGIN { + system("ls") +} diff --git a/Task/Execute-a-system-command/Ada/execute-a-system-command-1.ada b/Task/Execute-a-system-command/Ada/execute-a-system-command-1.ada new file mode 100644 index 0000000000..f54923c6b4 --- /dev/null +++ b/Task/Execute-a-system-command/Ada/execute-a-system-command-1.ada @@ -0,0 +1,8 @@ +with POSIX.Unsafe_Process_Primitives; + +procedure Execute_A_System_Command is + Arguments : POSIX.POSIX_String_List; +begin + POSIX.Append (Arguments, "ls"); + POSIX.Unsafe_Process_Primitives.Exec_Search ("ls", Arguments); +end Execute_A_System_Command; diff --git a/Task/Execute-a-system-command/Ada/execute-a-system-command-2.ada b/Task/Execute-a-system-command/Ada/execute-a-system-command-2.ada new file mode 100644 index 0000000000..7ab1331c29 --- /dev/null +++ b/Task/Execute-a-system-command/Ada/execute-a-system-command-2.ada @@ -0,0 +1,9 @@ +with Interfaces.C; use Interfaces.C; + +procedure Execute_System is + function Sys (Arg : Char_Array) return Integer; + pragma Import(C, Sys, "system"); + Ret_Val : Integer; +begin + Ret_Val := Sys(To_C("ls")); +end Execute_System; diff --git a/Task/Execute-a-system-command/Ada/execute-a-system-command-3.ada b/Task/Execute-a-system-command/Ada/execute-a-system-command-3.ada new file mode 100644 index 0000000000..cc9b0464a8 --- /dev/null +++ b/Task/Execute-a-system-command/Ada/execute-a-system-command-3.ada @@ -0,0 +1,20 @@ +with Ada.Text_IO; use Ada.Text_IO; +with System.OS_Lib; use System.OS_Lib; + +procedure Execute_Synchronously is + Result : Integer; + Arguments : Argument_List := + ( 1=> new String'("cmd.exe"), + 2=> new String'("/C dir c:\temp\*.adb") + ); +begin + Spawn + ( Program_Name => "cmd.exe", + Args => Arguments, + Output_File_Descriptor => Standout, + Return_Code => Result + ); + for Index in Arguments'Range loop + Free (Arguments (Index)); -- Free the argument list + end loop; +end Execute_Synchronously; diff --git a/Task/Execute-a-system-command/Aikido/execute-a-system-command-1.aikido b/Task/Execute-a-system-command/Aikido/execute-a-system-command-1.aikido new file mode 100644 index 0000000000..0a450300ac --- /dev/null +++ b/Task/Execute-a-system-command/Aikido/execute-a-system-command-1.aikido @@ -0,0 +1,4 @@ +var lines = system ("ls") +foreach line lines { + println (line) +} diff --git a/Task/Execute-a-system-command/Aikido/execute-a-system-command-2.aikido b/Task/Execute-a-system-command/Aikido/execute-a-system-command-2.aikido new file mode 100644 index 0000000000..0be1b3553c --- /dev/null +++ b/Task/Execute-a-system-command/Aikido/execute-a-system-command-2.aikido @@ -0,0 +1 @@ +exec ("ls") diff --git a/Task/Execute-a-system-command/Aikido/execute-a-system-command-3.aikido b/Task/Execute-a-system-command/Aikido/execute-a-system-command-3.aikido new file mode 100644 index 0000000000..757cecb3a4 --- /dev/null +++ b/Task/Execute-a-system-command/Aikido/execute-a-system-command-3.aikido @@ -0,0 +1,8 @@ +var pid = fork() +if (pid == 0) { + var args = ["/bin/ls"] + execv ("/bin/ls", args) + exit(1) +} +var status = 0 +waitpid (pid, status) diff --git a/Task/Execute-a-system-command/Aime/execute-a-system-command.aime b/Task/Execute-a-system-command/Aime/execute-a-system-command.aime new file mode 100644 index 0000000000..72ef92dbdc --- /dev/null +++ b/Task/Execute-a-system-command/Aime/execute-a-system-command.aime @@ -0,0 +1,7 @@ +sshell ss; + +b_cast(ss_path(ss), "/bin/ls"); + +lf_p_text(ss_argv(ss), "ls"); + +o_text(ss_link(ss)); diff --git a/Task/Execute-a-system-command/AppleScript/execute-a-system-command.applescript b/Task/Execute-a-system-command/AppleScript/execute-a-system-command.applescript new file mode 100644 index 0000000000..9b22977ed2 --- /dev/null +++ b/Task/Execute-a-system-command/AppleScript/execute-a-system-command.applescript @@ -0,0 +1 @@ +do shell script "ls" without altering line endings diff --git a/Task/Execute-a-system-command/AutoHotkey/execute-a-system-command.ahk b/Task/Execute-a-system-command/AutoHotkey/execute-a-system-command.ahk new file mode 100644 index 0000000000..c3eb83b695 --- /dev/null +++ b/Task/Execute-a-system-command/AutoHotkey/execute-a-system-command.ahk @@ -0,0 +1 @@ +Run, %comspec% /k dir & pause diff --git a/Task/Execute-a-system-command/BASIC/execute-a-system-command.bas b/Task/Execute-a-system-command/BASIC/execute-a-system-command.bas new file mode 100644 index 0000000000..d46b0fe50a --- /dev/null +++ b/Task/Execute-a-system-command/BASIC/execute-a-system-command.bas @@ -0,0 +1 @@ +SHELL "dir" diff --git a/Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-1.bbc b/Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-1.bbc new file mode 100644 index 0000000000..bf75ead32b --- /dev/null +++ b/Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-1.bbc @@ -0,0 +1 @@ +OSCLI "CAT" diff --git a/Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-2.bbc b/Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-2.bbc new file mode 100644 index 0000000000..242c726ddc --- /dev/null +++ b/Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-2.bbc @@ -0,0 +1 @@ +OSCLI "*dir":REM *dir to bypass BB4W's built-in dir command diff --git a/Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-3.bbc b/Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-3.bbc new file mode 100644 index 0000000000..aa864f1b7c --- /dev/null +++ b/Task/Execute-a-system-command/BBC-BASIC/execute-a-system-command-3.bbc @@ -0,0 +1 @@ +OSCLI "ls" diff --git a/Task/Execute-a-system-command/Bracmat/execute-a-system-command.bracmat b/Task/Execute-a-system-command/Bracmat/execute-a-system-command.bracmat new file mode 100644 index 0000000000..3d74e0bcdf --- /dev/null +++ b/Task/Execute-a-system-command/Bracmat/execute-a-system-command.bracmat @@ -0,0 +1 @@ +sys$dir diff --git a/Task/Execute-a-system-command/Brat/execute-a-system-command.brat b/Task/Execute-a-system-command/Brat/execute-a-system-command.brat new file mode 100644 index 0000000000..bfbbe7d4f7 --- /dev/null +++ b/Task/Execute-a-system-command/Brat/execute-a-system-command.brat @@ -0,0 +1,3 @@ +include :subprocess + +p subprocess.run :ls #Lists files in directory diff --git a/Task/Execute-a-system-command/Brlcad/execute-a-system-command.brlcad b/Task/Execute-a-system-command/Brlcad/execute-a-system-command.brlcad new file mode 100644 index 0000000000..1602fb9f80 --- /dev/null +++ b/Task/Execute-a-system-command/Brlcad/execute-a-system-command.brlcad @@ -0,0 +1 @@ +exec ls diff --git a/Task/Execute-a-system-command/C++/execute-a-system-command.cpp b/Task/Execute-a-system-command/C++/execute-a-system-command.cpp new file mode 100644 index 0000000000..d9b4b5ad63 --- /dev/null +++ b/Task/Execute-a-system-command/C++/execute-a-system-command.cpp @@ -0,0 +1 @@ +system("pause"); diff --git a/Task/Execute-a-system-command/C/execute-a-system-command.c b/Task/Execute-a-system-command/C/execute-a-system-command.c new file mode 100644 index 0000000000..cf8e4f87ba --- /dev/null +++ b/Task/Execute-a-system-command/C/execute-a-system-command.c @@ -0,0 +1,7 @@ +#include + +int main() +{ + system("ls"); + return 0; +} diff --git a/Task/Execute-a-system-command/CMake/execute-a-system-command-1.cmake b/Task/Execute-a-system-command/CMake/execute-a-system-command-1.cmake new file mode 100644 index 0000000000..98b3a9953b --- /dev/null +++ b/Task/Execute-a-system-command/CMake/execute-a-system-command-1.cmake @@ -0,0 +1 @@ +execute_process(COMMAND ls) diff --git a/Task/Execute-a-system-command/CMake/execute-a-system-command-2.cmake b/Task/Execute-a-system-command/CMake/execute-a-system-command-2.cmake new file mode 100644 index 0000000000..c7d71f84df --- /dev/null +++ b/Task/Execute-a-system-command/CMake/execute-a-system-command-2.cmake @@ -0,0 +1,7 @@ +# Calculate pi to 40 digits after the decimal point. +execute_process( + COMMAND printf "scale = 45; 4 * a(1) + 5 / 10 ^ 41\\n" + COMMAND bc -l + COMMAND sed -e "s/.\\{5\\}$//" + OUTPUT_VARIABLE pi OUTPUT_STRIP_TRAILING_WHITESPACE) +message(STATUS "pi is ${pi}") diff --git a/Task/Execute-a-system-command/Clojure/execute-a-system-command-1.clj b/Task/Execute-a-system-command/Clojure/execute-a-system-command-1.clj new file mode 100644 index 0000000000..fb9a66f325 --- /dev/null +++ b/Task/Execute-a-system-command/Clojure/execute-a-system-command-1.clj @@ -0,0 +1 @@ +(.. Runtime getRuntime (exec "cmd /C dir")) diff --git a/Task/Execute-a-system-command/Clojure/execute-a-system-command-2.clj b/Task/Execute-a-system-command/Clojure/execute-a-system-command-2.clj new file mode 100644 index 0000000000..ac2242cad4 --- /dev/null +++ b/Task/Execute-a-system-command/Clojure/execute-a-system-command-2.clj @@ -0,0 +1,18 @@ +user=> (use '[clojure.java.shell :only [sh]]) + +user=> (sh "ls" "-aul") + +{:exit 0, + :out total 64 +drwxr-xr-x 11 zkim staff 374 Jul 5 13:21 . +drwxr-xr-x 25 zkim staff 850 Jul 5 13:02 .. +drwxr-xr-x 12 zkim staff 408 Jul 5 13:02 .git +-rw-r--r-- 1 zkim staff 13 Jul 5 13:02 .gitignore +-rw-r--r-- 1 zkim staff 12638 Jul 5 13:02 LICENSE.html +-rw-r--r-- 1 zkim staff 4092 Jul 5 13:02 README.md +drwxr-xr-x 2 zkim staff 68 Jul 5 13:15 classes +drwxr-xr-x 5 zkim staff 170 Jul 5 13:15 lib +-rw-r--r--@ 1 zkim staff 3396 Jul 5 13:03 pom.xml +-rw-r--r--@ 1 zkim staff 367 Jul 5 13:15 project.clj +drwxr-xr-x 4 zkim staff 136 Jul 5 13:15 src +, :err } diff --git a/Task/Execute-a-system-command/Clojure/execute-a-system-command-3.clj b/Task/Execute-a-system-command/Clojure/execute-a-system-command-3.clj new file mode 100644 index 0000000000..50b6c1d594 --- /dev/null +++ b/Task/Execute-a-system-command/Clojure/execute-a-system-command-3.clj @@ -0,0 +1,14 @@ +user=> (use '[clojure.java.shell :only [sh]]) + +user=> (println (:out (sh "cowsay" "Printing a command-line output"))) + + _________________________________ +< Printing a command-line output. > + --------------------------------- + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || + +nil diff --git a/Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-1.lisp b/Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-1.lisp new file mode 100644 index 0000000000..53ae035d6e --- /dev/null +++ b/Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-1.lisp @@ -0,0 +1 @@ +(with-output-to-string (stream) (extensions:run-program "ls" nil :output stream)) diff --git a/Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-2.lisp b/Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-2.lisp new file mode 100644 index 0000000000..4061d39a24 --- /dev/null +++ b/Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-2.lisp @@ -0,0 +1 @@ +(system:call-system "ls") diff --git a/Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-3.lisp b/Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-3.lisp new file mode 100644 index 0000000000..d46272a663 --- /dev/null +++ b/Task/Execute-a-system-command/Common-Lisp/execute-a-system-command-3.lisp @@ -0,0 +1 @@ +(trivial-shell:shell-command "ls") diff --git a/Task/Execute-a-system-command/D/execute-a-system-command.d b/Task/Execute-a-system-command/D/execute-a-system-command.d new file mode 100644 index 0000000000..9857e12305 --- /dev/null +++ b/Task/Execute-a-system-command/D/execute-a-system-command.d @@ -0,0 +1 @@ +std.process.system("ls"); diff --git a/Task/Execute-a-system-command/DCL/execute-a-system-command-1.dcl b/Task/Execute-a-system-command/DCL/execute-a-system-command-1.dcl new file mode 100644 index 0000000000..eab13fc205 --- /dev/null +++ b/Task/Execute-a-system-command/DCL/execute-a-system-command-1.dcl @@ -0,0 +1 @@ +Directory diff --git a/Task/Execute-a-system-command/DCL/execute-a-system-command-2.dcl b/Task/Execute-a-system-command/DCL/execute-a-system-command-2.dcl new file mode 100644 index 0000000000..0d2ecd7fd0 --- /dev/null +++ b/Task/Execute-a-system-command/DCL/execute-a-system-command-2.dcl @@ -0,0 +1 @@ +dir diff --git a/Task/Execute-a-system-command/Delphi/execute-a-system-command.delphi b/Task/Execute-a-system-command/Delphi/execute-a-system-command.delphi new file mode 100644 index 0000000000..4a918ac3ec --- /dev/null +++ b/Task/Execute-a-system-command/Delphi/execute-a-system-command.delphi @@ -0,0 +1,9 @@ +program ExecuteSystemCommand; + +{$APPTYPE CONSOLE} + +uses Windows, ShellApi; + +begin + ShellExecute(0, nil, 'cmd.exe', ' /c dir', nil, SW_HIDE); +end. diff --git a/Task/Execute-a-system-command/E/execute-a-system-command.e b/Task/Execute-a-system-command/E/execute-a-system-command.e new file mode 100644 index 0000000000..f017b708f9 --- /dev/null +++ b/Task/Execute-a-system-command/E/execute-a-system-command.e @@ -0,0 +1,10 @@ +def ls := makeCommand("ls") +ls("-l") + +def [results, _, _] := ls.exec(["-l"]) +when (results) -> { + def [exitCode, out, err] := results + print(out) +} catch problem { + print(`failed to execute ls: $problem`) +} diff --git a/Task/Execute-a-system-command/Erlang/execute-a-system-command.erl b/Task/Execute-a-system-command/Erlang/execute-a-system-command.erl new file mode 100644 index 0000000000..191d34e284 --- /dev/null +++ b/Task/Execute-a-system-command/Erlang/execute-a-system-command.erl @@ -0,0 +1 @@ +os:cmd("ls"). diff --git a/Task/Execute-a-system-command/Forth/execute-a-system-command.fth b/Task/Execute-a-system-command/Forth/execute-a-system-command.fth new file mode 100644 index 0000000000..0894ad19af --- /dev/null +++ b/Task/Execute-a-system-command/Forth/execute-a-system-command.fth @@ -0,0 +1 @@ +s" ls" system diff --git a/Task/Execute-a-system-command/Fortran/execute-a-system-command.f b/Task/Execute-a-system-command/Fortran/execute-a-system-command.f new file mode 100644 index 0000000000..5ed7a4fbd5 --- /dev/null +++ b/Task/Execute-a-system-command/Fortran/execute-a-system-command.f @@ -0,0 +1,3 @@ +program SystemTest + call system("ls") +end program SystemTest diff --git a/Task/Execute-a-system-command/Go/execute-a-system-command.go b/Task/Execute-a-system-command/Go/execute-a-system-command.go new file mode 100644 index 0000000000..c6fee0de78 --- /dev/null +++ b/Task/Execute-a-system-command/Go/execute-a-system-command.go @@ -0,0 +1,13 @@ +package main +import "fmt" +import "os/exec" + +func main() { + cmd := exec.Command("ls", "-l") + output, err := cmd.Output() + if (err != nil) { + fmt.Println(err) + return + } + fmt.Print(string(output)) +} diff --git a/Task/Execute-a-system-command/Haskell/execute-a-system-command.hs b/Task/Execute-a-system-command/Haskell/execute-a-system-command.hs new file mode 100644 index 0000000000..1019474d23 --- /dev/null +++ b/Task/Execute-a-system-command/Haskell/execute-a-system-command.hs @@ -0,0 +1,3 @@ +import System.Cmd + +main = system "ls" diff --git a/Task/Execute-a-system-command/Java/execute-a-system-command-1.java b/Task/Execute-a-system-command/Java/execute-a-system-command-1.java new file mode 100644 index 0000000000..4177b9f736 --- /dev/null +++ b/Task/Execute-a-system-command/Java/execute-a-system-command-1.java @@ -0,0 +1,15 @@ +import java.util.Scanner; +import java.io.*; + +public class Program { + public static void main(String[] args) { + try { + Process p = Runtime.getRuntime().exec("cmd /C dir");//Windows command, use "ls -oa" for UNIX + Scanner sc = new Scanner(p.getInputStream()); + while (sc.hasNext()) System.out.println(sc.nextLine()); + } + catch (IOException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/Task/Execute-a-system-command/Java/execute-a-system-command-2.java b/Task/Execute-a-system-command/Java/execute-a-system-command-2.java new file mode 100644 index 0000000000..0b5f1edc1d --- /dev/null +++ b/Task/Execute-a-system-command/Java/execute-a-system-command-2.java @@ -0,0 +1,39 @@ +import java.io.IOException; +import java.io.InputStream; + +public class MainEntry { + public static void main(String[] args) { + executeCmd("ls -oa"); + } + + private static void executeCmd(String string) { + InputStream pipedOut = null; + try { + Process aProcess = Runtime.getRuntime().exec(string); + aProcess.waitFor(); + + pipedOut = aProcess.getInputStream(); + byte buffer[] = new byte[2048]; + int read = pipedOut.read(buffer); + // Replace following code with your intends processing tools + while(read >= 0) { + System.out.write(buffer, 0, read); + + read = pipedOut.read(buffer); + } + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } finally { + if(pipedOut != null) { + try { + pipedOut.close(); + } catch (IOException e) { + } + } + } + } + + +} diff --git a/Task/Execute-a-system-command/Java/execute-a-system-command-3.java b/Task/Execute-a-system-command/Java/execute-a-system-command-3.java new file mode 100644 index 0000000000..3d235e88c8 --- /dev/null +++ b/Task/Execute-a-system-command/Java/execute-a-system-command-3.java @@ -0,0 +1,64 @@ +import java.io.IOException; +import java.io.InputStream; + +public class MainEntry { + public static void main(String[] args) { + // the command to execute + executeCmd("ls -oa"); + } + + private static void executeCmd(String string) { + InputStream pipedOut = null; + try { + Process aProcess = Runtime.getRuntime().exec(string); + + // These two thread shall stop by themself when the process end + Thread pipeThread = new Thread(new StreamGobber(aProcess.getInputStream())); + Thread errorThread = new Thread(new StreamGobber(aProcess.getErrorStream())); + + pipeThread.start(); + errorThread.start(); + + aProcess.waitFor(); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } +} + +//Replace the following thread with your intends reader +class StreamGobber implements Runnable { + + private InputStream Pipe; + + public StreamGobber(InputStream pipe) { + if(pipe == null) { + throw new NullPointerException("bad pipe"); + } + Pipe = pipe; + } + + public void run() { + try { + byte buffer[] = new byte[2048]; + + int read = Pipe.read(buffer); + while(read >= 0) { + System.out.write(buffer, 0, read); + + read = Pipe.read(buffer); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if(Pipe != null) { + try { + Pipe.close(); + } catch (IOException e) { + } + } + } + } +} diff --git a/Task/Execute-a-system-command/JavaScript/execute-a-system-command-1.js b/Task/Execute-a-system-command/JavaScript/execute-a-system-command-1.js new file mode 100644 index 0000000000..f6d51a5745 --- /dev/null +++ b/Task/Execute-a-system-command/JavaScript/execute-a-system-command-1.js @@ -0,0 +1,2 @@ +var shell = new ActiveXObject("WScript.Shell"); +shell.run("cmd /c dir & pause"); diff --git a/Task/Execute-a-system-command/JavaScript/execute-a-system-command-2.js b/Task/Execute-a-system-command/JavaScript/execute-a-system-command-2.js new file mode 100644 index 0000000000..edcbb387c3 --- /dev/null +++ b/Task/Execute-a-system-command/JavaScript/execute-a-system-command-2.js @@ -0,0 +1,10 @@ +runCommand("cmd", "/c", "dir", "d:\\"); +print("==="); +var options = { + // can specify arguments here in the options object + args: ["/c", "dir", "d:\\"], + // capture stdout to the options.output property + output: '' +}; +runCommand("cmd", options); +print(options.output); diff --git a/Task/Execute-a-system-command/Lua/execute-a-system-command.lua b/Task/Execute-a-system-command/Lua/execute-a-system-command.lua new file mode 100644 index 0000000000..efba8cc29b --- /dev/null +++ b/Task/Execute-a-system-command/Lua/execute-a-system-command.lua @@ -0,0 +1,6 @@ +-- just executing the command +os.execute("ls") + +-- to execute and capture the output, use io.popen +local f = io.popen("ls") -- store the output in a "file" +print( f:read("*a") ) -- print out the "file"'s content diff --git a/Task/Execute-a-system-command/MATLAB/execute-a-system-command.m b/Task/Execute-a-system-command/MATLAB/execute-a-system-command.m new file mode 100644 index 0000000000..bf0a3178f3 --- /dev/null +++ b/Task/Execute-a-system-command/MATLAB/execute-a-system-command.m @@ -0,0 +1,8 @@ +>> system('PAUSE') + +Press any key to continue . . . + + +ans = + + 0 diff --git a/Task/Execute-a-system-command/PHP/execute-a-system-command-1.php b/Task/Execute-a-system-command/PHP/execute-a-system-command-1.php new file mode 100644 index 0000000000..6613cf2ee0 --- /dev/null +++ b/Task/Execute-a-system-command/PHP/execute-a-system-command-1.php @@ -0,0 +1,2 @@ +@exec($command,$output); +echo nl2br($output); diff --git a/Task/Execute-a-system-command/PHP/execute-a-system-command-2.php b/Task/Execute-a-system-command/PHP/execute-a-system-command-2.php new file mode 100644 index 0000000000..d7fc9b6157 --- /dev/null +++ b/Task/Execute-a-system-command/PHP/execute-a-system-command-2.php @@ -0,0 +1,11 @@ +$results = `ls`; +# runs command and returns its STDOUT as a string + +system("ls"); +# runs command and returns its exit status; its STDOUT gets output to our STDOUT + +echo `ls`; +# the same, but with back quotes + +passthru("ls"); +# like system() but binary-safe diff --git a/Task/Execute-a-system-command/Perl/execute-a-system-command.pl b/Task/Execute-a-system-command/Perl/execute-a-system-command.pl new file mode 100644 index 0000000000..0e83cb766d --- /dev/null +++ b/Task/Execute-a-system-command/Perl/execute-a-system-command.pl @@ -0,0 +1,13 @@ +my @results = qx(ls); +# runs command and returns its STDOUT as a string +my @results = `ls`; +# ditto, alternative syntax + +system "ls"; +# runs command and returns its exit status; its STDOUT gets output to our STDOUT + +print `ls`; +#The same, but with back quotes + +exec "ls"; +# replace current process with another diff --git a/Task/Execute-a-system-command/PicoLisp/execute-a-system-command.l b/Task/Execute-a-system-command/PicoLisp/execute-a-system-command.l new file mode 100644 index 0000000000..4d929754a5 --- /dev/null +++ b/Task/Execute-a-system-command/PicoLisp/execute-a-system-command.l @@ -0,0 +1 @@ +(call "ls") diff --git a/Task/Execute-a-system-command/Prolog/execute-a-system-command.pro b/Task/Execute-a-system-command/Prolog/execute-a-system-command.pro new file mode 100644 index 0000000000..6be3bacd65 --- /dev/null +++ b/Task/Execute-a-system-command/Prolog/execute-a-system-command.pro @@ -0,0 +1 @@ +shell('ls'). diff --git a/Task/Execute-a-system-command/Python/execute-a-system-command-1.py b/Task/Execute-a-system-command/Python/execute-a-system-command-1.py new file mode 100644 index 0000000000..1ea5e1b4e2 --- /dev/null +++ b/Task/Execute-a-system-command/Python/execute-a-system-command-1.py @@ -0,0 +1,3 @@ +import os +exit_code = os.system('ls') # Just execute the command, return a success/fail code +output = os.popen('ls').read() # If you want to get the output data. Deprecated. diff --git a/Task/Execute-a-system-command/Python/execute-a-system-command-2.py b/Task/Execute-a-system-command/Python/execute-a-system-command-2.py new file mode 100644 index 0000000000..5dd7c5f85d --- /dev/null +++ b/Task/Execute-a-system-command/Python/execute-a-system-command-2.py @@ -0,0 +1,5 @@ +import subprocess +# if the exit code was non-zero these commands raise a CalledProcessError +exit_code = subprocess.check_call(['ls', '-l']) # Python 2.5+ +assert exit_code == 0 +output = subprocess.check_output(['ls', '-l']) # Python 2.7+ diff --git a/Task/Execute-a-system-command/Python/execute-a-system-command-3.py b/Task/Execute-a-system-command/Python/execute-a-system-command-3.py new file mode 100644 index 0000000000..1ced2709f9 --- /dev/null +++ b/Task/Execute-a-system-command/Python/execute-a-system-command-3.py @@ -0,0 +1,3 @@ +from subprocess import PIPE, Popen, STDOUT +p = Popen('ls', stdout=PIPE, stderr=STDOUT) +print p.communicate()[0] diff --git a/Task/Execute-a-system-command/Python/execute-a-system-command-4.py b/Task/Execute-a-system-command/Python/execute-a-system-command-4.py new file mode 100644 index 0000000000..0d138a4b12 --- /dev/null +++ b/Task/Execute-a-system-command/Python/execute-a-system-command-4.py @@ -0,0 +1,4 @@ +import commands +stat, out = commands.getstatusoutput('ls') +if not stat: + print out diff --git a/Task/Execute-a-system-command/R/execute-a-system-command.r b/Task/Execute-a-system-command/R/execute-a-system-command.r new file mode 100644 index 0000000000..23c124353e --- /dev/null +++ b/Task/Execute-a-system-command/R/execute-a-system-command.r @@ -0,0 +1,2 @@ +system("ls") +output=system("ls",intern=TRUE) diff --git a/Task/Execute-a-system-command/REXX/execute-a-system-command.rexx b/Task/Execute-a-system-command/REXX/execute-a-system-command.rexx new file mode 100644 index 0000000000..5f6929877a --- /dev/null +++ b/Task/Execute-a-system-command/REXX/execute-a-system-command.rexx @@ -0,0 +1 @@ +"dir /a:d" diff --git a/Task/Execute-a-system-command/Ruby/execute-a-system-command.rb b/Task/Execute-a-system-command/Ruby/execute-a-system-command.rb new file mode 100644 index 0000000000..c16b923be8 --- /dev/null +++ b/Task/Execute-a-system-command/Ruby/execute-a-system-command.rb @@ -0,0 +1,18 @@ +string = `ls` +# runs command and returns its STDOUT as a string +string = %x{ls} +# ditto, alternative syntax + +system "ls" +# runs command and returns its exit status; its STDOUT gets output to our STDOUT + +print `ls` +#The same, but with back quotes + +exec "ls" +# replace current process with another + +# call system command and read output asynchronously +io = IO.popen('ls') +# ... later +io.each {|line| puts line} diff --git a/Task/Execute-a-system-command/Scala/execute-a-system-command.scala b/Task/Execute-a-system-command/Scala/execute-a-system-command.scala new file mode 100644 index 0000000000..fd41f41cde --- /dev/null +++ b/Task/Execute-a-system-command/Scala/execute-a-system-command.scala @@ -0,0 +1,2 @@ +import scala.sys.process.Process +Process("ls", Seq("-oa"))! diff --git a/Task/Execute-a-system-command/Scheme/execute-a-system-command.ss b/Task/Execute-a-system-command/Scheme/execute-a-system-command.ss new file mode 100644 index 0000000000..ba36561152 --- /dev/null +++ b/Task/Execute-a-system-command/Scheme/execute-a-system-command.ss @@ -0,0 +1 @@ +(system "ls") diff --git a/Task/Execute-a-system-command/Smalltalk/execute-a-system-command.st b/Task/Execute-a-system-command/Smalltalk/execute-a-system-command.st new file mode 100644 index 0000000000..20b9d9f9c9 --- /dev/null +++ b/Task/Execute-a-system-command/Smalltalk/execute-a-system-command.st @@ -0,0 +1 @@ +Smalltalk system: 'ls'. diff --git a/Task/Execute-a-system-command/Tcl/execute-a-system-command-1.tcl b/Task/Execute-a-system-command/Tcl/execute-a-system-command-1.tcl new file mode 100644 index 0000000000..48756b7c55 --- /dev/null +++ b/Task/Execute-a-system-command/Tcl/execute-a-system-command-1.tcl @@ -0,0 +1 @@ +puts [exec ls] diff --git a/Task/Execute-a-system-command/Tcl/execute-a-system-command-2.tcl b/Task/Execute-a-system-command/Tcl/execute-a-system-command-2.tcl new file mode 100644 index 0000000000..3e61dd9a63 --- /dev/null +++ b/Task/Execute-a-system-command/Tcl/execute-a-system-command-2.tcl @@ -0,0 +1 @@ +set io [open "|ls" r] diff --git a/Task/Execute-a-system-command/Tcl/execute-a-system-command-3.tcl b/Task/Execute-a-system-command/Tcl/execute-a-system-command-3.tcl new file mode 100644 index 0000000000..17665bdecb --- /dev/null +++ b/Task/Execute-a-system-command/Tcl/execute-a-system-command-3.tcl @@ -0,0 +1 @@ +set nextline [gets $io] diff --git a/Task/Execute-a-system-command/Tcl/execute-a-system-command-4.tcl b/Task/Execute-a-system-command/Tcl/execute-a-system-command-4.tcl new file mode 100644 index 0000000000..b0d6889ff2 --- /dev/null +++ b/Task/Execute-a-system-command/Tcl/execute-a-system-command-4.tcl @@ -0,0 +1 @@ +set lsoutput [read $io] diff --git a/Task/Exponentiation-operator/0DESCRIPTION b/Task/Exponentiation-operator/0DESCRIPTION new file mode 100644 index 0000000000..ea9672f517 --- /dev/null +++ b/Task/Exponentiation-operator/0DESCRIPTION @@ -0,0 +1,4 @@ +Most all programming languages have a built-in implementation of exponentiation. +Re-implement integer exponentiation for both intint and floatint as both a procedure, and an operator (if your language supports operator definition). + +If the language supports operator (or procedure) overloading, then an overloaded form should be provided for both intint and floatint variants. diff --git a/Task/Exponentiation-operator/1META.yaml b/Task/Exponentiation-operator/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Exponentiation-operator/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Exponentiation-operator/ALGOL-68/exponentiation-operator-1.alg b/Task/Exponentiation-operator/ALGOL-68/exponentiation-operator-1.alg new file mode 100644 index 0000000000..62ae0d3cec --- /dev/null +++ b/Task/Exponentiation-operator/ALGOL-68/exponentiation-operator-1.alg @@ -0,0 +1,61 @@ +main:( + INT two=2, thirty=30; # test constants # + PROC VOID undefined; + +# First implement exponentiation using a rather slow but sure FOR loop # + PROC int pow = (INT base, exponent)INT: ( # PROC cannot be over loaded # + IF exponent<0 THEN undefined FI; + INT out:=( exponent=0 | 1 | base ); + FROM 2 TO exponent DO out*:=base OD; + out + ); + + printf(($" One Gibi-unit is: int pow("g(0)","g(0)")="g(0)" - (cost: "g(0) + " INT multiplications)"l$,two, thirty, int pow(two,thirty),thirty-1)); + +# implement exponentiation using a faster binary technique and WHILE LOOP # + OP ** = (INT base, exponent)INT: ( + BITS binary exponent:=BIN exponent ; # do exponent arithmetic in binary # + INT out := IF bits width ELEM binary exponent THEN base ELSE 1 FI; + INT sq := IF exponent < 0 THEN undefined; ~ ELSE base FI; + + WHILE + binary exponent := binary exponent SHR 1; + binary exponent /= BIN 0 + DO + sq *:= sq; + IF bits width ELEM binary exponent THEN out *:= sq FI + OD; + out + ); + + printf(($" One Gibi-unit is: "g(0)"**"g(0)"="g(0)" - (cost: "g(0) + " INT multiplications)"l$,two, thirty, two ** thirty,8)); + + OP ** = (REAL in base, INT in exponent)REAL: ( # ** INT Operator can be overloaded # + REAL base := ( in exponent<0 | 1/in base | in base); + INT exponent := ABS in exponent; + BITS binary exponent:=BIN exponent ; # do exponent arithmetic in binary # + REAL out := IF bits width ELEM binary exponent THEN base ELSE 1 FI; + REAL sq := base; + + WHILE + binary exponent := binary exponent SHR 1; + binary exponent /= BIN 0 + DO + sq *:= sq; + IF bits width ELEM binary exponent THEN out *:= sq FI + OD; + out + ); + + printf(($" One Gibi-unit is: "g(0,1)"**"g(0)"="g(0,1)" - (cost: "g(0) + " REAL multiplications)"l$, 2.0, thirty, 2.0 ** thirty,8)); + + OP ** = (REAL base, REAL exponent)REAL: ( # ** REAL Operator can be overloaded # + exp(ln(base)*exponent) + ); + + printf(($" One Gibi-unit is: "g(0,1)"**"g(0,1)"="g(0,1)" - (cost: " + "depends on precision)"l$, 2.0, 30.0, 2.0 ** 30.0)) +) diff --git a/Task/Exponentiation-operator/ALGOL-68/exponentiation-operator-2.alg b/Task/Exponentiation-operator/ALGOL-68/exponentiation-operator-2.alg new file mode 100644 index 0000000000..c4095436d6 --- /dev/null +++ b/Task/Exponentiation-operator/ALGOL-68/exponentiation-operator-2.alg @@ -0,0 +1,50 @@ +main:( + INT two=2, thirty=30; # test constants # + PROC VOID undefined; + +# First implement exponentiation using a rather slow but sure FOR loop # + PROC int pow = (INT base, exponent)INT: ( # PROC cannot be over loaded # + IF exponent<0 THEN undefined FI; + INT out:=( exponent=0 | 1 | base ); + FROM 2 TO exponent DO out*:=base OD; + out + ); + + printf(($" One Gibi-unit is: int pow("g(0)","g(0)")="g(0)" - (cost: "g(0) + " INT multiplications)"l$,two, thirty, int pow(two,thirty),thirty-1)); + +# implement exponentiation using a faster binary technique and WHILE LOOP # + OP ** = (INT base, exponent)INT: + IF base = 0 THEN 0 ELIF base = 1 THEN 1 + ELIF exponent = 0 THEN 1 ELIF exponent = 1 THEN base + ELIF ODD exponent THEN + (base*base) ** (exponent OVER 2) * base + ELSE + (base*base) ** (exponent OVER 2) + FI; + + printf(($" One Gibi-unit is: "g(0)"**"g(0)"="g(0)" - (cost: "g(0) + " INT multiplications)"l$,two, thirty, two ** thirty,8)); + + OP ** = (REAL in base, INT in exponent)REAL: ( # ** INT Operator can be overloaded # + REAL base := ( in exponent<0 | 1/in base | in base); + INT exponent := ABS in exponent; + IF base = 0 THEN 0 ELIF base = 1 THEN 1 + ELIF exponent = 0 THEN 1 ELIF exponent = 1 THEN base + ELIF ODD exponent THEN + (base*base) ** (exponent OVER 2) * base + ELSE + (base*base) ** (exponent OVER 2) + FI + ); + + printf(($" One Gibi-unit is: "g(0,1)"**"g(0)"="g(0,1)" - (cost: "g(0) + " REAL multiplications)"l$, 2.0, thirty, 2.0 ** thirty,8)); + + OP ** = (REAL base, REAL exponent)REAL: ( # ** REAL Operator can be overloaded # + exp(ln(base)*exponent) + ); + + printf(($" One Gibi-unit is: "g(0,1)"**"g(0,1)"="g(0,1)" - (cost: " + "depends on precision)"l$, 2.0, 30.0, 2.0 ** 30.0)) +) diff --git a/Task/Exponentiation-operator/AWK/exponentiation-operator.awk b/Task/Exponentiation-operator/AWK/exponentiation-operator.awk new file mode 100644 index 0000000000..accef0333c --- /dev/null +++ b/Task/Exponentiation-operator/AWK/exponentiation-operator.awk @@ -0,0 +1,7 @@ +$ awk 'function pow(x,n){r=1;for(i=0;i 2.5, Exponent => 3, Result => R); + Put ("2.5 ^ 3 = "); + Put (R, Fore => 2, Aft => 4, Exp => 0); + New_Line; + + Exponentiate (Argument => -12, Exponent => 3, Result => I); + Put ("-12 ^ 3 = "); + Put (I, Width => 7); + New_Line; +end Test_Integer_Exponentiation; diff --git a/Task/Exponentiation-operator/Ada/exponentiation-operator-3.ada b/Task/Exponentiation-operator/Ada/exponentiation-operator-3.ada new file mode 100644 index 0000000000..aff86eb3ea --- /dev/null +++ b/Task/Exponentiation-operator/Ada/exponentiation-operator-3.ada @@ -0,0 +1,49 @@ +package body Integer_Exponentiation is + -- int^int + procedure Exponentiate (Argument : in Integer; + Exponent : in Natural; + Result : out Integer) is + begin + Result := 1; + for Counter in 1 .. Exponent loop + Result := Result * Argument; + end loop; + end Exponentiate; + + function "**" (Left : Integer; + Right : Natural) return Integer is + Result : Integer; + begin + Exponentiate (Argument => Left, + Exponent => Right, + Result => Result); + return Result; + end "**"; + + -- real^int + procedure Exponentiate (Argument : in Float; + Exponent : in Integer; + Result : out Float) is + begin + Result := 1.0; + if Exponent < 0 then + for Counter in Exponent .. -1 loop + Result := Result / Argument; + end loop; + else + for Counter in 1 .. Exponent loop + Result := Result * Argument; + end loop; + end if; + end Exponentiate; + + function "**" (Left : Float; + Right : Integer) return Float is + Result : Float; + begin + Exponentiate (Argument => Left, + Exponent => Right, + Result => Result); + return Result; + end "**"; +end Integer_Exponentiation; diff --git a/Task/Exponentiation-operator/AutoHotkey/exponentiation-operator.ahk b/Task/Exponentiation-operator/AutoHotkey/exponentiation-operator.ahk new file mode 100644 index 0000000000..79f75b835c --- /dev/null +++ b/Task/Exponentiation-operator/AutoHotkey/exponentiation-operator.ahk @@ -0,0 +1,9 @@ +MsgBox % Pow(5,3) +MsgBox % Pow(2.5,4) + +Pow(x, n){ + r:=1 + loop %n% + r *= x + return r +} diff --git a/Task/Exponentiation-operator/BASIC/exponentiation-operator.bas b/Task/Exponentiation-operator/BASIC/exponentiation-operator.bas new file mode 100644 index 0000000000..515986ea2c --- /dev/null +++ b/Task/Exponentiation-operator/BASIC/exponentiation-operator.bas @@ -0,0 +1,39 @@ +DECLARE FUNCTION powL& (x AS INTEGER, y AS INTEGER) +DECLARE FUNCTION powS# (x AS SINGLE, y AS INTEGER) + +DIM x AS INTEGER, y AS INTEGER +DIM a AS SINGLE + +RANDOMIZE TIMER +a = RND * 10 +x = INT(RND * 10) +y = INT(RND * 10) +PRINT x, y, powL&(x, y) +PRINT a, y, powS#(a, y) + +FUNCTION powL& (x AS INTEGER, y AS INTEGER) + DIM n AS INTEGER, m AS LONG + IF x <> 0 THEN + m = 1 + IF SGN(y) > 0 THEN + FOR n = 1 TO y + m = m * x + NEXT + END IF + END IF + powL& = m +END FUNCTION + +FUNCTION powS# (x AS SINGLE, y AS INTEGER) + DIM n AS INTEGER, m AS DOUBLE + IF x <> 0 THEN + m = 1 + IF y <> 0 THEN + FOR n = 1 TO y + m = m * x + NEXT + IF y < 0 THEN m = 1# / m + END IF + END IF + powS# = m +END FUNCTION diff --git a/Task/Exponentiation-operator/BBC-BASIC/exponentiation-operator.bbc b/Task/Exponentiation-operator/BBC-BASIC/exponentiation-operator.bbc new file mode 100644 index 0000000000..11b447cd9e --- /dev/null +++ b/Task/Exponentiation-operator/BBC-BASIC/exponentiation-operator.bbc @@ -0,0 +1,23 @@ + PRINT "11^5 = " ; FNipow(11, 5) + PRINT "PI^3 = " ; FNfpow(PI, 3) + END + + DEF FNipow(A%, B%) + LOCAL I%, P% + P% = 1 + FOR I% = 1 TO 32 + P% *= P% + IF B% < 0 THEN P% *= A% + B% = B% << 1 + NEXT + = P% + + DEF FNfpow(A, B%) + LOCAL I%, P + P = 1 + FOR I% = 1 TO 32 + P *= P + IF B% < 0 THEN P *= A + B% = B% << 1 + NEXT + = P diff --git a/Task/Exponentiation-operator/Brat/exponentiation-operator.brat b/Task/Exponentiation-operator/Brat/exponentiation-operator.brat new file mode 100644 index 0000000000..c6d7120c79 --- /dev/null +++ b/Task/Exponentiation-operator/Brat/exponentiation-operator.brat @@ -0,0 +1,13 @@ +#Procedure +exp = { base, exp | + 1.to(exp).reduce 1, { m, n | m = m * base } +} + +#Numbers are weird +1.parent.^ = { rhs | + num = my + 1.to(rhs).reduce 1 { m, n | m = m * num } +} + +p exp 2 5 #Prints 32 +p 2 ^ 5 #Prints 32 diff --git a/Task/Exponentiation-operator/C++/exponentiation-operator.cpp b/Task/Exponentiation-operator/C++/exponentiation-operator.cpp new file mode 100644 index 0000000000..f2f8390e1b --- /dev/null +++ b/Task/Exponentiation-operator/C++/exponentiation-operator.cpp @@ -0,0 +1,32 @@ +template + Number power(Number base, int exponent) +{ + int zerodir; + Number factor; + if (exponent < 0) + { + zerodir = 1; + factor = Number(1)/base; + } + else + { + zerodir = -1; + factor = base; + } + + Number result(1); + while (exponent != 0) + { + if (exponent % 2 != 0) + { + result *= factor; + exponent += zerodir; + } + else + { + factor *= factor; + exponent /= 2; + } + } + return result; +} diff --git a/Task/Exponentiation-operator/C/exponentiation-operator.c b/Task/Exponentiation-operator/C/exponentiation-operator.c new file mode 100644 index 0000000000..a888838e40 --- /dev/null +++ b/Task/Exponentiation-operator/C/exponentiation-operator.c @@ -0,0 +1,43 @@ +#include +#include + +int ipow(int base, int exp) +{ + int pow = base; + int v = 1; + if (exp < 0) { + assert (base != 0); /* divide by zero */ + return (base*base != 1)? 0: (exp&1)? base : 1; + } + + while(exp > 0 ) + { + if (exp & 1) v *= pow; + pow *= pow; + exp >>= 1; + } + return v; +} + +double dpow(double base, int exp) +{ + double v=1.0; + double pow = (exp <0)? 1.0/base : base; + if (exp < 0) exp = - exp; + + while(exp > 0 ) + { + if (exp & 1) v *= pow; + pow *= pow; + exp >>= 1; + } + return v; +} + +int main() +{ + printf("2^6 = %d\n", (int)ipow(2,6)); + printf("2^-6 = %lf\n", ipow(2,-6)); + printf("2.71^6 = %lf\n", dpow(2.71,6)); + printf("2.71^-6 = %lf\n", dpow(2.71,-6)); +} diff --git a/Task/Exponentiation-operator/Clojure/exponentiation-operator.clj b/Task/Exponentiation-operator/Clojure/exponentiation-operator.clj new file mode 100644 index 0000000000..1a0f6b5471 --- /dev/null +++ b/Task/Exponentiation-operator/Clojure/exponentiation-operator.clj @@ -0,0 +1 @@ +(defn ** [x n] (reduce * (repeat n x))) diff --git a/Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-1.lisp b/Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-1.lisp new file mode 100644 index 0000000000..775faf98a4 --- /dev/null +++ b/Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-1.lisp @@ -0,0 +1,4 @@ +(defun my-expt-do (a b) + (do ((x 1 (* x a)) + (y 0 (+ y 1))) + ((= y b) x))) diff --git a/Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-2.lisp b/Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-2.lisp new file mode 100644 index 0000000000..9d253e6dab --- /dev/null +++ b/Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-2.lisp @@ -0,0 +1,4 @@ +(defun my-expt-rec (a b) + (cond + ((= b 0) 1) + (t (* a (my-expt-rec a (- b 1)))))) diff --git a/Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-3.lisp b/Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-3.lisp new file mode 100644 index 0000000000..0cbfd68c61 --- /dev/null +++ b/Task/Exponentiation-operator/Common-Lisp/exponentiation-operator-3.lisp @@ -0,0 +1,4 @@ +(defun ^ (a b) + (do ((x 1 (* x a)) + (y 0 (+ y 1))) + ((= y b) x))) diff --git a/Task/Exponentiation-operator/D/exponentiation-operator.d b/Task/Exponentiation-operator/D/exponentiation-operator.d new file mode 100644 index 0000000000..f5f6dbc6cd --- /dev/null +++ b/Task/Exponentiation-operator/D/exponentiation-operator.d @@ -0,0 +1,47 @@ +import std.stdio, std.conv; + +struct Number(T) { + T x; // Base. + alias x this; + string toString() const { return text(x); } + + Number opBinary(string op)(in int exponent) + const pure nothrow if (op == "^^") in { + if (exponent < 0) + assert (x != 0, "Division by zero"); + } body { + debug puts("opBinary ^^"); + + int zerodir; + T factor; + if (exponent < 0) { + zerodir = +1; + factor = (cast(T)1) / x; + } else { + zerodir = -1; + factor = x; + } + + T result = 1; + int e = exponent; + while (e != 0) + if (e % 2 != 0) { + result *= factor; + e += zerodir; + } else { + factor *= factor; + e /= 2; + } + + return Number(result); + } +} + +void main() { + alias Double = Number!double; + writeln(Double(2.5) ^^ 5); + + alias Int = Number!int; + writeln(Int(3) ^^ 3); + writeln(Int(0) ^^ -2); // Division by zero. +} diff --git a/Task/Exponentiation-operator/E/exponentiation-operator.e b/Task/Exponentiation-operator/E/exponentiation-operator.e new file mode 100644 index 0000000000..d2445fae03 --- /dev/null +++ b/Task/Exponentiation-operator/E/exponentiation-operator.e @@ -0,0 +1,11 @@ +def power(base, exponent :int) { + var r := base + if (exponent < 0) { + for _ in exponent..0 { r /= base } + } else if (exponent <=> 0) { + return 1 + } else { + for _ in 2..exponent { r *= base } + } + return r +} diff --git a/Task/Exponentiation-operator/Erlang/exponentiation-operator-1.erl b/Task/Exponentiation-operator/Erlang/exponentiation-operator-1.erl new file mode 100644 index 0000000000..8c2ea201cf --- /dev/null +++ b/Task/Exponentiation-operator/Erlang/exponentiation-operator-1.erl @@ -0,0 +1,19 @@ +% -spec attribute is for documentation and dialyzer static analysis purposes only. +% It does not constrain the function like a guard (when ... ). +-spec exp_int(X :: integer(), N :: non_neg_integer()) -> integer(). + +% X ^ 0 +exp_int(X, 0) when is_integer(X) -> % is_integer guard is required, otherwise X would match anything. + 1; + +% X ^ odd +exp_int(X, N) when is_integer(X), N >= 1, N rem 2 == 1 -> + Part = exp_int(X, (N-1) div 2), + X * Part * Part; + +% X ^ even +exp_int(X, N) when is_integer(X), N >= 2, N rem 2 == 0 -> + Part = exp_int(X, N div 2), + Part * Part. + +% X ^ negative is excluded because it would return float. diff --git a/Task/Exponentiation-operator/Erlang/exponentiation-operator-2.erl b/Task/Exponentiation-operator/Erlang/exponentiation-operator-2.erl new file mode 100644 index 0000000000..706299b682 --- /dev/null +++ b/Task/Exponentiation-operator/Erlang/exponentiation-operator-2.erl @@ -0,0 +1,21 @@ +% -spec attribute is for documentation and dialyzer static analysis purposes only. +% It does not constrain the function like a guard (when ... ). +-spec exp_float(X :: float(), N :: integer()) -> float(). + +% X ^ 0 +exp_float(X, 0) when is_float(X) -> % is_float guard is required, otherwise X would match anything. + 1.0; + +% X ^ negative +exp_float(X, N) when is_float(X), N < 0 -> + 1.0 / exp_float(X, -N); + +% X ^ even +exp_float(X, N) when is_float(X), N >= 1, N rem 2 == 1 -> + Part = exp_float(X, (N-1) div 2), + X * Part * Part; + +% X ^ odd +exp_float(X, N) when is_float(X), N >= 2, N rem 2 == 0 -> + Part = exp_float(X, N div 2), + Part * Part. diff --git a/Task/Exponentiation-operator/Forth/exponentiation-operator-1.fth b/Task/Exponentiation-operator/Forth/exponentiation-operator-1.fth new file mode 100644 index 0000000000..4946e9efdb --- /dev/null +++ b/Task/Exponentiation-operator/Forth/exponentiation-operator-1.fth @@ -0,0 +1,2 @@ +: ** ( n m -- n^m ) + 1 swap 0 ?do over * loop nip ; diff --git a/Task/Exponentiation-operator/Forth/exponentiation-operator-2.fth b/Task/Exponentiation-operator/Forth/exponentiation-operator-2.fth new file mode 100644 index 0000000000..3a61137658 --- /dev/null +++ b/Task/Exponentiation-operator/Forth/exponentiation-operator-2.fth @@ -0,0 +1,8 @@ +: f**n ( f n -- f^n ) + dup 0= if + drop fdrop 1e + else dup 1 and if + 1- fdup recurse f* + else + 2/ fdup f* recurse + then then ; diff --git a/Task/Exponentiation-operator/Fortran/exponentiation-operator.f b/Task/Exponentiation-operator/Fortran/exponentiation-operator.f new file mode 100644 index 0000000000..272ca1d728 --- /dev/null +++ b/Task/Exponentiation-operator/Fortran/exponentiation-operator.f @@ -0,0 +1,51 @@ +MODULE Exp_Mod +IMPLICIT NONE + +INTERFACE OPERATOR (.pow.) ! Using ** instead would overload the standard exponentiation operator + MODULE PROCEDURE Intexp, Realexp +END INTERFACE + +CONTAINS + + FUNCTION Intexp (base, exponent) + INTEGER :: Intexp + INTEGER, INTENT(IN) :: base, exponent + INTEGER :: i + + IF (exponent < 0) THEN + IF (base == 1) THEN + Intexp = 1 + ELSE + Intexp = 0 + END IF + RETURN + END IF + Intexp = 1 + DO i = 1, exponent + Intexp = Intexp * base + END DO + END FUNCTION IntExp + + FUNCTION Realexp (base, exponent) + REAL :: Realexp + REAL, INTENT(IN) :: base + INTEGER, INTENT(IN) :: exponent + INTEGER :: i + + Realexp = 1.0 + IF (exponent < 0) THEN + DO i = exponent, -1 + Realexp = Realexp / base + END DO + ELSE + DO i = 1, exponent + Realexp = Realexp * base + END DO + END IF + END FUNCTION RealExp +END MODULE Exp_Mod + +PROGRAM EXAMPLE +USE Exp_Mod + WRITE(*,*) 2.pow.30, 2.0.pow.30 +END PROGRAM EXAMPLE diff --git a/Task/Exponentiation-operator/Go/exponentiation-operator.go b/Task/Exponentiation-operator/Go/exponentiation-operator.go new file mode 100644 index 0000000000..f2d6d6ad11 --- /dev/null +++ b/Task/Exponentiation-operator/Go/exponentiation-operator.go @@ -0,0 +1,77 @@ +package main + +import ( + "errors" + "fmt" +) + +func expI(b, p int) (int, error) { + if p < 0 { + return 0, errors.New("negative power not allowed") + } + r := 1 + for i := 1; i <= p; i++ { + r *= b + } + return r, nil +} + +func expF(b float32, p int) float32 { + var neg bool + if p < 0 { + neg = true + p = -p + } + r := float32(1) + for pow := b; p > 0; pow *= pow { + if p&1 == 1 { + r *= pow + } + p >>= 1 + } + if neg { + r = 1 / r + } + return r +} + +func main() { + ti := func(b, p int) { + fmt.Printf("%d^%d: ", b, p) + e, err := expI(b, p) + if err != nil { + fmt.Println(err) + } else { + fmt.Println(e) + } + } + + fmt.Println("expI tests") + ti(2, 10) + ti(2, -10) + ti(-2, 10) + ti(-2, 11) + ti(11, 0) + + fmt.Println("overflow undetected") + ti(10, 10) + + tf := func(b float32, p int) { + fmt.Printf("%g^%d: %g\n", b, p, expF(b, p)) + } + + fmt.Println("\nexpF tests:") + tf(2, 10) + tf(2, -10) + tf(-2, 10) + tf(-2, 11) + tf(11, 0) + + fmt.Println("disallowed in expI, allowed here") + tf(0, -1) + + fmt.Println("other interesting cases for 32 bit float type") + tf(10, 39) + tf(10, -39) + tf(-10, 39) +} diff --git a/Task/Exponentiation-operator/Haskell/exponentiation-operator-1.hs b/Task/Exponentiation-operator/Haskell/exponentiation-operator-1.hs new file mode 100644 index 0000000000..74ee6a01d3 --- /dev/null +++ b/Task/Exponentiation-operator/Haskell/exponentiation-operator-1.hs @@ -0,0 +1,8 @@ +(^) :: (Num a, Integral b) => a -> b -> a +_ ^ 0 = 1 +x ^ n | n > 0 = f x (n-1) x where + f _ 0 y = y + f a d y = g a d where + g b i | even i = g (b*b) (i `quot` 2) + | otherwise = f b (i-1) (b*y) +_ ^ _ = error "Prelude.^: negative exponent" diff --git a/Task/Exponentiation-operator/Haskell/exponentiation-operator-2.hs b/Task/Exponentiation-operator/Haskell/exponentiation-operator-2.hs new file mode 100644 index 0000000000..022e509556 --- /dev/null +++ b/Task/Exponentiation-operator/Haskell/exponentiation-operator-2.hs @@ -0,0 +1,2 @@ +(^^) :: (Fractional a, Integral b) => a -> b -> a +x ^^ n = if n >= 0 then x^n else recip (x^(negate n)) diff --git a/Task/Exponentiation-operator/Haskell/exponentiation-operator-3.hs b/Task/Exponentiation-operator/Haskell/exponentiation-operator-3.hs new file mode 100644 index 0000000000..62392e3637 --- /dev/null +++ b/Task/Exponentiation-operator/Haskell/exponentiation-operator-3.hs @@ -0,0 +1,2 @@ +(**) :: Floating a => a -> a -> a +x ** y = exp (log x * y) diff --git a/Task/Exponentiation-operator/Java/exponentiation-operator.java b/Task/Exponentiation-operator/Java/exponentiation-operator.java new file mode 100644 index 0000000000..fd6ab6fe7f --- /dev/null +++ b/Task/Exponentiation-operator/Java/exponentiation-operator.java @@ -0,0 +1,14 @@ +public class Exp{ + public static void main(String[] args){ + System.out.println(pow(2,30)); + System.out.println(pow(2.0,30)); //tests + System.out.println(pow(2.0,-2)); + } + + public static double pow(double base, int exp){ + if(exp < 0) return 1 / pow(base, -exp); + double ans = 1.0; + for(;exp > 0;--exp) ans *= base; + return ans; + } +} diff --git a/Task/Exponentiation-operator/JavaScript/exponentiation-operator.js b/Task/Exponentiation-operator/JavaScript/exponentiation-operator.js new file mode 100644 index 0000000000..6f6090c3e3 --- /dev/null +++ b/Task/Exponentiation-operator/JavaScript/exponentiation-operator.js @@ -0,0 +1,12 @@ +function pow(base, exp) { + if (exp != Math.floor(exp)) + throw "exponent must be an integer"; + if (exp < 0) + return 1 / pow(base, -exp); + var ans = 1; + while (exp > 0) { + ans *= base; + exp--; + } + return ans; +} diff --git a/Task/Exponentiation-operator/Lua/exponentiation-operator.lua b/Task/Exponentiation-operator/Lua/exponentiation-operator.lua new file mode 100644 index 0000000000..7f3e1f5486 --- /dev/null +++ b/Task/Exponentiation-operator/Lua/exponentiation-operator.lua @@ -0,0 +1,26 @@ +number = {} + +function number.pow( a, b ) + local ret = 1 + if b >= 0 then + for i = 1, b do + ret = ret * a.val + end + else + for i = b, -1 do + ret = ret / a.val + end + end + return ret +end + +function number.New( v ) + local num = { val = v } + local mt = { __pow = number.pow } + setmetatable( num, mt ) + return num +end + +x = number.New( 5 ) +print( x^2 ) --> 25 +print( number.pow( x, -4 ) ) --> 0.016 diff --git a/Task/Exponentiation-operator/Perl/exponentiation-operator.pl b/Task/Exponentiation-operator/Perl/exponentiation-operator.pl new file mode 100644 index 0000000000..c558939950 --- /dev/null +++ b/Task/Exponentiation-operator/Perl/exponentiation-operator.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl -w +use strict ; + +sub expon { + my ( $base , $expo ) = @_ ; + if ( $expo == 0 ) { + return 1 ; + } + elsif ( $expo == 1 ) { + return $base ; + } + elsif ( $expo > 1 ) { + my $prod = 1 ; + foreach my $n ( 0..($expo - 1) ) { + $prod *= $base ; + } + return $prod ; + } + elsif ( $expo < 0 ) { + return 1 / ( expon ( $base , -$expo ) ) ; + } +} +print "3 to the power of 10 as a function is " . expon( 3 , 10 ) . " !\n" ; +print "3 to the power of 10 as a builtin is " . 3**10 . " !\n" ; +print "5.5 to the power of -3 as a function is " . expon( 5.5 , -3 ) . " !\n" ; +print "5.5 to the power of -3 as a builtin is " . 5.5**-3 . " !\n" ; diff --git a/Task/Exponentiation-operator/PicoLisp/exponentiation-operator.l b/Task/Exponentiation-operator/PicoLisp/exponentiation-operator.l new file mode 100644 index 0000000000..46f9b81a4c --- /dev/null +++ b/Task/Exponentiation-operator/PicoLisp/exponentiation-operator.l @@ -0,0 +1,8 @@ +(de ** (X N) # N th power of X + (let Y 1 + (loop + (when (bit? 1 N) + (setq Y (* Y X)) ) + (T (=0 (setq N (>> 1 N))) + Y ) + (setq X (* X X)) ) ) ) diff --git a/Task/Exponentiation-operator/Python/exponentiation-operator.py b/Task/Exponentiation-operator/Python/exponentiation-operator.py new file mode 100644 index 0000000000..41beb48a2f --- /dev/null +++ b/Task/Exponentiation-operator/Python/exponentiation-operator.py @@ -0,0 +1,22 @@ +>>> import operator +>>> class num(int): + def __pow__(self, b): + print "Empowered" + return operator.__pow__(self+0, b) + + +>>> x = num(3) +>>> x**2 +Empowered +9 +>>> class num(float): + def __pow__(self, b): + print "Empowered" + return operator.__pow__(self+0, b) + + +>>> x = num(2.5) +>>> x**2 +Empowered +6.25 +>>> diff --git a/Task/Exponentiation-operator/R/exponentiation-operator.r b/Task/Exponentiation-operator/R/exponentiation-operator.r new file mode 100644 index 0000000000..6caf222968 --- /dev/null +++ b/Task/Exponentiation-operator/R/exponentiation-operator.r @@ -0,0 +1,12 @@ +# Method +pow <- function(x, y) +{ + x <- as.numeric(x) + y <- as.integer(y) + prod(rep(x, y)) +} +#Operator +"%pow%" <- function(x,y) pow(x,y) + +pow(3, 4) # 81 +2.5 %pow% 2 # 6.25 diff --git a/Task/Exponentiation-operator/REXX/exponentiation-operator.rexx b/Task/Exponentiation-operator/REXX/exponentiation-operator.rexx new file mode 100644 index 0000000000..a468ff0c4c --- /dev/null +++ b/Task/Exponentiation-operator/REXX/exponentiation-operator.rexx @@ -0,0 +1,38 @@ +/*REXX program to show various (integer) exponentations. */ + say center('digits='digits(),79,'─') +say '17**65 is:' +say 17**65 + +numeric digits 100; say; say center('digits='digits(),79,'─') +say '17**65 is:' +say 17**65 + +numeric digits 10; say; say center('digits='digits(),79,'─') +say '2 ** -10 is:' +say 2 ** -10 + +numeric digits 30; say; say center('digits='digits(),79,'─') +say '-3.1415926535897932384626433 ** 3 is:' +say -3.1415926535897932384626433 ** 3 + +numeric digits 1000; say; say center('digits='digits(),79,'─') +say '2 ** 1000 is:' +say 2 ** 1000 + +numeric digits 60; say; say center('digits='digits(),79,'─') +say 'ipow(5,70) is:' +say ipow(5,70) +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────ERRIPOW subroutine──────────────────*/ +errIpow: say; say '***error!***'; say; say arg(1); say; say; exit 13 +/*──────────────────────────────────IPOW subroutine─────────────────────*/ +ipow: procedure; parse arg x 1 _,p +if arg()<2 then call erripow 'not enough arguments specified' +if arg()>2 then call erripow 'too many arguments specified' +if \datatype(_,'N') then call erripow "1st arg isn't numeric:" _ +if \datatype(p,'W') then call erripow "2nd arg isn't an integer:" p +if p=0 then return 1 +pa=abs(p) + do pa-1; _=_*x; end +if p<0 then _=1/_ +return _ diff --git a/Task/Exponentiation-operator/Ruby/exponentiation-operator-1.rb b/Task/Exponentiation-operator/Ruby/exponentiation-operator-1.rb new file mode 100644 index 0000000000..fbdf97c3de --- /dev/null +++ b/Task/Exponentiation-operator/Ruby/exponentiation-operator-1.rb @@ -0,0 +1,16 @@ +class Numeric + def pow(m) + raise TypeError, "exponent must be an integer: #{m}" unless m.is_a? Integer + puts "pow!!" + + # below requires Ruby 1.8.7 + Array.new(m, self).reduce(1, :*) + + # for earlier versions of Ruby + #Array.new(m, self).inject(1) { |res, n| res * n } + end +end + +p 5.pow(3) +p 5.5.pow(3) +p 5.pow(3.1) diff --git a/Task/Exponentiation-operator/Ruby/exponentiation-operator-2.rb b/Task/Exponentiation-operator/Ruby/exponentiation-operator-2.rb new file mode 100644 index 0000000000..589525f5b0 --- /dev/null +++ b/Task/Exponentiation-operator/Ruby/exponentiation-operator-2.rb @@ -0,0 +1,5 @@ +class Numeric + def **(m) + pow(m) + end +end diff --git a/Task/Exponentiation-operator/Ruby/exponentiation-operator-3.rb b/Task/Exponentiation-operator/Ruby/exponentiation-operator-3.rb new file mode 100644 index 0000000000..4e4eb6155d --- /dev/null +++ b/Task/Exponentiation-operator/Ruby/exponentiation-operator-3.rb @@ -0,0 +1,22 @@ +class Fixnum + def **(m) + print "Fixnum " + pow(m) + end +end +class Bignum + def **(m) + print "Bignum " + pow(m) + end +end +class Float + def **(m) + print "Float " + pow(m) + end +end + +p i=2**64 +p i ** 2 +p 2.2 ** 3 diff --git a/Task/Exponentiation-operator/Scala/exponentiation-operator-1.scala b/Task/Exponentiation-operator/Scala/exponentiation-operator-1.scala new file mode 100644 index 0000000000..00251bbd71 --- /dev/null +++ b/Task/Exponentiation-operator/Scala/exponentiation-operator-1.scala @@ -0,0 +1,43 @@ +object Exponentiation { + import scala.annotation.tailrec + + @tailrec def powI[N](n: N, exponent: Int)(implicit num: Integral[N]): N = { + import num._ + exponent match { + case 0 => one + case _ if exponent % 2 == 0 => powI((n * n), (exponent / 2)) + case _ => powI(n, (exponent - 1)) * n + } + } + + @tailrec def powF[N](n: N, exponent: Int)(implicit num: Fractional[N]): N = { + import num._ + exponent match { + case 0 => one + case _ if exponent < 0 => one / powF(n, exponent.abs) + case _ if exponent % 2 == 0 => powF((n * n), (exponent / 2)) + case _ => powF(n, (exponent - 1)) * n + } + } + + class ExponentI[N : Integral](n: N) { + def \u2191(exponent: Int): N = powI(n, exponent) + } + + class ExponentF[N : Fractional](n: N) { + def \u2191(exponent: Int): N = powF(n, exponent) + } + + object ExponentI { + implicit def toExponentI[N : Integral](n: N): ExponentI[N] = new ExponentI(n) + } + + object ExponentF { + implicit def toExponentF[N : Fractional](n: N): ExponentF[N] = new ExponentF(n) + } + + object Exponents { + implicit def toExponent(n: Int): ExponentI[Int] = new ExponentI(n) + implicit def toExponent(n: Double): ExponentF[Double] = new ExponentF(n) + } +} diff --git a/Task/Exponentiation-operator/Scala/exponentiation-operator-2.scala b/Task/Exponentiation-operator/Scala/exponentiation-operator-2.scala new file mode 100644 index 0000000000..f50ca9fe49 --- /dev/null +++ b/Task/Exponentiation-operator/Scala/exponentiation-operator-2.scala @@ -0,0 +1,7 @@ + @tailrec def powI[N](n: N, exponent: Int, acc:Int=1)(implicit num: Integral[N]): N = { + exponent match { + case 0 => acc + case _ if exponent % 2 == 0 => powI(n * n, exponent / 2, acc) + case _ => powI(n, (exponent - 1), acc*n) + } + } diff --git a/Task/Exponentiation-operator/Scheme/exponentiation-operator.ss b/Task/Exponentiation-operator/Scheme/exponentiation-operator.ss new file mode 100644 index 0000000000..69964b2234 --- /dev/null +++ b/Task/Exponentiation-operator/Scheme/exponentiation-operator.ss @@ -0,0 +1,15 @@ +(define (^ base exponent) + (define (*^ exponent acc) + (if (= exponent 0) + acc + (*^ (- exponent 1) (* acc base)))) + (*^ exponent 1)) + +(display (^ 2 3)) +(newline) +(display (^ (/ 1 2) 3)) +(newline) +(display (^ 0.5 3)) +(newline) +(display (^ 2+i 3)) +(newline) diff --git a/Task/Exponentiation-operator/Smalltalk/exponentiation-operator.st b/Task/Exponentiation-operator/Smalltalk/exponentiation-operator.st new file mode 100644 index 0000000000..6d32a7504d --- /dev/null +++ b/Task/Exponentiation-operator/Smalltalk/exponentiation-operator.st @@ -0,0 +1,16 @@ +Number extend [ + ** anInt [ + | r | + ( anInt isInteger ) + ifFalse: + [ '** works fine only for integer powers' + displayOn: stderr . Character nl displayOn: stderr ]. + r := 1. + 1 to: anInt do: [ :i | r := ( r * self ) ]. + ^r + ] +]. + +( 2.5 ** 3 ) displayNl. +( 2 ** 10 ) displayNl. +( 3/7 ** 3 ) displayNl. diff --git a/Task/Exponentiation-operator/Tcl/exponentiation-operator.tcl b/Task/Exponentiation-operator/Tcl/exponentiation-operator.tcl new file mode 100644 index 0000000000..2d19830b2c --- /dev/null +++ b/Task/Exponentiation-operator/Tcl/exponentiation-operator.tcl @@ -0,0 +1,10 @@ +package require Tcl 8.5 +proc tcl::mathfunc::mypow {a b} { + if { ! [string is int -strict $b]} {error "exponent must be an integer"} + set res 1 + for {set i 1} {$i <= $b} {incr i} {set res [expr {$res * $a}]} + return $res +} +expr {mypow(3, 3)} ;# ==> 27 +expr {mypow(3.5, 3)} ;# ==> 42.875 +expr {mypow(3.5, 3.2)} ;# ==> exponent must be an integer diff --git a/Task/Extend-your-language/0DESCRIPTION b/Task/Extend-your-language/0DESCRIPTION new file mode 100644 index 0000000000..4f00a8898a --- /dev/null +++ b/Task/Extend-your-language/0DESCRIPTION @@ -0,0 +1,32 @@ +{{Control Structures}}{{omit from|BBC BASIC}} +Some programming languages allow you to [[wp:Extensible_programming|extend]] the language. While this can be done to a certain degree in most languages (e.g. by using macros), other languages go much further. Most notably in the Forth and Lisp families, programming per se is done by extending the language without any formal distinction between built-in and user-defined elements. + +If your language supports it, show how to introduce a new flow control mechanism. A practical and useful example is a four-way branch: + +Occasionally, code must be written that depends on ''two'' conditions, resulting in up to four branches (depending on whether both, only the first, only the second, or none of the conditions are "true"). In a C-like language this could look like the following: + + if (condition1isTrue) { + if (condition2isTrue) + bothConditionsAreTrue(); + else + firstConditionIsTrue(); + } + else if (condition2isTrue) + secondConditionIsTrue(); + else + noConditionIsTrue(); + +Besides being rather cluttered, the statement(s) for 'condition2isTrue' must be written down twice. If 'condition2isTrue' were a lengthy and involved expression, it would be quite unreadable, and the code generated by the compiler might be unnecessarily large. + +This can be improved by introducing a new keyword '''if2'''. It is similar to '''if''', but takes two conditional statements instead of one, and up to three 'else' statements. One proposal (in pseudo-C syntax) might be: + + if2 (condition1isTrue) (condition2isTrue) + bothConditionsAreTrue(); + else1 + firstConditionIsTrue(); + else2 + secondConditionIsTrue(); + else + noConditionIsTrue(); + +Pick the syntax which suits your language. The keywords 'else1' and 'else2' are just examples. The new conditional expression should look, nest and behave analog to the language's built-in 'if' statement. diff --git a/Task/Extend-your-language/C/extend-your-language-1.c b/Task/Extend-your-language/C/extend-your-language-1.c new file mode 100644 index 0000000000..837e2275c9 --- /dev/null +++ b/Task/Extend-your-language/C/extend-your-language-1.c @@ -0,0 +1,16 @@ +/* Four-way branch. + * + * if2 (firsttest, secondtest + * , bothtrue + * , firstrue + * , secondtrue + * , bothfalse + * ) + */ +#define if2(firsttest,secondtest,bothtrue,firsttrue,secondtrue,bothfalse)\ + switch(((firsttest)?0:2)+((secondtest)?0:1)) {\ + case 0: bothtrue; break;\ + case 1: firsttrue; break;\ + case 2: secondtrue; break;\ + case 3: bothfalse; break;\ + } diff --git a/Task/Extend-your-language/C/extend-your-language-2.c b/Task/Extend-your-language/C/extend-your-language-2.c new file mode 100644 index 0000000000..12c7df63ed --- /dev/null +++ b/Task/Extend-your-language/C/extend-your-language-2.c @@ -0,0 +1,24 @@ +#include +#include +#include +#include "if2.h" + +int main(int argc, char *argv[]) { + int i; + for (i = 1; i < argc; i++) { + char *arg= argv[i], *ep; + long lval = strtol(arg, &ep, 10); /* convert arg to long */ + if2 (arg[0] == '\0', *ep == '\0' + , puts("empty string") + , puts("empty string") + , if2 (lval > 10, lval > 100 + , printf("%s: a very big number\n", arg) + , printf("%s: a big number\n", arg) + , printf("%s: a very big number\n", arg) + , printf("%s: a number\n", arg) + ) + , printf("%s: not a number\n", arg) + ) + } + return 0; +} diff --git a/Task/Extend-your-language/C/extend-your-language-3.c b/Task/Extend-your-language/C/extend-your-language-3.c new file mode 100644 index 0000000000..57db4b731d --- /dev/null +++ b/Task/Extend-your-language/C/extend-your-language-3.c @@ -0,0 +1,9 @@ +$ make exten && ./exten 3 33 333 3a b " " -2 +cc exten.c -o exten +3: a number +33: a big number +333: a very big number +3a: not a number +b: not a number + : not a number +-2: a number diff --git a/Task/Extend-your-language/C/extend-your-language-4.c b/Task/Extend-your-language/C/extend-your-language-4.c new file mode 100644 index 0000000000..cdaafce6b1 --- /dev/null +++ b/Task/Extend-your-language/C/extend-your-language-4.c @@ -0,0 +1,34 @@ +#include + +#define if2(a, b) switch(((a)) + ((b)) * 2) { case 3: +#define else00 break; case 0: /* both false */ +#define else10 break; case 1: /* true, false */ +#define else01 break; case 2: /* false, true */ +#define else2 break; default: /* anything not metioned */ +#define fi2 } /* stupid end bracket */ + +int main() +{ + int i, j; + for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { + printf("%d %d: ", i, j); + if2 (i == 1, j == 1) + printf("both\n"); + else10 + printf("left\n"); + else01 + printf("right\n"); + else00 { /* <-- bracket is optional, flaw */, + printf("neither\n"); + if2 (i == 2, j == 2) + printf("\tis 22"); + printf("\n"); /* flaw: this is part of if2! */ + else2 + printf("\tnot 22\n"); + fi2 + } + fi2 + } + + return 0; +} diff --git a/Task/Extend-your-language/Clay/extend-your-language.clay b/Task/Extend-your-language/Clay/extend-your-language.clay new file mode 100644 index 0000000000..07107af526 --- /dev/null +++ b/Task/Extend-your-language/Clay/extend-your-language.clay @@ -0,0 +1,15 @@ +alias if2(cond1:Bool, + cond2:Bool, + both, + first, + second, + neither) +{ + var res1 = cond1; + var res2 = cond2; + + if (res1 and res2) return both; + if (res1) return first; + if (res2) return second; + return neither; +} diff --git a/Task/Extend-your-language/Clojure/extend-your-language.clj b/Task/Extend-your-language/Clojure/extend-your-language.clj new file mode 100644 index 0000000000..43516841a8 --- /dev/null +++ b/Task/Extend-your-language/Clojure/extend-your-language.clj @@ -0,0 +1,5 @@ +(defmacro if2 [[cond1 cond2] bothTrue firstTrue secondTrue else] + `(let [cond1# ~cond1 + cond2# ~cond2] + (if cond1# (if cond2# ~bothTrue ~firstTrue) + (if cond2# ~secondTrue ~else)))) diff --git a/Task/Extend-your-language/Common-Lisp/extend-your-language.lisp b/Task/Extend-your-language/Common-Lisp/extend-your-language.lisp new file mode 100644 index 0000000000..14f8184dc3 --- /dev/null +++ b/Task/Extend-your-language/Common-Lisp/extend-your-language.lisp @@ -0,0 +1,9 @@ +(defmacro if2 (cond1 cond2 both first second &rest neither) + (let ((res1 (gensym)) + (res2 (gensym))) + `(let ((,res1 ,cond1) + (,res2 ,cond2)) + (cond ((and ,res1 ,res2) ,both) + (,res1 ,first) + (,res2 ,second) + (t ,@neither))))) diff --git a/Task/Extend-your-language/D/extend-your-language.d b/Task/Extend-your-language/D/extend-your-language.d new file mode 100644 index 0000000000..4657a8d9ed --- /dev/null +++ b/Task/Extend-your-language/D/extend-your-language.d @@ -0,0 +1,32 @@ +void if2(T1, T2, T3, T4)(in bool c1, in bool c2, + lazy T1 first, + lazy T2 both, + lazy T3 second, + lazy T4 none) { + if (c1) { + if (c2) + both; + else + first; + } else { + if (c2) + second; + else + none; + } +} + +void test(in bool a, in bool b) { + import std.stdio; + if2(a, b, writeln("first"), + writeln("both"), + writeln("second"), + writeln("none")); +} + +void main() { + test(1 < 2, 3 > 4); + test(1 < 2, 1 < 2); + test(3 > 4, 3 > 4); + test(3 > 4, 1 < 2); +} diff --git a/Task/Extend-your-language/Delphi/extend-your-language-1.delphi b/Task/Extend-your-language/Delphi/extend-your-language-1.delphi new file mode 100644 index 0000000000..5d1be99b60 --- /dev/null +++ b/Task/Extend-your-language/Delphi/extend-your-language-1.delphi @@ -0,0 +1,15 @@ +procedure Check(Condition1: Boolean; Condition2: Boolean) +begin + if Condition1 = True then + begin + if Condition2 = True then + BothConditionsAreTrue + else + FirstConditionIsTrue; + end + else + if Condition2 = True then + SecondConditionIsTrue + else + NoConditionIsTrue; +end; diff --git a/Task/Extend-your-language/Delphi/extend-your-language-2.delphi b/Task/Extend-your-language/Delphi/extend-your-language-2.delphi new file mode 100644 index 0000000000..90797f21b6 --- /dev/null +++ b/Task/Extend-your-language/Delphi/extend-your-language-2.delphi @@ -0,0 +1,10 @@ +procedure Check(Condition1: Boolean; Condition2: Boolean) +begin + if (Condition1 = True) and (Condition2 = True) then + BothConditionsAreTrue + else if Condition1 = True then + FirstConditionIsTrue + else if Condition2 = True then + SecondConditionIsTrue + else NoConditionIsTrue; +end; diff --git a/Task/Extend-your-language/E/extend-your-language-1.e b/Task/Extend-your-language/E/extend-your-language-1.e new file mode 100644 index 0000000000..18b0a3d312 --- /dev/null +++ b/Task/Extend-your-language/E/extend-your-language-1.e @@ -0,0 +1,44 @@ +pragma.enable("lambda-args") # The feature is still experimental syntax + +def makeIf2Control(evalFn, tf, ft, ff) { + return def if2Control { + to only1__control_0(tf) { return makeIf2Control(evalFn, tf, ft, ff) } + to only2__control_0(ft) { return makeIf2Control(evalFn, tf, ft, ff) } + to else__control_0 (ff) { return makeIf2Control(evalFn, tf, ft, ff) } + to run__control() { + def [[a :boolean, b :boolean], # Main parameters evaluated + tt # First block ("then" case) + ] := evalFn() + return ( + if (a) { if (b) {tt} else {tf} } \ + else { if (b) {ft} else {ff} } + )() + } + } +} + +def if2 { + # The verb here is composed from the keyword before the brace, the number of + # parameters in the parentheses, and the number of parameters after the + # keyword. + to then__control_2_0(evalFn) { + # evalFn, when called, evaluates the expressions in parentheses, then + # returns a pair of those expressions and the first { block } as a + # closure. + return makeIf2Control(evalFn, fn {}, fn {}, fn {}) + } +} + +for a in [false,true] { + for b in [false,true] { + if2 (a, b) then { + println("both") + } only1 { + println("a true") + } only2 { + println("b true") + } else { + println("neither") + } + } +} diff --git a/Task/Extend-your-language/E/extend-your-language-2.e b/Task/Extend-your-language/E/extend-your-language-2.e new file mode 100644 index 0000000000..5f395eb6aa --- /dev/null +++ b/Task/Extend-your-language/E/extend-your-language-2.e @@ -0,0 +1,11 @@ +if2.then__control_2_0(fn { + [[a, b], fn { + println("both") + }] +}).only1__control_0(fn { + println("a true") +}).only2__control_0(fn { + println("b true") +}).else__control_0(fn { + println("neither") +}).run__control() diff --git a/Task/Extend-your-language/Forth/extend-your-language.fth b/Task/Extend-your-language/Forth/extend-your-language.fth new file mode 100644 index 0000000000..348c38d4ab --- /dev/null +++ b/Task/Extend-your-language/Forth/extend-your-language.fth @@ -0,0 +1,14 @@ +\ in this construct, either of the ELSE clauses may be omitted, just like IF-THEN. + +: BOTH postpone IF postpone IF ; immediate +: ORELSE postpone THEN postpone ELSE postpone IF ; immediate +: NEITHER postpone THEN postpone THEN ; immediate + +: fb ( n -- ) + dup 5 mod 0= over 3 mod 0= + BOTH ." FizzBuzz " + ELSE ." Fizz " + ORELSE ." Buzz " + ELSE dup . + NEITHER drop ; +: fizzbuzz ( n -- ) 0 do i 1+ fb loop ; diff --git a/Task/Extend-your-language/Haskell/extend-your-language.hs b/Task/Extend-your-language/Haskell/extend-your-language.hs new file mode 100644 index 0000000000..f01ff34220 --- /dev/null +++ b/Task/Extend-your-language/Haskell/extend-your-language.hs @@ -0,0 +1,7 @@ +if2 :: Bool -> Bool -> a -> a -> a -> a -> a +if2 p1 p2 e12 e1 e2 e = + if p1 then + if p2 then e12 else e1 + else if p2 then e2 else e + +main = print $ if2 True False (error "TT") "TF" (error "FT") (error "FF") diff --git a/Task/Extend-your-language/Perl/extend-your-language-1.pl b/Task/Extend-your-language/Perl/extend-your-language-1.pl new file mode 100644 index 0000000000..ec16a1ea76 --- /dev/null +++ b/Task/Extend-your-language/Perl/extend-your-language-1.pl @@ -0,0 +1,136 @@ +#!/usr/bin/perl +use warnings; +use strict; +use v5.10; + +=for starters + +Syntax: + + if2 condition1, condition2, then2 { + # both conditions are true + } + else1 { + # only condition1 is true + } + else2 { + # only condition2 is true + } + orelse { + # neither condition is true + }; + +Any (but not all) of the `then' and `else' clauses can be omitted, and else1 +and else2 can be specified in either order. + +This extension is imperfect in several ways: +* A normal if-statement uses round brackets, but this syntax forbids them. +* Perl doesn't have a `then' keyword; if it did, it probably wouldn't be + preceded by a comma. +* Unless it's the last thing in a block, the whole structure must be followed + by a semicolon. +* Error messages appear at runtime, not compile time, and they don't show the + line where the user's syntax error occurred. + +We could solve most of these problems with a source filter, but those are +dangerous. Can anyone else do better? Feel free to improve or replace. + +=cut + +# All the new `keywords' are in fact functions. Most of them return lists +# of four closures, one of which is then executed by if2. Here are indexes into +# these lists: + +use constant { + IdxThen => 0, + IdxElse1 => 1, + IdxElse2 => 2, + IdxOrElse => 3 +}; + +# Most of the magic is in the (&) prototype, which lets a function accept a +# closure marked by nothing except braces. + +sub orelse(&) { + my $clause = shift; + return undef, undef, undef, $clause; +} + +sub else2(&@) { + my $clause = shift; + die "Can't have two `else2' clauses" + if defined $_[IdxElse2]; + + return (undef, $_[IdxElse1], $clause, $_[IdxOrElse]); +} + +sub else1(&@) { + my $clause = shift; + die "Can't have two `else1' clauses" + if defined $_[IdxElse1]; + + return (undef, $clause, $_[IdxElse2], $_[IdxOrElse]); +} + +sub then2(&@) { + die "Can't have two `then2' clauses" + if defined $_[1+IdxThen]; + + splice @_, 1+IdxThen, 1; + return @_; +} + +# Here, we collect the two conditions and four closures (some of which will be +# undefined if some clauses are missing). We work out which of the four +# clauses (closures) to call, and call it if it exists. + +use constant { + # Defining True and False is almost always bad practice, but here we + # have a valid reason. + True => (0 == 0), + False => (0 == 1) +}; + +sub if2($$@) { + my $cond1 = !!shift; # Convert to Boolean to guarantee matching + my $cond2 = !!shift; # against either True or False + + die "if2 must be followed by then2, else1, else2, &/or orelse" + if @_ != 4 + or grep {defined and ref $_ ne 'CODE'} @_; + + my $index; + given ([$cond1, $cond2]) { + when ([False, False]) {$index = IdxOrElse} + when ([False, True ]) {$index = IdxElse2 } + when ([True, False]) {$index = IdxElse1 } + when ([True, True ]) {$index = IdxThen } + } + + my $closure = $_[$index]; + &$closure if defined $closure; +} + +# This is test code. You can play with it by deleting up to three of the +# four clauses. + +sub test_bits($) { + (my $n) = @_; + + print "Testing $n: "; + + if2 $n & 1, $n & 2, then2 { + say "Both bits 0 and 1 are set"; + } + else1 { + say "Only bit 0 is set"; + } + else2 { + say "Only bit 1 is set"; + } + orelse { + say "Neither bit is set"; + } +} + +test_bits $_ for 0 .. 7; diff --git a/Task/Extend-your-language/Perl/extend-your-language-2.pl b/Task/Extend-your-language/Perl/extend-your-language-2.pl new file mode 100644 index 0000000000..87b2b3b9c5 --- /dev/null +++ b/Task/Extend-your-language/Perl/extend-your-language-2.pl @@ -0,0 +1,10 @@ +msl@64Lucid:~/perl$ ./if2 +Testing 0: Neither bit is set +Testing 1: Only bit 0 is set +Testing 2: Only bit 1 is set +Testing 3: Both bits 0 and 1 are set +Testing 4: Neither bit is set +Testing 5: Only bit 0 is set +Testing 6: Only bit 1 is set +Testing 7: Both bits 0 and 1 are set +msl@64Lucid:~/perl$ diff --git a/Task/Extend-your-language/PicoLisp/extend-your-language.l b/Task/Extend-your-language/PicoLisp/extend-your-language.l new file mode 100644 index 0000000000..3b73025ab7 --- /dev/null +++ b/Task/Extend-your-language/PicoLisp/extend-your-language.l @@ -0,0 +1,8 @@ +(undef 'if2) # Undefine the built-in 'if2' + +(de if2 "P" + (if (eval (pop '"P")) + (eval ((if (eval (car "P")) cadr caddr) "P")) + (if (eval (car "P")) + (eval (cadddr "P")) + (run (cddddr "P")) ) ) ) diff --git a/Task/Extend-your-language/R/extend-your-language-1.r b/Task/Extend-your-language/R/extend-your-language-1.r new file mode 100644 index 0000000000..e782a36afc --- /dev/null +++ b/Task/Extend-your-language/R/extend-your-language-1.r @@ -0,0 +1,8 @@ +if2 <- function(condition1, condition2, both_true, first_true, second_true, both_false) +{ + expr <- if(condition1) + { + if(condition2) both_true else first_true + } else if(condition2) second_true else both_false + eval(expr) +} diff --git a/Task/Extend-your-language/R/extend-your-language-2.r b/Task/Extend-your-language/R/extend-your-language-2.r new file mode 100644 index 0000000000..9594dcb586 --- /dev/null +++ b/Task/Extend-your-language/R/extend-your-language-2.r @@ -0,0 +1,12 @@ +for(x in 1:2) for(y in letters[1:2]) +{ + print(if2(x == 1, y == "a", + "both conditions are true", + x + 99, + { + yy <- rep.int(y, 10) + paste(letters[1:10], yy) + }, + NULL + )) +} diff --git a/Task/Extend-your-language/R/extend-your-language-3.r b/Task/Extend-your-language/R/extend-your-language-3.r new file mode 100644 index 0000000000..f275a8eea1 --- /dev/null +++ b/Task/Extend-your-language/R/extend-your-language-3.r @@ -0,0 +1,10 @@ +if2 <- function(condition1, condition2, expr_list = NULL) +{ + cl <- as.call(expr_list) + cl_name <- if(condition1) + { + if(condition2) "" else "else1" + } else if(condition2) "else2" else "else" + if(!nzchar(cl_name)) cl_name <- which(!nzchar(names(cl))) + eval(cl[[cl_name]]) +} diff --git a/Task/Extend-your-language/R/extend-your-language-4.r b/Task/Extend-your-language/R/extend-your-language-4.r new file mode 100644 index 0000000000..586138762f --- /dev/null +++ b/Task/Extend-your-language/R/extend-your-language-4.r @@ -0,0 +1,13 @@ +for(x in 1:2) for(y in letters[1:2]) +{ + print(if2(x == 1, y == "a", list( + "both conditions are true", + else1 = x + 99, + else2 = + { + yy <- rep.int(y, 10) + paste(letters[1:10], yy) + }, + "else" = NULL + ))) +} diff --git a/Task/Extend-your-language/Ruby/extend-your-language-1.rb b/Task/Extend-your-language/Ruby/extend-your-language-1.rb new file mode 100644 index 0000000000..9801283f58 --- /dev/null +++ b/Task/Extend-your-language/Ruby/extend-your-language-1.rb @@ -0,0 +1,23 @@ +# Define a class which always returns itself for everything +class HopelesslyEgocentric + def method_missing what, *args; self; end; +end + +def if2 cond1, cond2 + if cond1 and cond2 + yield + HopelesslyEgocentric.new + elsif cond1 + Class.new(HopelesslyEgocentric) do + def else1; yield; HopelesslyEgocentric.new; end + end.new + elsif cond2 + Class.new(HopelesslyEgocentric) do + def else2; yield; HopelesslyEgocentric.new; end + end.new + else + Class.new(HopelesslyEgocentric) do + def neither; yield; end + end.new + end +end diff --git a/Task/Extend-your-language/Ruby/extend-your-language-2.rb b/Task/Extend-your-language/Ruby/extend-your-language-2.rb new file mode 100644 index 0000000000..e9000dbc8a --- /dev/null +++ b/Task/Extend-your-language/Ruby/extend-your-language-2.rb @@ -0,0 +1,9 @@ +if2(5 < x, x < 7) do + puts "both true" +end.else1 do + puts "first is true" +end.else2 do + puts "second is true" +end.neither do + puts "neither is true" +end diff --git a/Task/Extend-your-language/Scala/extend-your-language-1.scala b/Task/Extend-your-language/Scala/extend-your-language-1.scala new file mode 100644 index 0000000000..6fd7684961 --- /dev/null +++ b/Task/Extend-your-language/Scala/extend-your-language-1.scala @@ -0,0 +1,17 @@ +scala> def if2[A](x: => Boolean)(y: => Boolean)(xyt: => A) = new { + | def else1(xt: => A) = new { + | def else2(yt: => A) = new { + | def orElse(nt: => A) = { + | if(x) { + | if(y) xyt else xt + | } else if(y) { + | yt + | } else { + | nt + | } + | } + | } + | } + | } +if2: [A](x: => Boolean)(y: => Boolean)(xyt: => A)java.lang.Object{def else1(xt: => A): java.lang.Object{def else2(yt: => + A): java.lang.Object{def orElse(nt: => A): A}}} diff --git a/Task/Extend-your-language/Scala/extend-your-language-2.scala b/Task/Extend-your-language/Scala/extend-your-language-2.scala new file mode 100644 index 0000000000..5e5b9222b1 --- /dev/null +++ b/Task/Extend-your-language/Scala/extend-your-language-2.scala @@ -0,0 +1,21 @@ +scala> if2(true)(true) { + | 1 + | } else1 { + | 9 + | } else2 { + | 11 + | } orElse { + | 45 + | } +res0: Int = 1 + +scala> if2(false)(true) { + | "Luffy" + | } else1 { + | "Nami" + | } else2 { + | "Sanji" + | } orElse { + | "Zoro" + | } +res1: java.lang.String = Sanji diff --git a/Task/Extend-your-language/Scheme/extend-your-language.ss b/Task/Extend-your-language/Scheme/extend-your-language.ss new file mode 100644 index 0000000000..b2d10cb2ca --- /dev/null +++ b/Task/Extend-your-language/Scheme/extend-your-language.ss @@ -0,0 +1,7 @@ +(define-syntax if2 + (syntax-rules () + ((if2 cond1 cond2 both-true first-true second-true none-true) + (let ((c2 cond2)) + (if cond1 + (if c2 both-true first-true) + (if c2 second-true none-true)))))) diff --git a/Task/Extend-your-language/Tcl/extend-your-language-1.tcl b/Task/Extend-your-language/Tcl/extend-your-language-1.tcl new file mode 100644 index 0000000000..2f1fe7c0d3 --- /dev/null +++ b/Task/Extend-your-language/Tcl/extend-your-language-1.tcl @@ -0,0 +1,15 @@ +proc if2 {cond1 cond2 bothTrueBody firstTrueBody secondTrueBody bothFalseBody} { + # Must evaluate both conditions, and should do so in order + set c1 [uplevel 1 [list expr $cond1] + set c2 [uplevel 1 [list expr $cond2] + # Now use that to decide what to do + if {$c1 && $c2} { + uplevel 1 $bothTrueBody + } elseif {$c1 && !$c2} { + uplevel 1 $firstTrueBody + } elseif {$c2 && !$c1} { + uplevel 1 $secondTrueBody + } else { + uplevel 1 $bothFalseBody + } +} diff --git a/Task/Extend-your-language/Tcl/extend-your-language-2.tcl b/Task/Extend-your-language/Tcl/extend-your-language-2.tcl new file mode 100644 index 0000000000..fea4168b08 --- /dev/null +++ b/Task/Extend-your-language/Tcl/extend-your-language-2.tcl @@ -0,0 +1,9 @@ +if2 {1 > 0} {"grill" in {foo bar boo}} { + puts "1 and 2" +} { + puts "1 but not 2" +} { + puts "2 but not 1" +} { + puts "neither 1 nor 2" +} diff --git a/Task/Extend-your-language/Tcl/extend-your-language-3.tcl b/Task/Extend-your-language/Tcl/extend-your-language-3.tcl new file mode 100644 index 0000000000..2e89303a28 --- /dev/null +++ b/Task/Extend-your-language/Tcl/extend-your-language-3.tcl @@ -0,0 +1,8 @@ +proc if2 {cond1 cond2 body00 body01 body10 body11} { + # Must evaluate both conditions, and should do so in order + # Extra negations ensure boolean interpretation + set c1 [expr {![uplevel 1 [list expr $cond1]]}] + set c2 [expr {![uplevel 1 [list expr $cond2]]}] + # Use those values to pick the script to evaluate + uplevel 1 [set body$c1$c2] +} diff --git a/Task/Extend-your-language/Tcl/extend-your-language-4.tcl b/Task/Extend-your-language/Tcl/extend-your-language-4.tcl new file mode 100644 index 0000000000..ef0a5536c9 --- /dev/null +++ b/Task/Extend-your-language/Tcl/extend-your-language-4.tcl @@ -0,0 +1,6 @@ +proc loop {varName lowerBound upperBound body} { + upvar 1 $varName var + for {set var $lowerBound} {$var <= $upperBound} {incr var} { + uplevel 1 $body + } +} diff --git a/Task/Extend-your-language/Tcl/extend-your-language-5.tcl b/Task/Extend-your-language/Tcl/extend-your-language-5.tcl new file mode 100644 index 0000000000..6ac2b2e496 --- /dev/null +++ b/Task/Extend-your-language/Tcl/extend-your-language-5.tcl @@ -0,0 +1,8 @@ +proc timestables {M N} { + loop i 1 $M { + loop j 1 $N { + puts "$i x $j = [expr {$i * $j}]" + } + } +} +timestables 3 3 diff --git a/Task/Extreme-floating-point-values/0DESCRIPTION b/Task/Extreme-floating-point-values/0DESCRIPTION new file mode 100644 index 0000000000..b1d89b2987 --- /dev/null +++ b/Task/Extreme-floating-point-values/0DESCRIPTION @@ -0,0 +1,10 @@ +{{omit from|GAP}}{{omit from|BBC BASIC}} +The IEEE floating point specification defines certain 'extreme' floating point values such as minus zero, -0.0, a value distinct from plus zero; not a number, NaN; and plus and minus infinity. + +The task is to use expressions involving other 'normal' floating point values in your language to calculate these, (and maybe other), extreme floating point values in your language and assign them to variables. Print the values of these variables if possible; and show some arithmetic with these values and variables. If your language can directly enter these extreme floating point values then show it. + +
C.f: +* [http://www-users.math.umd.edu/~jkolesar/mait613/floating_point_math.pdf What Every Computer Scientist Should Know About Floating-Point Arithmetic] +* [[Infinity]] +* [[Detect division by zero]] +* [[Literals/Floating point]] diff --git a/Task/Extreme-floating-point-values/AWK/extreme-floating-point-values.awk b/Task/Extreme-floating-point-values/AWK/extreme-floating-point-values.awk new file mode 100644 index 0000000000..0e437f2b62 --- /dev/null +++ b/Task/Extreme-floating-point-values/AWK/extreme-floating-point-values.awk @@ -0,0 +1,34 @@ +BEGIN { + # This requires 1e400 to overflow to infinity. + nzero = -0 + nan = 0 * 1e400 + pinf = 1e400 + ninf = -1e400 + + print "nzero =", nzero + print "nan =", nan + print "pinf =", pinf + print "ninf =", ninf + print + + # When y == 0, sign of x decides if atan2(y, x) is 0 or pi. + print "atan2(0, 0) =", atan2(0, 0) + print "atan2(0, pinf) =", atan2(0, pinf) + print "atan2(0, nzero) =", atan2(0, nzero) + print "atan2(0, ninf) =", atan2(0, ninf) + print + + # From least to most: ninf, -1e200, 1e200, pinf. + print "ninf * -1 =", ninf * -1 + print "pinf * -1 =", pinf * -1 + print "-1e200 > ninf?", (-1e200 > ninf) ? "yes" : "no" + print "1e200 < pinf?", (1e200 < pinf) ? "yes" : "no" + print + + # NaN spreads from input to output. + print "nan test:", (1 + 2 * 3 - 4) / (-5.6e7 + nan) + + # NaN never equals anything. These tests should print "no". + print "nan == nan?", (nan == nan) ? "yes" : "no" + print "nan == 42?", (nan == 42) ? "yes" : "no" +} diff --git a/Task/Extreme-floating-point-values/Ada/extreme-floating-point-values-1.ada b/Task/Extreme-floating-point-values/Ada/extreme-floating-point-values-1.ada new file mode 100644 index 0000000000..3dd9fe906b --- /dev/null +++ b/Task/Extreme-floating-point-values/Ada/extreme-floating-point-values-1.ada @@ -0,0 +1 @@ +subtype Consistent_Float is Float range Float'Range; -- No IEEE ideals diff --git a/Task/Extreme-floating-point-values/Ada/extreme-floating-point-values-2.ada b/Task/Extreme-floating-point-values/Ada/extreme-floating-point-values-2.ada new file mode 100644 index 0000000000..257198bf03 --- /dev/null +++ b/Task/Extreme-floating-point-values/Ada/extreme-floating-point-values-2.ada @@ -0,0 +1,29 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure IEEE is -- Non portable, bad, never do this! + Zero : Float := 0.0; + PInf : Float := 1.0 / Zero; + NInf : Float := -PInf; + PZero : Float := 1.0 / PInf; + NZero : Float := 1.0 / NInf; + NaN : Float := 0.0 / Zero; +begin + Put_Line (" -oo = " & Float'Image (NInf)); + Put_Line (" +oo = " & Float'Image (PInf)); + Put_Line (" NaN = " & Float'Image (NaN)); + Put_Line (" -0 = " & Float'Image (NZero)); + + Put_Line (" -oo < first " & Boolean'Image (NInf < Float'First)); + Put_Line (" +oo > last " & Boolean'Image (PInf > Float'Last)); + Put_Line (" NaN = NaN " & Boolean'Image (NaN = NaN)); + Put_Line (" -0 = 0 " & Boolean'Image (NZero = 0.0)); + Put_Line (" +0 = 0 " & Boolean'Image (PZero = 0.0)); + Put_Line (" +0 < least positive " & Boolean'Image (PZero < Float'Succ (Zero))); + Put_Line (" -0 > biggest negative " & Boolean'Image (NZero > Float'Pred (Zero))); + + -- Validness checks + Put_Line ("Valid -oo is " & Boolean'Image (NInf'Valid)); + Put_Line ("Valid +oo is " & Boolean'Image (PInf'Valid)); + Put_Line ("Valid NaN is " & Boolean'Image (NaN'Valid)); + +end IEEE; diff --git a/Task/Extreme-floating-point-values/C/extreme-floating-point-values-1.c b/Task/Extreme-floating-point-values/C/extreme-floating-point-values-1.c new file mode 100644 index 0000000000..1c8e9dc8ad --- /dev/null +++ b/Task/Extreme-floating-point-values/C/extreme-floating-point-values-1.c @@ -0,0 +1,31 @@ +#include + +int main() +{ + double inf = 1/0.0; + double minus_inf = -1/0.0; + double minus_zero = -1/ inf ; + double nan = 0.0/0.0; + + printf("positive infinity: %f\n",inf); + printf("negative infinity: %f\n",minus_inf); + printf("negative zero: %f\n",minus_zero); + printf("not a number: %f\n",nan); + + /* some arithmetic */ + + printf("+inf + 2.0 = %f\n",inf + 2.0); + printf("+inf - 10.1 = %f\n",inf - 10.1); + printf("+inf + -inf = %f\n",inf + minus_inf); + printf("0.0 * +inf = %f\n",0.0 * inf); + printf("1.0/-0.0 = %f\n",1.0/minus_zero); + printf("NaN + 1.0 = %f\n",nan + 1.0); + printf("NaN + NaN = %f\n",nan + nan); + + /* some comparisons */ + + printf("NaN == NaN = %s\n",nan == nan ? "true" : "false"); + printf("0.0 == -0.0 = %s\n",0.0 == minus_zero ? "true" : "false"); + + return 0; +} diff --git a/Task/Extreme-floating-point-values/C/extreme-floating-point-values-2.c b/Task/Extreme-floating-point-values/C/extreme-floating-point-values-2.c new file mode 100644 index 0000000000..9b8214b9ad --- /dev/null +++ b/Task/Extreme-floating-point-values/C/extreme-floating-point-values-2.c @@ -0,0 +1,31 @@ +#include +#include +#include + +char * bits(double v) { + static char s[sizeof(double) * (CHARBITS + 1)]; + int n, i, j; + unsigned char *c = (void*)&v; + for (i = n = 0; i < sizeof(double); i++) { + for (j = 1 << (CHARBITS - 1); j; j >>= 1) + s[n++] = (c[i] & j) ? '1' : '.'; + s[n++] = ' '; + } + s[n-1] = 0; + return s; +} + +int main(void) +{ + double x[] = { + 1.0, -1.0, 1.0/256, 0.0, // "normal" values + -0.0, INFINITY, -INFINITY, NAN, -NAN, // special + DBL_MAX, DBL_MIN // not required by task + }; + int i; + + for (i = 0; i < sizeof(x) / sizeof(x[0]); i++) + printf("%s | %g\n", bits(x[i]), x[i]); + + return 0; +} diff --git a/Task/Extreme-floating-point-values/D/extreme-floating-point-values-1.d b/Task/Extreme-floating-point-values/D/extreme-floating-point-values-1.d new file mode 100644 index 0000000000..ea6e5fc545 --- /dev/null +++ b/Task/Extreme-floating-point-values/D/extreme-floating-point-values-1.d @@ -0,0 +1,64 @@ +// Compile this module without -O + +import std.stdio: writeln, writefln; +import std.string: format; +import std.math: NaN, getNaNPayload; + +void show(T)() { + static string toHex(T x) { + string result; + ubyte* ptr = cast(ubyte*)&x; + foreach (i; 0 .. T.sizeof) + result = format("%02x", ptr[i]) ~ result; + return result; + } + + enum string name = T.stringof; + writeln("Computed extreme ", name, " values:"); + + T zero = 0.0; + T pos_inf = (cast(T)1.0) / zero; + writeln(" ", name, " +oo = ", pos_inf); + + T neg_inf = -pos_inf; + writeln(" ", name, " -oo = ", neg_inf); + + T pos_zero = (cast(T)1.0) / pos_inf; + writeln(" ", name, " +0 (pos_zero) = ", pos_zero); + + T neg_zero = (cast(T)1.0) / neg_inf; + writeln(" ", name, " -0 = ", neg_zero); + + T nan = zero / pos_zero; + writefln(" " ~ name ~ " zero / pos_zero = %f %s", nan, toHex(nan)); + writeln(); + + writeln("Some ", T.stringof, " properties and literals:"); + writeln(" ", name, " +oo = ", T.infinity); + writeln(" ", name, " -oo = ", -T.infinity); + writeln(" ", name, " +0 = ", (cast(T)0.0)); + writeln(" ", name, " -0 = ", (cast(T)-0.0)); + writefln(" " ~ name ~ " nan = %f %s", T.nan, toHex(T.nan)); + writefln(" " ~ name ~ " init = %f %s", T.init, toHex(T.init)); + writeln(" ", name, " epsilon = ", T.epsilon); + writeln(" ", name, " max = ", T.max); + writeln(" ", name, " -max = ", -T.max); + writeln(" ", name, " min_normal = ", -T.min_normal); + writeln("-----------------------------"); +} + +void main() { + show!float(); + show!double(); + show!real(); + + writeln("Largest possible payload for float, double and real NaNs:"); + float f1 = NaN(0x3F_FFFF); + writeln(getNaNPayload(f1)); + + double f2 = NaN(0x3_FFFF_FFFF_FFFF); + writeln(getNaNPayload(f2)); + + real f3 = NaN(0x3FFF_FFFF_FFFF_FFFF); + writeln(getNaNPayload(f3)); +} diff --git a/Task/Extreme-floating-point-values/D/extreme-floating-point-values-2.d b/Task/Extreme-floating-point-values/D/extreme-floating-point-values-2.d new file mode 100644 index 0000000000..7967d9993a --- /dev/null +++ b/Task/Extreme-floating-point-values/D/extreme-floating-point-values-2.d @@ -0,0 +1,13 @@ +import std.math: FloatingPointControl; + +void main() { + // Enable hardware exceptions for division by zero, overflow + // to infinity, invalid operations, and uninitialized + // floating-point variables. + FloatingPointControl fpc; + fpc.enableExceptions(FloatingPointControl.severeExceptions); + + double f0 = 0.0; + double y1 = f0 / f0; // generates hardware exception + // unless it's compiled with -O) +} diff --git a/Task/Extreme-floating-point-values/Delphi/extreme-floating-point-values.delphi b/Task/Extreme-floating-point-values/Delphi/extreme-floating-point-values.delphi new file mode 100644 index 0000000000..7dbeeb718c --- /dev/null +++ b/Task/Extreme-floating-point-values/Delphi/extreme-floating-point-values.delphi @@ -0,0 +1,39 @@ +program Floats; + +{$APPTYPE CONSOLE} + +uses + SysUtils; + +var + PlusInf, MinusInf, NegZero, NotANum: Double; + +begin + PlusInf:= 1.0/0.0; + MinusInf:= -1.0/0.0; + NegZero:= -1.0/PlusInf; + NotANum:= 0.0/0.0; + + Writeln('Positive Infinity: ', PlusInf); // +Inf + Writeln('Negative Infinity: ', MinusInf); // -Inf + Writeln('Negative Zero: ', NegZero); // -0.0 + Writeln('Not a Number: ', NotANum); // Nan + +// allowed arithmetic + Writeln('+Inf + 2.0 = ', PlusInf + 2.0); // +Inf + Writeln('+Inf - 10.1 = ', PlusInf - 10.1); // +Inf + Writeln('NaN + 1.0 = ', NotANum + 1.0); // Nan + Writeln('NaN + NaN = ', NotANum + NotANum); // Nan + +// throws exception + try + Writeln('+inf + -inf = ', PlusInf + MinusInf); // EInvalidOp + Writeln('0.0 * +inf = ', 0.0 * PlusInf); // EInlalidOp + Writeln('1.0/-0.0 = ', 1.0 / NegZero); // EZeroDivide + except + on E:Exception do + Writeln(E.Classname, ': ', E.Message); + end; + + Readln; +end. diff --git a/Task/Extreme-floating-point-values/Euphoria/extreme-floating-point-values.euphoria b/Task/Extreme-floating-point-values/Euphoria/extreme-floating-point-values.euphoria new file mode 100644 index 0000000000..7d884e0064 --- /dev/null +++ b/Task/Extreme-floating-point-values/Euphoria/extreme-floating-point-values.euphoria @@ -0,0 +1,16 @@ +constant inf = 1E400 +constant minus_inf = -inf +constant nan = 0*inf + +printf(1,"positive infinity: %f\n", inf) +printf(1,"negative infinity: %f\n", minus_inf) +printf(1,"not a number: %f\n", nan) + +-- some arithmetic + +printf(1,"+inf + 2.0 = %f\n", inf + 2.0) +printf(1,"+inf - 10.1 = %f\n", inf - 10.1) +printf(1,"+inf + -inf = %f\n", inf + minus_inf) +printf(1,"0.0 * +inf = %f\n", 0.0 * inf) +printf(1,"NaN + 1.0 = %f\n", nan + 1.0) +printf(1,"NaN + NaN = %f\n", nan + nan) diff --git a/Task/Extreme-floating-point-values/Forth/extreme-floating-point-values.fth b/Task/Extreme-floating-point-values/Forth/extreme-floating-point-values.fth new file mode 100644 index 0000000000..f312083f0e --- /dev/null +++ b/Task/Extreme-floating-point-values/Forth/extreme-floating-point-values.fth @@ -0,0 +1,5 @@ + 1e 0e f/ f. \ inf +-1e 0e f/ f. \ inf (output bug: should say "-inf") +-1e 0e f/ f0< . \ -1 (true, it is -inf) + 0e 0e f/ f. \ nan +-1e 0e f/ 1/f f0< . \ 0 (false, can't represent IEEE negative zero) diff --git a/Task/Extreme-floating-point-values/Go/extreme-floating-point-values.go b/Task/Extreme-floating-point-values/Go/extreme-floating-point-values.go new file mode 100644 index 0000000000..a1cb7ef606 --- /dev/null +++ b/Task/Extreme-floating-point-values/Go/extreme-floating-point-values.go @@ -0,0 +1,78 @@ +package main + +import ( + "fmt" + "math" +) + +func main() { + // compute "extreme values" from non-extreme values + var zero float64 // zero is handy. + var negZero, posInf, negInf, nan float64 // values to compute. + negZero = zero * -1 + posInf = 1 / zero + negInf = -1 / zero + nan = zero / zero + + // print extreme values stored in variables + fmt.Println(negZero, posInf, negInf, nan) + + // directly obtain extreme values + fmt.Println(math.Float64frombits(1<<63), + math.Inf(1), math.Inf(-1), math.NaN()) + + // validate some arithmetic on extreme values + fmt.Println() + validateNaN(negInf+posInf, "-Inf + Inf") + validateNaN(0*posInf, "0 * Inf") + validateNaN(posInf/posInf, "Inf / Inf") + // mod is specifically named in "What every computer scientist..." + // Go math package doc lists many special cases for other package functions. + validateNaN(math.Mod(posInf, 1), "Inf % 1") + validateNaN(1+nan, "1 + NaN") + validateZero(1/posInf, "1 / Inf") + validateGT(posInf, math.MaxFloat64, "Inf > max value") + validateGT(-math.MaxFloat64, negInf, "-Inf < max neg value") + validateNE(nan, nan, "NaN != NaN") + validateEQ(negZero, 0, "-0 == 0") +} + +func validateNaN(n float64, op string) { + if math.IsNaN(n) { + fmt.Println(op, "-> NaN") + } else { + fmt.Println("!!! Expected NaN from", op, " Found", n) + } +} + +func validateZero(n float64, op string) { + if n == 0 { + fmt.Println(op, "-> 0") + } else { + fmt.Println("!!! Expected 0 from", op, " Found", n) + } +} + +func validateGT(a, b float64, op string) { + if a > b { + fmt.Println(op) + } else { + fmt.Println("!!! Expected", op, " Found not true.") + } +} + +func validateNE(a, b float64, op string) { + if a == b { + fmt.Println("!!! Expected", op, " Found not true.") + } else { + fmt.Println(op) + } +} + +func validateEQ(a, b float64, op string) { + if a == b { + fmt.Println(op) + } else { + fmt.Println("!!! Expected", op, " Found not true.") + } +} diff --git a/Task/Extreme-floating-point-values/Java/extreme-floating-point-values.java b/Task/Extreme-floating-point-values/Java/extreme-floating-point-values.java new file mode 100644 index 0000000000..55d9017fcf --- /dev/null +++ b/Task/Extreme-floating-point-values/Java/extreme-floating-point-values.java @@ -0,0 +1,16 @@ +public class Extreme { + public static void main(String[] args) { + double negInf = -1.0 / 0.0; //also Double.NEGATIVE_INFINITY + double inf = 1.0 / 0.0; //also Double.POSITIVE_INFINITY + double nan = 0.0 / 0.0; //also Double.NaN + double negZero = -2.0 / inf; + + System.out.println("Negative inf: " + negInf); + System.out.println("Positive inf: " + inf); + System.out.println("NaN: " + nan); + System.out.println("Negative 0: " + negZero); + System.out.println("inf + -inf: " + (inf + negInf)); + System.out.println("0 * NaN: " + (0 * nan)); + System.out.println("NaN == NaN: " + (nan == nan)); + } +} diff --git a/Task/Extreme-floating-point-values/Perl/extreme-floating-point-values-1.pl b/Task/Extreme-floating-point-values/Perl/extreme-floating-point-values-1.pl new file mode 100644 index 0000000000..4d0ddc8cd4 --- /dev/null +++ b/Task/Extreme-floating-point-values/Perl/extreme-floating-point-values-1.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl +use strict; +use warnings; + +my $nzero = -0.0; +my $nan = 0 + "nan"; +my $pinf = +"inf"; +my $ninf = -"inf"; + +printf "\$nzero = %.1f\n", $nzero; +print "\$nan = $nan\n"; +print "\$pinf = $pinf\n"; +print "\$ninf = $ninf\n\n"; + +printf "atan2(0, 0) = %g\n", atan2(0, 0); +printf "atan2(0, \$nzero) = %g\n", atan2(0, $nzero); +printf "sin(\$pinf) = %g\n", sin($pinf); +printf "\$pinf / -1 = %g\n", $pinf / -1; +printf "\$ninf + 1e100 = %g\n\n", $ninf + 1e100; + +printf "nan test: %g\n", (1 + 2 * 3 - 4) / (-5.6e7 * $nan); +printf "nan == nan? %s\n", ($nan == $nan) ? "yes" : "no"; +printf "nan == 42? %s\n", ($nan == 42) ? "yes" : "no"; diff --git a/Task/Extreme-floating-point-values/Perl/extreme-floating-point-values-2.pl b/Task/Extreme-floating-point-values/Perl/extreme-floating-point-values-2.pl new file mode 100644 index 0000000000..c64127fbd5 --- /dev/null +++ b/Task/Extreme-floating-point-values/Perl/extreme-floating-point-values-2.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Math::BigInt; + +my $nan = Math::BigInt->bnan(); +my $pinf = Math::BigInt->binf(); +my $ninf = Math::BigInt->binf('-'); + +print "\$nan = $nan\n"; +print "\$pinf = $pinf\n"; +print "\$ninf = $ninf\n\n"; + +my $huge = Math::BigInt->new("123456789"); +$huge->bmul($huge)->bmul($huge)->bmul($huge); + +print "\$huge = $huge\n"; +printf "\$ninf + \$huge = %s\n", $ninf->copy()->badd($huge); +printf "\$pinf - \$huge = %s\n", $pinf->copy()->bsub($huge); +printf "\$nan * \$huge = %s\n", $nan->copy()->bmul($huge); +printf "\$nan == \$nan? %s\n", defined($nan->bcmp($nan)) ? "maybe" : "no"; +printf "\$nan == \$huge? %s\n", defined($nan->bcmp($huge)) ? "maybe" : "no"; diff --git a/Task/Extreme-floating-point-values/PicoLisp/extreme-floating-point-values.l b/Task/Extreme-floating-point-values/PicoLisp/extreme-floating-point-values.l new file mode 100644 index 0000000000..431f8a0585 --- /dev/null +++ b/Task/Extreme-floating-point-values/PicoLisp/extreme-floating-point-values.l @@ -0,0 +1,7 @@ +(load "@lib/math.l") + +: (exp 1000.0) # Too large for IEEE floats +-> T + +: (+ 1 2 NIL 3) # NaN propagates +-> NIL diff --git a/Task/Extreme-floating-point-values/Python/extreme-floating-point-values-1.py b/Task/Extreme-floating-point-values/Python/extreme-floating-point-values-1.py new file mode 100644 index 0000000000..36df1ce343 --- /dev/null +++ b/Task/Extreme-floating-point-values/Python/extreme-floating-point-values-1.py @@ -0,0 +1,42 @@ +>>> # Extreme values from expressions +>>> inf = 1e234 * 1e234 +>>> _inf = 1e234 * -1e234 +>>> _zero = 1 / _inf +>>> nan = inf + _inf +>>> inf, _inf, _zero, nan +(inf, -inf, -0.0, nan) +>>> # Print +>>> for value in (inf, _inf, _zero, nan): print (value) + +inf +-inf +-0.0 +nan +>>> # Extreme values from other means +>>> float('nan') +nan +>>> float('inf') +inf +>>> float('-inf') +-inf +>>> -0. +-0.0 +>>> # Some arithmetic +>>> nan == nan +False +>>> nan is nan +True +>>> 0. == -0. +True +>>> 0. is -0. +False +>>> inf + _inf +nan +>>> 0.0 * nan +nan +>>> nan * 0.0 +nan +>>> 0.0 * inf +nan +>>> inf * 0.0 +nan diff --git a/Task/Extreme-floating-point-values/Python/extreme-floating-point-values-2.py b/Task/Extreme-floating-point-values/Python/extreme-floating-point-values-2.py new file mode 100644 index 0000000000..ee3d3013e9 --- /dev/null +++ b/Task/Extreme-floating-point-values/Python/extreme-floating-point-values-2.py @@ -0,0 +1,8 @@ +>>> # But note! +>>> 1 / -0.0 + +Traceback (most recent call last): + File "", line 1, in + 1 / -0.0 +ZeroDivisionError: float division by zero +>>> # (Not minus infinity) diff --git a/Task/Extreme-floating-point-values/R/extreme-floating-point-values.r b/Task/Extreme-floating-point-values/R/extreme-floating-point-values.r new file mode 100644 index 0000000000..9934b374c6 --- /dev/null +++ b/Task/Extreme-floating-point-values/R/extreme-floating-point-values.r @@ -0,0 +1,3 @@ +# 0 and -0 are recognized but are both printed as simply 0. +1/c(0, -0, Inf, -Inf, NaN) +# Inf -Inf 0 0 NaN diff --git a/Task/Extreme-floating-point-values/Ruby/extreme-floating-point-values.rb b/Task/Extreme-floating-point-values/Ruby/extreme-floating-point-values.rb new file mode 100644 index 0000000000..e06b9918f4 --- /dev/null +++ b/Task/Extreme-floating-point-values/Ruby/extreme-floating-point-values.rb @@ -0,0 +1,10 @@ +1.0/0.0 +# Infinity +-1.0/0.0 +# -Infinity +0.0/0.0 +# NaN +0.0 +# 0.0 +-0.0 +# -0.0 diff --git a/Task/Extreme-floating-point-values/Scheme/extreme-floating-point-values.ss b/Task/Extreme-floating-point-values/Scheme/extreme-floating-point-values.ss new file mode 100644 index 0000000000..434cc79e10 --- /dev/null +++ b/Task/Extreme-floating-point-values/Scheme/extreme-floating-point-values.ss @@ -0,0 +1,9 @@ +(define infinity (/ 1.0 0.0)) +(define minus-infinity (- infinity)) +(define zero 0.0) +(define minus-zero (- zero)) +(define not-a-number (/ 0.0 0.0)) + +(equal? (list infinity minus-infinity zero minus-zero not-a-number) + (list +inf.0 -inf.0 0.0 -0.0 +nan.0)) +; #t diff --git a/Task/Extreme-floating-point-values/Tcl/extreme-floating-point-values-1.tcl b/Task/Extreme-floating-point-values/Tcl/extreme-floating-point-values-1.tcl new file mode 100644 index 0000000000..1bc6acbab5 --- /dev/null +++ b/Task/Extreme-floating-point-values/Tcl/extreme-floating-point-values-1.tcl @@ -0,0 +1,16 @@ +% package require Tcl 8.5 +8.5.2 +% expr inf+1 +Inf +% set inf_val [expr {1.0 / 0.0}] +Inf +% set neginf_val [expr {-1.0 / 0.0}] +-Inf +% set negzero_val [expr {1.0 / $neginf_val}] +-0.0 +% expr {0.0 / 0.0} +domain error: argument not in valid range +% expr nan +domain error: argument not in valid range +% expr {1/-inf} +-0.0 diff --git a/Task/Extreme-floating-point-values/Tcl/extreme-floating-point-values-2.tcl b/Task/Extreme-floating-point-values/Tcl/extreme-floating-point-values-2.tcl new file mode 100644 index 0000000000..3c6da4a654 --- /dev/null +++ b/Task/Extreme-floating-point-values/Tcl/extreme-floating-point-values-2.tcl @@ -0,0 +1,7 @@ +% binary scan [binary format q nan] q nan +1 +% puts $nan +NaN +% # Show that it is a real NaN in there +% expr {$nan+0} +can't use non-numeric floating-point value as operand of "+" diff --git a/Task/FizzBuzz/C++/fizzbuzz-1.cpp b/Task/FizzBuzz/C++/fizzbuzz-1.cpp new file mode 100644 index 0000000000..cedbea43a2 --- /dev/null +++ b/Task/FizzBuzz/C++/fizzbuzz-1.cpp @@ -0,0 +1,18 @@ +#include + +using namespace std; +int main () { + + int i; + for (i = 0; i <= 100; i++) { + if ((i % 15) == 0) + cout << "FizzBuzz" << endl; + else if ((i % 3) == 0) + cout << "Fizz" << endl; + else if ((i % 5) == 0) + cout << "Buzz" << endl; + else + cout << i << endl; + } + return 0; +} diff --git a/Task/FizzBuzz/C++/fizzbuzz-2.cpp b/Task/FizzBuzz/C++/fizzbuzz-2.cpp new file mode 100644 index 0000000000..3688c21605 --- /dev/null +++ b/Task/FizzBuzz/C++/fizzbuzz-2.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; + +int main() +{ + for (int i = 0; i <= 100; ++i) + { + bool fizz = (i % 3) == 0; + bool buzz = (i % 5) == 0; + if (fizz) + cout << "Fizz"; + if (buzz) + cout << "Buzz"; + if (!fizz && !buzz) + cout << i; + cout << endl; + } + return 0; +} diff --git a/Task/FizzBuzz/C++/fizzbuzz-3.cpp b/Task/FizzBuzz/C++/fizzbuzz-3.cpp new file mode 100644 index 0000000000..d9974c72f9 --- /dev/null +++ b/Task/FizzBuzz/C++/fizzbuzz-3.cpp @@ -0,0 +1,48 @@ +#include + +template +struct fizzbuzz : fizzbuzz +{ + fizzbuzz() + { std::cout << n << std::endl; } +}; + +template +struct fizzbuzz : fizzbuzz +{ + fizzbuzz() + { std::cout << "FizzBuzz" << std::endl; } +}; + +template +struct fizzbuzz : fizzbuzz +{ + fizzbuzz() + { std::cout << "Fizz" << std::endl; } +}; + +template +struct fizzbuzz : fizzbuzz +{ + fizzbuzz() + { std::cout << "Buzz" << std::endl; } +}; + +template <> +struct fizzbuzz<0,0,0> +{ + fizzbuzz() + { std::cout << 0 << std::endl; } +}; + +template +struct fb_run +{ + fizzbuzz fb; +}; + +int main() +{ + fb_run<100> fb; + return 0; +} diff --git a/Task/FizzBuzz/C++/fizzbuzz-4.cpp b/Task/FizzBuzz/C++/fizzbuzz-4.cpp new file mode 100644 index 0000000000..d00cefbbe2 --- /dev/null +++ b/Task/FizzBuzz/C++/fizzbuzz-4.cpp @@ -0,0 +1,164 @@ +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace boost; + +/////////////////////////////////////////////////////////////////////////////// +// exponentiation calculations +template struct POWER_CORE : POWER_CORE{}; + +template +struct POWER_CORE +{ + enum : int { val = accum }; +}; + +template struct POWER : POWER_CORE<1, base, exp>{}; + +/////////////////////////////////////////////////////////////////////////////// +// # of digit calculations +template struct NUM_DIGITS_CORE : NUM_DIGITS_CORE{}; + +template +struct NUM_DIGITS_CORE +{ + enum : int { val = depth}; +}; + +template struct NUM_DIGITS : NUM_DIGITS_CORE<0, i>{}; + +template <> +struct NUM_DIGITS<0> +{ + enum : int { val = 1 }; +}; + +/////////////////////////////////////////////////////////////////////////////// +// Convert digit to character (1 -> '1') +template +struct DIGIT_TO_CHAR +{ + enum : char{ val = i + 48 }; +}; + +/////////////////////////////////////////////////////////////////////////////// +// Find the digit at a given offset into a number of the form 0000000017 +template // place -> [0 .. 10] +struct DIGIT_AT +{ + enum : char{ val = (i / POWER<10, place>::val) % 10 }; +}; + +struct NULL_CHAR +{ + enum : char{ val = '\0' }; +}; + +/////////////////////////////////////////////////////////////////////////////// +// Convert the digit at a given offset into a number of the form '0000000017' to a character +template // place -> [0 .. 9] + struct ALT_CHAR : DIGIT_TO_CHAR< DIGIT_AT::val >{}; + +/////////////////////////////////////////////////////////////////////////////// +// Convert the digit at a given offset into a number of the form '17' to a character + +// Template description, with specialization to generate null characters for out of range offsets +template + struct OFFSET_CHAR_CORE_CHECKED{}; +template + struct OFFSET_CHAR_CORE_CHECKED : NULL_CHAR{}; +template + struct OFFSET_CHAR_CORE_CHECKED : ALT_CHAR{}; + +// Perform the range check and pass it on +template + struct OFFSET_CHAR_CORE : OFFSET_CHAR_CORE_CHECKED{}; + +// Calc the number of digits and pass it on +template + struct OFFSET_CHAR : OFFSET_CHAR_CORE::val>{}; + +/////////////////////////////////////////////////////////////////////////////// +// Integer to char* template. Works on unsigned ints. +template +struct IntToStr +{ + const static char str[]; + typedef typename mpl::string< + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + /*OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val,*/ + NULL_CHAR::val>::type type; +}; + +template +const char IntToStr::str[] = +{ + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + OFFSET_CHAR::val, + NULL_CHAR::val +}; + +template +struct IF +{ + typedef Then RET; +}; + +template +struct IF +{ + typedef Else RET; +}; + + +template < typename Str1, typename Str2 > +struct concat : mpl::insert_range::type, Str2> {}; +template +struct concat3 : mpl::insert_range::type, typename concat::type > {}; + +typedef typename mpl::string<'f','i','z','z'>::type fizz; +typedef typename mpl::string<'b','u','z','z'>::type buzz; +typedef typename mpl::string<'\r', '\n'>::type mpendl; +typedef typename concat::type fizzbuzz; + +// discovered boost mpl limitation on some length + +template +struct FizzBuzz +{ + typedef typename concat3::type, typename IF::type >::RET >::RET >::RET, typename mpendl::type>::type type; +}; + +template <> +struct FizzBuzz<1> +{ + typedef mpl::string<'1','\r','\n'>::type type; +}; + +int main(int argc, char** argv) +{ + const int n = 7; + std::cout << mpl::c_str::type>::value << std::endl; + return 0; +} diff --git a/Task/FizzBuzz/CLIPS/fizzbuzz.clips b/Task/FizzBuzz/CLIPS/fizzbuzz.clips new file mode 100644 index 0000000000..052963eb4c --- /dev/null +++ b/Task/FizzBuzz/CLIPS/fizzbuzz.clips @@ -0,0 +1,26 @@ +(deffacts count + (count-to 100) +) + +(defrule print-numbers + (count-to ?max) + => + (loop-for-count (?num ?max) do + (if + (= (mod ?num 3) 0) + then + (printout t "Fizz") + ) + (if + (= (mod ?num 5) 0) + then + (printout t "Buzz") + ) + (if + (and (> (mod ?num 3) 0) (> (mod ?num 5) 0)) + then + (printout t ?num) + ) + (priint depth, unsigned int i> struct NUM_DIGITS_CORE : NUM_DIGITS_COREntout t crlf) + ) +) diff --git a/Task/FizzBuzz/CMake/fizzbuzz.cmake b/Task/FizzBuzz/CMake/fizzbuzz.cmake new file mode 100644 index 0000000000..8fb50ec595 --- /dev/null +++ b/Task/FizzBuzz/CMake/fizzbuzz.cmake @@ -0,0 +1,13 @@ +foreach(i RANGE 1 100) + math(EXPR off3 "${i} % 3") + math(EXPR off5 "${i} % 5") + if(NOT off3 AND NOT off5) + message(FizzBuzz) + elseif(NOT off3) + message(Fizz) + elseif(NOT off5) + message(Buzz) + else() + message(${i}) + endif() +endforeach(i) diff --git a/Task/FizzBuzz/COBOL/fizzbuzz-1.cobol b/Task/FizzBuzz/COBOL/fizzbuzz-1.cobol new file mode 100644 index 0000000000..034abf7411 --- /dev/null +++ b/Task/FizzBuzz/COBOL/fizzbuzz-1.cobol @@ -0,0 +1,36 @@ + * FIZZBUZZ.COB + * cobc -x -g FIZZBUZZ.COB + * + IDENTIFICATION DIVISION. + PROGRAM-ID. fizzbuzz. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 CNT PIC 9(03) VALUE 1. + 01 REM PIC 9(03) VALUE 0. + 01 QUOTIENT PIC 9(03) VALUE 0. + PROCEDURE DIVISION. + * + PERFORM UNTIL CNT > 100 + DIVIDE 15 INTO CNT GIVING QUOTIENT REMAINDER REM + IF REM = 0 + THEN + DISPLAY "FizzBuzz " WITH NO ADVANCING + ELSE + DIVIDE 3 INTO CNT GIVING QUOTIENT REMAINDER REM + IF REM = 0 + THEN + DISPLAY "Fizz " WITH NO ADVANCING + ELSE + DIVIDE 5 INTO CNT GIVING QUOTIENT REMAINDER REM + IF REM = 0 + THEN + DISPLAY "Buzz " WITH NO ADVANCING + ELSE + DISPLAY CNT " " WITH NO ADVANCING + END-IF + END-IF + END-IF + ADD 1 TO CNT + END-PERFORM + DISPLAY "" + STOP RUN. diff --git a/Task/FizzBuzz/COBOL/fizzbuzz-2.cobol b/Task/FizzBuzz/COBOL/fizzbuzz-2.cobol new file mode 100644 index 0000000000..c81e3e043e --- /dev/null +++ b/Task/FizzBuzz/COBOL/fizzbuzz-2.cobol @@ -0,0 +1,16 @@ +Identification division. +Program-id. fizz-buzz. + +Data division. +Working-storage section. + +01 num pic 999. + +Procedure division. + Perform varying num from 1 by 1 until num > 100 + if function mod (num, 15) = 0 then display "fizzbuzz" + else if function mod (num, 3) = 0 then display "fizz" + else if function mod (num, 5) = 0 then display "buzz" + else display num + end-perform. + Stop run. diff --git a/Task/FizzBuzz/Cduce/fizzbuzz.cduce b/Task/FizzBuzz/Cduce/fizzbuzz.cduce new file mode 100644 index 0000000000..97d7489931 --- /dev/null +++ b/Task/FizzBuzz/Cduce/fizzbuzz.cduce @@ -0,0 +1,18 @@ +(* FizzBuzz in CDuce *) + +let format (n : Int) : Latin1 = + if (n mod 3 = 0) || (n mod 5 = 0) then "FizzBuzz" + else if (n mod 5 = 0) then "Buzz" + else if (n mod 3 = 0) then "Fizz" + else string_of (n);; + +let fizz (n : Int, size : Int) : _ = + print (format (n) @ "\n"); + if (n = size) then + n = 0 (* do nothing *) + else + fizz(n + 1, size);; + +let fizbuzz (size : Int) : _ = fizz (1, size);; + +let _ = fizbuzz(100);; diff --git a/Task/FizzBuzz/Chef/fizzbuzz.chef b/Task/FizzBuzz/Chef/fizzbuzz.chef new file mode 100644 index 0000000000..891e88acec --- /dev/null +++ b/Task/FizzBuzz/Chef/fizzbuzz.chef @@ -0,0 +1,187 @@ +Irish Soda Bread with Club Soda. + +This is FizzBuzz + +Ingredients. +1 l buttermilk + +Method. +Take buttermilk from refrigerator. +Shake the buttermilk. + Put buttermilk into the 6th mixing bowl. + Serve with club soda. + Pour contents of the 1st mixing bowl into the 1st baking dish. + Clean the 1st mixing bowl. +Watch the buttermilk until shaked. + +Serves 1. + +Club Soda. + +Gets whether to print fizz buzz fizzbuzz or number. + +Ingredients. +70 g flour +105 g salt +122 ml milk +66 g sugar +117 ml vegetable oil +3 cups fizzle +5 cups seltzer +1 cup bmilk +1 cup ice +1 cup baking soda +1 g oregano +32 ml vinegar +1 g thyme +1 g sage + +Method. +Put milk into the 1st mixing bowl. +Put salt into the 1st mixing bowl. +Put flour into the 1st mixing bowl. +Put vinegar into the 1st mixing bowl. +Put milk into the 1st mixing bowl. +Stir the 1st mixing bowl for 5 minutes. +Liquify contents of the 1st mixing bowl. +Put fizzle into the 3rd mixing bowl. +Combine seltzer into the 3rd mixing bowl. +Fold bmilk into the 6th mixing bowl. +Put bmilk into the 6th mixing bowl. +Put seltzer into the 6th mixing bowl. +Put bmilk into the 6th mixing bowl. +Serve with moist cake. +Fold bmilk into the 1st mixing bowl. +Fold sage into the 6th mixing bowl. +Fold sage into the 6th mixing bowl. +Put bmilk into the 4th mixing bowl. +Remove seltzer from the 4th mixing bowl. +Fold oregano into the 4th mixing bowl. +Smell the oregano. + Fold bmilk into the 6th mixing bowl. + Put bmilk into the 6th mixing bowl. + Put fizzle into the 6th mixing bowl. + Put bmilk into the 6th mixing bowl. + Serve with moist cake. + Fold bmilk into the 1st mixing bowl. + Fold sage into the 6th mixing bowl. + Fold sage into the 6th mixing bowl. + Put bmilk into the 4th mixing bowl. + Remove fizzle from the 4th mixing bowl. + Fold oregano into the 4th mixing bowl. + Crush the oregano. + Clean the 1st mixing bowl. + Fold bmilk into the 6th mixing bowl. + Put bmilk into the 1st mixing bowl. + Refrigerate. + Grind until crushed. + Refrigerate. +Shuffle until smelled. +Clean the 1st mixing bowl. +Put milk into the 1st mixing bowl. +Put vegetable oil into the 1st mixing bowl. +Put sugar into the 1st mixing bowl. +Put vinegar into the 1st mixing bowl. +Put milk into the 1st mixing bowl. +Stir the 1st mixing bowl for 5 minutes. +Liquify contents of the 1st mixing bowl. +Fold baking soda into the 3rd mixing bowl. +Fold bmilk into the 6th mixing bowl. +Put bmilk into the 6th mixing bowl. +Put baking soda into the 6th mixing bowl. +Put bmilk into the 6th mixing bowl. +Serve with moist cake. +Fold bmilk into the 1st mixing bowl. +Fold sage into the 6th mixing bowl. +Fold sage into the 6th mixing bowl. +Put bmilk into the 4th mixing bowl. +Remove baking soda from the 4th mixing bowl. +Fold oregano into the 4th mixing bowl. +Separate the oregano. + Refrigerate. +Part until separated. +Put fizzle into the 6th mixing bowl. +Serve with club soda. +Stir the 1st mixing bowl for 1 minute. +Stir the 1st mixing bowl for 7 minutes. +Stir the 1st mixing bowl for 1 minute. +Stir the 1st mixing bowl for 7 minutes. +Stir the 1st mixing bowl for 5 minutes. +Fold the oregano into the 1st mixing bowl. +Fold the oregano into the 1st mixing bowl. +Fold the oregano into the 1st mixing bowl. +Fold the oregano into the 1st mixing bowl. +Fold the oregano into the 1st mixing bowl. +Refrigerate. + +Moist cake. + +Mods a number + +Ingredients. +1 cup chocolate +70 g wheat flour +1 cup white chocolate chips +1 cup baking powder +105 g honey +5 cups syrup +1 g vanilla +1 g rosemary + +Method. +Fold chocolate into the 6th mixing bowl. +Fold syrup into the 6th mixing bowl. +Clean the 1st mixing bowl. +Put chocolate into the 5th mixing bowl. +Fold wheat flour into the 5th mixing bowl. +Put white chocolate chips into the 5th mixing bowl. +Remove white chocolate chips from the 5th mixing bowl. +Fold baking powder into the 5th mixing bowl. +Put baking powder into the 5th mixing bowl. +Fold honey into the 5th mixing bowl. +Sift the wheat flour. + Put honey into the 5th mixing bowl. + Add white chocolate chips into the 5th mixing bowl. + Fold honey into the 5th mixing bowl. + Put honey into the 5th mixing bowl. + Remove syrup from the 5th mixing bowl. + Fold vanilla into the 5th mixing bowl. + Sprinkle the vanilla. + Put white chocolate chips into the 5th mixing bowl. + Remove white chocolate chips from the 5th mixing bowl. + Fold rosemary into the 5th mixing bowl. + Set aside. + Move until sprinkled. + Recite the rosemary. + Put white chocolate chips into the 5th mixing bowl. + Remove white chocolate chips from the 5th mixing bowl. + Fold honey into the 5th mixing bowl. + Put baking powder into the 5th mixing bowl. + Add white chocolate chips into the 5th mixing bowl. + Fold baking powder into the 5th mixing bowl. + Set aside. + Repeat until recited. + Put white chocolate chips into the 5th mixing bowl. + Fold rosemary into the 5th mixing bowl. +Shuffle the wheat flour until sifted. +Put the baking powder into the 5th mixing bowl. +Combine syrup into the 5th mixing bowl. +Fold honey into the 5th mixing bowl. +Put chocolate into the 5th mixing bowl. +Remove honey from the 5th mixing bowl. +Fold chocolate into the 5th mixing bowl. +Put white chocolate chips into the 5th mixing bowl. +Fold rosemary into the 5th mixing bowl. +Siphon chocolate. + Put white chocolate chips into the 5th mixing bowl. + Remove white chocolate chips from the 5th mixing bowl. + Fold rosemary into the 5th mixing bowl. + Set aside. +Gulp until siphoned. +Quote the rosemary. + Put syrup into the 5th mixing bowl. + Fold chocolate into the 5th mixing bowl. + Set aside. +Repeat until quoted. +Put chocolate into the 1st mixing bowl. +Refrigerate. diff --git a/Task/FizzBuzz/Clay/fizzbuzz.clay b/Task/FizzBuzz/Clay/fizzbuzz.clay new file mode 100644 index 0000000000..e411b2cd9d --- /dev/null +++ b/Task/FizzBuzz/Clay/fizzbuzz.clay @@ -0,0 +1,8 @@ +main() { + for(i in range(1,100)) { + if(i % 3 == 0 and i % 5 == 0) println("fizzbuzz"); + else if(i % 3 == 0) println("fizz"); + else if(i % 5 == 0) println("buzz"); + else print(i); + } +} diff --git a/Task/FizzBuzz/Clipper/fizzbuzz.clipper b/Task/FizzBuzz/Clipper/fizzbuzz.clipper new file mode 100644 index 0000000000..6e2334b5f6 --- /dev/null +++ b/Task/FizzBuzz/Clipper/fizzbuzz.clipper @@ -0,0 +1,9 @@ +Procedure Main() + Local n + Local cFB + For n := 1 to 100 + cFB := "" + AEval( {{3,"Fizz"},{5,"Buzz"}}, {|x| cFB += Iif((n % x[1])==0, x[2], "")}) + ?? Iif(cFB == "", LTrim(Str(n)), cFB) + Iif(n == 100, ".", ", ") + Next +Return diff --git a/Task/FizzBuzz/Common-Lisp/fizzbuzz.lisp b/Task/FizzBuzz/Common-Lisp/fizzbuzz.lisp new file mode 100644 index 0000000000..ec1475db6f --- /dev/null +++ b/Task/FizzBuzz/Common-Lisp/fizzbuzz.lisp @@ -0,0 +1,22 @@ +;; Solution 1: +(defun fizzbuzz () + (loop for x from 1 to 100 do + (princ (cond ((zerop (mod x 15)) "FizzBuzz") + ((zerop (mod x 3)) "Fizz") + ((zerop (mod x 5)) "Buzz") + (t x))) + (terpri))) + +;; Solution 2: +(defun fizzbuzz () + (loop for x from 1 to 100 do + (format t "~&~{~A~}" + (or (append (when (zerop (mod x 3)) '("Fizz")) + (when (zerop (mod x 5)) '("Buzz"))) + (list x))))) + +;; Solution 3: +(defun fizzbuzz () + (loop for n from 1 to 100 + do (format t "~&~[~[FizzBuzz~:;Fizz~]~*~:;~[Buzz~*~:;~D~]~]~%" + (mod n 3) (mod n 5) n))) diff --git a/Task/FizzBuzz/D/fizzbuzz.d b/Task/FizzBuzz/D/fizzbuzz.d new file mode 100644 index 0000000000..e330fd8473 --- /dev/null +++ b/Task/FizzBuzz/D/fizzbuzz.d @@ -0,0 +1,35 @@ +import std.stdio: writeln; + +// with if-else +void fizzBuzz(int n) { + foreach (i; 1 .. n+1) + if (!(i % 15)) + writeln("FizzBuzz"); + else if (!(i % 3)) + writeln("Fizz"); + else if (!(i % 5)) + writeln("Buzz"); + else + writeln(i); +} + +// with switch case +void fizzBuzzSwitch(int n) { + foreach (i; 1 .. n+1) + switch(i % 15) { + case 0: + writeln("FizzBuzz"); break; + case 3, 6, 9, 12: + writeln("Fizz"); break; + case 5, 10: + writeln("Buzz"); break; + default: + writeln(i); + } +} + +void main() { + fizzBuzz(100); + writeln(); + fizzBuzzSwitch(100); +} diff --git a/Task/FizzBuzz/DWScript/fizzbuzz.dwscript b/Task/FizzBuzz/DWScript/fizzbuzz.dwscript new file mode 100644 index 0000000000..30ef40b04d --- /dev/null +++ b/Task/FizzBuzz/DWScript/fizzbuzz.dwscript @@ -0,0 +1,11 @@ +var i : Integer; + +for i := 1 to 100 do begin + if i mod 15 = 0 then + PrintLn('FizzBuzz') + else if i mod 3 = 0 then + PrintLn('Fizz') + else if i mod 5 = 0 then + PrintLn('Buzz') + else PrintLn(i); +end; diff --git a/Task/FizzBuzz/Dart/fizzbuzz.dart b/Task/FizzBuzz/Dart/fizzbuzz.dart new file mode 100644 index 0000000000..e47163c2a6 --- /dev/null +++ b/Task/FizzBuzz/Dart/fizzbuzz.dart @@ -0,0 +1,4 @@ +main() { + for(int i=1;i<=100;i++) + print((i%3==0?"Fizz":"")+(i%5==0?"Buzz":"")+(i%3!=0&&i%5!=0?i:"")); +} diff --git a/Task/FizzBuzz/Delphi/fizzbuzz.delphi b/Task/FizzBuzz/Delphi/fizzbuzz.delphi new file mode 100644 index 0000000000..395d23df93 --- /dev/null +++ b/Task/FizzBuzz/Delphi/fizzbuzz.delphi @@ -0,0 +1,21 @@ +program FizzBuzz; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +var + i: Integer; +begin + for i := 1 to 100 do + begin + if i mod 15 = 0 then + Writeln('FizzBuzz') + else if i mod 3 = 0 then + Writeln('Fizz') + else if i mod 5 = 0 then + Writeln('Buzz') + else + Writeln(i); + end; +end. diff --git a/Task/FizzBuzz/E/fizzbuzz.e b/Task/FizzBuzz/E/fizzbuzz.e new file mode 100644 index 0000000000..78d6caf50e --- /dev/null +++ b/Task/FizzBuzz/E/fizzbuzz.e @@ -0,0 +1,8 @@ +for i in 1..100 { + println(switch ([i % 3, i % 5]) { + match [==0, ==0] { "FizzBuzz" } + match [==0, _ ] { "Fizz" } + match [_, ==0] { "Buzz" } + match _ { i } + }) + } diff --git a/Task/FizzBuzz/Ela/fizzbuzz.ela b/Task/FizzBuzz/Ela/fizzbuzz.ela new file mode 100644 index 0000000000..ecf28db01b --- /dev/null +++ b/Task/FizzBuzz/Ela/fizzbuzz.ela @@ -0,0 +1,8 @@ +open list + +prt x | x % 15 == 0 = "FizzBuzz" + | x % 3 == 0 = "Fizz" + | x % 5 == 0 = "Buzz" + | else = x + +[1..100] |> map prt diff --git a/Task/FizzBuzz/Elixir/fizzbuzz.elixir b/Task/FizzBuzz/Elixir/fizzbuzz.elixir new file mode 100644 index 0000000000..6a67105e90 --- /dev/null +++ b/Task/FizzBuzz/Elixir/fizzbuzz.elixir @@ -0,0 +1,12 @@ +Enum.each 1..100, fn x -> + IO.puts(case { rem(x, 5) == 0, rem(x,3) == 0 } do + { true, true } -> + "FizzBuzz" + { true, false } -> + "Fizz" + { false, true } -> + "Buzz" + { false, false } -> + x + end) +end diff --git a/Task/FizzBuzz/Euphoria/fizzbuzz.euphoria b/Task/FizzBuzz/Euphoria/fizzbuzz.euphoria new file mode 100644 index 0000000000..94e55fb185 --- /dev/null +++ b/Task/FizzBuzz/Euphoria/fizzbuzz.euphoria @@ -0,0 +1,33 @@ +include std/utils.e + +function fb( atom n ) + sequence fb + if remainder( n, 15 ) = 0 then + fb = "FizzBuzz" + elsif remainder( n, 5 ) = 0 then + fb = "Fizz" + elsif remainder( n, 3 ) = 0 then + fb = "Buzz" + else + fb = sprintf( "%d", n ) + end if + return fb +end function + +function fb2( atom n ) + return iif( remainder(n, 15) = 0, "FizzBuzz", + iif( remainder( n, 5 ) = 0, "Fizz", + iif( remainder( n, 3) = 0, "Buzz", sprintf( "%d", n ) ) ) ) +end function + +for i = 1 to 30 do + printf( 1, "%s ", { fb( i ) } ) +end for + +puts( 1, "\n" ) + +for i = 1 to 30 do + printf( 1, "%s ", { fb2( i ) } ) +end for + +puts( 1, "\n" ) diff --git a/Task/Forest-fire/C-sharp/forest-fire.cs b/Task/Forest-fire/C-sharp/forest-fire.cs new file mode 100644 index 0000000000..19761750e1 --- /dev/null +++ b/Task/Forest-fire/C-sharp/forest-fire.cs @@ -0,0 +1,136 @@ +using System; + +namespace ForestFire +{ + internal class Program + { + private static void Main(string[] args) + { + Console.Write("Height? "); + int height = int.Parse(Console.ReadLine()); + Console.Write("Width? "); + int width = int.Parse(Console.ReadLine()); + Console.Write("Probability of a tree spontaneously combusting? 1/"); + int f = int.Parse(Console.ReadLine()); + Console.Write("Probability of a tree growing? 1/"); + int p = int.Parse(Console.ReadLine()); + Console.Clear(); + + var state = InitializeForestFire(height, width); + + uint generation = 0; + + do + { + state = StepForestFire(state, f, p); + + Console.SetCursorPosition(0, 0); + Console.ResetColor(); + Console.WriteLine("Generation " + ++generation); + + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + switch (state[y, x]) + { + case CellState.Empty: + Console.Write(' '); + break; + case CellState.Tree: + Console.ForegroundColor = ConsoleColor.DarkGreen; + Console.Write('T'); + break; + case CellState.Burning: + Console.ForegroundColor = ConsoleColor.DarkRed; + Console.Write('F'); + break; + } + } + + Console.WriteLine(); + } + } while (Console.ReadKey(true).Key != ConsoleKey.Q && generation < uint.MaxValue); + } + + private static CellState[,] InitializeForestFire(int height, int width) + { + // Create our state array, initialize all indices as Empty, and return it. + var state = new CellState[height, width]; + state.Initialize(); + return state; + } + + private enum CellState : byte + { + Empty = 0, + Tree = 1, + Burning = 2 + } + + private static readonly Random Random = new Random(); + + private static CellState[,] StepForestFire(CellState[,] state, int f, int p) + { + /* Clone our old state, so we can write to our new state + * without changing any values in the old state. */ + var newState = (CellState[,]) state.Clone(); + + int height = state.GetLength(0); + int width = state.GetLength(1); + + for (int i = 1; i < height - 1; i++) + { + for (int o = 1; o < width - 1; o++) + { + /* + * Check the current cell. + * + * If it's empty, give it a 1/p chance of becoming a tree. + * + * If it's a tree, check to see if any neighbors are burning. + * If so, set the cell's state to burning, otherwise give it + * a 1/f chance of combusting. + * + * If it's burning, set it to empty. + */ + switch (state[i, o]) + { + case CellState.Empty: + if (Random.Next(0, p) == 0) + newState[i, o] = CellState.Tree; + break; + case CellState.Tree: + if (IsNeighbor(state, i, o, CellState.Burning) || + Random.Next(0, f) == 0) + newState[i, o] = CellState.Burning; + break; + case CellState.Burning: + newState[i, o] = CellState.Empty; + break; + } + } + } + + return newState; + } + + private static bool IsNeighbor(CellState[,] state, int x, int y, CellState value) + { + // Check each cell within a 1 cell radius for the specified value. + for (int i = -1; i <= 1; i++) + { + for (int o = -1; o <= 1; o++) + { + if (i == 0 && o == 0) + continue; + + if (state[x + i, y + o] == value) + return true; + } + } + + return false; + } + } +} diff --git a/Task/Forest-fire/Common-Lisp/forest-fire-1.lisp b/Task/Forest-fire/Common-Lisp/forest-fire-1.lisp new file mode 100644 index 0000000000..be30d24ab7 --- /dev/null +++ b/Task/Forest-fire/Common-Lisp/forest-fire-1.lisp @@ -0,0 +1,73 @@ +(defvar *dims* '(10 10)) +(defvar *prob-t* 0.5) +(defvar *prob-f* 0.1) +(defvar *prob-p* 0.01) + +(defmacro with-gensyms (names &body body) + `(let ,(mapcar (lambda (n) (list n '(gensym))) names) + ,@body)) + +(defmacro traverse-grid (grid rowvar colvar (&rest after-cols) &body body) + (with-gensyms (dims rows cols) + `(let* ((,dims (array-dimensions ,grid)) + (,rows (car ,dims)) + (,cols (cadr ,dims))) + (dotimes (,rowvar ,rows ,grid) + (dotimes (,colvar ,cols ,after-cols) + ,@body))))) + +(defun make-new-forest (&optional (dims *dims*)) + (let ((forest (make-array dims :element-type 'symbol :initial-element 'void))) + (traverse-grid forest row col nil + (if (<= (random 1.0) *prob-t*) + (setf (aref forest row col) 'tree))))) + +(defun print-forest (forest) + (traverse-grid forest row col (terpri) + (ecase (aref forest row col) + ((void) (write-char #\space)) + ((tree) (write-char #\T)) + ((fire) (write-char #\#)))) + (values)) + +(defvar *neighboring* '((-1 . -1) (-1 . 0) (-1 . 1) + (0 . -1) (0 . 1) + (1 . -1) (1 . 0) (1 . 1))) + +(defun neighbors (forest row col) + (loop for n in *neighboring* + for nrow = (+ row (car n)) + for ncol = (+ col (cdr n)) + when (array-in-bounds-p forest nrow ncol) + collect (aref forest nrow ncol))) + +(defun evolve-tree (forest row col) + (let ((tree (aref forest row col))) + (cond ((eq tree 'fire) ;; if the tree was on fire, it's dead Jim + 'void) + ((and (eq tree 'tree) ;; if a neighbor is on fire, it's on fire too + (find 'fire (neighbors forest row col) :test #'eq)) + 'fire) + ((and (eq tree 'tree) ;; random chance of fire happening + (<= (random 1.0) *prob-f*)) + 'fire) + ((and (eq tree 'void) ;; random chance of empty space becoming a tree + (<= (random 1.0) *prob-p*)) + 'tree) + (t tree)))) + +(defun evolve-forest (forest) + (let* ((dims (array-dimensions forest)) + (new (make-array dims :element-type 'symbol :initial-element 'void))) + (traverse-grid forest row col nil + (setf (aref new row col) (evolve-tree forest row col))) + new)) + +(defun simulate (forest n &optional (print-all t)) + (format t "------ Initial forest ------~%") + (print-forest forest) + (dotimes (i n) + (setf forest (evolve-forest forest)) + (when print-all + (progn (format t "~%------ Generation ~d ------~%" (1+ i)) + (print-forest forest))))) diff --git a/Task/Forest-fire/Common-Lisp/forest-fire-2.lisp b/Task/Forest-fire/Common-Lisp/forest-fire-2.lisp new file mode 100644 index 0000000000..f5fd543b14 --- /dev/null +++ b/Task/Forest-fire/Common-Lisp/forest-fire-2.lisp @@ -0,0 +1,74 @@ +CL-USER>(defparameter *forest* (make-new-forest)) +CL-USER>(simulate *forest* 5) +------ Initial forest ------ +TTTTT TT + TTT TT + TT T T + TTTT T TT +T TT T T + T TTT + TTTT TTT + T + T T T T +TTT TTT T + +------ Generation 1 ------ +TTTTT TT + TTT TT + TT T T + TTTT T TT +T TT T T + T TTT + TTTT TTT + T + T T T T +TTT TTT T + +------ Generation 2 ------ +TTTTT TT + TTT TT + TT T T + TTTT T TT +TTTT T T + T TTT + TTT# TTT + T + T T T T +TTT TTT T + +------ Generation 3 ------ +TTTTT TT + TTT TT + TT T T + TTTT T TT +TTTT T T + # TTT + TT# TTT + T + T T T T +TTT TTT T + +------ Generation 4 ------ +TTTTT TT + TTT TT + TT T TT + TTTT T TT +TTT# T T + TTT + T# TTT + T + T T T T +TTT TTT T + +------ Generation 5 ------ +TTTTT TT + TTT TT + TT T TT + T### T TT +TT# T T + TTT + # TTT + T + T T T T +TTT TTT T +NIL diff --git a/Task/Forest-fire/D/forest-fire-1.d b/Task/Forest-fire/D/forest-fire-1.d new file mode 100644 index 0000000000..6afba53282 --- /dev/null +++ b/Task/Forest-fire/D/forest-fire-1.d @@ -0,0 +1,54 @@ +import std.stdio, std.random, std.string, std.algorithm; + +enum TREE_PROB = 0.55; // original tree probability +enum F_PROB = 0.01; // auto combustion probability +enum P_PROB = 0.01; // tree creation probability + +enum Cell : char { empty=' ', tree='T', fire='#' } +alias Cell[][] World; + +bool hasBurningNeighbours(in World world, in int r, in int c) +pure nothrow { + foreach (rowShift; -1 .. 2) + foreach (colShift; -1 .. 2) + if ((r + rowShift) >= 0 && (r + rowShift) < world.length && + (c + colShift) >= 0 && (c + colShift) < world[0].length && + world[r + rowShift][c + colShift] == Cell.fire) + return true; + return false; +} + +void nextState(in World world, World nextWorld) { + foreach (r, row; world) + foreach (c, elem; row) + final switch (elem) { + case Cell.empty: + nextWorld[r][c]= uniform(0.,1.)= 0 && (r + rowShift) < nr && + (c + colShift) >= 0 && (c + colShift) < nc && + world[r + rowShift][c + colShift] == Cell.burning) { + nextWorld[r][c] = Cell.burning; + goto END; + } + + nextWorld[r][c]=(rnd.front()/div) + +double inf() +{ + if (std::numeric_limits::has_infinity) + return std::numeric_limits::infinity(); + else + return std::numeric_limits::max(); +} diff --git a/Task/Infinity/Common-Lisp/infinity.lisp b/Task/Infinity/Common-Lisp/infinity.lisp new file mode 100644 index 0000000000..0c07186c31 --- /dev/null +++ b/Task/Infinity/Common-Lisp/infinity.lisp @@ -0,0 +1,13 @@ +> (apropos "MOST-POSITIVE" :cl) +MOST-POSITIVE-LONG-FLOAT, value: 1.7976931348623158D308 +MOST-POSITIVE-SHORT-FLOAT, value: 3.4028172S38 +MOST-POSITIVE-SINGLE-FLOAT, value: 3.4028235E38 +MOST-POSITIVE-DOUBLE-FLOAT, value: 1.7976931348623158D308 +MOST-POSITIVE-FIXNUM, value: 536870911 + +> (apropos "MOST-NEGATIVE" :cl) +MOST-NEGATIVE-SINGLE-FLOAT, value: -3.4028235E38 +MOST-NEGATIVE-LONG-FLOAT, value: -1.7976931348623158D308 +MOST-NEGATIVE-SHORT-FLOAT, value: -3.4028172S38 +MOST-NEGATIVE-DOUBLE-FLOAT, value: -1.7976931348623158D308 +MOST-NEGATIVE-FIXNUM, value: -536870912 diff --git a/Task/Infinity/D/infinity.d b/Task/Infinity/D/infinity.d new file mode 100644 index 0000000000..626205e18a --- /dev/null +++ b/Task/Infinity/D/infinity.d @@ -0,0 +1,5 @@ +auto inf() { + return typeof(1.5).infinity; +} + +void main() {} diff --git a/Task/Infinity/Delphi/infinity-1.delphi b/Task/Infinity/Delphi/infinity-1.delphi new file mode 100644 index 0000000000..3b7a07df6e --- /dev/null +++ b/Task/Infinity/Delphi/infinity-1.delphi @@ -0,0 +1,2 @@ + Infinity = 1.0 / 0.0; + NegInfinity = -1.0 / 0.0; diff --git a/Task/Infinity/Delphi/infinity-2.delphi b/Task/Infinity/Delphi/infinity-2.delphi new file mode 100644 index 0000000000..c6dcd08f1f --- /dev/null +++ b/Task/Infinity/Delphi/infinity-2.delphi @@ -0,0 +1 @@ +Math.IsInfinite() diff --git a/Task/Infinity/E/infinity.e b/Task/Infinity/E/infinity.e new file mode 100644 index 0000000000..9bdc73796c --- /dev/null +++ b/Task/Infinity/E/infinity.e @@ -0,0 +1,3 @@ +def infinityTask() { + return Infinity # predefined variable holding positive infinity +} diff --git a/Task/Infinity/Euphoria/infinity.euphoria b/Task/Infinity/Euphoria/infinity.euphoria new file mode 100644 index 0000000000..d23e9ffe6e --- /dev/null +++ b/Task/Infinity/Euphoria/infinity.euphoria @@ -0,0 +1,3 @@ +constant infinity = 1E400 + +? infinity -- outputs "inf" diff --git a/Task/JSON/C++/json.cpp b/Task/JSON/C++/json.cpp new file mode 100644 index 0000000000..af7997f33f --- /dev/null +++ b/Task/JSON/C++/json.cpp @@ -0,0 +1,14 @@ +#include "Core/Core.h" + +using namespace Upp; + +CONSOLE_APP_MAIN +{ + JsonArray a; + a << Json("name", "John")("phone", "1234567") << Json("name", "Susan")("phone", "654321"); + String txt = ~a; + Cout() << txt << '\n'; + Value v = ParseJSON(txt); + for(int i = 0; i < v.GetCount(); i++) + Cout() << v[i]["name"] << ' ' << v[i]["phone"] << '\n'; +} diff --git a/Task/JSON/C-sharp/json.cs b/Task/JSON/C-sharp/json.cs new file mode 100644 index 0000000000..8b0f82ccd6 --- /dev/null +++ b/Task/JSON/C-sharp/json.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Web.Script.Serialization; + +class Program +{ + static void Main() + { + var people = new Dictionary {{"1", "John"}, {"2", "Susan"}}; + var serializer = new JavaScriptSerializer(); + + var json = serializer.Serialize(people); + Console.WriteLine(json); + + var deserialized = serializer.Deserialize>(json); + Console.WriteLine(deserialized["2"]); + + var jsonObject = serializer.DeserializeObject(@"{ ""foo"": 1, ""bar"": [10, ""apples""] }"); + var data = jsonObject as Dictionary; + var array = data["bar"] as object[]; + Console.WriteLine(array[1]); + } +} diff --git a/Task/JSON/Cache-ObjectScript/json.cos b/Task/JSON/Cache-ObjectScript/json.cos new file mode 100644 index 0000000000..54a0be03e8 --- /dev/null +++ b/Task/JSON/Cache-ObjectScript/json.cos @@ -0,0 +1,10 @@ +Class Sample.JSON [ Abstract ] +{ + +ClassMethod GetPerson(ByRef pParms, Output pObject As %RegisteredObject) As %Status +{ + Set pObject=##class(Sample.Person).%OpenId(pParms("oid")) + Quit $$$OK +} + +} diff --git a/Task/JSON/Common-Lisp/json.lisp b/Task/JSON/Common-Lisp/json.lisp new file mode 100644 index 0000000000..df1feeba7f --- /dev/null +++ b/Task/JSON/Common-Lisp/json.lisp @@ -0,0 +1,9 @@ +(ql:quickload '("cl-json")) + +(json:encode-json + '#( ((foo . (1 2 3)) (bar . t) (baz . #\!)) + "quux" 4/17 4.25)) + +(print (with-input-from-string + (s "{\"foo\": [1, 2, 3], \"bar\": true, \"baz\": \"!\"}") + (json:decode-json s))) diff --git a/Task/JSON/D/json.d b/Task/JSON/D/json.d new file mode 100644 index 0000000000..216d2db471 --- /dev/null +++ b/Task/JSON/D/json.d @@ -0,0 +1,6 @@ +import std.stdio, std.json; + +void main() { + auto j = parseJSON("{ \"foo\": 1, \"bar\": [10, \"apples\"] }"); + writeln(toJSON(&j)); +} diff --git a/Task/JSON/EGL/json-1.egl b/Task/JSON/EGL/json-1.egl new file mode 100644 index 0000000000..e4ed5c0a5d --- /dev/null +++ b/Task/JSON/EGL/json-1.egl @@ -0,0 +1,15 @@ +record familyMember + person person; + relationships relationship[]?; +end + +record person + firstName string; + lastName string; + age int; +end + +record relationship + relationshipType string; + id int; +end diff --git a/Task/JSON/EGL/json-2.egl b/Task/JSON/EGL/json-2.egl new file mode 100644 index 0000000000..8329d24c96 --- /dev/null +++ b/Task/JSON/EGL/json-2.egl @@ -0,0 +1,22 @@ +people Person[]; // Array of people + +people.appendElement(new Person { firstName = "Frederick", lastName = "Flintstone", age = 35} ); +people.appendElement(new Person { firstName = "Wilma", lastName = "Flintstone", age = 34} ); +people.appendElement(new Person { firstName = "Pebbles", lastName = "Flintstone", age = 2} ); +people.appendElement(new Person { firstName = "Bernard", lastName = "Rubble", age = 32} ); +people.appendElement(new Person { firstName = "Elizabeth", lastName = "Rubble", age = 29} ); +people.appendElement(new Person { firstName = "Bam Bam", lastName = "Rubble", age = 2} ); + +family Dictionary; // A dictionary of family members using a uid as key +family["1"] = new FamilyMember{ person = people[1], relationships = [new Relationship{ relationshipType="spouse", id = 2 }, new Relationship{ relationshipType="child", id = 3}] }; +family["2"] = new FamilyMember{ person = people[2], relationships = [new Relationship{ relationshipType="spouse", id = 1 }, new Relationship{ relationshipType="child", id = 3}] }; +family["3"] = new FamilyMember{ person = people[3], relationships = [new Relationship{ relationshipType="mother", id = 2 }, new Relationship{ relationshipType="father", id = 1}] }; +family["4"] = new FamilyMember{ person = people[4], relationships = [new Relationship{ relationshipType="spouse", id = 5 }, new Relationship{ relationshipType="child", id = 6}] }; +family["5"] = new FamilyMember{ person = people[5], relationships = [new Relationship{ relationshipType="spouse", id = 4 }, new Relationship{ relationshipType="child", id = 6}] }; +family["6"] = new FamilyMember{ person = people[6], relationships = [new Relationship{ relationshipType="mother", id = 5 }, new Relationship{ relationshipType="father", id = 4}] }; + +// Convert dictionary of family members to JSON string +jsonString string = jsonLib.convertToJSON(family); + +// Show JSON string +SysLib.writeStdout(jsonString); diff --git a/Task/JSON/EGL/json-3.egl b/Task/JSON/EGL/json-3.egl new file mode 100644 index 0000000000..ab947205ba --- /dev/null +++ b/Task/JSON/EGL/json-3.egl @@ -0,0 +1,25 @@ +// Convert JSON string into dictionary of family members +family Dictionary; +jsonLib.convertFromJSON(jsonString, family); + +// List family members and their relationships +familyMember FamilyMember; +relation FamilyMember; + +keys string[] = family.getKeys(); +for(i int from 1 to keys.getSize()) + + SysLib.writeStdout("----------------------------------------------------"); + + familyMember = family[keys[i]]; + + SysLib.writeStdout(familyMember.person.lastName + ", " + familyMember.person.firstName + " - " + familyMember.person.age); + + for(j int from 1 to familyMember.relationships.getSize()) + id string = familyMember.relationships[j].id; + relation = family[id]; + SysLib.writeStdout(familyMember.relationships[j].relationshipType + ": " + + relation.person.lastName + ", " + relation.person.firstName); + end + +end diff --git a/Task/JSON/EGL/json-4.egl b/Task/JSON/EGL/json-4.egl new file mode 100644 index 0000000000..df99037c92 --- /dev/null +++ b/Task/JSON/EGL/json-4.egl @@ -0,0 +1,15 @@ +// Service function definition +function geocode(address String) returns (GoogleGeocoding) { + @Resource{uri = "binding:GoogleGeocodingBinding"}, + @Rest{method = _GET, uriTemplate = "/json?address={address}&sensor=false", + requestFormat = None, responseFormat = JSON} +} + +// Invoke service function +call geocode("111 Maple Street, Somewhere, CO") returning to callback; + +function callBack(result GoogleGeocoding in) + SysLib.writeStdout(result.status); + SysLib.writeStdout(result.results[1].geometry.location.lat); + SysLib.writeStdout(result.results[1].geometry.location.lng); +end diff --git a/Task/Knuth-shuffle/C++/knuth-shuffle-1.cpp b/Task/Knuth-shuffle/C++/knuth-shuffle-1.cpp new file mode 100644 index 0000000000..a97da62f90 --- /dev/null +++ b/Task/Knuth-shuffle/C++/knuth-shuffle-1.cpp @@ -0,0 +1,13 @@ +#include +#include +#include + +template +void knuthShuffle(RandomAccessIterator begin, RandomAccessIterator end) { + for(unsigned int n = end - begin - 1; n >= 1; --n) { + unsigned int k = rand() % (n + 1); + if(k != n) { + std::iter_swap(begin + k, begin + n); + } + } +} diff --git a/Task/Knuth-shuffle/C++/knuth-shuffle-2.cpp b/Task/Knuth-shuffle/C++/knuth-shuffle-2.cpp new file mode 100644 index 0000000000..95cf261faf --- /dev/null +++ b/Task/Knuth-shuffle/C++/knuth-shuffle-2.cpp @@ -0,0 +1,11 @@ +#include +#include + +int main() +{ + int array[] = { 1,2,3,4,5,6,7,8,9 }; // C-style array of integers + std::vector vec(array, array + 9); // build STL container from int array + + std::random_shuffle(array, array + 9); // shuffle C-style array + std::random_shuffle(vec.begin(), vec.end()); // shuffle STL container +} diff --git a/Task/Knuth-shuffle/CMake/knuth-shuffle-1.cmake b/Task/Knuth-shuffle/CMake/knuth-shuffle-1.cmake new file mode 100644 index 0000000000..e1ef4a4332 --- /dev/null +++ b/Task/Knuth-shuffle/CMake/knuth-shuffle-1.cmake @@ -0,0 +1,33 @@ +# shuffle( [...]) shuffles the values, and +# stores the result in a list. +function(shuffle var) + set(forever 1) + + # Receive ARGV1, ARGV2, ..., ARGV${last} as an array of values. + math(EXPR last "${ARGC} - 1") + + # Shuffle the array with Knuth shuffle (Fisher-Yates shuffle). + foreach(i RANGE ${last} 1) + # Roll j = a random number from 1 to i. + math(EXPR min "100000000 % ${i}") + while(forever) + string(RANDOM LENGTH 8 ALPHABET 0123456789 j) + if(NOT j LESS min) # Prevent modulo bias when j < min. + break() # Break loop when j >= min. + endif() + endwhile() + math(EXPR j "${j} % ${i} + 1") + + # Swap ARGV${i} with ARGV${j}. + set(t ${ARGV${i}}) + set(ARGV${i} ${ARGV${j}}) + set(ARGV${j} ${t}) + endforeach(i) + + # Convert array to list. + set(answer) + foreach(i RANGE 1 ${last}) + list(APPEND answer ${ARGV${i}}) + endforeach(i) + set("${var}" ${answer} PARENT_SCOPE) +endfunction(shuffle) diff --git a/Task/Knuth-shuffle/CMake/knuth-shuffle-2.cmake b/Task/Knuth-shuffle/CMake/knuth-shuffle-2.cmake new file mode 100644 index 0000000000..af89c0a82d --- /dev/null +++ b/Task/Knuth-shuffle/CMake/knuth-shuffle-2.cmake @@ -0,0 +1,4 @@ +shuffle(result 11 22 33 44 55 66) +message(STATUS "${result}") +# One possible output: +# -- 66;33;22;55;44;11 diff --git a/Task/Knuth-shuffle/Common-Lisp/knuth-shuffle-1.lisp b/Task/Knuth-shuffle/Common-Lisp/knuth-shuffle-1.lisp new file mode 100644 index 0000000000..e996dbfc8f --- /dev/null +++ b/Task/Knuth-shuffle/Common-Lisp/knuth-shuffle-1.lisp @@ -0,0 +1,5 @@ +(defun nshuffle (sequence) + (loop for i from (length sequence) downto 2 + do (rotatef (elt sequence (random i)) + (elt sequence (1- i)))) + sequence) diff --git a/Task/Knuth-shuffle/Common-Lisp/knuth-shuffle-2.lisp b/Task/Knuth-shuffle/Common-Lisp/knuth-shuffle-2.lisp new file mode 100644 index 0000000000..4e17b0e70d --- /dev/null +++ b/Task/Knuth-shuffle/Common-Lisp/knuth-shuffle-2.lisp @@ -0,0 +1,16 @@ +(defun nshuffle (sequence) + (etypecase sequence + (list (nshuffle-list sequence)) + (array (nshuffle-array sequence)))) + +(defun nshuffle-list (list) + "Shuffle the list using an intermediate vector." + (let ((array (nshuffle-array (coerce list 'vector)))) + (declare (dynamic-extent array)) + (map-into list 'identity array))) + +(defun nshuffle-array (array) + (loop for i from (length array) downto 2 + do (rotatef (aref array (random i)) + (aref array (1- i))) + finally (return array))) diff --git a/Task/Knuth-shuffle/D/knuth-shuffle-1.d b/Task/Knuth-shuffle/D/knuth-shuffle-1.d new file mode 100644 index 0000000000..53bbdc68ba --- /dev/null +++ b/Task/Knuth-shuffle/D/knuth-shuffle-1.d @@ -0,0 +1,7 @@ +import std.stdio, std.random; + +void main() { + auto a = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + a.randomShuffle(); + writeln(a); +} diff --git a/Task/Knuth-shuffle/D/knuth-shuffle-2.d b/Task/Knuth-shuffle/D/knuth-shuffle-2.d new file mode 100644 index 0000000000..7de58d7fdf --- /dev/null +++ b/Task/Knuth-shuffle/D/knuth-shuffle-2.d @@ -0,0 +1,12 @@ +import std.stdio, std.algorithm, std.random; + +void shuffle(Range)(Range r) { + foreach_reverse (i; 1 .. r.length) + swap(r[i], r[uniform(0, i + 1)]); +} + +void main() { + auto a = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + a.shuffle(); + writeln(a); +} diff --git a/Task/Knuth-shuffle/DWScript/knuth-shuffle.dwscript b/Task/Knuth-shuffle/DWScript/knuth-shuffle.dwscript new file mode 100644 index 0000000000..613ddaf0e0 --- /dev/null +++ b/Task/Knuth-shuffle/DWScript/knuth-shuffle.dwscript @@ -0,0 +1,9 @@ +procedure KnuthShuffle(a : array of Integer); +var + i, j, tmp : Integer; +begin + for i:=a.High downto 1 do begin + j:=RandomInt(a.Length); + tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp; + end; +end; diff --git a/Task/Knuth-shuffle/E/knuth-shuffle-1.e b/Task/Knuth-shuffle/E/knuth-shuffle-1.e new file mode 100644 index 0000000000..89d2fa454a --- /dev/null +++ b/Task/Knuth-shuffle/E/knuth-shuffle-1.e @@ -0,0 +1,9 @@ +def shuffle(array, random) { + for bound in (2..(array.size())).descending() { + def i := random.nextInt(bound) + def swapTo := bound - 1 + def t := array[swapTo] + array[swapTo] := array[i] + array[i] := t + } +} diff --git a/Task/Knuth-shuffle/E/knuth-shuffle-2.e b/Task/Knuth-shuffle/E/knuth-shuffle-2.e new file mode 100644 index 0000000000..4c62065ea1 --- /dev/null +++ b/Task/Knuth-shuffle/E/knuth-shuffle-2.e @@ -0,0 +1,6 @@ +? def arr := [1,2,3,4,5,6,7,8,9,10].diverge() +# value: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].diverge() + +? shuffle(arr, entropy) +? arr +# value: [4, 5, 2, 9, 7, 8, 1, 3, 6, 10].diverge() diff --git a/Task/Knuth-shuffle/Euphoria/knuth-shuffle.euphoria b/Task/Knuth-shuffle/Euphoria/knuth-shuffle.euphoria new file mode 100644 index 0000000000..bfe166ff30 --- /dev/null +++ b/Task/Knuth-shuffle/Euphoria/knuth-shuffle.euphoria @@ -0,0 +1,23 @@ +sequence cards +cards = repeat(0,52) +integer card,temp + +puts(1,"Before:\n") +for i = 1 to 52 do + cards[i] = i + printf(1,"%d ",cards[i]) +end for + +for i = 52 to 1 by -1 do + card = rand(i) + if card != i then + temp = cards[card] + cards[card] = cards[i] + cards[i] = temp + end if +end for + +puts(1,"\nAfter:\n") +for i = 1 to 52 do + printf(1,"%d ",cards[i]) +end for diff --git a/Task/Narcissist/Common-Lisp/narcissist.lisp b/Task/Narcissist/Common-Lisp/narcissist.lisp new file mode 100644 index 0000000000..9fdee3e1aa --- /dev/null +++ b/Task/Narcissist/Common-Lisp/narcissist.lisp @@ -0,0 +1 @@ +#1=(PRINT (EQUAL (WRITE-TO-STRING '#1# :CIRCLE 1) (READ-LINE *STANDARD-INPUT*))) diff --git a/Task/Narcissist/Deja-Vu/narcissist.djv b/Task/Narcissist/Deja-Vu/narcissist.djv new file mode 100644 index 0000000000..335c94c64e --- /dev/null +++ b/Task/Narcissist/Deja-Vu/narcissist.djv @@ -0,0 +1 @@ += concat ( over over rot chr 34 ) "= concat ( over over chr 34 ) " diff --git a/Task/Ordered-words/C++/ordered-words.cpp b/Task/Ordered-words/C++/ordered-words.cpp new file mode 100644 index 0000000000..6fa04cb22b --- /dev/null +++ b/Task/Ordered-words/C++/ordered-words.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include +#include + +// use adjacent_find to test for out-of-order letter pair +bool ordered(const std::string &word) +{ + return std::adjacent_find(word.begin(), word.end(), std::greater()) == word.end(); +} + +int main() +{ + std::ifstream infile("unixdict.txt"); + if (!infile) + { + std::cerr << "Can't open word file\n"; + return -1; + } + + std::vector words; + std::string word; + int longest = 0; + + while (std::getline(infile, word)) + { + int length = word.length(); + if (length < longest) continue; // don't test short words + + if (ordered(word)) + { + if (length > longest) + { + longest = length; // set new minimum length + words.clear(); // reset the container + } + words.push_back(word); + } + } + std::copy(words.begin(), words.end(), std::ostream_iterator(std::cout, "\n")); +} diff --git a/Task/Ordered-words/Common-Lisp/ordered-words.lisp b/Task/Ordered-words/Common-Lisp/ordered-words.lisp new file mode 100644 index 0000000000..e27c2ea889 --- /dev/null +++ b/Task/Ordered-words/Common-Lisp/ordered-words.lisp @@ -0,0 +1,26 @@ +(defun orderedp (word) + (reduce (lambda (prev curr) + (when (char> prev curr) (return-from orderedp nil)) + curr) + word) + t) + +(defun longest-ordered-words (filename) + (let ((result nil)) + (with-open-file (s filename) + (loop + with greatest-length = 0 + for word = (read-line s nil) + until (null word) + do (let ((length (length word))) + (when (and (>= length greatest-length) + (orderedp word)) + (when (> length greatest-length) + (setf greatest-length length + result nil)) + (push word result))))) + (nreverse result))) + +CL-USER> (longest-ordered-words "unixdict.txt") +("abbott" "accent" "accept" "access" "accost" "almost" "bellow" "billow" + "biopsy" "chilly" "choosy" "choppy" "effort" "floppy" "glossy" "knotty") diff --git a/Task/Ordered-words/D/ordered-words-1.d b/Task/Ordered-words/D/ordered-words-1.d new file mode 100644 index 0000000000..eaa4013a1c --- /dev/null +++ b/Task/Ordered-words/D/ordered-words-1.d @@ -0,0 +1,20 @@ +import std.stdio, std.algorithm, std.range, std.string; + +void main() { + string[] result; + size_t maxLen; + + foreach (string word; File("unixdict.txt").lines()) { + word = word.chomp(); + immutable len = walkLength(word); + if (len < maxLen || !isSorted(word)) + continue; + if (len > maxLen) { + result = [word]; + maxLen = len; + } else + result ~= word; + } + + writeln(result.join("\n")); +} diff --git a/Task/Ordered-words/D/ordered-words-2.d b/Task/Ordered-words/D/ordered-words-2.d new file mode 100644 index 0000000000..ef128f1503 --- /dev/null +++ b/Task/Ordered-words/D/ordered-words-2.d @@ -0,0 +1,19 @@ +import std.stdio, std.algorithm, std.file, std.range; + +void main() { + string[] result; + size_t maxWalkLen; + + foreach (word; std.array.splitter(readText("unixdict.txt"))) { + if (word.length >= maxWalkLen && word.isSorted()) { + immutable wlen = word.walkLength(); + if (wlen > maxWalkLen) { + result.length = 0; + maxWalkLen = wlen; + } + result ~= word.idup; + } + } + + writefln("%-(%s\n%)", result); +} diff --git a/Task/Ordered-words/D/ordered-words-3.d b/Task/Ordered-words/D/ordered-words-3.d new file mode 100644 index 0000000000..214bcb7611 --- /dev/null +++ b/Task/Ordered-words/D/ordered-words-3.d @@ -0,0 +1,7 @@ +import std.stdio, std.algorithm, std.range, std.file, std.string; + +void main() { + auto ws = "unixdict.txt".readText().split().filter!isSorted(); + immutable maxLen = ws.map!walkLength().reduce!max(); + writefln("%-(%s\n%)", ws.filter!(w => w.length == maxLen)()); +} diff --git a/Task/Ordered-words/D/ordered-words-4.d b/Task/Ordered-words/D/ordered-words-4.d new file mode 100644 index 0000000000..fffbc0bcfe --- /dev/null +++ b/Task/Ordered-words/D/ordered-words-4.d @@ -0,0 +1,44 @@ +import std.stdio, core.stdc.string, std.mmfile, std.algorithm; + +const(char)[] findWord(const char[] s) pure nothrow @safe { + // return s.takeWhile!(c => c !in "\n\r"); + size_t wordEnd = 0; + while (wordEnd < s.length && s[wordEnd] != '\n' + && s[wordEnd] != '\r') + wordEnd++; + return s[0 .. wordEnd]; +} + +void main() { + auto mmf = new MmFile("unixdict.txt", + MmFile.Mode.readCopyOnWrite, 0, null); + auto txt = cast(char[])(mmf[]); + size_t maxLen = 0, outStart = 0; + + for (size_t wordStart = 0; wordStart < txt.length; ) { + while (wordStart < txt.length && + (txt[wordStart] == '\r' || txt[wordStart] == '\n')) + wordStart++; + const word = findWord(txt[wordStart .. $]); + wordStart += word.length; + + if (word.length < maxLen || !word.isSorted()) + continue; + if (word.length > maxLen) { + // Longer ordered word found, reset the out buffer. + outStart = 0; + maxLen = word.length; + } + + // Use the same mmap'd region to store output. Because of + // Mode.readCopyOnWrite, change will not go back to file. + // We are using only the head space to store output, so + // kernel doesn't need to copy more than the words we saved, + // in this case, one page tops. + memcpy(&txt[outStart], word.ptr, word.length); + outStart += word.length; + txt[outStart++] = '\n'; // Words separator in out buffer. + } + + write(txt[0 .. outStart]); +} diff --git a/Task/Ordered-words/Delphi/ordered-words-1.delphi b/Task/Ordered-words/Delphi/ordered-words-1.delphi new file mode 100644 index 0000000000..d0ed48cf3a --- /dev/null +++ b/Task/Ordered-words/Delphi/ordered-words-1.delphi @@ -0,0 +1,54 @@ +program POrderedWords; + +{$APPTYPE CONSOLE} + +uses + SysUtils, Classes, IdHTTP; + +function IsOrdered(const s:string): Boolean; +var + I: Integer; +begin + Result := Length(s)<2; // empty or 1 char strings are ordered + for I := 2 to Length(s) do + if s[I] WordSize) then begin + Result := slInput[I] + ' '; + WordSize := Length(slInput[I]); + end; + end; + finally + slInput.Free; + end; +end; + +begin + try + WriteLn(ProcessDictionary('http://www.puzzlers.org/pub/wordlists/unixdict.txt')); + except + on E: Exception do + Writeln(E.ClassName, ': ', E.Message); + end; +end. diff --git a/Task/Ordered-words/Delphi/ordered-words-2.delphi b/Task/Ordered-words/Delphi/ordered-words-2.delphi new file mode 100644 index 0000000000..3e11d49db4 --- /dev/null +++ b/Task/Ordered-words/Delphi/ordered-words-2.delphi @@ -0,0 +1 @@ +abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty diff --git a/Task/Ordered-words/E/ordered-words-1.e b/Task/Ordered-words/E/ordered-words-1.e new file mode 100644 index 0000000000..3ce292bcc2 --- /dev/null +++ b/Task/Ordered-words/E/ordered-words-1.e @@ -0,0 +1,7 @@ +pragma.enable("accumulator") + +def words := .getText().split("\n") +def ordered := accum [] for word ? (word.sort() <=> word) in words { _.with(word) } +def maxLen := accum 0 for word in ordered { _.max(word.size()) } +def maxOrderedWords := accum [] for word ? (word.size() <=> maxLen) in ordered { _.with(word) } +println(" ".rjoin(maxOrderedWords)) diff --git a/Task/Ordered-words/E/ordered-words-2.e b/Task/Ordered-words/E/ordered-words-2.e new file mode 100644 index 0000000000..24a9d4e929 --- /dev/null +++ b/Task/Ordered-words/E/ordered-words-2.e @@ -0,0 +1,11 @@ +def best := [].diverge() +for `@word$\n` ? (word.sort() <=> word) in { + if (best.size() == 0) { + best.push(word) + } else if (word.size() > best[0].size()) { + best(0) := [word] # replace all + } else if (word.size() <=> best[0].size()) { + best.push(word) + } +} +println(" ".rjoin(best.snapshot())) diff --git a/Task/Ordered-words/Euphoria/ordered-words.euphoria b/Task/Ordered-words/Euphoria/ordered-words.euphoria new file mode 100644 index 0000000000..2c366ee528 --- /dev/null +++ b/Task/Ordered-words/Euphoria/ordered-words.euphoria @@ -0,0 +1,36 @@ +include misc.e + +type ordered(sequence s) + for i = 1 to length(s)-1 do + -- assume all items in the sequence are atoms + if s[i]>s[i+1] then + return 0 + end if + end for + return 1 +end type + +integer maxlen +sequence words +object word +constant fn = open("unixdict.txt","r") +maxlen = -1 + +while 1 do + word = gets(fn) + if atom(word) then + exit + end if + word = word[1..$-1] -- truncate new-line + if length(word) >= maxlen and ordered(word) then + if length(word) > maxlen then + maxlen = length(word) + words = {} + end if + words = append(words,word) + end if +end while + +close(fn) + +pretty_print(1,words,{2}) diff --git a/Task/Pi/C++/pi.cpp b/Task/Pi/C++/pi.cpp new file mode 100644 index 0000000000..dc4b46fa5d --- /dev/null +++ b/Task/Pi/C++/pi.cpp @@ -0,0 +1,41 @@ +#include "gmp.h" + +void agm (const mpf_t in1, const mpf_t in2, mpf_t out1, mpf_t out2) { + mpf_add (out1, in1, in2); + mpf_div_ui (out1, out1, 2); + mpf_mul (out2, in1, in2); + mpf_sqrt (out2, out2); +} + +int main (void) { + mpf_set_default_prec (300000); + mpf_t x0, y0, resA, resB, Z, var; + + mpf_init_set_ui (x0, 1); + mpf_init_set_d (y0, 0.5); + mpf_sqrt (y0, y0); + mpf_init (resA); + mpf_init (resB); + mpf_init_set_d (Z, 0.25); + mpf_init (var); + + int n = 1; + for(int i=0; i<8; i++){ + agm(x0, y0, resA, resB); + mpf_sub(var, resA, x0); + mpf_mul(var, var, var); + mpf_mul_ui(var, var, n); + mpf_sub(Z, Z, var); + n += n; + agm(resA, resB, x0, y0); + mpf_sub(var, x0, resA); + mpf_mul(var, var, var); + mpf_mul_ui(var, var, n); + mpf_sub(Z, Z, var); + n += n; + } + mpf_mul(x0, x0, x0); + mpf_div(x0, x0, Z); + gmp_printf ("%.100000Ff\n", x0); + return 0; +} diff --git a/Task/Pi/D/pi-1.d b/Task/Pi/D/pi-1.d new file mode 100644 index 0000000000..88d913a1b1 --- /dev/null +++ b/Task/Pi/D/pi-1.d @@ -0,0 +1,38 @@ +import std.stdio, std.conv, std.string; + +struct PiDigits { + immutable uint nDigits; + + int opApply(int delegate(ref string /*chunk of pi digit*/) dg){ + // Maximum width for correct output, for type ulong. + enum size_t width = 9; + + enum ulong scale = 10UL ^^ width; + enum ulong initDigit = 2UL * 10UL ^^ (width - 1); + enum string formatString = "%0" ~ text(width) ~ "d"; + + immutable size_t len = 10 * nDigits / 3; + auto arr = new ulong[len]; + arr[] = initDigit; + ulong carry; + + foreach (i; 0 .. nDigits / width) { + ulong sum; + foreach_reverse (j; 0 .. len) { + auto quo = sum * (j + 1) + scale * arr[j]; + arr[j] = quo % (j*2 + 1); + sum = quo / (j*2 + 1); + } + auto yield = format(formatString, carry + sum/scale); + if (dg(yield)) + break; + carry = sum % scale; + } + return 0; + } +} + +void main() { + foreach (d; PiDigits(100)) + writeln(d); +} diff --git a/Task/Pi/D/pi-2.d b/Task/Pi/D/pi-2.d new file mode 100644 index 0000000000..268f11e853 --- /dev/null +++ b/Task/Pi/D/pi-2.d @@ -0,0 +1,33 @@ +import std.stdio, std.bigint; + +void main() { + int ndigits = 0; + auto q = BigInt(1); + auto r = BigInt(0); + auto t = q; + auto k = q; + auto n = BigInt(3); + auto l = n; + + bool first = true; + while (ndigits < 1_000) { + if (4 * q + r - t < n * t) { + write(n); ndigits++; + if (ndigits % 70 == 0) writeln(); + if (first) { first = false; write('.'); } + auto nr = 10 * (r - n * t); + n = ((10 * (3 * q + r)) / t) - 10 * n; + q *= 10; + r = nr; + } else { + auto nr = (2 * q + r) * l; + auto nn = (q * (7 * k + 2) + r * l) / (t * l); + q *= k; + t *= l; + l += 2; + k++; + n = nn; + r = nr; + } + } +} diff --git a/Task/Quine/C++/quine.cpp b/Task/Quine/C++/quine.cpp new file mode 100644 index 0000000000..80c68af98c --- /dev/null +++ b/Task/Quine/C++/quine.cpp @@ -0,0 +1,40 @@ +#include +#include + +void quote(char const* c) +{ + while (*c) + { + switch(*c) + { + case '\\': + std::cout << "\\\\";break; + case '\n': + std::cout << "\\n";break; + case '\"': + std::cout << "\\\"";break; + default: + std::cout << *c; + } + ++c; + } +} + +int main() +{ + char const* parts[] = { + "#include \n#include \n\nvoid quote(char const* c)\n{\n while (*c)\n {\n switch(*c)\n {\n case '\\\\':\n std::cout << \"\\\\\\\\\";break;\n case '\\n':\n std::cout << \"\\\\n\";break;\n case '\\\"':\n std::cout << \"\\\\\\\"\";break;\n default:\n std::cout << *c;\n }\n ++c;\n }\n}\n\nint main()\n{\n char const* parts[] = {\n \"", + "\",\n \"", + "\"\n };\n \n std::cout << parts[0];\n quote(parts[0]);\n std::cout << parts[1];\n quote(parts[1]);\n std::cout << parts[1];\n quote(parts[2]);\n std::cout << parts[2];\n\n return 0;\n}\n" + }; + + std::cout << parts[0]; + quote(parts[0]); + std::cout << parts[1]; + quote(parts[1]); + std::cout << parts[1]; + quote(parts[2]); + std::cout << parts[2]; + + return 0; +} diff --git a/Task/Quine/C-sharp/quine.cs b/Task/Quine/C-sharp/quine.cs new file mode 100644 index 0000000000..eb51a8dde8 --- /dev/null +++ b/Task/Quine/C-sharp/quine.cs @@ -0,0 +1 @@ +class Program { static void Main() { var s = "class Program {{ static void Main() {{ var s = {0}{1}{0}; System.Console.WriteLine(s, (char)34, s); }} }}"; System.Console.WriteLine(s, (char)34, s); } } diff --git a/Task/Quine/C1R/quine.c1r b/Task/Quine/C1R/quine.c1r new file mode 100644 index 0000000000..d6ea67cf5b --- /dev/null +++ b/Task/Quine/C1R/quine.c1r @@ -0,0 +1 @@ +Quine diff --git a/Task/Quine/COBOL/quine-1.cobol b/Task/Quine/COBOL/quine-1.cobol new file mode 100644 index 0000000000..79c601ebf6 --- /dev/null +++ b/Task/Quine/COBOL/quine-1.cobol @@ -0,0 +1,339 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. GRICE. + ENVIRONMENT DIVISION. + CONFIGURATION SECTION. + SPECIAL-NAMES. + SYMBOLIC CHARACTERS FULL-STOP IS 76. + INPUT-OUTPUT SECTION. + FILE-CONTROL. + SELECT OUTPUT-FILE ASSIGN TO OUTPUT1. + DATA DIVISION. + FILE SECTION. + FD OUTPUT-FILE + RECORDING MODE F + LABEL RECORDS OMITTED. + 01 OUTPUT-RECORD PIC X(80). + WORKING-STORAGE SECTION. + 01 SUB-X PIC S9(4) COMP. + 01 SOURCE-FACSIMILE-AREA. + 02 SOURCE-FACSIMILE-DATA. + 03 FILLER PIC X(40) VALUE + " IDENTIFICATION DIVISION. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " PROGRAM-ID. GRICE. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " ENVIRONMENT DIVISION. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " CONFIGURATION SECTION. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " SPECIAL-NAMES. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " SYMBOLIC CHARACTERS FULL-STOP". + 03 FILLER PIC X(40) VALUE + " IS 76. ". + 03 FILLER PIC X(40) VALUE + " INPUT-OUTPUT SECTION. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " FILE-CONTROL. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " SELECT OUTPUT-FILE ASSIGN TO ". + 03 FILLER PIC X(40) VALUE + "OUTPUT1. ". + 03 FILLER PIC X(40) VALUE + " DATA DIVISION. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " FILE SECTION. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " FD OUTPUT-FILE ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " RECORDING MODE F ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " LABEL RECORDS OMITTED. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " 01 OUTPUT-RECORD ". + 03 FILLER PIC X(40) VALUE + " PIC X(80). ". + 03 FILLER PIC X(40) VALUE + " WORKING-STORAGE SECTION. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " 01 SUB-X ". + 03 FILLER PIC X(40) VALUE + " PIC S9(4) COMP. ". + 03 FILLER PIC X(40) VALUE + " 01 SOURCE-FACSIMILE-AREA. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " 02 SOURCE-FACSIMILE-DATA. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " 03 FILLER ". + 03 FILLER PIC X(40) VALUE + " PIC X(40) VALUE ". + 03 FILLER PIC X(40) VALUE + " 02 SOURCE-FACSIMILE-TABLE RE". + 03 FILLER PIC X(40) VALUE + "DEFINES ". + 03 FILLER PIC X(40) VALUE + " SOURCE-FACSIMILE-DATA". + 03 FILLER PIC X(40) VALUE + ". ". + 03 FILLER PIC X(40) VALUE + " 03 SOURCE-FACSIMILE OCCU". + 03 FILLER PIC X(40) VALUE + "RS 68. ". + 03 FILLER PIC X(40) VALUE + " 04 SOURCE-FACSIMILE-". + 03 FILLER PIC X(40) VALUE + "ONE PIC X(40). ". + 03 FILLER PIC X(40) VALUE + " 04 SOURCE-FACSIMILE-". + 03 FILLER PIC X(40) VALUE + "TWO PIC X(40). ". + 03 FILLER PIC X(40) VALUE + " 01 FILLER-IMAGE. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " 02 FILLER ". + 03 FILLER PIC X(40) VALUE + " PIC X(15) VALUE SPACES. ". + 03 FILLER PIC X(40) VALUE + " 02 FILLER ". + 03 FILLER PIC X(40) VALUE + " PIC X VALUE QUOTE. ". + 03 FILLER PIC X(40) VALUE + " 02 FILLER-DATA ". + 03 FILLER PIC X(40) VALUE + " PIC X(40). ". + 03 FILLER PIC X(40) VALUE + " 02 FILLER ". + 03 FILLER PIC X(40) VALUE + " PIC X VALUE QUOTE. ". + 03 FILLER PIC X(40) VALUE + " 02 FILLER ". + 03 FILLER PIC X(40) VALUE + " PIC X VALUE FULL-STOP. ". + 03 FILLER PIC X(40) VALUE + " 02 FILLER ". + 03 FILLER PIC X(40) VALUE + " PIC X(22) VALUE SPACES. ". + 03 FILLER PIC X(40) VALUE + " PROCEDURE DIVISION. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " MAIN-LINE SECTION. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " ML-1. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " OPEN OUTPUT OUTPUT-FILE. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " MOVE 1 TO SUB-X. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " ML-2. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " MOVE SOURCE-FACSIMILE (SUB-X)". + 03 FILLER PIC X(40) VALUE + " TO OUTPUT-RECORD. ". + 03 FILLER PIC X(40) VALUE + " WRITE OUTPUT-RECORD. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " IF SUB-X < 19 ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " ADD 1 TO SUB-X ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " GO TO ML-2. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " MOVE 1 TO SUB-X. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " ML-3. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " MOVE SOURCE-FACSIMILE (20) TO". + 03 FILLER PIC X(40) VALUE + " OUTPUT-RECORD. ". + 03 FILLER PIC X(40) VALUE + " WRITE OUTPUT-RECORD. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " MOVE SOURCE-FACSIMILE-ONE (SU". + 03 FILLER PIC X(40) VALUE + "B-X) TO FILLER-DATA. ". + 03 FILLER PIC X(40) VALUE + " MOVE FILLER-IMAGE TO OUTPUT-R". + 03 FILLER PIC X(40) VALUE + "ECORD. ". + 03 FILLER PIC X(40) VALUE + " WRITE OUTPUT-RECORD. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " MOVE SOURCE-FACSIMILE (20) TO". + 03 FILLER PIC X(40) VALUE + " OUTPUT-RECORD. ". + 03 FILLER PIC X(40) VALUE + " WRITE OUTPUT-RECORD. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " MOVE SOURCE-FACSIMILE-TWO (SU". + 03 FILLER PIC X(40) VALUE + "B-X) TO FILLER-DATA. ". + 03 FILLER PIC X(40) VALUE + " MOVE FILLER-IMAGE TO OUTPUT-R". + 03 FILLER PIC X(40) VALUE + "ECORD. ". + 03 FILLER PIC X(40) VALUE + " WRITE OUTPUT-RECORD. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " IF SUB-X < 68 ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " ADD 1 TO SUB-X ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " GO TO ML-3. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " MOVE 21 TO SUB-X. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " ML-4. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " MOVE SOURCE-FACSIMILE (SUB-X)". + 03 FILLER PIC X(40) VALUE + " TO OUTPUT-RECORD. ". + 03 FILLER PIC X(40) VALUE + " WRITE OUTPUT-RECORD. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " IF SUB-X < 68 ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " ADD 1 TO SUB-X ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " GO TO ML-4. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " ML-99. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " CLOSE OUTPUT-FILE. ". + 03 FILLER PIC X(40) VALUE + " ". + 03 FILLER PIC X(40) VALUE + " STOP RUN. ". + 03 FILLER PIC X(40) VALUE + " ". + 02 SOURCE-FACSIMILE-TABLE REDEFINES + SOURCE-FACSIMILE-DATA. + 03 SOURCE-FACSIMILE OCCURS 68. + 04 SOURCE-FACSIMILE-ONE PIC X(40). + 04 SOURCE-FACSIMILE-TWO PIC X(40). + 01 FILLER-IMAGE. + 02 FILLER PIC X(15) VALUE SPACES. + 02 FILLER PIC X VALUE QUOTE. + 02 FILLER-DATA PIC X(40). + 02 FILLER PIC X VALUE QUOTE. + 02 FILLER PIC X VALUE FULL-STOP. + 02 FILLER PIC X(22) VALUE SPACES. + PROCEDURE DIVISION. + MAIN-LINE SECTION. + ML-1. + OPEN OUTPUT OUTPUT-FILE. + MOVE 1 TO SUB-X. + ML-2. + MOVE SOURCE-FACSIMILE (SUB-X) TO OUTPUT-RECORD. + WRITE OUTPUT-RECORD. + IF SUB-X < 19 + ADD 1 TO SUB-X + GO TO ML-2. + MOVE 1 TO SUB-X. + ML-3. + MOVE SOURCE-FACSIMILE (20) TO OUTPUT-RECORD. + WRITE OUTPUT-RECORD. + MOVE SOURCE-FACSIMILE-ONE (SUB-X) TO FILLER-DATA. + MOVE FILLER-IMAGE TO OUTPUT-RECORD. + WRITE OUTPUT-RECORD. + MOVE SOURCE-FACSIMILE (20) TO OUTPUT-RECORD. + WRITE OUTPUT-RECORD. + MOVE SOURCE-FACSIMILE-TWO (SUB-X) TO FILLER-DATA. + MOVE FILLER-IMAGE TO OUTPUT-RECORD. + WRITE OUTPUT-RECORD. + IF SUB-X < 68 + ADD 1 TO SUB-X + GO TO ML-3. + MOVE 21 TO SUB-X. + ML-4. + MOVE SOURCE-FACSIMILE (SUB-X) TO OUTPUT-RECORD. + WRITE OUTPUT-RECORD. + IF SUB-X < 68 + ADD 1 TO SUB-X + GO TO ML-4. + ML-99. + CLOSE OUTPUT-FILE. + STOP RUN. diff --git a/Task/Quine/COBOL/quine-2.cobol b/Task/Quine/COBOL/quine-2.cobol new file mode 100644 index 0000000000..412e295df7 --- /dev/null +++ b/Task/Quine/COBOL/quine-2.cobol @@ -0,0 +1,48 @@ + ID DIVISION. + PROGRAM-ID. QUINE. + DATA DIVISION. + WORKING-STORAGE SECTION. + 1 X PIC S9(4) COMP. + 1 A. 2 B. + 3 PIC X(40) VALUE " ID DIVISION. ". + 3 PIC X(40) VALUE " ". + 3 PIC X(40) VALUE " PROGRAM-ID. QUINE. ". + 3 PIC X(40) VALUE " ". + 3 PIC X(40) VALUE " DATA DIVISION. ". + 3 PIC X(40) VALUE " ". + 3 PIC X(40) VALUE " WORKING-STORAGE SECTION. ". + 3 PIC X(40) VALUE " ". + 3 PIC X(40) VALUE " 1 X PIC S9(4) COMP. ". + 3 PIC X(40) VALUE " ". + 3 PIC X(40) VALUE " 1 A. 2 B. ". + 3 PIC X(40) VALUE " ". + 3 PIC X(40) VALUE " 2 T REDEFINES B. 3 TE OCCURS 16. ". + 3 PIC X(40) VALUE "4 T1 PIC X(40). 4 T2 PIC X(40). ". + 3 PIC X(40) VALUE " 1 F. 2 PIC X(25) VALUE ". + 3 PIC X(40) VALUE "' 3 PIC X(40) VALUE '. ". + 3 PIC X(40) VALUE " 2 PIC X VALUE QUOTE. 2 FF PIC X(4". + 3 PIC X(40) VALUE "0). 2 PIC X VALUE QUOTE. ". + 3 PIC X(40) VALUE " 2 PIC X VALUE '.'. ". + 3 PIC X(40) VALUE " ". + 3 PIC X(40) VALUE " PROCEDURE DIVISION. ". + 3 PIC X(40) VALUE " ". + 3 PIC X(40) VALUE " PERFORM VARYING X FROM 1 BY 1". + 3 PIC X(40) VALUE " UNTIL X > 6 DISPLAY TE (X) ". + 3 PIC X(40) VALUE " END-PERFORM PERFORM VARYING X". + 3 PIC X(40) VALUE " FROM 1 BY 1 UNTIL X > 16 ". + 3 PIC X(40) VALUE " MOVE T1 (X) TO FF DISPLAY F M". + 3 PIC X(40) VALUE "OVE T2 (X) TO FF DISPLAY F ". + 3 PIC X(40) VALUE " END-PERFORM PERFORM VARYING X". + 3 PIC X(40) VALUE " FROM 7 BY 1 UNTIL X > 16 ". + 3 PIC X(40) VALUE " DISPLAY TE (X) END-PERFORM ST". + 3 PIC X(40) VALUE "OP RUN. ". + 2 T REDEFINES B. 3 TE OCCURS 16. 4 T1 PIC X(40). 4 T2 PIC X(40). + 1 F. 2 PIC X(25) VALUE ' 3 PIC X(40) VALUE '. + 2 PIC X VALUE QUOTE. 2 FF PIC X(40). 2 PIC X VALUE QUOTE. + 2 PIC X VALUE '.'. + PROCEDURE DIVISION. + PERFORM VARYING X FROM 1 BY 1 UNTIL X > 6 DISPLAY TE (X) + END-PERFORM PERFORM VARYING X FROM 1 BY 1 UNTIL X > 16 + MOVE T1 (X) TO FF DISPLAY F MOVE T2 (X) TO FF DISPLAY F + END-PERFORM PERFORM VARYING X FROM 7 BY 1 UNTIL X > 16 + DISPLAY TE (X) END-PERFORM STOP RUN. diff --git a/Task/Quine/Common-Lisp/quine-1.lisp b/Task/Quine/Common-Lisp/quine-1.lisp new file mode 100644 index 0000000000..199b2110be --- /dev/null +++ b/Task/Quine/Common-Lisp/quine-1.lisp @@ -0,0 +1,2 @@ +((lambda (s) (print (list s (list 'quote s)))) + '(lambda (s) (print (list s (list 'quote s))))) diff --git a/Task/Quine/Common-Lisp/quine-2.lisp b/Task/Quine/Common-Lisp/quine-2.lisp new file mode 100644 index 0000000000..1a29bc200b --- /dev/null +++ b/Task/Quine/Common-Lisp/quine-2.lisp @@ -0,0 +1 @@ +((lambda (s) (print `(,s ',s))) '(lambda (s) (print `(,s ',s)))) diff --git a/Task/Quine/Common-Lisp/quine-3.lisp b/Task/Quine/Common-Lisp/quine-3.lisp new file mode 100644 index 0000000000..7307eeb486 --- /dev/null +++ b/Task/Quine/Common-Lisp/quine-3.lisp @@ -0,0 +1 @@ +#1=(write '#1# :circle t) diff --git a/Task/Quine/Common-Lisp/quine-4.lisp b/Task/Quine/Common-Lisp/quine-4.lisp new file mode 100644 index 0000000000..635a58522b --- /dev/null +++ b/Task/Quine/Common-Lisp/quine-4.lisp @@ -0,0 +1 @@ +#1=(progn (setq *print-circle* t) (write '#1#)) diff --git a/Task/Quine/Common-Lisp/quine-5.lisp b/Task/Quine/Common-Lisp/quine-5.lisp new file mode 100644 index 0000000000..844366ab77 --- /dev/null +++ b/Task/Quine/Common-Lisp/quine-5.lisp @@ -0,0 +1 @@ +(format t #1='"(format t #1='~s #1#)" #1#) diff --git a/Task/Quine/Common-Lisp/quine-6.lisp b/Task/Quine/Common-Lisp/quine-6.lisp new file mode 100644 index 0000000000..bc6a80caad --- /dev/null +++ b/Task/Quine/Common-Lisp/quine-6.lisp @@ -0,0 +1 @@ +(write -) diff --git a/Task/Quine/D/quine.d b/Task/Quine/D/quine.d new file mode 100644 index 0000000000..67d1ef4530 --- /dev/null +++ b/Task/Quine/D/quine.d @@ -0,0 +1,3 @@ +const auto s=`const auto q="const auto s=\x60"~s~"\x60; +mixin(s);";import std.stdio;void main(){writefln(q);pragma(msg,q);}`; +mixin(s); diff --git a/Task/Quine/Dao/quine.dao b/Task/Quine/Dao/quine.dao new file mode 100644 index 0000000000..827769e2f8 --- /dev/null +++ b/Task/Quine/Dao/quine.dao @@ -0,0 +1 @@ +syntax{Q $EXP}as{io.writef('syntax{Q $EXP}as{%s}Q %s',\'$EXP\',\'$EXP\')}Q io.writef('syntax{Q $EXP}as{%s}Q %s',\'$EXP\',\'$EXP\') diff --git a/Task/Quine/Deja-Vu/quine.djv b/Task/Quine/Deja-Vu/quine.djv new file mode 100644 index 0000000000..5645bb280f --- /dev/null +++ b/Task/Quine/Deja-Vu/quine.djv @@ -0,0 +1,2 @@ +"print . dup" +print . dup diff --git a/Task/Quine/E/quine.e b/Task/Quine/E/quine.e new file mode 100644 index 0000000000..ed7dc1d0bc --- /dev/null +++ b/Task/Quine/E/quine.e @@ -0,0 +1 @@ +" =~ x; println(E.toQuote(x),x)" =~ x; println(E.toQuote(x),x) diff --git a/Task/Quine/Euphoria/quine.euphoria b/Task/Quine/Euphoria/quine.euphoria new file mode 100644 index 0000000000..ab3f0680cc --- /dev/null +++ b/Task/Quine/Euphoria/quine.euphoria @@ -0,0 +1 @@ +constant p="constant p=%s%s%s printf(1,p,{34,p,34})" printf(1,p,{34,p,34}) diff --git a/Task/Search-a-list/C++/search-a-list.cpp b/Task/Search-a-list/C++/search-a-list.cpp new file mode 100644 index 0000000000..ee26949aa1 --- /dev/null +++ b/Task/Search-a-list/C++/search-a-list.cpp @@ -0,0 +1,112 @@ +#include +#include +#include +#include +#include +#include + +// an exception to throw (actually, throwing an exception in this case is generally considered bad style, but it's part of the task) +class not_found: public std::exception +{ +public: + not_found(std::string const& s): text(s + " not found") {} + char const* what() const throw() { return text.c_str(); } + ~not_found() throw() {} +private: + std::string text; +}; + +// needle search function, C-style interface version using standard library +std::size_t get_index(std::string* haystack, int haystack_size, std::string needle) +{ + std::size_t index = std::find(haystack, haystack+haystack_size, needle) - haystack; + if (index == haystack_size) + throw not_found(needle); + else + return index; +} + +// needle search function, completely generic style, needs forward iterators +// (works with any container, but inefficient if not random-access-iterator) +template + typename std::iterator_traits::difference_type fwd_get_index(FwdIter first, FwdIter last, std::string needle) +{ + FwdIter elem = std::find(first, last, needle); + if (elem == last) + throw not_found(needle); + else + return std::distance(first, elem); +} + +// needle search function, implemented directly, needs only input iterator, works efficiently with all sequences +template + typename std::iterator_traits::difference_type generic_get_index(InIter first, InIter last, std::string needle) +{ + typename std::iterator_traits::difference_type index = 0; + while (first != last && *first != needle) + { + ++index; + ++first; + } + if (first == last) + throw not_found(needle); + else + return index; +} + +// ---------------------------------------------------------------------------------------------------------------------------------- + +// a sample haystack (content copied from Haskell example) +std::string haystack[] = { "Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty", "Charlie", "Bush", "Bozo" }; + +// some useful helper functions +template T* begin(T (&array)[sz]) { return array; } +template T* end(T (&array)[sz]) { return array + sz; } +template std::size_t size(T (&array)[sz]) { return sz; } + +// test function searching a given needle with each of the methods +void test(std::string const& needle) +{ + std::cout << "-- C style interface --\n"; + try + { + std::size_t index = get_index(haystack, size(haystack), needle); + std::cout << needle << " found at index " << index << "\n"; + } + catch(std::exception& exc) // better catch standard exceptions as well; me might e.g. run out of memory + { + std::cout << exc.what() << "\n"; + } + + std::cout << "-- generic interface, first version --\n"; + try + { + std::size_t index = fwd_get_index(begin(haystack), end(haystack), needle); + std::cout << needle << " found at index " << index << "\n"; + } + catch(std::exception& exc) // better catch standard exceptions as well; me might e.g. run out of memory + { + std::cout << exc.what() << "\n"; + } + + std::cout << "-- generic interface, second version --\n"; + try + { + std::size_t index = generic_get_index(begin(haystack), end(haystack), needle); + std::cout << needle << " found at index " << index << "\n"; + } + catch(std::exception& exc) // better catch standard exceptions as well; me might e.g. run out of memory + { + std::cout << exc.what() << "\n"; + } +} + +int main() +{ + std::cout << "\n=== Word which only occurs once ===\n"; + test("Wally"); + std::cout << "\n=== Word occuring multiple times ===\n"; + test("Bush"); + std::cout << "\n=== Word not occuring at all ===\n"; + test("Goofy"); +} diff --git a/Task/Search-a-list/Common-Lisp/search-a-list.lisp b/Task/Search-a-list/Common-Lisp/search-a-list.lisp new file mode 100644 index 0000000000..466d2327ae --- /dev/null +++ b/Task/Search-a-list/Common-Lisp/search-a-list.lisp @@ -0,0 +1,6 @@ +(let ((haystack '(Zig Zag Wally Ronald Bush Krusty Charlie Bush Bozo))) + (dolist (needle '(Washington Bush)) + (let ((index (position needle haystack))) + (if index + (progn (print index) (princ needle)) + (progn (print needle) (princ "is not in haystack")))))) diff --git a/Task/Search-a-list/D/search-a-list.d b/Task/Search-a-list/D/search-a-list.d new file mode 100644 index 0000000000..308cbded5b --- /dev/null +++ b/Task/Search-a-list/D/search-a-list.d @@ -0,0 +1,18 @@ +import std.algorithm, std.range, std.string; + +auto firstIndex(R, T)(R hay, T needle) { + auto i = countUntil(hay, needle); + if (i == -1) + throw new Exception("No needle found in haystack"); + return i; +} + +auto lastIndex(R, T)(R hay, T needle) { + return walkLength(hay) - firstIndex(retro(hay), needle) - 1; +} + +void main() { + auto h = split("Zig Zag Wally Ronald Bush Krusty Charlie Bush Bozo"); + assert(firstIndex(h, "Bush") == 4); + assert(lastIndex(h, "Bush") == 7); +} diff --git a/Task/Search-a-list/DWScript/search-a-list.dwscript b/Task/Search-a-list/DWScript/search-a-list.dwscript new file mode 100644 index 0000000000..13ba05b245 --- /dev/null +++ b/Task/Search-a-list/DWScript/search-a-list.dwscript @@ -0,0 +1,11 @@ +var haystack : array of String = ["Zig","Zag","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo"]; + +function Find(what : String) : Integer; +begin + Result := haystack.IndexOf(what); + if Result < 0 then + raise Exception.Create('not found'); +end; + +PrintLn(Find("Ronald")); // 3 +PrintLn(Find('McDonald')); // exception diff --git a/Task/Search-a-list/Delphi/search-a-list.delphi b/Task/Search-a-list/Delphi/search-a-list.delphi new file mode 100644 index 0000000000..b597a1f3d7 --- /dev/null +++ b/Task/Search-a-list/Delphi/search-a-list.delphi @@ -0,0 +1,36 @@ +program Needle; + +{$APPTYPE CONSOLE} + +uses + SysUtils, Classes; + +var + list: TStringList; + needle: string; + ind: Integer; +begin + list := TStringList.Create; + try + list.Append('triangle'); + list.Append('fork'); + list.Append('limit'); + list.Append('baby'); + list.Append('needle'); + + list.Sort; + + needle := 'needle'; + ind := list.IndexOf(needle); + if ind < 0 then + raise Exception.Create('Needle not found') + else begin + Writeln(ind); + Writeln(list[ind]); + end; + + Readln; + finally + list.Free; + end; +end. diff --git a/Task/Search-a-list/E/search-a-list.e b/Task/Search-a-list/E/search-a-list.e new file mode 100644 index 0000000000..9cba25b355 --- /dev/null +++ b/Task/Search-a-list/E/search-a-list.e @@ -0,0 +1,12 @@ +def haystack := ["Zig","Zag","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo"] + +/** meet the 'raise an exception' requirement */ +def find(needle) { + switch (haystack.indexOf1(needle)) { + match ==(-1) { throw("an exception") } + match index { return index } + } +} + +println(find("Ronald")) # prints 3 +println(find("McDonald")) # will throw diff --git a/Task/Search-a-list/Euphoria/search-a-list.euphoria b/Task/Search-a-list/Euphoria/search-a-list.euphoria new file mode 100644 index 0000000000..d7d36d9c4b --- /dev/null +++ b/Task/Search-a-list/Euphoria/search-a-list.euphoria @@ -0,0 +1,46 @@ +include std/search.e +include std/console.e + +--the string "needle" and example haystacks to test the procedure +sequence searchStr1 = "needle" +sequence haystack1 = { "needle", "needle", "noodle", "node", "need", "needle ", "needle" } +sequence haystack2 = {"spoon", "fork", "hay", "knife", "needle", "barn", "etcetera", "more hay", "needle", "a cow", "farmer", "needle", "dirt"} +sequence haystack3 = {"needle"} +sequence haystack4 = {"no", "need le s", "in", "this", "haystack"} +sequence haystack5 = {"knee", "needle", "dull", "needle"} +sequence haystack6 = {} + +--search procedure with console output +procedure haystackSearch(sequence hStack) + sequence foundNeedles = find_all(searchStr1, hStack) + puts(1,"---------------------------------\r\n") + if object(foundNeedles) and length(foundNeedles) > 0 then + printf(1, "First needle found at index %d \r\n", foundNeedles[1]) + + if length(foundNeedles) > 1 then + printf(1, "Last needle found at index %d \r\n", foundNeedles[length(foundNeedles)] ) + + for i = 1 to length(foundNeedles) do + printf(1, "Needle #%d ", i) + printf(1, "was at index %d .\r\n", foundNeedles[i]) + end for + + else + puts(1, "There was only one needle found in this haystack. \r\n") + end if + + else + puts(1, "Simulated exception - No needles found in this haystack.\r\n") + end if + +end procedure + +--runs the procedure on all haystacks +haystackSearch(haystack1) +haystackSearch(haystack2) +haystackSearch(haystack3) +haystackSearch(haystack4) +haystackSearch(haystack5) +haystackSearch(haystack6) +--wait for user to press a key to exit +any_key()